diff --git a/.gitmodules b/.gitmodules index ed0df4b60..614ca1471 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,3 +24,6 @@ url=https://github.com/libigl/nanogui.git [submodule "external/CoMISo"] path = external/CoMISo url = https://github.com/libigl/CoMISo.git +[submodule "external/cork"] + path = external/cork + url = https://github.com/libigl/cork.git diff --git a/external/cork b/external/cork new file mode 160000 index 000000000..adf814edd --- /dev/null +++ b/external/cork @@ -0,0 +1 @@ +Subproject commit adf814edd555cb4245edf6f539eddb7880edf195 diff --git a/external/cork/.gitignore b/external/cork/.gitignore deleted file mode 100644 index 73394cb63..000000000 --- a/external/cork/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ - -bin/ -depend/ -include/ -lib/ -obj/ - -error_log.txt - -win/wincork/Debug -win/wincork/Release -win/wincork/*.suo -win/wincork/*.vcxproj.user -win/wincork/*.sdf -win/wincork/*.opensdf - -# in case you're on mac -.DS_Store - diff --git a/external/cork/COPYRIGHT b/external/cork/COPYRIGHT deleted file mode 100644 index ba2038749..000000000 --- a/external/cork/COPYRIGHT +++ /dev/null @@ -1,205 +0,0 @@ - -Cork is - Copyright Gilbert Bernstein 2013 -and made available through the GNU LGPL (see below w/ template exception) -Please contact the author at - gilbert@gilbertbernstein.com -if you would like to discuss licensing under other terms. - -Triangle (used by Franky) is Copyright Jonathan Shewchuk according to the terms spelled out in the comments of triangle.c - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. - - -======================================================================== - -( The following exception for templates is taken from the Qt project ) - -Digia Qt LGPL Exception version 1.1 - -As an additional permission to the GNU Lesser General Public License version -2.1, the object code form of a "work that uses the Library" may incorporate -material from a header file that is part of the Library. You may distribute -such object code under terms of your choice, provided that: - (i) the header files of the Library have not been modified; and - (ii) the incorporated material is limited to numerical parameters, data - structure layouts, accessors, macros, inline functions and - templates; and - (iii) you comply with the terms of Section 6 of the GNU Lesser General - Public License version 2.1. - -Moreover, you may apply this exception to a modified version of the Library, -provided that such modification does not involve copying material from the -Library into the modified Library's header files unless such material is -limited to (i) numerical parameters; (ii) data structure layouts; -(iii) accessors; and (iv) small macros, templates and inline functions of -five lines or less in length. - -Furthermore, you are not required to apply this additional permission to a -modified version of the Library. - diff --git a/external/cork/Makefile b/external/cork/Makefile deleted file mode 100644 index ece27ffcd..000000000 --- a/external/cork/Makefile +++ /dev/null @@ -1,249 +0,0 @@ -# Warning: This makefile rampantly assumes it is being run in UNIX -# Also, there may be some gnu tool chain assumptions: gcc and gmake? - -# *********** -# * PREFACE * -# ***********------+ -# | Subdirectories | -# +----------------+ -# declare subdirectories of the source directory -SUBDIRECTORIES := util file_formats math isct mesh rawmesh accel - -# make sure the subdirectories are mirrored in -# the obj/ debug/ and depend/ directories -# (HACK: use this dummy variable to get access to shell commands) -SHELL_HACK := $(shell mkdir -p bin lib include) -SHELL_HACK := $(shell mkdir -p $(addprefix obj/,$(SUBDIRECTORIES))) -SHELL_HACK := $(shell mkdir -p $(addprefix debug/,$(SUBDIRECTORIES))) -SHELL_HACK := $(shell mkdir -p $(addprefix depend/,$(SUBDIRECTORIES))) -# also make a directory to expose headers in -#SHELL_HACK := $(shell mkdir -p $(addprefix include/,$(SUBDIRECTORIES))) - -# +----------+ -# | Platform | -# +----------+------------------- -# | evaluates to 'Darwin' on mac -# | evaluates to ??? on ??? -# +------------------------------ -PLATFORM := $(shell uname) - --include makeConstants - - -# ********* -# * TOOLS * -# *********--+ -# | Programs | -# +----------+ -CPP11_FLAGS := -std=c++11 -#include ../../build/Makefile.conf -#CC := ${GG} -#CXX := ${GG} -ifeq ($(PLATFORM),Darwin) # on mac - CPP11_FLAGS := $(CPP11_FLAGS) -Wno-c++11-extensions -endif -RM := rm -CP := cp - -# +--------------+ -# | Option Flags | -# +--------------+ -# Let the preprocessor know which platform we're on -ifeq ($(PLATFORM),Darwin) - CONFIG := $(CONFIG) -DMACOSX -else - CONFIG := $(CONFIG) -endif - -# include paths (flattens the hierarchy for include directives) -INC := -I src/ $(addprefix -I src/,$(SUBDIRECTORIES)) -# get the location of GMP header files from makeConstants include file -GMP_INC_DIR := /opt/local/include/ -GMPINC := -I $(GMP_INC_DIR) -INC := $(INC) $(GMPINC) - -# use the second line to disable profiling instrumentation -# PROFILING := -pg -PROFILING := -CCFLAGS := -Wall $(INC) $(CONFIG) -O2 -DNDEBUG $(PROFILING) -CXXFLAGS := $(CCFLAGS) $(CPP11_FLAGS) -CCDFLAGS := -Wall $(INC) $(CONFIG) -ggdb -CXXDFLAGS := $(CCDFLAGS) - -# Place the location of GMP libraries here -GMP_LIB_DIR := /opt/local/lib -GMPLD := -L$(GMP_LIB_DIR) -lgmpxx -lgmp -# static version... -#GMPLD := $(GMP_LIB_DIR)/libgmpxx.a $(GMP_LIB_DIR)/libgmp.a - -LINK := $(CXXFLAGS) $(GMPLD) -LINKD := $(CXXDFLAGS) $(GMPLD) -ifeq ($(PLATFORM),Darwin) - LINK := $(LINK) -Wl,-no_pie - LINKD := $(LINK) -Wl,-no_pie -endif - - -# *********************** -# * SOURCE DECLARATIONS * -# ***********************-----------------+ -# | SRCS defines a generic bag of sources | -# +---------------------------------------+ -MATH_SRCS := -UTIL_SRCS := timer log -ISCT_SRCS := empty3d quantization -MESH_SRCS := -RAWMESH_SRCS := -ACCEL_SRCS := -FILE_SRCS := files ifs off -SRCS := \ - cork \ - $(addprefix math/,$(MATH_SRCS))\ - $(addprefix util/,$(UTIL_SRCS))\ - $(addprefix isct/,$(ISCT_SRCS))\ - $(addprefix mesh/,$(MESH_SRCS))\ - $(addprefix rawmesh/,$(RAWMESH_SRCS))\ - $(addprefix accel/,$(ACCEL_SRCS))\ - $(addprefix file_formats/,$(FILE_SRCS)) - - -# +-----------------------------------+ -# | HEADERS defines headers to export | -# +-----------------------------------+ -MATH_HEADERS := vec.h bbox.h ray.h -UTIL_HEADERS := prelude.h memPool.h iterPool.h shortVec.h \ - unionFind.h -ISCT_HEADERS := unsafeRayTriIsct.h \ - ext4.h fixext4.h gmpext4.h absext4.h \ - quantization.h fixint.h \ - empty3d.h \ - triangle.h -RAWMESH_HEADERS := rawMesh.h rawMesh.tpp -MESH_HEADERS := mesh.h mesh.decl.h \ - mesh.tpp mesh.topoCache.tpp \ - mesh.remesh.tpp mesh.isct.tpp mesh.bool.tpp -ACCEL_HEADERS := aabvh.h -FILE_HEADERS := files.h -HEADERS := \ - cork.h -# $(addprefix math/,$(MATH_HEADERS))\ -# $(addprefix util/,$(UTIL_HEADERS))\ -# $(addprefix isct/,$(ISCT_HEADERS))\ -# $(addprefix mesh/,$(MESH_HEADERS))\ -# $(addprefix rawmesh/,$(RAWMESH_HEADERS))\ -# $(addprefix accel/,$(ACCEL_HEADERS))\ -# $(addprefix file_formats/,$(FILE_HEADERS)) -HEADER_COPIES := $(addprefix include/,$(HEADERS)) - -# +-----------------------------+ -# | stand alone program sources | -# +-----------------------------+ -MAIN_SRC := \ - $(SRCS) \ - main - -# +---------------------------------------+ -# | all sources for dependency generation | -# +---------------------------------------+ -ALL_SRCS := \ - $(SRCS)\ - main -DEPENDS := $(addprefix depend/,$(addsuffix .d,$(ALL_SRCS))) - -# +--------------------------------+ -# | Object Aggregation for Targets | -# +--------------------------------+ - -OBJ := $(addprefix obj/,$(addsuffix .o,$(SRCS))) \ - obj/isct/triangle.o -DEBUG := $(addprefix debug/,$(addsuffix .o,$(SRCS))) \ - obj/isct/triangle.o - -MAIN_OBJ := $(addprefix obj/,$(addsuffix .o,$(MAIN_SRC))) \ - obj/isct/triangle.o -MAIN_DEBUG := $(addprefix debug/,$(addsuffix .o,$(MAIN_SRC))) \ - obj/isct/triangle.o - -LIB_TARGET_NAME := cork - -# ********* -# * RULES * -# *********------+ -# | Target Rules | -# +--------------+ -all: lib/lib$(LIB_TARGET_NAME).a includes \ - bin/off2obj bin/cork -debug: lib/lib$(LIB_TARGET_NAME)debug.a includes - -lib/lib$(LIB_TARGET_NAME).a: $(OBJ) - @echo "Bundling $@" - @ar rcs $@ $(OBJ) - -lib/lib$(LIB_TARGET_NAME)debug.a: $(DEBUG) - @echo "Bundling $@" - @ar rcs $@ $(DEBUG) - -bin/cork: $(MAIN_OBJ) - @echo "Linking cork command line tool" - @$(CXX) -o bin/cork $(MAIN_OBJ) $(LINK) - -bin/off2obj: obj/off2obj.o - @echo "Linking off2obj" - @$(CXX) -o bin/off2obj obj/off2obj.o $(LINK) - -# +------------------------------+ -# | Specialized File Build Rules | -# +------------------------------+ - -obj/isct/triangle.o: src/isct/triangle.c - @echo "Compiling the Triangle library" - @$(CC) -x c -O2 -DNO_TIMER \ - -DREDUCED \ - -DCDT_ONLY -DTRILIBRARY \ - -Wall -DANSI_DECLARATORS \ - -o obj/isct/triangle.o -c src/isct/triangle.c - -# +------------------------------------+ -# | Generic Source->Object Build Rules | -# +------------------------------------+ -obj/%.o: src/%.cpp - @echo "Compiling $@" - @$(CXX) $(CXXFLAGS) -o $@ -c $< - -debug/%.o: src/%.cpp - @echo "Compiling $@" - @$(CXX) $(CXXDFLAGS) -o $@ -c $< - -# dependency file build rules -depend/%.d: src/%.cpp - @$(CXX) $(CXXFLAGS) -MM $< | \ - sed -e 's@^\(.*\)\.o:@depend/$*.d debug/$*.o obj/$*.o:@' > $@ - -# +-------------------+ -# | include copy rule | -# +-------------------+--------------------- -# | This rule exists to safely propagate -# | header file dependencies to other -# | targets that depend on the common code -# +----------------------------------------- -includes: $(HEADER_COPIES) - -include/%.h: src/%.h - @echo "updating $@" - @cp $< $@ -#also support template implementation files -include/%.tpp: src/%.tpp - @echo "updating $@" - @cp $< $@ - -# +---------------+ -# | cleaning rule | -# +---------------+ -clean: - -@$(RM) -r obj depend debug include bin lib - -@$(RM) bin/off2obj -# -@$(RM) gmon.out - -@$(RM) lib/lib$(LIB_TARGET_NAME).a - -@$(RM) lib/lib$(LIB_TARGET_NAME)debug.a - --include $(DEPENDS) diff --git a/external/cork/README.md b/external/cork/README.md deleted file mode 100644 index 49a6755fe..000000000 --- a/external/cork/README.md +++ /dev/null @@ -1,64 +0,0 @@ -Cork Boolean Library -==================== - -Welcome to the Cork Boolean/CSG library. Cork is designed to support Boolean operations between triangle meshes. - -Surprisingly, most Boolean/CSG libraries available today (early 2013) are not robust to numerical errors. Floating-point errors often lead to segmentation faults or produce grossly inaccurate results (e.g. nothing) despite the code being provided . The few libraries which are robust (e.g. CGAL) require the user to correctly configure the arithmetic settings to ensure robustness. - -Cork is designed with the philosophy that you, the user, don't know and don't care about esoteric problems with floating point arithmetic. You just want a Boolean library with a simple interface, that you can rely on... Unfortunately since Cork is still in ongoing development, this may be more or less true at the moment. This code should be very usable for a research project, perhaps slightly less so for use in a product. - -Cork was developed by Gilbert Bernstein, a computer scientist who has worked on robust geometric intersections in various projects since 2007. He's reasonably confident he knows what he's doing. =D - - -Installation -============ - -Dependencies (Mac/Linux) ------------- - -In order to build Cork on Mac or Linux, you will need Clang 3.1+ and GMP (GNU Multi-Precision arithmetic library). Eventually, Cork will support GCC. If you would like more information, or have special system requirements, please e-mail me: I'm much more likely to extend support to a platform if I receive requests. - -Mac ---- - -On OS X 10.8, Clang 3.1+ is the default compiler. If you are using the Homebrew package manager, I recommend installing GMP that way. - -Linux ------ - -Clang/LLVM 3.1 and GMP can be installed via your package manager. - - -Mac/Linux ----- - -To build the project, type - - make - -that's it. - - -If the build system is unable to find your GMP installation, please edit the paths in file makeConstants. In general, the project uses a basic makefile. In the event that you have to do something more complicated to get the library to compile, or if you are unable to get it to compile, please e-mail me or open an issue on GitHub. Doing so is much more effective than cursing at your computer, and will save other users trouble in the future. - - -Windows ----- - -Cork uses C++11, so you will need the most recent compiler; Visual Studio 2012 or higher please. You will also need to install the MPIR arithmetic library into your Visual Studio environment. - -Once this is done, you can use the solution and project files in the /win/ subdirectory to build the demo program. The solution/project is not currently configured to build a DLL. Please bug me if this is an issue for you. - - -Licensing -========= - -Cork is licensed under the LGPL with an exception (from QT) to more easily allow use of template code. In plain English, the following are some guidelines on the use of this code: - -* Unless you also intend to release your project under LGPL/GPL, you must make sure to DYNAMICALLY link against the Cork library. However, you may include unmodified header files without compromising your proprietary code. - -* If you distribute your code, (publicly or privately, compiled or in source form, for free or commercially) you must (a) acknowledge your use of Cork, (b) include the COPYRIGHT information and (c) either distribute the Cork code or clearly indicate where a copy may be found. - -Of course, none of the above supercedes the actual COPYRIGHT. - - diff --git a/external/cork/makeConstants b/external/cork/makeConstants deleted file mode 100644 index 78def01e5..000000000 --- a/external/cork/makeConstants +++ /dev/null @@ -1,3 +0,0 @@ - -GMP_INC_DIR = /usr/local/Cellar/gmp/5.0.2/include -GMP_LIB_DIR = /usr/local/Cellar/gmp/5.0.2/lib \ No newline at end of file diff --git a/external/cork/samples/ballA.off b/external/cork/samples/ballA.off deleted file mode 100644 index 3b5d9f510..000000000 --- a/external/cork/samples/ballA.off +++ /dev/null @@ -1,5698 +0,0 @@ -OFF -1900 3796 0 --0.25829 -4.29578 4.02524 --0.3358 -4.53536 -3.84291 --7.57239 -3.38175 4.92635 --8.24296 -3.47912 -4.28423 --10.9128 0.101619 0.0623689 --3.95774 -0.0574358 6.92651 -2.9146 0.0533714 0.24182 --4.01222 -6.91992 0.0371523 --3.99057 0.0386863 -6.92778 -1.03378 1.18957 -4.65973 --2.18708 -5.07931 -4.41747 --8.4637 -4.99938 1.8558 -0.54183 -4.89138 2.02043 --4.57817 -5.06808 4.73175 -1.08514 -0.2561 4.75309 --8.67515 0.767798 -5.101 --9.33906 -3.33608 2.96183 -1.14479 -3.76101 2.82256 --0.40116 -5.05098 -3.19851 --9.77707 -3.11471 -2.27789 --1.23321 2.04724 6.04069 --6.8605 -3.64971 5.1854 --1.09495 -2.45237 5.8325 -1.78648 -2.84769 -2.62427 --6.49648 -5.78477 2.9363 --6.712 -2.56372 -5.8688 --1.33472 -5.64397 3.0985 --1.15585 -3.12705 -5.53495 --6.93371 -5.74807 -2.57234 --0.86054 -6.20364 0.0807404 --7.33101 -0.118934 -6.08942 --9.93543 -0.641833 -3.5591 -2.12704 -3.28032 -0.333732 --4.48874 -2.97977 -6.25618 --9.88838 0.485767 3.6617 --1.07266 0.124539 -6.29691 -2.18224 -0.0561725 -3.16436 --4.48952 3.19039 6.15324 --4.42244 -3.40033 6.04147 --7.36601 -6.06296 -0.277572 --9.07079 -4.72227 -0.47385 --9.31022 1.50519 -4.244 --8.56053 -2.88007 4.39204 --3.98721 -6.13275 3.24967 --7.24188 -0.608595 6.11374 --7.42801 -3.83943 -4.68981 -2.29037 0.40971 2.90538 --10.2212 -2.99836 -0.628893 -1.00666 -4.37362 -2.12853 --0.79379 -0.135045 6.17036 --4.00492 -6.24429 -3.04152 --10.5969 -1.27795 1.62114 --5.23273 1.48704 6.66166 -2.636 -1.38746 1.45173 --2.77706 -6.71506 -1.21103 --7.69786 -1.56506 -5.67484 --5.21955 -3.70765 -5.75492 --6.36938 -4.9877 4.2343 --7.83901 -5.53422 1.68967 --7.96224 -4.26068 3.81993 -2.57986 1.53551 1.54193 -2.69253 1.20207 -1.36742 --9.08048 0.524064 4.72977 --9.16982 1.21543 -4.50434 --10.6334 -1.45512 -1.31869 --2.72846 1.54172 6.64343 --5.17145 -1.75295 6.60215 -1.21852 -4.60998 -0.208296 --0.0306 -1.91364 5.39912 -1.08056 -3.441 -3.31965 -0.851 -2.21978 -4.4811 --3.29638 -4.60631 5.17144 --2.49737 -1.38749 6.6269 --8.27808 -1.85536 5.16795 -0.20242 -3.69953 4.16999 --5.54552 -3.63536 5.71905 -0.50882 1.26632 5.15144 -2.66458 -1.29093 -1.41731 --10.6163 1.25725 -1.65113 --7.78582 -4.32481 -3.93613 --9.0838 -2.07056 -4.27632 -0.16944 -5.39443 -1.42633 -0.78492 -3.40457 3.75992 -1.38066 -1.04694 4.29062 --8.18636 0.940698 5.47902 --5.9342 -6.5447 1.18902 --5.61189 -1.4388 -6.58722 --9.15682 -4.38285 1.57474 --8.51458 -4.02686 3.43797 --9.31873 -1.71195 4.13843 --5.00369 1.44432 -6.70102 --7.87897 -5.4324 -1.93634 --2.67121 -6.72992 0.986656 --2.49144 1.56171 -6.58379 --2.5874 -1.05122 -6.70365 --6.73705 -4.95633 -4.04414 --5.73333 -5.37321 -4.05597 --0.32422 -2.43077 -5.38923 --2.80017 -4.64949 -5.03901 -0.06571 -3.62094 -4.35706 --5.67653 -6.65199 -0.93752 --8.07156 0.849591 -5.58402 -0.47856 -5.16726 1.35276 --2.80465 -5.51624 4.0726 --2.92136 -6.11008 -3.13464 --1.17516 -4.78518 4.21557 --2.56975 0.287066 6.77839 --4.98848 -6.84336 -0.141618 --7.27495 -5.94822 1.40433 --3.43845 -2.83588 6.30963 --1.24262 0.791856 6.32129 --4.86605 2.5212 6.41586 -0.40003 -2.46788 4.81559 --3.81812 1.58346 6.74497 --6.88827 -1.20855 6.19633 -2.12481 -1.07383 -3.10389 -2.24009 0.941198 -2.9011 -2.73472 0.480639 -1.56525 -2.0195 -0.712773 3.40074 --0.93915 0.830817 -6.17743 --2.49402 0.332179 -6.75101 --1.80003 -4.00422 -5.2627 --9.90661 -1.54477 3.31343 --4.87755 -3.03294 -6.18423 --2.65652 -2.61967 -6.29028 --4.01106 -1.55574 -6.74596 --4.90562 -6.23794 -2.90499 -2.33702 -2.58873 -1.19319 -2.78554 -1.39949 0.259135 --10.0994 -1.20924 -3.07598 --10.1886 1.51645 -2.76863 --6.88621 -2.027 -5.9789 --6.66155 0.672063 -6.37383 --5.52816 -0.179113 -6.75269 --0.61137 -5.89359 1.50292 --8.22956 -0.926689 -5.44326 --9.58103 -0.151139 -4.14731 --8.65196 -3.54916 -3.77473 -0.81916 0.476624 5.0049 --4.91735 -5.21091 4.51778 --3.78777 -4.58962 5.22436 --4.23932 1.36179 -6.78885 -0.85644 -4.97082 0.581019 -2.74467 1.54915 -0.363858 --0.85139 -0.861633 6.13449 --8.81866 -4.39745 2.41259 --7.11209 0.863641 6.14983 --0.0042 -5.10569 -2.56415 --8.56774 -0.358883 5.24001 --9.20075 -3.97749 -2.36296 --7.83781 -5.69029 -1.03584 --3.99741 -5.35265 -4.44443 --10.7713 -1.38547 -0.260428 --0.3662 -0.105134 -5.92309 --3.35753 3.07991 6.19382 -1.3155 0.0885704 -4.49167 -1.9739 0.49066 3.5268 --0.96311 -0.662269 -6.20958 --10.7198 -0.23663 1.63743 --7.82831 1.65867 -5.57554 -0.88744 -2.85278 -4.069 --4.24772 -6.76547 1.44467 --1.09325 -6.25567 -0.86055 --2.59793 -6.77918 -0.322046 --7.68104 -2.79742 -5.20523 -0.54492 -5.24989 -0.513553 --4.36082 -6.74402 -1.55171 --4.18876 -1.53375 6.74969 -2.77204 0.0974341 1.43448 --5.67416 -6.09623 2.86736 -1.84365 -3.67155 0.879334 --3.04466 -6.05868 3.26343 -0.36871 2.25024 4.93817 --1.41102 -4.08997 5.01488 --6.19147 -3.82249 -5.38825 --7.22083 -4.18995 4.52707 --1.17774 -4.58556 -4.42873 --10.7514 0.366488 -1.47221 --0.14756 -4.98869 2.99203 --10.2268 -2.86188 1.04671 --5.41143 -0.404945 6.77045 --9.85576 -3.56233 -1.10046 --8.95949 -1.30669 4.70595 -0.77386 -3.15172 3.99165 -1.1997 1.50001 4.38023 --8.88578 -2.75518 -4.1268 -0.23639 -0.799422 -5.45996 -0.72242 -1.3114 -4.95018 -0.57476 -1.90318 4.90253 --4.82583 -4.80904 -4.9681 --8.88314 -1.59964 -4.68663 --6.39685 -0.0333628 -6.51501 --4.67221 0.51754 -6.87316 --1.90377 -6.29708 -2.06721 -2.20777 -2.25408 2.16382 --4.64438 -6.84963 0.740749 --4.26066 -6.39827 2.65501 --4.88122 -0.540626 -6.84641 --4.18194 -2.12329 -6.60294 --6.39935 -6.48581 -0.24309 -0.44553 -4.24109 3.3153 -0.80483 -4.09065 -2.97846 --6.20579 2.50749 6.10067 --6.70485 -2.19396 6.01164 --7.94911 -4.81811 -3.11818 --1.81902 1.97327 6.28725 --10.8586 0.744908 -0.581319 --10.5214 0.464025 2.30846 --10.4738 0.801511 -2.35926 --10.8022 0.785676 1.02869 -2.55522 -2.23784 -0.437007 -2.86098 -0.775751 -0.515731 -2.45768 0.185279 -2.54055 --8.78417 -3.3953 3.75034 --1.35043 -0.358351 6.41212 --3.40592 -1.91438 6.63767 --10.2381 -2.20202 2.08033 --10.1222 -2.2697 -2.34505 --3.31022 -0.55714 6.86387 --1.85644 -2.27132 6.21215 --10.5456 -2.19316 -0.559255 --4.66631 -0.646429 6.86079 --6.51635 -0.350828 6.45574 --4.48532 -2.44222 6.4769 --3.43778 0.69077 6.87086 --1.53954 0.315261 6.48553 --3.94338 2.62807 6.42167 --10.8809 -0.339151 -0.55396 --10.5366 -0.282448 -2.27267 -2.8261 0.783806 0.885425 -2.57709 0.246081 2.20862 -2.82807 0.755397 -0.929308 -2.2195 -1.89588 -2.46375 --6.72001 -6.08849 1.90443 --5.89512 -2.3994 -6.24162 -2.56427 -2.24221 0.12725 --1.82061 -6.58426 0.151972 --3.77092 -6.51528 -2.34477 --3.31098 -6.86053 -0.638015 --6.45077 0.680729 6.45859 -2.86119 -0.627948 0.707595 -2.47664 -0.534346 2.44566 --10.8147 -0.748886 0.888302 --10.4915 -2.39871 0.0456708 --4.83259 0.481318 6.85936 --10.4038 -0.0775009 2.65096 --2.05003 -2.07058 -6.33709 --4.31313 -6.8814 -0.591466 --4.63183 -6.45182 -2.46131 -0.41954 -4.25146 -3.32489 --2.11932 -6.32829 2.17812 --3.06704 0.630707 -6.83552 --1.91815 -0.373129 -6.60152 --3.42281 -2.55429 -6.42842 --1.70378 0.764483 -6.50074 --3.4388 -0.551183 -6.87338 --6.10481 -6.26262 -2.12065 --3.37271 -6.88866 0.274794 --3.60379 -6.55165 2.23757 --7.54736 -2.07618 -5.61273 --9.92814 -0.148206 3.61481 --5.69624 -3.1214 -5.9716 --9.92094 -3.25969 1.58219 --6.01556 -5.24047 4.10779 --7.8437 0.224289 5.79247 -1.74823 -0.195697 3.91764 --3.14875 -5.63386 -3.99092 --0.10289 -5.75807 -0.372013 -2.14726 -3.19435 0.612584 -1.38372 0.69114 4.35885 -1.69493 -3.74918 -1.41237 -1.73234 -2.18742 -3.30118 --0.66511 -1.80945 5.83543 --2.48226 -3.86847 5.58349 --7.4225 -2.57717 5.48566 --0.48301 1.23219 5.86903 --9.74156 -3.89841 -0.256441 --4.49849 -4.11617 5.5792 --7.74317 -0.92911 5.78193 --0.43794 2.24879 5.53857 --3.14182 -3.65212 5.86139 --0.01579 0.0551899 5.69997 --9.16899 -2.78097 -3.73278 -1.58465 -4.00766 -1.09304 --9.88366 0.679411 -3.63605 --2.11309 -5.63062 -3.639 --0.5512 -5.79918 -1.72366 -1.50152 -3.67262 2.18861 -1.57295 -1.89905 3.71874 --8.09325 -5.56152 0.718349 --5.69497 3.18729 5.94344 --4.52431 -5.66432 3.99399 --4.56782 -4.00072 -5.66481 --9.55323 -3.5166 2.25088 --7.60816 -0.585318 -5.9057 --9.7713 -2.25299 3.12964 --7.07948 -6.00483 -1.61071 --2.36919 -3.33445 -5.88266 --0.14704 -1.27839 -5.64595 --0.5131 0.30054 -6.00135 --2.21648 -5.82715 3.36956 --0.32916 -5.46822 2.27303 --3.0781 -3.7885 -5.76409 --3.88877 -5.83182 -3.78548 --8.09841 -5.59855 -0.144876 --8.06642 -4.90098 2.80482 --0.33379 -3.11478 5.0486 --9.18783 -3.41896 -3.13531 --7.16496 -5.11668 -3.50231 --0.87566 -3.65565 -5.04805 -1.32288 -0.726714 -4.42533 -0.68113 0.453664 -5.12546 --9.12934 -0.595932 4.67097 --8.65412 0.196323 5.18032 -0.77246 -4.67328 2.00209 --2.42649 -4.82075 4.78019 --6.18301 -4.35373 4.9741 --1.7229 -4.64964 -4.66546 -2.90499 0.158083 -0.471641 --3.97944 -0.484767 6.89944 --3.37441 -5.26018 -4.52057 --3.39325 -6.72915 -1.55835 -2.74574 1.48814 0.512292 --6.94598 -5.72236 2.6063 --2.38997 -0.335139 6.73271 --5.7121 -6.70352 0.158035 --1.51731 -6.12127 -2.16523 --3.63011 -6.73201 1.57311 --6.80264 -6.2639 -0.973719 --1.75929 -6.44044 1.30592 --1.28857 -5.60089 -3.12918 --10.7708 -0.575154 -1.29867 --1.14816 -1.77993 -6.08065 --5.93586 1.65419 -6.45676 -2.44901 1.1959 2.27656 --3.51918 -1.57635 6.72602 --6.42289 -1.05661 -6.41171 --10.8791 -0.636012 -0.155407 --4.97564 -2.23835 -6.49369 --4.73917 -5.41939 -4.29863 --3.3411 1.29113 -6.77716 --10.5381 -0.868277 -2.13347 -2.80147 -1.27143 -0.444625 -2.90577 -0.431498 -0.162394 --9.60448 -1.04921 3.98323 --9.24633 -4.23575 -1.67361 --8.33518 -1.30529 5.28597 -1.88713 -3.26578 -1.75323 --5.73398 -5.97278 -3.09626 --3.74127 -0.740283 -6.8787 --4.45119 -1.25081 -6.79759 -2.75257 -0.410315 -1.52376 --5.78956 1.47628 6.5385 --10.3154 -1.08682 2.63604 --1.84989 -1.14369 6.50302 -2.89838 0.584386 -0.0566725 -1.88861 -2.00359 3.11426 --5.01811 -4.16048 5.47816 --4.05086 0.543639 -6.90074 --7.11628 -6.15311 0.710036 --1.77993 1.19233 -6.46733 -0.66607 -1.06797 5.0609 --8.95781 -0.793068 -4.81264 --10.5312 -1.96154 1.20579 --1.21071 -5.97963 2.21166 --8.70205 -4.99723 1.05212 --5.65552 -0.57298 -6.70275 --5.369 0.439609 -6.77281 --4.52333 0.117468 -6.90036 --3.92046 0.546896 6.8967 --4.40352 1.57396 6.73313 --3.81509 3.27806 6.12538 --9.65774 -2.16373 -3.40465 --5.38412 -6.45102 -2.13635 --3.41705 -1.57112 -6.72378 --1.50805 -2.7849 -5.86035 --2.68566 -6.76815 0.668509 --10.1034 -1.20025 3.08171 -2.44999 1.36861 -2.17046 -2.52331 -0.940832 -2.16951 --6.30627 -1.39208 6.40039 --3.78601 -2.88843 -6.31118 --2.68076 -0.635073 -6.77578 --4.30424 -6.88249 0.608639 --3.50035 -0.093146 -6.9006 -2.4124 -1.379 2.26188 --1.94872 -6.5618 -0.937183 --2.594 -2.33301 6.39178 --5.16916 -2.74139 6.26157 --10.7307 0.555891 1.53441 --6.72229 -0.927839 -6.31996 --2.76985 -6.449 -2.26928 --1.56563 -0.920068 -6.4336 --5.69033 0.456685 6.70629 --4.70815 -6.71687 1.5319 -2.79267 0.416058 1.29137 --10.7002 -1.69268 0.337507 --1.45073 -5.86055 2.74049 --10.2631 -2.67325 -1.28522 --1.73519 1.41535 6.40845 --6.58299 -6.36137 0.901856 --10.8969 -0.0678978 0.508785 -1.08782 -2.18452 4.23285 --4.45609 0.179376 6.89403 --10.744 1.41572 -0.69886 -2.07444 1.36687 3.09107 --10.8862 0.570154 0.0136537 --2.57755 -6.36384 2.3781 -2.45403 -2.40127 0.915576 --2.43474 -2.9979 6.07721 --5.32655 -6.39075 2.33756 -2.74934 -0.487558 1.49092 -1.48319 0.893557 -4.18933 --2.77282 2.4493 6.3787 --3.51719 -0.100659 6.90202 --2.48521 3.21185 5.97198 --6.94351 -4.96219 3.88505 -1.97146 -1.50803 3.23686 --0.64212 -3.96049 4.66006 --7.50768 -5.29964 -2.82595 --9.5164 -1.44236 -3.97994 --8.84482 -2.28644 4.44473 --8.62638 -4.27487 -2.95568 --4.97329 -5.74442 -3.76382 --7.24896 -5.33624 3.0537 --8.26437 -5.46215 0.330624 --0.56607 -2.39082 5.56804 -1.53455 -4.21801 0.129861 -1.71071 1.51312 -3.68188 -0.23197 -3.18381 -4.54451 --8.39656 -4.9169 -2.19766 --8.75562 -4.93134 -1.17279 --3.89876 -4.66503 -5.16356 --8.60687 1.23043 -5.07594 -0.17071 1.238 -5.42765 --3.77026 -5.41515 4.35941 -1.3578 -3.71529 -2.47428 --8.35109 -2.07759 -5.01195 --8.44788 -0.291357 -5.341 --1.27987 -3.15367 5.57648 --0.85317 -4.98823 3.71315 --9.24376 -4.53733 0.420273 --6.12873 -4.47373 -4.89376 -0.37757 -2.32379 -4.89951 -2.06829 -2.87572 1.80583 --10.1861 -2.67082 -1.63941 --6.03578 -2.89277 5.98492 --0.66555 -5.5609 -2.55119 -1.91836 0.261511 -3.63999 -1.37258 -2.92114 3.35323 --1.31491 -1.67787 6.18705 --6.68967 -3.18347 -5.57448 --6.49766 -5.60238 -3.27823 --9.81605 -2.39503 -2.94553 --2.22045 -5.37406 4.0506 --0.98382 1.83476 5.99112 --8.03541 -3.84842 4.16333 -1.4463 -4.24457 0.934153 --1.42496 -5.20655 -3.85909 --5.79072 -5.58231 3.73233 --1.74617 2.52167 6.07018 --0.74329 1.07343 -6.04329 -1.54943 -1.54134 -3.90897 --6.40522 1.62178 -6.3114 --10.2107 -1.80331 2.51759 --5.77269 -2.26262 6.31372 --10.2355 -3.01179 0.174833 --10.4994 -1.89052 -1.49062 -2.25455 -1.8682 2.39691 -2.58448 -1.90512 1.08246 --5.66738 -6.54185 1.55318 --5.03313 -5.92658 3.46836 -2.16831 -3.1379 -0.657129 --9.63064 -3.96184 0.935279 -2.63501 -1.57126 -1.25116 --5.27886 1.5642 -6.63213 --2.96563 -1.67133 -6.64332 --6.90818 -3.04122 5.53313 -1.12922 -4.56815 -1.2027 --5.52357 -4.88581 4.70658 -0.16341 -5.56224 0.527201 -1.78729 -2.9403 2.52092 --1.72501 -3.37251 5.6522 -0.10772 -5.20741 -2.13826 -1.25527 -4.36305 1.37814 --0.37018 -5.89378 -0.756605 --0.10326 0.361361 5.75264 --0.85932 -6.14507 0.850717 --7.28437 1.10338 -6.03205 --5.9118 -3.32071 -5.79973 -1.8668 -0.416466 -3.70654 --1.9253 0.211583 -6.61136 -0.51918 0.0127358 5.29999 --10.511 -1.10316 2.03234 --6.91946 -5.29253 3.43897 --5.02509 -5.98989 -3.36426 --8.54519 -1.47699 -5.05852 --9.78655 -3.31862 -1.94984 --9.37492 -2.99527 -3.24162 --6.11724 -6.56686 0.511296 --0.37691 -3.36528 -4.91902 -2.43457 1.04068 -2.3808 -1.15066 -2.87736 -3.7173 --9.78535 -0.493808 3.81495 -1.75287 1.28 3.7011 --8.33993 -2.63569 -4.76182 -1.76626 -3.88351 -0.150727 --10.0991 0.00857796 -3.31768 -0.42581 0.200221 -5.35583 --5.68636 -5.19935 -4.30187 --5.18714 -5.07552 4.616 --3.81289 -3.5704 5.95573 --2.01334 -6.08346 -2.71782 --3.80535 -6.68827 -1.79237 --0.18216 1.03981 5.72051 --0.244 -0.934498 5.77958 --7.79659 -4.63869 3.53327 --10.1443 0.659608 3.17552 --3.15211 -5.41586 -4.28269 --8.34509 -3.36296 4.2708 --0.00073 -0.547114 5.66626 -2.22801 -2.35199 -2.00585 -2.73613 -1.1247 -1.16709 --9.37122 -2.58237 3.58363 --7.29078 -6.08824 0.167421 --1.08661 -6.15332 -1.42621 --5.43081 1.04123 -6.70124 --5.44773 -1.05633 -6.69054 --6.84865 -5.64508 -2.88746 --5.02698 -6.77761 -0.938783 --5.15505 -0.983095 6.75805 -2.4604 -2.09651 -1.43554 --3.74042 -3.86948 -5.77296 -2.74255 -1.26272 0.978604 --2.72257 1.05358 6.72744 --9.35296 0.0771255 4.44264 --3.15685 -5.01037 4.7594 --7.50789 -1.60211 5.77755 --4.31192 -3.61432 -5.92422 --7.34806 -2.85746 -5.39008 --0.34171 -4.60963 3.75784 -1.15505 -1.74982 -4.33226 --10.4162 -0.500313 2.58079 --9.43113 -4.2169 -0.977491 --9.7392 -2.86371 2.66119 -1.26629 0.0190098 4.55368 --2.73451 -1.01512 6.74056 --4.8312 -4.44194 5.29355 --8.66083 -5.14466 -0.0372666 --7.59864 0.493796 -5.92861 --3.17376 -6.22695 2.97066 --9.49529 -4.05318 1.23826 -0.80185 -0.537678 -5.00423 --5.03932 -6.61296 -1.78331 -1.5578 -0.866956 -4.0844 --6.21798 0.950008 -6.50595 --10.6864 -1.04004 -1.42241 --0.51991 -3.99228 -4.53811 --4.76894 -6.72781 -1.40388 --4.60665 -1.27432 6.78308 --5.47588 -4.49272 -5.11072 --5.93069 -0.690041 6.62415 --5.03872 -6.7799 0.908094 --8.18608 -2.61944 4.91396 --0.06171 -5.51082 -1.60459 --0.03275 -5.67561 0.750613 --7.3214 -1.53843 -5.91188 -2.24343 -2.92987 0.837807 -0.08498 -5.3339 1.82846 --7.35955 -5.78068 -1.88408 --10.035 -3.39035 0.431731 --3.25433 3.48405 5.96723 -0.86406 -2.68194 4.21023 --10.4431 -2.44321 0.704701 --2.72438 -4.17732 5.4192 --2.80997 -0.501715 6.80557 --5.75528 -1.42038 6.54796 -0.35274 -4.62765 2.8785 --4.8872 -1.45552 -6.71743 -0.85601 -4.77465 -1.49278 --4.03987 -6.71102 1.70469 --9.60141 0.423908 -4.10331 --5.39668 -6.0957 -3.01986 --9.24412 -0.581999 -4.52456 --4.94534 -2.53873 -6.38365 --1.33545 -5.43558 3.45627 -0.55921 1.65764 4.99144 --3.88116 -2.96755 6.27429 --1.82567 -1.79125 -6.34936 --1.84241 -3.15068 -5.81534 --0.587 -5.37275 2.83177 --0.8187 0.307982 6.1715 --7.79894 -5.2984 2.41456 --3.11924 -6.73025 1.38709 --8.98752 -4.65762 -1.31975 --8.58334 -3.31206 -4.05478 --2.2358 -1.70252 -6.49298 -0.78432 -2.53939 -4.37488 -2.19531 1.31565 -2.86926 --9.12233 -3.99838 2.46101 --9.34896 -2.33457 3.77554 --1.14956 -2.2584 -5.93472 -1.55275 -2.08376 -3.65081 -1.02709 -4.30672 2.1991 --5.1333 -5.05869 -4.64375 --10.3184 -0.318277 -2.84806 --8.33204 -4.05196 -3.646 --5.7047 -6.21484 2.5666 --3.71439 -6.83513 1.05047 --3.44478 -6.38776 -2.66983 -0.8799 -3.73763 3.29495 --10.7858 -0.596597 1.20781 --1.80771 -5.17952 4.11709 --4.9685 -6.4006 2.47826 --8.63857 -5.15975 -0.348679 -0.49704 -3.73866 -3.80778 --2.06479 -0.849081 -6.60255 --6.8411 -4.55934 4.42155 --7.43703 -5.69893 1.97026 --0.86861 -3.33866 5.26189 --1.38773 -0.749212 6.38631 --10.1212 0.988832 -3.12457 --3.65453 -1.14936 6.82148 -2.80878 1.1245 -0.471722 --0.67584 0.952333 6.02631 --7.95911 -5.53971 -1.36341 -1.42299 -0.177785 -4.36083 --6.90379 -3.62437 -5.18419 --5.88923 -3.72449 5.56102 -0.94344 -1.67415 4.61087 -2.6386 1.00418 1.71879 --6.31159 -1.743 -6.30782 --6.4667 1.3689 6.34589 --1.69669 -6.02395 -2.59367 --0.77663 -4.21859 -4.521 --2.10377 -6.48642 -1.58062 -1.68146 0.121657 4.00748 --10.6799 -1.47031 1.03893 -1.10487 1.08983 4.59754 --9.14115 0.386501 -4.6679 --0.02442 -3.24059 4.7248 --2.33635 1.16525 6.63404 --2.79099 -6.14365 3.00276 --1.91297 -0.133261 6.61444 -2.15669 -1.28841 2.94916 -2.70096 1.52213 0.889948 --2.05945 -4.36639 5.07233 --4.77617 -3.26648 6.08012 --8.84541 -3.07674 3.92962 -0.3113 1.47769 -5.26046 --3.64954 -5.88658 3.67737 --1.2696 -4.33013 -4.7346 --6.38901 -6.01961 -2.49169 --6.37308 0.129811 6.50386 --5.53493 0.898688 6.70057 --0.06916 -0.695886 -5.69141 --2.62354 -5.6428 -3.83722 -1.61316 -4.09237 -0.511354 --3.56997 -4.676 -5.13439 --2.747 -6.5772 1.79625 -2.54784 -0.831415 2.13076 --2.53434 -2.11596 -6.43949 -2.0977 -3.00464 -1.47821 --7.28825 -6.06226 -0.704126 -1.78397 -1.55112 -3.54932 -1.61209 -3.83488 1.50446 --3.364 2.15853 6.55925 -1.37258 -0.712935 4.36635 --2.83287 -3.92069 -5.6296 --6.16559 -6.43997 -1.35359 --4.68438 1.88958 6.63379 --4.24491 -5.91336 -3.63772 --4.7997 3.30551 6.06576 -1.47781 1.21811 -4.10405 --1.41856 -6.4006 -0.805091 --3.46395 -6.0174 -3.43496 --8.11103 -1.7199 -5.3422 --3.38342 -3.29878 -6.08277 --7.37805 -4.72335 3.83505 --8.27567 -4.83159 2.57726 -2.36838 -2.17871 1.71634 --3.87759 -4.32554 5.45021 -0.54949 -5.20764 -0.834939 -0.73752 -0.181587 -5.08804 -2.67668 1.64387 -0.869878 -2.42812 -0.563359 -2.55863 --5.89185 2.90988 6.02506 -2.84337 -0.0275642 -1.06389 --9.70913 -0.195037 3.96005 --8.50085 -4.56574 -2.7014 -0.49857 -4.94266 -1.96646 --3.38224 -4.24211 -5.48161 --10.6049 1.54793 -1.40803 --6.20785 1.51709 6.4012 --8.11702 0.334656 5.58951 --3.75042 -6.86412 -0.830757 --7.93093 -5.19793 -2.4009 --0.85121 -1.35577 6.04815 -1.57785 -3.7525 -1.81709 --2.39203 0.781422 -6.69607 --0.12235 1.03272 -5.67817 --3.26606 1.17894 6.7796 --0.59755 -6.06058 -0.236273 --9.56562 -4.1432 0.0458662 --7.67178 -2.08084 5.52926 --5.87217 1.83057 6.43082 --8.03987 -3.2042 -4.6818 -1.15925 -4.35513 -1.73789 --7.07366 -4.39316 -4.44211 --0.06548 -2.79963 -5.02046 --6.19533 0.950733 6.51012 --9.79208 1.23159 -3.63934 --4.56185 -6.55612 2.17468 --4.03484 -2.27819 6.54404 -0.2837 0.74404 5.43077 --9.97888 -3.49498 -0.185 --10.6485 -0.460797 -1.85102 --9.99723 -2.91366 1.89568 --3.62858 -5.49483 -4.24233 --7.092 0.187736 6.21284 --8.68687 -1.21988 4.9873 -1.64696 0.722911 3.98552 -2.16321 -0.365464 3.18903 --0.00274 1.69119 5.44157 -0.77949 -4.8199 1.57211 --8.62887 -2.2445 -4.69026 --6.61301 -2.55116 5.91321 --10.402 0.3008 -2.65233 --2.28957 -4.31445 -5.18483 --1.59102 -3.01006 5.79265 --7.05052 -4.88055 -3.91282 --8.82443 -3.8286 -3.23697 --0.38882 -5.39949 -2.5202 --9.12998 -4.27556 1.93148 --9.65369 -3.85989 -1.13239 -1.94714 -2.31164 2.76146 --4.80701 -3.35772 -6.02415 --6.17468 -5.17214 -4.11646 -2.32905 -2.84851 -0.173716 -0.35167 -4.62913 -2.87509 --5.89208 -4.98014 4.46583 -1.72664 -3.14121 -2.40301 --5.20391 -3.26937 5.99876 --5.0862 -6.8186 0.262507 --4.02439 -5.00612 -4.82937 --10.8481 0.00856261 0.955029 --6.47852 -5.75767 -2.99018 --6.31561 -3.78984 5.34822 --6.49836 -3.26932 5.60189 --7.4441 -3.23864 -5.11586 --4.3849 1.0059 6.83487 --1.15448 -6.21809 1.22859 --2.93945 -5.0822 -4.63249 --4.1451 -4.38171 -5.40388 --9.76402 -3.81618 0.513155 -2.8441 1.01805 0.00217025 --4.32167 -6.00264 3.47194 --5.95619 -6.26728 2.21855 --4.94611 -5.73015 3.81253 --4.77758 -4.25442 -5.44918 -1.48578 -3.33424 2.69357 --3.04233 -1.57346 6.67888 -0.22883 -0.927177 5.44877 --9.00022 -4.38998 -2.00836 --2.19268 -6.66349 -0.558025 --6.38941 -5.39415 3.67953 --6.87622 -5.57602 2.97974 --5.28024 2.27522 6.42737 --1.30517 -6.36996 0.66553 --5.71835 2.46775 6.26177 --10.2332 -1.00495 -2.87507 -0.52841 -2.69026 4.56102 --6.74639 -4.35562 -4.67642 --10.0547 0.433296 3.37183 --1.61969 -4.61404 4.65114 --4.61862 -1.70218 6.67586 --9.07517 0.0971232 4.75763 --10.8189 -1.04365 -0.454132 --7.73208 -5.7961 0.740974 --0.77598 -5.15697 -3.41503 -1.88205 -3.5863 -0.980057 --10.8395 0.160628 -0.98848 -0.94267 -4.8903 -0.395002 --10.3932 -1.53341 -2.20471 --8.42818 -4.30941 3.18839 --1.26458 -0.555441 -6.35049 --7.36234 -3.26357 5.13375 --7.16388 -3.97585 4.75536 -1.4372 -3.06188 -3.08759 -2.42757 1.56149 2.06958 --6.6209 -5.18794 3.81152 -0.71723 -4.55842 -2.35204 --1.12924 1.24283 6.19245 -2.82693 -1.15646 0.0672408 --4.53896 -6.27832 2.90022 --10.5932 0.591683 -2.05431 --1.04158 -6.0226 -1.82353 -1.89925 -3.68017 0.250808 --2.04798 -2.89504 -6.01091 --6.59525 -6.19778 -1.69664 --5.95606 -5.61748 -3.58889 --9.93092 -1.84673 -3.1046 -1.1999 -4.58905 0.631297 --10.0274 -2.23661 2.59323 --7.05461 -6.12298 1.10522 --10.7088 -1.36325 -0.965749 -0.02058 -5.07932 2.56793 -0.27703 -5.48904 -0.0231057 --9.6043 -0.947935 -3.99265 --2.07846 0.304227 6.65428 --1.07176 -1.14292 -6.19368 --0.95215 -2.02577 -5.90757 --2.32815 -4.71589 -4.85087 --8.62933 -2.17529 4.71211 -1.29408 -1.80498 4.14306 --6.89606 -0.0121481 -6.30707 --3.30042 -3.94784 5.68395 -2.4966 -1.40911 -1.96835 -1.6768 -1.17677 3.84254 --9.95743 -3.41942 0.921431 --1.9274 -1.81886 6.36877 --1.98502 -0.742044 6.58982 --7.9739 0.0570186 -5.70359 --3.35166 -5.49422 4.20737 --8.29481 -5.17202 -1.74604 --6.20132 -2.30854 6.16542 --10.3001 -2.57845 1.2786 -2.62731 0.336723 -1.99619 -2.63395 0.722393 -1.88454 --8.23707 1.49731 -5.31155 --1.9803 -6.12053 2.58464 --2.40186 -0.199379 -6.72921 --5.15187 -5.42828 -4.18682 -0.14891 -1.73407 -5.31486 -1.86344 0.758417 -3.64922 -2.73493 1.13154 1.12364 --7.4982 -3.7108 4.73348 --2.39526 -3.3552 5.87074 --3.02815 0.222609 -6.84461 --4.8297 0.960518 6.8071 --1.35104 -6.18106 1.74868 --7.11075 -1.80743 5.94014 --1.84393 -6.5391 0.846092 --5.13534 -0.0987921 6.81547 -2.55654 -2.16202 0.67605 --3.46891 -6.01514 3.41815 --3.0037 -3.00973 -6.17914 --2.62124 -4.60977 5.02805 --7.85688 -3.48054 4.63051 --10.0757 -3.12852 -1.16802 --0.47457 -3.64691 4.78646 --1.75475 0.64088 6.53147 --2.49816 -6.2898 -2.54056 --5.33625 -6.70363 -1.06419 --4.61941 -5.34291 4.39892 --7.13691 -0.598161 -6.17034 -0.62648 -0.632199 5.15658 -1.96833 -1.7084 -3.12557 --3.73548 -1.95313 -6.64037 --6.44188 -6.08999 2.24825 --5.02263 1.96534 6.56588 --7.01379 -5.91275 -2.03636 --0.01482 0.101998 -5.69242 -1.03934 -1.15924 4.65692 --10.8523 0.906134 -0.31534 --8.39316 -5.25826 -1.12736 --7.41308 -5.02917 3.37567 --5.27927 -1.79605 -6.56986 --3.53186 0.213465 -6.89545 --4.36508 -6.89665 0.191483 --2.69667 0.879542 -6.74301 --5.40522 2.7531 6.21869 --10.1024 -1.70982 -2.81511 --2.11249 2.5526 6.17431 --5.74778 -6.15251 -2.68363 --8.78988 -4.06553 2.9767 --8.50299 -3.70192 3.80031 --5.83426 -4.1674 -5.25586 --0.33634 -5.88837 0.527471 --9.48565 -0.41059 4.24896 --4.77961 -1.77952 -6.64717 --4.33673 -5.13144 -4.67715 --5.51129 -4.79532 -4.80839 --4.26367 -4.57105 5.2282 --1.75696 -3.77603 5.40361 --3.51722 -1.06386 -6.81862 --5.96969 0.114166 -6.64001 --7.52853 -5.80738 -1.39371 --6.34573 0.283711 -6.51682 --6.0612 -6.581 -0.574521 -2.54714 -2.08978 -0.857197 --3.79418 -5.02926 4.7931 --6.55203 -3.98415 -5.09579 --2.79748 -6.29233 -2.67415 -0.40791 -1.44946 5.1857 -2.56664 -0.153785 -2.20526 --9.54875 -3.76019 -1.79454 --0.84609 -5.73692 2.36533 --1.40693 -3.6858 -5.30834 --8.91175 -1.79073 4.57913 --10.8271 1.09569 0.12972 --8.8736 -0.0840486 4.96288 --5.26004 -4.57054 5.08642 --5.09378 -0.119712 -6.82823 -1.20765 -2.69968 3.75542 --7.39769 -5.54685 -2.4244 -1.17086 -3.38341 3.2058 -0.15914 -5.53889 -0.666658 --10.0104 -0.710085 3.3908 --8.26486 -0.184441 5.49196 --1.18962 -5.85169 -2.48367 -2.39993 -0.0992923 2.67155 -2.67337 -1.79688 -0.472597 --5.4068 -6.63858 1.32735 --2.49433 -6.12444 -2.91816 --1.52848 1.59061 -6.28619 --6.67646 -6.38086 0.172909 --9.38797 -2.10039 -3.84856 --4.97927 -6.15241 3.0428 -2.37439 0.796402 2.61681 --3.45995 -2.41277 6.48013 --10.2386 -0.458499 2.96131 --5.81532 -1.09197 -6.58972 -1.47353 -2.34371 3.60483 -0.21727 0.620273 -5.49459 --10.6815 -1.64952 -0.640802 --0.40014 -0.350837 5.93403 --2.86745 -2.893 6.20874 --2.94396 -2.61776 6.33613 -1.44282 -1.53067 4.04883 --3.77121 1.00448 -6.8405 -0.87967 -4.1459 2.75061 -2.84796 -0.112717 0.944635 -1.86891 -0.79744 -3.62923 --9.14102 -4.54095 1.04673 --1.00298 1.54089 -6.07834 --5.76294 -6.50648 -1.57941 --8.60882 0.760885 5.1517 --1.31178 -6.40051 0.154588 -0.64074 -5.17903 0.0267526 --7.66202 -5.87234 -0.361093 --10.5911 -0.373984 2.08513 --3.72748 -6.88745 0.524049 -0.3728 -3.22964 4.35883 --10.4568 1.29939 -2.16019 -0.7775 -3.78444 -3.38315 --0.57847 -0.851455 -5.97995 --9.08043 -3.29809 -3.42014 --0.81462 -4.96196 -3.71457 --1.27736 -4.42477 4.64519 -0.56699 -3.74543 3.70667 --9.64493 0.254472 4.04464 --7.57982 -1.04264 -5.85591 --2.49943 -5.82116 -3.48529 --2.04944 -5.8271 -3.24571 --8.82535 0.026742 -5.0034 --6.44322 -0.565138 -6.45775 --1.49154 -6.36404 -1.21049 --7.14864 0.616068 -6.15558 --5.53935 -4.27292 5.25918 --8.90422 1.34765 -4.74898 --9.80895 -1.04015 3.65838 --8.20301 -4.58587 3.09499 --2.32069 -6.68752 0.533225 --1.8563 -5.82228 3.132 --6.40849 -2.91856 -5.82955 --6.78301 -1.35739 -6.20544 --9.02872 -3.58697 3.17964 -2.81441 -0.558214 -1.06137 -2.0756 0.569581 -3.30831 -1.63945 0.169561 -4.04923 --0.01383 -4.06586 -4.01954 -0.78034 -3.30872 -3.84546 -2.30633 -2.87068 0.396183 --10.262 -1.39926 -2.60907 -1.60518 -3.51739 -2.15504 --3.15629 -6.56689 -2.03894 --1.9592 -3.62223 -5.57748 --0.84382 -2.85164 5.50926 --7.7943 -4.63147 -3.54013 --9.85466 0.0780673 -3.73352 --9.60304 0.912423 -4.01806 --5.08074 -6.56096 1.91604 --3.75787 1.02732 6.83849 --0.74044 -2.30529 -5.6976 --5.79012 -1.96658 -6.40043 --5.51831 -2.34694 -6.34132 -0.40866 -0.437257 5.3588 --0.08943 -5.63989 -1.10003 -0.62028 -1.81353 -4.87885 --4.52972 -6.14056 -3.17979 --8.77043 -5.01057 0.533472 --1.47107 -6.21423 -1.78197 --0.61112 -5.11198 3.30376 --0.65418 -4.49798 4.14161 --10.1552 0.464577 -3.16085 -1.10076 -4.63973 0.980159 --1.03329 -5.4232 3.20348 --0.18563 -5.80941 0.219095 -0.38043 -4.82074 2.46359 --0.90589 -4.37708 4.45153 --1.47547 -0.118562 -6.45208 --7.69158 -5.75697 1.15515 --6.50302 -6.29767 1.42639 --10.8258 -1.05909 0.124441 -2.20117 0.890022 2.97867 --6.03384 -4.81245 -4.59512 --8.38128 0.351676 -5.3871 --8.61708 0.181419 -5.19184 --5.99818 -1.82612 6.37604 --0.41908 1.43249 -5.77833 --4.78635 -3.66658 5.84415 --8.30703 -5.39379 -0.676725 --2.7803 -6.58901 -1.76355 --2.36165 -6.02667 3.03766 --4.33929 -6.60278 -2.04869 -1.95072 1.29001 -3.33708 --7.83861 -0.257487 5.7817 --6.66233 -4.19956 4.84465 -1.86558 -3.38326 1.52525 --1.59234 -4.94795 -4.2657 --9.27441 -1.20743 4.36182 --5.32298 -5.3738 4.20104 --10.8565 -0.718912 0.360618 --7.0989 -2.44401 5.71244 -0.34805 -3.94869 3.76003 -0.79765 -3.99274 3.10057 -2.61626 -0.567707 1.98341 -2.68638 -0.115579 1.79303 --2.25186 -3.92678 -5.46639 --8.76137 1.63284 -4.80379 -2.34169 -1.07242 -2.60251 -0.63314 -2.30844 4.66067 --9.491 0.563872 4.2208 --8.19904 -5.33227 1.44388 --5.4745 -3.93065 5.53262 --8.78969 -4.64336 1.91934 --10.8609 0.466355 0.671073 --9.52971 -3.78431 1.79145 --3.67754 -4.94431 -4.87541 --3.01472 0.115703 6.84755 --4.18741 -4.83794 4.98143 -0.91542 -1.66451 -4.63169 -0.37142 -1.29891 -5.25106 --10.6247 0.11949 1.98974 -0.00407 -2.40685 5.16398 -1.67958 -2.54729 3.10409 --5.47012 -6.61758 -1.37581 -2.00021 -2.73111 -2.20428 -2.30991 -2.53293 1.38782 --7.97621 -1.56359 5.47886 --0.46769 1.77829 5.71542 --10.7604 0.878877 -1.15574 -2.06297 -2.82152 -1.88156 -0.25416 -0.28106 -5.48339 --0.01373 -4.49138 -3.53707 -2.71667 -1.67877 -0.198238 --2.20243 -6.59097 1.16281 --4.24339 -6.5676 2.18361 --7.95519 -2.05606 -5.34066 --9.78409 -1.51258 -3.52723 -1.66684 -0.822699 3.94166 --4.47175 -2.91645 6.27001 --6.17993 2.03291 6.26801 --0.06856 -4.68772 3.3397 --4.31112 -0.877635 6.85233 --1.9398 -1.31762 -6.48359 --6.53041 -2.14995 -6.09524 -1.20372 -2.54078 -3.86532 --8.20402 -0.557664 5.50465 --9.07874 -3.00055 3.67243 --0.75964 -2.82958 -5.47292 --9.03926 -0.271847 -4.7713 --6.16688 -6.36753 1.63881 --1.78359 -2.44392 -6.10889 --6.39662 -4.68878 -4.5451 --0.27605 -1.87512 -5.56705 --3.20211 -6.81446 0.892359 --0.72513 -6.03295 -1.0888 --2.64373 -5.24816 -4.35865 --4.25458 -0.672617 -6.87953 --7.40821 -4.75919 -3.75268 --5.31249 -2.85204 -6.18409 --3.04836 -5.88521 -3.56599 --9.61919 -1.63758 3.7355 --1.33626 -1.33727 -6.26599 -0.85806 1.38005 4.77542 --10.5835 -1.15624 -1.77094 --1.25133 -5.11339 3.84809 --2.88844 -4.17618 -5.44532 --6.46707 -2.98281 5.76708 --1.13499 -6.30787 -0.345386 -0.10084 -4.26906 3.67787 -1.21323 -2.1682 -4.06057 --2.19326 -6.5127 1.53365 --4.32516 -5.68187 -3.9814 --1.77365 -5.40493 3.77642 --6.5934 -6.38827 0.582648 --3.65253 -6.32055 2.82353 --5.83615 -0.159794 6.67255 -1.07841 0.56995 -4.70783 --8.14504 -4.4424 -3.3859 -0.58023 1.06886 -5.11266 -0.01956 -4.6919 -3.21736 --0.80868 -5.3515 -3.11032 --0.65297 -1.65268 -5.85782 -2.37169 -2.69484 -0.543351 --1.59203 -2.15667 -6.14352 --3.00652 -6.81694 0.617727 --7.97242 -5.55335 1.20961 --10.5745 -1.9573 0.886187 --7.48186 0.54132 5.98169 --10.6586 -0.0265192 -1.85806 --5.89596 -2.8658 -6.03177 --8.4697 -2.97191 -4.42062 --10.2971 -2.1154 -1.93687 --2.33098 2.18038 6.36776 --10.4072 -1.65303 1.99485 --10.879 0.243361 -0.584187 -0.03353 -2.79223 4.94106 --3.22709 -5.70845 3.89195 --5.3808 -6.75061 -0.515171 --0.7645 -3.25565 -5.23349 --0.35146 -2.92614 -5.15721 -0.02516 -5.53974 1.23376 --5.79349 0.696611 -6.64878 --0.0153 -1.42392 5.51093 --4.2965 2.20047 6.56167 --3.00585 -0.798892 -6.7997 -1.21326 -1.21593 -4.43431 --5.1731 -2.25214 6.44517 --9.74153 -1.06068 -3.75065 --10.8066 -0.66441 -0.939142 --2.92247 -5.79785 3.6765 --8.02473 -2.44246 -5.11897 -2.22523 0.443229 -3.03928 --3.2256 1.54201 6.70724 --9.07601 -1.09354 -4.6169 --9.38886 -1.01354 -4.25806 --7.13229 -2.32188 -5.74562 --1.31139 -3.5593 5.33563 -2.60713 -0.492647 -1.99539 -2.44527 -1.62783 1.92432 --7.8024 -5.7653 0.224617 -2.85364 0.234715 0.766595 --3.88075 2.10577 6.58332 --10.7575 -1.22078 0.612905 --5.69432 -6.67775 -0.389743 --1.75212 -6.53273 -0.359583 --8.63407 -4.85569 -1.72196 --9.40618 -4.31034 -0.365146 --9.52922 -3.16091 -2.73318 --0.6094 -1.21066 -5.91981 --6.1436 -5.68354 3.33431 --10.166 -0.112853 3.13289 --7.54279 -0.192153 5.9531 -2.33995 -1.9962 -1.94964 -2.24807 -0.623559 2.9232 --9.62778 -1.93967 3.54448 --0.50043 0.673894 5.94601 --2.17571 1.66338 6.46299 --5.82315 -6.62411 0.673527 --4.43589 -0.25097 -6.8871 --6.41131 -0.871454 6.42807 --2.61557 -5.1685 4.4264 -2.00299 -2.37179 -2.54401 --6.88268 -6.27438 -0.260331 --3.09067 -6.45775 2.30783 --10.7461 1.47367 -0.176768 -1.78491 -3.27417 1.99722 --8.10173 -0.434835 -5.57342 --5.34771 -4.10019 -5.43282 -2.17215 -1.48486 -2.78382 --5.70551 -3.76507 -5.57158 -2.37141 -1.41836 -2.31663 --6.66762 1.18448 -6.28024 --9.48891 -3.5461 -2.32043 --10.6229 -1.94292 -0.110874 --9.55521 -2.72304 3.12241 --6.61735 -5.27936 -3.66118 --8.17284 -4.8675 -2.65792 --7.59154 -4.22532 4.1735 --0.75677 -4.56046 -4.13582 --3.30707 -2.08776 -6.55598 -1.31959 -4.0708 1.85178 --8.01439 -3.90196 -4.11018 -2.15352 -0.565003 -3.13413 --6.79656 -1.70126 6.10398 --10.3079 0.823873 2.72524 --5.73244 -5.83927 3.29984 --9.98866 -2.53287 2.37076 -1.97592 -2.04165 -2.88247 --5.37541 -6.74171 0.533064 --0.21985 -3.83001 4.41503 -0.68991 -4.46718 2.5388 --0.03462 2.24952 5.23837 -0.81797 -4.89536 1.07656 --5.35364 -5.8586 -3.43004 --5.46468 -5.68095 -3.67636 --10.6484 -0.849876 1.62008 --8.38025 4.30637 -3.32241 --7.42391 5.21664 -3.11428 -1.69503 2.80996 -2.86858 --9.64636 2.36144 -3.30687 --6.41343 2.53733 -6.01099 --1.8077 2.60092 -6.06311 --7.68488 4.55504 -3.80624 --3.54377 3.0601 -6.22403 --5.65173 6.6263 -1.21068 --8.94118 3.17673 -3.76733 -1.08932 1.78989 -4.40508 -1.53765 2.18335 3.60839 --5.74267 5.54411 -3.84703 --8.19588 5.15072 -2.13341 -0.5033 2.08569 -4.88256 --8.1163 3.66692 -4.28527 --6.08168 4.95873 -4.44121 --6.82777 6.33274 -0.549827 -2.09341 2.87905 1.71928 --9.33497 3.29216 -3.05643 --6.84157 4.55041 -4.46347 --4.8038 4.07596 -5.58579 -0.90562 2.36829 4.34409 --4.66066 3.16864 -6.15728 --0.26992 2.81426 -5.17286 --2.58783 2.87436 -6.17662 --5.48117 6.76921 -0.278184 -0.61051 3.02652 -4.27098 --5.0195 5.927 -3.50295 --5.25088 4.37053 -5.27912 --8.52946 5.14434 -1.26587 --4.57506 2.52567 -6.43891 -2.41788 1.77563 -1.96638 -2.44665 1.96417 1.66471 -2.54882 2.26926 -0.399513 -2.5479 2.21096 0.596737 --6.01435 6.33455 -2.03068 --6.12428 6.60017 -0.312158 --2.01596 2.21298 -6.27741 --3.77328 2.22748 -6.5638 --8.69166 4.57082 -2.40221 --4.93411 5.60952 -4.01872 --9.81028 1.84249 -3.36246 -1.33883 2.46231 -3.74028 --5.15074 3.72666 -5.76877 --0.21578 1.83529 -5.55309 --7.23188 1.99533 -5.83754 --6.31698 3.99079 -5.22721 --6.90956 5.19746 -3.63441 --7.82972 3.05208 -4.966 --8.70176 2.50469 -4.49296 --2.75684 2.40181 -6.39431 --5.78153 5.9234 -3.20251 -2.47517 2.15798 -1.28228 --5.83705 3.05422 -5.97168 --5.58219 2.4719 -6.29772 --5.44661 5.06991 -4.56156 --7.67278 5.85011 -0.853487 --1.12595 1.95268 -6.02637 --4.99755 6.46344 -2.33551 -2.03259 2.10691 -2.755 --6.51248 6.35728 -1.24284 --7.36789 5.68683 -2.23321 -1.99812 2.80807 -2.11271 -2.4352 2.43317 0.884282 --6.9531 3.36968 -5.34159 --7.75204 2.5724 -5.27722 --9.97775 2.43438 -2.60153 --9.24412 2.46036 -3.87258 --6.6187 5.77913 -2.87998 --8.57248 3.40873 -4.0168 --5.90424 3.51144 -5.7063 --3.23025 2.43554 -6.45172 --10.024 2.70784 -2.18739 --7.05562 3.7124 -5.05695 --8.18311 5.5519 -0.497821 -1.83171 1.99796 -3.23431 --3.47539 3.40853 -6.02914 -0.55636 2.59964 -4.58328 -2.13661 2.20013 2.39939 --6.01072 6.56009 -1.06716 --7.41077 2.48844 -5.53556 --6.52866 6.03024 -2.38219 --7.64954 4.07648 -4.33996 -2.21158 2.65455 -1.65446 --5.89285 4.70915 -4.78798 --5.051 6.6928 -1.4673 -2.20743 2.92606 1.027 --5.00615 4.67726 -5.06602 --7.1287 6.20136 -0.310844 --8.92626 4.1895 -2.62128 --9.65603 1.76692 -3.64839 --6.13675 5.71215 -3.36268 --3.388 1.81584 -6.66173 -0.74038 1.99828 -4.69806 --8.90743 3.70724 -3.2892 --8.34627 2.13667 -5.01793 --4.53431 2.10443 -6.58717 --7.06736 6.06797 -1.47533 --7.93411 5.57305 -1.42991 --5.58239 6.3512 -2.3361 --6.67369 1.69689 -6.18666 -2.26996 2.98794 0.197154 --10.2719 1.99876 -2.21352 --3.90756 2.66868 -6.40359 -1.81977 1.96356 3.26727 -2.68173 1.80975 0.0955933 --8.46013 3.86735 -3.72257 --5.42423 6.57023 -1.71727 --8.29398 3.0013 -4.61308 --8.17685 4.79422 -2.87852 --5.45176 6.72029 -0.855841 --6.75231 6.0631 -2.01744 -0.06019 2.63544 -5.01252 --8.98333 4.36558 -2.18326 -0.90019 2.15024 -4.46167 --8.86768 2.05345 -4.54497 --0.97647 2.5448 -5.72729 --6.54397 3.41867 -5.51006 --7.83697 5.7895 -0.383522 --6.36465 3.00537 -5.79851 -1.3021 2.77689 -3.56858 -2.41943 2.55845 -0.607956 --7.35001 4.86839 -3.70547 --2.34702 2.49763 -6.26212 --5.61016 5.37183 -4.12674 --7.92923 5.21124 -2.44386 -2.24722 2.40733 -1.86104 --6.14103 5.46613 -3.75114 --8.10021 4.25001 -3.71828 --5.30325 2.82477 -6.2135 --7.46894 5.92649 -1.12376 --5.56277 3.47843 -5.81953 --5.03356 6.81828 -0.604239 --7.84464 3.55727 -4.61365 --5.06319 6.14458 -3.07598 --1.56406 2.89855 -5.83554 --6.40012 5.14595 -4.0409 --9.3106 3.83614 -2.36869 --1.90291 1.68043 -6.39655 --6.82547 2.52027 -5.83375 -2.09567 1.75274 2.8209 --9.00812 2.64898 -4.06275 --8.03164 2.53675 -5.08127 -2.24355 1.72337 -2.49591 --5.61359 3.86589 -5.55906 -1.0219 2.78681 -3.9451 --5.07601 2.45445 -6.40829 --7.42722 3.32661 -5.07832 --8.72662 2.91625 -4.21232 --2.94968 3.10268 -6.12119 --0.15056 2.2553 -5.33076 --6.95175 4.92454 -3.95008 -1.55986 1.93589 -3.70459 --5.92725 2.04535 -6.34203 --6.43856 6.44953 -0.802544 --6.9509 4.18008 -4.74374 --1.26509 2.42027 -5.9112 --4.04907 1.77312 -6.69642 -1.56349 2.35289 -3.45054 --6.5031 4.26156 -4.91666 --9.79321 2.9389 -2.50478 --7.0168 5.73703 -2.54045 --6.70042 3.08363 -5.61881 --0.62973 2.06334 -5.71953 --4.21406 3.15755 -6.17755 --9.46126 3.44612 -2.5837 --9.71628 2.79319 -2.81763 --7.88248 4.08082 -4.11721 --7.17598 2.92177 -5.45581 --5.304 4.73007 -4.94098 --6.16437 5.9752 -2.8267 --5.43251 6.17351 -2.84328 --7.60002 4.87392 -3.44538 -2.49083 2.13232 1.15208 -2.3271 2.60382 -1.15256 --5.21672 3.2948 -5.99661 -0.73631 2.03313 4.6728 --7.9351 4.67334 -3.35758 -1.37627 1.8489 4.0023 --5.443 2.02656 -6.46946 --7.50599 5.83327 -1.44528 --8.11015 5.53337 -0.972159 --7.24988 6.09855 -0.694762 -1.79857 2.59602 2.81213 --8.53873 4.44571 -2.87057 --5.72648 4.2108 -5.26843 --6.05997 6.20467 -2.36342 --9.28954 2.87626 -3.4645 --9.13062 3.74083 -2.83886 --7.26322 4.55272 -4.13485 -2.29281 1.69802 2.33797 --9.27717 1.98278 -4.05829 --6.36721 4.62978 -4.62573 --9.49066 2.8268 -3.18165 -2.26431 2.65611 1.30178 --2.12458 3.0609 -5.9306 --7.02131 5.49789 -2.99713 --7.3959 5.45174 -2.67374 --10.4183 1.77645 -1.95853 --9.49607 3.74411 -2.08439 --8.7732 4.64402 -2.07203 --9.81213 3.17464 -2.13437 --9.14215 4.45356 -1.53767 --10.2049 3.03696 -0.785077 --10.5795 2.17867 -0.221039 --9.88794 3.27447 -1.75689 --9.68668 3.79989 -1.32209 --10.4433 2.32361 -1.15497 --8.77787 5.02987 -0.67294 --10.2887 2.92032 -0.332859 --10.2388 2.69711 -1.44637 --9.86471 3.64059 -0.914959 --9.27913 4.40776 -1.13064 --10.2491 2.51352 -1.68876 --9.66732 4.00012 -0.604186 --10.5008 2.32123 -0.66897 --10.0891 3.30031 -0.561276 --10.0738 3.11803 -1.29431 --8.97556 4.74878 -1.07447 --10.3628 2.09488 -1.79271 --10.4284 2.59432 -0.0582419 --10.3523 2.66527 -0.825039 --10.5937 1.86966 -0.926915 --9.84724 3.72017 -0.413522 --10.7482 1.53162 0.345324 --10.7787 1.17449 0.727044 --10.6081 1.84282 1.0217 --10.6565 1.89437 0.215484 --10.5146 2.21994 0.783887 --8.88728 1.01156 4.85443 --10.5965 1.56456 1.44764 --9.83832 1.29922 3.54888 --6.80734 1.96568 6.05279 --9.56371 1.02888 4.05779 --10.5406 1.37184 1.85387 --7.64891 1.85506 5.63383 --8.55478 1.21447 5.12619 --7.44064 2.44308 5.5438 --7.13859 2.35702 5.74856 --7.18438 1.51189 5.98816 --7.92841 1.43939 5.56149 --10.1459 1.19088 3.00005 --8.83701 1.5639 4.75269 --9.27238 1.03096 4.41692 --7.45109 1.48244 5.84912 --10.4715 0.988137 2.27495 --7.61932 1.03546 5.84015 --10.6732 1.09159 1.46734 --6.6722 2.42551 5.94102 --8.23897 1.40034 5.33677 --9.08875 1.34493 4.54602 --6.91374 1.15331 6.1876 --7.84854 2.22899 5.34138 --10.2983 2.29632 1.84127 --10.4666 2.48478 0.320408 --10.3852 2.63003 0.71071 --10.2586 2.64844 1.42175 -1.11336 3.70475 -2.96779 -2.20195 3.11216 -0.286618 -1.3673 4.31637 -1.03425 -0.92453 3.34011 -3.64414 -1.87952 3.57665 -1.03586 -2.07007 3.27445 0.844518 -1.40354 3.8578 -2.11825 --1.66133 3.24743 -5.68457 --0.96412 3.22117 -5.38574 -0.19549 3.23741 -4.54289 -2.15877 3.10795 -0.827658 -0.99187 4.3976 -2.09238 -1.75765 3.21127 -2.23819 -1.59017 3.82534 -1.62465 -1.17345 4.64227 -0.433504 --0.20412 3.43186 -4.74125 -1.61329 4.05602 -0.67925 -1.09118 4.63728 -1.02053 -1.77254 3.44711 -1.80425 -1.40842 3.57425 -2.54723 -1.61942 3.9427 -1.1268 -1.36871 3.19547 -3.08332 -1.13474 4.36905 -1.73724 -1.03485 4.17801 -2.4007 --0.60558 3.3195 -5.09946 -1.92697 3.35026 1.36752 -2.06871 3.07988 -1.38446 -2.00627 3.45466 -0.448391 --4.42539 6.20672 -3.10863 --4.52011 5.26471 -4.54297 --2.47782 6.13895 -2.89504 --3.94659 4.69963 -5.1385 --3.10066 5.48618 -4.19267 --3.8922 3.81409 -5.81977 --2.82731 4.01894 -5.56088 --3.23123 4.84402 -4.94773 --3.99568 5.78815 -3.87612 --3.44531 6.19916 -3.09998 --3.21548 4.2193 -5.48188 --3.56622 5.30431 -4.50044 --3.02175 6.04098 -3.29975 --4.29175 4.62891 -5.19846 --4.44494 3.96098 -5.70881 --2.90591 3.66169 -5.81161 --2.68284 5.18265 -4.47287 --3.10717 4.55961 -5.18996 --4.70826 5.77457 -3.82435 --3.09857 5.7606 -3.80732 --3.76659 4.46112 -5.34546 --2.78532 4.67446 -5.01597 --4.23937 3.54014 -5.97601 --3.57215 5.65524 -4.02777 --2.72729 5.65809 -3.84943 --3.34547 3.8228 -5.76645 --4.09229 4.22869 -5.52408 --4.23385 4.99032 -4.84825 --3.72049 5.99365 -3.48805 --2.28964 4.51838 -5.03372 --0.71651 4.2904 -4.42371 --1.81399 4.23428 -5.08809 -0.3519 4.52039 -3.05635 -0.1512 3.98034 -3.96062 --2.33196 5.78049 -3.5141 -0.67121 3.99112 -3.3136 --2.1349 5.16908 -4.29363 --1.54311 4.76019 -4.47763 --0.76635 3.63758 -4.99089 --0.93975 4.94427 -3.86149 -0.85852 4.70496 -1.68696 --0.12992 4.46488 -3.71838 -0.73023 4.34731 -2.72636 --1.44344 4.12461 -5.00946 --2.26372 4.88844 -4.65346 --2.40453 4.15281 -5.35581 --0.66106 4.86491 -3.71931 -0.38259 3.66404 -4.00534 --1.64711 3.71273 -5.39694 -0.54901 4.77611 -2.24252 --2.43648 3.62128 -5.73177 --2.33765 5.52107 -3.90368 -0.24611 4.26741 -3.52137 --0.0238 3.70937 -4.36192 --1.21042 3.71794 -5.18144 --2.15094 3.76432 -5.54828 --0.46031 3.86113 -4.58248 --0.28265 4.13537 -4.19217 --0.3163 4.98825 -3.19226 --0.66961 5.59182 -2.489 -0.19004 5.07324 -2.31595 -0.26286 5.48944 -0.358956 --1.55022 5.52041 -3.48342 -0.55588 5.08803 -1.38122 --0.13599 5.46966 -1.91764 --0.34054 5.81016 -1.1242 -0.6657 5.11431 -0.753584 --1.6617 5.05991 -4.18858 --0.19528 5.79505 -0.574216 --1.59226 5.72517 -3.13132 -0.19925 5.48311 -0.868517 --0.90843 5.24351 -3.39853 -0.21606 5.38304 -1.29958 -0.1948 5.31226 -1.61609 --1.08178 5.52228 -3.0797 --0.45462 5.32215 -2.75798 --0.21059 5.35478 -2.31559 --1.84256 5.34475 -3.88853 --0.06313 5.03074 -2.7541 -0.37296 5.08063 -1.84858 --0.78902 5.41767 -2.94376 --2.83039 6.67443 -1.49644 --3.73805 6.73886 -1.61475 --3.92626 6.56318 -2.25591 --3.3469 6.86451 -0.667447 --4.34508 6.88078 -0.692561 --2.5006 6.48363 -1.99137 --4.72572 6.71012 -1.59065 --2.68421 6.795 -0.344875 --3.0929 6.52553 -2.18758 --3.72507 6.83777 -1.05186 --2.88783 6.35454 -2.55684 --2.73623 6.7396 -0.958456 --4.25903 6.64183 -1.96818 --4.63411 6.37552 -2.67802 --4.06682 6.81346 -1.22489 --4.6227 6.80501 -1.10211 --3.69217 6.37223 -2.71101 --4.16953 6.38908 -2.69072 --3.84526 6.88169 -0.698369 --4.42465 6.52887 -2.28345 --3.2691 6.36234 -2.64378 --3.27773 6.7561 -1.27415 --2.01744 6.06373 -2.78218 --2.27656 6.6167 -1.17791 --2.3386 6.27158 -2.45264 --2.02289 6.6016 -0.746603 --0.99315 6.25757 -0.260246 --1.07593 6.02904 -1.87091 --1.80124 6.57953 -0.298983 --1.91778 6.31521 -2.00205 --1.62769 6.41633 -1.2072 --1.6551 6.13201 -2.2899 --1.0712 6.24436 -0.856194 --1.46339 5.95796 -2.5634 --0.75105 5.94836 -1.5925 --1.97227 6.42025 -1.6696 --1.17965 5.95467 -2.2292 --0.44926 5.96382 -0.253916 --1.06988 6.14992 -1.35346 --0.66685 6.03386 -0.692221 --3.47694 4.65946 5.14899 --3.94094 4.44417 5.35844 --4.68319 3.93646 5.69863 --4.38713 3.77536 5.82432 --2.94847 4.16151 5.47881 --0.39161 3.0877 5.0957 --0.99814 2.88282 5.58132 --5.60453 4.20374 5.32244 --6.1556 3.94432 5.32486 --6.18437 3.46058 5.6413 --5.79851 4.46525 5.04469 --5.40018 3.68155 5.73571 --3.19922 4.94418 4.82805 --4.53724 4.71552 5.08631 --3.6643 3.99723 5.68265 --4.70983 4.4342 5.31735 --0.0729 2.71951 5.07407 --2.56494 3.7602 5.66737 --4.28617 4.33998 5.42342 --6.66211 3.93872 5.08809 --5.46975 4.53428 5.07406 --0.58157 2.83153 5.35658 --2.93211 3.46814 5.91839 --2.90586 4.68882 5.0169 --5.16347 4.05782 5.52695 --3.95812 4.89681 4.93538 --6.18893 3.01484 5.87119 --6.5551 3.58662 5.37506 --1.82441 2.88117 5.91624 --2.50855 4.94507 4.66369 -1.083 2.97568 3.72218 --5.11085 4.97703 4.74865 -1.52153 2.85348 3.13883 --6.16957 4.99453 4.35593 --6.60806 6.43398 -0.038862 --7.62076 5.94684 0.146417 --6.28439 6.50942 0.796612 --5.51897 6.75622 0.355497 --6.58548 4.45034 4.71223 --8.39522 5.40155 0.0532568 --5.11763 6.74321 1.19413 -0.35249 2.79414 4.66374 --5.55212 5.05691 4.52761 -1.90472 2.77433 2.40294 --6.13724 6.59473 0.0517756 --5.04861 6.83691 0.354884 --5.56208 6.69197 0.887341 --6.62789 4.94646 4.15197 -0.78374 2.84948 4.17497 --8.80851 5.03754 -0.182908 --9.27617 4.54246 -0.248443 --9.51197 4.25019 0.0327273 --7.02137 6.25577 0.321148 --7.9681 5.65453 0.921387 --7.34742 6.04772 0.784519 --6.91379 6.24941 0.821254 --6.9546 3.22892 5.42525 --7.77102 3.0918 4.98807 --7.10898 3.87095 4.89312 --6.74859 2.84124 5.72979 --7.45156 3.49953 4.93521 --7.8464 4.20898 4.02935 --7.10813 4.69187 4.12568 --7.85929 4.6639 3.47679 --6.78125 6.22698 1.33786 --7.52558 4.62872 3.83983 --7.80372 3.44999 4.72099 --7.05975 5.02607 3.75092 --7.64475 5.02298 3.18252 --7.33658 4.18505 4.47437 --7.8518 3.86552 4.33775 --7.57796 5.82812 1.20798 --8.14744 5.08123 2.32036 --10.2221 3.10253 0.135775 --9.82977 3.79975 0.0879154 --9.09206 4.74519 0.109349 --8.70595 5.04889 0.978231 --8.65983 5.16105 0.429639 --8.25314 5.48079 0.6045 --9.35464 4.43957 0.416284 --9.89533 3.6104 0.813948 --9.29784 4.425 0.969505 --9.067 4.71362 0.76277 --10.0635 3.28957 0.838541 --9.5021 4.2259 0.611967 --9.62007 4.01612 0.833696 --9.01627 4.8092 0.423617 --8.75382 4.71363 1.95422 --8.48289 4.82147 2.28071 --8.74032 4.89222 1.45401 --8.42553 5.20677 1.326 --10.063 3.14911 1.3018 --9.39193 4.05936 1.75043 --9.89828 3.09418 2.03981 --8.95027 4.31274 2.35581 --9.18389 4.44871 1.36525 --9.75077 3.70092 1.32581 --9.42564 3.72902 2.27405 --9.60747 3.65401 1.90867 --9.94527 2.72073 2.3613 --2.24443 4.49191 5.02534 --1.65754 4.07667 5.13596 --0.82145 3.74136 4.94452 --1.53632 3.20975 5.65817 --2.11394 3.28501 5.82689 --2.12142 4.6878 4.79533 --1.09649 3.50001 5.27144 --0.21007 3.36584 4.7749 --2.17321 4.00631 5.38904 --1.94706 3.76963 5.46929 --1.59586 3.61911 5.42618 --1.62099 4.37782 4.8542 -0.77108 3.95821 3.18335 -1.13208 4.69764 0.0270291 -0.33018 4.65254 2.8617 --1.22912 4.4061 4.63309 -1.30813 4.44728 0.723874 -1.58468 3.35456 2.45635 -1.82397 3.807 -0.0665188 -1.10616 4.16355 2.25912 --0.61117 4.75754 3.79831 -0.62698 3.33065 4.01025 --0.19317 4.36593 3.87612 -0.90909 4.67661 1.5872 -0.0204 3.67824 4.34682 -1.55794 3.98525 1.28431 -1.76515 3.42741 1.83916 -0.32914 3.2182 4.40574 -0.39967 4.11028 3.50954 -1.15763 3.52451 3.08581 --0.34514 3.87769 4.48903 --0.86063 4.46678 4.32709 -0.60905 3.71948 3.67879 -1.47997 4.28501 -0.23803 -1.75091 3.88933 0.421522 -1.34138 3.92285 2.11227 --0.13739 4.70144 3.38975 -1.12336 4.68849 0.397763 --1.36259 4.64742 4.45684 -0.77076 4.42272 2.48866 -1.84126 3.15669 2.05634 -0.23534 3.92253 3.89247 -1.15645 4.52848 1.14175 -0.49795 4.68467 2.49979 -1.91553 3.625 0.345968 --0.78007 4.16102 4.55668 -0.89202 3.42674 3.5774 -1.05291 3.94921 2.69809 -0.84828 4.53476 2.0738 -0.94377 4.81575 0.826043 -1.30109 4.12181 1.79783 -0.56944 5.17772 0.929438 --0.32231 5.58195 1.93658 --0.46601 5.87964 1.10387 --0.33576 5.12206 2.98536 -0.45294 5.0233 1.83835 --0.22685 5.21008 2.67113 --0.09027 5.49626 1.72692 --0.6012 5.40941 2.76396 --0.0206 5.63748 0.874497 -0.20852 5.10262 2.16621 --1.28993 4.97406 4.04884 -0.25152 5.34405 1.31208 --0.00239 5.69367 -0.0773789 --0.32115 5.87891 0.555096 -0.79428 5.04718 0.162687 -0.07673 5.63644 0.220107 --3.0671 6.81775 0.701223 --3.34265 6.82139 1.04286 --2.90093 6.71881 1.23562 --3.69193 6.87504 0.659396 --4.62048 6.75671 1.33215 --2.44397 6.68437 0.92335 --0.75101 6.00706 1.29086 --1.81234 6.44423 1.32996 --1.62277 6.45213 0.950407 --1.19862 6.32007 0.710659 --1.23494 6.27195 1.12289 --3.90766 6.92261 -0.0173769 --2.53231 6.77337 0.131283 --4.53085 6.88468 0.564215 --4.57472 6.90009 0.0351289 --3.53735 6.90617 0.113743 --4.19464 6.89737 0.568279 --3.08042 6.8471 0.302087 --3.07315 6.85514 -0.0756824 --2.09825 6.64814 0.501493 --1.51913 6.47197 0.350792 --0.51377 6.00853 0.235483 --1.95915 6.6208 0.202171 --10.2534 1.61332 2.55618 --8.25645 2.0149 5.13896 --8.10826 2.69885 4.94903 --9.22286 2.46781 3.90942 --9.9755 2.33449 2.68469 --8.7829 2.01177 4.65851 --9.64884 1.80311 3.65096 --9.27772 1.68249 4.22196 --9.80314 2.03729 3.25516 --8.70273 2.55494 4.47307 --9.49191 2.69499 3.34198 --8.1573 3.45658 4.4203 --8.44308 4.32622 3.21219 --8.241 4.81517 2.74904 --8.44297 3.07232 4.41317 --8.40285 3.87069 3.7803 --8.24201 4.26094 3.53608 --8.77656 3.53999 3.66245 --9.40411 3.46515 2.71664 --9.0806 3.64317 3.09028 --9.59633 2.93841 2.92574 --8.78129 3.17155 3.96315 --9.19288 3.0759 3.50079 --9.24403 3.83778 2.52456 --9.03108 3.98198 2.7203 --3.87763 5.2702 4.54643 --4.25064 5.2017 4.61843 --5.13266 5.18279 4.50863 --6.23587 5.24193 4.00708 --2.91723 5.26666 4.40645 --2.27965 5.11751 4.38769 --1.76343 5.2036 4.05319 --0.98799 5.54679 2.9396 --1.02632 5.31107 3.38033 --1.46042 5.55133 3.32519 --0.78046 5.79353 2.08381 --1.39399 5.25622 3.73346 --0.91328 5.70372 2.48788 --1.22144 5.9775 2.2029 --1.52994 6.19331 1.92073 --1.04021 6.05134 1.69972 --1.49139 5.91266 2.65031 --2.42968 6.61131 1.39865 --2.14562 5.69365 3.52942 --2.38564 5.54695 3.86373 --1.87027 5.88671 3.02484 --2.07324 6.33656 2.0932 --2.2328 6.13354 2.7376 --1.9708 6.11798 2.56194 --5.59002 6.61205 1.38009 --7.18782 6.00172 1.49458 --8.01099 5.50091 1.40654 --4.12333 6.7702 1.47018 --5.69985 5.53873 3.86836 --3.39638 5.42376 4.31583 --6.55039 5.47431 3.48317 --5.01366 5.55229 4.06724 --6.37329 6.32911 1.60442 --4.77722 5.38543 4.3372 --3.66294 5.52675 4.21143 --4.28269 5.51652 4.22589 --7.6646 5.32617 2.61317 --8.05388 5.34729 1.89168 --7.19463 5.37367 3.08646 --7.73494 5.65581 1.58062 --2.80785 5.65594 3.87619 --2.74925 6.39117 2.4054 --2.64428 6.59572 1.66325 --2.43005 6.01142 3.11983 --4.07504 6.13808 3.26323 --3.64194 5.76576 3.87651 --5.40498 6.18951 2.8369 --6.31805 6.20461 2.12066 --4.28475 5.78695 3.85557 --5.9703 5.93742 3.06088 --5.34792 6.49598 2.0645 --3.42305 6.08446 3.30494 --5.07396 5.9928 3.37245 --5.87591 5.68895 3.55035 --3.13349 5.95482 3.47325 --6.491 5.9691 2.56584 --6.69939 5.72163 2.90958 --5.70799 6.25448 2.49784 --6.03526 6.12134 2.58733 --4.9676 6.33643 2.65531 --4.49721 6.04454 3.38807 --2.94607 6.0616 3.21282 --5.90852 6.44337 1.72824 --5.83298 6.35029 2.09258 --7.41143 5.75329 1.94553 --6.98856 5.78084 2.48493 --7.01274 5.90605 2.10555 --6.75293 6.10316 1.80762 --3.59586 6.47118 2.48911 --4.44572 6.55827 2.21836 --3.65926 6.72686 1.63259 --4.49365 6.25934 2.97418 --3.2051 6.58478 2.01173 --4.65615 6.68096 1.71725 --3.73184 6.28591 2.91912 --2.92875 6.21048 2.90962 --3.21426 6.70702 1.52796 --4.00975 6.51082 2.37536 -3 0 1025 74 -3 0 74 1193 -3 0 418 994 -3 0 1193 418 -3 0 994 540 -3 0 540 1092 -3 0 1092 1025 -3 1 18 779 -3 1 1055 18 -3 1 971 249 -3 1 249 1055 -3 1 634 557 -3 1 557 971 -3 1 1182 634 -3 1 779 948 -3 1 948 1182 -3 2 21 786 -3 2 787 21 -3 2 274 563 -3 2 786 274 -3 2 563 848 -3 2 836 787 -3 2 848 836 -3 3 706 45 -3 3 45 1185 -3 3 137 595 -3 3 606 137 -3 3 595 706 -3 3 1185 606 -3 4 406 206 -3 4 206 1118 -3 4 227 337 -3 4 1118 227 -3 4 337 401 -3 4 401 1037 -3 4 1037 406 -3 5 319 218 -3 5 218 414 -3 5 221 319 -3 5 403 221 -3 5 224 369 -3 5 414 224 -3 5 369 403 -3 6 355 229 -3 6 229 1144 -3 6 240 343 -3 6 932 240 -3 6 343 318 -3 6 318 355 -3 6 1144 932 -3 7 107 247 -3 7 869 107 -3 7 238 257 -3 7 695 238 -3 7 247 695 -3 7 257 942 -3 7 383 869 -3 7 942 383 -3 8 192 358 -3 8 368 192 -3 8 255 349 -3 8 384 255 -3 8 349 1080 -3 8 358 868 -3 8 1162 368 -3 8 868 384 -3 8 1080 1162 -3 9 1100 311 -3 9 311 1102 -3 9 673 412 -3 9 412 1100 -3 9 1102 649 -3 10 458 285 -3 10 285 656 -3 10 812 317 -3 10 317 1020 -3 10 1020 458 -3 10 656 1079 -3 10 752 812 -3 10 1079 752 -3 11 58 592 -3 11 1034 58 -3 11 87 365 -3 11 1036 87 -3 11 679 145 -3 11 145 1036 -3 11 365 1034 -3 11 592 679 -3 12 568 102 -3 12 102 724 -3 12 314 577 -3 12 724 314 -3 12 806 568 -3 12 577 999 -3 12 999 806 -3 13 510 139 -3 13 139 854 -3 13 854 435 -3 13 435 891 -3 13 547 510 -3 13 883 547 -3 13 1041 883 -3 13 891 1041 -3 14 138 492 -3 14 545 138 -3 14 856 361 -3 14 361 863 -3 14 492 856 -3 14 667 545 -3 14 863 667 -3 15 63 433 -3 15 639 63 -3 15 433 101 -3 15 101 1007 -3 15 955 639 -3 15 1008 955 -3 15 1007 1008 -3 16 967 213 -3 16 213 1070 -3 16 544 293 -3 16 293 599 -3 16 1070 523 -3 16 523 1178 -3 16 1178 544 -3 16 599 875 -3 16 875 967 -3 17 603 287 -3 17 287 760 -3 17 931 603 -3 17 906 610 -3 17 610 1026 -3 17 760 906 -3 17 1026 931 -3 18 147 732 -3 18 739 147 -3 18 732 447 -3 18 447 1104 -3 18 1103 739 -3 18 1104 779 -3 18 1055 1103 -3 19 445 217 -3 19 217 453 -3 19 497 445 -3 19 453 1151 -3 19 1176 497 -3 19 1151 1176 -3 20 205 399 -3 20 460 205 -3 20 455 279 -3 20 399 455 -3 21 748 477 -3 21 477 786 -3 21 747 748 -3 21 1018 747 -3 21 787 1018 -3 22 450 219 -3 22 219 729 -3 22 426 272 -3 22 272 450 -3 22 978 426 -3 22 729 439 -3 22 439 978 -3 23 788 271 -3 23 271 1165 -3 23 741 436 -3 23 436 788 -3 23 521 1048 -3 23 1165 521 -3 23 1048 741 -3 24 607 169 -3 24 169 1153 -3 24 766 323 -3 24 323 859 -3 24 765 494 -3 24 494 766 -3 24 859 607 -3 24 1153 765 -3 25 131 1067 -3 25 1139 131 -3 25 234 965 -3 25 1067 234 -3 25 451 539 -3 25 965 451 -3 25 539 1139 -3 26 585 300 -3 26 300 964 -3 26 397 364 -3 26 364 897 -3 26 964 397 -3 26 997 585 -3 26 897 590 -3 26 590 997 -3 27 309 898 -3 27 1122 309 -3 27 589 375 -3 27 375 601 -3 27 898 589 -3 27 601 1071 -3 27 1071 1122 -3 28 419 528 -3 28 905 419 -3 28 528 652 -3 28 861 569 -3 28 569 905 -3 28 652 861 -3 29 162 702 -3 29 1091 162 -3 29 487 768 -3 29 878 487 -3 29 702 878 -3 29 768 938 -3 29 938 1091 -3 30 294 822 -3 30 855 294 -3 30 549 815 -3 30 822 549 -3 30 815 855 -3 31 129 770 -3 31 1060 129 -3 31 136 808 -3 31 980 136 -3 31 605 507 -3 31 507 980 -3 31 770 605 -3 31 808 1131 -3 31 1131 1060 -3 32 738 268 -3 32 268 797 -3 32 472 738 -3 32 780 472 -3 32 506 657 -3 32 797 506 -3 32 657 780 -3 33 123 584 -3 33 736 123 -3 33 338 198 -3 33 198 381 -3 33 584 338 -3 33 381 538 -3 33 538 736 -3 34 260 688 -3 34 773 260 -3 34 517 773 -3 34 688 951 -3 35 254 119 -3 35 119 299 -3 35 153 157 -3 35 299 153 -3 35 157 785 -3 35 491 254 -3 35 1001 491 -3 35 785 1001 -3 36 212 685 -3 36 1135 212 -3 36 490 448 -3 36 448 969 -3 36 1186 490 -3 36 685 1186 -3 36 969 1135 -3 37 111 226 -3 37 672 111 -3 37 226 371 -3 38 277 511 -3 38 1011 277 -3 38 511 587 -3 38 587 1062 -3 38 647 1011 -3 38 1062 647 -3 39 524 304 -3 39 304 940 -3 39 663 328 -3 39 328 1166 -3 39 916 524 -3 39 940 663 -3 39 1166 916 -3 40 594 431 -3 40 431 614 -3 40 548 441 -3 40 441 703 -3 40 543 594 -3 40 1150 543 -3 40 614 548 -3 40 703 1150 -3 41 960 63 -3 41 63 981 -3 42 213 519 -3 42 648 213 -3 42 421 648 -3 42 813 421 -3 42 519 563 -3 42 563 813 -3 43 794 196 -3 43 196 1098 -3 43 550 845 -3 43 1098 550 -3 43 650 756 -3 43 845 650 -3 43 756 794 -3 44 114 222 -3 44 278 114 -3 44 222 719 -3 44 1017 278 -3 44 719 1155 -3 44 1155 1017 -3 45 708 79 -3 45 79 1185 -3 45 749 627 -3 45 627 772 -3 45 706 749 -3 45 772 708 -3 46 156 722 -3 46 1005 156 -3 46 911 230 -3 46 230 919 -3 46 722 911 -3 46 919 1005 -3 47 181 715 -3 47 849 181 -3 47 243 220 -3 47 220 398 -3 47 466 243 -3 47 398 849 -3 47 715 466 -3 48 201 436 -3 48 791 201 -3 48 436 698 -3 48 579 690 -3 48 707 579 -3 48 690 791 -3 48 698 707 -3 49 214 144 -3 49 144 926 -3 49 225 214 -3 49 591 225 -3 49 281 486 -3 49 926 281 -3 49 486 591 -3 50 248 126 -3 50 126 990 -3 50 237 248 -3 50 609 237 -3 50 671 303 -3 50 303 675 -3 50 675 609 -3 50 990 671 -3 51 637 363 -3 51 363 1117 -3 51 1117 493 -3 51 493 1199 -3 51 611 637 -3 51 1199 611 -3 52 352 654 -3 52 705 352 -3 52 370 670 -3 52 839 370 -3 52 654 839 -3 52 670 860 -3 52 767 705 -3 52 860 767 -3 53 660 385 -3 53 385 1142 -3 53 533 411 -3 53 411 660 -3 53 469 533 -3 53 680 469 -3 53 1142 680 -3 54 163 238 -3 54 764 163 -3 54 238 321 -3 54 321 1013 -3 54 635 386 -3 54 386 764 -3 54 1013 635 -3 55 676 135 -3 55 135 952 -3 55 566 259 -3 55 259 676 -3 55 952 566 -3 56 261 123 -3 56 123 736 -3 56 489 261 -3 56 736 292 -3 56 292 759 -3 56 1173 489 -3 56 759 1171 -3 56 1171 877 -3 56 877 1173 -3 57 263 740 -3 57 765 263 -3 57 316 617 -3 57 740 316 -3 57 617 416 -3 57 416 790 -3 57 790 765 -3 58 108 618 -3 58 1002 108 -3 58 618 592 -3 58 1109 1002 -3 58 1034 1109 -3 59 88 516 -3 59 876 88 -3 59 456 876 -3 59 1181 456 -3 59 516 678 -3 59 678 1181 -3 60 334 630 -3 60 789 334 -3 60 630 835 -3 60 835 645 -3 61 231 117 -3 61 117 828 -3 61 684 231 -3 61 828 378 -3 62 776 313 -3 62 535 776 -3 62 1033 535 -3 63 960 433 -3 63 639 581 -3 63 581 981 -3 64 783 467 -3 64 467 805 -3 64 805 556 -3 64 556 1087 -3 64 1087 783 -3 65 413 666 -3 65 1116 413 -3 65 534 641 -3 65 701 534 -3 65 641 1160 -3 65 666 1136 -3 65 1136 701 -3 65 1160 1116 -3 66 223 775 -3 66 1130 223 -3 66 576 465 -3 66 465 1130 -3 66 559 530 -3 66 530 576 -3 66 775 559 -3 67 142 782 -3 67 802 142 -3 67 657 427 -3 67 427 802 -3 67 478 657 -3 67 782 478 -3 68 112 188 -3 68 1045 112 -3 68 188 894 -3 68 272 426 -3 68 1126 272 -3 68 426 1045 -3 68 894 1126 -3 69 436 201 -3 69 201 945 -3 69 788 436 -3 69 502 788 -3 69 972 502 -3 69 945 615 -3 69 615 972 -3 70 160 597 -3 70 1068 160 -3 70 597 443 -3 70 443 989 -3 70 1042 541 -3 70 541 1093 -3 70 989 1042 -3 70 1093 1068 -3 71 140 536 -3 71 681 140 -3 71 536 315 -3 71 315 847 -3 71 574 816 -3 71 847 574 -3 71 816 681 -3 72 354 546 -3 72 820 354 -3 72 761 387 -3 72 387 820 -3 72 546 761 -3 73 346 182 -3 73 182 813 -3 73 1050 346 -3 73 563 704 -3 73 813 563 -3 73 704 1050 -3 74 82 183 -3 74 950 82 -3 74 183 943 -3 74 640 850 -3 74 943 640 -3 74 850 1193 -3 74 1025 950 -3 75 357 1011 -3 75 1035 357 -3 75 446 628 -3 75 742 446 -3 75 628 1035 -3 75 647 742 -3 75 1011 647 -3 76 138 638 -3 76 714 138 -3 76 514 714 -3 76 723 514 -3 76 586 723 -3 76 1086 586 -3 76 638 1086 -3 77 379 351 -3 77 351 522 -3 77 817 379 -3 77 522 474 -3 77 474 531 -3 77 531 817 -3 78 795 177 -3 78 177 1052 -3 78 208 795 -3 78 944 208 -3 78 404 692 -3 78 1052 404 -3 79 979 204 -3 79 204 1101 -3 79 1101 606 -3 79 606 1185 -3 79 708 730 -3 79 730 1081 -3 79 1081 979 -3 80 185 282 -3 80 725 185 -3 80 420 190 -3 80 190 725 -3 80 282 917 -3 80 917 420 -3 81 564 483 -3 81 483 690 -3 81 988 564 -3 81 579 682 -3 81 690 579 -3 81 682 907 -3 81 907 988 -3 82 449 183 -3 82 610 449 -3 82 950 610 -3 83 629 814 -3 83 863 629 -3 83 667 863 -3 83 1061 667 -3 83 814 929 -3 83 929 818 -3 83 818 1061 -3 84 313 694 -3 84 937 313 -3 85 400 499 -3 85 1003 400 -3 85 913 470 -3 85 470 1073 -3 85 499 1161 -3 85 562 913 -3 85 1161 562 -3 85 1073 1003 -3 86 631 336 -3 86 336 922 -3 86 527 578 -3 86 922 527 -3 86 578 867 -3 86 985 631 -3 86 867 985 -3 87 934 365 -3 87 551 473 -3 87 473 934 -3 87 733 551 -3 87 1036 733 -3 88 876 213 -3 88 213 967 -3 88 962 516 -3 88 875 784 -3 88 784 962 -3 88 967 875 -3 89 899 182 -3 89 182 1021 -3 89 1021 344 -3 89 344 1084 -3 89 600 421 -3 89 421 899 -3 89 1084 600 -3 90 141 192 -3 90 192 526 -3 90 526 475 -3 91 696 419 -3 91 419 905 -3 91 430 696 -3 91 824 430 -3 91 569 625 -3 91 905 569 -3 91 625 824 -3 92 376 963 -3 92 1108 376 -3 92 659 593 -3 92 593 1077 -3 92 1057 659 -3 92 963 842 -3 92 842 1057 -3 92 1077 1108 -3 93 870 340 -3 93 360 699 -3 93 699 870 -3 94 476 374 -3 94 374 885 -3 94 382 616 -3 94 1128 382 -3 94 596 476 -3 94 616 596 -3 94 885 1128 -3 95 308 730 -3 95 1179 308 -3 95 730 708 -3 95 708 1075 -3 95 1006 737 -3 95 737 1179 -3 95 1075 1006 -3 96 832 423 -3 96 423 1198 -3 96 737 509 -3 96 509 832 -3 96 800 737 -3 96 1198 800 -3 97 443 709 -3 97 833 443 -3 97 709 1123 -3 97 984 811 -3 97 811 1076 -3 97 1076 833 -3 97 1071 984 -3 97 1123 1071 -3 98 320 658 -3 98 752 320 -3 98 658 691 -3 98 668 728 -3 98 1089 668 -3 98 691 1089 -3 98 728 812 -3 98 812 752 -3 99 500 429 -3 99 429 615 -3 99 557 500 -3 99 971 557 -3 99 615 971 -3 100 853 529 -3 100 529 1121 -3 100 889 669 -3 100 669 936 -3 100 1047 853 -3 100 1147 889 -3 100 936 1047 -3 100 1121 1147 -3 101 159 488 -3 101 829 159 -3 101 433 829 -3 101 488 549 -3 101 549 822 -3 101 822 1007 -3 102 480 142 -3 102 142 1196 -3 102 565 480 -3 102 1124 565 -3 102 568 1124 -3 102 1196 724 -3 103 300 454 -3 103 1133 300 -3 103 454 1164 -3 103 536 823 -3 103 1164 536 -3 103 823 1120 -3 103 1120 1133 -3 104 609 675 -3 104 893 609 -3 104 656 953 -3 104 1083 656 -3 104 675 1083 -3 104 852 893 -3 104 914 852 -3 104 953 914 -3 105 440 540 -3 105 1088 440 -3 105 540 994 -3 105 774 612 -3 105 612 1088 -3 105 949 774 -3 105 1000 949 -3 105 994 1000 -3 106 534 224 -3 106 224 1040 -3 106 575 324 -3 106 324 643 -3 106 641 534 -3 106 1040 575 -3 106 809 641 -3 106 643 809 -3 107 195 743 -3 107 869 195 -3 107 529 247 -3 107 743 325 -3 107 325 1121 -3 107 1121 529 -3 108 233 618 -3 108 804 233 -3 108 359 804 -3 108 1002 359 -3 109 511 280 -3 109 280 927 -3 109 587 511 -3 109 920 587 -3 109 928 920 -3 109 927 928 -3 110 225 591 -3 110 851 225 -3 110 792 399 -3 110 399 851 -3 110 591 624 -3 110 624 792 -3 111 1127 226 -3 111 860 670 -3 111 670 1127 -3 111 672 871 -3 111 769 767 -3 111 767 860 -3 111 871 769 -3 112 1032 188 -3 112 771 572 -3 112 572 1032 -3 112 640 771 -3 112 1119 640 -3 112 1045 1119 -3 113 224 701 -3 113 983 224 -3 113 670 370 -3 113 370 750 -3 113 1136 666 -3 113 666 1145 -3 113 1127 670 -3 113 701 1136 -3 113 750 983 -3 113 1145 1127 -3 114 1163 222 -3 114 278 537 -3 114 380 1163 -3 114 1187 380 -3 114 537 841 -3 114 841 1187 -3 115 933 490 -3 115 490 1186 -3 115 857 664 -3 115 664 933 -3 115 685 1031 -3 115 1186 685 -3 115 1172 857 -3 115 1031 1172 -3 116 501 212 -3 116 212 1135 -3 116 598 501 -3 116 1016 598 -3 116 969 834 -3 116 834 1016 -3 116 1135 969 -3 117 231 687 -3 117 687 351 -3 117 351 827 -3 117 827 828 -3 118 722 265 -3 118 265 1061 -3 118 417 644 -3 118 818 417 -3 118 644 1157 -3 118 1157 722 -3 118 1061 818 -3 119 254 360 -3 119 461 299 -3 119 360 915 -3 119 935 461 -3 119 915 935 -3 120 251 699 -3 120 838 251 -3 120 831 382 -3 120 382 838 -3 120 699 491 -3 120 491 831 -3 121 651 317 -3 121 317 812 -3 121 898 651 -3 121 812 728 -3 121 728 1029 -3 121 977 898 -3 121 1029 977 -3 122 464 295 -3 122 295 1158 -3 122 344 961 -3 122 1084 344 -3 122 377 464 -3 122 961 377 -3 122 1158 1084 -3 123 261 1082 -3 123 1082 584 -3 124 661 246 -3 124 246 798 -3 124 253 661 -3 124 846 253 -3 124 798 297 -3 124 297 846 -3 125 198 350 -3 125 858 198 -3 125 350 349 -3 125 349 374 -3 125 374 858 -3 126 248 373 -3 126 373 582 -3 126 582 495 -3 126 495 990 -3 127 890 210 -3 127 210 1106 -3 127 472 662 -3 127 1106 472 -3 127 521 531 -3 127 662 521 -3 127 531 890 -3 128 844 235 -3 128 235 1056 -3 128 240 533 -3 128 793 240 -3 128 342 793 -3 128 1056 342 -3 128 533 469 -3 128 469 844 -3 129 974 770 -3 129 801 872 -3 129 1060 801 -3 129 872 974 -3 130 621 208 -3 130 208 944 -3 130 711 621 -3 131 259 566 -3 131 1139 259 -3 131 566 966 -3 131 966 631 -3 131 631 1067 -3 132 191 815 -3 132 888 191 -3 132 463 555 -3 132 1175 463 -3 132 958 488 -3 132 488 1175 -3 132 555 888 -3 132 815 958 -3 133 366 191 -3 133 191 886 -3 133 197 366 -3 133 903 197 -3 133 886 367 -3 133 367 903 -3 134 568 301 -3 134 301 897 -3 134 364 840 -3 134 897 364 -3 134 487 565 -3 134 751 487 -3 134 565 1124 -3 134 1124 568 -3 134 840 751 -3 135 294 952 -3 135 1170 294 -3 135 362 438 -3 135 496 362 -3 135 438 1170 -3 135 676 496 -3 136 581 639 -3 136 980 581 -3 136 639 583 -3 136 583 808 -3 137 185 595 -3 137 947 185 -3 137 731 307 -3 137 307 947 -3 137 606 731 -3 138 545 269 -3 138 269 638 -3 138 714 492 -3 139 758 291 -3 139 291 854 -3 139 510 1022 -3 139 1022 758 -3 140 891 536 -3 140 681 883 -3 140 883 1041 -3 140 1041 891 -3 141 358 192 -3 141 340 930 -3 141 930 358 -3 142 480 807 -3 142 939 782 -3 142 802 996 -3 142 807 939 -3 142 996 1196 -3 143 623 231 -3 143 231 684 -3 143 322 755 -3 143 755 623 -3 144 214 620 -3 144 697 515 -3 144 515 926 -3 144 620 697 -3 145 679 305 -3 145 305 784 -3 145 599 733 -3 145 875 599 -3 145 733 1036 -3 145 784 875 -3 146 719 239 -3 146 1111 719 -3 147 690 483 -3 147 483 732 -3 147 791 690 -3 147 739 791 -3 148 312 720 -3 148 901 312 -3 148 313 901 -3 148 909 313 -3 148 720 346 -3 148 346 1069 -3 148 1069 909 -3 149 307 731 -3 149 1151 307 -3 149 763 345 -3 149 345 896 -3 149 422 689 -3 149 731 422 -3 149 896 497 -3 149 497 1176 -3 149 689 763 -3 149 1176 1151 -3 150 940 304 -3 150 304 1012 -3 150 865 625 -3 150 625 887 -3 150 887 663 -3 150 663 940 -3 150 1012 865 -3 151 718 303 -3 151 303 1095 -3 151 320 718 -3 151 744 320 -3 151 339 881 -3 151 1095 339 -3 151 881 744 -3 152 925 220 -3 152 220 1177 -3 152 337 777 -3 152 1004 337 -3 152 396 1004 -3 152 1177 396 -3 152 777 805 -3 152 805 925 -3 153 946 157 -3 153 299 862 -3 153 862 655 -3 153 655 946 -3 154 371 226 -3 154 226 666 -3 154 571 371 -3 154 413 415 -3 154 666 413 -3 155 683 311 -3 155 311 1100 -3 155 412 970 -3 155 1100 412 -3 155 626 552 -3 155 552 683 -3 155 970 626 -3 156 636 265 -3 156 265 722 -3 156 405 504 -3 156 1005 405 -3 156 504 721 -3 156 721 636 -3 157 392 785 -3 157 810 392 -3 157 946 810 -3 158 389 745 -3 158 1044 389 -3 158 493 941 -3 158 1199 493 -3 158 745 611 -3 158 611 1199 -3 158 941 1044 -3 160 429 597 -3 160 972 429 -3 160 502 972 -3 160 1068 502 -3 161 195 383 -3 161 394 195 -3 161 327 580 -3 161 608 327 -3 161 383 608 -3 161 580 394 -3 162 485 702 -3 162 1078 485 -3 162 674 525 -3 162 525 1078 -3 162 1091 674 -3 163 764 236 -3 163 236 963 -3 163 257 238 -3 163 376 257 -3 163 963 376 -3 164 259 539 -3 164 1059 259 -3 164 706 505 -3 164 505 1134 -3 164 539 749 -3 164 749 706 -3 164 1134 1059 -3 165 807 267 -3 165 267 907 -3 165 682 782 -3 165 907 682 -3 165 782 939 -3 165 939 807 -3 166 247 529 -3 166 695 247 -3 166 513 321 -3 166 321 695 -3 166 1015 513 -3 166 529 558 -3 166 558 553 -3 166 553 1015 -3 167 215 335 -3 167 713 215 -3 167 223 713 -3 167 775 223 -3 167 335 622 -3 167 622 559 -3 167 559 775 -3 168 395 230 -3 168 230 1028 -3 168 932 395 -3 168 411 932 -3 168 1028 411 -3 169 607 410 -3 169 410 613 -3 169 918 471 -3 169 471 1189 -3 169 613 918 -3 169 1189 1153 -3 170 268 567 -3 170 797 268 -3 170 665 457 -3 170 457 797 -3 170 567 1019 -3 170 1019 665 -3 171 642 300 -3 171 300 1133 -3 171 550 642 -3 171 845 550 -3 171 650 845 -3 171 1120 650 -3 171 1133 1120 -3 172 723 586 -3 172 1195 723 -3 173 418 619 -3 173 949 418 -3 173 619 1140 -3 173 646 774 -3 173 884 646 -3 173 774 949 -3 173 1140 884 -3 174 877 442 -3 174 442 892 -3 174 451 489 -3 174 627 451 -3 174 489 1173 -3 174 892 627 -3 174 1173 877 -3 175 836 456 -3 175 456 1181 -3 175 678 617 -3 175 617 1018 -3 175 1181 678 -3 175 787 836 -3 175 1018 787 -3 176 317 651 -3 176 1020 317 -3 176 948 458 -3 176 458 1020 -3 176 651 634 -3 176 634 1182 -3 176 1182 948 -3 177 781 206 -3 177 206 1052 -3 177 716 331 -3 177 331 781 -3 177 1112 716 -3 177 795 1112 -3 178 590 301 -3 178 301 806 -3 178 540 993 -3 178 1064 540 -3 178 806 577 -3 178 577 1064 -3 178 993 590 -3 179 819 262 -3 179 262 826 -3 179 466 570 -3 179 573 466 -3 179 570 819 -3 179 826 573 -3 180 530 221 -3 180 221 843 -3 180 843 393 -3 180 393 1099 -3 180 561 530 -3 180 1099 561 -3 181 543 276 -3 181 276 715 -3 181 497 734 -3 181 849 497 -3 181 734 543 -3 182 720 312 -3 182 312 1021 -3 182 346 720 -3 182 899 813 -3 183 449 904 -3 183 572 771 -3 183 904 572 -3 183 771 943 -3 184 269 504 -3 184 638 269 -3 184 586 1086 -3 184 1086 638 -3 185 947 282 -3 185 725 505 -3 185 505 1114 -3 185 1114 595 -3 186 552 187 -3 186 187 1043 -3 186 298 655 -3 186 1043 298 -3 186 683 552 -3 186 655 1054 -3 186 1054 683 -3 187 552 310 -3 187 310 1129 -3 187 541 1042 -3 187 1129 541 -3 187 989 833 -3 187 833 1043 -3 187 1042 989 -3 188 629 361 -3 188 361 894 -3 188 402 629 -3 188 1032 402 -3 189 339 604 -3 189 881 339 -3 189 432 744 -3 189 753 432 -3 189 604 560 -3 189 560 759 -3 189 744 881 -3 189 759 753 -3 190 362 496 -3 190 1137 362 -3 190 420 1137 -3 190 496 725 -3 191 366 956 -3 191 390 855 -3 191 956 390 -3 191 855 815 -3 191 888 886 -3 192 368 367 -3 192 367 526 -3 193 633 326 -3 193 326 992 -3 193 635 391 -3 193 391 852 -3 193 512 633 -3 193 852 512 -3 193 957 635 -3 193 992 957 -3 194 481 444 -3 194 444 680 -3 194 680 468 -3 194 468 735 -3 194 735 481 -3 195 869 383 -3 195 394 562 -3 195 562 743 -3 196 1058 258 -3 196 258 1098 -3 196 613 712 -3 196 794 613 -3 196 712 1058 -3 197 350 578 -3 197 1080 350 -3 197 527 366 -3 197 903 368 -3 197 368 1162 -3 197 578 527 -3 197 1162 1080 -3 198 253 381 -3 198 858 253 -3 198 338 880 -3 198 880 350 -3 199 325 499 -3 199 889 325 -3 199 328 889 -3 199 1166 328 -3 199 499 916 -3 199 916 1166 -3 200 540 1064 -3 200 1092 540 -3 200 577 931 -3 200 1064 577 -3 200 610 950 -3 200 1026 610 -3 200 931 1026 -3 200 950 1025 -3 200 1025 1092 -3 201 739 249 -3 201 249 945 -3 201 791 739 -3 202 769 686 -3 202 705 769 -3 202 1063 705 -3 203 825 380 -3 203 380 1187 -3 203 726 825 -3 203 1024 726 -3 203 841 1024 -3 203 1187 841 -3 204 308 419 -3 204 979 308 -3 204 419 696 -3 204 689 422 -3 204 422 1101 -3 204 1180 689 -3 204 696 1180 -3 205 1160 399 -3 205 460 873 -3 205 873 1116 -3 205 1116 1160 -3 206 864 404 -3 206 404 1052 -3 206 406 864 -3 206 781 1118 -3 207 245 517 -3 207 941 245 -3 207 389 1044 -3 207 517 1188 -3 207 1044 941 -3 208 621 727 -3 208 727 795 -3 209 745 389 -3 209 1037 745 -3 210 235 738 -3 210 912 235 -3 210 738 1106 -3 210 890 912 -3 211 318 343 -3 211 687 318 -3 211 343 342 -3 211 342 522 -3 211 522 968 -3 211 968 687 -3 212 501 828 -3 212 895 685 -3 212 828 827 -3 212 827 895 -3 213 876 519 -3 213 648 1070 -3 214 225 643 -3 214 354 620 -3 214 821 354 -3 214 643 821 -3 215 761 335 -3 215 387 761 -3 215 920 387 -3 215 713 920 -3 216 363 826 -3 216 1117 363 -3 216 803 464 -3 216 464 1117 -3 216 826 717 -3 216 717 1190 -3 216 1190 803 -3 217 445 1115 -3 217 801 453 -3 217 783 872 -3 217 1115 783 -3 217 872 801 -3 218 319 622 -3 218 575 414 -3 218 546 575 -3 218 622 546 -3 219 387 409 -3 219 820 387 -3 219 409 729 -3 219 450 820 -3 220 243 1177 -3 220 467 398 -3 220 925 467 -3 221 1065 319 -3 221 403 843 -3 221 530 559 -3 221 559 1065 -3 222 561 653 -3 222 1163 561 -3 222 653 719 -3 223 388 647 -3 223 1130 388 -3 223 587 713 -3 223 1062 587 -3 223 647 1062 -3 224 983 369 -3 224 414 1040 -3 224 534 701 -3 225 809 643 -3 225 851 809 -3 226 1145 666 -3 226 1127 1145 -3 227 781 331 -3 227 331 1132 -3 227 777 337 -3 227 1132 777 -3 227 1118 781 -3 228 605 341 -3 228 341 716 -3 228 727 605 -3 228 716 1112 -3 228 795 727 -3 228 1112 795 -3 229 322 645 -3 229 755 322 -3 229 355 755 -3 229 630 395 -3 229 395 1144 -3 229 835 630 -3 229 645 835 -3 230 911 241 -3 230 241 1027 -3 230 630 334 -3 230 334 919 -3 230 395 630 -3 230 1027 1028 -3 231 355 318 -3 231 318 687 -3 231 623 355 -3 232 1156 521 -3 232 521 1165 -3 232 817 1156 -3 232 1174 817 -3 232 857 1172 -3 232 1191 857 -3 232 1172 1031 -3 232 1031 1174 -3 232 1165 1191 -3 233 323 618 -3 233 859 323 -3 233 757 859 -3 233 1073 757 -3 233 804 1003 -3 233 1003 1073 -3 234 1082 261 -3 234 261 1113 -3 234 986 584 -3 234 584 1082 -3 234 631 985 -3 234 1067 631 -3 234 985 867 -3 234 867 986 -3 234 1113 965 -3 235 844 408 -3 235 408 973 -3 235 973 738 -3 235 912 1056 -3 236 764 1148 -3 236 768 842 -3 236 938 768 -3 236 842 963 -3 236 1148 938 -3 237 1015 248 -3 237 609 513 -3 237 513 1015 -3 238 695 321 -3 239 653 393 -3 239 393 710 -3 239 710 632 -3 239 719 653 -3 240 793 343 -3 240 411 533 -3 240 932 411 -3 241 644 385 -3 241 385 660 -3 241 1157 644 -3 241 660 1027 -3 241 911 722 -3 241 722 1157 -3 242 611 401 -3 242 401 1023 -3 242 637 611 -3 242 1146 637 -3 242 1023 1004 -3 242 1004 1146 -3 243 573 396 -3 243 396 1177 -3 243 466 573 -3 244 403 369 -3 244 369 750 -3 244 654 393 -3 244 393 843 -3 244 843 403 -3 244 839 654 -3 244 750 839 -3 245 773 517 -3 245 542 921 -3 245 941 542 -3 245 1154 773 -3 245 921 1154 -3 246 596 588 -3 246 588 1107 -3 246 661 596 -3 246 1074 798 -3 246 1107 1074 -3 248 553 373 -3 248 1015 553 -3 249 615 945 -3 249 971 615 -3 249 739 1103 -3 249 1103 1055 -3 250 329 840 -3 250 1094 329 -3 250 364 397 -3 250 840 364 -3 250 397 830 -3 250 407 659 -3 250 830 407 -3 250 659 1094 -3 251 340 870 -3 251 930 340 -3 251 868 358 -3 251 358 930 -3 251 838 384 -3 251 384 868 -3 251 870 699 -3 252 616 382 -3 252 382 831 -3 252 392 616 -3 252 785 392 -3 252 831 491 -3 252 491 1001 -3 252 1001 785 -3 253 677 381 -3 253 1183 661 -3 253 846 677 -3 253 858 1183 -3 254 699 360 -3 254 491 699 -3 255 885 349 -3 255 384 382 -3 255 382 1128 -3 255 1128 885 -3 256 874 373 -3 256 373 936 -3 256 861 652 -3 256 652 874 -3 256 669 799 -3 256 936 669 -3 256 799 861 -3 257 376 1108 -3 257 608 942 -3 257 1077 608 -3 257 1108 1077 -3 258 580 327 -3 258 327 593 -3 258 550 1098 -3 258 1167 550 -3 258 1058 580 -3 258 593 659 -3 258 659 1167 -3 259 1139 539 -3 259 1059 676 -3 260 503 688 -3 260 908 503 -3 260 773 1154 -3 260 1154 908 -3 261 489 1113 -3 262 293 717 -3 262 1038 293 -3 262 473 551 -3 262 819 473 -3 262 551 1038 -3 262 717 826 -3 263 765 459 -3 263 459 1022 -3 263 510 740 -3 263 1022 510 -3 264 694 909 -3 264 719 1111 -3 264 1155 719 -3 264 909 1017 -3 264 1017 1155 -3 265 636 545 -3 265 545 667 -3 265 667 1061 -3 266 675 303 -3 266 303 718 -3 266 320 518 -3 266 718 320 -3 266 518 656 -3 266 656 1083 -3 266 1083 675 -3 267 807 480 -3 267 480 998 -3 267 702 485 -3 267 485 907 -3 267 998 702 -3 268 408 567 -3 268 973 408 -3 268 738 973 -3 269 721 504 -3 269 545 636 -3 269 636 721 -3 270 283 707 -3 270 780 283 -3 270 347 662 -3 270 698 347 -3 270 662 780 -3 270 707 698 -3 271 502 602 -3 271 788 502 -3 271 602 664 -3 271 664 857 -3 271 857 1191 -3 271 1191 1165 -3 272 697 450 -3 272 515 697 -3 272 1126 515 -3 273 280 574 -3 273 837 280 -3 273 482 837 -3 273 884 482 -3 273 574 646 -3 273 646 884 -3 274 477 726 -3 274 786 477 -3 274 704 563 -3 274 841 704 -3 274 726 1024 -3 274 1024 841 -3 275 455 624 -3 275 1051 455 -3 275 624 514 -3 275 514 723 -3 275 723 1051 -3 276 543 1150 -3 276 570 715 -3 276 754 570 -3 276 703 754 -3 276 1150 703 -3 277 357 547 -3 277 1011 357 -3 277 681 511 -3 277 547 681 -3 278 346 1050 -3 278 1069 346 -3 278 1050 537 -3 278 1017 909 -3 278 909 1069 -3 279 455 1051 -3 279 1051 723 -3 279 723 1195 -3 280 837 409 -3 280 409 927 -3 280 511 816 -3 280 816 574 -3 281 492 486 -3 281 520 492 -3 281 926 520 -3 282 498 372 -3 282 372 917 -3 282 947 498 -3 283 657 478 -3 283 478 707 -3 283 780 657 -3 284 980 507 -3 284 507 995 -3 284 581 980 -3 284 981 581 -3 284 621 711 -3 284 995 621 -3 284 711 981 -3 285 458 330 -3 285 330 954 -3 285 953 656 -3 285 914 953 -3 285 954 914 -3 286 447 732 -3 286 796 447 -3 286 483 564 -3 286 732 483 -3 286 564 485 -3 286 485 1078 -3 286 525 796 -3 286 1078 525 -3 287 481 760 -3 287 1169 481 -3 287 603 1184 -3 287 665 1019 -3 287 1184 665 -3 287 1019 1169 -3 288 356 417 -3 288 923 356 -3 288 814 402 -3 288 402 904 -3 288 417 818 -3 288 929 814 -3 288 818 929 -3 288 904 923 -3 289 365 991 -3 289 1034 365 -3 289 425 778 -3 289 991 425 -3 289 778 1002 -3 289 1002 1109 -3 289 1109 1034 -3 290 871 672 -3 290 686 871 -3 291 650 435 -3 291 435 854 -3 291 471 756 -3 291 758 471 -3 291 756 650 -3 292 538 532 -3 292 532 753 -3 292 736 538 -3 292 753 759 -3 293 544 717 -3 293 733 599 -3 293 1038 733 -3 294 1170 822 -3 294 855 952 -3 295 464 803 -3 295 523 600 -3 295 1178 523 -3 295 803 544 -3 295 544 1178 -3 295 600 1158 -3 296 328 663 -3 296 799 328 -3 296 569 861 -3 296 887 569 -3 296 663 887 -3 296 861 799 -3 297 668 302 -3 297 302 846 -3 297 798 589 -3 297 589 977 -3 297 977 668 -3 298 946 655 -3 298 1043 833 -3 298 833 1076 -3 298 1152 946 -3 298 1076 1105 -3 298 1105 1152 -3 299 461 700 -3 299 700 924 -3 299 924 862 -3 300 1096 454 -3 300 585 1096 -3 300 642 1014 -3 300 830 964 -3 300 1014 830 -3 301 568 806 -3 301 590 897 -3 302 532 677 -3 302 691 532 -3 302 668 1089 -3 302 677 846 -3 302 1089 691 -3 303 671 1095 -3 304 425 614 -3 304 1143 425 -3 304 524 1143 -3 304 614 1012 -3 305 592 424 -3 305 424 866 -3 305 866 516 -3 305 516 962 -3 305 679 592 -3 305 962 784 -3 306 426 978 -3 306 1045 426 -3 306 619 850 -3 306 978 619 -3 306 850 640 -3 306 640 1119 -3 306 1119 1045 -3 307 498 947 -3 307 1151 498 -3 308 528 419 -3 308 452 528 -3 308 1179 452 -3 308 1081 730 -3 308 979 1081 -3 309 500 557 -3 309 1122 500 -3 309 557 634 -3 309 634 651 -3 309 651 898 -3 310 554 462 -3 310 462 1129 -3 310 552 626 -3 310 626 554 -3 311 683 508 -3 311 508 924 -3 311 924 1102 -3 312 879 344 -3 312 344 1021 -3 312 776 535 -3 312 535 879 -3 312 901 776 -3 313 909 694 -3 313 776 901 -3 314 484 603 -3 314 724 484 -3 314 1194 577 -3 314 603 1194 -3 315 454 612 -3 315 1164 454 -3 315 536 1164 -3 315 612 774 -3 315 774 646 -3 315 646 847 -3 316 740 479 -3 316 479 902 -3 316 1018 617 -3 316 628 747 -3 316 959 628 -3 316 747 1018 -3 316 902 959 -3 319 1065 622 -3 320 752 518 -3 320 1039 658 -3 320 744 1039 -3 321 976 391 -3 321 391 1013 -3 321 513 976 -3 323 424 592 -3 323 766 424 -3 323 592 618 -3 324 575 546 -3 324 546 821 -3 324 821 643 -3 325 1161 499 -3 325 743 1192 -3 325 889 1147 -3 325 1147 1121 -3 325 1192 1161 -3 326 796 525 -3 326 525 992 -3 326 633 910 -3 326 910 796 -3 327 608 593 -3 328 799 669 -3 328 669 889 -3 329 768 751 -3 329 751 840 -3 329 842 768 -3 329 1057 842 -3 329 1094 1057 -3 330 447 910 -3 330 1104 447 -3 330 458 779 -3 330 633 512 -3 330 512 954 -3 330 910 633 -3 330 779 1104 -3 331 341 556 -3 331 716 341 -3 331 556 1132 -3 332 601 588 -3 332 588 1085 -3 332 811 601 -3 332 1085 810 -3 332 810 1105 -3 332 1105 811 -3 333 555 463 -3 333 475 526 -3 333 526 555 -3 334 405 919 -3 335 546 622 -3 335 761 546 -3 336 366 922 -3 336 956 366 -3 336 631 390 -3 336 390 956 -3 337 1023 401 -3 337 1004 1023 -3 338 867 578 -3 338 578 880 -3 338 584 986 -3 338 986 867 -3 339 671 423 -3 339 423 832 -3 339 832 604 -3 339 1095 671 -3 341 1087 556 -3 341 605 770 -3 341 770 783 -3 341 783 1087 -3 342 343 793 -3 342 474 522 -3 342 890 474 -3 342 912 890 -3 342 1056 912 -3 344 879 503 -3 344 503 961 -3 345 594 543 -3 345 543 734 -3 345 763 594 -3 345 734 896 -3 347 1053 662 -3 347 698 975 -3 347 975 741 -3 347 741 1048 -3 347 1048 1053 -3 348 746 452 -3 348 452 800 -3 348 582 874 -3 348 1197 582 -3 348 652 746 -3 348 874 652 -3 348 800 1197 -3 349 350 1080 -3 349 885 374 -3 350 880 578 -3 351 379 1141 -3 351 968 522 -3 351 687 968 -3 351 895 827 -3 351 1141 895 -3 352 693 632 -3 352 632 710 -3 352 710 654 -3 352 705 693 -3 353 464 377 -3 353 377 542 -3 353 1117 464 -3 353 542 493 -3 353 493 1117 -3 354 450 620 -3 354 820 450 -3 354 821 546 -3 355 623 755 -3 356 468 417 -3 356 735 468 -3 356 1046 735 -3 356 923 1046 -3 357 902 547 -3 357 959 902 -3 357 1035 959 -3 359 400 804 -3 359 1097 400 -3 359 778 524 -3 359 524 916 -3 359 1002 778 -3 359 916 1097 -3 361 629 863 -3 361 856 762 -3 361 762 894 -3 362 955 438 -3 362 583 1072 -3 362 1137 583 -3 362 1072 955 -3 363 573 826 -3 363 1110 573 -3 363 637 1110 -3 365 934 441 -3 365 441 991 -3 366 527 922 -3 367 368 903 -3 367 1125 526 -3 367 886 1125 -3 369 983 750 -3 370 839 750 -3 372 420 917 -3 372 1060 420 -3 372 498 453 -3 372 453 801 -3 372 801 1060 -3 373 553 936 -3 373 874 582 -3 374 476 1183 -3 374 1183 858 -3 375 589 798 -3 375 1074 601 -3 375 798 1074 -3 377 921 542 -3 377 908 921 -3 377 961 908 -3 378 501 598 -3 378 828 501 -3 379 1031 685 -3 379 685 1141 -3 379 817 1174 -3 379 1174 1031 -3 380 576 561 -3 380 561 1163 -3 380 1009 576 -3 380 825 1009 -3 381 677 538 -3 382 384 838 -3 383 942 608 -3 385 644 468 -3 385 468 1142 -3 386 635 957 -3 386 957 674 -3 386 674 1148 -3 386 1148 764 -3 387 927 409 -3 387 920 928 -3 387 928 927 -3 388 465 446 -3 388 446 742 -3 388 1130 465 -3 388 742 647 -3 390 566 855 -3 390 966 566 -3 390 631 966 -3 391 609 893 -3 391 976 609 -3 391 635 1013 -3 391 893 852 -3 392 588 1066 -3 392 1085 588 -3 392 1066 616 -3 392 810 1085 -3 393 653 1099 -3 393 654 710 -3 394 470 913 -3 394 982 470 -3 394 913 562 -3 394 580 712 -3 394 712 982 -3 395 932 1144 -3 396 573 1110 -3 396 1110 637 -3 396 637 1146 -3 396 1146 1004 -3 397 964 830 -3 398 467 445 -3 398 445 849 -3 399 792 455 -3 399 641 851 -3 399 1160 641 -3 400 1097 499 -3 400 1003 804 -3 401 611 745 -3 401 745 1037 -3 402 572 904 -3 402 1032 572 -3 402 814 629 -3 404 864 1168 -3 405 1005 919 -3 406 900 864 -3 407 642 550 -3 407 550 1167 -3 407 1014 642 -3 407 1167 659 -3 407 830 1014 -3 408 469 680 -3 408 844 469 -3 408 1049 567 -3 408 680 1049 -3 409 482 729 -3 409 837 482 -3 410 757 470 -3 410 470 982 -3 410 607 757 -3 410 712 613 -3 410 982 712 -3 411 1027 660 -3 411 1028 1027 -3 412 673 428 -3 412 428 834 -3 412 834 448 -3 412 448 970 -3 413 1116 873 -3 414 575 1040 -3 416 494 790 -3 416 866 494 -3 416 617 678 -3 416 678 866 -3 417 468 644 -3 418 850 619 -3 418 1193 850 -3 418 949 1000 -3 418 1000 994 -3 420 1131 808 -3 420 808 1138 -3 420 1060 1131 -3 420 1138 1137 -3 421 600 648 -3 421 813 899 -3 422 731 606 -3 422 606 1101 -3 423 495 582 -3 423 671 495 -3 423 582 1197 -3 423 1197 1198 -3 424 766 494 -3 424 494 866 -3 425 548 614 -3 425 991 548 -3 425 1143 778 -3 427 797 457 -3 427 457 802 -3 427 657 506 -3 427 506 797 -3 428 598 1016 -3 428 1016 834 -3 429 443 597 -3 429 709 443 -3 429 500 709 -3 429 972 615 -3 430 763 689 -3 430 689 1180 -3 430 1180 696 -3 430 1149 763 -3 430 824 1149 -3 431 594 1149 -3 431 865 614 -3 431 824 865 -3 431 1149 824 -3 432 691 658 -3 432 658 1039 -3 432 753 691 -3 432 1039 744 -3 433 960 1030 -3 434 649 1102 -3 434 924 700 -3 434 1102 924 -3 435 823 536 -3 435 536 891 -3 435 650 823 -3 436 975 698 -3 436 741 975 -3 437 496 676 -3 437 725 496 -3 437 505 725 -3 437 1134 505 -3 437 676 1059 -3 437 1059 1134 -3 438 1007 822 -3 438 822 1170 -3 438 955 1008 -3 438 1008 1007 -3 439 482 619 -3 439 729 482 -3 439 619 978 -3 440 993 540 -3 440 585 993 -3 440 1088 585 -3 441 473 703 -3 441 934 473 -3 441 548 991 -3 442 877 560 -3 442 560 882 -3 442 772 892 -3 442 1075 772 -3 442 882 1006 -3 442 1006 1075 -3 443 833 989 -3 444 481 1169 -3 444 1019 567 -3 444 567 1049 -3 444 1049 680 -3 444 1169 1019 -3 445 467 1115 -3 445 497 849 -3 446 465 825 -3 446 748 628 -3 446 825 726 -3 446 726 1090 -3 446 1090 748 -3 447 796 910 -3 448 490 626 -3 448 626 970 -3 448 834 969 -3 449 760 481 -3 449 481 1046 -3 449 610 906 -3 449 906 760 -3 449 923 904 -3 449 1046 923 -3 450 697 620 -3 451 965 489 -3 451 749 539 -3 451 627 749 -3 452 746 528 -3 452 737 800 -3 452 1179 737 -3 453 498 1151 -3 454 1096 612 -3 455 792 624 -3 456 848 519 -3 456 519 876 -3 456 836 848 -3 457 665 484 -3 457 484 996 -3 457 996 802 -3 458 948 779 -3 459 471 758 -3 459 1189 471 -3 459 758 1022 -3 459 765 1153 -3 459 1153 1189 -3 461 1010 700 -3 461 935 1010 -3 462 602 541 -3 462 541 1129 -3 462 554 664 -3 462 664 602 -3 465 576 1009 -3 465 1009 825 -3 466 715 570 -3 467 783 1115 -3 467 925 805 -3 468 680 1142 -3 470 757 1073 -3 471 794 756 -3 471 918 794 -3 472 780 662 -3 472 1106 738 -3 473 570 754 -3 473 819 570 -3 473 754 703 -3 474 890 531 -3 476 596 661 -3 476 661 1183 -3 477 1090 726 -3 477 748 1090 -3 478 682 579 -3 478 579 707 -3 478 782 682 -3 479 740 510 -3 479 510 902 -3 480 565 878 -3 480 878 998 -3 481 735 1046 -3 482 1140 619 -3 482 884 1140 -3 484 1184 603 -3 484 665 1184 -3 484 724 996 -3 485 564 988 -3 485 988 907 -3 486 492 714 -3 486 714 514 -3 486 514 1159 -3 486 1159 591 -3 487 878 565 -3 487 751 768 -3 488 958 549 -3 489 965 1113 -3 490 554 626 -3 490 933 554 -3 492 520 987 -3 492 987 856 -3 493 542 941 -3 494 765 790 -3 495 671 990 -3 497 896 734 -3 499 1097 916 -3 500 1123 709 -3 500 1122 1071 -3 500 1071 1123 -3 502 1068 602 -3 503 879 688 -3 503 908 961 -3 505 706 1114 -3 507 605 727 -3 507 727 995 -3 508 683 1054 -3 508 862 924 -3 508 1054 862 -3 509 604 832 -3 509 882 604 -3 509 737 1006 -3 509 1006 882 -3 510 547 902 -3 511 681 816 -3 512 852 914 -3 512 914 954 -3 513 609 976 -3 514 624 1159 -3 515 762 520 -3 515 520 926 -3 515 1126 762 -3 516 866 678 -3 518 1079 656 -3 518 752 1079 -3 519 848 563 -3 520 762 987 -3 521 1156 531 -3 521 662 1053 -3 521 1053 1048 -3 523 648 600 -3 523 1070 648 -3 524 778 1143 -3 525 674 957 -3 525 957 992 -3 526 1125 555 -3 528 746 652 -3 529 853 558 -3 530 561 576 -3 531 1156 817 -3 532 538 677 -3 532 691 753 -3 535 688 879 -3 535 951 688 -3 535 1033 951 -3 537 704 841 -3 537 1050 704 -3 541 602 1093 -3 544 1190 717 -3 544 803 1190 -3 547 883 681 -3 549 958 815 -3 551 733 1038 -3 553 558 853 -3 553 853 1047 -3 553 1047 936 -3 554 933 664 -3 555 886 888 -3 555 1125 886 -3 556 805 777 -3 556 777 1132 -3 559 622 1065 -3 560 604 882 -3 560 1171 759 -3 560 877 1171 -3 561 1099 653 -3 562 1192 743 -3 562 1161 1192 -3 566 952 855 -3 569 887 625 -3 574 847 646 -3 577 806 999 -3 577 1194 931 -3 580 1058 712 -3 583 639 1072 -3 583 1138 808 -3 583 1137 1138 -3 585 1088 612 -3 585 612 1096 -3 585 997 993 -3 587 920 713 -3 588 596 1066 -3 588 601 1107 -3 589 898 977 -3 590 993 997 -3 591 1159 624 -3 593 608 1077 -3 594 763 1149 -3 595 1114 706 -3 596 616 1066 -3 600 1084 1158 -3 601 811 984 -3 601 984 1071 -3 601 1074 1107 -3 602 1068 1093 -3 603 931 1194 -3 607 859 757 -3 613 794 918 -3 614 865 1012 -3 621 995 727 -3 625 865 824 -3 627 892 772 -3 628 748 747 -3 628 959 1035 -3 639 955 1072 -3 640 943 771 -3 641 809 851 -3 650 1120 823 -3 655 862 1054 -3 659 1057 1094 -3 668 1029 728 -3 668 977 1029 -3 674 1091 938 -3 674 938 1148 -3 685 895 1141 -3 686 769 871 -3 693 705 1063 -3 702 998 878 -3 705 767 769 -3 708 772 1075 -3 724 1196 996 -3 762 856 987 -3 762 1126 894 -3 770 974 783 -3 783 974 872 -3 800 1198 1197 -3 810 946 1152 -3 810 1152 1105 -3 811 1105 1076 -3 908 1154 921 -3 1200 1206 1329 -3 1200 1378 1206 -3 1200 1295 1290 -3 1200 1290 1385 -3 1200 1307 1295 -3 1200 1329 1307 -3 1200 1310 1378 -3 1200 1385 1310 -3 9 1294 1210 -3 9 1210 673 -3 9 649 1294 -3 1201 1323 1206 -3 1201 1206 1373 -3 1201 1248 1323 -3 1201 1397 1248 -3 1201 1310 1326 -3 1201 1373 1310 -3 1201 1326 1398 -3 1201 1362 1397 -3 1201 1398 1362 -3 1202 1263 1260 -3 1202 1260 1276 -3 1202 1276 1359 -3 1202 1359 1321 -3 1203 1242 1267 -3 1203 1268 1242 -3 1203 1267 1367 -3 1203 1388 1268 -3 1203 1367 1394 -3 1203 1394 1388 -3 1204 1301 1246 -3 1204 1246 1340 -3 1204 1254 1255 -3 1204 1320 1254 -3 1204 1255 1354 -3 463 1301 1204 -3 463 1204 1354 -3 1204 1363 1320 -3 1204 1340 1363 -3 1205 1324 1225 -3 1205 1225 1396 -3 1205 1258 1238 -3 1205 1238 1324 -3 1205 1357 1258 -3 1205 1336 1357 -3 41 981 1291 -3 41 1291 1392 -3 41 1316 960 -3 41 1392 1316 -3 1206 1283 1368 -3 1206 1390 1283 -3 1206 1323 1390 -3 1206 1368 1329 -3 1206 1378 1373 -3 1207 1225 1272 -3 1207 1350 1225 -3 1207 1272 1304 -3 1207 1277 1350 -3 1207 1304 1365 -3 1208 1236 1280 -3 1208 1308 1236 -3 1208 1280 1311 -3 1208 1286 1308 -3 1208 1311 1286 -3 60 645 1233 -3 60 1233 789 -3 61 1232 1253 -3 61 378 1232 -3 61 1253 684 -3 1209 1219 1295 -3 1209 1388 1219 -3 1209 1342 1268 -3 1209 1268 1388 -3 1209 1307 1270 -3 1209 1270 1349 -3 1209 1295 1307 -3 1209 1349 1342 -3 1210 1315 1243 -3 1210 1243 1353 -3 428 673 1210 -3 428 1210 1353 -3 1210 1294 1315 -3 1211 1222 1379 -3 504 1305 1211 -3 504 1211 1379 -3 90 1297 141 -3 90 475 1297 -3 1212 1325 1216 -3 1212 1216 1328 -3 1212 1228 1241 -3 1212 1252 1228 -3 1212 1241 1325 -3 1212 1292 1252 -3 1212 1328 1292 -3 1213 1230 1299 -3 1213 1310 1240 -3 1213 1299 1262 -3 1213 1262 1326 -3 1213 1326 1310 -3 93 1251 1238 -3 93 1238 1339 -3 93 1293 1251 -3 93 340 1293 -3 93 1339 360 -3 1214 1278 1294 -3 1214 1313 1278 -3 649 1214 1294 -3 649 1351 1214 -3 1214 1351 1313 -3 1215 1270 1307 -3 1215 1309 1270 -3 1215 1283 1334 -3 1215 1368 1283 -3 1215 1307 1329 -3 1215 1334 1309 -3 1215 1329 1368 -3 1216 1220 1337 -3 1216 1393 1220 -3 1216 1256 1285 -3 1216 1325 1256 -3 1216 1285 1393 -3 1216 1337 1328 -3 1217 1237 1355 -3 1217 1261 1298 -3 1217 1355 1261 -3 1217 1383 1289 -3 1217 1298 1331 -3 1217 1331 1383 -3 1218 1279 1233 -3 1218 1233 1395 -3 1218 1395 1287 -3 130 1267 1242 -3 130 1242 711 -3 130 1303 1267 -3 1219 1389 1295 -3 1219 1366 1338 -3 1219 1338 1389 -3 1219 1361 1366 -3 1219 1367 1361 -3 1219 1394 1367 -3 1219 1388 1394 -3 141 1358 340 -3 141 1297 1358 -3 143 1234 1306 -3 143 684 1234 -3 143 1306 322 -3 1220 1356 1283 -3 1220 1283 1390 -3 1220 1323 1352 -3 1220 1390 1323 -3 1220 1352 1337 -3 1220 1360 1356 -3 1220 1393 1360 -3 1221 1244 1229 -3 1221 1229 1288 -3 172 1377 1222 -3 184 1222 1377 -3 184 1379 1222 -3 1223 1304 1231 -3 1223 1231 1347 -3 1223 1365 1304 -3 1223 1347 1330 -3 1223 1330 1376 -3 1224 1313 1351 -3 1224 1364 1317 -3 1224 1351 1364 -3 159 1266 1246 -3 159 1246 488 -3 159 1296 1266 -3 159 829 1296 -3 1225 1251 1272 -3 1225 1324 1251 -3 1226 1280 1237 -3 1226 1311 1280 -3 1226 1333 1311 -3 172 586 1377 -3 1227 1315 1278 -3 1227 1346 1315 -3 1228 1252 1335 -3 1229 1244 1345 -3 1229 1285 1370 -3 1229 1386 1285 -3 1229 1370 1288 -3 1229 1345 1386 -3 1230 1275 1382 -3 1230 1382 1299 -3 184 504 1379 -3 184 1377 586 -3 1231 1239 1297 -3 1231 1304 1239 -3 1231 1297 1347 -3 1232 1327 1253 -3 378 1344 1232 -3 1232 1260 1327 -3 1232 1344 1260 -3 1233 1374 1264 -3 1233 1264 1395 -3 789 1233 1279 -3 645 1374 1233 -3 1234 1302 1235 -3 1234 1235 1306 -3 684 1253 1234 -3 1234 1253 1322 -3 322 1235 645 -3 322 1306 1235 -3 1235 1302 1264 -3 1235 1264 1374 -3 645 1235 1374 -3 1236 1261 1280 -3 1236 1312 1261 -3 1236 1282 1312 -3 1236 1387 1282 -3 1236 1308 1300 -3 1236 1300 1387 -3 1237 1280 1355 -3 1238 1251 1324 -3 1238 1258 1339 -3 1239 1272 1293 -3 1239 1304 1272 -3 1239 1293 1358 -3 1239 1358 1297 -3 1240 1290 1314 -3 1240 1385 1290 -3 1240 1310 1385 -3 1241 1256 1325 -3 1242 1268 1291 -3 711 1242 1291 -3 1243 1276 1353 -3 1243 1359 1276 -3 1243 1315 1346 -3 1243 1346 1321 -3 1243 1321 1359 -3 1244 1332 1271 -3 1244 1271 1345 -3 1244 1376 1332 -3 434 1245 649 -3 434 700 1245 -3 649 1245 1351 -3 700 1010 1245 -3 935 1364 1245 -3 935 1245 1010 -3 1245 1364 1351 -3 1246 1266 1281 -3 488 1246 1301 -3 1246 1281 1340 -3 1247 1265 1274 -3 1247 1318 1265 -3 1247 1271 1318 -3 1247 1345 1271 -3 1247 1274 1356 -3 1247 1360 1285 -3 1247 1285 1386 -3 1247 1386 1345 -3 1247 1356 1360 -3 1248 1269 1292 -3 1248 1397 1269 -3 1248 1292 1328 -3 1248 1352 1323 -3 1248 1328 1337 -3 1248 1337 1352 -3 1249 1281 1266 -3 1249 1266 1343 -3 1249 1348 1281 -3 1249 1309 1334 -3 1249 1343 1309 -3 1249 1334 1348 -3 1250 1309 1296 -3 1250 1296 1316 -3 1250 1349 1309 -3 1250 1316 1342 -3 1250 1342 1349 -3 1251 1293 1272 -3 1252 1292 1269 -3 1252 1269 1371 -3 1252 1371 1300 -3 1252 1300 1372 -3 1252 1372 1335 -3 1253 1327 1284 -3 1253 1284 1375 -3 1253 1375 1322 -3 333 1354 1255 -3 333 1255 1380 -3 333 463 1354 -3 333 1380 475 -3 334 1341 405 -3 334 789 1391 -3 334 1391 1341 -3 1254 1330 1255 -3 1254 1320 1271 -3 1254 1271 1332 -3 1254 1332 1330 -3 340 1358 1293 -3 1255 1330 1347 -3 1255 1347 1380 -3 1256 1370 1285 -3 1256 1288 1370 -3 1257 1275 1319 -3 1257 1382 1275 -3 1257 1319 1289 -3 1257 1289 1383 -3 1257 1331 1299 -3 1257 1299 1382 -3 1257 1383 1331 -3 360 1339 915 -3 1258 1357 1317 -3 1258 1317 1364 -3 915 1339 1258 -3 915 1258 935 -3 935 1258 1364 -3 1259 1300 1308 -3 1259 1372 1300 -3 1259 1335 1372 -3 378 598 1344 -3 1260 1263 1327 -3 598 1276 1260 -3 598 1260 1344 -3 1261 1355 1280 -3 1261 1312 1298 -3 1262 1312 1282 -3 1262 1282 1362 -3 1262 1298 1312 -3 1262 1381 1298 -3 1262 1299 1381 -3 1262 1398 1326 -3 1262 1362 1398 -3 1263 1284 1327 -3 1264 1302 1287 -3 1264 1287 1395 -3 405 1305 504 -3 405 1341 1305 -3 1265 1348 1274 -3 1265 1318 1363 -3 1265 1363 1340 -3 1265 1340 1369 -3 1265 1369 1348 -3 1266 1296 1343 -3 428 1276 598 -3 428 1353 1276 -3 433 1296 829 -3 433 1030 1296 -3 1267 1303 1273 -3 1267 1273 1361 -3 1267 1361 1367 -3 1268 1392 1291 -3 1268 1342 1316 -3 1268 1316 1392 -3 1269 1362 1282 -3 1269 1282 1371 -3 1269 1397 1362 -3 1270 1309 1349 -3 1271 1320 1318 -3 463 1175 1301 -3 475 1347 1297 -3 475 1380 1347 -3 488 1301 1175 -3 1274 1334 1283 -3 1274 1283 1356 -3 1274 1348 1334 -3 1278 1315 1294 -3 1279 1305 1341 -3 1279 1384 1305 -3 789 1279 1391 -3 1279 1341 1391 -3 1281 1369 1340 -3 1281 1348 1369 -3 1282 1387 1371 -3 1285 1360 1393 -3 1286 1311 1333 -3 1290 1295 1389 -3 1290 1338 1314 -3 1290 1389 1338 -3 711 1291 981 -3 1296 1309 1343 -3 1030 1316 1296 -3 1298 1381 1331 -3 1299 1331 1381 -3 1300 1371 1387 -3 1310 1373 1378 -3 960 1316 1030 -3 1317 1357 1336 -3 1318 1320 1363 -3 1330 1332 1376 -3 1213 1240 1401 -3 130 1399 1303 -3 130 944 1399 -3 1240 1314 1401 -3 1314 1338 1400 -3 1338 1366 1400 -3 1361 1402 1400 -3 1361 1400 1366 -3 1273 1402 1361 -3 1230 1401 1403 -3 1230 1403 1419 -3 1400 1407 1403 -3 1403 1407 1413 -3 1314 1400 1403 -3 1314 1403 1401 -3 1403 1413 1419 -3 78 692 1399 -3 78 1399 944 -3 1213 1401 1230 -3 1404 1411 1408 -3 1404 1408 1422 -3 1404 1422 1410 -3 1404 1418 1411 -3 1404 1417 1412 -3 1404 1412 1418 -3 1230 1409 1275 -3 1230 1419 1409 -3 404 1405 1416 -3 404 1168 1405 -3 692 1408 1399 -3 1399 1408 1420 -3 1303 1399 1420 -3 1400 1406 1407 -3 1406 1412 1407 -3 1400 1402 1406 -3 1273 1411 1406 -3 1273 1406 1402 -3 1406 1411 1418 -3 1406 1418 1412 -3 1407 1412 1415 -3 1407 1415 1413 -3 1408 1411 1414 -3 692 1423 1408 -3 1408 1414 1420 -3 1408 1416 1422 -3 1408 1423 1416 -3 404 1423 692 -3 404 1416 1423 -3 1273 1414 1411 -3 1273 1303 1414 -3 1409 1419 1413 -3 1410 1422 1416 -3 1303 1420 1414 -3 1412 1424 1415 -3 1412 1417 1424 -3 900 1426 1425 -3 864 900 1425 -3 864 1425 1168 -3 209 1426 900 -3 209 900 1037 -3 406 1037 900 -3 1405 1425 1428 -3 1168 1425 1405 -3 1425 1427 1428 -3 1425 1426 1427 -3 1427 1429 1428 -3 62 313 1430 -3 62 1430 1444 -3 313 937 1430 -3 1430 1437 1443 -3 937 1437 1430 -3 1430 1443 1451 -3 1430 1451 1444 -3 34 1434 1432 -3 34 1432 517 -3 34 951 1434 -3 62 1444 1434 -3 62 1434 1033 -3 209 1431 1426 -3 209 1448 1431 -3 1431 1448 1435 -3 84 1437 937 -3 84 1450 1437 -3 84 694 1447 -3 84 1447 1441 -3 84 1441 1450 -3 146 239 632 -3 146 632 1452 -3 146 1452 1440 -3 202 1433 1063 -3 202 1449 1433 -3 207 1446 389 -3 207 1188 1446 -3 209 389 1448 -3 264 1447 694 -3 264 1111 1447 -3 517 1432 1442 -3 1433 1439 1436 -3 1433 1436 1440 -3 632 693 1433 -3 632 1433 1440 -3 1433 1449 1439 -3 693 1063 1433 -3 389 1446 1435 -3 389 1435 1448 -3 951 1033 1434 -3 1436 1439 1438 -3 1436 1438 1453 -3 1436 1445 1440 -3 1436 1441 1445 -3 517 1442 1188 -3 632 1440 1452 -3 1441 1447 1445 -3 1188 1442 1446 -3 1431 1435 1454 -3 1427 1431 1454 -3 1426 1431 1427 -3 1405 1428 1455 -3 1405 1455 1421 -3 1429 1456 1455 -3 1428 1429 1455 -3 1427 1456 1429 -3 1427 1454 1457 -3 1427 1457 1456 -3 413 873 415 -3 1202 1470 1263 -3 1202 1477 1470 -3 1202 1321 1479 -3 1202 1479 1477 -3 1205 1465 1336 -3 1205 1396 1465 -3 1458 1464 1477 -3 1458 1481 1464 -3 1458 1477 1479 -3 1234 1459 1302 -3 1234 1322 1459 -3 1322 1468 1459 -3 1459 1468 1485 -3 1460 1478 1471 -3 1460 1471 1480 -3 1460 1472 1474 -3 1460 1475 1472 -3 1460 1474 1478 -3 1227 1461 1346 -3 1321 1461 1479 -3 1321 1346 1461 -3 1462 1468 1484 -3 1462 1485 1468 -3 1462 1476 1471 -3 1462 1471 1478 -3 1462 1478 1474 -3 1462 1484 1476 -3 1218 1287 1463 -3 1218 1463 1483 -3 1224 1317 1466 -3 1224 1466 1482 -3 1224 1473 1467 -3 1224 1467 1313 -3 1224 1482 1473 -3 1227 1278 1467 -3 1287 1302 1463 -3 1464 1469 1471 -3 1464 1481 1469 -3 1464 1476 1470 -3 1464 1470 1477 -3 1464 1471 1476 -3 1336 1465 1466 -3 1317 1336 1466 -3 1263 1470 1284 -3 1278 1313 1467 -3 1284 1484 1468 -3 1284 1468 1375 -3 1322 1375 1468 -3 1469 1480 1471 -3 1284 1470 1476 -3 1284 1476 1484 -3 1228 1486 1504 -3 1228 1335 1486 -3 1486 1494 1504 -3 1486 1514 1494 -3 1486 1495 1514 -3 1207 1491 1277 -3 1207 1508 1491 -3 1207 1365 1508 -3 1221 1500 1244 -3 1221 1288 1499 -3 1221 1499 1500 -3 1241 1487 1256 -3 1241 1504 1487 -3 1256 1487 1288 -3 1487 1494 1497 -3 1487 1504 1494 -3 1487 1497 1513 -3 1288 1487 1499 -3 1487 1513 1499 -3 1223 1244 1500 -3 1223 1376 1244 -3 1223 1500 1508 -3 1223 1508 1365 -3 1488 1498 1495 -3 1225 1350 1501 -3 1228 1504 1241 -3 1489 1497 1493 -3 1489 1493 1506 -3 1489 1513 1497 -3 1489 1506 1499 -3 1489 1499 1513 -3 1490 1502 1497 -3 1490 1497 1509 -3 1490 1510 1502 -3 1490 1509 1505 -3 1490 1505 1510 -3 1491 1506 1496 -3 1491 1496 1511 -3 1277 1491 1511 -3 1491 1508 1500 -3 1491 1500 1512 -3 1491 1512 1506 -3 1492 1501 1496 -3 1492 1496 1503 -3 1493 1497 1502 -3 1493 1502 1507 -3 1493 1503 1506 -3 1493 1507 1503 -3 1494 1509 1497 -3 1494 1505 1509 -3 1494 1514 1505 -3 1495 1498 1505 -3 1495 1505 1514 -3 1496 1501 1511 -3 1496 1506 1503 -3 1277 1501 1350 -3 1277 1511 1501 -3 1499 1512 1500 -3 1499 1506 1512 -3 1515 1523 1517 -3 1515 1517 1531 -3 1492 1503 1515 -3 1492 1515 1531 -3 1515 1530 1523 -3 1502 1530 1515 -3 1502 1515 1507 -3 1503 1507 1515 -3 1458 1461 1521 -3 1458 1479 1461 -3 1458 1521 1528 -3 1458 1528 1481 -3 1460 1526 1475 -3 1460 1480 1526 -3 1227 1533 1461 -3 1461 1533 1521 -3 1516 1523 1525 -3 1516 1529 1523 -3 1516 1524 1529 -3 1516 1542 1524 -3 1516 1525 1532 -3 1516 1532 1527 -3 1516 1527 1543 -3 1516 1539 1542 -3 1516 1543 1539 -3 1517 1523 1529 -3 1517 1529 1534 -3 1517 1534 1531 -3 1488 1520 1498 -3 1518 1528 1521 -3 1518 1521 1538 -3 1518 1538 1527 -3 1225 1501 1536 -3 1225 1536 1396 -3 1227 1467 1533 -3 1467 1519 1533 -3 1467 1539 1519 -3 1519 1521 1533 -3 1519 1538 1521 -3 1519 1527 1538 -3 1519 1543 1527 -3 1519 1539 1543 -3 1498 1520 1505 -3 1505 1520 1510 -3 1510 1520 1537 -3 1465 1534 1466 -3 1465 1541 1534 -3 1465 1536 1541 -3 1396 1536 1465 -3 1466 1524 1482 -3 1466 1540 1524 -3 1466 1534 1540 -3 1492 1536 1501 -3 1492 1531 1536 -3 1467 1473 1539 -3 1502 1522 1530 -3 1502 1537 1522 -3 1469 1526 1480 -3 1469 1535 1526 -3 1469 1481 1528 -3 1469 1528 1535 -3 1524 1540 1529 -3 1473 1482 1524 -3 1473 1524 1542 -3 1529 1540 1534 -3 1473 1542 1539 -3 1502 1510 1537 -3 1531 1534 1541 -3 1531 1541 1536 -3 1544 1545 1561 -3 1544 1566 1545 -3 1518 1527 1544 -3 1518 1544 1564 -3 1525 1544 1532 -3 1525 1557 1544 -3 1527 1532 1544 -3 1544 1557 1566 -3 1544 1561 1564 -3 1545 1550 1562 -3 1545 1566 1560 -3 1545 1562 1561 -3 1518 1546 1528 -3 1518 1564 1546 -3 1546 1550 1559 -3 1546 1562 1550 -3 1526 1535 1546 -3 1526 1546 1565 -3 1528 1546 1535 -3 1546 1559 1565 -3 1546 1561 1562 -3 1546 1564 1561 -3 1547 1552 1556 -3 1547 1556 1554 -3 1520 1555 1548 -3 1520 1548 1537 -3 1525 1553 1548 -3 1525 1548 1557 -3 1548 1553 1563 -3 1548 1555 1560 -3 1548 1560 1557 -3 1537 1548 1563 -3 1475 1549 1552 -3 1549 1556 1552 -3 1475 1526 1549 -3 1526 1565 1549 -3 1549 1558 1556 -3 1549 1559 1558 -3 1549 1565 1559 -3 1550 1551 1558 -3 1550 1558 1559 -3 1551 1554 1556 -3 1551 1556 1558 -3 1522 1553 1523 -3 1522 1523 1530 -3 1522 1563 1553 -3 1522 1537 1563 -3 1523 1553 1525 -3 1472 1475 1552 -3 1557 1560 1566 -3 1486 1583 1495 -3 1335 1580 1486 -3 1486 1580 1584 -3 1486 1584 1583 -3 1567 1575 1568 -3 1567 1568 1588 -3 1567 1570 1578 -3 1567 1588 1570 -3 1567 1572 1575 -3 1488 1577 1572 -3 1488 1495 1577 -3 1568 1575 1569 -3 1568 1569 1579 -3 1568 1579 1573 -3 1568 1573 1581 -3 1568 1581 1576 -3 1568 1576 1588 -3 1569 1575 1583 -3 1569 1586 1579 -3 1569 1584 1580 -3 1569 1580 1586 -3 1569 1583 1584 -3 1570 1574 1578 -3 1570 1576 1585 -3 1570 1588 1576 -3 1333 1571 1582 -3 1571 1576 1581 -3 1571 1585 1576 -3 1571 1581 1582 -3 1572 1577 1575 -3 1259 1308 1573 -3 1259 1573 1579 -3 1286 1573 1308 -3 1286 1582 1573 -3 1573 1582 1581 -3 1259 1580 1335 -3 1259 1579 1586 -3 1259 1586 1580 -3 1495 1587 1577 -3 1495 1583 1587 -3 1286 1333 1582 -3 1575 1577 1587 -3 1575 1587 1583 -3 1567 1590 1572 -3 1567 1578 1590 -3 1488 1589 1520 -3 1488 1572 1591 -3 1488 1591 1589 -3 1574 1590 1578 -3 1574 1592 1590 -3 1545 1601 1550 -3 1545 1600 1603 -3 1545 1560 1600 -3 1545 1603 1601 -3 1593 1599 1595 -3 1593 1606 1599 -3 1554 1593 1604 -3 1554 1606 1593 -3 1594 1596 1597 -3 1594 1598 1596 -3 1594 1597 1605 -3 1594 1600 1598 -3 1594 1603 1600 -3 1594 1601 1603 -3 1594 1605 1601 -3 1574 1595 1592 -3 1595 1599 1597 -3 1592 1595 1597 -3 1572 1596 1598 -3 1572 1602 1596 -3 1596 1602 1597 -3 1520 1589 1555 -3 1550 1601 1551 -3 1551 1601 1599 -3 1551 1599 1606 -3 1551 1606 1554 -3 1572 1598 1591 -3 1572 1590 1602 -3 1597 1599 1605 -3 1590 1597 1602 -3 1590 1592 1597 -3 1589 1598 1600 -3 1589 1591 1598 -3 1555 1589 1600 -3 1599 1601 1605 -3 1555 1600 1560 -3 20 279 1613 -3 20 1613 460 -3 37 371 1610 -3 37 1610 672 -3 1607 1608 1621 -3 1607 1632 1608 -3 1607 1621 1611 -3 1607 1611 1630 -3 1607 1630 1619 -3 154 415 1629 -3 154 1629 571 -3 1608 1609 1610 -3 1608 1625 1609 -3 1608 1610 1621 -3 1608 1620 1625 -3 1608 1632 1620 -3 172 1623 1195 -3 202 686 1633 -3 672 1610 1609 -3 672 1609 1618 -3 1609 1631 1618 -3 1609 1625 1622 -3 1609 1622 1631 -3 371 1621 1610 -3 279 1628 1613 -3 279 1623 1628 -3 279 1195 1623 -3 290 1618 1616 -3 290 1616 686 -3 290 672 1618 -3 371 571 1621 -3 571 1611 1621 -3 571 1624 1611 -3 415 1624 1629 -3 1612 1613 1628 -3 1612 1628 1623 -3 1614 1615 1616 -3 1614 1617 1615 -3 1614 1616 1618 -3 1614 1627 1617 -3 1614 1618 1631 -3 1614 1622 1627 -3 1614 1631 1622 -3 460 1635 873 -3 1615 1634 1616 -3 1615 1626 1634 -3 686 1616 1633 -3 571 1629 1624 -3 1620 1622 1625 -3 1619 1630 1636 -3 1211 1639 1637 -3 1211 1637 1222 -3 1222 1637 1655 -3 1617 1638 1649 -3 1617 1627 1638 -3 1620 1638 1622 -3 1622 1638 1627 -3 1211 1305 1639 -3 1305 1384 1639 -3 1384 1650 1639 -3 1217 1641 1237 -3 1218 1650 1279 -3 1617 1640 1645 -3 1640 1654 1645 -3 1617 1649 1640 -3 172 1222 1648 -3 1222 1655 1648 -3 1226 1237 1644 -3 1226 1644 1652 -3 172 1648 1623 -3 1237 1641 1651 -3 1641 1643 1651 -3 1237 1651 1644 -3 1275 1642 1319 -3 1289 1319 1642 -3 1643 1644 1651 -3 1643 1653 1644 -3 1644 1647 1652 -3 1644 1653 1647 -3 1615 1617 1645 -3 1615 1645 1626 -3 1279 1650 1384 -3 1409 1657 1656 -3 1275 1656 1646 -3 1275 1409 1656 -3 1409 1413 1657 -3 1413 1415 1657 -3 1415 1658 1657 -3 1405 1410 1416 -3 1405 1421 1410 -3 1217 1659 1641 -3 1217 1289 1659 -3 1641 1659 1643 -3 1289 1642 1659 -3 1642 1661 1659 -3 1643 1659 1662 -3 1659 1661 1662 -3 1642 1660 1661 -3 1438 1663 1664 -3 1663 1667 1664 -3 1626 1665 1663 -3 1663 1665 1667 -3 1616 1663 1666 -3 1616 1634 1663 -3 1438 1439 1663 -3 1439 1666 1663 -3 1626 1663 1634 -3 202 1633 1666 -3 202 1666 1449 -3 1616 1666 1633 -3 1439 1449 1666 -3 1668 1669 1672 -3 1668 1676 1669 -3 1668 1672 1670 -3 1668 1677 1676 -3 1645 1669 1676 -3 1645 1654 1669 -3 1669 1674 1672 -3 1654 1674 1669 -3 1664 1667 1673 -3 1660 1678 1661 -3 1643 1662 1671 -3 1645 1676 1665 -3 1626 1645 1665 -3 1670 1672 1674 -3 1670 1674 1675 -3 1665 1676 1673 -3 1665 1673 1667 -3 1661 1671 1662 -3 1673 1676 1677 -3 1275 1646 1642 -3 1404 1410 1680 -3 1404 1680 1417 -3 1417 1680 1681 -3 1410 1421 1680 -3 1656 1657 1682 -3 1415 1681 1658 -3 1415 1424 1681 -3 1417 1681 1424 -3 1660 1685 1683 -3 1683 1685 1684 -3 1642 1685 1660 -3 1642 1646 1685 -3 1646 1684 1685 -3 1455 1456 1680 -3 1421 1455 1680 -3 1680 1687 1681 -3 1680 1690 1687 -3 1456 1690 1680 -3 1657 1658 1686 -3 1657 1686 1682 -3 1681 1691 1686 -3 1658 1681 1686 -3 1686 1688 1689 -3 1686 1691 1688 -3 1686 1689 1693 -3 1682 1686 1693 -3 1646 1656 1684 -3 1656 1682 1684 -3 1683 1689 1688 -3 1683 1684 1689 -3 1681 1687 1691 -3 1687 1692 1691 -3 1688 1691 1692 -3 1684 1693 1689 -3 1682 1693 1684 -3 1660 1683 1697 -3 1683 1696 1697 -3 1694 1699 1701 -3 1694 1702 1699 -3 1694 1701 1695 -3 1694 1696 1702 -3 1687 1698 1703 -3 1687 1690 1698 -3 1457 1700 1698 -3 1698 1700 1703 -3 1456 1457 1698 -3 1456 1698 1690 -3 1683 1688 1702 -3 1683 1702 1696 -3 1687 1703 1692 -3 1688 1699 1702 -3 1688 1703 1699 -3 1699 1703 1705 -3 1699 1705 1704 -3 1454 1700 1457 -3 1454 1706 1700 -3 1700 1705 1703 -3 1700 1704 1705 -3 1688 1692 1703 -3 1707 1715 1708 -3 1707 1708 1718 -3 1611 1715 1707 -3 1611 1707 1630 -3 1707 1718 1712 -3 1708 1713 1709 -3 1708 1717 1713 -3 1708 1715 1716 -3 1708 1716 1717 -3 1611 1624 1715 -3 415 1711 1624 -3 415 873 1711 -3 1612 1709 1713 -3 1612 1714 1709 -3 1612 1713 1613 -3 1612 1623 1714 -3 460 1613 1710 -3 1613 1713 1710 -3 460 1710 1635 -3 1710 1716 1711 -3 1635 1710 1711 -3 1710 1713 1717 -3 1710 1717 1716 -3 1624 1711 1715 -3 873 1635 1711 -3 1711 1716 1715 -3 1719 1721 1735 -3 1719 1746 1721 -3 1719 1735 1739 -3 1719 1739 1736 -3 1719 1736 1754 -3 1719 1754 1746 -3 1720 1723 1740 -3 1720 1744 1723 -3 1472 1720 1740 -3 1636 1707 1712 -3 1630 1707 1636 -3 1637 1639 1736 -3 1637 1753 1728 -3 1637 1728 1655 -3 1637 1736 1753 -3 1302 1459 1725 -3 1459 1485 1725 -3 1721 1743 1735 -3 1721 1746 1750 -3 1708 1709 1722 -3 1708 1722 1718 -3 1709 1752 1722 -3 1712 1722 1745 -3 1712 1718 1722 -3 1722 1752 1738 -3 1639 1724 1736 -3 1639 1650 1724 -3 1723 1732 1741 -3 1723 1749 1732 -3 1723 1741 1740 -3 1723 1756 1749 -3 1462 1474 1725 -3 1462 1725 1485 -3 1218 1733 1747 -3 1218 1483 1733 -3 1218 1747 1650 -3 1724 1742 1726 -3 1724 1726 1754 -3 1724 1733 1742 -3 1724 1747 1733 -3 1724 1754 1736 -3 1650 1747 1724 -3 1302 1725 1751 -3 1474 1740 1725 -3 1725 1740 1741 -3 1725 1741 1751 -3 1463 1741 1732 -3 1463 1732 1483 -3 1302 1751 1463 -3 1463 1751 1741 -3 1726 1730 1755 -3 1726 1757 1730 -3 1726 1742 1757 -3 1726 1746 1754 -3 1726 1755 1746 -3 1727 1738 1729 -3 1727 1729 1743 -3 1728 1731 1734 -3 1728 1739 1731 -3 1648 1728 1734 -3 1648 1655 1728 -3 1728 1753 1739 -3 1709 1714 1737 -3 1709 1737 1752 -3 1729 1737 1731 -3 1729 1731 1748 -3 1729 1735 1743 -3 1729 1748 1735 -3 1729 1738 1737 -3 1730 1732 1749 -3 1730 1757 1732 -3 1714 1734 1731 -3 1714 1731 1737 -3 1731 1739 1748 -3 1732 1742 1733 -3 1483 1732 1733 -3 1732 1757 1742 -3 1623 1648 1734 -3 1623 1734 1714 -3 1472 1740 1474 -3 1735 1748 1739 -3 1736 1739 1753 -3 1737 1738 1752 -3 1721 1763 1761 -3 1721 1761 1743 -3 1721 1767 1763 -3 1721 1750 1767 -3 1722 1738 1768 -3 1722 1768 1745 -3 1730 1758 1762 -3 1730 1749 1758 -3 1758 1769 1762 -3 1758 1766 1769 -3 1749 1756 1758 -3 1759 1764 1760 -3 1759 1763 1764 -3 1759 1765 1763 -3 1760 1764 1766 -3 1727 1743 1761 -3 1727 1768 1738 -3 1761 1763 1765 -3 1730 1762 1755 -3 1762 1764 1767 -3 1762 1769 1764 -3 1750 1762 1767 -3 1746 1762 1750 -3 1746 1755 1762 -3 1763 1767 1764 -3 1764 1769 1766 -3 1723 1744 1756 -3 1472 1772 1720 -3 1720 1772 1744 -3 1758 1772 1773 -3 1744 1772 1758 -3 1758 1773 1766 -3 1744 1758 1756 -3 1547 1770 1773 -3 1547 1554 1770 -3 1547 1772 1552 -3 1547 1773 1772 -3 1770 1771 1773 -3 1760 1766 1771 -3 1472 1552 1772 -3 1766 1773 1771 -3 1774 1777 1775 -3 1774 1775 1779 -3 1775 1776 1779 -3 1780 1783 1784 -3 1781 1784 1782 -3 1782 1784 1783 -3 1785 1788 1787 -3 1785 1787 1790 -3 1570 1785 1789 -3 1570 1585 1785 -3 1571 1788 1785 -3 1571 1785 1585 -3 1785 1790 1789 -3 1774 1786 1791 -3 1574 1792 1786 -3 1786 1792 1791 -3 1226 1788 1333 -3 1226 1652 1788 -3 1774 1791 1789 -3 1774 1789 1777 -3 1652 1787 1788 -3 1647 1787 1652 -3 1647 1778 1787 -3 1570 1789 1792 -3 1570 1792 1574 -3 1333 1788 1571 -3 1777 1789 1790 -3 1789 1791 1792 -3 1775 1777 1790 -3 1774 1779 1786 -3 1779 1793 1786 -3 1593 1595 1794 -3 1593 1794 1783 -3 1593 1783 1795 -3 1593 1795 1604 -3 1574 1786 1595 -3 1595 1786 1796 -3 1786 1793 1796 -3 1760 1771 1780 -3 1771 1783 1780 -3 1595 1796 1794 -3 1782 1783 1794 -3 1782 1794 1793 -3 1793 1794 1796 -3 1770 1795 1771 -3 1604 1795 1770 -3 1554 1604 1770 -3 1771 1795 1783 -3 1435 1446 1797 -3 1442 1797 1446 -3 1436 1798 1441 -3 1436 1453 1798 -3 1437 1450 1798 -3 1441 1798 1450 -3 1438 1799 1453 -3 1454 1797 1801 -3 1797 1805 1801 -3 1435 1797 1454 -3 1442 1805 1797 -3 1800 1804 1802 -3 1800 1803 1804 -3 1432 1434 1803 -3 1432 1803 1805 -3 1432 1805 1442 -3 1437 1798 1802 -3 1437 1802 1443 -3 1443 1802 1804 -3 1434 1804 1803 -3 1434 1444 1804 -3 1443 1804 1451 -3 1444 1451 1804 -3 1453 1799 1798 -3 1798 1799 1806 -3 1800 1802 1806 -3 1800 1807 1803 -3 1798 1806 1802 -3 1801 1805 1807 -3 1803 1807 1805 -3 1438 1664 1799 -3 1668 1808 1677 -3 1664 1808 1799 -3 1664 1673 1808 -3 1673 1677 1808 -3 1668 1812 1808 -3 1668 1670 1813 -3 1668 1813 1812 -3 1670 1810 1809 -3 1670 1809 1813 -3 1809 1812 1813 -3 1799 1808 1811 -3 1799 1811 1806 -3 1670 1675 1810 -3 1679 1695 1810 -3 1809 1816 1814 -3 1809 1814 1812 -3 1808 1814 1811 -3 1808 1812 1814 -3 1814 1816 1819 -3 1811 1814 1818 -3 1814 1819 1818 -3 1700 1817 1815 -3 1700 1815 1704 -3 1815 1819 1816 -3 1815 1816 1820 -3 1815 1817 1819 -3 1704 1815 1820 -3 1701 1809 1810 -3 1701 1821 1809 -3 1809 1821 1816 -3 1800 1806 1818 -3 1800 1819 1807 -3 1800 1818 1819 -3 1806 1811 1818 -3 1454 1801 1706 -3 1801 1807 1817 -3 1706 1801 1817 -3 1699 1820 1701 -3 1699 1704 1820 -3 1700 1706 1817 -3 1807 1819 1817 -3 1695 1701 1810 -3 1701 1820 1821 -3 1816 1821 1820 -3 146 1440 1445 -3 146 1445 1447 -3 146 1447 1111 -3 1638 1824 1649 -3 1640 1825 1654 -3 1636 1827 1826 -3 1745 1768 1828 -3 1768 1833 1828 -3 1759 1832 1765 -3 1727 1761 1830 -3 1727 1830 1768 -3 1761 1829 1830 -3 1761 1765 1829 -3 1829 1831 1830 -3 1765 1834 1829 -3 1768 1830 1833 -3 1830 1831 1833 -3 1765 1832 1834 -3 1759 1760 1780 -3 1759 1780 1837 -3 1759 1837 1832 -3 1780 1784 1837 -3 1829 1835 1838 -3 1829 1834 1835 -3 1835 1837 1836 -3 1832 1837 1835 -3 1832 1835 1834 -3 1784 1836 1837 -3 1619 1636 1826 -3 1620 1823 1638 -3 1607 1619 1822 -3 1607 1822 1632 -3 1632 1822 1823 -3 1620 1632 1823 -3 1636 1712 1827 -3 1712 1828 1827 -3 1712 1745 1828 -3 1781 1782 1839 -3 1779 1839 1793 -3 1782 1793 1839 -3 1829 1842 1831 -3 1831 1842 1840 -3 1827 1828 1841 -3 1828 1840 1841 -3 1828 1831 1840 -3 1828 1833 1831 -3 1829 1838 1842 -3 1838 1845 1842 -3 1842 1845 1844 -3 1781 1843 1836 -3 1835 1836 1843 -3 1835 1843 1838 -3 1838 1843 1845 -3 1843 1844 1845 -3 1781 1836 1784 -3 1643 1846 1653 -3 1647 1653 1846 -3 1661 1847 1671 -3 1661 1678 1847 -3 1660 1697 1848 -3 1776 1839 1779 -3 1787 1849 1790 -3 1778 1849 1787 -3 1775 1790 1849 -3 1638 1823 1855 -3 1638 1855 1824 -3 1643 1854 1846 -3 1640 1649 1850 -3 1640 1850 1825 -3 1822 1857 1823 -3 1822 1851 1856 -3 1822 1856 1857 -3 1824 1853 1850 -3 1649 1824 1850 -3 1823 1857 1855 -3 1654 1825 1852 -3 1824 1855 1853 -3 1675 1860 1858 -3 1671 1847 1854 -3 1678 1861 1847 -3 1660 1861 1678 -3 1660 1848 1861 -3 1643 1671 1854 -3 1674 1852 1860 -3 1654 1852 1674 -3 1674 1860 1675 -3 1694 1695 1859 -3 1694 1859 1696 -3 1679 1859 1695 -3 1696 1859 1697 -3 1697 1859 1848 -3 1679 1858 1859 -3 1675 1858 1810 -3 1679 1810 1858 -3 1619 1851 1822 -3 1619 1826 1851 -3 1827 1841 1862 -3 1840 1862 1841 -3 1839 1864 1843 -3 1843 1864 1863 -3 1843 1863 1844 -3 1844 1863 1865 -3 1840 1865 1862 -3 1840 1842 1865 -3 1842 1844 1865 -3 1781 1839 1843 -3 1866 1870 1867 -3 1866 1867 1873 -3 1866 1882 1870 -3 1647 1846 1872 -3 1846 1884 1872 -3 1846 1854 1884 -3 1856 1867 1870 -3 1851 1862 1867 -3 1862 1876 1867 -3 1867 1876 1873 -3 1851 1867 1856 -3 1868 1871 1874 -3 1868 1879 1871 -3 1868 1872 1879 -3 1868 1881 1872 -3 1869 1877 1880 -3 1854 1869 1884 -3 1869 1880 1879 -3 1869 1879 1885 -3 1869 1885 1884 -3 1850 1853 1874 -3 1850 1874 1875 -3 1825 1850 1875 -3 1853 1870 1874 -3 1853 1855 1870 -3 1870 1882 1874 -3 1855 1857 1870 -3 1856 1870 1857 -3 1826 1862 1851 -3 1852 1875 1871 -3 1852 1871 1878 -3 1871 1875 1874 -3 1871 1877 1878 -3 1871 1880 1877 -3 1871 1879 1880 -3 1872 1885 1879 -3 1872 1884 1885 -3 1873 1876 1883 -3 1825 1875 1852 -3 1858 1860 1887 -3 1858 1887 1886 -3 1859 1886 1861 -3 1848 1859 1861 -3 1847 1886 1888 -3 1847 1861 1886 -3 1847 1889 1854 -3 1847 1888 1889 -3 1869 1887 1877 -3 1869 1888 1887 -3 1854 1889 1869 -3 1869 1889 1888 -3 1852 1878 1860 -3 1860 1878 1887 -3 1886 1887 1888 -3 1877 1887 1878 -3 1826 1827 1862 -3 1866 1873 1896 -3 1866 1893 1882 -3 1863 1894 1890 -3 1863 1890 1897 -3 1863 1864 1894 -3 1849 1891 1892 -3 1849 1895 1891 -3 1775 1849 1892 -3 1778 1895 1849 -3 1868 1874 1893 -3 1868 1893 1881 -3 1873 1890 1896 -3 1873 1897 1890 -3 1890 1894 1892 -3 1872 1891 1895 -3 1872 1881 1891 -3 1881 1893 1891 -3 1647 1872 1895 -3 1873 1883 1897 -3 1775 1892 1898 -3 1892 1894 1898 -3 1874 1882 1893 -3 1647 1895 1778 -3 1775 1898 1864 -3 1775 1864 1776 -3 1864 1898 1894 -3 1776 1864 1839 -3 1863 1897 1865 -3 1862 1865 1876 -3 1865 1883 1876 -3 1865 1897 1883 -3 1858 1886 1859 -3 1866 1896 1899 -3 1866 1899 1893 -3 1890 1892 1899 -3 1890 1899 1896 -3 1899 1892 1891 -3 1891 1893 1899 diff --git a/external/cork/samples/ballB.off b/external/cork/samples/ballB.off deleted file mode 100644 index 87cc06970..000000000 --- a/external/cork/samples/ballB.off +++ /dev/null @@ -1,5698 +0,0 @@ -OFF -1900 3796 0 -7.74171 -4.29578 4.02524 -7.6642 -4.53536 -3.84291 -0.42761 -3.38175 4.92635 --0.24296 -3.47912 -4.28423 --2.91279 0.101619 0.0623689 -4.04226 -0.0574358 6.92651 -10.9146 0.0533714 0.24182 -3.98778 -6.91992 0.0371523 -4.00943 0.0386863 -6.92778 -9.03378 1.18957 -4.65973 -5.81292 -5.07931 -4.41747 --0.4637 -4.99938 1.8558 -8.54183 -4.89138 2.02043 -3.42183 -5.06808 4.73175 -9.08514 -0.2561 4.75309 --0.67515 0.767798 -5.101 --1.33906 -3.33608 2.96183 -9.14479 -3.76101 2.82256 -7.59884 -5.05098 -3.19851 --1.77707 -3.11471 -2.27789 -6.76679 2.04724 6.04069 -1.1395 -3.64971 5.1854 -6.90505 -2.45237 5.8325 -9.78648 -2.84769 -2.62427 -1.50352 -5.78477 2.9363 -1.288 -2.56372 -5.8688 -6.66528 -5.64397 3.0985 -6.84415 -3.12705 -5.53495 -1.06629 -5.74807 -2.57234 -7.13946 -6.20364 0.0807404 -0.66899 -0.118934 -6.08942 --1.93543 -0.641833 -3.5591 -10.127 -3.28032 -0.333732 -3.51126 -2.97977 -6.25618 --1.88838 0.485767 3.6617 -6.92734 0.124539 -6.29691 -10.1822 -0.0561725 -3.16436 -3.51048 3.19039 6.15324 -3.57756 -3.40033 6.04147 -0.63399 -6.06296 -0.277572 --1.07079 -4.72227 -0.47385 --1.31022 1.50519 -4.244 --0.56053 -2.88007 4.39204 -4.01279 -6.13275 3.24967 -0.75812 -0.608595 6.11374 -0.57199 -3.83943 -4.68981 -10.2904 0.40971 2.90538 --2.22124 -2.99836 -0.628893 -9.00666 -4.37362 -2.12853 -7.20621 -0.135045 6.17036 -3.99508 -6.24429 -3.04152 --2.59686 -1.27795 1.62114 -2.76727 1.48704 6.66166 -10.636 -1.38746 1.45173 -5.22294 -6.71506 -1.21103 -0.30214 -1.56506 -5.67484 -2.78045 -3.70765 -5.75492 -1.63062 -4.9877 4.2343 -0.16099 -5.53422 1.68967 -0.03776 -4.26068 3.81993 -10.5799 1.53551 1.54193 -10.6925 1.20207 -1.36742 --1.08048 0.524064 4.72977 --1.16982 1.21543 -4.50434 --2.63345 -1.45512 -1.31869 -5.27154 1.54172 6.64343 -2.82855 -1.75295 6.60215 -9.21852 -4.60998 -0.208296 -7.9694 -1.91364 5.39912 -9.08056 -3.441 -3.31965 -8.851 -2.21978 -4.4811 -4.70362 -4.60631 5.17144 -5.50263 -1.38749 6.6269 --0.27808 -1.85536 5.16795 -8.20242 -3.69953 4.16999 -2.45448 -3.63536 5.71905 -8.50882 1.26632 5.15144 -10.6646 -1.29093 -1.41731 --2.61625 1.25725 -1.65113 -0.21418 -4.32481 -3.93613 --1.0838 -2.07056 -4.27632 -8.16944 -5.39443 -1.42633 -8.78492 -3.40457 3.75992 -9.38066 -1.04694 4.29062 --0.18636 0.940698 5.47902 -2.0658 -6.5447 1.18902 -2.38811 -1.4388 -6.58722 --1.15682 -4.38285 1.57474 --0.51458 -4.02686 3.43797 --1.31873 -1.71195 4.13843 -2.99631 1.44432 -6.70102 -0.12103 -5.4324 -1.93634 -5.32879 -6.72992 0.986656 -5.50856 1.56171 -6.58379 -5.4126 -1.05122 -6.70365 -1.26295 -4.95633 -4.04414 -2.26667 -5.37321 -4.05597 -7.67578 -2.43077 -5.38923 -5.19983 -4.64949 -5.03901 -8.06571 -3.62094 -4.35706 -2.32347 -6.65199 -0.93752 --0.07156 0.849591 -5.58402 -8.47856 -5.16726 1.35276 -5.19535 -5.51624 4.0726 -5.07864 -6.11008 -3.13464 -6.82484 -4.78518 4.21557 -5.43025 0.287066 6.77839 -3.01152 -6.84336 -0.141618 -0.72505 -5.94822 1.40433 -4.56155 -2.83588 6.30963 -6.75738 0.791856 6.32129 -3.13395 2.5212 6.41586 -8.40003 -2.46788 4.81559 -4.18188 1.58346 6.74497 -1.11173 -1.20855 6.19633 -10.1248 -1.07383 -3.10389 -10.2401 0.941198 -2.9011 -10.7347 0.480639 -1.56525 -10.0195 -0.712773 3.40074 -7.06085 0.830817 -6.17743 -5.50598 0.332179 -6.75101 -6.19997 -4.00422 -5.2627 --1.90661 -1.54477 3.31343 -3.12245 -3.03294 -6.18423 -5.34348 -2.61967 -6.29028 -3.98894 -1.55574 -6.74596 -3.09438 -6.23794 -2.90499 -10.337 -2.58873 -1.19319 -10.7855 -1.39949 0.259135 --2.09935 -1.20924 -3.07598 --2.1886 1.51645 -2.76863 -1.11379 -2.027 -5.9789 -1.33845 0.672063 -6.37383 -2.47184 -0.179113 -6.75269 -7.38863 -5.89359 1.50292 --0.22956 -0.926689 -5.44326 --1.58103 -0.151139 -4.14731 --0.65196 -3.54916 -3.77473 -8.81916 0.476624 5.0049 -3.08265 -5.21091 4.51778 -4.21223 -4.58962 5.22436 -3.76068 1.36179 -6.78885 -8.85644 -4.97082 0.581019 -10.7447 1.54915 -0.363858 -7.14861 -0.861633 6.13449 --0.81866 -4.39745 2.41259 -0.88791 0.863641 6.14983 -7.9958 -5.10569 -2.56415 --0.56774 -0.358883 5.24001 --1.20075 -3.97749 -2.36296 -0.16219 -5.69029 -1.03584 -4.00259 -5.35265 -4.44443 --2.77132 -1.38547 -0.260428 -7.6338 -0.105134 -5.92309 -4.64247 3.07991 6.19382 -9.3155 0.0885704 -4.49167 -9.9739 0.49066 3.5268 -7.03689 -0.662269 -6.20958 --2.71983 -0.23663 1.63743 -0.17169 1.65867 -5.57554 -8.88744 -2.85278 -4.069 -3.75228 -6.76547 1.44467 -6.90675 -6.25567 -0.86055 -5.40207 -6.77918 -0.322046 -0.31896 -2.79742 -5.20523 -8.54492 -5.24989 -0.513553 -3.63918 -6.74402 -1.55171 -3.81124 -1.53375 6.74969 -10.772 0.0974341 1.43448 -2.32584 -6.09623 2.86736 -9.84365 -3.67155 0.879334 -4.95534 -6.05868 3.26343 -8.36871 2.25024 4.93817 -6.58898 -4.08997 5.01488 -1.80853 -3.82249 -5.38825 -0.77917 -4.18995 4.52707 -6.82226 -4.58556 -4.42873 --2.75142 0.366488 -1.47221 -7.85244 -4.98869 2.99203 --2.22684 -2.86188 1.04671 -2.58857 -0.404945 6.77045 --1.85576 -3.56233 -1.10046 --0.95949 -1.30669 4.70595 -8.77386 -3.15172 3.99165 -9.1997 1.50001 4.38023 --0.88578 -2.75518 -4.1268 -8.23639 -0.799422 -5.45996 -8.72242 -1.3114 -4.95018 -8.57476 -1.90318 4.90253 -3.17417 -4.80904 -4.9681 --0.88314 -1.59964 -4.68663 -1.60315 -0.0333628 -6.51501 -3.32779 0.51754 -6.87316 -6.09623 -6.29708 -2.06721 -10.2078 -2.25408 2.16382 -3.35562 -6.84963 0.740749 -3.73934 -6.39827 2.65501 -3.11878 -0.540626 -6.84641 -3.81806 -2.12329 -6.60294 -1.60065 -6.48581 -0.24309 -8.44553 -4.24109 3.3153 -8.80483 -4.09065 -2.97846 -1.79421 2.50749 6.10067 -1.29515 -2.19396 6.01164 -0.05089 -4.81811 -3.11818 -6.18098 1.97327 6.28725 --2.85861 0.744908 -0.581319 --2.52141 0.464025 2.30846 --2.47384 0.801511 -2.35926 --2.80221 0.785676 1.02869 -10.5552 -2.23784 -0.437007 -10.861 -0.775751 -0.515731 -10.4577 0.185279 -2.54055 --0.78417 -3.3953 3.75034 -6.64957 -0.358351 6.41212 -4.59408 -1.91438 6.63767 --2.23812 -2.20202 2.08033 --2.12219 -2.2697 -2.34505 -4.68978 -0.55714 6.86387 -6.14356 -2.27132 6.21215 --2.54555 -2.19316 -0.559255 -3.3337 -0.646429 6.86079 -1.48365 -0.350828 6.45574 -3.51468 -2.44222 6.4769 -4.56222 0.69077 6.87086 -6.46046 0.315261 6.48553 -4.05662 2.62807 6.42167 --2.88093 -0.339151 -0.55396 --2.53664 -0.282448 -2.27267 -10.8261 0.783806 0.885425 -10.5771 0.246081 2.20862 -10.8281 0.755397 -0.929308 -10.2195 -1.89588 -2.46375 -1.27999 -6.08849 1.90443 -2.10488 -2.3994 -6.24162 -10.5643 -2.24221 0.12725 -6.17939 -6.58426 0.151972 -4.22908 -6.51528 -2.34477 -4.68902 -6.86053 -0.638015 -1.54923 0.680729 6.45859 -10.8612 -0.627948 0.707595 -10.4766 -0.534346 2.44566 --2.8147 -0.748886 0.888302 --2.49151 -2.39871 0.0456708 -3.16741 0.481318 6.85936 --2.40378 -0.0775009 2.65096 -5.94997 -2.07058 -6.33709 -3.68687 -6.8814 -0.591466 -3.36817 -6.45182 -2.46131 -8.41954 -4.25146 -3.32489 -5.88068 -6.32829 2.17812 -4.93296 0.630707 -6.83552 -6.08185 -0.373129 -6.60152 -4.57719 -2.55429 -6.42842 -6.29622 0.764483 -6.50074 -4.5612 -0.551183 -6.87338 -1.89519 -6.26262 -2.12065 -4.62729 -6.88866 0.274794 -4.39621 -6.55165 2.23757 -0.45264 -2.07618 -5.61273 --1.92814 -0.148206 3.61481 -2.30376 -3.1214 -5.9716 --1.92094 -3.25969 1.58219 -1.98444 -5.24047 4.10779 -0.1563 0.224289 5.79247 -9.74823 -0.195697 3.91764 -4.85125 -5.63386 -3.99092 -7.89711 -5.75807 -0.372013 -10.1473 -3.19435 0.612584 -9.38372 0.69114 4.35885 -9.69493 -3.74918 -1.41237 -9.73234 -2.18742 -3.30118 -7.33489 -1.80945 5.83543 -5.51774 -3.86847 5.58349 -0.5775 -2.57717 5.48566 -7.51699 1.23219 5.86903 --1.74156 -3.89841 -0.256441 -3.50151 -4.11617 5.5792 -0.25683 -0.92911 5.78193 -7.56206 2.24879 5.53857 -4.85818 -3.65212 5.86139 -7.98421 0.0551899 5.69997 --1.16899 -2.78097 -3.73278 -9.58465 -4.00766 -1.09304 --1.88366 0.679411 -3.63605 -5.88691 -5.63062 -3.639 -7.4488 -5.79918 -1.72366 -9.50152 -3.67262 2.18861 -9.57295 -1.89905 3.71874 --0.09325 -5.56152 0.718349 -2.30503 3.18729 5.94344 -3.47569 -5.66432 3.99399 -3.43218 -4.00072 -5.66481 --1.55323 -3.5166 2.25088 -0.39184 -0.585318 -5.9057 --1.7713 -2.25299 3.12964 -0.92052 -6.00483 -1.61071 -5.63081 -3.33445 -5.88266 -7.85296 -1.27839 -5.64595 -7.4869 0.30054 -6.00135 -5.78352 -5.82715 3.36956 -7.67084 -5.46822 2.27303 -4.9219 -3.7885 -5.76409 -4.11123 -5.83182 -3.78548 --0.09841 -5.59855 -0.144876 --0.06642 -4.90098 2.80482 -7.66621 -3.11478 5.0486 --1.18783 -3.41896 -3.13531 -0.83504 -5.11668 -3.50231 -7.12434 -3.65565 -5.04805 -9.32288 -0.726714 -4.42533 -8.68113 0.453664 -5.12546 --1.12934 -0.595932 4.67097 --0.65412 0.196323 5.18032 -8.77246 -4.67328 2.00209 -5.57351 -4.82075 4.78019 -1.81699 -4.35373 4.9741 -6.2771 -4.64964 -4.66546 -10.905 0.158083 -0.471641 -4.02056 -0.484767 6.89944 -4.62559 -5.26018 -4.52057 -4.60675 -6.72915 -1.55835 -10.7457 1.48814 0.512292 -1.05402 -5.72236 2.6063 -5.61003 -0.335139 6.73271 -2.2879 -6.70352 0.158035 -6.48269 -6.12127 -2.16523 -4.36989 -6.73201 1.57311 -1.19736 -6.2639 -0.973719 -6.24071 -6.44044 1.30592 -6.71143 -5.60089 -3.12918 --2.77082 -0.575154 -1.29867 -6.85184 -1.77993 -6.08065 -2.06414 1.65419 -6.45676 -10.449 1.1959 2.27656 -4.48082 -1.57635 6.72602 -1.57711 -1.05661 -6.41171 --2.87909 -0.636012 -0.155407 -3.02436 -2.23835 -6.49369 -3.26083 -5.41939 -4.29863 -4.6589 1.29113 -6.77716 --2.53808 -0.868277 -2.13347 -10.8015 -1.27143 -0.444625 -10.9058 -0.431498 -0.162394 --1.60448 -1.04921 3.98323 --1.24633 -4.23575 -1.67361 --0.33518 -1.30529 5.28597 -9.88713 -3.26578 -1.75323 -2.26602 -5.97278 -3.09626 -4.25873 -0.740283 -6.8787 -3.54881 -1.25081 -6.79759 -10.7526 -0.410315 -1.52376 -2.21044 1.47628 6.5385 --2.31538 -1.08682 2.63604 -6.15011 -1.14369 6.50302 -10.8984 0.584386 -0.0566725 -9.88861 -2.00359 3.11426 -2.98189 -4.16048 5.47816 -3.94914 0.543639 -6.90074 -0.88372 -6.15311 0.710036 -6.22007 1.19233 -6.46733 -8.66607 -1.06797 5.0609 --0.95781 -0.793068 -4.81264 --2.53117 -1.96154 1.20579 -6.78929 -5.97963 2.21166 --0.70205 -4.99723 1.05212 -2.34448 -0.57298 -6.70275 -2.631 0.439609 -6.77281 -3.47667 0.117468 -6.90036 -4.07954 0.546896 6.8967 -3.59648 1.57396 6.73313 -4.18491 3.27806 6.12538 --1.65774 -2.16373 -3.40465 -2.61588 -6.45102 -2.13635 -4.58295 -1.57112 -6.72378 -6.49195 -2.7849 -5.86035 -5.31434 -6.76815 0.668509 --2.10337 -1.20025 3.08171 -10.45 1.36861 -2.17046 -10.5233 -0.940832 -2.16951 -1.69373 -1.39208 6.40039 -4.21399 -2.88843 -6.31118 -5.31924 -0.635073 -6.77578 -3.69576 -6.88249 0.608639 -4.49965 -0.093146 -6.9006 -10.4124 -1.379 2.26188 -6.05128 -6.5618 -0.937183 -5.406 -2.33301 6.39178 -2.83084 -2.74139 6.26157 --2.73069 0.555891 1.53441 -1.27771 -0.927839 -6.31996 -5.23015 -6.449 -2.26928 -6.43437 -0.920068 -6.4336 -2.30967 0.456685 6.70629 -3.29185 -6.71687 1.5319 -10.7927 0.416058 1.29137 --2.70021 -1.69268 0.337507 -6.54927 -5.86055 2.74049 --2.26311 -2.67325 -1.28522 -6.26481 1.41535 6.40845 -1.41701 -6.36137 0.901856 --2.8969 -0.0678978 0.508785 -9.08782 -2.18452 4.23285 -3.54391 0.179376 6.89403 --2.74399 1.41572 -0.69886 -10.0744 1.36687 3.09107 --2.88615 0.570154 0.0136537 -5.42245 -6.36384 2.3781 -10.454 -2.40127 0.915576 -5.56526 -2.9979 6.07721 -2.67345 -6.39075 2.33756 -10.7493 -0.487558 1.49092 -9.48319 0.893557 -4.18933 -5.22718 2.4493 6.3787 -4.48281 -0.100659 6.90202 -5.51479 3.21185 5.97198 -1.05649 -4.96219 3.88505 -9.97146 -1.50803 3.23686 -7.35788 -3.96049 4.66006 -0.49232 -5.29964 -2.82595 --1.5164 -1.44236 -3.97994 --0.84482 -2.28644 4.44473 --0.62638 -4.27487 -2.95568 -3.02671 -5.74442 -3.76382 -0.75104 -5.33624 3.0537 --0.26437 -5.46215 0.330624 -7.43393 -2.39082 5.56804 -9.53455 -4.21801 0.129861 -9.71071 1.51312 -3.68188 -8.23197 -3.18381 -4.54451 --0.39656 -4.9169 -2.19766 --0.75562 -4.93134 -1.17279 -4.10124 -4.66503 -5.16356 --0.60687 1.23043 -5.07594 -8.17071 1.238 -5.42765 -4.22974 -5.41515 4.35941 -9.3578 -3.71529 -2.47428 --0.35109 -2.07759 -5.01195 --0.44788 -0.291357 -5.341 -6.72013 -3.15367 5.57648 -7.14683 -4.98823 3.71315 --1.24376 -4.53733 0.420273 -1.87127 -4.47373 -4.89376 -8.37757 -2.32379 -4.89951 -10.0683 -2.87572 1.80583 --2.18613 -2.67082 -1.63941 -1.96422 -2.89277 5.98492 -7.33445 -5.5609 -2.55119 -9.91836 0.261511 -3.63999 -9.37258 -2.92114 3.35323 -6.68509 -1.67787 6.18705 -1.31033 -3.18347 -5.57448 -1.50234 -5.60238 -3.27823 --1.81605 -2.39503 -2.94553 -5.77955 -5.37406 4.0506 -7.01618 1.83476 5.99112 --0.03541 -3.84842 4.16333 -9.4463 -4.24457 0.934153 -6.57504 -5.20655 -3.85909 -2.20928 -5.58231 3.73233 -6.25383 2.52167 6.07018 -7.25671 1.07343 -6.04329 -9.54943 -1.54134 -3.90897 -1.59478 1.62178 -6.3114 --2.21069 -1.80331 2.51759 -2.22731 -2.26262 6.31372 --2.23555 -3.01179 0.174833 --2.49936 -1.89052 -1.49062 -10.2546 -1.8682 2.39691 -10.5845 -1.90512 1.08246 -2.33262 -6.54185 1.55318 -2.96687 -5.92658 3.46836 -10.1683 -3.1379 -0.657129 --1.63064 -3.96184 0.935279 -10.635 -1.57126 -1.25116 -2.72114 1.5642 -6.63213 -5.03437 -1.67133 -6.64332 -1.09182 -3.04122 5.53313 -9.12922 -4.56815 -1.2027 -2.47643 -4.88581 4.70658 -8.16341 -5.56224 0.527201 -9.78729 -2.9403 2.52092 -6.27499 -3.37251 5.6522 -8.10772 -5.20741 -2.13826 -9.25527 -4.36305 1.37814 -7.62982 -5.89378 -0.756605 -7.89674 0.361361 5.75264 -7.14068 -6.14507 0.850717 -0.71563 1.10338 -6.03205 -2.0882 -3.32071 -5.79973 -9.8668 -0.416466 -3.70654 -6.0747 0.211583 -6.61136 -8.51918 0.0127358 5.29999 --2.51095 -1.10316 2.03234 -1.08054 -5.29253 3.43897 -2.97491 -5.98989 -3.36426 --0.54519 -1.47699 -5.05852 --1.78655 -3.31862 -1.94984 --1.37492 -2.99527 -3.24162 -1.88276 -6.56686 0.511296 -7.62309 -3.36528 -4.91902 -10.4346 1.04068 -2.3808 -9.15066 -2.87736 -3.7173 --1.78535 -0.493808 3.81495 -9.75287 1.28 3.7011 --0.33993 -2.63569 -4.76182 -9.76626 -3.88351 -0.150727 --2.09913 0.00857796 -3.31768 -8.42581 0.200221 -5.35583 -2.31364 -5.19935 -4.30187 -2.81286 -5.07552 4.616 -4.18711 -3.5704 5.95573 -5.98666 -6.08346 -2.71782 -4.19465 -6.68827 -1.79237 -7.81784 1.03981 5.72051 -7.756 -0.934498 5.77958 -0.20341 -4.63869 3.53327 --2.14433 0.659608 3.17552 -4.84789 -5.41586 -4.28269 --0.34509 -3.36296 4.2708 -7.99927 -0.547114 5.66626 -10.228 -2.35199 -2.00585 -10.7361 -1.1247 -1.16709 --1.37122 -2.58237 3.58363 -0.70922 -6.08824 0.167421 -6.91339 -6.15332 -1.42621 -2.56919 1.04123 -6.70124 -2.55227 -1.05633 -6.69054 -1.15135 -5.64508 -2.88746 -2.97302 -6.77761 -0.938783 -2.84495 -0.983095 6.75805 -10.4604 -2.09651 -1.43554 -4.25958 -3.86948 -5.77296 -10.7425 -1.26272 0.978604 -5.27743 1.05358 6.72744 --1.35296 0.0771255 4.44264 -4.84315 -5.01037 4.7594 -0.49211 -1.60211 5.77755 -3.68808 -3.61432 -5.92422 -0.65194 -2.85746 -5.39008 -7.65829 -4.60963 3.75784 -9.15505 -1.74982 -4.33226 --2.41616 -0.500313 2.58079 --1.43113 -4.2169 -0.977491 --1.7392 -2.86371 2.66119 -9.26629 0.0190098 4.55368 -5.26549 -1.01512 6.74056 -3.1688 -4.44194 5.29355 --0.66083 -5.14466 -0.0372666 -0.40136 0.493796 -5.92861 -4.82624 -6.22695 2.97066 --1.49529 -4.05318 1.23826 -8.80185 -0.537678 -5.00423 -2.96068 -6.61296 -1.78331 -9.5578 -0.866956 -4.0844 -1.78202 0.950008 -6.50595 --2.68641 -1.04004 -1.42241 -7.48009 -3.99228 -4.53811 -3.23106 -6.72781 -1.40388 -3.39335 -1.27432 6.78308 -2.52412 -4.49272 -5.11072 -2.06931 -0.690041 6.62415 -2.96128 -6.7799 0.908094 --0.18608 -2.61944 4.91396 -7.93829 -5.51082 -1.60459 -7.96725 -5.67561 0.750613 -0.6786 -1.53843 -5.91188 -10.2434 -2.92987 0.837807 -8.08498 -5.3339 1.82846 -0.64045 -5.78068 -1.88408 --2.03504 -3.39035 0.431731 -4.74567 3.48405 5.96723 -8.86406 -2.68194 4.21023 --2.44308 -2.44321 0.704701 -5.27562 -4.17732 5.4192 -5.19003 -0.501715 6.80557 -2.24472 -1.42038 6.54796 -8.35274 -4.62765 2.8785 -3.1128 -1.45552 -6.71743 -8.85601 -4.77465 -1.49278 -3.96013 -6.71102 1.70469 --1.60141 0.423908 -4.10331 -2.60332 -6.0957 -3.01986 --1.24412 -0.581999 -4.52456 -3.05466 -2.53873 -6.38365 -6.66455 -5.43558 3.45627 -8.55921 1.65764 4.99144 -4.11884 -2.96755 6.27429 -6.17433 -1.79125 -6.34936 -6.15759 -3.15068 -5.81534 -7.413 -5.37275 2.83177 -7.1813 0.307982 6.1715 -0.20106 -5.2984 2.41456 -4.88076 -6.73025 1.38709 --0.98752 -4.65762 -1.31975 --0.58334 -3.31206 -4.05478 -5.7642 -1.70252 -6.49298 -8.78432 -2.53939 -4.37488 -10.1953 1.31565 -2.86926 --1.12233 -3.99838 2.46101 --1.34896 -2.33457 3.77554 -6.85044 -2.2584 -5.93472 -9.55275 -2.08376 -3.65081 -9.02709 -4.30672 2.1991 -2.8667 -5.05869 -4.64375 --2.31842 -0.318277 -2.84806 --0.33204 -4.05196 -3.646 -2.2953 -6.21484 2.5666 -4.28561 -6.83513 1.05047 -4.55522 -6.38776 -2.66983 -8.8799 -3.73763 3.29495 --2.78582 -0.596597 1.20781 -6.19229 -5.17952 4.11709 -3.0315 -6.4006 2.47826 --0.63857 -5.15975 -0.348679 -8.49704 -3.73866 -3.80778 -5.93521 -0.849081 -6.60255 -1.1589 -4.55934 4.42155 -0.56297 -5.69893 1.97026 -7.13139 -3.33866 5.26189 -6.61227 -0.749212 6.38631 --2.12125 0.988832 -3.12457 -4.34547 -1.14936 6.82148 -10.8088 1.1245 -0.471722 -7.32416 0.952333 6.02631 -0.04089 -5.53971 -1.36341 -9.42299 -0.177785 -4.36083 -1.09621 -3.62437 -5.18419 -2.11077 -3.72449 5.56102 -8.94344 -1.67415 4.61087 -10.6386 1.00418 1.71879 -1.68841 -1.743 -6.30782 -1.5333 1.3689 6.34589 -6.30331 -6.02395 -2.59367 -7.22337 -4.21859 -4.521 -5.89623 -6.48642 -1.58062 -9.68146 0.121657 4.00748 --2.67995 -1.47031 1.03893 -9.10487 1.08983 4.59754 --1.14115 0.386501 -4.6679 -7.97558 -3.24059 4.7248 -5.66365 1.16525 6.63404 -5.20901 -6.14365 3.00276 -6.08703 -0.133261 6.61444 -10.1567 -1.28841 2.94916 -10.701 1.52213 0.889948 -5.94055 -4.36639 5.07233 -3.22383 -3.26648 6.08012 --0.84541 -3.07674 3.92962 -8.3113 1.47769 -5.26046 -4.35046 -5.88658 3.67737 -6.7304 -4.33013 -4.7346 -1.61099 -6.01961 -2.49169 -1.62692 0.129811 6.50386 -2.46507 0.898688 6.70057 -7.93084 -0.695886 -5.69141 -5.37646 -5.6428 -3.83722 -9.61316 -4.09237 -0.511354 -4.43002 -4.676 -5.13439 -5.253 -6.5772 1.79625 -10.5478 -0.831415 2.13076 -5.46566 -2.11596 -6.43949 -10.0977 -3.00464 -1.47821 -0.71175 -6.06226 -0.704126 -9.78397 -1.55112 -3.54932 -9.61209 -3.83488 1.50446 -4.636 2.15853 6.55925 -9.37258 -0.712935 4.36635 -5.16713 -3.92069 -5.6296 -1.83441 -6.43997 -1.35359 -3.31562 1.88958 6.63379 -3.75509 -5.91336 -3.63772 -3.2003 3.30551 6.06576 -9.47781 1.21811 -4.10405 -6.58144 -6.4006 -0.805091 -4.53605 -6.0174 -3.43496 --0.11103 -1.7199 -5.3422 -4.61658 -3.29878 -6.08277 -0.62195 -4.72335 3.83505 --0.27567 -4.83159 2.57726 -10.3684 -2.17871 1.71634 -4.12241 -4.32554 5.45021 -8.54949 -5.20764 -0.834939 -8.73752 -0.181587 -5.08804 -10.6767 1.64387 -0.869878 -10.4281 -0.563359 -2.55863 -2.10815 2.90988 6.02506 -10.8434 -0.0275642 -1.06389 --1.70913 -0.195037 3.96005 --0.50085 -4.56574 -2.7014 -8.49857 -4.94266 -1.96646 -4.61776 -4.24211 -5.48161 --2.60495 1.54793 -1.40803 -1.79215 1.51709 6.4012 --0.11702 0.334656 5.58951 -4.24958 -6.86412 -0.830757 -0.06907 -5.19793 -2.4009 -7.14879 -1.35577 6.04815 -9.57785 -3.7525 -1.81709 -5.60797 0.781422 -6.69607 -7.87765 1.03272 -5.67817 -4.73394 1.17894 6.7796 -7.40245 -6.06058 -0.236273 --1.56562 -4.1432 0.0458662 -0.32822 -2.08084 5.52926 -2.12783 1.83057 6.43082 --0.03987 -3.2042 -4.6818 -9.15925 -4.35513 -1.73789 -0.92634 -4.39316 -4.44211 -7.93452 -2.79963 -5.02046 -1.80467 0.950733 6.51012 --1.79208 1.23159 -3.63934 -3.43815 -6.55612 2.17468 -3.96516 -2.27819 6.54404 -8.2837 0.74404 5.43077 --1.97888 -3.49498 -0.185 --2.64853 -0.460797 -1.85102 --1.99723 -2.91366 1.89568 -4.37142 -5.49483 -4.24233 -0.908 0.187736 6.21284 --0.68687 -1.21988 4.9873 -9.64696 0.722911 3.98552 -10.1632 -0.365464 3.18903 -7.99726 1.69119 5.44157 -8.77949 -4.8199 1.57211 --0.62887 -2.2445 -4.69026 -1.38699 -2.55116 5.91321 --2.40196 0.3008 -2.65233 -5.71043 -4.31445 -5.18483 -6.40898 -3.01006 5.79265 -0.94948 -4.88055 -3.91282 --0.82443 -3.8286 -3.23697 -7.61118 -5.39949 -2.5202 --1.12998 -4.27556 1.93148 --1.65369 -3.85989 -1.13239 -9.94714 -2.31164 2.76146 -3.19299 -3.35772 -6.02415 -1.82532 -5.17214 -4.11646 -10.329 -2.84851 -0.173716 -8.35167 -4.62913 -2.87509 -2.10792 -4.98014 4.46583 -9.72664 -3.14121 -2.40301 -2.79609 -3.26937 5.99876 -2.9138 -6.8186 0.262507 -3.97561 -5.00612 -4.82937 --2.84812 0.00856261 0.955029 -1.52148 -5.75767 -2.99018 -1.68439 -3.78984 5.34822 -1.50164 -3.26932 5.60189 -0.5559 -3.23864 -5.11586 -3.6151 1.0059 6.83487 -6.84552 -6.21809 1.22859 -5.06055 -5.0822 -4.63249 -3.8549 -4.38171 -5.40388 --1.76402 -3.81618 0.513155 -10.8441 1.01805 0.00217025 -3.67833 -6.00264 3.47194 -2.04381 -6.26728 2.21855 -3.05389 -5.73015 3.81253 -3.22242 -4.25442 -5.44918 -9.48578 -3.33424 2.69357 -4.95767 -1.57346 6.67888 -8.22883 -0.927177 5.44877 --1.00022 -4.38998 -2.00836 -5.80732 -6.66349 -0.558025 -1.61059 -5.39415 3.67953 -1.12378 -5.57602 2.97974 -2.71976 2.27522 6.42737 -6.69483 -6.36996 0.66553 -2.28165 2.46775 6.26177 --2.23321 -1.00495 -2.87507 -8.52841 -2.69026 4.56102 -1.25361 -4.35562 -4.67642 --2.05467 0.433296 3.37183 -6.38031 -4.61404 4.65114 -3.38138 -1.70218 6.67586 --1.07517 0.0971232 4.75763 --2.81891 -1.04365 -0.454132 -0.26792 -5.7961 0.740974 -7.22402 -5.15697 -3.41503 -9.88205 -3.5863 -0.980057 --2.83946 0.160628 -0.98848 -8.94267 -4.8903 -0.395002 --2.39316 -1.53341 -2.20471 --0.42818 -4.30941 3.18839 -6.73542 -0.555441 -6.35049 -0.63766 -3.26357 5.13375 -0.83612 -3.97585 4.75536 -9.4372 -3.06188 -3.08759 -10.4276 1.56149 2.06958 -1.3791 -5.18794 3.81152 -8.71723 -4.55842 -2.35204 -6.87076 1.24283 6.19245 -10.8269 -1.15646 0.0672408 -3.46104 -6.27832 2.90022 --2.59317 0.591683 -2.05431 -6.95842 -6.0226 -1.82353 -9.89925 -3.68017 0.250808 -5.95202 -2.89504 -6.01091 -1.40475 -6.19778 -1.69664 -2.04394 -5.61748 -3.58889 --1.93092 -1.84673 -3.1046 -9.1999 -4.58905 0.631297 --2.0274 -2.23661 2.59323 -0.94539 -6.12298 1.10522 --2.70879 -1.36325 -0.965749 -8.02058 -5.07932 2.56793 -8.27703 -5.48904 -0.0231057 --1.6043 -0.947935 -3.99265 -5.92154 0.304227 6.65428 -6.92824 -1.14292 -6.19368 -7.04785 -2.02577 -5.90757 -5.67185 -4.71589 -4.85087 --0.62933 -2.17529 4.71211 -9.29408 -1.80498 4.14306 -1.10394 -0.0121481 -6.30707 -4.69958 -3.94784 5.68395 -10.4966 -1.40911 -1.96835 -9.6768 -1.17677 3.84254 --1.95743 -3.41942 0.921431 -6.0726 -1.81886 6.36877 -6.01498 -0.742044 6.58982 -0.0261 0.0570186 -5.70359 -4.64834 -5.49422 4.20737 --0.29481 -5.17202 -1.74604 -1.79868 -2.30854 6.16542 --2.30009 -2.57845 1.2786 -10.6273 0.336723 -1.99619 -10.6339 0.722393 -1.88454 --0.23707 1.49731 -5.31155 -6.0197 -6.12053 2.58464 -5.59814 -0.199379 -6.72921 -2.84813 -5.42828 -4.18682 -8.14891 -1.73407 -5.31486 -9.86344 0.758417 -3.64922 -10.7349 1.13154 1.12364 -0.5018 -3.7108 4.73348 -5.60474 -3.3552 5.87074 -4.97185 0.222609 -6.84461 -3.1703 0.960518 6.8071 -6.64896 -6.18106 1.74868 -0.88925 -1.80743 5.94014 -6.15607 -6.5391 0.846092 -2.86466 -0.0987921 6.81547 -10.5565 -2.16202 0.67605 -4.53109 -6.01514 3.41815 -4.9963 -3.00973 -6.17914 -5.37876 -4.60977 5.02805 -0.14312 -3.48054 4.63051 --2.07571 -3.12852 -1.16802 -7.52543 -3.64691 4.78646 -6.24525 0.64088 6.53147 -5.50184 -6.2898 -2.54056 -2.66375 -6.70363 -1.06419 -3.38059 -5.34291 4.39892 -0.86309 -0.598161 -6.17034 -8.62648 -0.632199 5.15658 -9.96833 -1.7084 -3.12557 -4.26452 -1.95313 -6.64037 -1.55812 -6.08999 2.24825 -2.97737 1.96534 6.56588 -0.98621 -5.91275 -2.03636 -7.98518 0.101998 -5.69242 -9.03934 -1.15924 4.65692 --2.85229 0.906134 -0.31534 --0.39316 -5.25826 -1.12736 -0.58692 -5.02917 3.37567 -2.72073 -1.79605 -6.56986 -4.46814 0.213465 -6.89545 -3.63492 -6.89665 0.191483 -5.30333 0.879542 -6.74301 -2.59478 2.7531 6.21869 --2.10238 -1.70982 -2.81511 -5.88751 2.5526 6.17431 -2.25222 -6.15251 -2.68363 --0.78988 -4.06553 2.9767 --0.50299 -3.70192 3.80031 -2.16574 -4.1674 -5.25586 -7.66366 -5.88837 0.527471 --1.48565 -0.41059 4.24896 -3.22039 -1.77952 -6.64717 -3.66327 -5.13144 -4.67715 -2.48871 -4.79532 -4.80839 -3.73633 -4.57105 5.2282 -6.24304 -3.77603 5.40361 -4.48278 -1.06386 -6.81862 -2.03031 0.114166 -6.64001 -0.47147 -5.80738 -1.39371 -1.65427 0.283711 -6.51682 -1.9388 -6.581 -0.574521 -10.5471 -2.08978 -0.857197 -4.20582 -5.02926 4.7931 -1.44797 -3.98415 -5.09579 -5.20252 -6.29233 -2.67415 -8.40791 -1.44946 5.1857 -10.5666 -0.153785 -2.20526 --1.54875 -3.76019 -1.79454 -7.15391 -5.73692 2.36533 -6.59307 -3.6858 -5.30834 --0.91175 -1.79073 4.57913 --2.8271 1.09569 0.12972 --0.8736 -0.0840486 4.96288 -2.73996 -4.57054 5.08642 -2.90622 -0.119712 -6.82823 -9.20765 -2.69968 3.75542 -0.60231 -5.54685 -2.4244 -9.17086 -3.38341 3.2058 -8.15914 -5.53889 -0.666658 --2.01041 -0.710085 3.3908 --0.26486 -0.184441 5.49196 -6.81038 -5.85169 -2.48367 -10.3999 -0.0992923 2.67155 -10.6734 -1.79688 -0.472597 -2.5932 -6.63858 1.32735 -5.50567 -6.12444 -2.91816 -6.47152 1.59061 -6.28619 -1.32354 -6.38086 0.172909 --1.38797 -2.10039 -3.84856 -3.02073 -6.15241 3.0428 -10.3744 0.796402 2.61681 -4.54005 -2.41277 6.48013 --2.23864 -0.458499 2.96131 -2.18468 -1.09197 -6.58972 -9.47353 -2.34371 3.60483 -8.21727 0.620273 -5.49459 --2.68151 -1.64952 -0.640802 -7.59986 -0.350837 5.93403 -5.13255 -2.893 6.20874 -5.05604 -2.61776 6.33613 -9.44282 -1.53067 4.04883 -4.22879 1.00448 -6.8405 -8.87967 -4.1459 2.75061 -10.848 -0.112717 0.944635 -9.86891 -0.79744 -3.62923 --1.14102 -4.54095 1.04673 -6.99702 1.54089 -6.07834 -2.23706 -6.50648 -1.57941 --0.60882 0.760885 5.1517 -6.68822 -6.40051 0.154588 -8.64074 -5.17903 0.0267526 -0.33798 -5.87234 -0.361093 --2.59111 -0.373984 2.08513 -4.27252 -6.88745 0.524049 -8.3728 -3.22964 4.35883 --2.45684 1.29939 -2.16019 -8.7775 -3.78444 -3.38315 -7.42153 -0.851455 -5.97995 --1.08043 -3.29809 -3.42014 -7.18538 -4.96196 -3.71457 -6.72264 -4.42477 4.64519 -8.56699 -3.74543 3.70667 --1.64493 0.254472 4.04464 -0.42018 -1.04264 -5.85591 -5.50057 -5.82116 -3.48529 -5.95056 -5.8271 -3.24571 --0.82535 0.026742 -5.0034 -1.55678 -0.565138 -6.45775 -6.50846 -6.36404 -1.21049 -0.85136 0.616068 -6.15558 -2.46065 -4.27292 5.25918 --0.90422 1.34765 -4.74898 --1.80895 -1.04015 3.65838 --0.20301 -4.58587 3.09499 -5.67931 -6.68752 0.533225 -6.1437 -5.82228 3.132 -1.59151 -2.91856 -5.82955 -1.21699 -1.35739 -6.20544 --1.02872 -3.58697 3.17964 -10.8144 -0.558214 -1.06137 -10.0756 0.569581 -3.30831 -9.63945 0.169561 -4.04923 -7.98617 -4.06586 -4.01954 -8.78034 -3.30872 -3.84546 -10.3063 -2.87068 0.396183 --2.26201 -1.39926 -2.60907 -9.60518 -3.51739 -2.15504 -4.84371 -6.56689 -2.03894 -6.0408 -3.62223 -5.57748 -7.15618 -2.85164 5.50926 -0.2057 -4.63147 -3.54013 --1.85466 0.0780673 -3.73352 --1.60304 0.912423 -4.01806 -2.91926 -6.56096 1.91604 -4.24213 1.02732 6.83849 -7.25956 -2.30529 -5.6976 -2.20988 -1.96658 -6.40043 -2.48169 -2.34694 -6.34132 -8.40866 -0.437257 5.3588 -7.91057 -5.63989 -1.10003 -8.62028 -1.81353 -4.87885 -3.47028 -6.14056 -3.17979 --0.77043 -5.01057 0.533472 -6.52893 -6.21423 -1.78197 -7.38888 -5.11198 3.30376 -7.34582 -4.49798 4.14161 --2.15517 0.464577 -3.16085 -9.10076 -4.63973 0.980159 -6.96671 -5.4232 3.20348 -7.81437 -5.80941 0.219095 -8.38043 -4.82074 2.46359 -7.09411 -4.37708 4.45153 -6.52453 -0.118562 -6.45208 -0.30842 -5.75697 1.15515 -1.49698 -6.29767 1.42639 --2.82581 -1.05909 0.124441 -10.2012 0.890022 2.97867 -1.96616 -4.81245 -4.59512 --0.38128 0.351676 -5.3871 --0.61708 0.181419 -5.19184 -2.00182 -1.82612 6.37604 -7.58092 1.43249 -5.77833 -3.21365 -3.66658 5.84415 --0.30703 -5.39379 -0.676725 -5.2197 -6.58901 -1.76355 -5.63835 -6.02667 3.03766 -3.66071 -6.60278 -2.04869 -9.95072 1.29001 -3.33708 -0.16139 -0.257487 5.7817 -1.33767 -4.19956 4.84465 -9.86558 -3.38326 1.52525 -6.40766 -4.94795 -4.2657 --1.27441 -1.20743 4.36182 -2.67702 -5.3738 4.20104 --2.85649 -0.718912 0.360618 -0.9011 -2.44401 5.71244 -8.34805 -3.94869 3.76003 -8.79765 -3.99274 3.10057 -10.6163 -0.567707 1.98341 -10.6864 -0.115579 1.79303 -5.74814 -3.92678 -5.46639 --0.76137 1.63284 -4.80379 -10.3417 -1.07242 -2.60251 -8.63314 -2.30844 4.66067 --1.491 0.563872 4.2208 --0.19904 -5.33227 1.44388 -2.5255 -3.93065 5.53262 --0.78969 -4.64336 1.91934 --2.86092 0.466355 0.671073 --1.52971 -3.78431 1.79145 -4.32246 -4.94431 -4.87541 -4.98527 0.115703 6.84755 -3.81259 -4.83794 4.98143 -8.91542 -1.66451 -4.63169 -8.37142 -1.29891 -5.25106 --2.62473 0.11949 1.98974 -8.00407 -2.40685 5.16398 -9.67958 -2.54729 3.10409 -2.52988 -6.61758 -1.37581 -10.0002 -2.73111 -2.20428 -10.3099 -2.53293 1.38782 -0.02379 -1.56359 5.47886 -7.53231 1.77829 5.71542 --2.7604 0.878877 -1.15574 -10.063 -2.82152 -1.88156 -8.25416 -0.28106 -5.48339 -7.98627 -4.49138 -3.53707 -10.7167 -1.67877 -0.198238 -5.79757 -6.59097 1.16281 -3.75661 -6.5676 2.18361 -0.04481 -2.05606 -5.34066 --1.78409 -1.51258 -3.52723 -9.66684 -0.822699 3.94166 -3.52825 -2.91645 6.27001 -1.82007 2.03291 6.26801 -7.93144 -4.68772 3.3397 -3.68888 -0.877635 6.85233 -6.0602 -1.31762 -6.48359 -1.46959 -2.14995 -6.09524 -9.20372 -2.54078 -3.86532 --0.20402 -0.557664 5.50465 --1.07874 -3.00055 3.67243 -7.24036 -2.82958 -5.47292 --1.03926 -0.271847 -4.7713 -1.83312 -6.36753 1.63881 -6.21641 -2.44392 -6.10889 -1.60338 -4.68878 -4.5451 -7.72395 -1.87512 -5.56705 -4.79789 -6.81446 0.892359 -7.27487 -6.03295 -1.0888 -5.35627 -5.24816 -4.35865 -3.74542 -0.672617 -6.87953 -0.59179 -4.75919 -3.75268 -2.68751 -2.85204 -6.18409 -4.95164 -5.88521 -3.56599 --1.61919 -1.63758 3.7355 -6.66374 -1.33727 -6.26599 -8.85806 1.38005 4.77542 --2.58346 -1.15624 -1.77094 -6.74867 -5.11339 3.84809 -5.11156 -4.17618 -5.44532 -1.53293 -2.98281 5.76708 -6.86501 -6.30787 -0.345386 -8.10084 -4.26906 3.67787 -9.21323 -2.1682 -4.06057 -5.80674 -6.5127 1.53365 -3.67484 -5.68187 -3.9814 -6.22635 -5.40493 3.77642 -1.4066 -6.38827 0.582648 -4.34747 -6.32055 2.82353 -2.16385 -0.159794 6.67255 -9.07841 0.56995 -4.70783 --0.14504 -4.4424 -3.3859 -8.58023 1.06886 -5.11266 -8.01956 -4.6919 -3.21736 -7.19132 -5.3515 -3.11032 -7.34703 -1.65268 -5.85782 -10.3717 -2.69484 -0.543351 -6.40797 -2.15667 -6.14352 -4.99348 -6.81694 0.617727 -0.02758 -5.55335 1.20961 --2.57449 -1.9573 0.886187 -0.51814 0.54132 5.98169 --2.65862 -0.0265192 -1.85806 -2.10404 -2.8658 -6.03177 --0.4697 -2.97191 -4.42062 --2.29714 -2.1154 -1.93687 -5.66902 2.18038 6.36776 --2.40717 -1.65303 1.99485 --2.87905 0.243361 -0.584187 -8.03353 -2.79223 4.94106 -4.77291 -5.70845 3.89195 -2.6192 -6.75061 -0.515171 -7.2355 -3.25565 -5.23349 -7.64854 -2.92614 -5.15721 -8.02516 -5.53974 1.23376 -2.20651 0.696611 -6.64878 -7.9847 -1.42392 5.51093 -3.7035 2.20047 6.56167 -4.99415 -0.798892 -6.7997 -9.21326 -1.21593 -4.43431 -2.8269 -2.25214 6.44517 --1.74153 -1.06068 -3.75065 --2.8066 -0.66441 -0.939142 -5.07753 -5.79785 3.6765 --0.02473 -2.44246 -5.11897 -10.2252 0.443229 -3.03928 -4.7744 1.54201 6.70724 --1.07601 -1.09354 -4.6169 --1.38886 -1.01354 -4.25806 -0.86771 -2.32188 -5.74562 -6.68861 -3.5593 5.33563 -10.6071 -0.492647 -1.99539 -10.4453 -1.62783 1.92432 -0.1976 -5.7653 0.224617 -10.8536 0.234715 0.766595 -4.11925 2.10577 6.58332 --2.75746 -1.22078 0.612905 -2.30568 -6.67775 -0.389743 -6.24788 -6.53273 -0.359583 --0.63407 -4.85569 -1.72196 --1.40618 -4.31034 -0.365146 --1.52922 -3.16091 -2.73318 -7.3906 -1.21066 -5.91981 -1.8564 -5.68354 3.33431 --2.16596 -0.112853 3.13289 -0.45721 -0.192153 5.9531 -10.3399 -1.9962 -1.94964 -10.2481 -0.623559 2.9232 --1.62778 -1.93967 3.54448 -7.49957 0.673894 5.94601 -5.82429 1.66338 6.46299 -2.17685 -6.62411 0.673527 -3.56411 -0.25097 -6.8871 -1.58869 -0.871454 6.42807 -5.38443 -5.1685 4.4264 -10.003 -2.37179 -2.54401 -1.11732 -6.27438 -0.260331 -4.90933 -6.45775 2.30783 --2.74609 1.47367 -0.176768 -9.78491 -3.27417 1.99722 --0.10173 -0.434835 -5.57342 -2.65229 -4.10019 -5.43282 -10.1722 -1.48486 -2.78382 -2.29449 -3.76507 -5.57158 -10.3714 -1.41836 -2.31663 -1.33238 1.18448 -6.28024 --1.48891 -3.5461 -2.32043 --2.62288 -1.94292 -0.110874 --1.55521 -2.72304 3.12241 -1.38265 -5.27936 -3.66118 --0.17284 -4.8675 -2.65792 -0.40846 -4.22532 4.1735 -7.24323 -4.56046 -4.13582 -4.69293 -2.08776 -6.55598 -9.31959 -4.0708 1.85178 --0.01439 -3.90196 -4.11018 -10.1535 -0.565003 -3.13413 -1.20344 -1.70126 6.10398 --2.3079 0.823873 2.72524 -2.26756 -5.83927 3.29984 --1.98866 -2.53287 2.37076 -9.97592 -2.04165 -2.88247 -2.62459 -6.74171 0.533064 -7.78015 -3.83001 4.41503 -8.68991 -4.46718 2.5388 -7.96538 2.24952 5.23837 -8.81797 -4.89536 1.07656 -2.64636 -5.8586 -3.43004 -2.53532 -5.68095 -3.67636 --2.64839 -0.849876 1.62008 --0.38025 4.30637 -3.32241 -0.57609 5.21664 -3.11428 -9.69503 2.80996 -2.86858 --1.64636 2.36144 -3.30687 -1.58657 2.53733 -6.01099 -6.1923 2.60092 -6.06311 -0.31512 4.55504 -3.80624 -4.45623 3.0601 -6.22403 -2.34827 6.6263 -1.21068 --0.94118 3.17673 -3.76733 -9.08932 1.78989 -4.40508 -9.53765 2.18335 3.60839 -2.25733 5.54411 -3.84703 --0.19588 5.15072 -2.13341 -8.5033 2.08569 -4.88256 --0.1163 3.66692 -4.28527 -1.91832 4.95873 -4.44121 -1.17223 6.33274 -0.549827 -10.0934 2.87905 1.71928 --1.33497 3.29216 -3.05643 -1.15843 4.55041 -4.46347 -3.1962 4.07596 -5.58579 -8.90562 2.36829 4.34409 -3.33934 3.16864 -6.15728 -7.73008 2.81426 -5.17286 -5.41217 2.87436 -6.17662 -2.51883 6.76921 -0.278184 -8.61051 3.02652 -4.27098 -2.9805 5.927 -3.50295 -2.74912 4.37053 -5.27912 --0.52946 5.14434 -1.26587 -3.42494 2.52567 -6.43891 -10.4179 1.77563 -1.96638 -10.4466 1.96417 1.66471 -10.5488 2.26926 -0.399513 -10.5479 2.21096 0.596737 -1.98565 6.33455 -2.03068 -1.87572 6.60017 -0.312158 -5.98404 2.21298 -6.27741 -4.22672 2.22748 -6.5638 --0.69166 4.57082 -2.40221 -3.06589 5.60952 -4.01872 --1.81028 1.84249 -3.36246 -9.33883 2.46231 -3.74028 -2.84926 3.72666 -5.76877 -7.78422 1.83529 -5.55309 -0.76812 1.99533 -5.83754 -1.68302 3.99079 -5.22721 -1.09044 5.19746 -3.63441 -0.17028 3.05208 -4.966 --0.70176 2.50469 -4.49296 -5.24316 2.40181 -6.39431 -2.21847 5.9234 -3.20251 -10.4752 2.15798 -1.28228 -2.16295 3.05422 -5.97168 -2.41781 2.4719 -6.29772 -2.55339 5.06991 -4.56156 -0.32722 5.85011 -0.853487 -6.87405 1.95268 -6.02637 -3.00245 6.46344 -2.33551 -10.0326 2.10691 -2.755 -1.48752 6.35728 -1.24284 -0.63211 5.68683 -2.23321 -9.99812 2.80807 -2.11271 -10.4352 2.43317 0.884282 -1.0469 3.36968 -5.34159 -0.24796 2.5724 -5.27722 --1.97775 2.43438 -2.60153 --1.24412 2.46036 -3.87258 -1.3813 5.77913 -2.87998 --0.57248 3.40873 -4.0168 -2.09576 3.51144 -5.7063 -4.76975 2.43554 -6.45172 --2.02396 2.70784 -2.18739 -0.94438 3.7124 -5.05695 --0.18311 5.5519 -0.497821 -9.83171 1.99796 -3.23431 -4.52461 3.40853 -6.02914 -8.55636 2.59964 -4.58328 -10.1366 2.20013 2.39939 -1.98928 6.56009 -1.06716 -0.58923 2.48844 -5.53556 -1.47134 6.03024 -2.38219 -0.35046 4.07648 -4.33996 -10.2116 2.65455 -1.65446 -2.10715 4.70915 -4.78798 -2.949 6.6928 -1.4673 -10.2074 2.92606 1.027 -2.99385 4.67726 -5.06602 -0.8713 6.20136 -0.310844 --0.92626 4.1895 -2.62128 --1.65603 1.76692 -3.64839 -1.86325 5.71215 -3.36268 -4.612 1.81584 -6.66173 -8.74038 1.99828 -4.69806 --0.90743 3.70724 -3.2892 --0.34627 2.13667 -5.01793 -3.46569 2.10443 -6.58717 -0.93264 6.06797 -1.47533 -0.06589 5.57305 -1.42991 -2.41761 6.3512 -2.3361 -1.32631 1.69689 -6.18666 -10.27 2.98794 0.197154 --2.2719 1.99876 -2.21352 -4.09244 2.66868 -6.40359 -9.81977 1.96356 3.26727 -10.6817 1.80975 0.0955933 --0.46013 3.86735 -3.72257 -2.57577 6.57023 -1.71727 --0.29398 3.0013 -4.61308 --0.17685 4.79422 -2.87852 -2.54824 6.72029 -0.855841 -1.24769 6.0631 -2.01744 -8.06019 2.63544 -5.01252 --0.98333 4.36558 -2.18326 -8.90019 2.15024 -4.46167 --0.86768 2.05345 -4.54497 -7.02353 2.5448 -5.72729 -1.45603 3.41867 -5.51006 -0.16303 5.7895 -0.383522 -1.63535 3.00537 -5.79851 -9.3021 2.77689 -3.56858 -10.4194 2.55845 -0.607956 -0.64999 4.86839 -3.70547 -5.65298 2.49763 -6.26212 -2.38984 5.37183 -4.12674 -0.07077 5.21124 -2.44386 -10.2472 2.40733 -1.86104 -1.85897 5.46613 -3.75114 --0.10021 4.25001 -3.71828 -2.69675 2.82477 -6.2135 -0.53106 5.92649 -1.12376 -2.43723 3.47843 -5.81953 -2.96644 6.81828 -0.604239 -0.15536 3.55727 -4.61365 -2.93681 6.14458 -3.07598 -6.43594 2.89855 -5.83554 -1.59988 5.14595 -4.0409 --1.3106 3.83614 -2.36869 -6.09709 1.68043 -6.39655 -1.17453 2.52027 -5.83375 -10.0957 1.75274 2.8209 --1.00812 2.64898 -4.06275 --0.03164 2.53675 -5.08127 -10.2435 1.72337 -2.49591 -2.38641 3.86589 -5.55906 -9.0219 2.78681 -3.9451 -2.92399 2.45445 -6.40829 -0.57278 3.32661 -5.07832 --0.72662 2.91625 -4.21232 -5.05032 3.10268 -6.12119 -7.84944 2.2553 -5.33076 -1.04825 4.92454 -3.95008 -9.55986 1.93589 -3.70459 -2.07275 2.04535 -6.34203 -1.56144 6.44953 -0.802544 -1.0491 4.18008 -4.74374 -6.73491 2.42027 -5.9112 -3.95093 1.77312 -6.69642 -9.56349 2.35289 -3.45054 -1.4969 4.26156 -4.91666 --1.79321 2.9389 -2.50478 -0.9832 5.73703 -2.54045 -1.29958 3.08363 -5.61881 -7.37027 2.06334 -5.71953 -3.78593 3.15755 -6.17755 --1.46126 3.44612 -2.5837 --1.71628 2.79319 -2.81763 -0.11752 4.08082 -4.11721 -0.82402 2.92177 -5.45581 -2.696 4.73007 -4.94098 -1.83563 5.9752 -2.8267 -2.56749 6.17351 -2.84328 -0.39998 4.87392 -3.44538 -10.4908 2.13232 1.15208 -10.3271 2.60382 -1.15256 -2.78328 3.2948 -5.99661 -8.73631 2.03313 4.6728 -0.0649 4.67334 -3.35758 -9.37627 1.8489 4.0023 -2.557 2.02656 -6.46946 -0.49401 5.83327 -1.44528 --0.11015 5.53337 -0.972159 -0.75012 6.09855 -0.694762 -9.79857 2.59602 2.81213 --0.53873 4.44571 -2.87057 -2.27352 4.2108 -5.26843 -1.94003 6.20467 -2.36342 --1.28954 2.87626 -3.4645 --1.13062 3.74083 -2.83886 -0.73678 4.55272 -4.13485 -10.2928 1.69802 2.33797 --1.27717 1.98278 -4.05829 -1.63279 4.62978 -4.62573 --1.49066 2.8268 -3.18165 -10.2643 2.65611 1.30178 -5.87542 3.0609 -5.9306 -0.97869 5.49789 -2.99713 -0.6041 5.45174 -2.67374 --2.41832 1.77645 -1.95853 --1.49607 3.74411 -2.08439 --0.7732 4.64402 -2.07203 --1.81213 3.17464 -2.13437 --1.14215 4.45356 -1.53767 --2.20487 3.03696 -0.785077 --2.57948 2.17867 -0.221039 --1.88794 3.27447 -1.75689 --1.68668 3.79989 -1.32209 --2.44334 2.32361 -1.15497 --0.77787 5.02987 -0.67294 --2.28868 2.92032 -0.332859 --2.23883 2.69711 -1.44637 --1.86471 3.64059 -0.914959 --1.27913 4.40776 -1.13064 --2.24914 2.51352 -1.68876 --1.66732 4.00012 -0.604186 --2.50077 2.32123 -0.66897 --2.08913 3.30031 -0.561276 --2.07381 3.11803 -1.29431 --0.97556 4.74878 -1.07447 --2.36281 2.09488 -1.79271 --2.42836 2.59432 -0.0582419 --2.35228 2.66527 -0.825039 --2.59367 1.86966 -0.926915 --1.84724 3.72017 -0.413522 --2.74818 1.53162 0.345324 --2.77872 1.17449 0.727044 --2.60809 1.84282 1.0217 --2.65648 1.89437 0.215484 --2.51465 2.21994 0.783887 --0.88728 1.01156 4.85443 --2.59646 1.56456 1.44764 --1.83832 1.29922 3.54888 -1.19266 1.96568 6.05279 --1.56371 1.02888 4.05779 --2.54058 1.37184 1.85387 -0.35109 1.85506 5.63383 --0.55478 1.21447 5.12619 -0.55936 2.44308 5.5438 -0.86141 2.35702 5.74856 -0.81562 1.51189 5.98816 -0.07159 1.43939 5.56149 --2.14588 1.19088 3.00005 --0.83701 1.5639 4.75269 --1.27238 1.03096 4.41692 -0.54891 1.48244 5.84912 --2.47147 0.988137 2.27495 -0.38068 1.03546 5.84015 --2.67316 1.09159 1.46734 -1.3278 2.42551 5.94102 --0.23897 1.40034 5.33677 --1.08875 1.34493 4.54602 -1.08626 1.15331 6.1876 -0.15146 2.22899 5.34138 --2.29827 2.29632 1.84127 --2.4666 2.48478 0.320408 --2.38517 2.63003 0.71071 --2.25858 2.64844 1.42175 -9.11336 3.70475 -2.96779 -10.202 3.11216 -0.286618 -9.3673 4.31637 -1.03425 -8.92453 3.34011 -3.64414 -9.87952 3.57665 -1.03586 -10.0701 3.27445 0.844518 -9.40354 3.8578 -2.11825 -6.33867 3.24743 -5.68457 -7.03588 3.22117 -5.38574 -8.19549 3.23741 -4.54289 -10.1588 3.10795 -0.827658 -8.99187 4.3976 -2.09238 -9.75765 3.21127 -2.23819 -9.59017 3.82534 -1.62465 -9.17345 4.64227 -0.433504 -7.79588 3.43186 -4.74125 -9.61329 4.05602 -0.67925 -9.09118 4.63728 -1.02053 -9.77254 3.44711 -1.80425 -9.40842 3.57425 -2.54723 -9.61942 3.9427 -1.1268 -9.36871 3.19547 -3.08332 -9.13474 4.36905 -1.73724 -9.03485 4.17801 -2.4007 -7.39442 3.3195 -5.09946 -9.92697 3.35026 1.36752 -10.0687 3.07988 -1.38446 -10.0063 3.45466 -0.448391 -3.57461 6.20672 -3.10863 -3.47989 5.26471 -4.54297 -5.52218 6.13895 -2.89504 -4.05341 4.69963 -5.1385 -4.89934 5.48618 -4.19267 -4.1078 3.81409 -5.81977 -5.17269 4.01894 -5.56088 -4.76877 4.84402 -4.94773 -4.00432 5.78815 -3.87612 -4.55469 6.19916 -3.09998 -4.78452 4.2193 -5.48188 -4.43378 5.30431 -4.50044 -4.97825 6.04098 -3.29975 -3.70825 4.62891 -5.19846 -3.55506 3.96098 -5.70881 -5.09409 3.66169 -5.81161 -5.31716 5.18265 -4.47287 -4.89283 4.55961 -5.18996 -3.29174 5.77457 -3.82435 -4.90143 5.7606 -3.80732 -4.23341 4.46112 -5.34546 -5.21468 4.67446 -5.01597 -3.76063 3.54014 -5.97601 -4.42785 5.65524 -4.02777 -5.27271 5.65809 -3.84943 -4.65453 3.8228 -5.76645 -3.90771 4.22869 -5.52408 -3.76615 4.99032 -4.84825 -4.27951 5.99365 -3.48805 -5.71036 4.51838 -5.03372 -7.28349 4.2904 -4.42371 -6.18601 4.23428 -5.08809 -8.3519 4.52039 -3.05635 -8.1512 3.98034 -3.96062 -5.66804 5.78049 -3.5141 -8.67121 3.99112 -3.3136 -5.8651 5.16908 -4.29363 -6.45689 4.76019 -4.47763 -7.23365 3.63758 -4.99089 -7.06025 4.94427 -3.86149 -8.85852 4.70496 -1.68696 -7.87008 4.46488 -3.71838 -8.73023 4.34731 -2.72636 -6.55656 4.12461 -5.00946 -5.73628 4.88844 -4.65346 -5.59547 4.15281 -5.35581 -7.33894 4.86491 -3.71931 -8.38259 3.66404 -4.00534 -6.35289 3.71273 -5.39694 -8.54901 4.77611 -2.24252 -5.56352 3.62128 -5.73177 -5.66235 5.52107 -3.90368 -8.24611 4.26741 -3.52137 -7.9762 3.70937 -4.36192 -6.78958 3.71794 -5.18144 -5.84906 3.76432 -5.54828 -7.53969 3.86113 -4.58248 -7.71735 4.13537 -4.19217 -7.6837 4.98825 -3.19226 -7.33039 5.59182 -2.489 -8.19004 5.07324 -2.31595 -8.26286 5.48944 -0.358956 -6.44978 5.52041 -3.48342 -8.55588 5.08803 -1.38122 -7.86401 5.46966 -1.91764 -7.65946 5.81016 -1.1242 -8.6657 5.11431 -0.753584 -6.3383 5.05991 -4.18858 -7.80472 5.79505 -0.574216 -6.40774 5.72517 -3.13132 -8.19925 5.48311 -0.868517 -7.09157 5.24351 -3.39853 -8.21606 5.38304 -1.29958 -8.1948 5.31226 -1.61609 -6.91822 5.52228 -3.0797 -7.54538 5.32215 -2.75798 -7.78941 5.35478 -2.31559 -6.15744 5.34475 -3.88853 -7.93687 5.03074 -2.7541 -8.37296 5.08063 -1.84858 -7.21098 5.41767 -2.94376 -5.16961 6.67443 -1.49644 -4.26196 6.73886 -1.61475 -4.07374 6.56318 -2.25591 -4.6531 6.86451 -0.667447 -3.65492 6.88078 -0.692561 -5.4994 6.48363 -1.99137 -3.27428 6.71012 -1.59065 -5.31579 6.795 -0.344875 -4.9071 6.52553 -2.18758 -4.27493 6.83777 -1.05186 -5.11217 6.35454 -2.55684 -5.26377 6.7396 -0.958456 -3.74097 6.64183 -1.96818 -3.36589 6.37552 -2.67802 -3.93318 6.81346 -1.22489 -3.3773 6.80501 -1.10211 -4.30783 6.37223 -2.71101 -3.83047 6.38908 -2.69072 -4.15474 6.88169 -0.698369 -3.57535 6.52887 -2.28345 -4.7309 6.36234 -2.64378 -4.72227 6.7561 -1.27415 -5.98256 6.06373 -2.78218 -5.72344 6.6167 -1.17791 -5.6614 6.27158 -2.45264 -5.97711 6.6016 -0.746603 -7.00685 6.25757 -0.260246 -6.92407 6.02904 -1.87091 -6.19876 6.57953 -0.298983 -6.08222 6.31521 -2.00205 -6.37231 6.41633 -1.2072 -6.3449 6.13201 -2.2899 -6.9288 6.24436 -0.856194 -6.53661 5.95796 -2.5634 -7.24895 5.94836 -1.5925 -6.02773 6.42025 -1.6696 -6.82035 5.95467 -2.2292 -7.55074 5.96382 -0.253916 -6.93012 6.14992 -1.35346 -7.33315 6.03386 -0.692221 -4.52306 4.65946 5.14899 -4.05906 4.44417 5.35844 -3.31681 3.93646 5.69863 -3.61287 3.77536 5.82432 -5.05153 4.16151 5.47881 -7.60839 3.0877 5.0957 -7.00186 2.88282 5.58132 -2.39547 4.20374 5.32244 -1.8444 3.94432 5.32486 -1.81563 3.46058 5.6413 -2.20149 4.46525 5.04469 -2.59982 3.68155 5.73571 -4.80078 4.94418 4.82805 -3.46276 4.71552 5.08631 -4.3357 3.99723 5.68265 -3.29017 4.4342 5.31735 -7.9271 2.71951 5.07407 -5.43506 3.7602 5.66737 -3.71383 4.33998 5.42342 -1.33789 3.93872 5.08809 -2.53025 4.53428 5.07406 -7.41843 2.83153 5.35658 -5.06789 3.46814 5.91839 -5.09414 4.68882 5.0169 -2.83653 4.05782 5.52695 -4.04188 4.89681 4.93538 -1.81107 3.01484 5.87119 -1.4449 3.58662 5.37506 -6.17559 2.88117 5.91624 -5.49145 4.94507 4.66369 -9.083 2.97568 3.72218 -2.88915 4.97703 4.74865 -9.52153 2.85348 3.13883 -1.83043 4.99453 4.35593 -1.39194 6.43398 -0.038862 -0.37924 5.94684 0.146417 -1.71561 6.50942 0.796612 -2.48103 6.75622 0.355497 -1.41452 4.45034 4.71223 --0.39522 5.40155 0.0532568 -2.88237 6.74321 1.19413 -8.35249 2.79414 4.66374 -2.44788 5.05691 4.52761 -9.90472 2.77433 2.40294 -1.86276 6.59473 0.0517756 -2.95139 6.83691 0.354884 -2.43792 6.69197 0.887341 -1.37211 4.94646 4.15197 -8.78374 2.84948 4.17497 --0.80851 5.03754 -0.182908 --1.27617 4.54246 -0.248443 --1.51197 4.25019 0.0327273 -0.97863 6.25577 0.321148 -0.0319 5.65453 0.921387 -0.65258 6.04772 0.784519 -1.08621 6.24941 0.821254 -1.0454 3.22892 5.42525 -0.22898 3.0918 4.98807 -0.89102 3.87095 4.89312 -1.25141 2.84124 5.72979 -0.54844 3.49953 4.93521 -0.1536 4.20898 4.02935 -0.89187 4.69187 4.12568 -0.14071 4.6639 3.47679 -1.21875 6.22698 1.33786 -0.47442 4.62872 3.83983 -0.19628 3.44999 4.72099 -0.94025 5.02607 3.75092 -0.35525 5.02298 3.18252 -0.66342 4.18505 4.47437 -0.1482 3.86552 4.33775 -0.42204 5.82812 1.20798 --0.14744 5.08123 2.32036 --2.22214 3.10253 0.135775 --1.82977 3.79975 0.0879154 --1.09206 4.74519 0.109349 --0.70595 5.04889 0.978231 --0.65983 5.16105 0.429639 --0.25314 5.48079 0.6045 --1.35464 4.43957 0.416284 --1.89533 3.6104 0.813948 --1.29784 4.425 0.969505 --1.067 4.71362 0.76277 --2.06355 3.28957 0.838541 --1.5021 4.2259 0.611967 --1.62007 4.01612 0.833696 --1.01627 4.8092 0.423617 --0.75382 4.71363 1.95422 --0.48289 4.82147 2.28071 --0.74032 4.89222 1.45401 --0.42553 5.20677 1.326 --2.06295 3.14911 1.3018 --1.39193 4.05936 1.75043 --1.89828 3.09418 2.03981 --0.95027 4.31274 2.35581 --1.18389 4.44871 1.36525 --1.75077 3.70092 1.32581 --1.42564 3.72902 2.27405 --1.60747 3.65401 1.90867 --1.94527 2.72073 2.3613 -5.75557 4.49191 5.02534 -6.34246 4.07667 5.13596 -7.17855 3.74136 4.94452 -6.46368 3.20975 5.65817 -5.88606 3.28501 5.82689 -5.87858 4.6878 4.79533 -6.90351 3.50001 5.27144 -7.78993 3.36584 4.7749 -5.82679 4.00631 5.38904 -6.05294 3.76963 5.46929 -6.40414 3.61911 5.42618 -6.37901 4.37782 4.8542 -8.77108 3.95821 3.18335 -9.13208 4.69764 0.0270291 -8.33018 4.65254 2.8617 -6.77088 4.4061 4.63309 -9.30813 4.44728 0.723874 -9.58468 3.35456 2.45635 -9.82397 3.807 -0.0665188 -9.10616 4.16355 2.25912 -7.38883 4.75754 3.79831 -8.62698 3.33065 4.01025 -7.80683 4.36593 3.87612 -8.90909 4.67661 1.5872 -8.0204 3.67824 4.34682 -9.55794 3.98525 1.28431 -9.76515 3.42741 1.83916 -8.32914 3.2182 4.40574 -8.39967 4.11028 3.50954 -9.15763 3.52451 3.08581 -7.65486 3.87769 4.48903 -7.13937 4.46678 4.32709 -8.60905 3.71948 3.67879 -9.47997 4.28501 -0.23803 -9.75091 3.88933 0.421522 -9.34138 3.92285 2.11227 -7.86261 4.70144 3.38975 -9.12336 4.68849 0.397763 -6.63741 4.64742 4.45684 -8.77076 4.42272 2.48866 -9.84126 3.15669 2.05634 -8.23534 3.92253 3.89247 -9.15645 4.52848 1.14175 -8.49795 4.68467 2.49979 -9.91553 3.625 0.345968 -7.21993 4.16102 4.55668 -8.89202 3.42674 3.5774 -9.05291 3.94921 2.69809 -8.84828 4.53476 2.0738 -8.94377 4.81575 0.826043 -9.30109 4.12181 1.79783 -8.56944 5.17772 0.929438 -7.67769 5.58195 1.93658 -7.53399 5.87964 1.10387 -7.66424 5.12206 2.98536 -8.45294 5.0233 1.83835 -7.77315 5.21008 2.67113 -7.90973 5.49626 1.72692 -7.3988 5.40941 2.76396 -7.9794 5.63748 0.874497 -8.20852 5.10262 2.16621 -6.71007 4.97406 4.04884 -8.25152 5.34405 1.31208 -7.99761 5.69367 -0.0773789 -7.67885 5.87891 0.555096 -8.79428 5.04718 0.162687 -8.07673 5.63644 0.220107 -4.9329 6.81775 0.701223 -4.65735 6.82139 1.04286 -5.09907 6.71881 1.23562 -4.30807 6.87504 0.659396 -3.37952 6.75671 1.33215 -5.55603 6.68437 0.92335 -7.24899 6.00706 1.29086 -6.18766 6.44423 1.32996 -6.37723 6.45213 0.950407 -6.80138 6.32007 0.710659 -6.76506 6.27195 1.12289 -4.09234 6.92261 -0.0173769 -5.46769 6.77337 0.131283 -3.46915 6.88468 0.564215 -3.42528 6.90009 0.0351289 -4.46265 6.90617 0.113743 -3.80536 6.89737 0.568279 -4.91958 6.8471 0.302087 -4.92685 6.85514 -0.0756824 -5.90175 6.64814 0.501493 -6.48087 6.47197 0.350792 -7.48623 6.00853 0.235483 -6.04085 6.6208 0.202171 --2.25335 1.61332 2.55618 --0.25645 2.0149 5.13896 --0.10826 2.69885 4.94903 --1.22286 2.46781 3.90942 --1.9755 2.33449 2.68469 --0.7829 2.01177 4.65851 --1.64884 1.80311 3.65096 --1.27772 1.68249 4.22196 --1.80314 2.03729 3.25516 --0.70273 2.55494 4.47307 --1.49191 2.69499 3.34198 --0.1573 3.45658 4.4203 --0.44308 4.32622 3.21219 --0.241 4.81517 2.74904 --0.44297 3.07232 4.41317 --0.40285 3.87069 3.7803 --0.24201 4.26094 3.53608 --0.77656 3.53999 3.66245 --1.40411 3.46515 2.71664 --1.0806 3.64317 3.09028 --1.59633 2.93841 2.92574 --0.78129 3.17155 3.96315 --1.19288 3.0759 3.50079 --1.24403 3.83778 2.52456 --1.03108 3.98198 2.7203 -4.12237 5.2702 4.54643 -3.74936 5.2017 4.61843 -2.86734 5.18279 4.50863 -1.76413 5.24193 4.00708 -5.08277 5.26666 4.40645 -5.72035 5.11751 4.38769 -6.23657 5.2036 4.05319 -7.01201 5.54679 2.9396 -6.97368 5.31107 3.38033 -6.53958 5.55133 3.32519 -7.21954 5.79353 2.08381 -6.60601 5.25622 3.73346 -7.08672 5.70372 2.48788 -6.77856 5.9775 2.2029 -6.47006 6.19331 1.92073 -6.95979 6.05134 1.69972 -6.50861 5.91266 2.65031 -5.57032 6.61131 1.39865 -5.85438 5.69365 3.52942 -5.61436 5.54695 3.86373 -6.12973 5.88671 3.02484 -5.92676 6.33656 2.0932 -5.7672 6.13354 2.7376 -6.0292 6.11798 2.56194 -2.40998 6.61205 1.38009 -0.81218 6.00172 1.49458 --0.01099 5.50091 1.40654 -3.87667 6.7702 1.47018 -2.30015 5.53873 3.86836 -4.60362 5.42376 4.31583 -1.44961 5.47431 3.48317 -2.98634 5.55229 4.06724 -1.62671 6.32911 1.60442 -3.22278 5.38543 4.3372 -4.33706 5.52675 4.21143 -3.71731 5.51652 4.22589 -0.3354 5.32617 2.61317 --0.05388 5.34729 1.89168 -0.80537 5.37367 3.08646 -0.26506 5.65581 1.58062 -5.19215 5.65594 3.87619 -5.25075 6.39117 2.4054 -5.35572 6.59572 1.66325 -5.56995 6.01142 3.11983 -3.92496 6.13808 3.26323 -4.35806 5.76576 3.87651 -2.59502 6.18951 2.8369 -1.68195 6.20461 2.12066 -3.71525 5.78695 3.85557 -2.0297 5.93742 3.06088 -2.65208 6.49598 2.0645 -4.57695 6.08446 3.30494 -2.92604 5.9928 3.37245 -2.12409 5.68895 3.55035 -4.86651 5.95482 3.47325 -1.509 5.9691 2.56584 -1.30061 5.72163 2.90958 -2.29201 6.25448 2.49784 -1.96474 6.12134 2.58733 -3.0324 6.33643 2.65531 -3.50279 6.04454 3.38807 -5.05393 6.0616 3.21282 -2.09148 6.44337 1.72824 -2.16702 6.35029 2.09258 -0.58857 5.75329 1.94553 -1.01144 5.78084 2.48493 -0.98726 5.90605 2.10555 -1.24707 6.10316 1.80762 -4.40414 6.47118 2.48911 -3.55428 6.55827 2.21836 -4.34074 6.72686 1.63259 -3.50635 6.25934 2.97418 -4.7949 6.58478 2.01173 -3.34385 6.68096 1.71725 -4.26816 6.28591 2.91912 -5.07125 6.21048 2.90962 -4.78574 6.70702 1.52796 -3.99025 6.51082 2.37536 -3 0 1025 74 -3 0 74 1193 -3 0 418 994 -3 0 1193 418 -3 0 994 540 -3 0 540 1092 -3 0 1092 1025 -3 1 18 779 -3 1 1055 18 -3 1 971 249 -3 1 249 1055 -3 1 634 557 -3 1 557 971 -3 1 1182 634 -3 1 779 948 -3 1 948 1182 -3 2 21 786 -3 2 787 21 -3 2 274 563 -3 2 786 274 -3 2 563 848 -3 2 836 787 -3 2 848 836 -3 3 706 45 -3 3 45 1185 -3 3 137 595 -3 3 606 137 -3 3 595 706 -3 3 1185 606 -3 4 406 206 -3 4 206 1118 -3 4 227 337 -3 4 1118 227 -3 4 337 401 -3 4 401 1037 -3 4 1037 406 -3 5 319 218 -3 5 218 414 -3 5 221 319 -3 5 403 221 -3 5 224 369 -3 5 414 224 -3 5 369 403 -3 6 355 229 -3 6 229 1144 -3 6 240 343 -3 6 932 240 -3 6 343 318 -3 6 318 355 -3 6 1144 932 -3 7 107 247 -3 7 869 107 -3 7 238 257 -3 7 695 238 -3 7 247 695 -3 7 257 942 -3 7 383 869 -3 7 942 383 -3 8 192 358 -3 8 368 192 -3 8 255 349 -3 8 384 255 -3 8 349 1080 -3 8 358 868 -3 8 1162 368 -3 8 868 384 -3 8 1080 1162 -3 9 1100 311 -3 9 311 1102 -3 9 673 412 -3 9 412 1100 -3 9 1102 649 -3 10 458 285 -3 10 285 656 -3 10 812 317 -3 10 317 1020 -3 10 1020 458 -3 10 656 1079 -3 10 752 812 -3 10 1079 752 -3 11 58 592 -3 11 1034 58 -3 11 87 365 -3 11 1036 87 -3 11 679 145 -3 11 145 1036 -3 11 365 1034 -3 11 592 679 -3 12 568 102 -3 12 102 724 -3 12 314 577 -3 12 724 314 -3 12 806 568 -3 12 577 999 -3 12 999 806 -3 13 510 139 -3 13 139 854 -3 13 854 435 -3 13 435 891 -3 13 547 510 -3 13 883 547 -3 13 1041 883 -3 13 891 1041 -3 14 138 492 -3 14 545 138 -3 14 856 361 -3 14 361 863 -3 14 492 856 -3 14 667 545 -3 14 863 667 -3 15 63 433 -3 15 639 63 -3 15 433 101 -3 15 101 1007 -3 15 955 639 -3 15 1008 955 -3 15 1007 1008 -3 16 967 213 -3 16 213 1070 -3 16 544 293 -3 16 293 599 -3 16 1070 523 -3 16 523 1178 -3 16 1178 544 -3 16 599 875 -3 16 875 967 -3 17 603 287 -3 17 287 760 -3 17 931 603 -3 17 906 610 -3 17 610 1026 -3 17 760 906 -3 17 1026 931 -3 18 147 732 -3 18 739 147 -3 18 732 447 -3 18 447 1104 -3 18 1103 739 -3 18 1104 779 -3 18 1055 1103 -3 19 445 217 -3 19 217 453 -3 19 497 445 -3 19 453 1151 -3 19 1176 497 -3 19 1151 1176 -3 20 205 399 -3 20 460 205 -3 20 455 279 -3 20 399 455 -3 21 748 477 -3 21 477 786 -3 21 747 748 -3 21 1018 747 -3 21 787 1018 -3 22 450 219 -3 22 219 729 -3 22 426 272 -3 22 272 450 -3 22 978 426 -3 22 729 439 -3 22 439 978 -3 23 788 271 -3 23 271 1165 -3 23 741 436 -3 23 436 788 -3 23 521 1048 -3 23 1165 521 -3 23 1048 741 -3 24 607 169 -3 24 169 1153 -3 24 766 323 -3 24 323 859 -3 24 765 494 -3 24 494 766 -3 24 859 607 -3 24 1153 765 -3 25 131 1067 -3 25 1139 131 -3 25 234 965 -3 25 1067 234 -3 25 451 539 -3 25 965 451 -3 25 539 1139 -3 26 585 300 -3 26 300 964 -3 26 397 364 -3 26 364 897 -3 26 964 397 -3 26 997 585 -3 26 897 590 -3 26 590 997 -3 27 309 898 -3 27 1122 309 -3 27 589 375 -3 27 375 601 -3 27 898 589 -3 27 601 1071 -3 27 1071 1122 -3 28 419 528 -3 28 905 419 -3 28 528 652 -3 28 861 569 -3 28 569 905 -3 28 652 861 -3 29 162 702 -3 29 1091 162 -3 29 487 768 -3 29 878 487 -3 29 702 878 -3 29 768 938 -3 29 938 1091 -3 30 294 822 -3 30 855 294 -3 30 549 815 -3 30 822 549 -3 30 815 855 -3 31 129 770 -3 31 1060 129 -3 31 136 808 -3 31 980 136 -3 31 605 507 -3 31 507 980 -3 31 770 605 -3 31 808 1131 -3 31 1131 1060 -3 32 738 268 -3 32 268 797 -3 32 472 738 -3 32 780 472 -3 32 506 657 -3 32 797 506 -3 32 657 780 -3 33 123 584 -3 33 736 123 -3 33 338 198 -3 33 198 381 -3 33 584 338 -3 33 381 538 -3 33 538 736 -3 34 260 688 -3 34 773 260 -3 34 517 773 -3 34 688 951 -3 35 254 119 -3 35 119 299 -3 35 153 157 -3 35 299 153 -3 35 157 785 -3 35 491 254 -3 35 1001 491 -3 35 785 1001 -3 36 212 685 -3 36 1135 212 -3 36 490 448 -3 36 448 969 -3 36 1186 490 -3 36 685 1186 -3 36 969 1135 -3 37 111 226 -3 37 672 111 -3 37 226 371 -3 38 277 511 -3 38 1011 277 -3 38 511 587 -3 38 587 1062 -3 38 647 1011 -3 38 1062 647 -3 39 524 304 -3 39 304 940 -3 39 663 328 -3 39 328 1166 -3 39 916 524 -3 39 940 663 -3 39 1166 916 -3 40 594 431 -3 40 431 614 -3 40 548 441 -3 40 441 703 -3 40 543 594 -3 40 1150 543 -3 40 614 548 -3 40 703 1150 -3 41 960 63 -3 41 63 981 -3 42 213 519 -3 42 648 213 -3 42 421 648 -3 42 813 421 -3 42 519 563 -3 42 563 813 -3 43 794 196 -3 43 196 1098 -3 43 550 845 -3 43 1098 550 -3 43 650 756 -3 43 845 650 -3 43 756 794 -3 44 114 222 -3 44 278 114 -3 44 222 719 -3 44 1017 278 -3 44 719 1155 -3 44 1155 1017 -3 45 708 79 -3 45 79 1185 -3 45 749 627 -3 45 627 772 -3 45 706 749 -3 45 772 708 -3 46 156 722 -3 46 1005 156 -3 46 911 230 -3 46 230 919 -3 46 722 911 -3 46 919 1005 -3 47 181 715 -3 47 849 181 -3 47 243 220 -3 47 220 398 -3 47 466 243 -3 47 398 849 -3 47 715 466 -3 48 201 436 -3 48 791 201 -3 48 436 698 -3 48 579 690 -3 48 707 579 -3 48 690 791 -3 48 698 707 -3 49 214 144 -3 49 144 926 -3 49 225 214 -3 49 591 225 -3 49 281 486 -3 49 926 281 -3 49 486 591 -3 50 248 126 -3 50 126 990 -3 50 237 248 -3 50 609 237 -3 50 671 303 -3 50 303 675 -3 50 675 609 -3 50 990 671 -3 51 637 363 -3 51 363 1117 -3 51 1117 493 -3 51 493 1199 -3 51 611 637 -3 51 1199 611 -3 52 352 654 -3 52 705 352 -3 52 370 670 -3 52 839 370 -3 52 654 839 -3 52 670 860 -3 52 767 705 -3 52 860 767 -3 53 660 385 -3 53 385 1142 -3 53 533 411 -3 53 411 660 -3 53 469 533 -3 53 680 469 -3 53 1142 680 -3 54 163 238 -3 54 764 163 -3 54 238 321 -3 54 321 1013 -3 54 635 386 -3 54 386 764 -3 54 1013 635 -3 55 676 135 -3 55 135 952 -3 55 566 259 -3 55 259 676 -3 55 952 566 -3 56 261 123 -3 56 123 736 -3 56 489 261 -3 56 736 292 -3 56 292 759 -3 56 1173 489 -3 56 759 1171 -3 56 1171 877 -3 56 877 1173 -3 57 263 740 -3 57 765 263 -3 57 316 617 -3 57 740 316 -3 57 617 416 -3 57 416 790 -3 57 790 765 -3 58 108 618 -3 58 1002 108 -3 58 618 592 -3 58 1109 1002 -3 58 1034 1109 -3 59 88 516 -3 59 876 88 -3 59 456 876 -3 59 1181 456 -3 59 516 678 -3 59 678 1181 -3 60 334 630 -3 60 789 334 -3 60 630 835 -3 60 835 645 -3 61 231 117 -3 61 117 828 -3 61 684 231 -3 61 828 378 -3 62 776 313 -3 62 535 776 -3 62 1033 535 -3 63 960 433 -3 63 639 581 -3 63 581 981 -3 64 783 467 -3 64 467 805 -3 64 805 556 -3 64 556 1087 -3 64 1087 783 -3 65 413 666 -3 65 1116 413 -3 65 534 641 -3 65 701 534 -3 65 641 1160 -3 65 666 1136 -3 65 1136 701 -3 65 1160 1116 -3 66 223 775 -3 66 1130 223 -3 66 576 465 -3 66 465 1130 -3 66 559 530 -3 66 530 576 -3 66 775 559 -3 67 142 782 -3 67 802 142 -3 67 657 427 -3 67 427 802 -3 67 478 657 -3 67 782 478 -3 68 112 188 -3 68 1045 112 -3 68 188 894 -3 68 272 426 -3 68 1126 272 -3 68 426 1045 -3 68 894 1126 -3 69 436 201 -3 69 201 945 -3 69 788 436 -3 69 502 788 -3 69 972 502 -3 69 945 615 -3 69 615 972 -3 70 160 597 -3 70 1068 160 -3 70 597 443 -3 70 443 989 -3 70 1042 541 -3 70 541 1093 -3 70 989 1042 -3 70 1093 1068 -3 71 140 536 -3 71 681 140 -3 71 536 315 -3 71 315 847 -3 71 574 816 -3 71 847 574 -3 71 816 681 -3 72 354 546 -3 72 820 354 -3 72 761 387 -3 72 387 820 -3 72 546 761 -3 73 346 182 -3 73 182 813 -3 73 1050 346 -3 73 563 704 -3 73 813 563 -3 73 704 1050 -3 74 82 183 -3 74 950 82 -3 74 183 943 -3 74 640 850 -3 74 943 640 -3 74 850 1193 -3 74 1025 950 -3 75 357 1011 -3 75 1035 357 -3 75 446 628 -3 75 742 446 -3 75 628 1035 -3 75 647 742 -3 75 1011 647 -3 76 138 638 -3 76 714 138 -3 76 514 714 -3 76 723 514 -3 76 586 723 -3 76 1086 586 -3 76 638 1086 -3 77 379 351 -3 77 351 522 -3 77 817 379 -3 77 522 474 -3 77 474 531 -3 77 531 817 -3 78 795 177 -3 78 177 1052 -3 78 208 795 -3 78 944 208 -3 78 404 692 -3 78 1052 404 -3 79 979 204 -3 79 204 1101 -3 79 1101 606 -3 79 606 1185 -3 79 708 730 -3 79 730 1081 -3 79 1081 979 -3 80 185 282 -3 80 725 185 -3 80 420 190 -3 80 190 725 -3 80 282 917 -3 80 917 420 -3 81 564 483 -3 81 483 690 -3 81 988 564 -3 81 579 682 -3 81 690 579 -3 81 682 907 -3 81 907 988 -3 82 449 183 -3 82 610 449 -3 82 950 610 -3 83 629 814 -3 83 863 629 -3 83 667 863 -3 83 1061 667 -3 83 814 929 -3 83 929 818 -3 83 818 1061 -3 84 313 694 -3 84 937 313 -3 85 400 499 -3 85 1003 400 -3 85 913 470 -3 85 470 1073 -3 85 499 1161 -3 85 562 913 -3 85 1161 562 -3 85 1073 1003 -3 86 631 336 -3 86 336 922 -3 86 527 578 -3 86 922 527 -3 86 578 867 -3 86 985 631 -3 86 867 985 -3 87 934 365 -3 87 551 473 -3 87 473 934 -3 87 733 551 -3 87 1036 733 -3 88 876 213 -3 88 213 967 -3 88 962 516 -3 88 875 784 -3 88 784 962 -3 88 967 875 -3 89 899 182 -3 89 182 1021 -3 89 1021 344 -3 89 344 1084 -3 89 600 421 -3 89 421 899 -3 89 1084 600 -3 90 141 192 -3 90 192 526 -3 90 526 475 -3 91 696 419 -3 91 419 905 -3 91 430 696 -3 91 824 430 -3 91 569 625 -3 91 905 569 -3 91 625 824 -3 92 376 963 -3 92 1108 376 -3 92 659 593 -3 92 593 1077 -3 92 1057 659 -3 92 963 842 -3 92 842 1057 -3 92 1077 1108 -3 93 870 340 -3 93 360 699 -3 93 699 870 -3 94 476 374 -3 94 374 885 -3 94 382 616 -3 94 1128 382 -3 94 596 476 -3 94 616 596 -3 94 885 1128 -3 95 308 730 -3 95 1179 308 -3 95 730 708 -3 95 708 1075 -3 95 1006 737 -3 95 737 1179 -3 95 1075 1006 -3 96 832 423 -3 96 423 1198 -3 96 737 509 -3 96 509 832 -3 96 800 737 -3 96 1198 800 -3 97 443 709 -3 97 833 443 -3 97 709 1123 -3 97 984 811 -3 97 811 1076 -3 97 1076 833 -3 97 1071 984 -3 97 1123 1071 -3 98 320 658 -3 98 752 320 -3 98 658 691 -3 98 668 728 -3 98 1089 668 -3 98 691 1089 -3 98 728 812 -3 98 812 752 -3 99 500 429 -3 99 429 615 -3 99 557 500 -3 99 971 557 -3 99 615 971 -3 100 853 529 -3 100 529 1121 -3 100 889 669 -3 100 669 936 -3 100 1047 853 -3 100 1147 889 -3 100 936 1047 -3 100 1121 1147 -3 101 159 488 -3 101 829 159 -3 101 433 829 -3 101 488 549 -3 101 549 822 -3 101 822 1007 -3 102 480 142 -3 102 142 1196 -3 102 565 480 -3 102 1124 565 -3 102 568 1124 -3 102 1196 724 -3 103 300 454 -3 103 1133 300 -3 103 454 1164 -3 103 536 823 -3 103 1164 536 -3 103 823 1120 -3 103 1120 1133 -3 104 609 675 -3 104 893 609 -3 104 656 953 -3 104 1083 656 -3 104 675 1083 -3 104 852 893 -3 104 914 852 -3 104 953 914 -3 105 440 540 -3 105 1088 440 -3 105 540 994 -3 105 774 612 -3 105 612 1088 -3 105 949 774 -3 105 1000 949 -3 105 994 1000 -3 106 534 224 -3 106 224 1040 -3 106 575 324 -3 106 324 643 -3 106 641 534 -3 106 1040 575 -3 106 809 641 -3 106 643 809 -3 107 195 743 -3 107 869 195 -3 107 529 247 -3 107 743 325 -3 107 325 1121 -3 107 1121 529 -3 108 233 618 -3 108 804 233 -3 108 359 804 -3 108 1002 359 -3 109 511 280 -3 109 280 927 -3 109 587 511 -3 109 920 587 -3 109 928 920 -3 109 927 928 -3 110 225 591 -3 110 851 225 -3 110 792 399 -3 110 399 851 -3 110 591 624 -3 110 624 792 -3 111 1127 226 -3 111 860 670 -3 111 670 1127 -3 111 672 871 -3 111 769 767 -3 111 767 860 -3 111 871 769 -3 112 1032 188 -3 112 771 572 -3 112 572 1032 -3 112 640 771 -3 112 1119 640 -3 112 1045 1119 -3 113 224 701 -3 113 983 224 -3 113 670 370 -3 113 370 750 -3 113 1136 666 -3 113 666 1145 -3 113 1127 670 -3 113 701 1136 -3 113 750 983 -3 113 1145 1127 -3 114 1163 222 -3 114 278 537 -3 114 380 1163 -3 114 1187 380 -3 114 537 841 -3 114 841 1187 -3 115 933 490 -3 115 490 1186 -3 115 857 664 -3 115 664 933 -3 115 685 1031 -3 115 1186 685 -3 115 1172 857 -3 115 1031 1172 -3 116 501 212 -3 116 212 1135 -3 116 598 501 -3 116 1016 598 -3 116 969 834 -3 116 834 1016 -3 116 1135 969 -3 117 231 687 -3 117 687 351 -3 117 351 827 -3 117 827 828 -3 118 722 265 -3 118 265 1061 -3 118 417 644 -3 118 818 417 -3 118 644 1157 -3 118 1157 722 -3 118 1061 818 -3 119 254 360 -3 119 461 299 -3 119 360 915 -3 119 935 461 -3 119 915 935 -3 120 251 699 -3 120 838 251 -3 120 831 382 -3 120 382 838 -3 120 699 491 -3 120 491 831 -3 121 651 317 -3 121 317 812 -3 121 898 651 -3 121 812 728 -3 121 728 1029 -3 121 977 898 -3 121 1029 977 -3 122 464 295 -3 122 295 1158 -3 122 344 961 -3 122 1084 344 -3 122 377 464 -3 122 961 377 -3 122 1158 1084 -3 123 261 1082 -3 123 1082 584 -3 124 661 246 -3 124 246 798 -3 124 253 661 -3 124 846 253 -3 124 798 297 -3 124 297 846 -3 125 198 350 -3 125 858 198 -3 125 350 349 -3 125 349 374 -3 125 374 858 -3 126 248 373 -3 126 373 582 -3 126 582 495 -3 126 495 990 -3 127 890 210 -3 127 210 1106 -3 127 472 662 -3 127 1106 472 -3 127 521 531 -3 127 662 521 -3 127 531 890 -3 128 844 235 -3 128 235 1056 -3 128 240 533 -3 128 793 240 -3 128 342 793 -3 128 1056 342 -3 128 533 469 -3 128 469 844 -3 129 974 770 -3 129 801 872 -3 129 1060 801 -3 129 872 974 -3 130 621 208 -3 130 208 944 -3 130 711 621 -3 131 259 566 -3 131 1139 259 -3 131 566 966 -3 131 966 631 -3 131 631 1067 -3 132 191 815 -3 132 888 191 -3 132 463 555 -3 132 1175 463 -3 132 958 488 -3 132 488 1175 -3 132 555 888 -3 132 815 958 -3 133 366 191 -3 133 191 886 -3 133 197 366 -3 133 903 197 -3 133 886 367 -3 133 367 903 -3 134 568 301 -3 134 301 897 -3 134 364 840 -3 134 897 364 -3 134 487 565 -3 134 751 487 -3 134 565 1124 -3 134 1124 568 -3 134 840 751 -3 135 294 952 -3 135 1170 294 -3 135 362 438 -3 135 496 362 -3 135 438 1170 -3 135 676 496 -3 136 581 639 -3 136 980 581 -3 136 639 583 -3 136 583 808 -3 137 185 595 -3 137 947 185 -3 137 731 307 -3 137 307 947 -3 137 606 731 -3 138 545 269 -3 138 269 638 -3 138 714 492 -3 139 758 291 -3 139 291 854 -3 139 510 1022 -3 139 1022 758 -3 140 891 536 -3 140 681 883 -3 140 883 1041 -3 140 1041 891 -3 141 358 192 -3 141 340 930 -3 141 930 358 -3 142 480 807 -3 142 939 782 -3 142 802 996 -3 142 807 939 -3 142 996 1196 -3 143 623 231 -3 143 231 684 -3 143 322 755 -3 143 755 623 -3 144 214 620 -3 144 697 515 -3 144 515 926 -3 144 620 697 -3 145 679 305 -3 145 305 784 -3 145 599 733 -3 145 875 599 -3 145 733 1036 -3 145 784 875 -3 146 719 239 -3 146 1111 719 -3 147 690 483 -3 147 483 732 -3 147 791 690 -3 147 739 791 -3 148 312 720 -3 148 901 312 -3 148 313 901 -3 148 909 313 -3 148 720 346 -3 148 346 1069 -3 148 1069 909 -3 149 307 731 -3 149 1151 307 -3 149 763 345 -3 149 345 896 -3 149 422 689 -3 149 731 422 -3 149 896 497 -3 149 497 1176 -3 149 689 763 -3 149 1176 1151 -3 150 940 304 -3 150 304 1012 -3 150 865 625 -3 150 625 887 -3 150 887 663 -3 150 663 940 -3 150 1012 865 -3 151 718 303 -3 151 303 1095 -3 151 320 718 -3 151 744 320 -3 151 339 881 -3 151 1095 339 -3 151 881 744 -3 152 925 220 -3 152 220 1177 -3 152 337 777 -3 152 1004 337 -3 152 396 1004 -3 152 1177 396 -3 152 777 805 -3 152 805 925 -3 153 946 157 -3 153 299 862 -3 153 862 655 -3 153 655 946 -3 154 371 226 -3 154 226 666 -3 154 571 371 -3 154 413 415 -3 154 666 413 -3 155 683 311 -3 155 311 1100 -3 155 412 970 -3 155 1100 412 -3 155 626 552 -3 155 552 683 -3 155 970 626 -3 156 636 265 -3 156 265 722 -3 156 405 504 -3 156 1005 405 -3 156 504 721 -3 156 721 636 -3 157 392 785 -3 157 810 392 -3 157 946 810 -3 158 389 745 -3 158 1044 389 -3 158 493 941 -3 158 1199 493 -3 158 745 611 -3 158 611 1199 -3 158 941 1044 -3 160 429 597 -3 160 972 429 -3 160 502 972 -3 160 1068 502 -3 161 195 383 -3 161 394 195 -3 161 327 580 -3 161 608 327 -3 161 383 608 -3 161 580 394 -3 162 485 702 -3 162 1078 485 -3 162 674 525 -3 162 525 1078 -3 162 1091 674 -3 163 764 236 -3 163 236 963 -3 163 257 238 -3 163 376 257 -3 163 963 376 -3 164 259 539 -3 164 1059 259 -3 164 706 505 -3 164 505 1134 -3 164 539 749 -3 164 749 706 -3 164 1134 1059 -3 165 807 267 -3 165 267 907 -3 165 682 782 -3 165 907 682 -3 165 782 939 -3 165 939 807 -3 166 247 529 -3 166 695 247 -3 166 513 321 -3 166 321 695 -3 166 1015 513 -3 166 529 558 -3 166 558 553 -3 166 553 1015 -3 167 215 335 -3 167 713 215 -3 167 223 713 -3 167 775 223 -3 167 335 622 -3 167 622 559 -3 167 559 775 -3 168 395 230 -3 168 230 1028 -3 168 932 395 -3 168 411 932 -3 168 1028 411 -3 169 607 410 -3 169 410 613 -3 169 918 471 -3 169 471 1189 -3 169 613 918 -3 169 1189 1153 -3 170 268 567 -3 170 797 268 -3 170 665 457 -3 170 457 797 -3 170 567 1019 -3 170 1019 665 -3 171 642 300 -3 171 300 1133 -3 171 550 642 -3 171 845 550 -3 171 650 845 -3 171 1120 650 -3 171 1133 1120 -3 172 723 586 -3 172 1195 723 -3 173 418 619 -3 173 949 418 -3 173 619 1140 -3 173 646 774 -3 173 884 646 -3 173 774 949 -3 173 1140 884 -3 174 877 442 -3 174 442 892 -3 174 451 489 -3 174 627 451 -3 174 489 1173 -3 174 892 627 -3 174 1173 877 -3 175 836 456 -3 175 456 1181 -3 175 678 617 -3 175 617 1018 -3 175 1181 678 -3 175 787 836 -3 175 1018 787 -3 176 317 651 -3 176 1020 317 -3 176 948 458 -3 176 458 1020 -3 176 651 634 -3 176 634 1182 -3 176 1182 948 -3 177 781 206 -3 177 206 1052 -3 177 716 331 -3 177 331 781 -3 177 1112 716 -3 177 795 1112 -3 178 590 301 -3 178 301 806 -3 178 540 993 -3 178 1064 540 -3 178 806 577 -3 178 577 1064 -3 178 993 590 -3 179 819 262 -3 179 262 826 -3 179 466 570 -3 179 573 466 -3 179 570 819 -3 179 826 573 -3 180 530 221 -3 180 221 843 -3 180 843 393 -3 180 393 1099 -3 180 561 530 -3 180 1099 561 -3 181 543 276 -3 181 276 715 -3 181 497 734 -3 181 849 497 -3 181 734 543 -3 182 720 312 -3 182 312 1021 -3 182 346 720 -3 182 899 813 -3 183 449 904 -3 183 572 771 -3 183 904 572 -3 183 771 943 -3 184 269 504 -3 184 638 269 -3 184 586 1086 -3 184 1086 638 -3 185 947 282 -3 185 725 505 -3 185 505 1114 -3 185 1114 595 -3 186 552 187 -3 186 187 1043 -3 186 298 655 -3 186 1043 298 -3 186 683 552 -3 186 655 1054 -3 186 1054 683 -3 187 552 310 -3 187 310 1129 -3 187 541 1042 -3 187 1129 541 -3 187 989 833 -3 187 833 1043 -3 187 1042 989 -3 188 629 361 -3 188 361 894 -3 188 402 629 -3 188 1032 402 -3 189 339 604 -3 189 881 339 -3 189 432 744 -3 189 753 432 -3 189 604 560 -3 189 560 759 -3 189 744 881 -3 189 759 753 -3 190 362 496 -3 190 1137 362 -3 190 420 1137 -3 190 496 725 -3 191 366 956 -3 191 390 855 -3 191 956 390 -3 191 855 815 -3 191 888 886 -3 192 368 367 -3 192 367 526 -3 193 633 326 -3 193 326 992 -3 193 635 391 -3 193 391 852 -3 193 512 633 -3 193 852 512 -3 193 957 635 -3 193 992 957 -3 194 481 444 -3 194 444 680 -3 194 680 468 -3 194 468 735 -3 194 735 481 -3 195 869 383 -3 195 394 562 -3 195 562 743 -3 196 1058 258 -3 196 258 1098 -3 196 613 712 -3 196 794 613 -3 196 712 1058 -3 197 350 578 -3 197 1080 350 -3 197 527 366 -3 197 903 368 -3 197 368 1162 -3 197 578 527 -3 197 1162 1080 -3 198 253 381 -3 198 858 253 -3 198 338 880 -3 198 880 350 -3 199 325 499 -3 199 889 325 -3 199 328 889 -3 199 1166 328 -3 199 499 916 -3 199 916 1166 -3 200 540 1064 -3 200 1092 540 -3 200 577 931 -3 200 1064 577 -3 200 610 950 -3 200 1026 610 -3 200 931 1026 -3 200 950 1025 -3 200 1025 1092 -3 201 739 249 -3 201 249 945 -3 201 791 739 -3 202 769 686 -3 202 705 769 -3 202 1063 705 -3 203 825 380 -3 203 380 1187 -3 203 726 825 -3 203 1024 726 -3 203 841 1024 -3 203 1187 841 -3 204 308 419 -3 204 979 308 -3 204 419 696 -3 204 689 422 -3 204 422 1101 -3 204 1180 689 -3 204 696 1180 -3 205 1160 399 -3 205 460 873 -3 205 873 1116 -3 205 1116 1160 -3 206 864 404 -3 206 404 1052 -3 206 406 864 -3 206 781 1118 -3 207 245 517 -3 207 941 245 -3 207 389 1044 -3 207 517 1188 -3 207 1044 941 -3 208 621 727 -3 208 727 795 -3 209 745 389 -3 209 1037 745 -3 210 235 738 -3 210 912 235 -3 210 738 1106 -3 210 890 912 -3 211 318 343 -3 211 687 318 -3 211 343 342 -3 211 342 522 -3 211 522 968 -3 211 968 687 -3 212 501 828 -3 212 895 685 -3 212 828 827 -3 212 827 895 -3 213 876 519 -3 213 648 1070 -3 214 225 643 -3 214 354 620 -3 214 821 354 -3 214 643 821 -3 215 761 335 -3 215 387 761 -3 215 920 387 -3 215 713 920 -3 216 363 826 -3 216 1117 363 -3 216 803 464 -3 216 464 1117 -3 216 826 717 -3 216 717 1190 -3 216 1190 803 -3 217 445 1115 -3 217 801 453 -3 217 783 872 -3 217 1115 783 -3 217 872 801 -3 218 319 622 -3 218 575 414 -3 218 546 575 -3 218 622 546 -3 219 387 409 -3 219 820 387 -3 219 409 729 -3 219 450 820 -3 220 243 1177 -3 220 467 398 -3 220 925 467 -3 221 1065 319 -3 221 403 843 -3 221 530 559 -3 221 559 1065 -3 222 561 653 -3 222 1163 561 -3 222 653 719 -3 223 388 647 -3 223 1130 388 -3 223 587 713 -3 223 1062 587 -3 223 647 1062 -3 224 983 369 -3 224 414 1040 -3 224 534 701 -3 225 809 643 -3 225 851 809 -3 226 1145 666 -3 226 1127 1145 -3 227 781 331 -3 227 331 1132 -3 227 777 337 -3 227 1132 777 -3 227 1118 781 -3 228 605 341 -3 228 341 716 -3 228 727 605 -3 228 716 1112 -3 228 795 727 -3 228 1112 795 -3 229 322 645 -3 229 755 322 -3 229 355 755 -3 229 630 395 -3 229 395 1144 -3 229 835 630 -3 229 645 835 -3 230 911 241 -3 230 241 1027 -3 230 630 334 -3 230 334 919 -3 230 395 630 -3 230 1027 1028 -3 231 355 318 -3 231 318 687 -3 231 623 355 -3 232 1156 521 -3 232 521 1165 -3 232 817 1156 -3 232 1174 817 -3 232 857 1172 -3 232 1191 857 -3 232 1172 1031 -3 232 1031 1174 -3 232 1165 1191 -3 233 323 618 -3 233 859 323 -3 233 757 859 -3 233 1073 757 -3 233 804 1003 -3 233 1003 1073 -3 234 1082 261 -3 234 261 1113 -3 234 986 584 -3 234 584 1082 -3 234 631 985 -3 234 1067 631 -3 234 985 867 -3 234 867 986 -3 234 1113 965 -3 235 844 408 -3 235 408 973 -3 235 973 738 -3 235 912 1056 -3 236 764 1148 -3 236 768 842 -3 236 938 768 -3 236 842 963 -3 236 1148 938 -3 237 1015 248 -3 237 609 513 -3 237 513 1015 -3 238 695 321 -3 239 653 393 -3 239 393 710 -3 239 710 632 -3 239 719 653 -3 240 793 343 -3 240 411 533 -3 240 932 411 -3 241 644 385 -3 241 385 660 -3 241 1157 644 -3 241 660 1027 -3 241 911 722 -3 241 722 1157 -3 242 611 401 -3 242 401 1023 -3 242 637 611 -3 242 1146 637 -3 242 1023 1004 -3 242 1004 1146 -3 243 573 396 -3 243 396 1177 -3 243 466 573 -3 244 403 369 -3 244 369 750 -3 244 654 393 -3 244 393 843 -3 244 843 403 -3 244 839 654 -3 244 750 839 -3 245 773 517 -3 245 542 921 -3 245 941 542 -3 245 1154 773 -3 245 921 1154 -3 246 596 588 -3 246 588 1107 -3 246 661 596 -3 246 1074 798 -3 246 1107 1074 -3 248 553 373 -3 248 1015 553 -3 249 615 945 -3 249 971 615 -3 249 739 1103 -3 249 1103 1055 -3 250 329 840 -3 250 1094 329 -3 250 364 397 -3 250 840 364 -3 250 397 830 -3 250 407 659 -3 250 830 407 -3 250 659 1094 -3 251 340 870 -3 251 930 340 -3 251 868 358 -3 251 358 930 -3 251 838 384 -3 251 384 868 -3 251 870 699 -3 252 616 382 -3 252 382 831 -3 252 392 616 -3 252 785 392 -3 252 831 491 -3 252 491 1001 -3 252 1001 785 -3 253 677 381 -3 253 1183 661 -3 253 846 677 -3 253 858 1183 -3 254 699 360 -3 254 491 699 -3 255 885 349 -3 255 384 382 -3 255 382 1128 -3 255 1128 885 -3 256 874 373 -3 256 373 936 -3 256 861 652 -3 256 652 874 -3 256 669 799 -3 256 936 669 -3 256 799 861 -3 257 376 1108 -3 257 608 942 -3 257 1077 608 -3 257 1108 1077 -3 258 580 327 -3 258 327 593 -3 258 550 1098 -3 258 1167 550 -3 258 1058 580 -3 258 593 659 -3 258 659 1167 -3 259 1139 539 -3 259 1059 676 -3 260 503 688 -3 260 908 503 -3 260 773 1154 -3 260 1154 908 -3 261 489 1113 -3 262 293 717 -3 262 1038 293 -3 262 473 551 -3 262 819 473 -3 262 551 1038 -3 262 717 826 -3 263 765 459 -3 263 459 1022 -3 263 510 740 -3 263 1022 510 -3 264 694 909 -3 264 719 1111 -3 264 1155 719 -3 264 909 1017 -3 264 1017 1155 -3 265 636 545 -3 265 545 667 -3 265 667 1061 -3 266 675 303 -3 266 303 718 -3 266 320 518 -3 266 718 320 -3 266 518 656 -3 266 656 1083 -3 266 1083 675 -3 267 807 480 -3 267 480 998 -3 267 702 485 -3 267 485 907 -3 267 998 702 -3 268 408 567 -3 268 973 408 -3 268 738 973 -3 269 721 504 -3 269 545 636 -3 269 636 721 -3 270 283 707 -3 270 780 283 -3 270 347 662 -3 270 698 347 -3 270 662 780 -3 270 707 698 -3 271 502 602 -3 271 788 502 -3 271 602 664 -3 271 664 857 -3 271 857 1191 -3 271 1191 1165 -3 272 697 450 -3 272 515 697 -3 272 1126 515 -3 273 280 574 -3 273 837 280 -3 273 482 837 -3 273 884 482 -3 273 574 646 -3 273 646 884 -3 274 477 726 -3 274 786 477 -3 274 704 563 -3 274 841 704 -3 274 726 1024 -3 274 1024 841 -3 275 455 624 -3 275 1051 455 -3 275 624 514 -3 275 514 723 -3 275 723 1051 -3 276 543 1150 -3 276 570 715 -3 276 754 570 -3 276 703 754 -3 276 1150 703 -3 277 357 547 -3 277 1011 357 -3 277 681 511 -3 277 547 681 -3 278 346 1050 -3 278 1069 346 -3 278 1050 537 -3 278 1017 909 -3 278 909 1069 -3 279 455 1051 -3 279 1051 723 -3 279 723 1195 -3 280 837 409 -3 280 409 927 -3 280 511 816 -3 280 816 574 -3 281 492 486 -3 281 520 492 -3 281 926 520 -3 282 498 372 -3 282 372 917 -3 282 947 498 -3 283 657 478 -3 283 478 707 -3 283 780 657 -3 284 980 507 -3 284 507 995 -3 284 581 980 -3 284 981 581 -3 284 621 711 -3 284 995 621 -3 284 711 981 -3 285 458 330 -3 285 330 954 -3 285 953 656 -3 285 914 953 -3 285 954 914 -3 286 447 732 -3 286 796 447 -3 286 483 564 -3 286 732 483 -3 286 564 485 -3 286 485 1078 -3 286 525 796 -3 286 1078 525 -3 287 481 760 -3 287 1169 481 -3 287 603 1184 -3 287 665 1019 -3 287 1184 665 -3 287 1019 1169 -3 288 356 417 -3 288 923 356 -3 288 814 402 -3 288 402 904 -3 288 417 818 -3 288 929 814 -3 288 818 929 -3 288 904 923 -3 289 365 991 -3 289 1034 365 -3 289 425 778 -3 289 991 425 -3 289 778 1002 -3 289 1002 1109 -3 289 1109 1034 -3 290 871 672 -3 290 686 871 -3 291 650 435 -3 291 435 854 -3 291 471 756 -3 291 758 471 -3 291 756 650 -3 292 538 532 -3 292 532 753 -3 292 736 538 -3 292 753 759 -3 293 544 717 -3 293 733 599 -3 293 1038 733 -3 294 1170 822 -3 294 855 952 -3 295 464 803 -3 295 523 600 -3 295 1178 523 -3 295 803 544 -3 295 544 1178 -3 295 600 1158 -3 296 328 663 -3 296 799 328 -3 296 569 861 -3 296 887 569 -3 296 663 887 -3 296 861 799 -3 297 668 302 -3 297 302 846 -3 297 798 589 -3 297 589 977 -3 297 977 668 -3 298 946 655 -3 298 1043 833 -3 298 833 1076 -3 298 1152 946 -3 298 1076 1105 -3 298 1105 1152 -3 299 461 700 -3 299 700 924 -3 299 924 862 -3 300 1096 454 -3 300 585 1096 -3 300 642 1014 -3 300 830 964 -3 300 1014 830 -3 301 568 806 -3 301 590 897 -3 302 532 677 -3 302 691 532 -3 302 668 1089 -3 302 677 846 -3 302 1089 691 -3 303 671 1095 -3 304 425 614 -3 304 1143 425 -3 304 524 1143 -3 304 614 1012 -3 305 592 424 -3 305 424 866 -3 305 866 516 -3 305 516 962 -3 305 679 592 -3 305 962 784 -3 306 426 978 -3 306 1045 426 -3 306 619 850 -3 306 978 619 -3 306 850 640 -3 306 640 1119 -3 306 1119 1045 -3 307 498 947 -3 307 1151 498 -3 308 528 419 -3 308 452 528 -3 308 1179 452 -3 308 1081 730 -3 308 979 1081 -3 309 500 557 -3 309 1122 500 -3 309 557 634 -3 309 634 651 -3 309 651 898 -3 310 554 462 -3 310 462 1129 -3 310 552 626 -3 310 626 554 -3 311 683 508 -3 311 508 924 -3 311 924 1102 -3 312 879 344 -3 312 344 1021 -3 312 776 535 -3 312 535 879 -3 312 901 776 -3 313 909 694 -3 313 776 901 -3 314 484 603 -3 314 724 484 -3 314 1194 577 -3 314 603 1194 -3 315 454 612 -3 315 1164 454 -3 315 536 1164 -3 315 612 774 -3 315 774 646 -3 315 646 847 -3 316 740 479 -3 316 479 902 -3 316 1018 617 -3 316 628 747 -3 316 959 628 -3 316 747 1018 -3 316 902 959 -3 319 1065 622 -3 320 752 518 -3 320 1039 658 -3 320 744 1039 -3 321 976 391 -3 321 391 1013 -3 321 513 976 -3 323 424 592 -3 323 766 424 -3 323 592 618 -3 324 575 546 -3 324 546 821 -3 324 821 643 -3 325 1161 499 -3 325 743 1192 -3 325 889 1147 -3 325 1147 1121 -3 325 1192 1161 -3 326 796 525 -3 326 525 992 -3 326 633 910 -3 326 910 796 -3 327 608 593 -3 328 799 669 -3 328 669 889 -3 329 768 751 -3 329 751 840 -3 329 842 768 -3 329 1057 842 -3 329 1094 1057 -3 330 447 910 -3 330 1104 447 -3 330 458 779 -3 330 633 512 -3 330 512 954 -3 330 910 633 -3 330 779 1104 -3 331 341 556 -3 331 716 341 -3 331 556 1132 -3 332 601 588 -3 332 588 1085 -3 332 811 601 -3 332 1085 810 -3 332 810 1105 -3 332 1105 811 -3 333 555 463 -3 333 475 526 -3 333 526 555 -3 334 405 919 -3 335 546 622 -3 335 761 546 -3 336 366 922 -3 336 956 366 -3 336 631 390 -3 336 390 956 -3 337 1023 401 -3 337 1004 1023 -3 338 867 578 -3 338 578 880 -3 338 584 986 -3 338 986 867 -3 339 671 423 -3 339 423 832 -3 339 832 604 -3 339 1095 671 -3 341 1087 556 -3 341 605 770 -3 341 770 783 -3 341 783 1087 -3 342 343 793 -3 342 474 522 -3 342 890 474 -3 342 912 890 -3 342 1056 912 -3 344 879 503 -3 344 503 961 -3 345 594 543 -3 345 543 734 -3 345 763 594 -3 345 734 896 -3 347 1053 662 -3 347 698 975 -3 347 975 741 -3 347 741 1048 -3 347 1048 1053 -3 348 746 452 -3 348 452 800 -3 348 582 874 -3 348 1197 582 -3 348 652 746 -3 348 874 652 -3 348 800 1197 -3 349 350 1080 -3 349 885 374 -3 350 880 578 -3 351 379 1141 -3 351 968 522 -3 351 687 968 -3 351 895 827 -3 351 1141 895 -3 352 693 632 -3 352 632 710 -3 352 710 654 -3 352 705 693 -3 353 464 377 -3 353 377 542 -3 353 1117 464 -3 353 542 493 -3 353 493 1117 -3 354 450 620 -3 354 820 450 -3 354 821 546 -3 355 623 755 -3 356 468 417 -3 356 735 468 -3 356 1046 735 -3 356 923 1046 -3 357 902 547 -3 357 959 902 -3 357 1035 959 -3 359 400 804 -3 359 1097 400 -3 359 778 524 -3 359 524 916 -3 359 1002 778 -3 359 916 1097 -3 361 629 863 -3 361 856 762 -3 361 762 894 -3 362 955 438 -3 362 583 1072 -3 362 1137 583 -3 362 1072 955 -3 363 573 826 -3 363 1110 573 -3 363 637 1110 -3 365 934 441 -3 365 441 991 -3 366 527 922 -3 367 368 903 -3 367 1125 526 -3 367 886 1125 -3 369 983 750 -3 370 839 750 -3 372 420 917 -3 372 1060 420 -3 372 498 453 -3 372 453 801 -3 372 801 1060 -3 373 553 936 -3 373 874 582 -3 374 476 1183 -3 374 1183 858 -3 375 589 798 -3 375 1074 601 -3 375 798 1074 -3 377 921 542 -3 377 908 921 -3 377 961 908 -3 378 501 598 -3 378 828 501 -3 379 1031 685 -3 379 685 1141 -3 379 817 1174 -3 379 1174 1031 -3 380 576 561 -3 380 561 1163 -3 380 1009 576 -3 380 825 1009 -3 381 677 538 -3 382 384 838 -3 383 942 608 -3 385 644 468 -3 385 468 1142 -3 386 635 957 -3 386 957 674 -3 386 674 1148 -3 386 1148 764 -3 387 927 409 -3 387 920 928 -3 387 928 927 -3 388 465 446 -3 388 446 742 -3 388 1130 465 -3 388 742 647 -3 390 566 855 -3 390 966 566 -3 390 631 966 -3 391 609 893 -3 391 976 609 -3 391 635 1013 -3 391 893 852 -3 392 588 1066 -3 392 1085 588 -3 392 1066 616 -3 392 810 1085 -3 393 653 1099 -3 393 654 710 -3 394 470 913 -3 394 982 470 -3 394 913 562 -3 394 580 712 -3 394 712 982 -3 395 932 1144 -3 396 573 1110 -3 396 1110 637 -3 396 637 1146 -3 396 1146 1004 -3 397 964 830 -3 398 467 445 -3 398 445 849 -3 399 792 455 -3 399 641 851 -3 399 1160 641 -3 400 1097 499 -3 400 1003 804 -3 401 611 745 -3 401 745 1037 -3 402 572 904 -3 402 1032 572 -3 402 814 629 -3 404 864 1168 -3 405 1005 919 -3 406 900 864 -3 407 642 550 -3 407 550 1167 -3 407 1014 642 -3 407 1167 659 -3 407 830 1014 -3 408 469 680 -3 408 844 469 -3 408 1049 567 -3 408 680 1049 -3 409 482 729 -3 409 837 482 -3 410 757 470 -3 410 470 982 -3 410 607 757 -3 410 712 613 -3 410 982 712 -3 411 1027 660 -3 411 1028 1027 -3 412 673 428 -3 412 428 834 -3 412 834 448 -3 412 448 970 -3 413 1116 873 -3 414 575 1040 -3 416 494 790 -3 416 866 494 -3 416 617 678 -3 416 678 866 -3 417 468 644 -3 418 850 619 -3 418 1193 850 -3 418 949 1000 -3 418 1000 994 -3 420 1131 808 -3 420 808 1138 -3 420 1060 1131 -3 420 1138 1137 -3 421 600 648 -3 421 813 899 -3 422 731 606 -3 422 606 1101 -3 423 495 582 -3 423 671 495 -3 423 582 1197 -3 423 1197 1198 -3 424 766 494 -3 424 494 866 -3 425 548 614 -3 425 991 548 -3 425 1143 778 -3 427 797 457 -3 427 457 802 -3 427 657 506 -3 427 506 797 -3 428 598 1016 -3 428 1016 834 -3 429 443 597 -3 429 709 443 -3 429 500 709 -3 429 972 615 -3 430 763 689 -3 430 689 1180 -3 430 1180 696 -3 430 1149 763 -3 430 824 1149 -3 431 594 1149 -3 431 865 614 -3 431 824 865 -3 431 1149 824 -3 432 691 658 -3 432 658 1039 -3 432 753 691 -3 432 1039 744 -3 433 960 1030 -3 434 649 1102 -3 434 924 700 -3 434 1102 924 -3 435 823 536 -3 435 536 891 -3 435 650 823 -3 436 975 698 -3 436 741 975 -3 437 496 676 -3 437 725 496 -3 437 505 725 -3 437 1134 505 -3 437 676 1059 -3 437 1059 1134 -3 438 1007 822 -3 438 822 1170 -3 438 955 1008 -3 438 1008 1007 -3 439 482 619 -3 439 729 482 -3 439 619 978 -3 440 993 540 -3 440 585 993 -3 440 1088 585 -3 441 473 703 -3 441 934 473 -3 441 548 991 -3 442 877 560 -3 442 560 882 -3 442 772 892 -3 442 1075 772 -3 442 882 1006 -3 442 1006 1075 -3 443 833 989 -3 444 481 1169 -3 444 1019 567 -3 444 567 1049 -3 444 1049 680 -3 444 1169 1019 -3 445 467 1115 -3 445 497 849 -3 446 465 825 -3 446 748 628 -3 446 825 726 -3 446 726 1090 -3 446 1090 748 -3 447 796 910 -3 448 490 626 -3 448 626 970 -3 448 834 969 -3 449 760 481 -3 449 481 1046 -3 449 610 906 -3 449 906 760 -3 449 923 904 -3 449 1046 923 -3 450 697 620 -3 451 965 489 -3 451 749 539 -3 451 627 749 -3 452 746 528 -3 452 737 800 -3 452 1179 737 -3 453 498 1151 -3 454 1096 612 -3 455 792 624 -3 456 848 519 -3 456 519 876 -3 456 836 848 -3 457 665 484 -3 457 484 996 -3 457 996 802 -3 458 948 779 -3 459 471 758 -3 459 1189 471 -3 459 758 1022 -3 459 765 1153 -3 459 1153 1189 -3 461 1010 700 -3 461 935 1010 -3 462 602 541 -3 462 541 1129 -3 462 554 664 -3 462 664 602 -3 465 576 1009 -3 465 1009 825 -3 466 715 570 -3 467 783 1115 -3 467 925 805 -3 468 680 1142 -3 470 757 1073 -3 471 794 756 -3 471 918 794 -3 472 780 662 -3 472 1106 738 -3 473 570 754 -3 473 819 570 -3 473 754 703 -3 474 890 531 -3 476 596 661 -3 476 661 1183 -3 477 1090 726 -3 477 748 1090 -3 478 682 579 -3 478 579 707 -3 478 782 682 -3 479 740 510 -3 479 510 902 -3 480 565 878 -3 480 878 998 -3 481 735 1046 -3 482 1140 619 -3 482 884 1140 -3 484 1184 603 -3 484 665 1184 -3 484 724 996 -3 485 564 988 -3 485 988 907 -3 486 492 714 -3 486 714 514 -3 486 514 1159 -3 486 1159 591 -3 487 878 565 -3 487 751 768 -3 488 958 549 -3 489 965 1113 -3 490 554 626 -3 490 933 554 -3 492 520 987 -3 492 987 856 -3 493 542 941 -3 494 765 790 -3 495 671 990 -3 497 896 734 -3 499 1097 916 -3 500 1123 709 -3 500 1122 1071 -3 500 1071 1123 -3 502 1068 602 -3 503 879 688 -3 503 908 961 -3 505 706 1114 -3 507 605 727 -3 507 727 995 -3 508 683 1054 -3 508 862 924 -3 508 1054 862 -3 509 604 832 -3 509 882 604 -3 509 737 1006 -3 509 1006 882 -3 510 547 902 -3 511 681 816 -3 512 852 914 -3 512 914 954 -3 513 609 976 -3 514 624 1159 -3 515 762 520 -3 515 520 926 -3 515 1126 762 -3 516 866 678 -3 518 1079 656 -3 518 752 1079 -3 519 848 563 -3 520 762 987 -3 521 1156 531 -3 521 662 1053 -3 521 1053 1048 -3 523 648 600 -3 523 1070 648 -3 524 778 1143 -3 525 674 957 -3 525 957 992 -3 526 1125 555 -3 528 746 652 -3 529 853 558 -3 530 561 576 -3 531 1156 817 -3 532 538 677 -3 532 691 753 -3 535 688 879 -3 535 951 688 -3 535 1033 951 -3 537 704 841 -3 537 1050 704 -3 541 602 1093 -3 544 1190 717 -3 544 803 1190 -3 547 883 681 -3 549 958 815 -3 551 733 1038 -3 553 558 853 -3 553 853 1047 -3 553 1047 936 -3 554 933 664 -3 555 886 888 -3 555 1125 886 -3 556 805 777 -3 556 777 1132 -3 559 622 1065 -3 560 604 882 -3 560 1171 759 -3 560 877 1171 -3 561 1099 653 -3 562 1192 743 -3 562 1161 1192 -3 566 952 855 -3 569 887 625 -3 574 847 646 -3 577 806 999 -3 577 1194 931 -3 580 1058 712 -3 583 639 1072 -3 583 1138 808 -3 583 1137 1138 -3 585 1088 612 -3 585 612 1096 -3 585 997 993 -3 587 920 713 -3 588 596 1066 -3 588 601 1107 -3 589 898 977 -3 590 993 997 -3 591 1159 624 -3 593 608 1077 -3 594 763 1149 -3 595 1114 706 -3 596 616 1066 -3 600 1084 1158 -3 601 811 984 -3 601 984 1071 -3 601 1074 1107 -3 602 1068 1093 -3 603 931 1194 -3 607 859 757 -3 613 794 918 -3 614 865 1012 -3 621 995 727 -3 625 865 824 -3 627 892 772 -3 628 748 747 -3 628 959 1035 -3 639 955 1072 -3 640 943 771 -3 641 809 851 -3 650 1120 823 -3 655 862 1054 -3 659 1057 1094 -3 668 1029 728 -3 668 977 1029 -3 674 1091 938 -3 674 938 1148 -3 685 895 1141 -3 686 769 871 -3 693 705 1063 -3 702 998 878 -3 705 767 769 -3 708 772 1075 -3 724 1196 996 -3 762 856 987 -3 762 1126 894 -3 770 974 783 -3 783 974 872 -3 800 1198 1197 -3 810 946 1152 -3 810 1152 1105 -3 811 1105 1076 -3 908 1154 921 -3 1200 1206 1329 -3 1200 1378 1206 -3 1200 1295 1290 -3 1200 1290 1385 -3 1200 1307 1295 -3 1200 1329 1307 -3 1200 1310 1378 -3 1200 1385 1310 -3 9 1294 1210 -3 9 1210 673 -3 9 649 1294 -3 1201 1323 1206 -3 1201 1206 1373 -3 1201 1248 1323 -3 1201 1397 1248 -3 1201 1310 1326 -3 1201 1373 1310 -3 1201 1326 1398 -3 1201 1362 1397 -3 1201 1398 1362 -3 1202 1263 1260 -3 1202 1260 1276 -3 1202 1276 1359 -3 1202 1359 1321 -3 1203 1242 1267 -3 1203 1268 1242 -3 1203 1267 1367 -3 1203 1388 1268 -3 1203 1367 1394 -3 1203 1394 1388 -3 1204 1301 1246 -3 1204 1246 1340 -3 1204 1254 1255 -3 1204 1320 1254 -3 1204 1255 1354 -3 463 1301 1204 -3 463 1204 1354 -3 1204 1363 1320 -3 1204 1340 1363 -3 1205 1324 1225 -3 1205 1225 1396 -3 1205 1258 1238 -3 1205 1238 1324 -3 1205 1357 1258 -3 1205 1336 1357 -3 41 981 1291 -3 41 1291 1392 -3 41 1316 960 -3 41 1392 1316 -3 1206 1283 1368 -3 1206 1390 1283 -3 1206 1323 1390 -3 1206 1368 1329 -3 1206 1378 1373 -3 1207 1225 1272 -3 1207 1350 1225 -3 1207 1272 1304 -3 1207 1277 1350 -3 1207 1304 1365 -3 1208 1236 1280 -3 1208 1308 1236 -3 1208 1280 1311 -3 1208 1286 1308 -3 1208 1311 1286 -3 60 645 1233 -3 60 1233 789 -3 61 1232 1253 -3 61 378 1232 -3 61 1253 684 -3 1209 1219 1295 -3 1209 1388 1219 -3 1209 1342 1268 -3 1209 1268 1388 -3 1209 1307 1270 -3 1209 1270 1349 -3 1209 1295 1307 -3 1209 1349 1342 -3 1210 1315 1243 -3 1210 1243 1353 -3 428 673 1210 -3 428 1210 1353 -3 1210 1294 1315 -3 1211 1222 1379 -3 504 1305 1211 -3 504 1211 1379 -3 90 1297 141 -3 90 475 1297 -3 1212 1325 1216 -3 1212 1216 1328 -3 1212 1228 1241 -3 1212 1252 1228 -3 1212 1241 1325 -3 1212 1292 1252 -3 1212 1328 1292 -3 1213 1230 1299 -3 1213 1310 1240 -3 1213 1299 1262 -3 1213 1262 1326 -3 1213 1326 1310 -3 93 1251 1238 -3 93 1238 1339 -3 93 1293 1251 -3 93 340 1293 -3 93 1339 360 -3 1214 1278 1294 -3 1214 1313 1278 -3 649 1214 1294 -3 649 1351 1214 -3 1214 1351 1313 -3 1215 1270 1307 -3 1215 1309 1270 -3 1215 1283 1334 -3 1215 1368 1283 -3 1215 1307 1329 -3 1215 1334 1309 -3 1215 1329 1368 -3 1216 1220 1337 -3 1216 1393 1220 -3 1216 1256 1285 -3 1216 1325 1256 -3 1216 1285 1393 -3 1216 1337 1328 -3 1217 1237 1355 -3 1217 1261 1298 -3 1217 1355 1261 -3 1217 1383 1289 -3 1217 1298 1331 -3 1217 1331 1383 -3 1218 1279 1233 -3 1218 1233 1395 -3 1218 1395 1287 -3 130 1267 1242 -3 130 1242 711 -3 130 1303 1267 -3 1219 1389 1295 -3 1219 1366 1338 -3 1219 1338 1389 -3 1219 1361 1366 -3 1219 1367 1361 -3 1219 1394 1367 -3 1219 1388 1394 -3 141 1358 340 -3 141 1297 1358 -3 143 1234 1306 -3 143 684 1234 -3 143 1306 322 -3 1220 1356 1283 -3 1220 1283 1390 -3 1220 1323 1352 -3 1220 1390 1323 -3 1220 1352 1337 -3 1220 1360 1356 -3 1220 1393 1360 -3 1221 1244 1229 -3 1221 1229 1288 -3 172 1377 1222 -3 184 1222 1377 -3 184 1379 1222 -3 1223 1304 1231 -3 1223 1231 1347 -3 1223 1365 1304 -3 1223 1347 1330 -3 1223 1330 1376 -3 1224 1313 1351 -3 1224 1364 1317 -3 1224 1351 1364 -3 159 1266 1246 -3 159 1246 488 -3 159 1296 1266 -3 159 829 1296 -3 1225 1251 1272 -3 1225 1324 1251 -3 1226 1280 1237 -3 1226 1311 1280 -3 1226 1333 1311 -3 172 586 1377 -3 1227 1315 1278 -3 1227 1346 1315 -3 1228 1252 1335 -3 1229 1244 1345 -3 1229 1285 1370 -3 1229 1386 1285 -3 1229 1370 1288 -3 1229 1345 1386 -3 1230 1275 1382 -3 1230 1382 1299 -3 184 504 1379 -3 184 1377 586 -3 1231 1239 1297 -3 1231 1304 1239 -3 1231 1297 1347 -3 1232 1327 1253 -3 378 1344 1232 -3 1232 1260 1327 -3 1232 1344 1260 -3 1233 1374 1264 -3 1233 1264 1395 -3 789 1233 1279 -3 645 1374 1233 -3 1234 1302 1235 -3 1234 1235 1306 -3 684 1253 1234 -3 1234 1253 1322 -3 322 1235 645 -3 322 1306 1235 -3 1235 1302 1264 -3 1235 1264 1374 -3 645 1235 1374 -3 1236 1261 1280 -3 1236 1312 1261 -3 1236 1282 1312 -3 1236 1387 1282 -3 1236 1308 1300 -3 1236 1300 1387 -3 1237 1280 1355 -3 1238 1251 1324 -3 1238 1258 1339 -3 1239 1272 1293 -3 1239 1304 1272 -3 1239 1293 1358 -3 1239 1358 1297 -3 1240 1290 1314 -3 1240 1385 1290 -3 1240 1310 1385 -3 1241 1256 1325 -3 1242 1268 1291 -3 711 1242 1291 -3 1243 1276 1353 -3 1243 1359 1276 -3 1243 1315 1346 -3 1243 1346 1321 -3 1243 1321 1359 -3 1244 1332 1271 -3 1244 1271 1345 -3 1244 1376 1332 -3 434 1245 649 -3 434 700 1245 -3 649 1245 1351 -3 700 1010 1245 -3 935 1364 1245 -3 935 1245 1010 -3 1245 1364 1351 -3 1246 1266 1281 -3 488 1246 1301 -3 1246 1281 1340 -3 1247 1265 1274 -3 1247 1318 1265 -3 1247 1271 1318 -3 1247 1345 1271 -3 1247 1274 1356 -3 1247 1360 1285 -3 1247 1285 1386 -3 1247 1386 1345 -3 1247 1356 1360 -3 1248 1269 1292 -3 1248 1397 1269 -3 1248 1292 1328 -3 1248 1352 1323 -3 1248 1328 1337 -3 1248 1337 1352 -3 1249 1281 1266 -3 1249 1266 1343 -3 1249 1348 1281 -3 1249 1309 1334 -3 1249 1343 1309 -3 1249 1334 1348 -3 1250 1309 1296 -3 1250 1296 1316 -3 1250 1349 1309 -3 1250 1316 1342 -3 1250 1342 1349 -3 1251 1293 1272 -3 1252 1292 1269 -3 1252 1269 1371 -3 1252 1371 1300 -3 1252 1300 1372 -3 1252 1372 1335 -3 1253 1327 1284 -3 1253 1284 1375 -3 1253 1375 1322 -3 333 1354 1255 -3 333 1255 1380 -3 333 463 1354 -3 333 1380 475 -3 334 1341 405 -3 334 789 1391 -3 334 1391 1341 -3 1254 1330 1255 -3 1254 1320 1271 -3 1254 1271 1332 -3 1254 1332 1330 -3 340 1358 1293 -3 1255 1330 1347 -3 1255 1347 1380 -3 1256 1370 1285 -3 1256 1288 1370 -3 1257 1275 1319 -3 1257 1382 1275 -3 1257 1319 1289 -3 1257 1289 1383 -3 1257 1331 1299 -3 1257 1299 1382 -3 1257 1383 1331 -3 360 1339 915 -3 1258 1357 1317 -3 1258 1317 1364 -3 915 1339 1258 -3 915 1258 935 -3 935 1258 1364 -3 1259 1300 1308 -3 1259 1372 1300 -3 1259 1335 1372 -3 378 598 1344 -3 1260 1263 1327 -3 598 1276 1260 -3 598 1260 1344 -3 1261 1355 1280 -3 1261 1312 1298 -3 1262 1312 1282 -3 1262 1282 1362 -3 1262 1298 1312 -3 1262 1381 1298 -3 1262 1299 1381 -3 1262 1398 1326 -3 1262 1362 1398 -3 1263 1284 1327 -3 1264 1302 1287 -3 1264 1287 1395 -3 405 1305 504 -3 405 1341 1305 -3 1265 1348 1274 -3 1265 1318 1363 -3 1265 1363 1340 -3 1265 1340 1369 -3 1265 1369 1348 -3 1266 1296 1343 -3 428 1276 598 -3 428 1353 1276 -3 433 1296 829 -3 433 1030 1296 -3 1267 1303 1273 -3 1267 1273 1361 -3 1267 1361 1367 -3 1268 1392 1291 -3 1268 1342 1316 -3 1268 1316 1392 -3 1269 1362 1282 -3 1269 1282 1371 -3 1269 1397 1362 -3 1270 1309 1349 -3 1271 1320 1318 -3 463 1175 1301 -3 475 1347 1297 -3 475 1380 1347 -3 488 1301 1175 -3 1274 1334 1283 -3 1274 1283 1356 -3 1274 1348 1334 -3 1278 1315 1294 -3 1279 1305 1341 -3 1279 1384 1305 -3 789 1279 1391 -3 1279 1341 1391 -3 1281 1369 1340 -3 1281 1348 1369 -3 1282 1387 1371 -3 1285 1360 1393 -3 1286 1311 1333 -3 1290 1295 1389 -3 1290 1338 1314 -3 1290 1389 1338 -3 711 1291 981 -3 1296 1309 1343 -3 1030 1316 1296 -3 1298 1381 1331 -3 1299 1331 1381 -3 1300 1371 1387 -3 1310 1373 1378 -3 960 1316 1030 -3 1317 1357 1336 -3 1318 1320 1363 -3 1330 1332 1376 -3 1213 1240 1401 -3 130 1399 1303 -3 130 944 1399 -3 1240 1314 1401 -3 1314 1338 1400 -3 1338 1366 1400 -3 1361 1402 1400 -3 1361 1400 1366 -3 1273 1402 1361 -3 1230 1401 1403 -3 1230 1403 1419 -3 1400 1407 1403 -3 1403 1407 1413 -3 1314 1400 1403 -3 1314 1403 1401 -3 1403 1413 1419 -3 78 692 1399 -3 78 1399 944 -3 1213 1401 1230 -3 1404 1411 1408 -3 1404 1408 1422 -3 1404 1422 1410 -3 1404 1418 1411 -3 1404 1417 1412 -3 1404 1412 1418 -3 1230 1409 1275 -3 1230 1419 1409 -3 404 1405 1416 -3 404 1168 1405 -3 692 1408 1399 -3 1399 1408 1420 -3 1303 1399 1420 -3 1400 1406 1407 -3 1406 1412 1407 -3 1400 1402 1406 -3 1273 1411 1406 -3 1273 1406 1402 -3 1406 1411 1418 -3 1406 1418 1412 -3 1407 1412 1415 -3 1407 1415 1413 -3 1408 1411 1414 -3 692 1423 1408 -3 1408 1414 1420 -3 1408 1416 1422 -3 1408 1423 1416 -3 404 1423 692 -3 404 1416 1423 -3 1273 1414 1411 -3 1273 1303 1414 -3 1409 1419 1413 -3 1410 1422 1416 -3 1303 1420 1414 -3 1412 1424 1415 -3 1412 1417 1424 -3 900 1426 1425 -3 864 900 1425 -3 864 1425 1168 -3 209 1426 900 -3 209 900 1037 -3 406 1037 900 -3 1405 1425 1428 -3 1168 1425 1405 -3 1425 1427 1428 -3 1425 1426 1427 -3 1427 1429 1428 -3 62 313 1430 -3 62 1430 1444 -3 313 937 1430 -3 1430 1437 1443 -3 937 1437 1430 -3 1430 1443 1451 -3 1430 1451 1444 -3 34 1434 1432 -3 34 1432 517 -3 34 951 1434 -3 62 1444 1434 -3 62 1434 1033 -3 209 1431 1426 -3 209 1448 1431 -3 1431 1448 1435 -3 84 1437 937 -3 84 1450 1437 -3 84 694 1447 -3 84 1447 1441 -3 84 1441 1450 -3 146 239 632 -3 146 632 1452 -3 146 1452 1440 -3 202 1433 1063 -3 202 1449 1433 -3 207 1446 389 -3 207 1188 1446 -3 209 389 1448 -3 264 1447 694 -3 264 1111 1447 -3 517 1432 1442 -3 1433 1439 1436 -3 1433 1436 1440 -3 632 693 1433 -3 632 1433 1440 -3 1433 1449 1439 -3 693 1063 1433 -3 389 1446 1435 -3 389 1435 1448 -3 951 1033 1434 -3 1436 1439 1438 -3 1436 1438 1453 -3 1436 1445 1440 -3 1436 1441 1445 -3 517 1442 1188 -3 632 1440 1452 -3 1441 1447 1445 -3 1188 1442 1446 -3 1431 1435 1454 -3 1427 1431 1454 -3 1426 1431 1427 -3 1405 1428 1455 -3 1405 1455 1421 -3 1429 1456 1455 -3 1428 1429 1455 -3 1427 1456 1429 -3 1427 1454 1457 -3 1427 1457 1456 -3 413 873 415 -3 1202 1470 1263 -3 1202 1477 1470 -3 1202 1321 1479 -3 1202 1479 1477 -3 1205 1465 1336 -3 1205 1396 1465 -3 1458 1464 1477 -3 1458 1481 1464 -3 1458 1477 1479 -3 1234 1459 1302 -3 1234 1322 1459 -3 1322 1468 1459 -3 1459 1468 1485 -3 1460 1478 1471 -3 1460 1471 1480 -3 1460 1472 1474 -3 1460 1475 1472 -3 1460 1474 1478 -3 1227 1461 1346 -3 1321 1461 1479 -3 1321 1346 1461 -3 1462 1468 1484 -3 1462 1485 1468 -3 1462 1476 1471 -3 1462 1471 1478 -3 1462 1478 1474 -3 1462 1484 1476 -3 1218 1287 1463 -3 1218 1463 1483 -3 1224 1317 1466 -3 1224 1466 1482 -3 1224 1473 1467 -3 1224 1467 1313 -3 1224 1482 1473 -3 1227 1278 1467 -3 1287 1302 1463 -3 1464 1469 1471 -3 1464 1481 1469 -3 1464 1476 1470 -3 1464 1470 1477 -3 1464 1471 1476 -3 1336 1465 1466 -3 1317 1336 1466 -3 1263 1470 1284 -3 1278 1313 1467 -3 1284 1484 1468 -3 1284 1468 1375 -3 1322 1375 1468 -3 1469 1480 1471 -3 1284 1470 1476 -3 1284 1476 1484 -3 1228 1486 1504 -3 1228 1335 1486 -3 1486 1494 1504 -3 1486 1514 1494 -3 1486 1495 1514 -3 1207 1491 1277 -3 1207 1508 1491 -3 1207 1365 1508 -3 1221 1500 1244 -3 1221 1288 1499 -3 1221 1499 1500 -3 1241 1487 1256 -3 1241 1504 1487 -3 1256 1487 1288 -3 1487 1494 1497 -3 1487 1504 1494 -3 1487 1497 1513 -3 1288 1487 1499 -3 1487 1513 1499 -3 1223 1244 1500 -3 1223 1376 1244 -3 1223 1500 1508 -3 1223 1508 1365 -3 1488 1498 1495 -3 1225 1350 1501 -3 1228 1504 1241 -3 1489 1497 1493 -3 1489 1493 1506 -3 1489 1513 1497 -3 1489 1506 1499 -3 1489 1499 1513 -3 1490 1502 1497 -3 1490 1497 1509 -3 1490 1510 1502 -3 1490 1509 1505 -3 1490 1505 1510 -3 1491 1506 1496 -3 1491 1496 1511 -3 1277 1491 1511 -3 1491 1508 1500 -3 1491 1500 1512 -3 1491 1512 1506 -3 1492 1501 1496 -3 1492 1496 1503 -3 1493 1497 1502 -3 1493 1502 1507 -3 1493 1503 1506 -3 1493 1507 1503 -3 1494 1509 1497 -3 1494 1505 1509 -3 1494 1514 1505 -3 1495 1498 1505 -3 1495 1505 1514 -3 1496 1501 1511 -3 1496 1506 1503 -3 1277 1501 1350 -3 1277 1511 1501 -3 1499 1512 1500 -3 1499 1506 1512 -3 1515 1523 1517 -3 1515 1517 1531 -3 1492 1503 1515 -3 1492 1515 1531 -3 1515 1530 1523 -3 1502 1530 1515 -3 1502 1515 1507 -3 1503 1507 1515 -3 1458 1461 1521 -3 1458 1479 1461 -3 1458 1521 1528 -3 1458 1528 1481 -3 1460 1526 1475 -3 1460 1480 1526 -3 1227 1533 1461 -3 1461 1533 1521 -3 1516 1523 1525 -3 1516 1529 1523 -3 1516 1524 1529 -3 1516 1542 1524 -3 1516 1525 1532 -3 1516 1532 1527 -3 1516 1527 1543 -3 1516 1539 1542 -3 1516 1543 1539 -3 1517 1523 1529 -3 1517 1529 1534 -3 1517 1534 1531 -3 1488 1520 1498 -3 1518 1528 1521 -3 1518 1521 1538 -3 1518 1538 1527 -3 1225 1501 1536 -3 1225 1536 1396 -3 1227 1467 1533 -3 1467 1519 1533 -3 1467 1539 1519 -3 1519 1521 1533 -3 1519 1538 1521 -3 1519 1527 1538 -3 1519 1543 1527 -3 1519 1539 1543 -3 1498 1520 1505 -3 1505 1520 1510 -3 1510 1520 1537 -3 1465 1534 1466 -3 1465 1541 1534 -3 1465 1536 1541 -3 1396 1536 1465 -3 1466 1524 1482 -3 1466 1540 1524 -3 1466 1534 1540 -3 1492 1536 1501 -3 1492 1531 1536 -3 1467 1473 1539 -3 1502 1522 1530 -3 1502 1537 1522 -3 1469 1526 1480 -3 1469 1535 1526 -3 1469 1481 1528 -3 1469 1528 1535 -3 1524 1540 1529 -3 1473 1482 1524 -3 1473 1524 1542 -3 1529 1540 1534 -3 1473 1542 1539 -3 1502 1510 1537 -3 1531 1534 1541 -3 1531 1541 1536 -3 1544 1545 1561 -3 1544 1566 1545 -3 1518 1527 1544 -3 1518 1544 1564 -3 1525 1544 1532 -3 1525 1557 1544 -3 1527 1532 1544 -3 1544 1557 1566 -3 1544 1561 1564 -3 1545 1550 1562 -3 1545 1566 1560 -3 1545 1562 1561 -3 1518 1546 1528 -3 1518 1564 1546 -3 1546 1550 1559 -3 1546 1562 1550 -3 1526 1535 1546 -3 1526 1546 1565 -3 1528 1546 1535 -3 1546 1559 1565 -3 1546 1561 1562 -3 1546 1564 1561 -3 1547 1552 1556 -3 1547 1556 1554 -3 1520 1555 1548 -3 1520 1548 1537 -3 1525 1553 1548 -3 1525 1548 1557 -3 1548 1553 1563 -3 1548 1555 1560 -3 1548 1560 1557 -3 1537 1548 1563 -3 1475 1549 1552 -3 1549 1556 1552 -3 1475 1526 1549 -3 1526 1565 1549 -3 1549 1558 1556 -3 1549 1559 1558 -3 1549 1565 1559 -3 1550 1551 1558 -3 1550 1558 1559 -3 1551 1554 1556 -3 1551 1556 1558 -3 1522 1553 1523 -3 1522 1523 1530 -3 1522 1563 1553 -3 1522 1537 1563 -3 1523 1553 1525 -3 1472 1475 1552 -3 1557 1560 1566 -3 1486 1583 1495 -3 1335 1580 1486 -3 1486 1580 1584 -3 1486 1584 1583 -3 1567 1575 1568 -3 1567 1568 1588 -3 1567 1570 1578 -3 1567 1588 1570 -3 1567 1572 1575 -3 1488 1577 1572 -3 1488 1495 1577 -3 1568 1575 1569 -3 1568 1569 1579 -3 1568 1579 1573 -3 1568 1573 1581 -3 1568 1581 1576 -3 1568 1576 1588 -3 1569 1575 1583 -3 1569 1586 1579 -3 1569 1584 1580 -3 1569 1580 1586 -3 1569 1583 1584 -3 1570 1574 1578 -3 1570 1576 1585 -3 1570 1588 1576 -3 1333 1571 1582 -3 1571 1576 1581 -3 1571 1585 1576 -3 1571 1581 1582 -3 1572 1577 1575 -3 1259 1308 1573 -3 1259 1573 1579 -3 1286 1573 1308 -3 1286 1582 1573 -3 1573 1582 1581 -3 1259 1580 1335 -3 1259 1579 1586 -3 1259 1586 1580 -3 1495 1587 1577 -3 1495 1583 1587 -3 1286 1333 1582 -3 1575 1577 1587 -3 1575 1587 1583 -3 1567 1590 1572 -3 1567 1578 1590 -3 1488 1589 1520 -3 1488 1572 1591 -3 1488 1591 1589 -3 1574 1590 1578 -3 1574 1592 1590 -3 1545 1601 1550 -3 1545 1600 1603 -3 1545 1560 1600 -3 1545 1603 1601 -3 1593 1599 1595 -3 1593 1606 1599 -3 1554 1593 1604 -3 1554 1606 1593 -3 1594 1596 1597 -3 1594 1598 1596 -3 1594 1597 1605 -3 1594 1600 1598 -3 1594 1603 1600 -3 1594 1601 1603 -3 1594 1605 1601 -3 1574 1595 1592 -3 1595 1599 1597 -3 1592 1595 1597 -3 1572 1596 1598 -3 1572 1602 1596 -3 1596 1602 1597 -3 1520 1589 1555 -3 1550 1601 1551 -3 1551 1601 1599 -3 1551 1599 1606 -3 1551 1606 1554 -3 1572 1598 1591 -3 1572 1590 1602 -3 1597 1599 1605 -3 1590 1597 1602 -3 1590 1592 1597 -3 1589 1598 1600 -3 1589 1591 1598 -3 1555 1589 1600 -3 1599 1601 1605 -3 1555 1600 1560 -3 20 279 1613 -3 20 1613 460 -3 37 371 1610 -3 37 1610 672 -3 1607 1608 1621 -3 1607 1632 1608 -3 1607 1621 1611 -3 1607 1611 1630 -3 1607 1630 1619 -3 154 415 1629 -3 154 1629 571 -3 1608 1609 1610 -3 1608 1625 1609 -3 1608 1610 1621 -3 1608 1620 1625 -3 1608 1632 1620 -3 172 1623 1195 -3 202 686 1633 -3 672 1610 1609 -3 672 1609 1618 -3 1609 1631 1618 -3 1609 1625 1622 -3 1609 1622 1631 -3 371 1621 1610 -3 279 1628 1613 -3 279 1623 1628 -3 279 1195 1623 -3 290 1618 1616 -3 290 1616 686 -3 290 672 1618 -3 371 571 1621 -3 571 1611 1621 -3 571 1624 1611 -3 415 1624 1629 -3 1612 1613 1628 -3 1612 1628 1623 -3 1614 1615 1616 -3 1614 1617 1615 -3 1614 1616 1618 -3 1614 1627 1617 -3 1614 1618 1631 -3 1614 1622 1627 -3 1614 1631 1622 -3 460 1635 873 -3 1615 1634 1616 -3 1615 1626 1634 -3 686 1616 1633 -3 571 1629 1624 -3 1620 1622 1625 -3 1619 1630 1636 -3 1211 1639 1637 -3 1211 1637 1222 -3 1222 1637 1655 -3 1617 1638 1649 -3 1617 1627 1638 -3 1620 1638 1622 -3 1622 1638 1627 -3 1211 1305 1639 -3 1305 1384 1639 -3 1384 1650 1639 -3 1217 1641 1237 -3 1218 1650 1279 -3 1617 1640 1645 -3 1640 1654 1645 -3 1617 1649 1640 -3 172 1222 1648 -3 1222 1655 1648 -3 1226 1237 1644 -3 1226 1644 1652 -3 172 1648 1623 -3 1237 1641 1651 -3 1641 1643 1651 -3 1237 1651 1644 -3 1275 1642 1319 -3 1289 1319 1642 -3 1643 1644 1651 -3 1643 1653 1644 -3 1644 1647 1652 -3 1644 1653 1647 -3 1615 1617 1645 -3 1615 1645 1626 -3 1279 1650 1384 -3 1409 1657 1656 -3 1275 1656 1646 -3 1275 1409 1656 -3 1409 1413 1657 -3 1413 1415 1657 -3 1415 1658 1657 -3 1405 1410 1416 -3 1405 1421 1410 -3 1217 1659 1641 -3 1217 1289 1659 -3 1641 1659 1643 -3 1289 1642 1659 -3 1642 1661 1659 -3 1643 1659 1662 -3 1659 1661 1662 -3 1642 1660 1661 -3 1438 1663 1664 -3 1663 1667 1664 -3 1626 1665 1663 -3 1663 1665 1667 -3 1616 1663 1666 -3 1616 1634 1663 -3 1438 1439 1663 -3 1439 1666 1663 -3 1626 1663 1634 -3 202 1633 1666 -3 202 1666 1449 -3 1616 1666 1633 -3 1439 1449 1666 -3 1668 1669 1672 -3 1668 1676 1669 -3 1668 1672 1670 -3 1668 1677 1676 -3 1645 1669 1676 -3 1645 1654 1669 -3 1669 1674 1672 -3 1654 1674 1669 -3 1664 1667 1673 -3 1660 1678 1661 -3 1643 1662 1671 -3 1645 1676 1665 -3 1626 1645 1665 -3 1670 1672 1674 -3 1670 1674 1675 -3 1665 1676 1673 -3 1665 1673 1667 -3 1661 1671 1662 -3 1673 1676 1677 -3 1275 1646 1642 -3 1404 1410 1680 -3 1404 1680 1417 -3 1417 1680 1681 -3 1410 1421 1680 -3 1656 1657 1682 -3 1415 1681 1658 -3 1415 1424 1681 -3 1417 1681 1424 -3 1660 1685 1683 -3 1683 1685 1684 -3 1642 1685 1660 -3 1642 1646 1685 -3 1646 1684 1685 -3 1455 1456 1680 -3 1421 1455 1680 -3 1680 1687 1681 -3 1680 1690 1687 -3 1456 1690 1680 -3 1657 1658 1686 -3 1657 1686 1682 -3 1681 1691 1686 -3 1658 1681 1686 -3 1686 1688 1689 -3 1686 1691 1688 -3 1686 1689 1693 -3 1682 1686 1693 -3 1646 1656 1684 -3 1656 1682 1684 -3 1683 1689 1688 -3 1683 1684 1689 -3 1681 1687 1691 -3 1687 1692 1691 -3 1688 1691 1692 -3 1684 1693 1689 -3 1682 1693 1684 -3 1660 1683 1697 -3 1683 1696 1697 -3 1694 1699 1701 -3 1694 1702 1699 -3 1694 1701 1695 -3 1694 1696 1702 -3 1687 1698 1703 -3 1687 1690 1698 -3 1457 1700 1698 -3 1698 1700 1703 -3 1456 1457 1698 -3 1456 1698 1690 -3 1683 1688 1702 -3 1683 1702 1696 -3 1687 1703 1692 -3 1688 1699 1702 -3 1688 1703 1699 -3 1699 1703 1705 -3 1699 1705 1704 -3 1454 1700 1457 -3 1454 1706 1700 -3 1700 1705 1703 -3 1700 1704 1705 -3 1688 1692 1703 -3 1707 1715 1708 -3 1707 1708 1718 -3 1611 1715 1707 -3 1611 1707 1630 -3 1707 1718 1712 -3 1708 1713 1709 -3 1708 1717 1713 -3 1708 1715 1716 -3 1708 1716 1717 -3 1611 1624 1715 -3 415 1711 1624 -3 415 873 1711 -3 1612 1709 1713 -3 1612 1714 1709 -3 1612 1713 1613 -3 1612 1623 1714 -3 460 1613 1710 -3 1613 1713 1710 -3 460 1710 1635 -3 1710 1716 1711 -3 1635 1710 1711 -3 1710 1713 1717 -3 1710 1717 1716 -3 1624 1711 1715 -3 873 1635 1711 -3 1711 1716 1715 -3 1719 1721 1735 -3 1719 1746 1721 -3 1719 1735 1739 -3 1719 1739 1736 -3 1719 1736 1754 -3 1719 1754 1746 -3 1720 1723 1740 -3 1720 1744 1723 -3 1472 1720 1740 -3 1636 1707 1712 -3 1630 1707 1636 -3 1637 1639 1736 -3 1637 1753 1728 -3 1637 1728 1655 -3 1637 1736 1753 -3 1302 1459 1725 -3 1459 1485 1725 -3 1721 1743 1735 -3 1721 1746 1750 -3 1708 1709 1722 -3 1708 1722 1718 -3 1709 1752 1722 -3 1712 1722 1745 -3 1712 1718 1722 -3 1722 1752 1738 -3 1639 1724 1736 -3 1639 1650 1724 -3 1723 1732 1741 -3 1723 1749 1732 -3 1723 1741 1740 -3 1723 1756 1749 -3 1462 1474 1725 -3 1462 1725 1485 -3 1218 1733 1747 -3 1218 1483 1733 -3 1218 1747 1650 -3 1724 1742 1726 -3 1724 1726 1754 -3 1724 1733 1742 -3 1724 1747 1733 -3 1724 1754 1736 -3 1650 1747 1724 -3 1302 1725 1751 -3 1474 1740 1725 -3 1725 1740 1741 -3 1725 1741 1751 -3 1463 1741 1732 -3 1463 1732 1483 -3 1302 1751 1463 -3 1463 1751 1741 -3 1726 1730 1755 -3 1726 1757 1730 -3 1726 1742 1757 -3 1726 1746 1754 -3 1726 1755 1746 -3 1727 1738 1729 -3 1727 1729 1743 -3 1728 1731 1734 -3 1728 1739 1731 -3 1648 1728 1734 -3 1648 1655 1728 -3 1728 1753 1739 -3 1709 1714 1737 -3 1709 1737 1752 -3 1729 1737 1731 -3 1729 1731 1748 -3 1729 1735 1743 -3 1729 1748 1735 -3 1729 1738 1737 -3 1730 1732 1749 -3 1730 1757 1732 -3 1714 1734 1731 -3 1714 1731 1737 -3 1731 1739 1748 -3 1732 1742 1733 -3 1483 1732 1733 -3 1732 1757 1742 -3 1623 1648 1734 -3 1623 1734 1714 -3 1472 1740 1474 -3 1735 1748 1739 -3 1736 1739 1753 -3 1737 1738 1752 -3 1721 1763 1761 -3 1721 1761 1743 -3 1721 1767 1763 -3 1721 1750 1767 -3 1722 1738 1768 -3 1722 1768 1745 -3 1730 1758 1762 -3 1730 1749 1758 -3 1758 1769 1762 -3 1758 1766 1769 -3 1749 1756 1758 -3 1759 1764 1760 -3 1759 1763 1764 -3 1759 1765 1763 -3 1760 1764 1766 -3 1727 1743 1761 -3 1727 1768 1738 -3 1761 1763 1765 -3 1730 1762 1755 -3 1762 1764 1767 -3 1762 1769 1764 -3 1750 1762 1767 -3 1746 1762 1750 -3 1746 1755 1762 -3 1763 1767 1764 -3 1764 1769 1766 -3 1723 1744 1756 -3 1472 1772 1720 -3 1720 1772 1744 -3 1758 1772 1773 -3 1744 1772 1758 -3 1758 1773 1766 -3 1744 1758 1756 -3 1547 1770 1773 -3 1547 1554 1770 -3 1547 1772 1552 -3 1547 1773 1772 -3 1770 1771 1773 -3 1760 1766 1771 -3 1472 1552 1772 -3 1766 1773 1771 -3 1774 1777 1775 -3 1774 1775 1779 -3 1775 1776 1779 -3 1780 1783 1784 -3 1781 1784 1782 -3 1782 1784 1783 -3 1785 1788 1787 -3 1785 1787 1790 -3 1570 1785 1789 -3 1570 1585 1785 -3 1571 1788 1785 -3 1571 1785 1585 -3 1785 1790 1789 -3 1774 1786 1791 -3 1574 1792 1786 -3 1786 1792 1791 -3 1226 1788 1333 -3 1226 1652 1788 -3 1774 1791 1789 -3 1774 1789 1777 -3 1652 1787 1788 -3 1647 1787 1652 -3 1647 1778 1787 -3 1570 1789 1792 -3 1570 1792 1574 -3 1333 1788 1571 -3 1777 1789 1790 -3 1789 1791 1792 -3 1775 1777 1790 -3 1774 1779 1786 -3 1779 1793 1786 -3 1593 1595 1794 -3 1593 1794 1783 -3 1593 1783 1795 -3 1593 1795 1604 -3 1574 1786 1595 -3 1595 1786 1796 -3 1786 1793 1796 -3 1760 1771 1780 -3 1771 1783 1780 -3 1595 1796 1794 -3 1782 1783 1794 -3 1782 1794 1793 -3 1793 1794 1796 -3 1770 1795 1771 -3 1604 1795 1770 -3 1554 1604 1770 -3 1771 1795 1783 -3 1435 1446 1797 -3 1442 1797 1446 -3 1436 1798 1441 -3 1436 1453 1798 -3 1437 1450 1798 -3 1441 1798 1450 -3 1438 1799 1453 -3 1454 1797 1801 -3 1797 1805 1801 -3 1435 1797 1454 -3 1442 1805 1797 -3 1800 1804 1802 -3 1800 1803 1804 -3 1432 1434 1803 -3 1432 1803 1805 -3 1432 1805 1442 -3 1437 1798 1802 -3 1437 1802 1443 -3 1443 1802 1804 -3 1434 1804 1803 -3 1434 1444 1804 -3 1443 1804 1451 -3 1444 1451 1804 -3 1453 1799 1798 -3 1798 1799 1806 -3 1800 1802 1806 -3 1800 1807 1803 -3 1798 1806 1802 -3 1801 1805 1807 -3 1803 1807 1805 -3 1438 1664 1799 -3 1668 1808 1677 -3 1664 1808 1799 -3 1664 1673 1808 -3 1673 1677 1808 -3 1668 1812 1808 -3 1668 1670 1813 -3 1668 1813 1812 -3 1670 1810 1809 -3 1670 1809 1813 -3 1809 1812 1813 -3 1799 1808 1811 -3 1799 1811 1806 -3 1670 1675 1810 -3 1679 1695 1810 -3 1809 1816 1814 -3 1809 1814 1812 -3 1808 1814 1811 -3 1808 1812 1814 -3 1814 1816 1819 -3 1811 1814 1818 -3 1814 1819 1818 -3 1700 1817 1815 -3 1700 1815 1704 -3 1815 1819 1816 -3 1815 1816 1820 -3 1815 1817 1819 -3 1704 1815 1820 -3 1701 1809 1810 -3 1701 1821 1809 -3 1809 1821 1816 -3 1800 1806 1818 -3 1800 1819 1807 -3 1800 1818 1819 -3 1806 1811 1818 -3 1454 1801 1706 -3 1801 1807 1817 -3 1706 1801 1817 -3 1699 1820 1701 -3 1699 1704 1820 -3 1700 1706 1817 -3 1807 1819 1817 -3 1695 1701 1810 -3 1701 1820 1821 -3 1816 1821 1820 -3 146 1440 1445 -3 146 1445 1447 -3 146 1447 1111 -3 1638 1824 1649 -3 1640 1825 1654 -3 1636 1827 1826 -3 1745 1768 1828 -3 1768 1833 1828 -3 1759 1832 1765 -3 1727 1761 1830 -3 1727 1830 1768 -3 1761 1829 1830 -3 1761 1765 1829 -3 1829 1831 1830 -3 1765 1834 1829 -3 1768 1830 1833 -3 1830 1831 1833 -3 1765 1832 1834 -3 1759 1760 1780 -3 1759 1780 1837 -3 1759 1837 1832 -3 1780 1784 1837 -3 1829 1835 1838 -3 1829 1834 1835 -3 1835 1837 1836 -3 1832 1837 1835 -3 1832 1835 1834 -3 1784 1836 1837 -3 1619 1636 1826 -3 1620 1823 1638 -3 1607 1619 1822 -3 1607 1822 1632 -3 1632 1822 1823 -3 1620 1632 1823 -3 1636 1712 1827 -3 1712 1828 1827 -3 1712 1745 1828 -3 1781 1782 1839 -3 1779 1839 1793 -3 1782 1793 1839 -3 1829 1842 1831 -3 1831 1842 1840 -3 1827 1828 1841 -3 1828 1840 1841 -3 1828 1831 1840 -3 1828 1833 1831 -3 1829 1838 1842 -3 1838 1845 1842 -3 1842 1845 1844 -3 1781 1843 1836 -3 1835 1836 1843 -3 1835 1843 1838 -3 1838 1843 1845 -3 1843 1844 1845 -3 1781 1836 1784 -3 1643 1846 1653 -3 1647 1653 1846 -3 1661 1847 1671 -3 1661 1678 1847 -3 1660 1697 1848 -3 1776 1839 1779 -3 1787 1849 1790 -3 1778 1849 1787 -3 1775 1790 1849 -3 1638 1823 1855 -3 1638 1855 1824 -3 1643 1854 1846 -3 1640 1649 1850 -3 1640 1850 1825 -3 1822 1857 1823 -3 1822 1851 1856 -3 1822 1856 1857 -3 1824 1853 1850 -3 1649 1824 1850 -3 1823 1857 1855 -3 1654 1825 1852 -3 1824 1855 1853 -3 1675 1860 1858 -3 1671 1847 1854 -3 1678 1861 1847 -3 1660 1861 1678 -3 1660 1848 1861 -3 1643 1671 1854 -3 1674 1852 1860 -3 1654 1852 1674 -3 1674 1860 1675 -3 1694 1695 1859 -3 1694 1859 1696 -3 1679 1859 1695 -3 1696 1859 1697 -3 1697 1859 1848 -3 1679 1858 1859 -3 1675 1858 1810 -3 1679 1810 1858 -3 1619 1851 1822 -3 1619 1826 1851 -3 1827 1841 1862 -3 1840 1862 1841 -3 1839 1864 1843 -3 1843 1864 1863 -3 1843 1863 1844 -3 1844 1863 1865 -3 1840 1865 1862 -3 1840 1842 1865 -3 1842 1844 1865 -3 1781 1839 1843 -3 1866 1870 1867 -3 1866 1867 1873 -3 1866 1882 1870 -3 1647 1846 1872 -3 1846 1884 1872 -3 1846 1854 1884 -3 1856 1867 1870 -3 1851 1862 1867 -3 1862 1876 1867 -3 1867 1876 1873 -3 1851 1867 1856 -3 1868 1871 1874 -3 1868 1879 1871 -3 1868 1872 1879 -3 1868 1881 1872 -3 1869 1877 1880 -3 1854 1869 1884 -3 1869 1880 1879 -3 1869 1879 1885 -3 1869 1885 1884 -3 1850 1853 1874 -3 1850 1874 1875 -3 1825 1850 1875 -3 1853 1870 1874 -3 1853 1855 1870 -3 1870 1882 1874 -3 1855 1857 1870 -3 1856 1870 1857 -3 1826 1862 1851 -3 1852 1875 1871 -3 1852 1871 1878 -3 1871 1875 1874 -3 1871 1877 1878 -3 1871 1880 1877 -3 1871 1879 1880 -3 1872 1885 1879 -3 1872 1884 1885 -3 1873 1876 1883 -3 1825 1875 1852 -3 1858 1860 1887 -3 1858 1887 1886 -3 1859 1886 1861 -3 1848 1859 1861 -3 1847 1886 1888 -3 1847 1861 1886 -3 1847 1889 1854 -3 1847 1888 1889 -3 1869 1887 1877 -3 1869 1888 1887 -3 1854 1889 1869 -3 1869 1889 1888 -3 1852 1878 1860 -3 1860 1878 1887 -3 1886 1887 1888 -3 1877 1887 1878 -3 1826 1827 1862 -3 1866 1873 1896 -3 1866 1893 1882 -3 1863 1894 1890 -3 1863 1890 1897 -3 1863 1864 1894 -3 1849 1891 1892 -3 1849 1895 1891 -3 1775 1849 1892 -3 1778 1895 1849 -3 1868 1874 1893 -3 1868 1893 1881 -3 1873 1890 1896 -3 1873 1897 1890 -3 1890 1894 1892 -3 1872 1891 1895 -3 1872 1881 1891 -3 1881 1893 1891 -3 1647 1872 1895 -3 1873 1883 1897 -3 1775 1892 1898 -3 1892 1894 1898 -3 1874 1882 1893 -3 1647 1895 1778 -3 1775 1898 1864 -3 1775 1864 1776 -3 1864 1898 1894 -3 1776 1864 1839 -3 1863 1897 1865 -3 1862 1865 1876 -3 1865 1883 1876 -3 1865 1897 1883 -3 1858 1886 1859 -3 1866 1896 1899 -3 1866 1899 1893 -3 1890 1892 1899 -3 1890 1899 1896 -3 1899 1892 1891 -3 1891 1893 1899 diff --git a/external/cork/src/accel/aabvh.h b/external/cork/src/accel/aabvh.h deleted file mode 100644 index 6670140cc..000000000 --- a/external/cork/src/accel/aabvh.h +++ /dev/null @@ -1,196 +0,0 @@ -// +------------------------------------------------------------------------- -// | aabvh.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "bbox.h" - -#include - -// maximum leaf size -static const uint LEAF_SIZE = 8; - -template -struct GeomBlob -{ - BBox3d bbox; - Vec3d point; // representative point, usually the box midpoint - GeomIdx id; -}; - -template -struct AABVHNode -{ - BBox3d bbox; - AABVHNode *left; - AABVHNode *right; - ShortVec blobids; - inline bool isLeaf() const { return left == nullptr; } -}; - -template -class AABVH -{ -public: - AABVH(const std::vector< GeomBlob > &geoms) : - root(nullptr), blobs(geoms), tmpids(geoms.size()) - { - ENSURE(blobs.size() > 0); - - for(uint k=0; k action - ) { - // do a recursive search and invoke the action at each - // piece of geometry - std::stack< AABVHNode* > nodes; - nodes.push(root); - - while(!nodes.empty()) { - AABVHNode *node = nodes.top(); - nodes.pop(); - - // check bounding box isct - if(!hasIsct(node->bbox, bbox)) continue; - - // otherwise... - if(node->isLeaf()) { - for(uint bid : node->blobids) { - if(hasIsct(bbox, blobs[bid].bbox)) - action(blobs[bid].id); - } - } else { - nodes.push(node->left); - nodes.push(node->right); - } - } - } - -private: - // process range of tmpids including begin, excluding end - // last_dim provides a hint by saying which dimension a - // split was last made along - AABVHNode* constructTree(uint begin, uint end, uint last_dim) - { - ENSURE(end - begin > 0); // don't tell me to build a tree from nothing - // base case - if(end-begin <= LEAF_SIZE) { - AABVHNode *node = node_pool.alloc(); - node->left = nullptr; - node->blobids.resize(end-begin); - for(uint k=0; kblobids[k] = tmpids[begin + k]; - node->bbox = convex(node->bbox, blobs[blobid].bbox); - } - return node; - } - // otherwise, let's try to split this geometry up - - uint dim = (last_dim+1)%3; - uint mid = (begin + end) / 2; - quickSelect(mid, begin, end, dim); - - // now recurse - AABVHNode *node = node_pool.alloc(); - node->left = constructTree(begin, mid, dim); - node->right = constructTree(mid, end, dim); - node->bbox = convex(node->left->bbox, node->right->bbox); - return node; - } - - // precondition: begin <= select < end - void quickSelect(uint select, uint begin, uint end, uint dim) - { - // NOTE: values equal to the pivot - // may appear on either side of the split - if(end-1 == select) return; - - // p(ivot)i(ndex) and p(ivot)v(alue) - uint pi = randMod(end-begin) + begin; - double pv = blobs[tmpids[pi]].point[dim]; - - int front = begin; - int back = end-1; - while(front < back) { - if(blobs[tmpids[front]].point[dim] < pv) { - front++; - } - else if(blobs[tmpids[back]].point[dim] > pv) { - back--; - } - else { - std::swap(tmpids[front], tmpids[back]); - front++; - back--; - } - } - if(front == back && blobs[tmpids[front]].point[dim] <= pv) { - front++; - } - - if(select < uint(front)) { - quickSelect(select, begin, front, dim); - } else { - quickSelect(select, front, end, dim); - } - } -private: - AABVHNode *root; - - IterPool< AABVHNode > node_pool; - std::vector< GeomBlob > blobs; - std::vector tmpids; // used during construction -}; - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/cork/src/cork.cpp b/external/cork/src/cork.cpp deleted file mode 100644 index 5d25eb752..000000000 --- a/external/cork/src/cork.cpp +++ /dev/null @@ -1,260 +0,0 @@ -// +------------------------------------------------------------------------- -// | cork.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "cork.h" - -#include "mesh.h" - - -void freeCorkTriMesh(CorkTriMesh *mesh) -{ - delete[] mesh->triangles; - delete[] mesh->vertices; - mesh->n_triangles = 0; - mesh->n_vertices = 0; -} - - -struct CorkTriangle; - -struct CorkVertex : - public MinimalVertexData, - public RemeshVertexData, - public IsctVertexData, - public BoolVertexData -{ - void merge(const CorkVertex &v0, const CorkVertex &v1) { - double a0 = 0.5; - if(v0.manifold && !v1.manifold) a0 = 0.0; - if(!v0.manifold && v1.manifold) a0 = 1.0; - double a1 = 1.0 - a0; - - pos = a0 * v0.pos + a1 * v1.pos; - } - void interpolate(const CorkVertex &v0, const CorkVertex &v1) { - double a0 = 0.5; - double a1 = 0.5; - pos = a0 * v0.pos + a1 * v1.pos; - } - - - void isct(IsctVertEdgeTriInput input) - { - Vec2d a_e = Vec2d(1,1)/2.0; - Vec3d a_t = Vec3d(1,1,1)/3.0; - a_e /= 2.0; - a_t /= 2.0; - } - void isct(IsctVertTriTriTriInput input) - { - Vec3d a[3]; - for(uint k=0; k<3; k++) { - a[k] = Vec3d(1,1,1)/3.0; - a[k] /= 3.0; - } - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - }} - } - void isctInterpolate(const CorkVertex &v0, const CorkVertex &v1) { - double a0 = len(v1.pos - pos); - double a1 = len(v0.pos - pos); - if(a0 + a1 == 0.0) a0 = a1 = 0.5; // safety - double sum = a0+a1; - a0 /= sum; - a1 /= sum; - } -}; - -struct CorkTriangle : - public MinimalTriangleData, - public RemeshTriangleData, - public IsctTriangleData, - public BoolTriangleData -{ - void merge(const CorkTriangle &, const CorkTriangle &) {} - static void split(CorkTriangle &, CorkTriangle &, - const CorkTriangle &) {} - void move(const CorkTriangle &) {} - void subdivide(SubdivideTriInput input) - { - bool_alg_data = input.pt->bool_alg_data; - } -}; - -//using RawCorkMesh = RawMesh; -//using CorkMesh = Mesh; -typedef RawMesh RawCorkMesh; -typedef Mesh CorkMesh; - -void corkTriMesh2CorkMesh( - CorkTriMesh in, - CorkMesh *mesh_out -) { - RawCorkMesh raw; - raw.vertices.resize(in.n_vertices); - raw.triangles.resize(in.n_triangles); - if(in.n_vertices == 0 || in.n_triangles == 0) { - CORK_ERROR("empty mesh input to Cork routine."); - *mesh_out = CorkMesh(raw); - return; - } - - uint max_ref_idx = 0; - for(uint i=0; i in.n_vertices) { - CORK_ERROR("mesh input to Cork routine has an out of range reference " - "to a vertex."); - raw.vertices.clear(); - raw.triangles.clear(); - *mesh_out = CorkMesh(raw); - return; - } - - for(uint i=0; iraw(); - - out->n_triangles = raw.triangles.size(); - out->n_vertices = raw.vertices.size(); - - out->triangles = new uint[(out->n_triangles) * 3]; - out->vertices = new double[(out->n_vertices) * 3]; - - for(uint i=0; in_triangles; i++) { - (out->triangles)[3*i+0] = raw.triangles[i].a; - (out->triangles)[3*i+1] = raw.triangles[i].b; - (out->triangles)[3*i+2] = raw.triangles[i].c; - } - - for(uint i=0; in_vertices; i++) { - (out->vertices)[3*i+0] = raw.vertices[i].pos.x; - (out->vertices)[3*i+1] = raw.vertices[i].pos.y; - (out->vertices)[3*i+2] = raw.vertices[i].pos.z; - } -} - - -bool isSolid(CorkTriMesh cmesh) -{ - CorkMesh mesh; - corkTriMesh2CorkMesh(cmesh, &mesh); - - bool solid = true; - - if(mesh.isSelfIntersecting()) { - CORK_ERROR("isSolid() was given a self-intersecting mesh"); - solid = false; - } - - if(!mesh.isClosed()) { - CORK_ERROR("isSolid() was given a non-closed mesh"); - solid = false; - } - - return solid; -} - -void computeUnion( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out -) { - CorkMesh cmIn0, cmIn1; - corkTriMesh2CorkMesh(in0, &cmIn0); - corkTriMesh2CorkMesh(in1, &cmIn1); - - cmIn0.boolUnion(cmIn1); - - corkMesh2CorkTriMesh(&cmIn0, out); -} - -void computeDifference( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out -) { - CorkMesh cmIn0, cmIn1; - corkTriMesh2CorkMesh(in0, &cmIn0); - corkTriMesh2CorkMesh(in1, &cmIn1); - - cmIn0.boolDiff(cmIn1); - - corkMesh2CorkTriMesh(&cmIn0, out); -} - -void computeIntersection( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out -) { - CorkMesh cmIn0, cmIn1; - corkTriMesh2CorkMesh(in0, &cmIn0); - corkTriMesh2CorkMesh(in1, &cmIn1); - - cmIn0.boolIsct(cmIn1); - - corkMesh2CorkTriMesh(&cmIn0, out); -} - -void computeSymmetricDifference( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out -) { - CorkMesh cmIn0, cmIn1; - corkTriMesh2CorkMesh(in0, &cmIn0); - corkTriMesh2CorkMesh(in1, &cmIn1); - - cmIn0.boolXor(cmIn1); - - corkMesh2CorkTriMesh(&cmIn0, out); -} - -void resolveIntersections( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out -) { - CorkMesh cmIn0, cmIn1; - corkTriMesh2CorkMesh(in0, &cmIn0); - corkTriMesh2CorkMesh(in1, &cmIn1); - - cmIn0.disjointUnion(cmIn1); - cmIn0.resolveIntersections(); - - corkMesh2CorkTriMesh(&cmIn0, out); -} - diff --git a/external/cork/src/cork.h b/external/cork/src/cork.h deleted file mode 100644 index 44a552700..000000000 --- a/external/cork/src/cork.h +++ /dev/null @@ -1,74 +0,0 @@ -// +------------------------------------------------------------------------- -// | cork.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#ifndef uint -typedef unsigned int uint; -#endif - -// if a mesh is taken as input, the client must manage the memory -// if a mesh is given as output, please use the provided -// function to free the allocated memory. -struct CorkTriMesh -{ - uint n_triangles; - uint n_vertices; - uint *triangles; - double *vertices; -}; - -void freeCorkTriMesh(CorkTriMesh *mesh); - -// the inputs to Boolean operations must be "solid": -// - closed (aka. watertight; see comment at bottom) -// - non-self-intersecting -// additionally, inputs should use a counter-clockwise convention -// for triangle facing. If the triangles are presented in clockwise -// orientation, the object is interpreted as its unbounded complement - -// This function will test whether or not a mesh is solid -bool isSolid(CorkTriMesh mesh); - -// Boolean operations follow -// result = A U B -void computeUnion(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out); - -// result = A - B -void computeDifference(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out); - -// result = A ^ B -void computeIntersection(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out); - -// result = A XOR B -void computeSymmetricDifference( - CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out); - -// Not a Boolean operation, but related: -// No portion of either surface is deleted. However, the -// curve of intersection between the two surfaces is made explicit, -// such that the two surfaces are now connected. -void resolveIntersections(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out); - diff --git a/external/cork/src/file_formats/files.cpp b/external/cork/src/file_formats/files.cpp deleted file mode 100644 index 762578fb2..000000000 --- a/external/cork/src/file_formats/files.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// +------------------------------------------------------------------------- -// | files.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "files.h" - -#include -using std::cout; -using std::cerr; -using std::endl; - -namespace Files { - -using std::string; - -// private module data -namespace { -} - -int readTriMesh(string filename, FileMesh *mesh) -{ - int lastdot = filename.find_last_of('.'); - if(lastdot < 0) return 1; - string suffix = filename.substr(lastdot, filename.length()-lastdot); - if(suffix == ".ifs") - return readIFS(filename, mesh); - else if (suffix == ".off") - return readOFF(filename, mesh); - else - return 1; -} - -int writeTriMesh(string filename, FileMesh *mesh) -{ - int lastdot = filename.find_last_of('.'); - if(lastdot < 0) return 1; - string suffix = filename.substr(lastdot, filename.length()-lastdot); - if(suffix == ".ifs") - return writeIFS(filename, mesh); - else if (suffix == ".off") - return writeOFF(filename, mesh); - else - return 1; -} - -} // end namespace Files diff --git a/external/cork/src/file_formats/files.h b/external/cork/src/file_formats/files.h deleted file mode 100644 index aa84879fb..000000000 --- a/external/cork/src/file_formats/files.h +++ /dev/null @@ -1,63 +0,0 @@ -// +------------------------------------------------------------------------- -// | files.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include - -//#include "triMesh.h" - -#include "rawMesh.h" - -/* - * Files provides a wrapper for different file types and a common - * data view for the rest of the program. This wrapper was introduced - * to make it easier to support multiple file types using other people's - * file importer/exporter code - */ - -namespace Files { - -// all functions with integer return values here are intended -// to return an error count as if they were a main function - -struct FileVertex : public MinimalVertexData {}; -struct FileTriangle : public MinimalTriangleData {}; -typedef RawMesh FileMesh; -//using FileMesh = RawMesh; - -// generic filetype functions -// these detect which filetype to use by inspecting the filename -int readTriMesh(std::string filename, FileMesh *mesh); -int writeTriMesh(std::string filename, FileMesh *mesh); - -// specific filetype functions -int readIFS(std::string filename, FileMesh *mesh); -int writeIFS(std::string filename, FileMesh *mesh); - -int readOFF(std::string filename, FileMesh *mesh); -int writeOFF(std::string filename, FileMesh *mesh); - -} // end namespace Files diff --git a/external/cork/src/file_formats/ifs.cpp b/external/cork/src/file_formats/ifs.cpp deleted file mode 100644 index d52c89c68..000000000 --- a/external/cork/src/file_formats/ifs.cpp +++ /dev/null @@ -1,339 +0,0 @@ -// +------------------------------------------------------------------------- -// | ifs.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "files.h" - -#include -#include -using std::ifstream; -using std::ofstream; -using std::cout; -using std::endl; -#include - - -namespace Files { - -using std::string; - -// private module data -namespace { - typedef float float32; - typedef unsigned int uint32; - - bool swapBytes; - bool writeFlipping = false; -} - -// All functions return true -// if there are no errors - -inline void flip(char *bytes, int num) -{ - char temp; - for(int i=0; ivertices.resize(num_vertices); - for(auto &v : data->vertices) { - if(!read_vertex(in, v.pos)) return 1; - } - - // TRIANGLES - if(!checkString(in,"TRIANGLES")) return 1; - if(!readString(in,junk_str)) return 1; - uint32 num_tris; - if(!read_uint32(in, num_tris)) return 1; - data->triangles.resize(num_tris); - for(auto &tri : data->triangles) { - if(!read_triangle(in, tri)) return 1; - } - - // TEXTURECOORD - if(hasTextures) { - // noop - } - - return 0; -} - -int writeIFS(string filename, FileMesh *data) -{ - swapBytes = writeFlipping; - string junk_str; - if(!data) return 1; - - ofstream out; - out.open(filename.c_str(), std::ios::out | std::ios::binary); - if(!out) return 1; - - // "IFS" - if(!writeString(out,"IFS")) return 1; - // version # - float32 version = 1.0; // i.e. no textures - if(!write_float32(out,version)) return 1; - // model name - if(!writeString(out,"no_name")) return 1; - - // VERTICES - if(!writeString(out,"VERTICES")) return 1; - uint32 num_vertices = data->vertices.size(); - if(!write_uint32(out, num_vertices)) return 1; - for(const auto &v : data->vertices) { - if(!write_vertex(out, v.pos)) return 1; - } - - // TRIANGLES - if(!writeString(out,"TRIANGLES")) return 1; - uint32 num_tris = data->triangles.size(); - if(!write_uint32(out, num_tris)) return 1; - for(const auto &tri : data->triangles) { - if(!write_triangle(out, tri)) return 1; - } - - // TEXTURECOORD - // not used - - return 0; -} - -} // end namespace Files diff --git a/external/cork/src/file_formats/off.cpp b/external/cork/src/file_formats/off.cpp deleted file mode 100644 index 3b1257164..000000000 --- a/external/cork/src/file_formats/off.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// +------------------------------------------------------------------------- -// | off.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "files.h" - -#include -#include -using std::ifstream; -using std::ofstream; -using std::endl; - - -namespace Files { - -using std::string; -using std::vector; - -int readOFF(string filename, FileMesh *data) -{ - if(!data) return 1; - - ifstream in; // will close on exit from this read function - in.open(filename.c_str()); - if(!in) return 1; - - // "OFF" - string filetype; - in >> filetype; - if(filetype != "OFF") return 1; - - // counts of things - int numvertices, numfaces, numedges; - in >> numvertices >> numfaces >> numedges; - if(!in) return 1; - data->vertices.resize(numvertices); - data->triangles.resize(numfaces); - - // vertex data - for(auto &v : data->vertices) { - Vec3d &p = v.pos; - in >> p.x >> p.y >> p.z; - } - if(!in) return 1; - - // face data - for(auto &tri : data->triangles) { - int polysize; - in >> polysize; - if(polysize != 3) return 1; - - in >> tri.a >> tri.b >> tri.c; - } - if(!in) return 1; - - return 0; -} - -int writeOFF(string filename, FileMesh *data) -{ - if(!data) return 1; - - ofstream out; - out.open(filename.c_str()); - if(!out) return 1; - - // "OFF" - out << "OFF" << endl; - - // numvertices, numfaces, numedges=0 - int numvertices = data->vertices.size(); - int numfaces = data->triangles.size(); - out << numvertices << ' ' << numfaces << ' ' << 0 << endl; - - // vertex data - for(const auto &v : data->vertices) { - const Vec3d &p = v.pos; - out << p.x << ' ' << p.y << ' ' << p.z << endl; - } - - // face data - for(const auto &tri : data->triangles) { - out << "3 " << tri.a << ' ' << tri.b << ' ' << tri.c << endl; - } - if(!out) return 1; - - return 0; -} - - - -} // end namespace Files diff --git a/external/cork/src/isct/absext4.h b/external/cork/src/isct/absext4.h deleted file mode 100644 index 88ae3b7dc..000000000 --- a/external/cork/src/isct/absext4.h +++ /dev/null @@ -1,242 +0,0 @@ -// +------------------------------------------------------------------------- -// | absext4.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -/* - * - * AbsExt4 - * - * Support for performing exterior calculus in R4 - * - * Used for performing filter computations. - * All numbers are positive! (overflow/underflow are concerns) - * and all numbers are kept positive - * - */ - -#include "ext4.h" - -#include - -namespace AbsExt4 { - -using namespace Ext4; -using std::fabs; - -struct AbsExt4_1 { - union { - double v[4]; - struct { - double e0; - double e1; - double e2; - double e3; - }; - }; -}; - -struct AbsExt4_2 { - union { - double v[6]; - struct { - double e01; - double e02; - double e03; - double e12; - double e13; - double e23; - }; - }; -}; - -struct AbsExt4_3 { - union { - double v[4]; - struct { - double e012; - double e013; - double e023; - double e123; - }; - }; -}; - -// ************************ -// An abs takes a k-vector and returns a version with -// absolute values of all the coordinates taken -inline void abs(AbsExt4_1 &out, const Ext4_1 &in) { - for(int i=0; i<4; i++) - out.v[i] = fabs(in.v[i]); -} -inline void abs(AbsExt4_2 &out, const Ext4_2 &in) { - for(int i=0; i<6; i++) - out.v[i] = fabs(in.v[i]); -} -inline void abs(AbsExt4_3 &out, const Ext4_3 &in) { - for(int i=0; i<4; i++) - out.v[i] = fabs(in.v[i]); -} - - -// ************************ -// A neg takes a k-vector and returns its negation -// neg(X,Y) is safe for X=Y -inline void neg(AbsExt4_1 &out, const AbsExt4_1 &in) { - out = in; -} -inline void neg(AbsExt4_2 &out, const AbsExt4_2 &in) { - out = in; -} -inline void neg(AbsExt4_3 &out, const AbsExt4_3 &in) { - out = in; -} - - -// ************************ -// A dual operation takes a k-vector and returns a (4-k)-vector -// A reverse dual operation inverts the dual operation -// dual(X,Y) is not safe for X=Y (same with revdual) -inline void dual(AbsExt4_1 &out, const AbsExt4_3 &in) { - out.e0 = in.e123; - out.e1 = in.e023; - out.e2 = in.e013; - out.e3 = in.e012; -} -inline void dual(AbsExt4_2 &out, const AbsExt4_2 &in) { - out.e01 = in.e23; - out.e02 = in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = in.e02; - out.e23 = in.e01; -} -inline void dual(AbsExt4_3 &out, const AbsExt4_1 &in) { - out.e012 = in.e3; - out.e013 = in.e2; - out.e023 = in.e1; - out.e123 = in.e0; -} -inline void revdual(AbsExt4_1 &out, const AbsExt4_3 &in) { - out.e0 = in.e123; - out.e1 = in.e023; - out.e2 = in.e013; - out.e3 = in.e012; -} -inline void revdual(AbsExt4_2 &out, const AbsExt4_2 &in) { - out.e01 = in.e23; - out.e02 = in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = in.e02; - out.e23 = in.e01; -} -inline void revdual(AbsExt4_3 &out, const AbsExt4_1 &in) { - out.e012 = in.e3; - out.e013 = in.e2; - out.e023 = in.e1; - out.e123 = in.e0; -} - - -// ************************ -// A join takes a j-vector and a k-vector and returns a (j+k)-vector -inline void join(AbsExt4_2 &out, const AbsExt4_1 &lhs, const AbsExt4_1 &rhs) { - out.e01 = (lhs.e0 * rhs.e1) + (rhs.e0 * lhs.e1); - out.e02 = (lhs.e0 * rhs.e2) + (rhs.e0 * lhs.e2); - out.e03 = (lhs.e0 * rhs.e3) + (rhs.e0 * lhs.e3); - out.e12 = (lhs.e1 * rhs.e2) + (rhs.e1 * lhs.e2); - out.e13 = (lhs.e1 * rhs.e3) + (rhs.e1 * lhs.e3); - out.e23 = (lhs.e2 * rhs.e3) + (rhs.e2 * lhs.e3); -} -inline void join(AbsExt4_3 &out, const AbsExt4_2 &lhs, const AbsExt4_1 &rhs) { - out.e012 = (lhs.e01 * rhs.e2) + (lhs.e02 * rhs.e1) + (lhs.e12 *rhs.e0); - out.e013 = (lhs.e01 * rhs.e3) + (lhs.e03 * rhs.e1) + (lhs.e13 *rhs.e0); - out.e023 = (lhs.e02 * rhs.e3) + (lhs.e03 * rhs.e2) + (lhs.e23 *rhs.e0); - out.e123 = (lhs.e12 * rhs.e3) + (lhs.e13 * rhs.e2) + (lhs.e23 *rhs.e1); -} -inline void join(AbsExt4_3 &out, const AbsExt4_1 &lhs, const AbsExt4_2 &rhs) { - join(out, rhs, lhs); -} - - -// ************************ -// A meet takes a j-vector and a k-vector and returns a (j+k-4)-vector -inline void meet(AbsExt4_2 &out, const AbsExt4_3 &lhs, const AbsExt4_3 &rhs) { - AbsExt4_2 out_dual; - AbsExt4_1 lhs_dual; - AbsExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline void meet(AbsExt4_1 &out, const AbsExt4_2 &lhs, const AbsExt4_3 &rhs) { - AbsExt4_3 out_dual; - AbsExt4_2 lhs_dual; - AbsExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline void meet(AbsExt4_1 &out, const AbsExt4_3 &lhs, const AbsExt4_2 &rhs) { - AbsExt4_3 out_dual; - AbsExt4_1 lhs_dual; - AbsExt4_2 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} - - -// ************************ -// An inner product takes two k-vectors and produces a single number -inline double inner(const AbsExt4_1 &lhs, const AbsExt4_1 &rhs) { - double acc = 0.0; - for(int i=0; i<4; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} -inline double inner(const AbsExt4_2 &lhs, const AbsExt4_2 &rhs) { - double acc = 0.0; - for(int i=0; i<6; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} -inline double inner(const AbsExt4_3 &lhs, const AbsExt4_3 &rhs) { - double acc = 0.0; - for(int i=0; i<4; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} - - - - -} // end namespace AbsExt4 - - diff --git a/external/cork/src/isct/empty3d.cpp b/external/cork/src/isct/empty3d.cpp deleted file mode 100644 index ef1936f98..000000000 --- a/external/cork/src/isct/empty3d.cpp +++ /dev/null @@ -1,673 +0,0 @@ -// +------------------------------------------------------------------------- -// | empty3d.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "empty3d.h" - -#include "ext4.h" -#include "absext4.h" -#include "fixext4.h" -#include "gmpext4.h" - -#include "quantization.h" - -#include - -namespace Empty3d { - -// externalized counters... -int degeneracy_count = 0; -int exact_count = 0; -int callcount = 0; - -using namespace Ext4; -using namespace AbsExt4; -using namespace FixExt4; -using namespace GMPExt4; - -void toExt(Ext4_1 &out, const Vec3d &in) -{ - out.e0 = in.x; - out.e1 = in.y; - out.e2 = in.z; - out.e3 = 1.0f; -} - -void toAbsExt(AbsExt4_1 &out, const Vec3d &in) -{ - Vec3d vec = abs(in); - out.e0 = vec.x; - out.e1 = vec.y; - out.e2 = vec.z; - out.e3 = 1.0f; -} - -void toVec3d(Vec3d &out, const Ext4_1 &in) -{ - // Warning: beware of division by zero! - out.x = in.e0 / in.e3; - out.y = in.e1 / in.e3; - out.z = in.e2 / in.e3; -} - -const static int IN_BITS = Quantization::BITS + 1; // +1 for sign bit - -void toFixExt(FixExt4_1 &out, const Vec3d &in) -{ - out.e0 = BitInt::Rep(Quantization::quantize2int(in[0])); - out.e1 = BitInt::Rep(Quantization::quantize2int(in[1])); - out.e2 = BitInt::Rep(Quantization::quantize2int(in[2])); - out.e3 = BitInt::Rep(1); -} - -void toGmpExt(GmpExt4_1 &out, const Vec3d &in) -{ - out.e0 = Quantization::quantize2int(in.x); - out.e1 = Quantization::quantize2int(in.y); - out.e2 = Quantization::quantize2int(in.z); - out.e3 = 1; -} - -void toVec3d(Vec3d &out, const GmpExt4_1 &in) -{ - Vec4d tmp; - tmp.x = in.e0.get_d(); - tmp.y = in.e1.get_d(); - tmp.z = in.e2.get_d(); - tmp.w = in.e3.get_d(); - tmp /= tmp.w; - for(uint k=0; k<3; k++) - out.v[k] = Quantization::RESHRINK * tmp.v[k]; -} - -//template -//void appxFixExt(Vec3d &out, FixExt4_1 &in) -//{ -// Vec4d temp; -// temp[0] = approximate(in.e0); -// temp[1] = approximate(in.e1); -// temp[2] = approximate(in.e2); -// temp[3] = approximate(in.e3); -// std::cout << "appx " << temp << std::endl; -// for(uint k=0; k<3; k++) { -// out[k] = temp[k]; -// out[k] /= temp[3]; -// out[k] *= Quantization::RESHRINK; -// } -//} - -const static double EPS = DBL_EPSILON; -const static double EPS2 = EPS * EPS; - -inline bool filterCheck(double val, double absval, double coeff) { - return fabs(val) > absval*coeff; -} - - -bool isEmpty(const TriEdgeIn &input) -{ - callcount++; - - Ext4_2 temp_e2; - - // construct the triangle - Ext4_1 tp0, tp1, tp2; - toExt(tp0, input.tri.p[0]); - toExt(tp1, input.tri.p[1]); - toExt(tp2, input.tri.p[2]); - Ext4_3 t_ext3; - join(temp_e2, tp0, tp1); - join(t_ext3, temp_e2, tp2); - - // construct the edge - Ext4_1 ep0, ep1; - toExt(ep0, input.edge.p[0]); - toExt(ep1, input.edge.p[1]); - Ext4_2 e_ext2; - join(e_ext2, ep0, ep1); - - // compute the point of intersection - Ext4_1 p_isct; - meet(p_isct, e_ext2, t_ext3); - // need to adjust for negative w-coordinate - if(p_isct.e3 < 0.0) - neg(p_isct, p_isct); - - // a_t0 is the variation of t_ext3 with tp0 replaced with p_isct - // a_t1 is the variation of t_ext3 with tp1 replaced with p_isct - // and so on... - Ext4_3 a_t0, a_t1, a_t2; - join(temp_e2, p_isct, tp1); join(a_t0, temp_e2, tp2); - join(temp_e2, tp0, p_isct); join(a_t1, temp_e2, tp2); - join(temp_e2, tp0, tp1); join(a_t2, temp_e2, p_isct); - Ext4_2 a_e0, a_e1; - join(a_e0, p_isct, ep1); - join(a_e1, ep0, p_isct); - - return (inner(t_ext3, a_t0) < 0.0) || - (inner(t_ext3, a_t1) < 0.0) || - (inner(t_ext3, a_t2) < 0.0) || - (inner(e_ext2, a_e0) < 0.0) || - (inner(e_ext2, a_e1) < 0.0); -} - -Vec3d coords(const TriEdgeIn &input) -{ - Ext4_2 temp_e2; - - // construct the triangle - Ext4_1 tp0, tp1, tp2; - toExt(tp0, input.tri.p[0]); - toExt(tp1, input.tri.p[1]); - toExt(tp2, input.tri.p[2]); - Ext4_3 t_ext3; - join(temp_e2, tp0, tp1); - join(t_ext3, temp_e2, tp2); - - // construct the edge - Ext4_1 ep0, ep1; - toExt(ep0, input.edge.p[0]); - toExt(ep1, input.edge.p[1]); - Ext4_2 e_ext2; - join(e_ext2, ep0, ep1); - - // compute the point of intersection - Ext4_1 p_isct; - meet(p_isct, e_ext2, t_ext3); - // no need to adjust for negative w-coordinate. - // will drop out in divide. - - Vec3d result; - toVec3d(result, p_isct); - return result; -} - -const static double COEFF_IT12_PISCT = 10.0*EPS + 64.0*EPS2; -const static double COEFF_IT12_S1 = 20.0*EPS + 256.0*EPS2; -const static double COEFF_IT12_S2 = 24.0*EPS + 512.0*EPS2; - -int emptyFilter(const TriEdgeIn &input) -{ - Ext4_2 temp2; AbsExt4_2 ktemp2; - Ext4_1 ep[2]; AbsExt4_1 kep[2]; - Ext4_1 tp[3]; AbsExt4_1 ktp[3]; - Ext4_2 e_ext2; AbsExt4_2 ke_ext2; - Ext4_3 t_ext3; AbsExt4_3 kt_ext3; - - // load the points - for(int i=0; i<2; i++) { - toExt(ep[i], input.edge.p[i]); abs(kep[i], ep[i]); - } - for(int i=0; i<3; i++) { - toExt(tp[i], input.tri.p[i]); abs(ktp[i], tp[i]); - } - // form the edge and triangle - join(e_ext2, ep[0], ep[1]); join(ke_ext2, kep[0], kep[1]); - join(temp2, tp[0], tp[1]); join(ktemp2, ktp[0], ktp[1]); - join(t_ext3, temp2, tp[2]); join(kt_ext3, ktemp2, ktp[2]); - - // compute the point of intersection - Ext4_1 pisct; AbsExt4_1 kpisct; - meet(pisct, e_ext2, t_ext3); meet(kpisct, ke_ext2, kt_ext3); - // We perform one of the filter exit tests here... - if(!filterCheck(pisct.e3, kpisct.e3, COEFF_IT12_PISCT)) - return 0; // i.e. uncertain - // need to adjust for negative w-coordinate - if(pisct.e3 < 0.0) - neg(pisct, pisct); - - bool uncertain = false; - // process edge - for(int i=0; i<2; i++) { - Ext4_2 a; AbsExt4_2 ka; - join(a, (i==0)? pisct : ep[0], - (i==1)? pisct : ep[1]); - join(ka, (i==0)? kpisct : kep[0], - (i==1)? kpisct : kep[1]); - double dot = inner(e_ext2, a); double kdot = inner(ke_ext2, ka); - // now figure out what to do... - bool outside = dot < 0.0; - bool reliable = filterCheck(dot, kdot, COEFF_IT12_S1); - if(reliable && outside) - return 1; // i.e. true - if(!reliable) uncertain = true; - } - // process triangle - for(int i=0; i<3; i++) { - Ext4_3 a; AbsExt4_3 ka; - join(temp2, (i==0)? pisct : tp[0], - (i==1)? pisct : tp[1]); - join(a, temp2, - (i==2)? pisct : tp[2]); - join(ktemp2, (i==0)? kpisct : ktp[0], - (i==1)? kpisct : ktp[1]); - join(ka, ktemp2, - (i==2)? kpisct : ktp[2]); - double dot = inner(t_ext3, a); double kdot = inner(kt_ext3, ka); - // now figure out what to do... - bool outside = dot < 0.0; - bool reliable = filterCheck(dot, kdot, COEFF_IT12_S2); - if(reliable && outside) - return 1; // i.e. true - if(!reliable) uncertain = true; - } - if(uncertain) - return 0; - else - return -1; // i.e. false (the intersection is not empty) -} - -bool exactFallback(const TriEdgeIn &input) -{ - // How many bits do we need for various intermediary values? - // Here we label the amount with the relevant type (i.e. EXT2) - // and the relevant role - const static int LINE_BITS = 2*IN_BITS + 1; - const static int TRI_BITS = LINE_BITS + IN_BITS + 2; - const static int ISCT_BITS = TRI_BITS + LINE_BITS + 2; - const static int LINE_A_BITS = ISCT_BITS + IN_BITS + 1; - const static int TRI_A_BITS = LINE_A_BITS + IN_BITS + 2; - const static int INNER_LINE_BITS = LINE_A_BITS + LINE_BITS + 3; - const static int INNER_TRI_BITS = TRI_A_BITS + TRI_BITS + 2; - - // pull in points - FixExt4_1 ep[2]; - FixExt4_1 tp[3]; - for(uint i=0; i<2; i++) - toFixExt(ep[i], input.edge.p[i]); - for(uint i=0; i<3; i++) - toFixExt(tp[i], input.tri.p[i]); - - // construct geometry - FixExt4_2 e; - join(e, ep[0], ep[1]); - FixExt4_2 temp_up; - FixExt4_3 t; - join(temp_up, tp[0], tp[1]); - join(t, temp_up, tp[2]); - - // compute the point of intersection - FixExt4_1 pisct; - meet(pisct, e, t); - // need to adjust for negative w-coordinate - int e3sign = sign(pisct.e3); - if(e3sign < 0) { - neg(pisct, pisct); - } else if(e3sign == 0) { - degeneracy_count++; - return true; - } - - // process edge - FixExt4_2 ae0, ae1; - BitInt::Rep test_e0, test_e1; - int sign_e0, sign_e1; - join(ae0, pisct, ep[1]); - join(ae1, ep[0], pisct); - inner(test_e0, e, ae0); - inner(test_e1, e, ae1); - sign_e0 = sign(test_e0); - sign_e1 = sign(test_e1); - - // process triangle - FixExt4_3 at0, at1, at2; - FixExt4_2 temp0, temp1; - FixExt4_2 temp2; - BitInt::Rep test_t0, test_t1, test_t2; - int sign_t0, sign_t1, sign_t2; - join(temp0, pisct, tp[1]); join(at0, temp0, tp[2]); - join(temp1, tp[0], pisct); join(at1, temp1, tp[2]); - join(temp2, tp[0], tp[1]); join(at2, temp2, pisct); - inner(test_t0, t, at0); - inner(test_t1, t, at1); - inner(test_t2, t, at2); - sign_t0 = sign(test_t0); - sign_t1 = sign(test_t1); - sign_t2 = sign(test_t2); - - if(sign_e0 < 0 || sign_e1 < 0 || - sign_t0 < 0 || sign_t1 < 0 || sign_t2 < 0) - return true; - - if(sign_e0 == 0 || sign_e1 == 0 || - sign_t0 == 0 || sign_t1 == 0 || sign_t2 == 0) - { - degeneracy_count++; - } - return false; -} - -bool emptyExact(const TriEdgeIn &input) -{ - callcount++; - int filter = emptyFilter(input); - if(filter == 0) { - exact_count++; - return exactFallback(input); - } - else - return filter > 0; -} - -Vec3d coordsExact(const TriEdgeIn &input) -{ - // How many bits do we need for various intermediary values? - // Here we label the amount with the relevant type (i.e. EXT2) - // and the relevant role - //const static int LINE_BITS = 2*IN_BITS + 1; - //const static int TRI_BITS = LINE_BITS + IN_BITS + 2; - //const static int ISCT_BITS = TRI_BITS + LINE_BITS + 2; - //const static int LINE_A_BITS = ISCT_BITS + IN_BITS + 1; - //const static int TRI_A_BITS = LINE_A_BITS + IN_BITS + 2; - //const static int INNER_LINE_BITS = LINE_A_BITS + LINE_BITS + 3; - //const static int INNER_TRI_BITS = TRI_A_BITS + TRI_BITS + 2; - - // pull in points - GmpExt4_1 ep[2]; - GmpExt4_1 tp[3]; - for(uint i=0; i<2; i++) - toGmpExt(ep[i], input.edge.p[i]); - for(uint i=0; i<3; i++) - toGmpExt(tp[i], input.tri.p[i]); - - // construct geometry - GmpExt4_2 e; - join(e, ep[0], ep[1]); - GmpExt4_2 temp_up; - GmpExt4_3 t; - join(temp_up, tp[0], tp[1]); - join(t, temp_up, tp[2]); - - // compute the point of intersection - GmpExt4_1 pisct; - meet(pisct, e, t); - - // convert to double - Vec3d result; - toVec3d(result, pisct); - //std::cout << result << std::endl; - return result; -} - - - - - - - - -bool isEmpty(const TriTriTriIn &input) -{ - callcount++; - - Ext4_2 temp_e2; - - // construct the triangles - Ext4_1 tps[3][3]; - Ext4_3 t_ext3s[3]; - for(uint ti=0; ti<3; ti++) { - for(uint pi=0; pi<3; pi++) { - toExt(tps[ti][pi], input.tri[ti].p[pi]); - } - Ext4_2 temp_e2; // help out liveness analysis - join(temp_e2, tps[ti][0], tps[ti][1]); - join(t_ext3s[ti], temp_e2, tps[ti][2]); - } - - // compute the point of intersection - Ext4_1 p_isct; - meet(temp_e2, t_ext3s[0], t_ext3s[1]); - meet(p_isct, temp_e2, t_ext3s[2]); - // need to adjust for negative w-coordinate - if(p_isct.e3 < 0.0) - neg(p_isct, p_isct); - - // Test whether p_isct is inside each triangle - // For each triangle, this is done by creating three modified - // versions, replacing each point with p_isct. - // If none of these modifications flips the orientation of - // the resulting plane, then the point must lie inside the triangle - for(uint ti=0; ti<3; ti++) { - for(uint pi=0; pi<3; pi++) { // three copies... - Ext4_3 a; - Ext4_2 temp_e2; // help out liveness analysis - join(temp_e2, ((pi==0)? p_isct : tps[ti][0]), - ((pi==1)? p_isct : tps[ti][1])); - join(a, temp_e2, ((pi==2)? p_isct : tps[ti][2])); - double test = inner(t_ext3s[ti], a); - if(test < 0.0) // AHA, p_isct IS outside this triangle - return true; - } - } - // well, p_isct must be inside all of the triangles. - return false; -} - -Vec3d coords(const TriTriTriIn &input) -{ - Ext4_2 temp_e2; - - // construct the triangles - Ext4_1 tps[3][3]; - Ext4_3 t_ext3s[3]; - for(uint ti=0; ti<3; ti++) { - for(uint pi=0; pi<3; pi++) { - toExt(tps[ti][pi], input.tri[ti].p[pi]); - } - Ext4_2 temp_e2; // help out liveness analysis - join(temp_e2, tps[ti][0], tps[ti][1]); - join(t_ext3s[ti], temp_e2, tps[ti][2]); - } - - // compute the point of intersection - Ext4_1 p_isct; - meet(temp_e2, t_ext3s[0], t_ext3s[1]); - meet(p_isct, temp_e2, t_ext3s[2]); - // no need to adjust for negative w-coordinate. - // will come out in the divide. - - Vec3d result; - toVec3d(result, p_isct); - return result; -} - -const static double COEFF_IT222_PISCT = 20.0*EPS + 256.0*EPS2; -const static double COEFF_IT222_S2 = 34.0*EPS + 1024.0*EPS2; - -int emptyFilter(const TriTriTriIn &input) -{ - Ext4_2 temp2; AbsExt4_2 ktemp2; - Ext4_1 p[3][3]; AbsExt4_1 kp[3][3]; - Ext4_3 t[3]; AbsExt4_3 kt[3]; - - // load the points and form triangles - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - toExt(p[i][j], input.tri[i].p[j]); abs(kp[i][j], p[i][j]); - } - join(temp2, p[i][0], p[i][1]); join(ktemp2, kp[i][0], kp[i][1]); - join(t[i], temp2, p[i][2]); join(kt[i], ktemp2, kp[i][2]); - } - - // compute the point of intersection - Ext4_1 pisct; AbsExt4_1 kpisct; - meet(temp2, t[0], t[1]); meet(ktemp2, kt[0], kt[1]); - meet(pisct, temp2, t[2]); meet(kpisct, ktemp2, kt[2]); - // We perform one of the filter exit tests here... - if(!filterCheck(pisct.e3, kpisct.e3, COEFF_IT222_PISCT)) - return 0; // i.e. uncertain - // need to adjust for negative w-coordinate - if(pisct.e3 < 0.0) - neg(pisct, pisct); - - bool uncertain = false; - for(int i=0; i<3; i++) { - for(int j=0; j<3; j++) { - Ext4_2 b; AbsExt4_2 kb; - Ext4_3 a; AbsExt4_3 ka; - join(b, (j==0)? pisct : p[i][0], - (j==1)? pisct : p[i][1]); - join(a, b, - (j==2)? pisct : p[i][2]); - join(kb, (j==0)? kpisct : kp[i][0], - (j==1)? kpisct : kp[i][1]); - join(ka, kb, - (j==2)? kpisct : kp[i][2]); - double dot = inner(t[i], a); double kdot = inner(kt[i], ka); - // then consider the filtering... - bool outside = dot < 0.0; - bool reliable = filterCheck(dot, kdot, COEFF_IT222_S2); - if(reliable && outside) - return 1; // i.e. true - if(!reliable) uncertain = true; - } - } - if(uncertain) - return 0; - else - return -1; // i.e. false (the intersection is not empty) -} - -bool exactFallback(const TriTriTriIn &input) -{ - // How many bits do we need for various intermediary values? - // Here we label the amount with the relevant type (i.e. EXT2) - // and the relevant role - const static int EXT2_UP_BITS = 2*IN_BITS + 1; - const static int EXT3_UP_BITS = EXT2_UP_BITS + IN_BITS + 2; - const static int EXT2_DN_BITS = 2*EXT3_UP_BITS + 1; - const static int ISCT_BITS = EXT2_DN_BITS + EXT3_UP_BITS + 2; - const static int EXT2_TA_BITS = ISCT_BITS + IN_BITS + 1; - const static int EXT3_TA_BITS = EXT2_TA_BITS + IN_BITS + 2; - const static int INNER_BITS = EXT3_TA_BITS + EXT3_UP_BITS + 2; - - FixExt4_1 p[3][3]; - FixExt4_3 t[3]; - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - toFixExt(p[i][j], input.tri[i].p[j]); - } - FixExt4_2 temp; - join(temp, p[i][0], p[i][1]); - join(t[i], temp, p[i][2]); - } - - // compute the point of intersection - FixExt4_1 pisct; - { - FixExt4_2 temp; - meet(temp, t[0], t[1]); - meet(pisct, temp, t[2]); - } - // need to adjust for negative w-coordinate - int e3sign = sign(pisct.e3); - if(e3sign < 0) { - neg(pisct, pisct); - } else if(e3sign == 0) { - degeneracy_count++; - return true; - } - - bool uncertain = false; - for(uint i=0; i<3; i++) { - FixExt4_3 a[3]; - FixExt4_2 temp; - FixExt4_2 tmp2; - - join(temp, pisct, p[i][1]); join(a[0], temp, p[i][2]); - join(temp, p[i][0], pisct); join(a[1], temp, p[i][2]); - join(tmp2, p[i][0], p[i][1]); join(a[2], tmp2, pisct); - for(uint j=0; j<3; j++) { - BitInt::Rep test; - int testsign; - inner(test, a[j], t[i]); - testsign = sign(test); - if(testsign < 0) - return true; - if(testsign == 0) - uncertain = true; - } - } - if(uncertain) { - degeneracy_count++; - } - return false; -} - -bool emptyExact(const TriTriTriIn &input) -{ - callcount++; - int filter = emptyFilter(input); - if(filter == 0) { - exact_count++; - return exactFallback(input); - } - else - return filter > 0; -} - -Vec3d coordsExact(const TriTriTriIn &input) -{ - // How many bits do we need for various intermediary values? - // Here we label the amount with the relevant type (i.e. EXT2) - // and the relevant role - //const static int EXT2_UP_BITS = 2*IN_BITS + 1; - //const static int EXT3_UP_BITS = EXT2_UP_BITS + IN_BITS + 2; - //const static int EXT2_DN_BITS = 2*EXT3_UP_BITS + 1; - //const static int ISCT_BITS = EXT2_DN_BITS + EXT3_UP_BITS + 2; - //const static int EXT2_TA_BITS = ISCT_BITS + IN_BITS + 1; - //const static int EXT3_TA_BITS = EXT2_TA_BITS + IN_BITS + 2; - //const static int INNER_BITS = EXT3_TA_BITS + EXT3_UP_BITS + 2; - - GmpExt4_1 p[3][3]; - GmpExt4_3 t[3]; - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - toGmpExt(p[i][j], input.tri[i].p[j]); - } - GmpExt4_2 temp; - join(temp, p[i][0], p[i][1]); - join(t[i], temp, p[i][2]); - } - - // compute the point of intersection - GmpExt4_1 pisct; - { - GmpExt4_2 temp; - meet(temp, t[0], t[1]); - meet(pisct, temp, t[2]); - } - - // convert to double - Vec3d result; - toVec3d(result, pisct); - return result; -} - - - -} // end namespace Empty3d - - - diff --git a/external/cork/src/isct/empty3d.h b/external/cork/src/isct/empty3d.h deleted file mode 100644 index 5a4998927..000000000 --- a/external/cork/src/isct/empty3d.h +++ /dev/null @@ -1,82 +0,0 @@ -// +------------------------------------------------------------------------- -// | empty3d.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "vec.h" - -namespace Empty3d { - -struct TriIn -{ - Vec3d p[3]; -}; - -struct EdgeIn -{ - Vec3d p[2]; -}; - - - -struct TriEdgeIn -{ - TriIn tri; - EdgeIn edge; -}; -bool isEmpty(const TriEdgeIn &input); -Vec3d coords(const TriEdgeIn &input); -bool emptyExact(const TriEdgeIn &input); -Vec3d coordsExact(const TriEdgeIn &input); - -struct TriTriTriIn -{ - TriIn tri[3]; -}; -bool isEmpty(const TriTriTriIn &input); -Vec3d coords(const TriTriTriIn &input); -bool emptyExact(const TriTriTriIn &input); -Vec3d coordsExact(const TriTriTriIn &input); - -extern int degeneracy_count; // count degeneracies encountered -extern int exact_count; // count of filter calls failed -extern int callcount; // total call count - -/* -// exact versions - - -bool emptyExact(const Cell3d0 &c0, - const Complex3d2 &complex, - const Metric3d2 &metric); - -void cell3d0toPointExact(SmVector3 &point, - const Cell3d0 &c0, - const Complex3d2 &complex, - const Metric3d2 &metric); -*/ -} // end namespace Empty3d - - diff --git a/external/cork/src/isct/ext4.h b/external/cork/src/isct/ext4.h deleted file mode 100644 index a0150af0f..000000000 --- a/external/cork/src/isct/ext4.h +++ /dev/null @@ -1,225 +0,0 @@ -// +------------------------------------------------------------------------- -// | ext4.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -/* - * - * Ext4 - * - * Support for performing exterior calculus in R4 - * - */ - -namespace Ext4 { - -// types for k-vectors in R4: -// Ext4_k - -struct Ext4_1 { - union { - double v[4]; - struct { - double e0; - double e1; - double e2; - double e3; - }; - }; -}; - -struct Ext4_2 { - union { - double v[6]; - struct { - double e01; - double e02; - double e03; - double e12; - double e13; - double e23; - }; - }; -}; - -struct Ext4_3 { - union { - double v[4]; - struct { - double e012; - double e013; - double e023; - double e123; - }; - }; -}; - -// ************************ -// Output routines - -// NONE CURRENTLY - - -// ************************ -// A neg takes a k-vector and returns its negation -// neg(X,Y) is safe for X=Y -inline void neg(Ext4_1 &out, const Ext4_1 &in) { - for(int i=0; i<4; i++) - out.v[i] = -in.v[i]; -} -inline void neg(Ext4_2 &out, const Ext4_2 &in) { - for(int i=0; i<6; i++) - out.v[i] = -in.v[i]; -} -inline void neg(Ext4_3 &out, const Ext4_3 &in) { - for(int i=0; i<4; i++) - out.v[i] = -in.v[i]; -} - - -// ************************ -// A dual operation takes a k-vector and returns a (4-k)-vector -// A reverse dual operation inverts the dual operation -// dual(X,Y) is not safe for X=Y (same with revdual) -inline void dual(Ext4_1 &out, const Ext4_3 &in) { - out.e0 = in.e123; - out.e1 = -in.e023; - out.e2 = in.e013; - out.e3 = -in.e012; -} -inline void dual(Ext4_2 &out, const Ext4_2 &in) { - out.e01 = in.e23; - out.e02 = -in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = -in.e02; - out.e23 = in.e01; -} -inline void dual(Ext4_3 &out, const Ext4_1 &in) { - out.e012 = in.e3; - out.e013 = -in.e2; - out.e023 = in.e1; - out.e123 = -in.e0; -} -inline void revdual(Ext4_1 &out, const Ext4_3 &in) { - out.e0 = -in.e123; - out.e1 = in.e023; - out.e2 = -in.e013; - out.e3 = in.e012; -} -inline void revdual(Ext4_2 &out, const Ext4_2 &in) { - out.e01 = in.e23; - out.e02 = -in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = -in.e02; - out.e23 = in.e01; -} -inline void revdual(Ext4_3 &out, const Ext4_1 &in) { - out.e012 = -in.e3; - out.e013 = in.e2; - out.e023 = -in.e1; - out.e123 = in.e0; -} - - -// ************************ -// A join takes a j-vector and a k-vector and returns a (j+k)-vector -inline void join(Ext4_2 &out, const Ext4_1 &lhs, const Ext4_1 &rhs) { - out.e01 = (lhs.e0 * rhs.e1) - (rhs.e0 * lhs.e1); - out.e02 = (lhs.e0 * rhs.e2) - (rhs.e0 * lhs.e2); - out.e03 = (lhs.e0 * rhs.e3) - (rhs.e0 * lhs.e3); - out.e12 = (lhs.e1 * rhs.e2) - (rhs.e1 * lhs.e2); - out.e13 = (lhs.e1 * rhs.e3) - (rhs.e1 * lhs.e3); - out.e23 = (lhs.e2 * rhs.e3) - (rhs.e2 * lhs.e3); -} -inline void join(Ext4_3 &out, const Ext4_2 &lhs, const Ext4_1 &rhs) { - out.e012 = (lhs.e01 * rhs.e2) - (lhs.e02 * rhs.e1) + (lhs.e12 *rhs.e0); - out.e013 = (lhs.e01 * rhs.e3) - (lhs.e03 * rhs.e1) + (lhs.e13 *rhs.e0); - out.e023 = (lhs.e02 * rhs.e3) - (lhs.e03 * rhs.e2) + (lhs.e23 *rhs.e0); - out.e123 = (lhs.e12 * rhs.e3) - (lhs.e13 * rhs.e2) + (lhs.e23 *rhs.e1); -} -inline void join(Ext4_3 &out, const Ext4_1 &lhs, const Ext4_2 &rhs) { - join(out, rhs, lhs); - // no negation since swapping the arguments requires two - // swaps of 1-vectors -} - - -// ************************ -// A meet takes a j-vector and a k-vector and returns a (j+k-4)-vector -inline void meet(Ext4_2 &out, const Ext4_3 &lhs, const Ext4_3 &rhs) { - Ext4_2 out_dual; - Ext4_1 lhs_dual; - Ext4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline void meet(Ext4_1 &out, const Ext4_2 &lhs, const Ext4_3 &rhs) { - Ext4_3 out_dual; - Ext4_2 lhs_dual; - Ext4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline void meet(Ext4_1 &out, const Ext4_3 &lhs, const Ext4_2 &rhs) { - Ext4_3 out_dual; - Ext4_1 lhs_dual; - Ext4_2 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} - - -// ************************ -// An inner product takes two k-vectors and produces a single number -inline double inner(const Ext4_1 &lhs, const Ext4_1 &rhs) { - double acc = 0.0; - for(int i=0; i<4; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} -inline double inner(const Ext4_2 &lhs, const Ext4_2 &rhs) { - double acc = 0.0; - for(int i=0; i<6; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} -inline double inner(const Ext4_3 &lhs, const Ext4_3 &rhs) { - double acc = 0.0; - for(int i=0; i<4; i++) - acc += lhs.v[i] * rhs.v[i]; - return acc; -} - - -} - diff --git a/external/cork/src/isct/fixext4.h b/external/cork/src/isct/fixext4.h deleted file mode 100644 index e8a778881..000000000 --- a/external/cork/src/isct/fixext4.h +++ /dev/null @@ -1,355 +0,0 @@ -// +------------------------------------------------------------------------- -// | fixext4.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -/* - * - * FixExt4 - * - * Support for performing exterior calculus in R4 - * - */ - -//#include -//using std::cout; -//using std::endl; -#include - - -#include "fixint.h" - -namespace FixExt4 { - -using namespace FixInt; - -// types for k-vectors in R4: -// Ext4_k - -template -struct FixExt4_1 { - typename BitInt::Rep e0; - typename BitInt::Rep e1; - typename BitInt::Rep e2; - typename BitInt::Rep e3; -}; - -template -struct FixExt4_2 { - typename BitInt::Rep e01; - typename BitInt::Rep e02; - typename BitInt::Rep e03; - typename BitInt::Rep e12; - typename BitInt::Rep e13; - typename BitInt::Rep e23; -}; - -template -struct FixExt4_3 { - typename BitInt::Rep e012; - typename BitInt::Rep e013; - typename BitInt::Rep e023; - typename BitInt::Rep e123; -}; - - -// ******************************** -// Output Routines -template -std::ostream& operator<<(std::ostream &out, const FixExt4_1 &ext) -{ - return out << '[' << toString(ext.e0) - << ',' << toString(ext.e1) - << ',' << toString(ext.e2) - << ',' << toString(ext.e3) << ']'; -} -template -std::ostream& operator<<(std::ostream &out, const FixExt4_2 &ext) -{ - return out << '[' << toString(ext.e01) - << ',' << toString(ext.e02) - << ',' << toString(ext.e03) - << ',' << toString(ext.e12) - << ',' << toString(ext.e13) - << ',' << toString(ext.e23) << ']'; -} -template -std::ostream& operator<<(std::ostream &out, const FixExt4_3 &ext) -{ - return out << '[' << toString(ext.e012) - << ',' << toString(ext.e013) - << ',' << toString(ext.e023) - << ',' << toString(ext.e123) << ']'; -} - - -// ******************************** -// A neg takes a k-vector and returns its negation -// neg(X,Y) is safe for X=Y -template inline -void neg(FixExt4_1 &out, const FixExt4_1 &in) -{ - neg(out.e0, in.e0); - neg(out.e1, in.e1); - neg(out.e2, in.e2); - neg(out.e3, in.e3); -} -template inline -void neg(FixExt4_2 &out, const FixExt4_2 &in) -{ - neg(out.e01, in.e01); - neg(out.e02, in.e02); - neg(out.e03, in.e03); - neg(out.e12, in.e12); - neg(out.e13, in.e13); - neg(out.e23, in.e23); -} -template inline -void neg(FixExt4_3 &out, const FixExt4_3 &in) -{ - neg(out.e012, in.e012); - neg(out.e013, in.e013); - neg(out.e023, in.e023); - neg(out.e123, in.e123); -} - - -// ******************************** -// A dual operation takes a k-vector and returns a (4-k)-vector -// A reverse dual operation inverts the dual operation -// dual(X,Y) is not safe for X=Y (same with revdual) -template inline -void dual(FixExt4_1 &out, const FixExt4_3 &in) -{ - out.e0 = in.e123; - neg(out.e1, in.e023); - out.e2 = in.e013; - neg(out.e3, in.e012); -} -template inline -void dual(FixExt4_2 &out, const FixExt4_2 &in) -{ - out.e01 = in.e23; - neg(out.e02, in.e13); - out.e03 = in.e12; - out.e12 = in.e03; - neg(out.e13, in.e02); - out.e23 = in.e01; -} -template inline -void dual(FixExt4_3 &out, const FixExt4_1 &in) -{ - out.e012 = in.e3; - neg(out.e013, in.e2); - out.e023 = in.e1; - neg(out.e123, in.e0); -} -template inline -void revdual(FixExt4_1 &out, const FixExt4_3 &in) -{ - neg(out.e0, in.e123); - out.e1 = in.e023; - neg(out.e2, in.e013); - out.e3 = in.e012; -} -template inline -void revdual(FixExt4_2 &out, const FixExt4_2 &in) -{ - out.e01 = in.e23; - neg(out.e02, in.e13); - out.e03 = in.e12; - out.e12 = in.e03; - neg(out.e13, in.e02); - out.e23 = in.e01; -} -template inline -void revdual(FixExt4_3 &out, const FixExt4_1 &in) -{ - neg(out.e012, in.e3); - out.e013 = in.e2; - neg(out.e023, in.e1); - out.e123 = in.e0; -} - - -// ******************************** -// A join takes a j-vector and a k-vector and returns a (j+k)-vector -template inline -void join(FixExt4_2<(Nlhs + Nrhs + 1)> &out, - const FixExt4_1 &lhs, - const FixExt4_1 &rhs) -{ - typename BitInt<(Nlhs + Nrhs)>::Rep a; - typename BitInt<(Nlhs + Nrhs)>::Rep b; - mul(a, lhs.e0, rhs.e1); mul(b, rhs.e0, lhs.e1); - //cout << "a/b limbs: " << BITS_TO_LIMBS(Nlhs+Nrhs) << endl; - //cout << "out bits: " << BITS_TO_LIMBS(Nlhs+Nrhs+1) << endl; - //cout << "a,b: " << toString(a) << ',' << toString(b) << endl; - sub(out.e01, a, b); - mul(a, lhs.e0, rhs.e2); mul(b, rhs.e0, lhs.e2); - sub(out.e02, a, b); - mul(a, lhs.e0, rhs.e3); mul(b, rhs.e0, lhs.e3); - sub(out.e03, a, b); - mul(a, lhs.e1, rhs.e2); mul(b, rhs.e1, lhs.e2); - sub(out.e12, a, b); - mul(a, lhs.e1, rhs.e3); mul(b, rhs.e1, lhs.e3); - sub(out.e13, a, b); - mul(a, lhs.e2, rhs.e3); mul(b, rhs.e2, lhs.e3); - sub(out.e23, a, b); -} -template inline -void join(FixExt4_3<(Nlhs + Nrhs + 2)> &out, - const FixExt4_2 &lhs, - const FixExt4_1 &rhs) -{ - typename BitInt<(Nlhs + Nrhs)>::Rep a; - typename BitInt<(Nlhs + Nrhs)>::Rep b; - typename BitInt<(Nlhs + Nrhs)>::Rep c; - typename BitInt<(Nlhs + Nrhs + 1)>::Rep x; - //cout << "Nlhs: " << Nlhs << " Nrhs: " << Nrhs << endl; - mul(a, lhs.e01, rhs.e2); mul(b, lhs.e02, rhs.e1); mul(c, lhs.e12, rhs.e0); - //cout << "a,b,c: " << toString(a) << ',' - // << toString(b) << ',' << toString(c) << endl; - sub(x, a, b); add(out.e012, x, c); - mul(a, lhs.e01, rhs.e3); mul(b, lhs.e03, rhs.e1); mul(c, lhs.e13, rhs.e0); - //cout << "a,b,c: " << toString(a) << ',' - // << toString(b) << ',' << toString(c) << endl; - sub(x, a, b); add(out.e013, x, c); - mul(a, lhs.e02, rhs.e3); mul(b, lhs.e03, rhs.e2); mul(c, lhs.e23, rhs.e0); - //cout << "a,b,c: " << toString(a) << ',' - // << toString(b) << ',' << toString(c) << endl; - sub(x, a, b); add(out.e023, x, c); - mul(a, lhs.e12, rhs.e3); mul(b, lhs.e13, rhs.e2); mul(c, lhs.e23, rhs.e1); - //cout << "a,b,c: " << toString(a) << ',' - // << toString(b) << ',' << toString(c) << endl; - sub(x, a, b); add(out.e123, x, c); -} -template inline -void join(FixExt4_3<(Nlhs + Nrhs + 2)> &out, - const FixExt4_1 &lhs, - const FixExt4_2 &rhs) -{ - join(out, rhs, lhs); - // no negation since swapping the arguments requires two - // swaps of 1-vectors -} - - -// ******************************** -// A meet takes a j-vector and a k-vector and returns a (j+k-4)-vector -template inline -void meet(FixExt4_2<(Nlhs + Nrhs + 1)> &out, - const FixExt4_3 &lhs, - const FixExt4_3 &rhs) -{ - FixExt4_2<(Nlhs + Nrhs + 1)> out_dual; - FixExt4_1 lhs_dual; - FixExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -template inline -void meet(FixExt4_1<(Nlhs + Nrhs + 2)> &out, - const FixExt4_2 &lhs, - const FixExt4_3 &rhs) -{ - FixExt4_3<(Nlhs + Nrhs + 2)> out_dual; - FixExt4_2 lhs_dual; - FixExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -template inline -void meet(FixExt4_1<(Nlhs + Nrhs + 2)> &out, - const FixExt4_3 &lhs, - const FixExt4_2 &rhs) -{ - FixExt4_3<(Nlhs + Nrhs + 2)> out_dual; - FixExt4_1 lhs_dual; - FixExt4_2 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} - - -// ******************************** -// An inner product takes two k-vectors and produces a single number -template inline -void inner(typename BitInt<(Nlhs + Nrhs + 2)>::Rep &out, - const FixExt4_1 &lhs, - const FixExt4_1 &rhs) -{ - typename BitInt<(Nlhs + Nrhs)>::Rep p0; mul(p0, lhs.e0, rhs.e0); - typename BitInt<(Nlhs + Nrhs)>::Rep p1; mul(p1, lhs.e1, rhs.e1); - typename BitInt<(Nlhs + Nrhs)>::Rep p2; mul(p2, lhs.e2, rhs.e2); - typename BitInt<(Nlhs + Nrhs)>::Rep p3; mul(p3, lhs.e3, rhs.e3); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep a; add(a, p0, p1); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep b; add(b, p2, p3); - add(out, a, b); -} -template inline -void inner(typename BitInt<(Nlhs + Nrhs + 3)>::Rep &out, - const FixExt4_2 &lhs, - const FixExt4_2 &rhs) -{ - typename BitInt<(Nlhs + Nrhs)>::Rep p0; mul(p0, lhs.e01, rhs.e01); - typename BitInt<(Nlhs + Nrhs)>::Rep p1; mul(p1, lhs.e02, rhs.e02); - typename BitInt<(Nlhs + Nrhs)>::Rep p2; mul(p2, lhs.e03, rhs.e03); - typename BitInt<(Nlhs + Nrhs)>::Rep p3; mul(p3, lhs.e12, rhs.e12); - typename BitInt<(Nlhs + Nrhs)>::Rep p4; mul(p4, lhs.e13, rhs.e13); - typename BitInt<(Nlhs + Nrhs)>::Rep p5; mul(p5, lhs.e23, rhs.e23); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep a; add(a, p0, p1); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep b; add(b, p2, p3); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep c; add(c, p4, p5); - typename BitInt<(Nlhs + Nrhs + 2)>::Rep x; add(x, a, b); - add(out, x, c); -} -template inline -void inner(typename BitInt<(Nlhs + Nrhs + 2)>::Rep &out, - const FixExt4_3 &lhs, - const FixExt4_3 &rhs) -{ - typename BitInt<(Nlhs + Nrhs)>::Rep p0; mul(p0, lhs.e012, rhs.e012); - typename BitInt<(Nlhs + Nrhs)>::Rep p1; mul(p1, lhs.e013, rhs.e013); - typename BitInt<(Nlhs + Nrhs)>::Rep p2; mul(p2, lhs.e023, rhs.e023); - typename BitInt<(Nlhs + Nrhs)>::Rep p3; mul(p3, lhs.e123, rhs.e123); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep a; add(a, p0, p1); - typename BitInt<(Nlhs + Nrhs + 1)>::Rep b; add(b, p2, p3); - add(out, a, b); -} - - - - - - -} // end namespace FixExt4 - diff --git a/external/cork/src/isct/fixint.h b/external/cork/src/isct/fixint.h deleted file mode 100644 index 37465a1d8..000000000 --- a/external/cork/src/isct/fixint.h +++ /dev/null @@ -1,367 +0,0 @@ -// +------------------------------------------------------------------------- -// | fixint.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -/* - * - * fixint.H - * - * Support for known size big integers - * - * See the BitInt wrapper class towards the end of the file - * for the type you want to use. Specifically you want to declare - * - * BitInt<128>::Rep myInt; - * - * to get an integer guaranteed to hold at least 128 bits. - * Provided the size of all integers used in this fashion - * is declared appropriately, the template magic will - * statically decide which specialized function to call. - * - */ - - - -#ifdef _WIN32 -#include -#else -#include -#endif - -#include -#include -#include - -namespace FixInt { - -// static assertion using templates. Usage: -// ASSERT_STATIC< expr_to_assert >::test(); -template -struct ASSERT_STATIC {}; -template<> -struct ASSERT_STATIC { static void test() {}; }; - - -const static unsigned int LIMB_BIT_SIZE = GMP_NUMB_BITS; -const static unsigned int SIGN_BIT_OFFSET = LIMB_BIT_SIZE-1; -// mask defining the position of the sign bit in a limb -#define LIMB_SIGN_MASK (mp_limb_t(1) << SIGN_BIT_OFFSET) -// function which tests sign and returns 1 if it's set; 0 otherwise -#define SIGN_BOOL(limbs,n) \ - (((limbs)[(n)-1] & LIMB_SIGN_MASK) >> SIGN_BIT_OFFSET) -// function which tests sign and returns -1 if it's set; 1 otherwise -#define SIGN_INT(limbs,n) (((limbs)[(n)-1] & LIMB_SIGN_MASK)? -1 : 1) -// pattern of all 1s filling up a limb -#define ONES_PATTERN (mp_limb_t(-1)) -#define ZERO_PATTERN (mp_limb_t(0)) -// function which tests sign and returns -#define SIGN_LIMB(limbs,n) (((limbs)[(n)-1] & LIMB_SIGN_MASK)? \ - ONES_PATTERN : ZERO_PATTERN) -#define BITS_TO_LIMBS(n) ((((n)-1)/ LIMB_BIT_SIZE)+1) - -template -class LimbInt { -public: - mp_limb_t limbs[Nlimbs]; - - inline LimbInt(int init) { - ASSERT_STATIC<(sizeof(int) <= sizeof(mp_limb_t))>::test(); - limbs[0] = init; - if(Nlimbs > 1) { - mp_limb_t fill = SIGN_LIMB(limbs,1); - for(int i=1; i -std::ostream& operator<<(std::ostream &out, const LimbInt &num) -{ - out << "[" << std::hex << num.limbs[0]; - for(int k=0; k -inline void promote(LimbInt &out, const LimbInt &in) -{ - ASSERT_STATIC<(Nout >= Nin)>::test(); - - mpn_copyi(out.limbs, in.limbs, Nin); - - if(Nout > Nin) { // fill out the higher order bits... - mp_limb_t fill = SIGN_LIMB(out.limbs, Nin); - for(int i=Nin; i -inline void add(LimbInt &out, - const LimbInt &lhs, - const LimbInt &rhs) -{ - ASSERT_STATIC<(Nout >= Nlhs && Nout >= Nrhs)>::test(); - int Nmax = Nlhs; - if(Nrhs > Nlhs) Nmax = Nrhs; - mp_limb_t carry; - - if(Nlhs == Nrhs) { - carry = mpn_add_n(out.limbs, lhs.limbs, rhs.limbs, Nlhs); - } else if(Nlhs > Nrhs) { - mp_limb_t rhs_is_neg = SIGN_BOOL(rhs.limbs, Nrhs); - carry = mpn_add(out.limbs, lhs.limbs, Nlhs, rhs.limbs, Nrhs); - mp_limb_t borrow = mpn_sub_1(out.limbs+Nrhs, - out.limbs+Nrhs, Nlhs-Nrhs, - rhs_is_neg); - if(Nout > Nmax) carry = carry | (mp_limb_t(1) - borrow); - } else { // Nrhs > Nlhs - mp_limb_t lhs_is_neg = SIGN_BOOL(lhs.limbs, Nlhs); - carry = mpn_add(out.limbs, rhs.limbs, Nrhs, lhs.limbs, Nlhs); - mp_limb_t borrow = mpn_sub_1(out.limbs+Nlhs, - out.limbs+Nlhs, Nrhs-Nlhs, - lhs_is_neg); - if(Nout > Nmax) carry = carry | (mp_limb_t(1) - borrow); - } - - // fill out any new higher order bits - if(Nout > Nmax) { - mp_limb_t rhs_is_neg = SIGN_BOOL(rhs.limbs, Nrhs); - mp_limb_t lhs_is_neg = SIGN_BOOL(lhs.limbs, Nlhs); - mp_limb_t fill_bit = rhs_is_neg ^ lhs_is_neg ^ carry; - mp_limb_t fill = (fill_bit)? ONES_PATTERN : ZERO_PATTERN; - for(int i=Nmax; i -inline void sub(LimbInt &out, - const LimbInt &lhs, - const LimbInt &rhs) -{ - // for testing... - LimbInt tempright; - mpn_neg(tempright.limbs, rhs.limbs, Nrhs); - add(out, lhs, tempright); - /*ASSERT_STATIC<(Nout >= Nlhs && Nout >= Nrhs)>::test(); - const mp_limb_t *left = lhs.limbs; - const mp_limb_t *right = rhs.limbs; - int Nleft = Nlhs; - int Nright = Nrhs; - if(Nrhs > Nlhs) { - const mp_limb_t *temp = left; left = right; right = temp; - int tempi = Nleft; Nleft = Nright; Nright = tempi; - } - - mpn_copyi(out.limbs, left, Nleft); - if(Nout != Nleft) { // make sure higher order limbs are filled - mp_limb_t fill = SIGN_LIMB(left, Nleft); - for(int i=Nleft; i= Nlhs && Nout >= Nrhs)>::test(); - int Nmax = Nlhs; - if(Nrhs > Nlhs) Nmax = Nrhs; - mp_limb_t carry; - - if(Nlhs == Nrhs) { - carry = mpn_add_n(out.limbs, lhs.limbs, rhs.limbs, Nlhs); - } else if(Nlhs > Nrhs) { - mp_limb_t rhs_is_neg = SIGN_BOOL(rhs.limbs, Nrhs); - carry = mpn_add(out.limbs, lhs.limbs, Nlhs, rhs.limbs, Nrhs); - mp_limb_t borrow = mpn_sub_1(out.limbs+Nrhs, - out.limbs+Nrhs, Nlhs-Nrhs, - rhs_is_neg); - if(Nout > Nmax) carry = carry | (mp_limb_t(1) - borrow); - } else { // Nrhs > Nlhs - mp_limb_t lhs_is_neg = SIGN_BOOL(lhs.limbs, Nlhs); - carry = mpn_add(out.limbs, rhs.limbs, Nrhs, lhs.limbs, Nlhs); - mp_limb_t borrow = mpn_sub_1(out.limbs+Nlhs, - out.limbs+Nlhs, Nrhs-Nlhs, - lhs_is_neg); - if(Nout > Nmax) carry = carry | (mp_limb_t(1) - borrow); - } - - // fill out any new higher order bits (DOES THIS HAVE TO USE THE CARRY?) - if(Nout > Nmax) { - mp_limb_t rhs_is_neg = SIGN_BOOL(rhs.limbs, Nrhs); - mp_limb_t lhs_is_neg = SIGN_BOOL(lhs.limbs, Nlhs); - mp_limb_t fill_bit = rhs_is_neg ^ lhs_is_neg ^ carry; - mp_limb_t fill = -fill_bit; - for(int i=Nmax; i -inline void neg(LimbInt &out, - const LimbInt &in) -{ - ASSERT_STATIC<(Nout >= Nin)>::test(); - - mpn_neg(out.limbs, in.limbs, Nin); - - if(Nout > Nin) { - mp_limb_t fill = SIGN_LIMB(out.limbs, Nin); - for(int i=Nin; i -inline void mul(LimbInt &out, - const LimbInt &lhs, - const LimbInt &rhs) -{ - ASSERT_STATIC<(Nout >= Nlhs && Nout >= Nrhs)>::test(); - // handle the possibility that we need to use more space - // than we have... - mp_limb_t *res = out.limbs; - LimbInt tempresult; - if(Nout < Nlhs + Nrhs) - res = tempresult.limbs; - - // multiply - if(Nlhs == Nrhs) - mpn_mul_n(res, lhs.limbs, rhs.limbs, Nlhs); - else if(Nlhs > Nrhs) - mpn_mul(res, lhs.limbs, Nlhs, rhs.limbs, Nrhs); - else // need to flip in order to satisfy calling condition... - mpn_mul(res, rhs.limbs, Nrhs, lhs.limbs, Nlhs); - - mp_limb_t lhs_sign = SIGN_BOOL(lhs.limbs,Nlhs); - mp_limb_t rhs_sign = SIGN_BOOL(rhs.limbs,Nrhs); - - mpn_submul_1((res+Nlhs), rhs.limbs, Nrhs, lhs_sign); - mpn_submul_1((res+Nrhs), lhs.limbs, Nlhs, rhs_sign); - - // transfer large result if we had one... - if(Nout < Nlhs + Nrhs) - mpn_copyi(out.limbs, res, Nout); - - // if we have more limbs than needed for the multiply, - // fill out the extra higher order limbs... - if(Nout > Nlhs + Nrhs) { - mp_limb_t fill = SIGN_LIMB(out.limbs, Nlhs+Nrhs); - for(int i=Nlhs+Nrhs; i -inline -int sign(const LimbInt &in) -{ - bool nonzero = false; - for(int i=0; i -//inline -//double approximate(const LimbInt &in) -//{ -// std::cout << in << std::endl; -// // not the most efficient implementation, but it should work -// LimbInt tmp; -// double sign; -// if(SIGN_BOOL(in.limbs, N-1)) { -// neg(tmp, in); -// sign = -1.0; -// } else { -// tmp = in; -// sign = 1.0; -// } -// std::cout << tmp << std::endl; -// std::cout << typeid(mp_limb_t).name() << std::endl; -// std::cout << double(in.limbs[2]) << std::endl; -// double result = 0.0; -// for(int i=0; i -inline -std::string toString(const LimbInt &num) -{ - char cbuf[(N*LIMB_BIT_SIZE*3)/10 + 3]; - LimbInt garbage = num; - bool neg = SIGN_BOOL(num.limbs,N); - if(neg) - mpn_neg(garbage.limbs, garbage.limbs, N); - - int count = mpn_get_str(reinterpret_cast(cbuf), - 10, garbage.limbs, N); - - std::string result = ""; - - if(neg) result += '-'; - int i=0; - for(;i::Rep my128bitNumberVariable; -template -class BitInt { -public: - typedef LimbInt Rep; -private: - BitInt(); -}; - -} // end namespace FIXINT diff --git a/external/cork/src/isct/gmpext4.h b/external/cork/src/isct/gmpext4.h deleted file mode 100644 index 1a5541c99..000000000 --- a/external/cork/src/isct/gmpext4.h +++ /dev/null @@ -1,286 +0,0 @@ -// +------------------------------------------------------------------------- -// | gmpext4.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#ifdef _WIN32 -#pragma warning(disable: 4800) -#pragma warning(disable: 4244) -#include -#pragma warning(default: 4244) -#pragma warning(default: 4800) -#else -#include -#endif - -#include - - -namespace GMPExt4 { - -// types for k-vectors in R4: -// Ext4_k - -struct GmpExt4_1 { - mpz_class e0; - mpz_class e1; - mpz_class e2; - mpz_class e3; -}; - -struct GmpExt4_2 { - mpz_class e01; - mpz_class e02; - mpz_class e03; - mpz_class e12; - mpz_class e13; - mpz_class e23; -}; - -struct GmpExt4_3 { - mpz_class e012; - mpz_class e013; - mpz_class e023; - mpz_class e123; -}; - - -// ******************************** -// Output Routines -inline std::ostream& operator<<(std::ostream &out, const GmpExt4_1 &ext) -{ - return out << '[' << ext.e0 - << ',' << ext.e1 - << ',' << ext.e2 - << ',' << ext.e3 << ']'; -} -inline std::ostream& operator<<(std::ostream &out, const GmpExt4_2 &ext) -{ - return out << '[' << ext.e01 - << ',' << ext.e02 - << ',' << ext.e03 - << ',' << ext.e12 - << ',' << ext.e13 - << ',' << ext.e23 << ']'; -} -inline std::ostream& operator<<(std::ostream &out, const GmpExt4_3 &ext) -{ - return out << '[' << ext.e012 - << ',' << ext.e013 - << ',' << ext.e023 - << ',' << ext.e123 << ']'; -} - - -// ******************************** -// A neg takes a k-vector and returns its negation -// neg(X,Y) is safe for X=Y -inline -void neg(GmpExt4_1 &out, const GmpExt4_1 &in) -{ - out.e0 = -in.e0; - out.e1 = -in.e1; - out.e2 = -in.e2; - out.e3 = -in.e3; -} -inline -void neg(GmpExt4_2 &out, const GmpExt4_2 &in) -{ - out.e01 = -in.e01; - out.e02 = -in.e02; - out.e03 = -in.e03; - out.e12 = -in.e12; - out.e13 = -in.e13; - out.e23 = -in.e23; -} -inline -void neg(GmpExt4_3 &out, const GmpExt4_3 &in) -{ - out.e012 = -in.e012; - out.e013 = -in.e013; - out.e023 = -in.e023; - out.e123 = -in.e123; -} - - -// ******************************** -// A dual operation takes a k-vector and returns a (4-k)-vector -// A reverse dual operation inverts the dual operation -// dual(X,Y) is not safe for X=Y (same with revdual) -inline -void dual(GmpExt4_1 &out, const GmpExt4_3 &in) -{ - out.e0 = in.e123; - out.e1 = -in.e023; - out.e2 = in.e013; - out.e3 = -in.e012; -} -inline -void dual(GmpExt4_2 &out, const GmpExt4_2 &in) -{ - out.e01 = in.e23; - out.e02 = -in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = -in.e02; - out.e23 = in.e01; -} -inline -void dual(GmpExt4_3 &out, const GmpExt4_1 &in) -{ - out.e012 = in.e3; - out.e013 = -in.e2; - out.e023 = in.e1; - out.e123 = -in.e0; -} -inline -void revdual(GmpExt4_1 &out, const GmpExt4_3 &in) -{ - out.e0 = -in.e123; - out.e1 = in.e023; - out.e2 = -in.e013; - out.e3 = in.e012; -} -inline -void revdual(GmpExt4_2 &out, const GmpExt4_2 &in) -{ - out.e01 = in.e23; - out.e02 = -in.e13; - out.e03 = in.e12; - out.e12 = in.e03; - out.e13 = -in.e02; - out.e23 = in.e01; -} -inline -void revdual(GmpExt4_3 &out, const GmpExt4_1 &in) -{ - out.e012 = -in.e3; - out.e013 = in.e2; - out.e023 = -in.e1; - out.e123 = in.e0; -} - - -// ******************************** -// A join takes a j-vector and a k-vector and returns a (j+k)-vector -inline -void join(GmpExt4_2 &out, const GmpExt4_1 &lhs, const GmpExt4_1 &rhs) -{ - out.e01 = (lhs.e0 * rhs.e1) - (rhs.e0 * lhs.e1); - out.e02 = (lhs.e0 * rhs.e2) - (rhs.e0 * lhs.e2); - out.e03 = (lhs.e0 * rhs.e3) - (rhs.e0 * lhs.e3); - out.e12 = (lhs.e1 * rhs.e2) - (rhs.e1 * lhs.e2); - out.e13 = (lhs.e1 * rhs.e3) - (rhs.e1 * lhs.e3); - out.e23 = (lhs.e2 * rhs.e3) - (rhs.e2 * lhs.e3); -} -inline -void join(GmpExt4_3 &out, const GmpExt4_2 &lhs, const GmpExt4_1 &rhs) -{ - out.e012 = (lhs.e01 * rhs.e2) - (lhs.e02 * rhs.e1) + (lhs.e12 *rhs.e0); - out.e013 = (lhs.e01 * rhs.e3) - (lhs.e03 * rhs.e1) + (lhs.e13 *rhs.e0); - out.e023 = (lhs.e02 * rhs.e3) - (lhs.e03 * rhs.e2) + (lhs.e23 *rhs.e0); - out.e123 = (lhs.e12 * rhs.e3) - (lhs.e13 * rhs.e2) + (lhs.e23 *rhs.e1); -} -inline -void join(GmpExt4_3 &out, const GmpExt4_1 &lhs, const GmpExt4_2 &rhs) -{ - join(out, rhs, lhs); - // no negation since swapping the arguments requires two - // swaps of 1-vectors -} - - -// ******************************** -// A meet takes a j-vector and a k-vector and returns a (j+k-4)-vector -inline -void meet(GmpExt4_2 &out, const GmpExt4_3 &lhs, const GmpExt4_3 &rhs) -{ - GmpExt4_2 out_dual; - GmpExt4_1 lhs_dual; - GmpExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline -void meet(GmpExt4_1 &out, const GmpExt4_2 &lhs, const GmpExt4_3 &rhs) -{ - GmpExt4_3 out_dual; - GmpExt4_2 lhs_dual; - GmpExt4_1 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} -inline -void meet(GmpExt4_1 &out, const GmpExt4_3 &lhs, const GmpExt4_2 &rhs) -{ - GmpExt4_3 out_dual; - GmpExt4_1 lhs_dual; - GmpExt4_2 rhs_dual; - dual(lhs_dual, lhs); - dual(rhs_dual, rhs); - join(out_dual, lhs_dual, rhs_dual); - revdual(out, out_dual); -} - - -// ******************************** -// An inner product takes two k-vectors and produces a single number -inline -mpz_class inner(const GmpExt4_1 &lhs, const GmpExt4_1 &rhs) -{ - return lhs.e0 * rhs.e0 + - lhs.e1 * rhs.e1 + - lhs.e2 * rhs.e2 + - lhs.e3 * rhs.e3; -} -inline -mpz_class inner(const GmpExt4_2 &lhs, const GmpExt4_2 &rhs) -{ - return lhs.e01 * rhs.e01 + - lhs.e02 * rhs.e02 + - lhs.e03 * rhs.e03 + - lhs.e12 * rhs.e12 + - lhs.e13 * rhs.e13 + - lhs.e23 * rhs.e23; -} -inline -mpz_class inner(const GmpExt4_3 &lhs, const GmpExt4_3 &rhs) -{ - return lhs.e012 * rhs.e012 + - lhs.e013 * rhs.e013 + - lhs.e023 * rhs.e023 + - lhs.e123 * rhs.e123; -} - - - - - - -} // end namespace GMPExt4 diff --git a/external/cork/src/isct/quantization.cpp b/external/cork/src/isct/quantization.cpp deleted file mode 100644 index a0d67581d..000000000 --- a/external/cork/src/isct/quantization.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// +------------------------------------------------------------------------- -// | quantization.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "quantization.h" - -namespace Quantization { - -double MAGNIFY = 1.0; -double RESHRINK = 1.0; - -} // end namespace Quantization - diff --git a/external/cork/src/isct/quantization.h b/external/cork/src/isct/quantization.h deleted file mode 100644 index e0e3919f3..000000000 --- a/external/cork/src/isct/quantization.h +++ /dev/null @@ -1,65 +0,0 @@ -// +------------------------------------------------------------------------- -// | quantization.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include - -namespace Quantization { - -// NOTE: none of these values should be modified by the clients -static const int BITS = 30; -// MAGNIFY * RESHRINK == 1 -extern double MAGNIFY; -extern double RESHRINK; -inline int quantize2int(double number) { - return int(number * MAGNIFY); -} -inline double quantizedInt2double(int number) { - return RESHRINK * double(number); -} -inline double quantize(double number) { - return RESHRINK * double(int(number * MAGNIFY)); -} - -// given the specified number of bits, -// and bound on the coordinate values of points, -// fit as fine-grained a grid as possible over the space. -inline void callibrate(double maximumMagnitude) -{ - int max_exponent; - std::frexp(maximumMagnitude, &max_exponent); - max_exponent++; // ensure that 2^max_exponent > maximumMagnitude - - // set constants - MAGNIFY = std::pow(2.0, BITS - max_exponent); - // we are guaranteed that maximumMagnitude * MAGNIFY < 2.0^BITS - RESHRINK = std::pow(2.0, max_exponent - BITS); -} - - -} // end namespace Quantization - - diff --git a/external/cork/src/isct/triangle.c b/external/cork/src/isct/triangle.c deleted file mode 100644 index 08dcc87e2..000000000 --- a/external/cork/src/isct/triangle.c +++ /dev/null @@ -1,16005 +0,0 @@ -/*****************************************************************************/ -/* */ -/* 888888888 ,o, / 888 */ -/* 888 88o88o " o8888o 88o8888o o88888o 888 o88888o */ -/* 888 888 888 88b 888 888 888 888 888 d888 88b */ -/* 888 888 888 o88^o888 888 888 "88888" 888 8888oo888 */ -/* 888 888 888 C888 888 888 888 / 888 q888 */ -/* 888 888 888 "88o^888 888 888 Cb 888 "88oooo" */ -/* "8oo8D */ -/* */ -/* A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator. */ -/* (triangle.c) */ -/* */ -/* Version 1.6 */ -/* July 28, 2005 */ -/* */ -/* Copyright 1993, 1995, 1997, 1998, 2002, 2005 */ -/* Jonathan Richard Shewchuk */ -/* 2360 Woolsey #H */ -/* Berkeley, California 94705-1927 */ -/* jrs@cs.berkeley.edu */ -/* */ -/* This program may be freely redistributed under the condition that the */ -/* copyright notices (including this entire header and the copyright */ -/* notice printed when the `-h' switch is selected) are not removed, and */ -/* no compensation is received. Private, research, and institutional */ -/* use is free. You may distribute modified versions of this code UNDER */ -/* THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE */ -/* SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE */ -/* AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR */ -/* NOTICE IS GIVEN OF THE MODIFICATIONS. Distribution of this code as */ -/* part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT */ -/* WITH THE AUTHOR. (If you are not directly supplying this code to a */ -/* customer, and you are instead telling them how they can obtain it for */ -/* free, then you are not required to make any arrangement with me.) */ -/* */ -/* Hypertext instructions for Triangle are available on the Web at */ -/* */ -/* http://www.cs.cmu.edu/~quake/triangle.html */ -/* */ -/* Disclaimer: Neither I nor Carnegie Mellon warrant this code in any way */ -/* whatsoever. This code is provided "as-is". Use at your own risk. */ -/* */ -/* Some of the references listed below are marked with an asterisk. [*] */ -/* These references are available for downloading from the Web page */ -/* */ -/* http://www.cs.cmu.edu/~quake/triangle.research.html */ -/* */ -/* Three papers discussing aspects of Triangle are available. A short */ -/* overview appears in "Triangle: Engineering a 2D Quality Mesh */ -/* Generator and Delaunay Triangulator," in Applied Computational */ -/* Geometry: Towards Geometric Engineering, Ming C. Lin and Dinesh */ -/* Manocha, editors, Lecture Notes in Computer Science volume 1148, */ -/* pages 203-222, Springer-Verlag, Berlin, May 1996 (from the First ACM */ -/* Workshop on Applied Computational Geometry). [*] */ -/* */ -/* The algorithms are discussed in the greatest detail in "Delaunay */ -/* Refinement Algorithms for Triangular Mesh Generation," Computational */ -/* Geometry: Theory and Applications 22(1-3):21-74, May 2002. [*] */ -/* */ -/* More detail about the data structures may be found in my dissertation: */ -/* "Delaunay Refinement Mesh Generation," Ph.D. thesis, Technical Report */ -/* CMU-CS-97-137, School of Computer Science, Carnegie Mellon University, */ -/* Pittsburgh, Pennsylvania, 18 May 1997. [*] */ -/* */ -/* Triangle was created as part of the Quake Project in the School of */ -/* Computer Science at Carnegie Mellon University. For further */ -/* information, see Hesheng Bao, Jacobo Bielak, Omar Ghattas, Loukas F. */ -/* Kallivokas, David R. O'Hallaron, Jonathan R. Shewchuk, and Jifeng Xu, */ -/* "Large-scale Simulation of Elastic Wave Propagation in Heterogeneous */ -/* Media on Parallel Computers," Computer Methods in Applied Mechanics */ -/* and Engineering 152(1-2):85-102, 22 January 1998. */ -/* */ -/* Triangle's Delaunay refinement algorithm for quality mesh generation is */ -/* a hybrid of one due to Jim Ruppert, "A Delaunay Refinement Algorithm */ -/* for Quality 2-Dimensional Mesh Generation," Journal of Algorithms */ -/* 18(3):548-585, May 1995 [*], and one due to L. Paul Chew, "Guaranteed- */ -/* Quality Mesh Generation for Curved Surfaces," Proceedings of the Ninth */ -/* Annual Symposium on Computational Geometry (San Diego, California), */ -/* pages 274-280, Association for Computing Machinery, May 1993, */ -/* http://portal.acm.org/citation.cfm?id=161150 . */ -/* */ -/* The Delaunay refinement algorithm has been modified so that it meshes */ -/* domains with small input angles well, as described in Gary L. Miller, */ -/* Steven E. Pav, and Noel J. Walkington, "When and Why Ruppert's */ -/* Algorithm Works," Twelfth International Meshing Roundtable, pages */ -/* 91-102, Sandia National Laboratories, September 2003. [*] */ -/* */ -/* My implementation of the divide-and-conquer and incremental Delaunay */ -/* triangulation algorithms follows closely the presentation of Guibas */ -/* and Stolfi, even though I use a triangle-based data structure instead */ -/* of their quad-edge data structure. (In fact, I originally implemented */ -/* Triangle using the quad-edge data structure, but the switch to a */ -/* triangle-based data structure sped Triangle by a factor of two.) The */ -/* mesh manipulation primitives and the two aforementioned Delaunay */ -/* triangulation algorithms are described by Leonidas J. Guibas and Jorge */ -/* Stolfi, "Primitives for the Manipulation of General Subdivisions and */ -/* the Computation of Voronoi Diagrams," ACM Transactions on Graphics */ -/* 4(2):74-123, April 1985, http://portal.acm.org/citation.cfm?id=282923 .*/ -/* */ -/* Their O(n log n) divide-and-conquer algorithm is adapted from Der-Tsai */ -/* Lee and Bruce J. Schachter, "Two Algorithms for Constructing the */ -/* Delaunay Triangulation," International Journal of Computer and */ -/* Information Science 9(3):219-242, 1980. Triangle's improvement of the */ -/* divide-and-conquer algorithm by alternating between vertical and */ -/* horizontal cuts was introduced by Rex A. Dwyer, "A Faster Divide-and- */ -/* Conquer Algorithm for Constructing Delaunay Triangulations," */ -/* Algorithmica 2(2):137-151, 1987. */ -/* */ -/* The incremental insertion algorithm was first proposed by C. L. Lawson, */ -/* "Software for C1 Surface Interpolation," in Mathematical Software III, */ -/* John R. Rice, editor, Academic Press, New York, pp. 161-194, 1977. */ -/* For point location, I use the algorithm of Ernst P. Mucke, Isaac */ -/* Saias, and Binhai Zhu, "Fast Randomized Point Location Without */ -/* Preprocessing in Two- and Three-Dimensional Delaunay Triangulations," */ -/* Proceedings of the Twelfth Annual Symposium on Computational Geometry, */ -/* ACM, May 1996. [*] If I were to randomize the order of vertex */ -/* insertion (I currently don't bother), their result combined with the */ -/* result of Kenneth L. Clarkson and Peter W. Shor, "Applications of */ -/* Random Sampling in Computational Geometry II," Discrete & */ -/* Computational Geometry 4(1):387-421, 1989, would yield an expected */ -/* O(n^{4/3}) bound on running time. */ -/* */ -/* The O(n log n) sweepline Delaunay triangulation algorithm is taken from */ -/* Steven Fortune, "A Sweepline Algorithm for Voronoi Diagrams", */ -/* Algorithmica 2(2):153-174, 1987. A random sample of edges on the */ -/* boundary of the triangulation are maintained in a splay tree for the */ -/* purpose of point location. Splay trees are described by Daniel */ -/* Dominic Sleator and Robert Endre Tarjan, "Self-Adjusting Binary Search */ -/* Trees," Journal of the ACM 32(3):652-686, July 1985, */ -/* http://portal.acm.org/citation.cfm?id=3835 . */ -/* */ -/* The algorithms for exact computation of the signs of determinants are */ -/* described in Jonathan Richard Shewchuk, "Adaptive Precision Floating- */ -/* Point Arithmetic and Fast Robust Geometric Predicates," Discrete & */ -/* Computational Geometry 18(3):305-363, October 1997. (Also available */ -/* as Technical Report CMU-CS-96-140, School of Computer Science, */ -/* Carnegie Mellon University, Pittsburgh, Pennsylvania, May 1996.) [*] */ -/* An abbreviated version appears as Jonathan Richard Shewchuk, "Robust */ -/* Adaptive Floating-Point Geometric Predicates," Proceedings of the */ -/* Twelfth Annual Symposium on Computational Geometry, ACM, May 1996. [*] */ -/* Many of the ideas for my exact arithmetic routines originate with */ -/* Douglas M. Priest, "Algorithms for Arbitrary Precision Floating Point */ -/* Arithmetic," Tenth Symposium on Computer Arithmetic, pp. 132-143, IEEE */ -/* Computer Society Press, 1991. [*] Many of the ideas for the correct */ -/* evaluation of the signs of determinants are taken from Steven Fortune */ -/* and Christopher J. Van Wyk, "Efficient Exact Arithmetic for Computa- */ -/* tional Geometry," Proceedings of the Ninth Annual Symposium on */ -/* Computational Geometry, ACM, pp. 163-172, May 1993, and from Steven */ -/* Fortune, "Numerical Stability of Algorithms for 2D Delaunay Triangu- */ -/* lations," International Journal of Computational Geometry & Applica- */ -/* tions 5(1-2):193-213, March-June 1995. */ -/* */ -/* The method of inserting new vertices off-center (not precisely at the */ -/* circumcenter of every poor-quality triangle) is from Alper Ungor, */ -/* "Off-centers: A New Type of Steiner Points for Computing Size-Optimal */ -/* Quality-Guaranteed Delaunay Triangulations," Proceedings of LATIN */ -/* 2004 (Buenos Aires, Argentina), April 2004. */ -/* */ -/* For definitions of and results involving Delaunay triangulations, */ -/* constrained and conforming versions thereof, and other aspects of */ -/* triangular mesh generation, see the excellent survey by Marshall Bern */ -/* and David Eppstein, "Mesh Generation and Optimal Triangulation," in */ -/* Computing and Euclidean Geometry, Ding-Zhu Du and Frank Hwang, */ -/* editors, World Scientific, Singapore, pp. 23-90, 1992. [*] */ -/* */ -/* The time for incrementally adding PSLG (planar straight line graph) */ -/* segments to create a constrained Delaunay triangulation is probably */ -/* O(t^2) per segment in the worst case and O(t) per segment in the */ -/* common case, where t is the number of triangles that intersect the */ -/* segment before it is inserted. This doesn't count point location, */ -/* which can be much more expensive. I could improve this to O(d log d) */ -/* time, but d is usually quite small, so it's not worth the bother. */ -/* (This note does not apply when the -s switch is used, invoking a */ -/* different method is used to insert segments.) */ -/* */ -/* The time for deleting a vertex from a Delaunay triangulation is O(d^2) */ -/* in the worst case and O(d) in the common case, where d is the degree */ -/* of the vertex being deleted. I could improve this to O(d log d) time, */ -/* but d is usually quite small, so it's not worth the bother. */ -/* */ -/* Ruppert's Delaunay refinement algorithm typically generates triangles */ -/* at a linear rate (constant time per triangle) after the initial */ -/* triangulation is formed. There may be pathological cases where */ -/* quadratic time is required, but these never arise in practice. */ -/* */ -/* The geometric predicates (circumcenter calculations, segment */ -/* intersection formulae, etc.) appear in my "Lecture Notes on Geometric */ -/* Robustness" at http://www.cs.berkeley.edu/~jrs/mesh . */ -/* */ -/* If you make any improvements to this code, please please please let me */ -/* know, so that I may obtain the improvements. Even if you don't change */ -/* the code, I'd still love to hear what it's being used for. */ -/* */ -/*****************************************************************************/ - -/* For single precision (which will save some memory and reduce paging), */ -/* define the symbol SINGLE by using the -DSINGLE compiler switch or by */ -/* writing "#define SINGLE" below. */ -/* */ -/* For double precision (which will allow you to refine meshes to a smaller */ -/* edge length), leave SINGLE undefined. */ -/* */ -/* Double precision uses more memory, but improves the resolution of the */ -/* meshes you can generate with Triangle. It also reduces the likelihood */ -/* of a floating exception due to overflow. Finally, it is much faster */ -/* than single precision on 64-bit architectures like the DEC Alpha. I */ -/* recommend double precision unless you want to generate a mesh for which */ -/* you do not have enough memory. */ - -/* #define SINGLE */ - -#ifdef SINGLE -#define REAL float -#else /* not SINGLE */ -#define REAL double -#endif /* not SINGLE */ - -/* If yours is not a Unix system, define the NO_TIMER compiler switch to */ -/* remove the Unix-specific timing code. */ - -/* #define NO_TIMER */ - -/* To insert lots of self-checks for internal errors, define the SELF_CHECK */ -/* symbol. This will slow down the program significantly. It is best to */ -/* define the symbol using the -DSELF_CHECK compiler switch, but you could */ -/* write "#define SELF_CHECK" below. If you are modifying this code, I */ -/* recommend you turn self-checks on until your work is debugged. */ - -/* #define SELF_CHECK */ - -/* To compile Triangle as a callable object library (triangle.o), define the */ -/* TRILIBRARY symbol. Read the file triangle.h for details on how to call */ -/* the procedure triangulate() that results. */ - -/* #define TRILIBRARY */ - -/* It is possible to generate a smaller version of Triangle using one or */ -/* both of the following symbols. Define the REDUCED symbol to eliminate */ -/* all features that are primarily of research interest; specifically, the */ -/* -i, -F, -s, and -C switches. Define the CDT_ONLY symbol to eliminate */ -/* all meshing algorithms above and beyond constrained Delaunay */ -/* triangulation; specifically, the -r, -q, -a, -u, -D, -S, and -s */ -/* switches. These reductions are most likely to be useful when */ -/* generating an object library (triangle.o) by defining the TRILIBRARY */ -/* symbol. */ - -/* #define REDUCED */ -/* #define CDT_ONLY */ - -/* On some machines, my exact arithmetic routines might be defeated by the */ -/* use of internal extended precision floating-point registers. The best */ -/* way to solve this problem is to set the floating-point registers to use */ -/* single or double precision internally. On 80x86 processors, this may */ -/* be accomplished by setting the CPU86 symbol for the Microsoft C */ -/* compiler, or the LINUX symbol for the gcc compiler running on Linux. */ -/* */ -/* An inferior solution is to declare certain values as `volatile', thus */ -/* forcing them to be stored to memory and rounded off. Unfortunately, */ -/* this solution might slow Triangle down quite a bit. To use volatile */ -/* values, write "#define INEXACT volatile" below. Normally, however, */ -/* INEXACT should be defined to be nothing. ("#define INEXACT".) */ -/* */ -/* For more discussion, see http://www.cs.cmu.edu/~quake/robust.pc.html . */ -/* For yet more discussion, see Section 5 of my paper, "Adaptive Precision */ -/* Floating-Point Arithmetic and Fast Robust Geometric Predicates" (also */ -/* available as Section 6.6 of my dissertation). */ - -/* #define CPU86 */ -/* #define LINUX */ - -#define INEXACT /* Nothing */ -/* #define INEXACT volatile */ - -/* Maximum number of characters in a file name (including the null). */ - -#define FILENAMESIZE 2048 - -/* Maximum number of characters in a line read from a file (including the */ -/* null). */ - -#define INPUTLINESIZE 1024 - -/* For efficiency, a variety of data structures are allocated in bulk. The */ -/* following constants determine how many of each structure is allocated */ -/* at once. */ - -#define TRIPERBLOCK 4092 /* Number of triangles allocated at once. */ -#define SUBSEGPERBLOCK 508 /* Number of subsegments allocated at once. */ -#define VERTEXPERBLOCK 4092 /* Number of vertices allocated at once. */ -#define VIRUSPERBLOCK 1020 /* Number of virus triangles allocated at once. */ -/* Number of encroached subsegments allocated at once. */ -#define BADSUBSEGPERBLOCK 252 -/* Number of skinny triangles allocated at once. */ -#define BADTRIPERBLOCK 4092 -/* Number of flipped triangles allocated at once. */ -#define FLIPSTACKERPERBLOCK 252 -/* Number of splay tree nodes allocated at once. */ -#define SPLAYNODEPERBLOCK 508 - -/* The vertex types. A DEADVERTEX has been deleted entirely. An */ -/* UNDEADVERTEX is not part of the mesh, but is written to the output */ -/* .node file and affects the node indexing in the other output files. */ - -#define INPUTVERTEX 0 -#define SEGMENTVERTEX 1 -#define FREEVERTEX 2 -#define DEADVERTEX -32768 -#define UNDEADVERTEX -32767 - -/* The next line is used to outsmart some very stupid compilers. If your */ -/* compiler is smarter, feel free to replace the "int" with "void". */ -/* Not that it matters. */ - -#define VOID int - -/* Two constants for algorithms based on random sampling. Both constants */ -/* have been chosen empirically to optimize their respective algorithms. */ - -/* Used for the point location scheme of Mucke, Saias, and Zhu, to decide */ -/* how large a random sample of triangles to inspect. */ - -#define SAMPLEFACTOR 11 - -/* Used in Fortune's sweepline Delaunay algorithm to determine what fraction */ -/* of boundary edges should be maintained in the splay tree for point */ -/* location on the front. */ - -#define SAMPLERATE 10 - -/* A number that speaks for itself, every kissable digit. */ - -#define PI 3.141592653589793238462643383279502884197169399375105820974944592308 - -/* Another fave. */ - -#define SQUAREROOTTWO 1.4142135623730950488016887242096980785696718753769480732 - -/* And here's one for those of you who are intimidated by math. */ - -#define ONETHIRD 0.333333333333333333333333333333333333333333333333333333333333 - -#include -#include -#include -#include -#ifndef NO_TIMER -#include -#endif /* not NO_TIMER */ -#ifdef CPU86 -#include -#endif /* CPU86 */ -#ifdef LINUX -#include -#endif /* LINUX */ -#ifdef TRILIBRARY -#include "triangle.h" -#endif /* TRILIBRARY */ - -/* A few forward declarations. */ - -#ifndef TRILIBRARY -char *readline(); -char *findfield(); -#endif /* not TRILIBRARY */ - -/* Labels that signify the result of point location. The result of a */ -/* search indicates that the point falls in the interior of a triangle, on */ -/* an edge, on a vertex, or outside the mesh. */ - -enum locateresult {INTRIANGLE, ONEDGE, ONVERTEX, OUTSIDE}; - -/* Labels that signify the result of vertex insertion. The result indicates */ -/* that the vertex was inserted with complete success, was inserted but */ -/* encroaches upon a subsegment, was not inserted because it lies on a */ -/* segment, or was not inserted because another vertex occupies the same */ -/* location. */ - -enum insertvertexresult {SUCCESSFULVERTEX, ENCROACHINGVERTEX, VIOLATINGVERTEX, - DUPLICATEVERTEX}; - -/* Labels that signify the result of direction finding. The result */ -/* indicates that a segment connecting the two query points falls within */ -/* the direction triangle, along the left edge of the direction triangle, */ -/* or along the right edge of the direction triangle. */ - -enum finddirectionresult {WITHIN, LEFTCOLLINEAR, RIGHTCOLLINEAR}; - -/*****************************************************************************/ -/* */ -/* The basic mesh data structures */ -/* */ -/* There are three: vertices, triangles, and subsegments (abbreviated */ -/* `subseg'). These three data structures, linked by pointers, comprise */ -/* the mesh. A vertex simply represents a mesh vertex and its properties. */ -/* A triangle is a triangle. A subsegment is a special data structure used */ -/* to represent an impenetrable edge of the mesh (perhaps on the outer */ -/* boundary, on the boundary of a hole, or part of an internal boundary */ -/* separating two triangulated regions). Subsegments represent boundaries, */ -/* defined by the user, that triangles may not lie across. */ -/* */ -/* A triangle consists of a list of three vertices, a list of three */ -/* adjoining triangles, a list of three adjoining subsegments (when */ -/* segments exist), an arbitrary number of optional user-defined */ -/* floating-point attributes, and an optional area constraint. The latter */ -/* is an upper bound on the permissible area of each triangle in a region, */ -/* used for mesh refinement. */ -/* */ -/* For a triangle on a boundary of the mesh, some or all of the neighboring */ -/* triangles may not be present. For a triangle in the interior of the */ -/* mesh, often no neighboring subsegments are present. Such absent */ -/* triangles and subsegments are never represented by NULL pointers; they */ -/* are represented by two special records: `dummytri', the triangle that */ -/* fills "outer space", and `dummysub', the omnipresent subsegment. */ -/* `dummytri' and `dummysub' are used for several reasons; for instance, */ -/* they can be dereferenced and their contents examined without violating */ -/* protected memory. */ -/* */ -/* However, it is important to understand that a triangle includes other */ -/* information as well. The pointers to adjoining vertices, triangles, and */ -/* subsegments are ordered in a way that indicates their geometric relation */ -/* to each other. Furthermore, each of these pointers contains orientation */ -/* information. Each pointer to an adjoining triangle indicates which face */ -/* of that triangle is contacted. Similarly, each pointer to an adjoining */ -/* subsegment indicates which side of that subsegment is contacted, and how */ -/* the subsegment is oriented relative to the triangle. */ -/* */ -/* The data structure representing a subsegment may be thought to be */ -/* abutting the edge of one or two triangle data structures: either */ -/* sandwiched between two triangles, or resting against one triangle on an */ -/* exterior boundary or hole boundary. */ -/* */ -/* A subsegment consists of a list of four vertices--the vertices of the */ -/* subsegment, and the vertices of the segment it is a part of--a list of */ -/* two adjoining subsegments, and a list of two adjoining triangles. One */ -/* of the two adjoining triangles may not be present (though there should */ -/* always be one), and neighboring subsegments might not be present. */ -/* Subsegments also store a user-defined integer "boundary marker". */ -/* Typically, this integer is used to indicate what boundary conditions are */ -/* to be applied at that location in a finite element simulation. */ -/* */ -/* Like triangles, subsegments maintain information about the relative */ -/* orientation of neighboring objects. */ -/* */ -/* Vertices are relatively simple. A vertex is a list of floating-point */ -/* numbers, starting with the x, and y coordinates, followed by an */ -/* arbitrary number of optional user-defined floating-point attributes, */ -/* followed by an integer boundary marker. During the segment insertion */ -/* phase, there is also a pointer from each vertex to a triangle that may */ -/* contain it. Each pointer is not always correct, but when one is, it */ -/* speeds up segment insertion. These pointers are assigned values once */ -/* at the beginning of the segment insertion phase, and are not used or */ -/* updated except during this phase. Edge flipping during segment */ -/* insertion will render some of them incorrect. Hence, don't rely upon */ -/* them for anything. */ -/* */ -/* Other than the exception mentioned above, vertices have no information */ -/* about what triangles, subfacets, or subsegments they are linked to. */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* Handles */ -/* */ -/* The oriented triangle (`otri') and oriented subsegment (`osub') data */ -/* structures defined below do not themselves store any part of the mesh. */ -/* The mesh itself is made of `triangle's, `subseg's, and `vertex's. */ -/* */ -/* Oriented triangles and oriented subsegments will usually be referred to */ -/* as "handles." A handle is essentially a pointer into the mesh; it */ -/* allows you to "hold" one particular part of the mesh. Handles are used */ -/* to specify the regions in which one is traversing and modifying the mesh.*/ -/* A single `triangle' may be held by many handles, or none at all. (The */ -/* latter case is not a memory leak, because the triangle is still */ -/* connected to other triangles in the mesh.) */ -/* */ -/* An `otri' is a handle that holds a triangle. It holds a specific edge */ -/* of the triangle. An `osub' is a handle that holds a subsegment. It */ -/* holds either the left or right side of the subsegment. */ -/* */ -/* Navigation about the mesh is accomplished through a set of mesh */ -/* manipulation primitives, further below. Many of these primitives take */ -/* a handle and produce a new handle that holds the mesh near the first */ -/* handle. Other primitives take two handles and glue the corresponding */ -/* parts of the mesh together. The orientation of the handles is */ -/* important. For instance, when two triangles are glued together by the */ -/* bond() primitive, they are glued at the edges on which the handles lie. */ -/* */ -/* Because vertices have no information about which triangles they are */ -/* attached to, I commonly represent a vertex by use of a handle whose */ -/* origin is the vertex. A single handle can simultaneously represent a */ -/* triangle, an edge, and a vertex. */ -/* */ -/*****************************************************************************/ - -/* The triangle data structure. Each triangle contains three pointers to */ -/* adjoining triangles, plus three pointers to vertices, plus three */ -/* pointers to subsegments (declared below; these pointers are usually */ -/* `dummysub'). It may or may not also contain user-defined attributes */ -/* and/or a floating-point "area constraint." It may also contain extra */ -/* pointers for nodes, when the user asks for high-order elements. */ -/* Because the size and structure of a `triangle' is not decided until */ -/* runtime, I haven't simply declared the type `triangle' as a struct. */ - -typedef REAL **triangle; /* Really: typedef triangle *triangle */ - -/* An oriented triangle: includes a pointer to a triangle and orientation. */ -/* The orientation denotes an edge of the triangle. Hence, there are */ -/* three possible orientations. By convention, each edge always points */ -/* counterclockwise about the corresponding triangle. */ - -struct otri { - triangle *tri; - int orient; /* Ranges from 0 to 2. */ -}; - -/* The subsegment data structure. Each subsegment contains two pointers to */ -/* adjoining subsegments, plus four pointers to vertices, plus two */ -/* pointers to adjoining triangles, plus one boundary marker, plus one */ -/* segment number. */ - -typedef REAL **subseg; /* Really: typedef subseg *subseg */ - -/* An oriented subsegment: includes a pointer to a subsegment and an */ -/* orientation. The orientation denotes a side of the edge. Hence, there */ -/* are two possible orientations. By convention, the edge is always */ -/* directed so that the "side" denoted is the right side of the edge. */ - -struct osub { - subseg *ss; - int ssorient; /* Ranges from 0 to 1. */ -}; - -/* The vertex data structure. Each vertex is actually an array of REALs. */ -/* The number of REALs is unknown until runtime. An integer boundary */ -/* marker, and sometimes a pointer to a triangle, is appended after the */ -/* REALs. */ - -typedef REAL *vertex; - -/* A queue used to store encroached subsegments. Each subsegment's vertices */ -/* are stored so that we can check whether a subsegment is still the same. */ - -struct badsubseg { - subseg encsubseg; /* An encroached subsegment. */ - vertex subsegorg, subsegdest; /* Its two vertices. */ -}; - -/* A queue used to store bad triangles. The key is the square of the cosine */ -/* of the smallest angle of the triangle. Each triangle's vertices are */ -/* stored so that one can check whether a triangle is still the same. */ - -struct badtriang { - triangle poortri; /* A skinny or too-large triangle. */ - REAL key; /* cos^2 of smallest (apical) angle. */ - vertex triangorg, triangdest, triangapex; /* Its three vertices. */ - struct badtriang *nexttriang; /* Pointer to next bad triangle. */ -}; - -/* A stack of triangles flipped during the most recent vertex insertion. */ -/* The stack is used to undo the vertex insertion if the vertex encroaches */ -/* upon a subsegment. */ - -struct flipstacker { - triangle flippedtri; /* A recently flipped triangle. */ - struct flipstacker *prevflip; /* Previous flip in the stack. */ -}; - -/* A node in a heap used to store events for the sweepline Delaunay */ -/* algorithm. Nodes do not point directly to their parents or children in */ -/* the heap. Instead, each node knows its position in the heap, and can */ -/* look up its parent and children in a separate array. The `eventptr' */ -/* points either to a `vertex' or to a triangle (in encoded format, so */ -/* that an orientation is included). In the latter case, the origin of */ -/* the oriented triangle is the apex of a "circle event" of the sweepline */ -/* algorithm. To distinguish site events from circle events, all circle */ -/* events are given an invalid (smaller than `xmin') x-coordinate `xkey'. */ - -struct event { - REAL xkey, ykey; /* Coordinates of the event. */ - VOID *eventptr; /* Can be a vertex or the location of a circle event. */ - int heapposition; /* Marks this event's position in the heap. */ -}; - -/* A node in the splay tree. Each node holds an oriented ghost triangle */ -/* that represents a boundary edge of the growing triangulation. When a */ -/* circle event covers two boundary edges with a triangle, so that they */ -/* are no longer boundary edges, those edges are not immediately deleted */ -/* from the tree; rather, they are lazily deleted when they are next */ -/* encountered. (Since only a random sample of boundary edges are kept */ -/* in the tree, lazy deletion is faster.) `keydest' is used to verify */ -/* that a triangle is still the same as when it entered the splay tree; if */ -/* it has been rotated (due to a circle event), it no longer represents a */ -/* boundary edge and should be deleted. */ - -struct splaynode { - struct otri keyedge; /* Lprev of an edge on the front. */ - vertex keydest; /* Used to verify that splay node is still live. */ - struct splaynode *lchild, *rchild; /* Children in splay tree. */ -}; - -/* A type used to allocate memory. firstblock is the first block of items. */ -/* nowblock is the block from which items are currently being allocated. */ -/* nextitem points to the next slab of free memory for an item. */ -/* deaditemstack is the head of a linked list (stack) of deallocated items */ -/* that can be recycled. unallocateditems is the number of items that */ -/* remain to be allocated from nowblock. */ -/* */ -/* Traversal is the process of walking through the entire list of items, and */ -/* is separate from allocation. Note that a traversal will visit items on */ -/* the "deaditemstack" stack as well as live items. pathblock points to */ -/* the block currently being traversed. pathitem points to the next item */ -/* to be traversed. pathitemsleft is the number of items that remain to */ -/* be traversed in pathblock. */ -/* */ -/* alignbytes determines how new records should be aligned in memory. */ -/* itembytes is the length of a record in bytes (after rounding up). */ -/* itemsperblock is the number of items allocated at once in a single */ -/* block. itemsfirstblock is the number of items in the first block, */ -/* which can vary from the others. items is the number of currently */ -/* allocated items. maxitems is the maximum number of items that have */ -/* been allocated at once; it is the current number of items plus the */ -/* number of records kept on deaditemstack. */ - -struct memorypool { - VOID **firstblock, **nowblock; - VOID *nextitem; - VOID *deaditemstack; - VOID **pathblock; - VOID *pathitem; - int alignbytes; - int itembytes; - int itemsperblock; - int itemsfirstblock; - long items, maxitems; - int unallocateditems; - int pathitemsleft; -}; - - -/* Global constants. */ - -REAL splitter; /* Used to split REAL factors for exact multiplication. */ -REAL epsilon; /* Floating-point machine epsilon. */ -REAL resulterrbound; -REAL ccwerrboundA, ccwerrboundB, ccwerrboundC; -REAL iccerrboundA, iccerrboundB, iccerrboundC; -REAL o3derrboundA, o3derrboundB, o3derrboundC; - -/* Random number seed is not constant, but I've made it global anyway. */ - -unsigned long randomseed; /* Current random number seed. */ - - -/* Mesh data structure. Triangle operates on only one mesh, but the mesh */ -/* structure is used (instead of global variables) to allow reentrancy. */ - -struct mesh { - -/* Variables used to allocate memory for triangles, subsegments, vertices, */ -/* viri (triangles being eaten), encroached segments, bad (skinny or too */ -/* large) triangles, and splay tree nodes. */ - - struct memorypool triangles; - struct memorypool subsegs; - struct memorypool vertices; - struct memorypool viri; - struct memorypool badsubsegs; - struct memorypool badtriangles; - struct memorypool flipstackers; - struct memorypool splaynodes; - -/* Variables that maintain the bad triangle queues. The queues are */ -/* ordered from 4095 (highest priority) to 0 (lowest priority). */ - - struct badtriang *queuefront[4096]; - struct badtriang *queuetail[4096]; - int nextnonemptyq[4096]; - int firstnonemptyq; - -/* Variable that maintains the stack of recently flipped triangles. */ - - struct flipstacker *lastflip; - -/* Other variables. */ - - REAL xmin, xmax, ymin, ymax; /* x and y bounds. */ - REAL xminextreme; /* Nonexistent x value used as a flag in sweepline. */ - int invertices; /* Number of input vertices. */ - int inelements; /* Number of input triangles. */ - int insegments; /* Number of input segments. */ - int holes; /* Number of input holes. */ - int regions; /* Number of input regions. */ - int undeads; /* Number of input vertices that don't appear in the mesh. */ - long edges; /* Number of output edges. */ - int mesh_dim; /* Dimension (ought to be 2). */ - int nextras; /* Number of attributes per vertex. */ - int eextras; /* Number of attributes per triangle. */ - long hullsize; /* Number of edges in convex hull. */ - int steinerleft; /* Number of Steiner points not yet used. */ - int vertexmarkindex; /* Index to find boundary marker of a vertex. */ - int vertex2triindex; /* Index to find a triangle adjacent to a vertex. */ - int highorderindex; /* Index to find extra nodes for high-order elements. */ - int elemattribindex; /* Index to find attributes of a triangle. */ - int areaboundindex; /* Index to find area bound of a triangle. */ - int checksegments; /* Are there segments in the triangulation yet? */ - int checkquality; /* Has quality triangulation begun yet? */ - int readnodefile; /* Has a .node file been read? */ - long samples; /* Number of random samples for point location. */ - - long incirclecount; /* Number of incircle tests performed. */ - long counterclockcount; /* Number of counterclockwise tests performed. */ - long orient3dcount; /* Number of 3D orientation tests performed. */ - long hyperbolacount; /* Number of right-of-hyperbola tests performed. */ - long circumcentercount; /* Number of circumcenter calculations performed. */ - long circletopcount; /* Number of circle top calculations performed. */ - -/* Triangular bounding box vertices. */ - - vertex infvertex1, infvertex2, infvertex3; - -/* Pointer to the `triangle' that occupies all of "outer space." */ - - triangle *dummytri; - triangle *dummytribase; /* Keep base address so we can free() it later. */ - -/* Pointer to the omnipresent subsegment. Referenced by any triangle or */ -/* subsegment that isn't really connected to a subsegment at that */ -/* location. */ - - subseg *dummysub; - subseg *dummysubbase; /* Keep base address so we can free() it later. */ - -/* Pointer to a recently visited triangle. Improves point location if */ -/* proximate vertices are inserted sequentially. */ - - struct otri recenttri; - -}; /* End of `struct mesh'. */ - - -/* Data structure for command line switches and file names. This structure */ -/* is used (instead of global variables) to allow reentrancy. */ - -struct behavior { - -/* Switches for the triangulator. */ -/* poly: -p switch. refine: -r switch. */ -/* quality: -q switch. */ -/* minangle: minimum angle bound, specified after -q switch. */ -/* goodangle: cosine squared of minangle. */ -/* offconstant: constant used to place off-center Steiner points. */ -/* vararea: -a switch without number. */ -/* fixedarea: -a switch with number. */ -/* maxarea: maximum area bound, specified after -a switch. */ -/* usertest: -u switch. */ -/* regionattrib: -A switch. convex: -c switch. */ -/* weighted: 1 for -w switch, 2 for -W switch. jettison: -j switch */ -/* firstnumber: inverse of -z switch. All items are numbered starting */ -/* from `firstnumber'. */ -/* edgesout: -e switch. voronoi: -v switch. */ -/* neighbors: -n switch. geomview: -g switch. */ -/* nobound: -B switch. nopolywritten: -P switch. */ -/* nonodewritten: -N switch. noelewritten: -E switch. */ -/* noiterationnum: -I switch. noholes: -O switch. */ -/* noexact: -X switch. */ -/* order: element order, specified after -o switch. */ -/* nobisect: count of how often -Y switch is selected. */ -/* steiner: maximum number of Steiner points, specified after -S switch. */ -/* incremental: -i switch. sweepline: -F switch. */ -/* dwyer: inverse of -l switch. */ -/* splitseg: -s switch. */ -/* conformdel: -D switch. docheck: -C switch. */ -/* quiet: -Q switch. verbose: count of how often -V switch is selected. */ -/* usesegments: -p, -r, -q, or -c switch; determines whether segments are */ -/* used at all. */ -/* */ -/* Read the instructions to find out the meaning of these switches. */ - - int poly, refine, quality, vararea, fixedarea, usertest; - int regionattrib, convex, weighted, jettison; - int firstnumber; - int edgesout, voronoi, neighbors, geomview; - int nobound, nopolywritten, nonodewritten, noelewritten, noiterationnum; - int noholes, noexact, conformdel; - int incremental, sweepline, dwyer; - int splitseg; - int docheck; - int quiet, verbose; - int usesegments; - int order; - int nobisect; - int steiner; - REAL minangle, goodangle, offconstant; - REAL maxarea; - -/* Variables for file names. */ - -#ifndef TRILIBRARY - char innodefilename[FILENAMESIZE]; - char inelefilename[FILENAMESIZE]; - char inpolyfilename[FILENAMESIZE]; - char areafilename[FILENAMESIZE]; - char outnodefilename[FILENAMESIZE]; - char outelefilename[FILENAMESIZE]; - char outpolyfilename[FILENAMESIZE]; - char edgefilename[FILENAMESIZE]; - char vnodefilename[FILENAMESIZE]; - char vedgefilename[FILENAMESIZE]; - char neighborfilename[FILENAMESIZE]; - char offfilename[FILENAMESIZE]; -#endif /* not TRILIBRARY */ - -}; /* End of `struct behavior'. */ - - -/*****************************************************************************/ -/* */ -/* Mesh manipulation primitives. Each triangle contains three pointers to */ -/* other triangles, with orientations. Each pointer points not to the */ -/* first byte of a triangle, but to one of the first three bytes of a */ -/* triangle. It is necessary to extract both the triangle itself and the */ -/* orientation. To save memory, I keep both pieces of information in one */ -/* pointer. To make this possible, I assume that all triangles are aligned */ -/* to four-byte boundaries. The decode() routine below decodes a pointer, */ -/* extracting an orientation (in the range 0 to 2) and a pointer to the */ -/* beginning of a triangle. The encode() routine compresses a pointer to a */ -/* triangle and an orientation into a single pointer. My assumptions that */ -/* triangles are four-byte-aligned and that the `unsigned long' type is */ -/* long enough to hold a pointer are two of the few kludges in this program.*/ -/* */ -/* Subsegments are manipulated similarly. A pointer to a subsegment */ -/* carries both an address and an orientation in the range 0 to 1. */ -/* */ -/* The other primitives take an oriented triangle or oriented subsegment, */ -/* and return an oriented triangle or oriented subsegment or vertex; or */ -/* they change the connections in the data structure. */ -/* */ -/* Below, triangles and subsegments are denoted by their vertices. The */ -/* triangle abc has origin (org) a, destination (dest) b, and apex (apex) */ -/* c. These vertices occur in counterclockwise order about the triangle. */ -/* The handle abc may simultaneously denote vertex a, edge ab, and triangle */ -/* abc. */ -/* */ -/* Similarly, the subsegment ab has origin (sorg) a and destination (sdest) */ -/* b. If ab is thought to be directed upward (with b directly above a), */ -/* then the handle ab is thought to grasp the right side of ab, and may */ -/* simultaneously denote vertex a and edge ab. */ -/* */ -/* An asterisk (*) denotes a vertex whose identity is unknown. */ -/* */ -/* Given this notation, a partial list of mesh manipulation primitives */ -/* follows. */ -/* */ -/* */ -/* For triangles: */ -/* */ -/* sym: Find the abutting triangle; same edge. */ -/* sym(abc) -> ba* */ -/* */ -/* lnext: Find the next edge (counterclockwise) of a triangle. */ -/* lnext(abc) -> bca */ -/* */ -/* lprev: Find the previous edge (clockwise) of a triangle. */ -/* lprev(abc) -> cab */ -/* */ -/* onext: Find the next edge counterclockwise with the same origin. */ -/* onext(abc) -> ac* */ -/* */ -/* oprev: Find the next edge clockwise with the same origin. */ -/* oprev(abc) -> a*b */ -/* */ -/* dnext: Find the next edge counterclockwise with the same destination. */ -/* dnext(abc) -> *ba */ -/* */ -/* dprev: Find the next edge clockwise with the same destination. */ -/* dprev(abc) -> cb* */ -/* */ -/* rnext: Find the next edge (counterclockwise) of the adjacent triangle. */ -/* rnext(abc) -> *a* */ -/* */ -/* rprev: Find the previous edge (clockwise) of the adjacent triangle. */ -/* rprev(abc) -> b** */ -/* */ -/* org: Origin dest: Destination apex: Apex */ -/* org(abc) -> a dest(abc) -> b apex(abc) -> c */ -/* */ -/* bond: Bond two triangles together at the resepective handles. */ -/* bond(abc, bad) */ -/* */ -/* */ -/* For subsegments: */ -/* */ -/* ssym: Reverse the orientation of a subsegment. */ -/* ssym(ab) -> ba */ -/* */ -/* spivot: Find adjoining subsegment with the same origin. */ -/* spivot(ab) -> a* */ -/* */ -/* snext: Find next subsegment in sequence. */ -/* snext(ab) -> b* */ -/* */ -/* sorg: Origin sdest: Destination */ -/* sorg(ab) -> a sdest(ab) -> b */ -/* */ -/* sbond: Bond two subsegments together at the respective origins. */ -/* sbond(ab, ac) */ -/* */ -/* */ -/* For interacting tetrahedra and subfacets: */ -/* */ -/* tspivot: Find a subsegment abutting a triangle. */ -/* tspivot(abc) -> ba */ -/* */ -/* stpivot: Find a triangle abutting a subsegment. */ -/* stpivot(ab) -> ba* */ -/* */ -/* tsbond: Bond a triangle to a subsegment. */ -/* tsbond(abc, ba) */ -/* */ -/*****************************************************************************/ - -/********* Mesh manipulation primitives begin here *********/ -/** **/ -/** **/ - -/* Fast lookup arrays to speed some of the mesh manipulation primitives. */ - -int plus1mod3[3] = {1, 2, 0}; -int minus1mod3[3] = {2, 0, 1}; - -/********* Primitives for triangles *********/ -/* */ -/* */ - -/* decode() converts a pointer to an oriented triangle. The orientation is */ -/* extracted from the two least significant bits of the pointer. */ - -#define decode(ptr, otri) \ - (otri).orient = (int) ((unsigned long) (ptr) & (unsigned long) 3l); \ - (otri).tri = (triangle *) \ - ((unsigned long) (ptr) ^ (unsigned long) (otri).orient) - -/* encode() compresses an oriented triangle into a single pointer. It */ -/* relies on the assumption that all triangles are aligned to four-byte */ -/* boundaries, so the two least significant bits of (otri).tri are zero. */ - -#define encode(otri) \ - (triangle) ((unsigned long) (otri).tri | (unsigned long) (otri).orient) - -/* The following handle manipulation primitives are all described by Guibas */ -/* and Stolfi. However, Guibas and Stolfi use an edge-based data */ -/* structure, whereas I use a triangle-based data structure. */ - -/* sym() finds the abutting triangle, on the same edge. Note that the edge */ -/* direction is necessarily reversed, because the handle specified by an */ -/* oriented triangle is directed counterclockwise around the triangle. */ - -#define sym(otri1, otri2) \ - ptr = (otri1).tri[(otri1).orient]; \ - decode(ptr, otri2); - -#define symself(otri) \ - ptr = (otri).tri[(otri).orient]; \ - decode(ptr, otri); - -/* lnext() finds the next edge (counterclockwise) of a triangle. */ - -#define lnext(otri1, otri2) \ - (otri2).tri = (otri1).tri; \ - (otri2).orient = plus1mod3[(otri1).orient] - -#define lnextself(otri) \ - (otri).orient = plus1mod3[(otri).orient] - -/* lprev() finds the previous edge (clockwise) of a triangle. */ - -#define lprev(otri1, otri2) \ - (otri2).tri = (otri1).tri; \ - (otri2).orient = minus1mod3[(otri1).orient] - -#define lprevself(otri) \ - (otri).orient = minus1mod3[(otri).orient] - -/* onext() spins counterclockwise around a vertex; that is, it finds the */ -/* next edge with the same origin in the counterclockwise direction. This */ -/* edge is part of a different triangle. */ - -#define onext(otri1, otri2) \ - lprev(otri1, otri2); \ - symself(otri2); - -#define onextself(otri) \ - lprevself(otri); \ - symself(otri); - -/* oprev() spins clockwise around a vertex; that is, it finds the next edge */ -/* with the same origin in the clockwise direction. This edge is part of */ -/* a different triangle. */ - -#define oprev(otri1, otri2) \ - sym(otri1, otri2); \ - lnextself(otri2); - -#define oprevself(otri) \ - symself(otri); \ - lnextself(otri); - -/* dnext() spins counterclockwise around a vertex; that is, it finds the */ -/* next edge with the same destination in the counterclockwise direction. */ -/* This edge is part of a different triangle. */ - -#define dnext(otri1, otri2) \ - sym(otri1, otri2); \ - lprevself(otri2); - -#define dnextself(otri) \ - symself(otri); \ - lprevself(otri); - -/* dprev() spins clockwise around a vertex; that is, it finds the next edge */ -/* with the same destination in the clockwise direction. This edge is */ -/* part of a different triangle. */ - -#define dprev(otri1, otri2) \ - lnext(otri1, otri2); \ - symself(otri2); - -#define dprevself(otri) \ - lnextself(otri); \ - symself(otri); - -/* rnext() moves one edge counterclockwise about the adjacent triangle. */ -/* (It's best understood by reading Guibas and Stolfi. It involves */ -/* changing triangles twice.) */ - -#define rnext(otri1, otri2) \ - sym(otri1, otri2); \ - lnextself(otri2); \ - symself(otri2); - -#define rnextself(otri) \ - symself(otri); \ - lnextself(otri); \ - symself(otri); - -/* rprev() moves one edge clockwise about the adjacent triangle. */ -/* (It's best understood by reading Guibas and Stolfi. It involves */ -/* changing triangles twice.) */ - -#define rprev(otri1, otri2) \ - sym(otri1, otri2); \ - lprevself(otri2); \ - symself(otri2); - -#define rprevself(otri) \ - symself(otri); \ - lprevself(otri); \ - symself(otri); - -/* These primitives determine or set the origin, destination, or apex of a */ -/* triangle. */ - -#define org(otri, vertexptr) \ - vertexptr = (vertex) (otri).tri[plus1mod3[(otri).orient] + 3] - -#define dest(otri, vertexptr) \ - vertexptr = (vertex) (otri).tri[minus1mod3[(otri).orient] + 3] - -#define apex(otri, vertexptr) \ - vertexptr = (vertex) (otri).tri[(otri).orient + 3] - -#define setorg(otri, vertexptr) \ - (otri).tri[plus1mod3[(otri).orient] + 3] = (triangle) vertexptr - -#define setdest(otri, vertexptr) \ - (otri).tri[minus1mod3[(otri).orient] + 3] = (triangle) vertexptr - -#define setapex(otri, vertexptr) \ - (otri).tri[(otri).orient + 3] = (triangle) vertexptr - -/* Bond two triangles together. */ - -#define bond(otri1, otri2) \ - (otri1).tri[(otri1).orient] = encode(otri2); \ - (otri2).tri[(otri2).orient] = encode(otri1) - -/* Dissolve a bond (from one side). Note that the other triangle will still */ -/* think it's connected to this triangle. Usually, however, the other */ -/* triangle is being deleted entirely, or bonded to another triangle, so */ -/* it doesn't matter. */ - -#define dissolve(otri) \ - (otri).tri[(otri).orient] = (triangle) m->dummytri - -/* Copy an oriented triangle. */ - -#define otricopy(otri1, otri2) \ - (otri2).tri = (otri1).tri; \ - (otri2).orient = (otri1).orient - -/* Test for equality of oriented triangles. */ - -#define otriequal(otri1, otri2) \ - (((otri1).tri == (otri2).tri) && \ - ((otri1).orient == (otri2).orient)) - -/* Primitives to infect or cure a triangle with the virus. These rely on */ -/* the assumption that all subsegments are aligned to four-byte boundaries.*/ - -#define infect(otri) \ - (otri).tri[6] = (triangle) \ - ((unsigned long) (otri).tri[6] | (unsigned long) 2l) - -#define uninfect(otri) \ - (otri).tri[6] = (triangle) \ - ((unsigned long) (otri).tri[6] & ~ (unsigned long) 2l) - -/* Test a triangle for viral infection. */ - -#define infected(otri) \ - (((unsigned long) (otri).tri[6] & (unsigned long) 2l) != 0l) - -/* Check or set a triangle's attributes. */ - -#define elemattribute(otri, attnum) \ - ((REAL *) (otri).tri)[m->elemattribindex + (attnum)] - -#define setelemattribute(otri, attnum, value) \ - ((REAL *) (otri).tri)[m->elemattribindex + (attnum)] = value - -/* Check or set a triangle's maximum area bound. */ - -#define areabound(otri) ((REAL *) (otri).tri)[m->areaboundindex] - -#define setareabound(otri, value) \ - ((REAL *) (otri).tri)[m->areaboundindex] = value - -/* Check or set a triangle's deallocation. Its second pointer is set to */ -/* NULL to indicate that it is not allocated. (Its first pointer is used */ -/* for the stack of dead items.) Its fourth pointer (its first vertex) */ -/* is set to NULL in case a `badtriang' structure points to it. */ - -#define deadtri(tria) ((tria)[1] == (triangle) NULL) - -#define killtri(tria) \ - (tria)[1] = (triangle) NULL; \ - (tria)[3] = (triangle) NULL - -/********* Primitives for subsegments *********/ -/* */ -/* */ - -/* sdecode() converts a pointer to an oriented subsegment. The orientation */ -/* is extracted from the least significant bit of the pointer. The two */ -/* least significant bits (one for orientation, one for viral infection) */ -/* are masked out to produce the real pointer. */ - -#define sdecode(sptr, osub) \ - (osub).ssorient = (int) ((unsigned long) (sptr) & (unsigned long) 1l); \ - (osub).ss = (subseg *) \ - ((unsigned long) (sptr) & ~ (unsigned long) 3l) - -/* sencode() compresses an oriented subsegment into a single pointer. It */ -/* relies on the assumption that all subsegments are aligned to two-byte */ -/* boundaries, so the least significant bit of (osub).ss is zero. */ - -#define sencode(osub) \ - (subseg) ((unsigned long) (osub).ss | (unsigned long) (osub).ssorient) - -/* ssym() toggles the orientation of a subsegment. */ - -#define ssym(osub1, osub2) \ - (osub2).ss = (osub1).ss; \ - (osub2).ssorient = 1 - (osub1).ssorient - -#define ssymself(osub) \ - (osub).ssorient = 1 - (osub).ssorient - -/* spivot() finds the other subsegment (from the same segment) that shares */ -/* the same origin. */ - -#define spivot(osub1, osub2) \ - sptr = (osub1).ss[(osub1).ssorient]; \ - sdecode(sptr, osub2) - -#define spivotself(osub) \ - sptr = (osub).ss[(osub).ssorient]; \ - sdecode(sptr, osub) - -/* snext() finds the next subsegment (from the same segment) in sequence; */ -/* one whose origin is the input subsegment's destination. */ - -#define snext(osub1, osub2) \ - sptr = (osub1).ss[1 - (osub1).ssorient]; \ - sdecode(sptr, osub2) - -#define snextself(osub) \ - sptr = (osub).ss[1 - (osub).ssorient]; \ - sdecode(sptr, osub) - -/* These primitives determine or set the origin or destination of a */ -/* subsegment or the segment that includes it. */ - -#define sorg(osub, vertexptr) \ - vertexptr = (vertex) (osub).ss[2 + (osub).ssorient] - -#define sdest(osub, vertexptr) \ - vertexptr = (vertex) (osub).ss[3 - (osub).ssorient] - -#define setsorg(osub, vertexptr) \ - (osub).ss[2 + (osub).ssorient] = (subseg) vertexptr - -#define setsdest(osub, vertexptr) \ - (osub).ss[3 - (osub).ssorient] = (subseg) vertexptr - -#define segorg(osub, vertexptr) \ - vertexptr = (vertex) (osub).ss[4 + (osub).ssorient] - -#define segdest(osub, vertexptr) \ - vertexptr = (vertex) (osub).ss[5 - (osub).ssorient] - -#define setsegorg(osub, vertexptr) \ - (osub).ss[4 + (osub).ssorient] = (subseg) vertexptr - -#define setsegdest(osub, vertexptr) \ - (osub).ss[5 - (osub).ssorient] = (subseg) vertexptr - -/* These primitives read or set a boundary marker. Boundary markers are */ -/* used to hold user-defined tags for setting boundary conditions in */ -/* finite element solvers. */ - -#define mark(osub) (* (int *) ((osub).ss + 8)) - -#define setmark(osub, value) \ - * (int *) ((osub).ss + 8) = value - -/* Bond two subsegments together. */ - -#define sbond(osub1, osub2) \ - (osub1).ss[(osub1).ssorient] = sencode(osub2); \ - (osub2).ss[(osub2).ssorient] = sencode(osub1) - -/* Dissolve a subsegment bond (from one side). Note that the other */ -/* subsegment will still think it's connected to this subsegment. */ - -#define sdissolve(osub) \ - (osub).ss[(osub).ssorient] = (subseg) m->dummysub - -/* Copy a subsegment. */ - -#define subsegcopy(osub1, osub2) \ - (osub2).ss = (osub1).ss; \ - (osub2).ssorient = (osub1).ssorient - -/* Test for equality of subsegments. */ - -#define subsegequal(osub1, osub2) \ - (((osub1).ss == (osub2).ss) && \ - ((osub1).ssorient == (osub2).ssorient)) - -/* Check or set a subsegment's deallocation. Its second pointer is set to */ -/* NULL to indicate that it is not allocated. (Its first pointer is used */ -/* for the stack of dead items.) Its third pointer (its first vertex) */ -/* is set to NULL in case a `badsubseg' structure points to it. */ - -#define deadsubseg(sub) ((sub)[1] == (subseg) NULL) - -#define killsubseg(sub) \ - (sub)[1] = (subseg) NULL; \ - (sub)[2] = (subseg) NULL - -/********* Primitives for interacting triangles and subsegments *********/ -/* */ -/* */ - -/* tspivot() finds a subsegment abutting a triangle. */ - -#define tspivot(otri, osub) \ - sptr = (subseg) (otri).tri[6 + (otri).orient]; \ - sdecode(sptr, osub) - -/* stpivot() finds a triangle abutting a subsegment. It requires that the */ -/* variable `ptr' of type `triangle' be defined. */ - -#define stpivot(osub, otri) \ - ptr = (triangle) (osub).ss[6 + (osub).ssorient]; \ - decode(ptr, otri) - -/* Bond a triangle to a subsegment. */ - -#define tsbond(otri, osub) \ - (otri).tri[6 + (otri).orient] = (triangle) sencode(osub); \ - (osub).ss[6 + (osub).ssorient] = (subseg) encode(otri) - -/* Dissolve a bond (from the triangle side). */ - -#define tsdissolve(otri) \ - (otri).tri[6 + (otri).orient] = (triangle) m->dummysub - -/* Dissolve a bond (from the subsegment side). */ - -#define stdissolve(osub) \ - (osub).ss[6 + (osub).ssorient] = (subseg) m->dummytri - -/********* Primitives for vertices *********/ -/* */ -/* */ - -#define vertexmark(vx) ((int *) (vx))[m->vertexmarkindex] - -#define setvertexmark(vx, value) \ - ((int *) (vx))[m->vertexmarkindex] = value - -#define vertextype(vx) ((int *) (vx))[m->vertexmarkindex + 1] - -#define setvertextype(vx, value) \ - ((int *) (vx))[m->vertexmarkindex + 1] = value - -#define vertex2tri(vx) ((triangle *) (vx))[m->vertex2triindex] - -#define setvertex2tri(vx, value) \ - ((triangle *) (vx))[m->vertex2triindex] = value - -/** **/ -/** **/ -/********* Mesh manipulation primitives end here *********/ - -/********* User-defined triangle evaluation routine begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* triunsuitable() Determine if a triangle is unsuitable, and thus must */ -/* be further refined. */ -/* */ -/* You may write your own procedure that decides whether or not a selected */ -/* triangle is too big (and needs to be refined). There are two ways to do */ -/* this. */ -/* */ -/* (1) Modify the procedure `triunsuitable' below, then recompile */ -/* Triangle. */ -/* */ -/* (2) Define the symbol EXTERNAL_TEST (either by adding the definition */ -/* to this file, or by using the appropriate compiler switch). This way, */ -/* you can compile triangle.c separately from your test. Write your own */ -/* `triunsuitable' procedure in a separate C file (using the same prototype */ -/* as below). Compile it and link the object code with triangle.o. */ -/* */ -/* This procedure returns 1 if the triangle is too large and should be */ -/* refined; 0 otherwise. */ -/* */ -/*****************************************************************************/ - -#ifdef EXTERNAL_TEST - -int triunsuitable(); - -#else /* not EXTERNAL_TEST */ - -#ifdef ANSI_DECLARATORS -int triunsuitable(vertex triorg, vertex tridest, vertex triapex, REAL area) -#else /* not ANSI_DECLARATORS */ -int triunsuitable(triorg, tridest, triapex, area) -vertex triorg; /* The triangle's origin vertex. */ -vertex tridest; /* The triangle's destination vertex. */ -vertex triapex; /* The triangle's apex vertex. */ -REAL area; /* The area of the triangle. */ -#endif /* not ANSI_DECLARATORS */ - -{ - REAL dxoa, dxda, dxod; - REAL dyoa, dyda, dyod; - REAL oalen, dalen, odlen; - REAL maxlen; - - dxoa = triorg[0] - triapex[0]; - dyoa = triorg[1] - triapex[1]; - dxda = tridest[0] - triapex[0]; - dyda = tridest[1] - triapex[1]; - dxod = triorg[0] - tridest[0]; - dyod = triorg[1] - tridest[1]; - /* Find the squares of the lengths of the triangle's three edges. */ - oalen = dxoa * dxoa + dyoa * dyoa; - dalen = dxda * dxda + dyda * dyda; - odlen = dxod * dxod + dyod * dyod; - /* Find the square of the length of the longest edge. */ - maxlen = (dalen > oalen) ? dalen : oalen; - maxlen = (odlen > maxlen) ? odlen : maxlen; - - if (maxlen > 0.05 * (triorg[0] * triorg[0] + triorg[1] * triorg[1]) + 0.02) { - return 1; - } else { - return 0; - } -} - -#endif /* not EXTERNAL_TEST */ - -/** **/ -/** **/ -/********* User-defined triangle evaluation routine ends here *********/ - -/********* Memory allocation and program exit wrappers begin here *********/ -/** **/ -/** **/ - -#ifdef ANSI_DECLARATORS -void triexit(int status) -#else /* not ANSI_DECLARATORS */ -void triexit(status) -int status; -#endif /* not ANSI_DECLARATORS */ - -{ - exit(status); -} - -#ifdef ANSI_DECLARATORS -VOID *trimalloc(int size) -#else /* not ANSI_DECLARATORS */ -VOID *trimalloc(size) -int size; -#endif /* not ANSI_DECLARATORS */ - -{ - VOID *memptr; - - memptr = (VOID *) malloc((unsigned int) size); - if (memptr == (VOID *) NULL) { - printf("Error: Out of memory.\n"); - triexit(1); - } - return(memptr); -} - -#ifdef ANSI_DECLARATORS -void trifree(void *memptr) -#else /* not ANSI_DECLARATORS */ -void trifree(memptr) -VOID *memptr; -#endif /* not ANSI_DECLARATORS */ -{ - free(memptr); -} - -/** **/ -/** **/ -/********* Memory allocation and program exit wrappers end here *********/ - -/********* User interaction routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* syntax() Print list of command line switches. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -void syntax() -{ -#ifdef CDT_ONLY -#ifdef REDUCED - printf("triangle [-pAcjevngBPNEIOXzo_lQVh] input_file\n"); -#else /* not REDUCED */ - printf("triangle [-pAcjevngBPNEIOXzo_iFlCQVh] input_file\n"); -#endif /* not REDUCED */ -#else /* not CDT_ONLY */ -#ifdef REDUCED - printf("triangle [-prq__a__uAcDjevngBPNEIOXzo_YS__lQVh] input_file\n"); -#else /* not REDUCED */ - printf("triangle [-prq__a__uAcDjevngBPNEIOXzo_YS__iFlsCQVh] input_file\n"); -#endif /* not REDUCED */ -#endif /* not CDT_ONLY */ - - printf(" -p Triangulates a Planar Straight Line Graph (.poly file).\n"); -#ifndef CDT_ONLY - printf(" -r Refines a previously generated mesh.\n"); - printf( - " -q Quality mesh generation. A minimum angle may be specified.\n"); - printf(" -a Applies a maximum triangle area constraint.\n"); - printf(" -u Applies a user-defined triangle constraint.\n"); -#endif /* not CDT_ONLY */ - printf( - " -A Applies attributes to identify triangles in certain regions.\n"); - printf(" -c Encloses the convex hull with segments.\n"); -#ifndef CDT_ONLY - printf(" -D Conforming Delaunay: all triangles are truly Delaunay.\n"); -#endif /* not CDT_ONLY */ -/* - printf(" -w Weighted Delaunay triangulation.\n"); - printf(" -W Regular triangulation (lower hull of a height field).\n"); -*/ - printf(" -j Jettison unused vertices from output .node file.\n"); - printf(" -e Generates an edge list.\n"); - printf(" -v Generates a Voronoi diagram.\n"); - printf(" -n Generates a list of triangle neighbors.\n"); - printf(" -g Generates an .off file for Geomview.\n"); - printf(" -B Suppresses output of boundary information.\n"); - printf(" -P Suppresses output of .poly file.\n"); - printf(" -N Suppresses output of .node file.\n"); - printf(" -E Suppresses output of .ele file.\n"); - printf(" -I Suppresses mesh iteration numbers.\n"); - printf(" -O Ignores holes in .poly file.\n"); - printf(" -X Suppresses use of exact arithmetic.\n"); - printf(" -z Numbers all items starting from zero (rather than one).\n"); - printf(" -o2 Generates second-order subparametric elements.\n"); -#ifndef CDT_ONLY - printf(" -Y Suppresses boundary segment splitting.\n"); - printf(" -S Specifies maximum number of added Steiner points.\n"); -#endif /* not CDT_ONLY */ -#ifndef REDUCED - printf(" -i Uses incremental method, rather than divide-and-conquer.\n"); - printf(" -F Uses Fortune's sweepline algorithm, rather than d-and-c.\n"); -#endif /* not REDUCED */ - printf(" -l Uses vertical cuts only, rather than alternating cuts.\n"); -#ifndef REDUCED -#ifndef CDT_ONLY - printf( - " -s Force segments into mesh by splitting (instead of using CDT).\n"); -#endif /* not CDT_ONLY */ - printf(" -C Check consistency of final mesh.\n"); -#endif /* not REDUCED */ - printf(" -Q Quiet: No terminal output except errors.\n"); - printf(" -V Verbose: Detailed information on what I'm doing.\n"); - printf(" -h Help: Detailed instructions for Triangle.\n"); - triexit(0); -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* info() Print out complete instructions. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -void info() -{ - printf("Triangle\n"); - printf( -"A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.\n"); - printf("Version 1.6\n\n"); - printf( -"Copyright 1993, 1995, 1997, 1998, 2002, 2005 Jonathan Richard Shewchuk\n"); - printf("2360 Woolsey #H / Berkeley, California 94705-1927\n"); - printf("Bugs/comments to jrs@cs.berkeley.edu\n"); - printf( -"Created as part of the Quake project (tools for earthquake simulation).\n"); - printf( -"Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship.\n"); - printf("There is no warranty whatsoever. Use at your own risk.\n"); -#ifdef SINGLE - printf("This executable is compiled for single precision arithmetic.\n\n\n"); -#else /* not SINGLE */ - printf("This executable is compiled for double precision arithmetic.\n\n\n"); -#endif /* not SINGLE */ - printf( -"Triangle generates exact Delaunay triangulations, constrained Delaunay\n"); - printf( -"triangulations, conforming Delaunay triangulations, Voronoi diagrams, and\n"); - printf( -"high-quality triangular meshes. The latter can be generated with no small\n" -); - printf( -"or large angles, and are thus suitable for finite element analysis. If no\n" -); - printf( -"command line switch is specified, your .node input file is read, and the\n"); - printf( -"Delaunay triangulation is returned in .node and .ele output files. The\n"); - printf("command syntax is:\n\n"); - printf("triangle [-prq__a__uAcDjevngBPNEIOXzo_YS__iFlsCQVh] input_file\n\n"); - printf( -"Underscores indicate that numbers may optionally follow certain switches.\n"); - printf( -"Do not leave any space between a switch and its numeric parameter.\n"); - printf( -"input_file must be a file with extension .node, or extension .poly if the\n"); - printf( -"-p switch is used. If -r is used, you must supply .node and .ele files,\n"); - printf( -"and possibly a .poly file and an .area file as well. The formats of these\n" -); - printf("files are described below.\n\n"); - printf("Command Line Switches:\n\n"); - printf( -" -p Reads a Planar Straight Line Graph (.poly file), which can specify\n" -); - printf( -" vertices, segments, holes, regional attributes, and regional area\n"); - printf( -" constraints. Generates a constrained Delaunay triangulation (CDT)\n" -); - printf( -" fitting the input; or, if -s, -q, -a, or -u is used, a conforming\n"); - printf( -" constrained Delaunay triangulation (CCDT). If you want a truly\n"); - printf( -" Delaunay (not just constrained Delaunay) triangulation, use -D as\n"); - printf( -" well. When -p is not used, Triangle reads a .node file by default.\n" -); - printf( -" -r Refines a previously generated mesh. The mesh is read from a .node\n" -); - printf( -" file and an .ele file. If -p is also used, a .poly file is read\n"); - printf( -" and used to constrain segments in the mesh. If -a is also used\n"); - printf( -" (with no number following), an .area file is read and used to\n"); - printf( -" impose area constraints on the mesh. Further details on refinement\n" -); - printf(" appear below.\n"); - printf( -" -q Quality mesh generation by Delaunay refinement (a hybrid of Paul\n"); - printf( -" Chew's and Jim Ruppert's algorithms). Adds vertices to the mesh to\n" -); - printf( -" ensure that all angles are between 20 and 140 degrees. An\n"); - printf( -" alternative bound on the minimum angle, replacing 20 degrees, may\n"); - printf( -" be specified after the `q'. The specified angle may include a\n"); - printf( -" decimal point, but not exponential notation. Note that a bound of\n" -); - printf( -" theta degrees on the smallest angle also implies a bound of\n"); - printf( -" (180 - 2 theta) on the largest angle. If the minimum angle is 28.6\n" -); - printf( -" degrees or smaller, Triangle is mathematically guaranteed to\n"); - printf( -" terminate (assuming infinite precision arithmetic--Triangle may\n"); - printf( -" fail to terminate if you run out of precision). In practice,\n"); - printf( -" Triangle often succeeds for minimum angles up to 34 degrees. For\n"); - printf( -" some meshes, however, you might need to reduce the minimum angle to\n" -); - printf( -" avoid problems associated with insufficient floating-point\n"); - printf(" precision.\n"); - printf( -" -a Imposes a maximum triangle area. If a number follows the `a', no\n"); - printf( -" triangle is generated whose area is larger than that number. If no\n" -); - printf( -" number is specified, an .area file (if -r is used) or .poly file\n"); - printf( -" (if -r is not used) specifies a set of maximum area constraints.\n"); - printf( -" An .area file contains a separate area constraint for each\n"); - printf( -" triangle, and is useful for refining a finite element mesh based on\n" -); - printf( -" a posteriori error estimates. A .poly file can optionally contain\n" -); - printf( -" an area constraint for each segment-bounded region, thereby\n"); - printf( -" controlling triangle densities in a first triangulation of a PSLG.\n" -); - printf( -" You can impose both a fixed area constraint and a varying area\n"); - printf( -" constraint by invoking the -a switch twice, once with and once\n"); - printf( -" without a number following. Each area specified may include a\n"); - printf(" decimal point.\n"); - printf( -" -u Imposes a user-defined constraint on triangle size. There are two\n" -); - printf( -" ways to use this feature. One is to edit the triunsuitable()\n"); - printf( -" procedure in triangle.c to encode any constraint you like, then\n"); - printf( -" recompile Triangle. The other is to compile triangle.c with the\n"); - printf( -" EXTERNAL_TEST symbol set (compiler switch -DEXTERNAL_TEST), then\n"); - printf( -" link Triangle with a separate object file that implements\n"); - printf( -" triunsuitable(). In either case, the -u switch causes the user-\n"); - printf(" defined test to be applied to every triangle.\n"); - printf( -" -A Assigns an additional floating-point attribute to each triangle\n"); - printf( -" that identifies what segment-bounded region each triangle belongs\n"); - printf( -" to. Attributes are assigned to regions by the .poly file. If a\n"); - printf( -" region is not explicitly marked by the .poly file, triangles in\n"); - printf( -" that region are assigned an attribute of zero. The -A switch has\n"); - printf( -" an effect only when the -p switch is used and the -r switch is not.\n" -); - printf( -" -c Creates segments on the convex hull of the triangulation. If you\n"); - printf( -" are triangulating a vertex set, this switch causes a .poly file to\n" -); - printf( -" be written, containing all edges of the convex hull. If you are\n"); - printf( -" triangulating a PSLG, this switch specifies that the whole convex\n"); - printf( -" hull of the PSLG should be triangulated, regardless of what\n"); - printf( -" segments the PSLG has. If you do not use this switch when\n"); - printf( -" triangulating a PSLG, Triangle assumes that you have identified the\n" -); - printf( -" region to be triangulated by surrounding it with segments of the\n"); - printf( -" input PSLG. Beware: if you are not careful, this switch can cause\n" -); - printf( -" the introduction of an extremely thin angle between a PSLG segment\n" -); - printf( -" and a convex hull segment, which can cause overrefinement (and\n"); - printf( -" possibly failure if Triangle runs out of precision). If you are\n"); - printf( -" refining a mesh, the -c switch works differently: it causes a\n"); - printf( -" .poly file to be written containing the boundary edges of the mesh\n" -); - printf(" (useful if no .poly file was read).\n"); - printf( -" -D Conforming Delaunay triangulation: use this switch if you want to\n" -); - printf( -" ensure that all the triangles in the mesh are Delaunay, and not\n"); - printf( -" merely constrained Delaunay; or if you want to ensure that all the\n" -); - printf( -" Voronoi vertices lie within the triangulation. (Some finite volume\n" -); - printf( -" methods have this requirement.) This switch invokes Ruppert's\n"); - printf( -" original algorithm, which splits every subsegment whose diametral\n"); - printf( -" circle is encroached. It usually increases the number of vertices\n" -); - printf(" and triangles.\n"); - printf( -" -j Jettisons vertices that are not part of the final triangulation\n"); - printf( -" from the output .node file. By default, Triangle copies all\n"); - printf( -" vertices in the input .node file to the output .node file, in the\n"); - printf( -" same order, so their indices do not change. The -j switch prevents\n" -); - printf( -" duplicated input vertices, or vertices `eaten' by holes, from\n"); - printf( -" appearing in the output .node file. Thus, if two input vertices\n"); - printf( -" have exactly the same coordinates, only the first appears in the\n"); - printf( -" output. If any vertices are jettisoned, the vertex numbering in\n"); - printf( -" the output .node file differs from that of the input .node file.\n"); - printf( -" -e Outputs (to an .edge file) a list of edges of the triangulation.\n"); - printf( -" -v Outputs the Voronoi diagram associated with the triangulation.\n"); - printf( -" Does not attempt to detect degeneracies, so some Voronoi vertices\n"); - printf( -" may be duplicated. See the discussion of Voronoi diagrams below.\n"); - printf( -" -n Outputs (to a .neigh file) a list of triangles neighboring each\n"); - printf(" triangle.\n"); - printf( -" -g Outputs the mesh to an Object File Format (.off) file, suitable for\n" -); - printf(" viewing with the Geometry Center's Geomview package.\n"); - printf( -" -B No boundary markers in the output .node, .poly, and .edge output\n"); - printf( -" files. See the detailed discussion of boundary markers below.\n"); - printf( -" -P No output .poly file. Saves disk space, but you lose the ability\n"); - printf( -" to maintain constraining segments on later refinements of the mesh.\n" -); - printf(" -N No output .node file.\n"); - printf(" -E No output .ele file.\n"); - printf( -" -I No iteration numbers. Suppresses the output of .node and .poly\n"); - printf( -" files, so your input files won't be overwritten. (If your input is\n" -); - printf( -" a .poly file only, a .node file is written.) Cannot be used with\n"); - printf( -" the -r switch, because that would overwrite your input .ele file.\n"); - printf( -" Shouldn't be used with the -q, -a, -u, or -s switch if you are\n"); - printf( -" using a .node file for input, because no .node file is written, so\n" -); - printf(" there is no record of any added Steiner points.\n"); - printf(" -O No holes. Ignores the holes in the .poly file.\n"); - printf( -" -X No exact arithmetic. Normally, Triangle uses exact floating-point\n" -); - printf( -" arithmetic for certain tests if it thinks the inexact tests are not\n" -); - printf( -" accurate enough. Exact arithmetic ensures the robustness of the\n"); - printf( -" triangulation algorithms, despite floating-point roundoff error.\n"); - printf( -" Disabling exact arithmetic with the -X switch causes a small\n"); - printf( -" improvement in speed and creates the possibility that Triangle will\n" -); - printf(" fail to produce a valid mesh. Not recommended.\n"); - printf( -" -z Numbers all items starting from zero (rather than one). Note that\n" -); - printf( -" this switch is normally overridden by the value used to number the\n" -); - printf( -" first vertex of the input .node or .poly file. However, this\n"); - printf( -" switch is useful when calling Triangle from another program.\n"); - printf( -" -o2 Generates second-order subparametric elements with six nodes each.\n" -); - printf( -" -Y No new vertices on the boundary. This switch is useful when the\n"); - printf( -" mesh boundary must be preserved so that it conforms to some\n"); - printf( -" adjacent mesh. Be forewarned that you will probably sacrifice much\n" -); - printf( -" of the quality of the mesh; Triangle will try, but the resulting\n"); - printf( -" mesh may contain poorly shaped triangles. Works well if all the\n"); - printf( -" boundary vertices are closely spaced. Specify this switch twice\n"); - printf( -" (`-YY') to prevent all segment splitting, including internal\n"); - printf(" boundaries.\n"); - printf( -" -S Specifies the maximum number of Steiner points (vertices that are\n"); - printf( -" not in the input, but are added to meet the constraints on minimum\n" -); - printf( -" angle and maximum area). The default is to allow an unlimited\n"); - printf( -" number. If you specify this switch with no number after it,\n"); - printf( -" the limit is set to zero. Triangle always adds vertices at segment\n" -); - printf( -" intersections, even if it needs to use more vertices than the limit\n" -); - printf( -" you set. When Triangle inserts segments by splitting (-s), it\n"); - printf( -" always adds enough vertices to ensure that all the segments of the\n" -); - printf(" PLSG are recovered, ignoring the limit if necessary.\n"); - printf( -" -i Uses an incremental rather than a divide-and-conquer algorithm to\n"); - printf( -" construct a Delaunay triangulation. Try it if the divide-and-\n"); - printf(" conquer algorithm fails.\n"); - printf( -" -F Uses Steven Fortune's sweepline algorithm to construct a Delaunay\n"); - printf( -" triangulation. Warning: does not use exact arithmetic for all\n"); - printf(" calculations. An exact result is not guaranteed.\n"); - printf( -" -l Uses only vertical cuts in the divide-and-conquer algorithm. By\n"); - printf( -" default, Triangle alternates between vertical and horizontal cuts,\n" -); - printf( -" which usually improve the speed except with vertex sets that are\n"); - printf( -" small or short and wide. This switch is primarily of theoretical\n"); - printf(" interest.\n"); - printf( -" -s Specifies that segments should be forced into the triangulation by\n" -); - printf( -" recursively splitting them at their midpoints, rather than by\n"); - printf( -" generating a constrained Delaunay triangulation. Segment splitting\n" -); - printf( -" is true to Ruppert's original algorithm, but can create needlessly\n" -); - printf( -" small triangles. This switch is primarily of theoretical interest.\n" -); - printf( -" -C Check the consistency of the final mesh. Uses exact arithmetic for\n" -); - printf( -" checking, even if the -X switch is used. Useful if you suspect\n"); - printf(" Triangle is buggy.\n"); - printf( -" -Q Quiet: Suppresses all explanation of what Triangle is doing,\n"); - printf(" unless an error occurs.\n"); - printf( -" -V Verbose: Gives detailed information about what Triangle is doing.\n" -); - printf( -" Add more `V's for increasing amount of detail. `-V' is most\n"); - printf( -" useful; itgives information on algorithmic progress and much more\n"); - printf( -" detailed statistics. `-VV' gives vertex-by-vertex details, and\n"); - printf( -" prints so much that Triangle runs much more slowly. `-VVVV' gives\n" -); - printf(" information only a debugger could love.\n"); - printf(" -h Help: Displays these instructions.\n"); - printf("\n"); - printf("Definitions:\n"); - printf("\n"); - printf( -" A Delaunay triangulation of a vertex set is a triangulation whose\n"); - printf( -" vertices are the vertex set, that covers the convex hull of the vertex\n"); - printf( -" set. A Delaunay triangulation has the property that no vertex lies\n"); - printf( -" inside the circumscribing circle (circle that passes through all three\n"); - printf(" vertices) of any triangle in the triangulation.\n\n"); - printf( -" A Voronoi diagram of a vertex set is a subdivision of the plane into\n"); - printf( -" polygonal cells (some of which may be unbounded, meaning infinitely\n"); - printf( -" large), where each cell is the set of points in the plane that are closer\n" -); - printf( -" to some input vertex than to any other input vertex. The Voronoi diagram\n" -); - printf(" is a geometric dual of the Delaunay triangulation.\n\n"); - printf( -" A Planar Straight Line Graph (PSLG) is a set of vertices and segments.\n"); - printf( -" Segments are simply edges, whose endpoints are all vertices in the PSLG.\n" -); - printf( -" Segments may intersect each other only at their endpoints. The file\n"); - printf(" format for PSLGs (.poly files) is described below.\n\n"); - printf( -" A constrained Delaunay triangulation (CDT) of a PSLG is similar to a\n"); - printf( -" Delaunay triangulation, but each PSLG segment is present as a single edge\n" -); - printf( -" of the CDT. (A constrained Delaunay triangulation is not truly a\n"); - printf( -" Delaunay triangulation, because some of its triangles might not be\n"); - printf( -" Delaunay.) By definition, a CDT does not have any vertices other than\n"); - printf( -" those specified in the input PSLG. Depending on context, a CDT might\n"); - printf( -" cover the convex hull of the PSLG, or it might cover only a segment-\n"); - printf(" bounded region (e.g. a polygon).\n\n"); - printf( -" A conforming Delaunay triangulation of a PSLG is a triangulation in which\n" -); - printf( -" each triangle is truly Delaunay, and each PSLG segment is represented by\n" -); - printf( -" a linear contiguous sequence of edges of the triangulation. New vertices\n" -); - printf( -" (not part of the PSLG) may appear, and each input segment may have been\n"); - printf( -" subdivided into shorter edges (subsegments) by these additional vertices.\n" -); - printf( -" The new vertices are frequently necessary to maintain the Delaunay\n"); - printf(" property while ensuring that every segment is represented.\n\n"); - printf( -" A conforming constrained Delaunay triangulation (CCDT) of a PSLG is a\n"); - printf( -" triangulation of a PSLG whose triangles are constrained Delaunay. New\n"); - printf(" vertices may appear, and input segments may be subdivided into\n"); - printf( -" subsegments, but not to guarantee that segments are respected; rather, to\n" -); - printf( -" improve the quality of the triangles. The high-quality meshes produced\n"); - printf( -" by the -q switch are usually CCDTs, but can be made conforming Delaunay\n"); - printf(" with the -D switch.\n\n"); - printf("File Formats:\n\n"); - printf( -" All files may contain comments prefixed by the character '#'. Vertices,\n" -); - printf( -" triangles, edges, holes, and maximum area constraints must be numbered\n"); - printf( -" consecutively, starting from either 1 or 0. Whichever you choose, all\n"); - printf( -" input files must be consistent; if the vertices are numbered from 1, so\n"); - printf( -" must be all other objects. Triangle automatically detects your choice\n"); - printf( -" while reading the .node (or .poly) file. (When calling Triangle from\n"); - printf( -" another program, use the -z switch if you wish to number objects from\n"); - printf(" zero.) Examples of these file formats are given below.\n\n"); - printf(" .node files:\n"); - printf( -" First line: <# of vertices> <# of attributes>\n" -); - printf( -" <# of boundary markers (0 or 1)>\n" -); - printf( -" Remaining lines: [attributes] [boundary marker]\n"); - printf("\n"); - printf( -" The attributes, which are typically floating-point values of physical\n"); - printf( -" quantities (such as mass or conductivity) associated with the nodes of\n" -); - printf( -" a finite element mesh, are copied unchanged to the output mesh. If -q,\n" -); - printf( -" -a, -u, -D, or -s is selected, each new Steiner point added to the mesh\n" -); - printf(" has attributes assigned to it by linear interpolation.\n\n"); - printf( -" If the fourth entry of the first line is `1', the last column of the\n"); - printf( -" remainder of the file is assumed to contain boundary markers. Boundary\n" -); - printf( -" markers are used to identify boundary vertices and vertices resting on\n" -); - printf( -" PSLG segments; a complete description appears in a section below. The\n" -); - printf( -" .node file produced by Triangle contains boundary markers in the last\n"); - printf(" column unless they are suppressed by the -B switch.\n\n"); - printf(" .ele files:\n"); - printf( -" First line: <# of triangles> <# of attributes>\n"); - printf( -" Remaining lines: ... [attributes]\n"); - printf("\n"); - printf( -" Nodes are indices into the corresponding .node file. The first three\n"); - printf( -" nodes are the corner vertices, and are listed in counterclockwise order\n" -); - printf( -" around each triangle. (The remaining nodes, if any, depend on the type\n" -); - printf(" of finite element used.)\n\n"); - printf( -" The attributes are just like those of .node files. Because there is no\n" -); - printf( -" simple mapping from input to output triangles, Triangle attempts to\n"); - printf( -" interpolate attributes, and may cause a lot of diffusion of attributes\n" -); - printf( -" among nearby triangles as the triangulation is refined. Attributes do\n" -); - printf(" not diffuse across segments, so attributes used to identify\n"); - printf(" segment-bounded regions remain intact.\n\n"); - printf( -" In .ele files produced by Triangle, each triangular element has three\n"); - printf( -" nodes (vertices) unless the -o2 switch is used, in which case\n"); - printf( -" subparametric quadratic elements with six nodes each are generated.\n"); - printf( -" The first three nodes are the corners in counterclockwise order, and\n"); - printf( -" the fourth, fifth, and sixth nodes lie on the midpoints of the edges\n"); - printf( -" opposite the first, second, and third vertices, respectively.\n"); - printf("\n"); - printf(" .poly files:\n"); - printf( -" First line: <# of vertices> <# of attributes>\n" -); - printf( -" <# of boundary markers (0 or 1)>\n" -); - printf( -" Following lines: [attributes] [boundary marker]\n"); - printf(" One line: <# of segments> <# of boundary markers (0 or 1)>\n"); - printf( -" Following lines: [boundary marker]\n"); - printf(" One line: <# of holes>\n"); - printf(" Following lines: \n"); - printf( -" Optional line: <# of regional attributes and/or area constraints>\n"); - printf( -" Optional following lines: \n"); - printf("\n"); - printf( -" A .poly file represents a PSLG, as well as some additional information.\n" -); - printf( -" The first section lists all the vertices, and is identical to the\n"); - printf( -" format of .node files. <# of vertices> may be set to zero to indicate\n" -); - printf( -" that the vertices are listed in a separate .node file; .poly files\n"); - printf( -" produced by Triangle always have this format. A vertex set represented\n" -); - printf( -" this way has the advantage that it may easily be triangulated with or\n"); - printf( -" without segments (depending on whether the -p switch is invoked).\n"); - printf("\n"); - printf( -" The second section lists the segments. Segments are edges whose\n"); - printf( -" presence in the triangulation is enforced. (Depending on the choice of\n" -); - printf( -" switches, segment might be subdivided into smaller edges). Each\n"); - printf( -" segment is specified by listing the indices of its two endpoints. This\n" -); - printf( -" means that you must include its endpoints in the vertex list. Each\n"); - printf(" segment, like each point, may have a boundary marker.\n\n"); - printf( -" If -q, -a, -u, and -s are not selected, Triangle produces a constrained\n" -); - printf( -" Delaunay triangulation (CDT), in which each segment appears as a single\n" -); - printf( -" edge in the triangulation. If -q, -a, -u, or -s is selected, Triangle\n" -); - printf( -" produces a conforming constrained Delaunay triangulation (CCDT), in\n"); - printf( -" which segments may be subdivided into smaller edges. If -D is\n"); - printf( -" selected, Triangle produces a conforming Delaunay triangulation, so\n"); - printf( -" that every triangle is Delaunay, and not just constrained Delaunay.\n"); - printf("\n"); - printf( -" The third section lists holes (and concavities, if -c is selected) in\n"); - printf( -" the triangulation. Holes are specified by identifying a point inside\n"); - printf( -" each hole. After the triangulation is formed, Triangle creates holes\n"); - printf( -" by eating triangles, spreading out from each hole point until its\n"); - printf( -" progress is blocked by segments in the PSLG. You must be careful to\n"); - printf( -" enclose each hole in segments, or your whole triangulation might be\n"); - printf( -" eaten away. If the two triangles abutting a segment are eaten, the\n"); - printf( -" segment itself is also eaten. Do not place a hole directly on a\n"); - printf(" segment; if you do, Triangle chooses one side of the segment\n"); - printf(" arbitrarily.\n\n"); - printf( -" The optional fourth section lists regional attributes (to be assigned\n"); - printf( -" to all triangles in a region) and regional constraints on the maximum\n"); - printf( -" triangle area. Triangle reads this section only if the -A switch is\n"); - printf( -" used or the -a switch is used without a number following it, and the -r\n" -); - printf( -" switch is not used. Regional attributes and area constraints are\n"); - printf( -" propagated in the same manner as holes: you specify a point for each\n"); - printf( -" attribute and/or constraint, and the attribute and/or constraint\n"); - printf( -" affects the whole region (bounded by segments) containing the point.\n"); - printf( -" If two values are written on a line after the x and y coordinate, the\n"); - printf( -" first such value is assumed to be a regional attribute (but is only\n"); - printf( -" applied if the -A switch is selected), and the second value is assumed\n" -); - printf( -" to be a regional area constraint (but is only applied if the -a switch\n" -); - printf( -" is selected). You may specify just one value after the coordinates,\n"); - printf( -" which can serve as both an attribute and an area constraint, depending\n" -); - printf( -" on the choice of switches. If you are using the -A and -a switches\n"); - printf( -" simultaneously and wish to assign an attribute to some region without\n"); - printf(" imposing an area constraint, use a negative maximum area.\n\n"); - printf( -" When a triangulation is created from a .poly file, you must either\n"); - printf( -" enclose the entire region to be triangulated in PSLG segments, or\n"); - printf( -" use the -c switch, which automatically creates extra segments that\n"); - printf( -" enclose the convex hull of the PSLG. If you do not use the -c switch,\n" -); - printf( -" Triangle eats all triangles that are not enclosed by segments; if you\n"); - printf( -" are not careful, your whole triangulation may be eaten away. If you do\n" -); - printf( -" use the -c switch, you can still produce concavities by the appropriate\n" -); - printf( -" placement of holes just inside the boundary of the convex hull.\n"); - printf("\n"); - printf( -" An ideal PSLG has no intersecting segments, nor any vertices that lie\n"); - printf( -" upon segments (except, of course, the endpoints of each segment). You\n" -); - printf( -" aren't required to make your .poly files ideal, but you should be aware\n" -); - printf( -" of what can go wrong. Segment intersections are relatively safe--\n"); - printf( -" Triangle calculates the intersection points for you and adds them to\n"); - printf( -" the triangulation--as long as your machine's floating-point precision\n"); - printf( -" doesn't become a problem. You are tempting the fates if you have three\n" -); - printf( -" segments that cross at the same location, and expect Triangle to figure\n" -); - printf( -" out where the intersection point is. Thanks to floating-point roundoff\n" -); - printf( -" error, Triangle will probably decide that the three segments intersect\n" -); - printf( -" at three different points, and you will find a minuscule triangle in\n"); - printf( -" your output--unless Triangle tries to refine the tiny triangle, uses\n"); - printf( -" up the last bit of machine precision, and fails to terminate at all.\n"); - printf( -" You're better off putting the intersection point in the input files,\n"); - printf( -" and manually breaking up each segment into two. Similarly, if you\n"); - printf( -" place a vertex at the middle of a segment, and hope that Triangle will\n" -); - printf( -" break up the segment at that vertex, you might get lucky. On the other\n" -); - printf( -" hand, Triangle might decide that the vertex doesn't lie precisely on\n"); - printf( -" the segment, and you'll have a needle-sharp triangle in your output--or\n" -); - printf(" a lot of tiny triangles if you're generating a quality mesh.\n"); - printf("\n"); - printf( -" When Triangle reads a .poly file, it also writes a .poly file, which\n"); - printf( -" includes all the subsegments--the edges that are parts of input\n"); - printf( -" segments. If the -c switch is used, the output .poly file also\n"); - printf( -" includes all of the edges on the convex hull. Hence, the output .poly\n" -); - printf( -" file is useful for finding edges associated with input segments and for\n" -); - printf( -" setting boundary conditions in finite element simulations. Moreover,\n"); - printf( -" you will need the output .poly file if you plan to refine the output\n"); - printf( -" mesh, and don't want segments to be missing in later triangulations.\n"); - printf("\n"); - printf(" .area files:\n"); - printf(" First line: <# of triangles>\n"); - printf(" Following lines: \n"); - printf("\n"); - printf( -" An .area file associates with each triangle a maximum area that is used\n" -); - printf( -" for mesh refinement. As with other file formats, every triangle must\n"); - printf( -" be represented, and the triangles must be numbered consecutively. A\n"); - printf( -" triangle may be left unconstrained by assigning it a negative maximum\n"); - printf(" area.\n\n"); - printf(" .edge files:\n"); - printf(" First line: <# of edges> <# of boundary markers (0 or 1)>\n"); - printf( -" Following lines: [boundary marker]\n"); - printf("\n"); - printf( -" Endpoints are indices into the corresponding .node file. Triangle can\n" -); - printf( -" produce .edge files (use the -e switch), but cannot read them. The\n"); - printf( -" optional column of boundary markers is suppressed by the -B switch.\n"); - printf("\n"); - printf( -" In Voronoi diagrams, one also finds a special kind of edge that is an\n"); - printf( -" infinite ray with only one endpoint. For these edges, a different\n"); - printf(" format is used:\n\n"); - printf(" -1 \n\n"); - printf( -" The `direction' is a floating-point vector that indicates the direction\n" -); - printf(" of the infinite ray.\n\n"); - printf(" .neigh files:\n"); - printf( -" First line: <# of triangles> <# of neighbors per triangle (always 3)>\n" -); - printf( -" Following lines: \n"); - printf("\n"); - printf( -" Neighbors are indices into the corresponding .ele file. An index of -1\n" -); - printf( -" indicates no neighbor (because the triangle is on an exterior\n"); - printf( -" boundary). The first neighbor of triangle i is opposite the first\n"); - printf(" corner of triangle i, and so on.\n\n"); - printf( -" Triangle can produce .neigh files (use the -n switch), but cannot read\n" -); - printf(" them.\n\n"); - printf("Boundary Markers:\n\n"); - printf( -" Boundary markers are tags used mainly to identify which output vertices\n"); - printf( -" and edges are associated with which PSLG segment, and to identify which\n"); - printf( -" vertices and edges occur on a boundary of the triangulation. A common\n"); - printf( -" use is to determine where boundary conditions should be applied to a\n"); - printf( -" finite element mesh. You can prevent boundary markers from being written\n" -); - printf(" into files produced by Triangle by using the -B switch.\n\n"); - printf( -" The boundary marker associated with each segment in an output .poly file\n" -); - printf(" and each edge in an output .edge file is chosen as follows:\n"); - printf( -" - If an output edge is part or all of a PSLG segment with a nonzero\n"); - printf( -" boundary marker, then the edge is assigned the same marker.\n"); - printf( -" - Otherwise, if the edge lies on a boundary of the triangulation\n"); - printf( -" (even the boundary of a hole), then the edge is assigned the marker\n"); - printf(" one (1).\n"); - printf(" - Otherwise, the edge is assigned the marker zero (0).\n"); - printf( -" The boundary marker associated with each vertex in an output .node file\n"); - printf(" is chosen as follows:\n"); - printf( -" - If a vertex is assigned a nonzero boundary marker in the input file,\n" -); - printf( -" then it is assigned the same marker in the output .node file.\n"); - printf( -" - Otherwise, if the vertex lies on a PSLG segment (even if it is an\n"); - printf( -" endpoint of the segment) with a nonzero boundary marker, then the\n"); - printf( -" vertex is assigned the same marker. If the vertex lies on several\n"); - printf(" such segments, one of the markers is chosen arbitrarily.\n"); - printf( -" - Otherwise, if the vertex occurs on a boundary of the triangulation,\n"); - printf(" then the vertex is assigned the marker one (1).\n"); - printf(" - Otherwise, the vertex is assigned the marker zero (0).\n"); - printf("\n"); - printf( -" If you want Triangle to determine for you which vertices and edges are on\n" -); - printf( -" the boundary, assign them the boundary marker zero (or use no markers at\n" -); - printf( -" all) in your input files. In the output files, all boundary vertices,\n"); - printf(" edges, and segments will be assigned the value one.\n\n"); - printf("Triangulation Iteration Numbers:\n\n"); - printf( -" Because Triangle can read and refine its own triangulations, input\n"); - printf( -" and output files have iteration numbers. For instance, Triangle might\n"); - printf( -" read the files mesh.3.node, mesh.3.ele, and mesh.3.poly, refine the\n"); - printf( -" triangulation, and output the files mesh.4.node, mesh.4.ele, and\n"); - printf(" mesh.4.poly. Files with no iteration number are treated as if\n"); - printf( -" their iteration number is zero; hence, Triangle might read the file\n"); - printf( -" points.node, triangulate it, and produce the files points.1.node and\n"); - printf(" points.1.ele.\n\n"); - printf( -" Iteration numbers allow you to create a sequence of successively finer\n"); - printf( -" meshes suitable for multigrid methods. They also allow you to produce a\n" -); - printf( -" sequence of meshes using error estimate-driven mesh refinement.\n"); - printf("\n"); - printf( -" If you're not using refinement or quality meshing, and you don't like\n"); - printf( -" iteration numbers, use the -I switch to disable them. This switch also\n"); - printf( -" disables output of .node and .poly files to prevent your input files from\n" -); - printf( -" being overwritten. (If the input is a .poly file that contains its own\n"); - printf( -" points, a .node file is written. This can be quite convenient for\n"); - printf(" computing CDTs or quality meshes.)\n\n"); - printf("Examples of How to Use Triangle:\n\n"); - printf( -" `triangle dots' reads vertices from dots.node, and writes their Delaunay\n" -); - printf( -" triangulation to dots.1.node and dots.1.ele. (dots.1.node is identical\n"); - printf( -" to dots.node.) `triangle -I dots' writes the triangulation to dots.ele\n"); - printf( -" instead. (No additional .node file is needed, so none is written.)\n"); - printf("\n"); - printf( -" `triangle -pe object.1' reads a PSLG from object.1.poly (and possibly\n"); - printf( -" object.1.node, if the vertices are omitted from object.1.poly) and writes\n" -); - printf( -" its constrained Delaunay triangulation to object.2.node and object.2.ele.\n" -); - printf( -" The segments are copied to object.2.poly, and all edges are written to\n"); - printf(" object.2.edge.\n\n"); - printf( -" `triangle -pq31.5a.1 object' reads a PSLG from object.poly (and possibly\n" -); - printf( -" object.node), generates a mesh whose angles are all between 31.5 and 117\n" -); - printf( -" degrees and whose triangles all have areas of 0.1 or less, and writes the\n" -); - printf( -" mesh to object.1.node and object.1.ele. Each segment may be broken up\n"); - printf(" into multiple subsegments; these are written to object.1.poly.\n"); - printf("\n"); - printf( -" Here is a sample file `box.poly' describing a square with a square hole:\n" -); - printf("\n"); - printf( -" # A box with eight vertices in 2D, no attributes, one boundary marker.\n" -); - printf(" 8 2 0 1\n"); - printf(" # Outer box has these vertices:\n"); - printf(" 1 0 0 0\n"); - printf(" 2 0 3 0\n"); - printf(" 3 3 0 0\n"); - printf(" 4 3 3 33 # A special marker for this vertex.\n"); - printf(" # Inner square has these vertices:\n"); - printf(" 5 1 1 0\n"); - printf(" 6 1 2 0\n"); - printf(" 7 2 1 0\n"); - printf(" 8 2 2 0\n"); - printf(" # Five segments with boundary markers.\n"); - printf(" 5 1\n"); - printf(" 1 1 2 5 # Left side of outer box.\n"); - printf(" # Square hole has these segments:\n"); - printf(" 2 5 7 0\n"); - printf(" 3 7 8 0\n"); - printf(" 4 8 6 10\n"); - printf(" 5 6 5 0\n"); - printf(" # One hole in the middle of the inner square.\n"); - printf(" 1\n"); - printf(" 1 1.5 1.5\n"); - printf("\n"); - printf( -" Note that some segments are missing from the outer square, so you must\n"); - printf( -" use the `-c' switch. After `triangle -pqc box.poly', here is the output\n" -); - printf( -" file `box.1.node', with twelve vertices. The last four vertices were\n"); - printf( -" added to meet the angle constraint. Vertices 1, 2, and 9 have markers\n"); - printf( -" from segment 1. Vertices 6 and 8 have markers from segment 4. All the\n"); - printf( -" other vertices but 4 have been marked to indicate that they lie on a\n"); - printf(" boundary.\n\n"); - printf(" 12 2 0 1\n"); - printf(" 1 0 0 5\n"); - printf(" 2 0 3 5\n"); - printf(" 3 3 0 1\n"); - printf(" 4 3 3 33\n"); - printf(" 5 1 1 1\n"); - printf(" 6 1 2 10\n"); - printf(" 7 2 1 1\n"); - printf(" 8 2 2 10\n"); - printf(" 9 0 1.5 5\n"); - printf(" 10 1.5 0 1\n"); - printf(" 11 3 1.5 1\n"); - printf(" 12 1.5 3 1\n"); - printf(" # Generated by triangle -pqc box.poly\n"); - printf("\n"); - printf(" Here is the output file `box.1.ele', with twelve triangles.\n"); - printf("\n"); - printf(" 12 3 0\n"); - printf(" 1 5 6 9\n"); - printf(" 2 10 3 7\n"); - printf(" 3 6 8 12\n"); - printf(" 4 9 1 5\n"); - printf(" 5 6 2 9\n"); - printf(" 6 7 3 11\n"); - printf(" 7 11 4 8\n"); - printf(" 8 7 5 10\n"); - printf(" 9 12 2 6\n"); - printf(" 10 8 7 11\n"); - printf(" 11 5 1 10\n"); - printf(" 12 8 4 12\n"); - printf(" # Generated by triangle -pqc box.poly\n\n"); - printf( -" Here is the output file `box.1.poly'. Note that segments have been added\n" -); - printf( -" to represent the convex hull, and some segments have been subdivided by\n"); - printf( -" newly added vertices. Note also that <# of vertices> is set to zero to\n"); - printf(" indicate that the vertices should be read from the .node file.\n"); - printf("\n"); - printf(" 0 2 0 1\n"); - printf(" 12 1\n"); - printf(" 1 1 9 5\n"); - printf(" 2 5 7 1\n"); - printf(" 3 8 7 1\n"); - printf(" 4 6 8 10\n"); - printf(" 5 5 6 1\n"); - printf(" 6 3 10 1\n"); - printf(" 7 4 11 1\n"); - printf(" 8 2 12 1\n"); - printf(" 9 9 2 5\n"); - printf(" 10 10 1 1\n"); - printf(" 11 11 3 1\n"); - printf(" 12 12 4 1\n"); - printf(" 1\n"); - printf(" 1 1.5 1.5\n"); - printf(" # Generated by triangle -pqc box.poly\n"); - printf("\n"); - printf("Refinement and Area Constraints:\n"); - printf("\n"); - printf( -" The -r switch causes a mesh (.node and .ele files) to be read and\n"); - printf( -" refined. If the -p switch is also used, a .poly file is read and used to\n" -); - printf( -" specify edges that are constrained and cannot be eliminated (although\n"); - printf( -" they can be subdivided into smaller edges) by the refinement process.\n"); - printf("\n"); - printf( -" When you refine a mesh, you generally want to impose tighter constraints.\n" -); - printf( -" One way to accomplish this is to use -q with a larger angle, or -a\n"); - printf( -" followed by a smaller area than you used to generate the mesh you are\n"); - printf( -" refining. Another way to do this is to create an .area file, which\n"); - printf( -" specifies a maximum area for each triangle, and use the -a switch\n"); - printf( -" (without a number following). Each triangle's area constraint is applied\n" -); - printf( -" to that triangle. Area constraints tend to diffuse as the mesh is\n"); - printf( -" refined, so if there are large variations in area constraint between\n"); - printf( -" adjacent triangles, you may not get the results you want. In that case,\n" -); - printf( -" consider instead using the -u switch and writing a C procedure that\n"); - printf(" determines which triangles are too large.\n\n"); - printf( -" If you are refining a mesh composed of linear (three-node) elements, the\n" -); - printf( -" output mesh contains all the nodes present in the input mesh, in the same\n" -); - printf( -" order, with new nodes added at the end of the .node file. However, the\n"); - printf( -" refinement is not hierarchical: there is no guarantee that each output\n"); - printf( -" element is contained in a single input element. Often, an output element\n" -); - printf( -" can overlap two or three input elements, and some input edges are not\n"); - printf( -" present in the output mesh. Hence, a sequence of refined meshes forms a\n" -); - printf( -" hierarchy of nodes, but not a hierarchy of elements. If you refine a\n"); - printf( -" mesh of higher-order elements, the hierarchical property applies only to\n" -); - printf( -" the nodes at the corners of an element; the midpoint nodes on each edge\n"); - printf(" are discarded before the mesh is refined.\n\n"); - printf( -" Maximum area constraints in .poly files operate differently from those in\n" -); - printf( -" .area files. A maximum area in a .poly file applies to the whole\n"); - printf( -" (segment-bounded) region in which a point falls, whereas a maximum area\n"); - printf( -" in an .area file applies to only one triangle. Area constraints in .poly\n" -); - printf( -" files are used only when a mesh is first generated, whereas area\n"); - printf( -" constraints in .area files are used only to refine an existing mesh, and\n" -); - printf( -" are typically based on a posteriori error estimates resulting from a\n"); - printf(" finite element simulation on that mesh.\n\n"); - printf( -" `triangle -rq25 object.1' reads object.1.node and object.1.ele, then\n"); - printf( -" refines the triangulation to enforce a 25 degree minimum angle, and then\n" -); - printf( -" writes the refined triangulation to object.2.node and object.2.ele.\n"); - printf("\n"); - printf( -" `triangle -rpaa6.2 z.3' reads z.3.node, z.3.ele, z.3.poly, and z.3.area.\n" -); - printf( -" After reconstructing the mesh and its subsegments, Triangle refines the\n"); - printf( -" mesh so that no triangle has area greater than 6.2, and furthermore the\n"); - printf( -" triangles satisfy the maximum area constraints in z.3.area. No angle\n"); - printf( -" bound is imposed at all. The output is written to z.4.node, z.4.ele, and\n" -); - printf(" z.4.poly.\n\n"); - printf( -" The sequence `triangle -qa1 x', `triangle -rqa.3 x.1', `triangle -rqa.1\n"); - printf( -" x.2' creates a sequence of successively finer meshes x.1, x.2, and x.3,\n"); - printf(" suitable for multigrid.\n\n"); - printf("Convex Hulls and Mesh Boundaries:\n\n"); - printf( -" If the input is a vertex set (not a PSLG), Triangle produces its convex\n"); - printf( -" hull as a by-product in the output .poly file if you use the -c switch.\n"); - printf( -" There are faster algorithms for finding a two-dimensional convex hull\n"); - printf(" than triangulation, of course, but this one comes for free.\n\n"); - printf( -" If the input is an unconstrained mesh (you are using the -r switch but\n"); - printf( -" not the -p switch), Triangle produces a list of its boundary edges\n"); - printf( -" (including hole boundaries) as a by-product when you use the -c switch.\n"); - printf( -" If you also use the -p switch, the output .poly file contains all the\n"); - printf(" segments from the input .poly file as well.\n\n"); - printf("Voronoi Diagrams:\n\n"); - printf( -" The -v switch produces a Voronoi diagram, in files suffixed .v.node and\n"); - printf( -" .v.edge. For example, `triangle -v points' reads points.node, produces\n"); - printf( -" its Delaunay triangulation in points.1.node and points.1.ele, and\n"); - printf( -" produces its Voronoi diagram in points.1.v.node and points.1.v.edge. The\n" -); - printf( -" .v.node file contains a list of all Voronoi vertices, and the .v.edge\n"); - printf( -" file contains a list of all Voronoi edges, some of which may be infinite\n" -); - printf( -" rays. (The choice of filenames makes it easy to run the set of Voronoi\n"); - printf(" vertices through Triangle, if so desired.)\n\n"); - printf( -" This implementation does not use exact arithmetic to compute the Voronoi\n" -); - printf( -" vertices, and does not check whether neighboring vertices are identical.\n" -); - printf( -" Be forewarned that if the Delaunay triangulation is degenerate or\n"); - printf( -" near-degenerate, the Voronoi diagram may have duplicate vertices or\n"); - printf(" crossing edges.\n\n"); - printf( -" The result is a valid Voronoi diagram only if Triangle's output is a true\n" -); - printf( -" Delaunay triangulation. The Voronoi output is usually meaningless (and\n"); - printf( -" may contain crossing edges and other pathology) if the output is a CDT or\n" -); - printf( -" CCDT, or if it has holes or concavities. If the triangulated domain is\n"); - printf( -" convex and has no holes, you can use -D switch to force Triangle to\n"); - printf( -" construct a conforming Delaunay triangulation instead of a CCDT, so the\n"); - printf(" Voronoi diagram will be valid.\n\n"); - printf("Mesh Topology:\n\n"); - printf( -" You may wish to know which triangles are adjacent to a certain Delaunay\n"); - printf( -" edge in an .edge file, which Voronoi cells are adjacent to a certain\n"); - printf( -" Voronoi edge in a .v.edge file, or which Voronoi cells are adjacent to\n"); - printf( -" each other. All of this information can be found by cross-referencing\n"); - printf( -" output files with the recollection that the Delaunay triangulation and\n"); - printf(" the Voronoi diagram are planar duals.\n\n"); - printf( -" Specifically, edge i of an .edge file is the dual of Voronoi edge i of\n"); - printf( -" the corresponding .v.edge file, and is rotated 90 degrees counterclock-\n"); - printf( -" wise from the Voronoi edge. Triangle j of an .ele file is the dual of\n"); - printf( -" vertex j of the corresponding .v.node file. Voronoi cell k is the dual\n"); - printf(" of vertex k of the corresponding .node file.\n\n"); - printf( -" Hence, to find the triangles adjacent to a Delaunay edge, look at the\n"); - printf( -" vertices of the corresponding Voronoi edge. If the endpoints of a\n"); - printf( -" Voronoi edge are Voronoi vertices 2 and 6 respectively, then triangles 2\n" -); - printf( -" and 6 adjoin the left and right sides of the corresponding Delaunay edge,\n" -); - printf( -" respectively. To find the Voronoi cells adjacent to a Voronoi edge, look\n" -); - printf( -" at the endpoints of the corresponding Delaunay edge. If the endpoints of\n" -); - printf( -" a Delaunay edge are input vertices 7 and 12, then Voronoi cells 7 and 12\n" -); - printf( -" adjoin the right and left sides of the corresponding Voronoi edge,\n"); - printf( -" respectively. To find which Voronoi cells are adjacent to each other,\n"); - printf(" just read the list of Delaunay edges.\n\n"); - printf( -" Triangle does not write a list of the edges adjoining each Voronoi cell,\n" -); - printf( -" but you can reconstructed it straightforwardly. For instance, to find\n"); - printf( -" all the edges of Voronoi cell 1, search the output .edge file for every\n"); - printf( -" edge that has input vertex 1 as an endpoint. The corresponding dual\n"); - printf( -" edges in the output .v.edge file form the boundary of Voronoi cell 1.\n"); - printf("\n"); - printf( -" For each Voronoi vertex, the .neigh file gives a list of the three\n"); - printf( -" Voronoi vertices attached to it. You might find this more convenient\n"); - printf(" than the .v.edge file.\n\n"); - printf("Quadratic Elements:\n\n"); - printf( -" Triangle generates meshes with subparametric quadratic elements if the\n"); - printf( -" -o2 switch is specified. Quadratic elements have six nodes per element,\n" -); - printf( -" rather than three. `Subparametric' means that the edges of the triangles\n" -); - printf( -" are always straight, so that subparametric quadratic elements are\n"); - printf( -" geometrically identical to linear elements, even though they can be used\n" -); - printf( -" with quadratic interpolating functions. The three extra nodes of an\n"); - printf( -" element fall at the midpoints of the three edges, with the fourth, fifth,\n" -); - printf( -" and sixth nodes appearing opposite the first, second, and third corners\n"); - printf(" respectively.\n\n"); - printf("Domains with Small Angles:\n\n"); - printf( -" If two input segments adjoin each other at a small angle, clearly the -q\n" -); - printf( -" switch cannot remove the small angle. Moreover, Triangle may have no\n"); - printf( -" choice but to generate additional triangles whose smallest angles are\n"); - printf( -" smaller than the specified bound. However, these triangles only appear\n"); - printf( -" between input segments separated by small angles. Moreover, if you\n"); - printf( -" request a minimum angle of theta degrees, Triangle will generally produce\n" -); - printf( -" no angle larger than 180 - 2 theta, even if it is forced to compromise on\n" -); - printf(" the minimum angle.\n\n"); - printf("Statistics:\n\n"); - printf( -" After generating a mesh, Triangle prints a count of entities in the\n"); - printf( -" output mesh, including the number of vertices, triangles, edges, exterior\n" -); - printf( -" boundary edges (i.e. subsegments on the boundary of the triangulation,\n"); - printf( -" including hole boundaries), interior boundary edges (i.e. subsegments of\n" -); - printf( -" input segments not on the boundary), and total subsegments. If you've\n"); - printf( -" forgotten the statistics for an existing mesh, run Triangle on that mesh\n" -); - printf( -" with the -rNEP switches to read the mesh and print the statistics without\n" -); - printf( -" writing any files. Use -rpNEP if you've got a .poly file for the mesh.\n"); - printf("\n"); - printf( -" The -V switch produces extended statistics, including a rough estimate\n"); - printf( -" of memory use, the number of calls to geometric predicates, and\n"); - printf( -" histograms of the angles and the aspect ratios of the triangles in the\n"); - printf(" mesh.\n\n"); - printf("Exact Arithmetic:\n\n"); - printf( -" Triangle uses adaptive exact arithmetic to perform what computational\n"); - printf( -" geometers call the `orientation' and `incircle' tests. If the floating-\n" -); - printf( -" point arithmetic of your machine conforms to the IEEE 754 standard (as\n"); - printf( -" most workstations do), and does not use extended precision internal\n"); - printf( -" floating-point registers, then your output is guaranteed to be an\n"); - printf( -" absolutely true Delaunay or constrained Delaunay triangulation, roundoff\n" -); - printf( -" error notwithstanding. The word `adaptive' implies that these arithmetic\n" -); - printf( -" routines compute the result only to the precision necessary to guarantee\n" -); - printf( -" correctness, so they are usually nearly as fast as their approximate\n"); - printf(" counterparts.\n\n"); - printf( -" May CPUs, including Intel x86 processors, have extended precision\n"); - printf( -" floating-point registers. These must be reconfigured so their precision\n" -); - printf( -" is reduced to memory precision. Triangle does this if it is compiled\n"); - printf(" correctly. See the makefile for details.\n\n"); - printf( -" The exact tests can be disabled with the -X switch. On most inputs, this\n" -); - printf( -" switch reduces the computation time by about eight percent--it's not\n"); - printf( -" worth the risk. There are rare difficult inputs (having many collinear\n"); - printf( -" and cocircular vertices), however, for which the difference in speed\n"); - printf( -" could be a factor of two. Be forewarned that these are precisely the\n"); - printf( -" inputs most likely to cause errors if you use the -X switch. Hence, the\n" -); - printf(" -X switch is not recommended.\n\n"); - printf( -" Unfortunately, the exact tests don't solve every numerical problem.\n"); - printf( -" Exact arithmetic is not used to compute the positions of new vertices,\n"); - printf( -" because the bit complexity of vertex coordinates would grow without\n"); - printf( -" bound. Hence, segment intersections aren't computed exactly; in very\n"); - printf( -" unusual cases, roundoff error in computing an intersection point might\n"); - printf( -" actually lead to an inverted triangle and an invalid triangulation.\n"); - printf( -" (This is one reason to specify your own intersection points in your .poly\n" -); - printf( -" files.) Similarly, exact arithmetic is not used to compute the vertices\n" -); - printf(" of the Voronoi diagram.\n\n"); - printf( -" Another pair of problems not solved by the exact arithmetic routines is\n"); - printf( -" underflow and overflow. If Triangle is compiled for double precision\n"); - printf( -" arithmetic, I believe that Triangle's geometric predicates work correctly\n" -); - printf( -" if the exponent of every input coordinate falls in the range [-148, 201].\n" -); - printf( -" Underflow can silently prevent the orientation and incircle tests from\n"); - printf( -" being performed exactly, while overflow typically causes a floating\n"); - printf(" exception.\n\n"); - printf("Calling Triangle from Another Program:\n\n"); - printf(" Read the file triangle.h for details.\n\n"); - printf("Troubleshooting:\n\n"); - printf(" Please read this section before mailing me bugs.\n\n"); - printf(" `My output mesh has no triangles!'\n\n"); - printf( -" If you're using a PSLG, you've probably failed to specify a proper set\n" -); - printf( -" of bounding segments, or forgotten to use the -c switch. Or you may\n"); - printf( -" have placed a hole badly, thereby eating all your triangles. To test\n"); - printf(" these possibilities, try again with the -c and -O switches.\n"); - printf( -" Alternatively, all your input vertices may be collinear, in which case\n" -); - printf(" you can hardly expect to triangulate them.\n\n"); - printf(" `Triangle doesn't terminate, or just crashes.'\n\n"); - printf( -" Bad things can happen when triangles get so small that the distance\n"); - printf( -" between their vertices isn't much larger than the precision of your\n"); - printf( -" machine's arithmetic. If you've compiled Triangle for single-precision\n" -); - printf( -" arithmetic, you might do better by recompiling it for double-precision.\n" -); - printf( -" Then again, you might just have to settle for more lenient constraints\n" -); - printf( -" on the minimum angle and the maximum area than you had planned.\n"); - printf("\n"); - printf( -" You can minimize precision problems by ensuring that the origin lies\n"); - printf( -" inside your vertex set, or even inside the densest part of your\n"); - printf( -" mesh. If you're triangulating an object whose x-coordinates all fall\n"); - printf( -" between 6247133 and 6247134, you're not leaving much floating-point\n"); - printf(" precision for Triangle to work with.\n\n"); - printf( -" Precision problems can occur covertly if the input PSLG contains two\n"); - printf( -" segments that meet (or intersect) at an extremely small angle, or if\n"); - printf( -" such an angle is introduced by the -c switch. If you don't realize\n"); - printf( -" that a tiny angle is being formed, you might never discover why\n"); - printf( -" Triangle is crashing. To check for this possibility, use the -S switch\n" -); - printf( -" (with an appropriate limit on the number of Steiner points, found by\n"); - printf( -" trial-and-error) to stop Triangle early, and view the output .poly file\n" -); - printf( -" with Show Me (described below). Look carefully for regions where dense\n" -); - printf( -" clusters of vertices are forming and for small angles between segments.\n" -); - printf( -" Zoom in closely, as such segments might look like a single segment from\n" -); - printf(" a distance.\n\n"); - printf( -" If some of the input values are too large, Triangle may suffer a\n"); - printf( -" floating exception due to overflow when attempting to perform an\n"); - printf( -" orientation or incircle test. (Read the section on exact arithmetic\n"); - printf( -" above.) Again, I recommend compiling Triangle for double (rather\n"); - printf(" than single) precision arithmetic.\n\n"); - printf( -" Unexpected problems can arise if you use quality meshing (-q, -a, or\n"); - printf( -" -u) with an input that is not segment-bounded--that is, if your input\n"); - printf( -" is a vertex set, or you're using the -c switch. If the convex hull of\n" -); - printf( -" your input vertices has collinear vertices on its boundary, an input\n"); - printf( -" vertex that you think lies on the convex hull might actually lie just\n"); - printf( -" inside the convex hull. If so, the vertex and the nearby convex hull\n"); - printf( -" edge form an extremely thin triangle. When Triangle tries to refine\n"); - printf( -" the mesh to enforce angle and area constraints, Triangle might generate\n" -); - printf( -" extremely tiny triangles, or it might fail because of insufficient\n"); - printf(" floating-point precision.\n\n"); - printf( -" `The numbering of the output vertices doesn't match the input vertices.'\n" -); - printf("\n"); - printf( -" You may have had duplicate input vertices, or you may have eaten some\n"); - printf( -" of your input vertices with a hole, or by placing them outside the area\n" -); - printf( -" enclosed by segments. In any case, you can solve the problem by not\n"); - printf(" using the -j switch.\n\n"); - printf( -" `Triangle executes without incident, but when I look at the resulting\n"); - printf( -" mesh, it has overlapping triangles or other geometric inconsistencies.'\n"); - printf("\n"); - printf( -" If you select the -X switch, Triangle occasionally makes mistakes due\n"); - printf( -" to floating-point roundoff error. Although these errors are rare,\n"); - printf( -" don't use the -X switch. If you still have problems, please report the\n" -); - printf(" bug.\n\n"); - printf( -" `Triangle executes without incident, but when I look at the resulting\n"); - printf(" Voronoi diagram, it has overlapping edges or other geometric\n"); - printf(" inconsistencies.'\n"); - printf("\n"); - printf( -" If your input is a PSLG (-p), you can only expect a meaningful Voronoi\n" -); - printf( -" diagram if the domain you are triangulating is convex and free of\n"); - printf( -" holes, and you use the -D switch to construct a conforming Delaunay\n"); - printf(" triangulation (instead of a CDT or CCDT).\n\n"); - printf( -" Strange things can happen if you've taken liberties with your PSLG. Do\n"); - printf( -" you have a vertex lying in the middle of a segment? Triangle sometimes\n"); - printf( -" copes poorly with that sort of thing. Do you want to lay out a collinear\n" -); - printf( -" row of evenly spaced, segment-connected vertices? Have you simply\n"); - printf( -" defined one long segment connecting the leftmost vertex to the rightmost\n" -); - printf( -" vertex, and a bunch of vertices lying along it? This method occasionally\n" -); - printf( -" works, especially with horizontal and vertical lines, but often it\n"); - printf( -" doesn't, and you'll have to connect each adjacent pair of vertices with a\n" -); - printf(" separate segment. If you don't like it, tough.\n\n"); - printf( -" Furthermore, if you have segments that intersect other than at their\n"); - printf( -" endpoints, try not to let the intersections fall extremely close to PSLG\n" -); - printf(" vertices or each other.\n\n"); - printf( -" If you have problems refining a triangulation not produced by Triangle:\n"); - printf( -" Are you sure the triangulation is geometrically valid? Is it formatted\n"); - printf( -" correctly for Triangle? Are the triangles all listed so the first three\n" -); - printf( -" vertices are their corners in counterclockwise order? Are all of the\n"); - printf( -" triangles constrained Delaunay? Triangle's Delaunay refinement algorithm\n" -); - printf(" assumes that it starts with a CDT.\n\n"); - printf("Show Me:\n\n"); - printf( -" Triangle comes with a separate program named `Show Me', whose primary\n"); - printf( -" purpose is to draw meshes on your screen or in PostScript. Its secondary\n" -); - printf( -" purpose is to check the validity of your input files, and do so more\n"); - printf( -" thoroughly than Triangle does. Unlike Triangle, Show Me requires that\n"); - printf( -" you have the X Windows system. Sorry, Microsoft Windows users.\n"); - printf("\n"); - printf("Triangle on the Web:\n"); - printf("\n"); - printf(" To see an illustrated version of these instructions, check out\n"); - printf("\n"); - printf(" http://www.cs.cmu.edu/~quake/triangle.html\n"); - printf("\n"); - printf("A Brief Plea:\n"); - printf("\n"); - printf( -" If you use Triangle, and especially if you use it to accomplish real\n"); - printf( -" work, I would like very much to hear from you. A short letter or email\n"); - printf( -" (to jrs@cs.berkeley.edu) describing how you use Triangle will mean a lot\n" -); - printf( -" to me. The more people I know are using this program, the more easily I\n" -); - printf( -" can justify spending time on improvements, which in turn will benefit\n"); - printf( -" you. Also, I can put you on a list to receive email whenever a new\n"); - printf(" version of Triangle is available.\n\n"); - printf( -" If you use a mesh generated by Triangle in a publication, please include\n" -); - printf( -" an acknowledgment as well. And please spell Triangle with a capital `T'!\n" -); - printf( -" If you want to include a citation, use `Jonathan Richard Shewchuk,\n"); - printf( -" ``Triangle: Engineering a 2D Quality Mesh Generator and Delaunay\n"); - printf( -" Triangulator,'' in Applied Computational Geometry: Towards Geometric\n"); - printf( -" Engineering (Ming C. Lin and Dinesh Manocha, editors), volume 1148 of\n"); - printf( -" Lecture Notes in Computer Science, pages 203-222, Springer-Verlag,\n"); - printf( -" Berlin, May 1996. (From the First ACM Workshop on Applied Computational\n" -); - printf(" Geometry.)'\n\n"); - printf("Research credit:\n\n"); - printf( -" Of course, I can take credit for only a fraction of the ideas that made\n"); - printf( -" this mesh generator possible. Triangle owes its existence to the efforts\n" -); - printf( -" of many fine computational geometers and other researchers, including\n"); - printf( -" Marshall Bern, L. Paul Chew, Kenneth L. Clarkson, Boris Delaunay, Rex A.\n" -); - printf( -" Dwyer, David Eppstein, Steven Fortune, Leonidas J. Guibas, Donald E.\n"); - printf( -" Knuth, Charles L. Lawson, Der-Tsai Lee, Gary L. Miller, Ernst P. Mucke,\n"); - printf( -" Steven E. Pav, Douglas M. Priest, Jim Ruppert, Isaac Saias, Bruce J.\n"); - printf( -" Schachter, Micha Sharir, Peter W. Shor, Daniel D. Sleator, Jorge Stolfi,\n" -); - printf(" Robert E. Tarjan, Alper Ungor, Christopher J. Van Wyk, Noel J.\n"); - printf( -" Walkington, and Binhai Zhu. See the comments at the beginning of the\n"); - printf(" source code for references.\n\n"); - triexit(0); -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* internalerror() Ask the user to send me the defective product. Exit. */ -/* */ -/*****************************************************************************/ - -void internalerror() -{ - printf(" Please report this bug to jrs@cs.berkeley.edu\n"); - printf(" Include the message above, your input data set, and the exact\n"); - printf(" command line you used to run Triangle.\n"); - triexit(1); -} - -/*****************************************************************************/ -/* */ -/* parsecommandline() Read the command line, identify switches, and set */ -/* up options and file names. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void parsecommandline(int argc, char **argv, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void parsecommandline(argc, argv, b) -int argc; -char **argv; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ -#ifdef TRILIBRARY -#define STARTINDEX 0 -#else /* not TRILIBRARY */ -#define STARTINDEX 1 - int increment; - int meshnumber; -#endif /* not TRILIBRARY */ - int i, j, k; - char workstring[FILENAMESIZE]; - - b->poly = b->refine = b->quality = 0; - b->vararea = b->fixedarea = b->usertest = 0; - b->regionattrib = b->convex = b->weighted = b->jettison = 0; - b->firstnumber = 1; - b->edgesout = b->voronoi = b->neighbors = b->geomview = 0; - b->nobound = b->nopolywritten = b->nonodewritten = b->noelewritten = 0; - b->noiterationnum = 0; - b->noholes = b->noexact = 0; - b->incremental = b->sweepline = 0; - b->dwyer = 1; - b->splitseg = 0; - b->docheck = 0; - b->nobisect = 0; - b->conformdel = 0; - b->steiner = -1; - b->order = 1; - b->minangle = 0.0; - b->maxarea = -1.0; - b->quiet = b->verbose = 0; -#ifndef TRILIBRARY - b->innodefilename[0] = '\0'; -#endif /* not TRILIBRARY */ - - for (i = STARTINDEX; i < argc; i++) { -#ifndef TRILIBRARY - if (argv[i][0] == '-') { -#endif /* not TRILIBRARY */ - for (j = STARTINDEX; argv[i][j] != '\0'; j++) { - if (argv[i][j] == 'p') { - b->poly = 1; - } -#ifndef CDT_ONLY - if (argv[i][j] == 'r') { - b->refine = 1; - } - if (argv[i][j] == 'q') { - b->quality = 1; - if (((argv[i][j + 1] >= '0') && (argv[i][j + 1] <= '9')) || - (argv[i][j + 1] == '.')) { - k = 0; - while (((argv[i][j + 1] >= '0') && (argv[i][j + 1] <= '9')) || - (argv[i][j + 1] == '.')) { - j++; - workstring[k] = argv[i][j]; - k++; - } - workstring[k] = '\0'; - b->minangle = (REAL) strtod(workstring, (char **) NULL); - } else { - b->minangle = 20.0; - } - } - if (argv[i][j] == 'a') { - b->quality = 1; - if (((argv[i][j + 1] >= '0') && (argv[i][j + 1] <= '9')) || - (argv[i][j + 1] == '.')) { - b->fixedarea = 1; - k = 0; - while (((argv[i][j + 1] >= '0') && (argv[i][j + 1] <= '9')) || - (argv[i][j + 1] == '.')) { - j++; - workstring[k] = argv[i][j]; - k++; - } - workstring[k] = '\0'; - b->maxarea = (REAL) strtod(workstring, (char **) NULL); - if (b->maxarea <= 0.0) { - printf("Error: Maximum area must be greater than zero.\n"); - triexit(1); - } - } else { - b->vararea = 1; - } - } - if (argv[i][j] == 'u') { - b->quality = 1; - b->usertest = 1; - } -#endif /* not CDT_ONLY */ - if (argv[i][j] == 'A') { - b->regionattrib = 1; - } - if (argv[i][j] == 'c') { - b->convex = 1; - } - if (argv[i][j] == 'w') { - b->weighted = 1; - } - if (argv[i][j] == 'W') { - b->weighted = 2; - } - if (argv[i][j] == 'j') { - b->jettison = 1; - } - if (argv[i][j] == 'z') { - b->firstnumber = 0; - } - if (argv[i][j] == 'e') { - b->edgesout = 1; - } - if (argv[i][j] == 'v') { - b->voronoi = 1; - } - if (argv[i][j] == 'n') { - b->neighbors = 1; - } - if (argv[i][j] == 'g') { - b->geomview = 1; - } - if (argv[i][j] == 'B') { - b->nobound = 1; - } - if (argv[i][j] == 'P') { - b->nopolywritten = 1; - } - if (argv[i][j] == 'N') { - b->nonodewritten = 1; - } - if (argv[i][j] == 'E') { - b->noelewritten = 1; - } -#ifndef TRILIBRARY - if (argv[i][j] == 'I') { - b->noiterationnum = 1; - } -#endif /* not TRILIBRARY */ - if (argv[i][j] == 'O') { - b->noholes = 1; - } - if (argv[i][j] == 'X') { - b->noexact = 1; - } - if (argv[i][j] == 'o') { - if (argv[i][j + 1] == '2') { - j++; - b->order = 2; - } - } -#ifndef CDT_ONLY - if (argv[i][j] == 'Y') { - b->nobisect++; - } - if (argv[i][j] == 'S') { - b->steiner = 0; - while ((argv[i][j + 1] >= '0') && (argv[i][j + 1] <= '9')) { - j++; - b->steiner = b->steiner * 10 + (int) (argv[i][j] - '0'); - } - } -#endif /* not CDT_ONLY */ -#ifndef REDUCED - if (argv[i][j] == 'i') { - b->incremental = 1; - } - if (argv[i][j] == 'F') { - b->sweepline = 1; - } -#endif /* not REDUCED */ - if (argv[i][j] == 'l') { - b->dwyer = 0; - } -#ifndef REDUCED -#ifndef CDT_ONLY - if (argv[i][j] == 's') { - b->splitseg = 1; - } - if ((argv[i][j] == 'D') || (argv[i][j] == 'L')) { - b->quality = 1; - b->conformdel = 1; - } -#endif /* not CDT_ONLY */ - if (argv[i][j] == 'C') { - b->docheck = 1; - } -#endif /* not REDUCED */ - if (argv[i][j] == 'Q') { - b->quiet = 1; - } - if (argv[i][j] == 'V') { - b->verbose++; - } -#ifndef TRILIBRARY - if ((argv[i][j] == 'h') || (argv[i][j] == 'H') || - (argv[i][j] == '?')) { - info(); - } -#endif /* not TRILIBRARY */ - } -#ifndef TRILIBRARY - } else { - strncpy(b->innodefilename, argv[i], FILENAMESIZE - 1); - b->innodefilename[FILENAMESIZE - 1] = '\0'; - } -#endif /* not TRILIBRARY */ - } -#ifndef TRILIBRARY - if (b->innodefilename[0] == '\0') { - syntax(); - } - if (!strcmp(&b->innodefilename[strlen(b->innodefilename) - 5], ".node")) { - b->innodefilename[strlen(b->innodefilename) - 5] = '\0'; - } - if (!strcmp(&b->innodefilename[strlen(b->innodefilename) - 5], ".poly")) { - b->innodefilename[strlen(b->innodefilename) - 5] = '\0'; - b->poly = 1; - } -#ifndef CDT_ONLY - if (!strcmp(&b->innodefilename[strlen(b->innodefilename) - 4], ".ele")) { - b->innodefilename[strlen(b->innodefilename) - 4] = '\0'; - b->refine = 1; - } - if (!strcmp(&b->innodefilename[strlen(b->innodefilename) - 5], ".area")) { - b->innodefilename[strlen(b->innodefilename) - 5] = '\0'; - b->refine = 1; - b->quality = 1; - b->vararea = 1; - } -#endif /* not CDT_ONLY */ -#endif /* not TRILIBRARY */ - b->usesegments = b->poly || b->refine || b->quality || b->convex; - b->goodangle = cos(b->minangle * PI / 180.0); - if (b->goodangle == 1.0) { - b->offconstant = 0.0; - } else { - b->offconstant = 0.475 * sqrt((1.0 + b->goodangle) / (1.0 - b->goodangle)); - } - b->goodangle *= b->goodangle; - if (b->refine && b->noiterationnum) { - printf( - "Error: You cannot use the -I switch when refining a triangulation.\n"); - triexit(1); - } - /* Be careful not to allocate space for element area constraints that */ - /* will never be assigned any value (other than the default -1.0). */ - if (!b->refine && !b->poly) { - b->vararea = 0; - } - /* Be careful not to add an extra attribute to each element unless the */ - /* input supports it (PSLG in, but not refining a preexisting mesh). */ - if (b->refine || !b->poly) { - b->regionattrib = 0; - } - /* Regular/weighted triangulations are incompatible with PSLGs */ - /* and meshing. */ - if (b->weighted && (b->poly || b->quality)) { - b->weighted = 0; - if (!b->quiet) { - printf("Warning: weighted triangulations (-w, -W) are incompatible\n"); - printf(" with PSLGs (-p) and meshing (-q, -a, -u). Weights ignored.\n" - ); - } - } - if (b->jettison && b->nonodewritten && !b->quiet) { - printf("Warning: -j and -N switches are somewhat incompatible.\n"); - printf(" If any vertices are jettisoned, you will need the output\n"); - printf(" .node file to reconstruct the new node indices."); - } - -#ifndef TRILIBRARY - strcpy(b->inpolyfilename, b->innodefilename); - strcpy(b->inelefilename, b->innodefilename); - strcpy(b->areafilename, b->innodefilename); - increment = 0; - strcpy(workstring, b->innodefilename); - j = 1; - while (workstring[j] != '\0') { - if ((workstring[j] == '.') && (workstring[j + 1] != '\0')) { - increment = j + 1; - } - j++; - } - meshnumber = 0; - if (increment > 0) { - j = increment; - do { - if ((workstring[j] >= '0') && (workstring[j] <= '9')) { - meshnumber = meshnumber * 10 + (int) (workstring[j] - '0'); - } else { - increment = 0; - } - j++; - } while (workstring[j] != '\0'); - } - if (b->noiterationnum) { - strcpy(b->outnodefilename, b->innodefilename); - strcpy(b->outelefilename, b->innodefilename); - strcpy(b->edgefilename, b->innodefilename); - strcpy(b->vnodefilename, b->innodefilename); - strcpy(b->vedgefilename, b->innodefilename); - strcpy(b->neighborfilename, b->innodefilename); - strcpy(b->offfilename, b->innodefilename); - strcat(b->outnodefilename, ".node"); - strcat(b->outelefilename, ".ele"); - strcat(b->edgefilename, ".edge"); - strcat(b->vnodefilename, ".v.node"); - strcat(b->vedgefilename, ".v.edge"); - strcat(b->neighborfilename, ".neigh"); - strcat(b->offfilename, ".off"); - } else if (increment == 0) { - strcpy(b->outnodefilename, b->innodefilename); - strcpy(b->outpolyfilename, b->innodefilename); - strcpy(b->outelefilename, b->innodefilename); - strcpy(b->edgefilename, b->innodefilename); - strcpy(b->vnodefilename, b->innodefilename); - strcpy(b->vedgefilename, b->innodefilename); - strcpy(b->neighborfilename, b->innodefilename); - strcpy(b->offfilename, b->innodefilename); - strcat(b->outnodefilename, ".1.node"); - strcat(b->outpolyfilename, ".1.poly"); - strcat(b->outelefilename, ".1.ele"); - strcat(b->edgefilename, ".1.edge"); - strcat(b->vnodefilename, ".1.v.node"); - strcat(b->vedgefilename, ".1.v.edge"); - strcat(b->neighborfilename, ".1.neigh"); - strcat(b->offfilename, ".1.off"); - } else { - workstring[increment] = '%'; - workstring[increment + 1] = 'd'; - workstring[increment + 2] = '\0'; - sprintf(b->outnodefilename, workstring, meshnumber + 1); - strcpy(b->outpolyfilename, b->outnodefilename); - strcpy(b->outelefilename, b->outnodefilename); - strcpy(b->edgefilename, b->outnodefilename); - strcpy(b->vnodefilename, b->outnodefilename); - strcpy(b->vedgefilename, b->outnodefilename); - strcpy(b->neighborfilename, b->outnodefilename); - strcpy(b->offfilename, b->outnodefilename); - strcat(b->outnodefilename, ".node"); - strcat(b->outpolyfilename, ".poly"); - strcat(b->outelefilename, ".ele"); - strcat(b->edgefilename, ".edge"); - strcat(b->vnodefilename, ".v.node"); - strcat(b->vedgefilename, ".v.edge"); - strcat(b->neighborfilename, ".neigh"); - strcat(b->offfilename, ".off"); - } - strcat(b->innodefilename, ".node"); - strcat(b->inpolyfilename, ".poly"); - strcat(b->inelefilename, ".ele"); - strcat(b->areafilename, ".area"); -#endif /* not TRILIBRARY */ -} - -/** **/ -/** **/ -/********* User interaction routines begin here *********/ - -/********* Debugging routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* printtriangle() Print out the details of an oriented triangle. */ -/* */ -/* I originally wrote this procedure to simplify debugging; it can be */ -/* called directly from the debugger, and presents information about an */ -/* oriented triangle in digestible form. It's also used when the */ -/* highest level of verbosity (`-VVV') is specified. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void printtriangle(struct mesh *m, struct behavior *b, struct otri *t) -#else /* not ANSI_DECLARATORS */ -void printtriangle(m, b, t) -struct mesh *m; -struct behavior *b; -struct otri *t; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri printtri; - struct osub printsh; - vertex printvertex; - - printf("triangle x%lx with orientation %d:\n", (unsigned long) t->tri, - t->orient); - decode(t->tri[0], printtri); - if (printtri.tri == m->dummytri) { - printf(" [0] = Outer space\n"); - } else { - printf(" [0] = x%lx %d\n", (unsigned long) printtri.tri, - printtri.orient); - } - decode(t->tri[1], printtri); - if (printtri.tri == m->dummytri) { - printf(" [1] = Outer space\n"); - } else { - printf(" [1] = x%lx %d\n", (unsigned long) printtri.tri, - printtri.orient); - } - decode(t->tri[2], printtri); - if (printtri.tri == m->dummytri) { - printf(" [2] = Outer space\n"); - } else { - printf(" [2] = x%lx %d\n", (unsigned long) printtri.tri, - printtri.orient); - } - - org(*t, printvertex); - if (printvertex == (vertex) NULL) - printf(" Origin[%d] = NULL\n", (t->orient + 1) % 3 + 3); - else - printf(" Origin[%d] = x%lx (%.12g, %.12g)\n", - (t->orient + 1) % 3 + 3, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - dest(*t, printvertex); - if (printvertex == (vertex) NULL) - printf(" Dest [%d] = NULL\n", (t->orient + 2) % 3 + 3); - else - printf(" Dest [%d] = x%lx (%.12g, %.12g)\n", - (t->orient + 2) % 3 + 3, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - apex(*t, printvertex); - if (printvertex == (vertex) NULL) - printf(" Apex [%d] = NULL\n", t->orient + 3); - else - printf(" Apex [%d] = x%lx (%.12g, %.12g)\n", - t->orient + 3, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - - if (b->usesegments) { - sdecode(t->tri[6], printsh); - if (printsh.ss != m->dummysub) { - printf(" [6] = x%lx %d\n", (unsigned long) printsh.ss, - printsh.ssorient); - } - sdecode(t->tri[7], printsh); - if (printsh.ss != m->dummysub) { - printf(" [7] = x%lx %d\n", (unsigned long) printsh.ss, - printsh.ssorient); - } - sdecode(t->tri[8], printsh); - if (printsh.ss != m->dummysub) { - printf(" [8] = x%lx %d\n", (unsigned long) printsh.ss, - printsh.ssorient); - } - } - - if (b->vararea) { - printf(" Area constraint: %.4g\n", areabound(*t)); - } -} - -/*****************************************************************************/ -/* */ -/* printsubseg() Print out the details of an oriented subsegment. */ -/* */ -/* I originally wrote this procedure to simplify debugging; it can be */ -/* called directly from the debugger, and presents information about an */ -/* oriented subsegment in digestible form. It's also used when the highest */ -/* level of verbosity (`-VVV') is specified. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void printsubseg(struct mesh *m, struct behavior *b, struct osub *s) -#else /* not ANSI_DECLARATORS */ -void printsubseg(m, b, s) -struct mesh *m; -struct behavior *b; -struct osub *s; -#endif /* not ANSI_DECLARATORS */ - -{ - struct osub printsh; - struct otri printtri; - vertex printvertex; - - printf("subsegment x%lx with orientation %d and mark %d:\n", - (unsigned long) s->ss, s->ssorient, mark(*s)); - sdecode(s->ss[0], printsh); - if (printsh.ss == m->dummysub) { - printf(" [0] = No subsegment\n"); - } else { - printf(" [0] = x%lx %d\n", (unsigned long) printsh.ss, - printsh.ssorient); - } - sdecode(s->ss[1], printsh); - if (printsh.ss == m->dummysub) { - printf(" [1] = No subsegment\n"); - } else { - printf(" [1] = x%lx %d\n", (unsigned long) printsh.ss, - printsh.ssorient); - } - - sorg(*s, printvertex); - if (printvertex == (vertex) NULL) - printf(" Origin[%d] = NULL\n", 2 + s->ssorient); - else - printf(" Origin[%d] = x%lx (%.12g, %.12g)\n", - 2 + s->ssorient, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - sdest(*s, printvertex); - if (printvertex == (vertex) NULL) - printf(" Dest [%d] = NULL\n", 3 - s->ssorient); - else - printf(" Dest [%d] = x%lx (%.12g, %.12g)\n", - 3 - s->ssorient, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - - decode(s->ss[6], printtri); - if (printtri.tri == m->dummytri) { - printf(" [6] = Outer space\n"); - } else { - printf(" [6] = x%lx %d\n", (unsigned long) printtri.tri, - printtri.orient); - } - decode(s->ss[7], printtri); - if (printtri.tri == m->dummytri) { - printf(" [7] = Outer space\n"); - } else { - printf(" [7] = x%lx %d\n", (unsigned long) printtri.tri, - printtri.orient); - } - - segorg(*s, printvertex); - if (printvertex == (vertex) NULL) - printf(" Segment origin[%d] = NULL\n", 4 + s->ssorient); - else - printf(" Segment origin[%d] = x%lx (%.12g, %.12g)\n", - 4 + s->ssorient, (unsigned long) printvertex, - printvertex[0], printvertex[1]); - segdest(*s, printvertex); - if (printvertex == (vertex) NULL) - printf(" Segment dest [%d] = NULL\n", 5 - s->ssorient); - else - printf(" Segment dest [%d] = x%lx (%.12g, %.12g)\n", - 5 - s->ssorient, (unsigned long) printvertex, - printvertex[0], printvertex[1]); -} - -/** **/ -/** **/ -/********* Debugging routines end here *********/ - -/********* Memory management routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* poolzero() Set all of a pool's fields to zero. */ -/* */ -/* This procedure should never be called on a pool that has any memory */ -/* allocated to it, as that memory would leak. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void poolzero(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -void poolzero(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - pool->firstblock = (VOID **) NULL; - pool->nowblock = (VOID **) NULL; - pool->nextitem = (VOID *) NULL; - pool->deaditemstack = (VOID *) NULL; - pool->pathblock = (VOID **) NULL; - pool->pathitem = (VOID *) NULL; - pool->alignbytes = 0; - pool->itembytes = 0; - pool->itemsperblock = 0; - pool->itemsfirstblock = 0; - pool->items = 0; - pool->maxitems = 0; - pool->unallocateditems = 0; - pool->pathitemsleft = 0; -} - -/*****************************************************************************/ -/* */ -/* poolrestart() Deallocate all items in a pool. */ -/* */ -/* The pool is returned to its starting state, except that no memory is */ -/* freed to the operating system. Rather, the previously allocated blocks */ -/* are ready to be reused. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void poolrestart(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -void poolrestart(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - unsigned long alignptr; - - pool->items = 0; - pool->maxitems = 0; - - /* Set the currently active block. */ - pool->nowblock = pool->firstblock; - /* Find the first item in the pool. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->nowblock + 1); - /* Align the item on an `alignbytes'-byte boundary. */ - pool->nextitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); - /* There are lots of unallocated items left in this block. */ - pool->unallocateditems = pool->itemsfirstblock; - /* The stack of deallocated items is empty. */ - pool->deaditemstack = (VOID *) NULL; -} - -/*****************************************************************************/ -/* */ -/* poolinit() Initialize a pool of memory for allocation of items. */ -/* */ -/* This routine initializes the machinery for allocating items. A `pool' */ -/* is created whose records have size at least `bytecount'. Items will be */ -/* allocated in `itemcount'-item blocks. Each item is assumed to be a */ -/* collection of words, and either pointers or floating-point values are */ -/* assumed to be the "primary" word type. (The "primary" word type is used */ -/* to determine alignment of items.) If `alignment' isn't zero, all items */ -/* will be `alignment'-byte aligned in memory. `alignment' must be either */ -/* a multiple or a factor of the primary word size; powers of two are safe. */ -/* `alignment' is normally used to create a few unused bits at the bottom */ -/* of each item's pointer, in which information may be stored. */ -/* */ -/* Don't change this routine unless you understand it. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void poolinit(struct memorypool *pool, int bytecount, int itemcount, - int firstitemcount, int alignment) -#else /* not ANSI_DECLARATORS */ -void poolinit(pool, bytecount, itemcount, firstitemcount, alignment) -struct memorypool *pool; -int bytecount; -int itemcount; -int firstitemcount; -int alignment; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Find the proper alignment, which must be at least as large as: */ - /* - The parameter `alignment'. */ - /* - sizeof(VOID *), so the stack of dead items can be maintained */ - /* without unaligned accesses. */ - if (alignment > sizeof(VOID *)) { - pool->alignbytes = alignment; - } else { - pool->alignbytes = sizeof(VOID *); - } - pool->itembytes = ((bytecount - 1) / pool->alignbytes + 1) * - pool->alignbytes; - pool->itemsperblock = itemcount; - if (firstitemcount == 0) { - pool->itemsfirstblock = itemcount; - } else { - pool->itemsfirstblock = firstitemcount; - } - - /* Allocate a block of items. Space for `itemsfirstblock' items and one */ - /* pointer (to point to the next block) are allocated, as well as space */ - /* to ensure alignment of the items. */ - pool->firstblock = (VOID **) - trimalloc(pool->itemsfirstblock * pool->itembytes + (int) sizeof(VOID *) + - pool->alignbytes); - /* Set the next block pointer to NULL. */ - *(pool->firstblock) = (VOID *) NULL; - poolrestart(pool); -} - -/*****************************************************************************/ -/* */ -/* pooldeinit() Free to the operating system all memory taken by a pool. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void pooldeinit(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -void pooldeinit(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - while (pool->firstblock != (VOID **) NULL) { - pool->nowblock = (VOID **) *(pool->firstblock); - trifree((VOID *) pool->firstblock); - pool->firstblock = pool->nowblock; - } -} - -/*****************************************************************************/ -/* */ -/* poolalloc() Allocate space for an item. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -VOID *poolalloc(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -VOID *poolalloc(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - VOID *newitem; - VOID **newblock; - unsigned long alignptr; - - /* First check the linked list of dead items. If the list is not */ - /* empty, allocate an item from the list rather than a fresh one. */ - if (pool->deaditemstack != (VOID *) NULL) { - newitem = pool->deaditemstack; /* Take first item in list. */ - pool->deaditemstack = * (VOID **) pool->deaditemstack; - } else { - /* Check if there are any free items left in the current block. */ - if (pool->unallocateditems == 0) { - /* Check if another block must be allocated. */ - if (*(pool->nowblock) == (VOID *) NULL) { - /* Allocate a new block of items, pointed to by the previous block. */ - newblock = (VOID **) trimalloc(pool->itemsperblock * pool->itembytes + - (int) sizeof(VOID *) + - pool->alignbytes); - *(pool->nowblock) = (VOID *) newblock; - /* The next block pointer is NULL. */ - *newblock = (VOID *) NULL; - } - - /* Move to the new block. */ - pool->nowblock = (VOID **) *(pool->nowblock); - /* Find the first item in the block. */ - /* Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->nowblock + 1); - /* Align the item on an `alignbytes'-byte boundary. */ - pool->nextitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); - /* There are lots of unallocated items left in this block. */ - pool->unallocateditems = pool->itemsperblock; - } - - /* Allocate a new item. */ - newitem = pool->nextitem; - /* Advance `nextitem' pointer to next free item in block. */ - pool->nextitem = (VOID *) ((char *) pool->nextitem + pool->itembytes); - pool->unallocateditems--; - pool->maxitems++; - } - pool->items++; - return newitem; -} - -/*****************************************************************************/ -/* */ -/* pooldealloc() Deallocate space for an item. */ -/* */ -/* The deallocated space is stored in a queue for later reuse. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void pooldealloc(struct memorypool *pool, VOID *dyingitem) -#else /* not ANSI_DECLARATORS */ -void pooldealloc(pool, dyingitem) -struct memorypool *pool; -VOID *dyingitem; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Push freshly killed item onto stack. */ - *((VOID **) dyingitem) = pool->deaditemstack; - pool->deaditemstack = dyingitem; - pool->items--; -} - -/*****************************************************************************/ -/* */ -/* traversalinit() Prepare to traverse the entire list of items. */ -/* */ -/* This routine is used in conjunction with traverse(). */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void traversalinit(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -void traversalinit(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - unsigned long alignptr; - - /* Begin the traversal in the first block. */ - pool->pathblock = pool->firstblock; - /* Find the first item in the block. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->pathblock + 1); - /* Align with item on an `alignbytes'-byte boundary. */ - pool->pathitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); - /* Set the number of items left in the current block. */ - pool->pathitemsleft = pool->itemsfirstblock; -} - -/*****************************************************************************/ -/* */ -/* traverse() Find the next item in the list. */ -/* */ -/* This routine is used in conjunction with traversalinit(). Be forewarned */ -/* that this routine successively returns all items in the list, including */ -/* deallocated ones on the deaditemqueue. It's up to you to figure out */ -/* which ones are actually dead. Why? I don't want to allocate extra */ -/* space just to demarcate dead items. It can usually be done more */ -/* space-efficiently by a routine that knows something about the structure */ -/* of the item. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -VOID *traverse(struct memorypool *pool) -#else /* not ANSI_DECLARATORS */ -VOID *traverse(pool) -struct memorypool *pool; -#endif /* not ANSI_DECLARATORS */ - -{ - VOID *newitem; - unsigned long alignptr; - - /* Stop upon exhausting the list of items. */ - if (pool->pathitem == pool->nextitem) { - return (VOID *) NULL; - } - - /* Check whether any untraversed items remain in the current block. */ - if (pool->pathitemsleft == 0) { - /* Find the next block. */ - pool->pathblock = (VOID **) *(pool->pathblock); - /* Find the first item in the block. Increment by the size of (VOID *). */ - alignptr = (unsigned long) (pool->pathblock + 1); - /* Align with item on an `alignbytes'-byte boundary. */ - pool->pathitem = (VOID *) - (alignptr + (unsigned long) pool->alignbytes - - (alignptr % (unsigned long) pool->alignbytes)); - /* Set the number of items left in the current block. */ - pool->pathitemsleft = pool->itemsperblock; - } - - newitem = pool->pathitem; - /* Find the next item in the block. */ - pool->pathitem = (VOID *) ((char *) pool->pathitem + pool->itembytes); - pool->pathitemsleft--; - return newitem; -} - -/*****************************************************************************/ -/* */ -/* dummyinit() Initialize the triangle that fills "outer space" and the */ -/* omnipresent subsegment. */ -/* */ -/* The triangle that fills "outer space," called `dummytri', is pointed to */ -/* by every triangle and subsegment on a boundary (be it outer or inner) of */ -/* the triangulation. Also, `dummytri' points to one of the triangles on */ -/* the convex hull (until the holes and concavities are carved), making it */ -/* possible to find a starting triangle for point location. */ -/* */ -/* The omnipresent subsegment, `dummysub', is pointed to by every triangle */ -/* or subsegment that doesn't have a full complement of real subsegments */ -/* to point to. */ -/* */ -/* `dummytri' and `dummysub' are generally required to fulfill only a few */ -/* invariants: their vertices must remain NULL and `dummytri' must always */ -/* be bonded (at offset zero) to some triangle on the convex hull of the */ -/* mesh, via a boundary edge. Otherwise, the connections of `dummytri' and */ -/* `dummysub' may change willy-nilly. This makes it possible to avoid */ -/* writing a good deal of special-case code (in the edge flip, for example) */ -/* for dealing with the boundary of the mesh, places where no subsegment is */ -/* present, and so forth. Other entities are frequently bonded to */ -/* `dummytri' and `dummysub' as if they were real mesh entities, with no */ -/* harm done. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void dummyinit(struct mesh *m, struct behavior *b, int trianglebytes, - int subsegbytes) -#else /* not ANSI_DECLARATORS */ -void dummyinit(m, b, trianglebytes, subsegbytes) -struct mesh *m; -struct behavior *b; -int trianglebytes; -int subsegbytes; -#endif /* not ANSI_DECLARATORS */ - -{ - unsigned long alignptr; - - /* Set up `dummytri', the `triangle' that occupies "outer space." */ - m->dummytribase = (triangle *) trimalloc(trianglebytes + - m->triangles.alignbytes); - /* Align `dummytri' on a `triangles.alignbytes'-byte boundary. */ - alignptr = (unsigned long) m->dummytribase; - m->dummytri = (triangle *) - (alignptr + (unsigned long) m->triangles.alignbytes - - (alignptr % (unsigned long) m->triangles.alignbytes)); - /* Initialize the three adjoining triangles to be "outer space." These */ - /* will eventually be changed by various bonding operations, but their */ - /* values don't really matter, as long as they can legally be */ - /* dereferenced. */ - m->dummytri[0] = (triangle) m->dummytri; - m->dummytri[1] = (triangle) m->dummytri; - m->dummytri[2] = (triangle) m->dummytri; - /* Three NULL vertices. */ - m->dummytri[3] = (triangle) NULL; - m->dummytri[4] = (triangle) NULL; - m->dummytri[5] = (triangle) NULL; - - if (b->usesegments) { - /* Set up `dummysub', the omnipresent subsegment pointed to by any */ - /* triangle side or subsegment end that isn't attached to a real */ - /* subsegment. */ - m->dummysubbase = (subseg *) trimalloc(subsegbytes + - m->subsegs.alignbytes); - /* Align `dummysub' on a `subsegs.alignbytes'-byte boundary. */ - alignptr = (unsigned long) m->dummysubbase; - m->dummysub = (subseg *) - (alignptr + (unsigned long) m->subsegs.alignbytes - - (alignptr % (unsigned long) m->subsegs.alignbytes)); - /* Initialize the two adjoining subsegments to be the omnipresent */ - /* subsegment. These will eventually be changed by various bonding */ - /* operations, but their values don't really matter, as long as they */ - /* can legally be dereferenced. */ - m->dummysub[0] = (subseg) m->dummysub; - m->dummysub[1] = (subseg) m->dummysub; - /* Four NULL vertices. */ - m->dummysub[2] = (subseg) NULL; - m->dummysub[3] = (subseg) NULL; - m->dummysub[4] = (subseg) NULL; - m->dummysub[5] = (subseg) NULL; - /* Initialize the two adjoining triangles to be "outer space." */ - m->dummysub[6] = (subseg) m->dummytri; - m->dummysub[7] = (subseg) m->dummytri; - /* Set the boundary marker to zero. */ - * (int *) (m->dummysub + 8) = 0; - - /* Initialize the three adjoining subsegments of `dummytri' to be */ - /* the omnipresent subsegment. */ - m->dummytri[6] = (triangle) m->dummysub; - m->dummytri[7] = (triangle) m->dummysub; - m->dummytri[8] = (triangle) m->dummysub; - } -} - -/*****************************************************************************/ -/* */ -/* initializevertexpool() Calculate the size of the vertex data structure */ -/* and initialize its memory pool. */ -/* */ -/* This routine also computes the `vertexmarkindex' and `vertex2triindex' */ -/* indices used to find values within each vertex. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void initializevertexpool(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void initializevertexpool(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - int vertexsize; - - /* The index within each vertex at which the boundary marker is found, */ - /* followed by the vertex type. Ensure the vertex marker is aligned to */ - /* a sizeof(int)-byte address. */ - m->vertexmarkindex = ((m->mesh_dim + m->nextras) * sizeof(REAL) + - sizeof(int) - 1) / - sizeof(int); - vertexsize = (m->vertexmarkindex + 2) * sizeof(int); - if (b->poly) { - /* The index within each vertex at which a triangle pointer is found. */ - /* Ensure the pointer is aligned to a sizeof(triangle)-byte address. */ - m->vertex2triindex = (vertexsize + sizeof(triangle) - 1) / - sizeof(triangle); - vertexsize = (m->vertex2triindex + 1) * sizeof(triangle); - } - - /* Initialize the pool of vertices. */ - poolinit(&m->vertices, vertexsize, VERTEXPERBLOCK, - m->invertices > VERTEXPERBLOCK ? m->invertices : VERTEXPERBLOCK, - sizeof(REAL)); -} - -/*****************************************************************************/ -/* */ -/* initializetrisubpools() Calculate the sizes of the triangle and */ -/* subsegment data structures and initialize */ -/* their memory pools. */ -/* */ -/* This routine also computes the `highorderindex', `elemattribindex', and */ -/* `areaboundindex' indices used to find values within each triangle. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void initializetrisubpools(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void initializetrisubpools(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - int trisize; - - /* The index within each triangle at which the extra nodes (above three) */ - /* associated with high order elements are found. There are three */ - /* pointers to other triangles, three pointers to corners, and possibly */ - /* three pointers to subsegments before the extra nodes. */ - m->highorderindex = 6 + (b->usesegments * 3); - /* The number of bytes occupied by a triangle. */ - trisize = ((b->order + 1) * (b->order + 2) / 2 + (m->highorderindex - 3)) * - sizeof(triangle); - /* The index within each triangle at which its attributes are found, */ - /* where the index is measured in REALs. */ - m->elemattribindex = (trisize + sizeof(REAL) - 1) / sizeof(REAL); - /* The index within each triangle at which the maximum area constraint */ - /* is found, where the index is measured in REALs. Note that if the */ - /* `regionattrib' flag is set, an additional attribute will be added. */ - m->areaboundindex = m->elemattribindex + m->eextras + b->regionattrib; - /* If triangle attributes or an area bound are needed, increase the number */ - /* of bytes occupied by a triangle. */ - if (b->vararea) { - trisize = (m->areaboundindex + 1) * sizeof(REAL); - } else if (m->eextras + b->regionattrib > 0) { - trisize = m->areaboundindex * sizeof(REAL); - } - /* If a Voronoi diagram or triangle neighbor graph is requested, make */ - /* sure there's room to store an integer index in each triangle. This */ - /* integer index can occupy the same space as the subsegment pointers */ - /* or attributes or area constraint or extra nodes. */ - if ((b->voronoi || b->neighbors) && - (trisize < 6 * sizeof(triangle) + sizeof(int))) { - trisize = 6 * sizeof(triangle) + sizeof(int); - } - - /* Having determined the memory size of a triangle, initialize the pool. */ - poolinit(&m->triangles, trisize, TRIPERBLOCK, - (2 * m->invertices - 2) > TRIPERBLOCK ? (2 * m->invertices - 2) : - TRIPERBLOCK, 4); - - if (b->usesegments) { - /* Initialize the pool of subsegments. Take into account all eight */ - /* pointers and one boundary marker. */ - poolinit(&m->subsegs, 8 * sizeof(triangle) + sizeof(int), - SUBSEGPERBLOCK, SUBSEGPERBLOCK, 4); - - /* Initialize the "outer space" triangle and omnipresent subsegment. */ - dummyinit(m, b, m->triangles.itembytes, m->subsegs.itembytes); - } else { - /* Initialize the "outer space" triangle. */ - dummyinit(m, b, m->triangles.itembytes, 0); - } -} - -/*****************************************************************************/ -/* */ -/* triangledealloc() Deallocate space for a triangle, marking it dead. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void triangledealloc(struct mesh *m, triangle *dyingtriangle) -#else /* not ANSI_DECLARATORS */ -void triangledealloc(m, dyingtriangle) -struct mesh *m; -triangle *dyingtriangle; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Mark the triangle as dead. This makes it possible to detect dead */ - /* triangles when traversing the list of all triangles. */ - killtri(dyingtriangle); - pooldealloc(&m->triangles, (VOID *) dyingtriangle); -} - -/*****************************************************************************/ -/* */ -/* triangletraverse() Traverse the triangles, skipping dead ones. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -triangle *triangletraverse(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -triangle *triangletraverse(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - triangle *newtriangle; - - do { - newtriangle = (triangle *) traverse(&m->triangles); - if (newtriangle == (triangle *) NULL) { - return (triangle *) NULL; - } - } while (deadtri(newtriangle)); /* Skip dead ones. */ - return newtriangle; -} - -/*****************************************************************************/ -/* */ -/* subsegdealloc() Deallocate space for a subsegment, marking it dead. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void subsegdealloc(struct mesh *m, subseg *dyingsubseg) -#else /* not ANSI_DECLARATORS */ -void subsegdealloc(m, dyingsubseg) -struct mesh *m; -subseg *dyingsubseg; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Mark the subsegment as dead. This makes it possible to detect dead */ - /* subsegments when traversing the list of all subsegments. */ - killsubseg(dyingsubseg); - pooldealloc(&m->subsegs, (VOID *) dyingsubseg); -} - -/*****************************************************************************/ -/* */ -/* subsegtraverse() Traverse the subsegments, skipping dead ones. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -subseg *subsegtraverse(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -subseg *subsegtraverse(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - subseg *newsubseg; - - do { - newsubseg = (subseg *) traverse(&m->subsegs); - if (newsubseg == (subseg *) NULL) { - return (subseg *) NULL; - } - } while (deadsubseg(newsubseg)); /* Skip dead ones. */ - return newsubseg; -} - -/*****************************************************************************/ -/* */ -/* vertexdealloc() Deallocate space for a vertex, marking it dead. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void vertexdealloc(struct mesh *m, vertex dyingvertex) -#else /* not ANSI_DECLARATORS */ -void vertexdealloc(m, dyingvertex) -struct mesh *m; -vertex dyingvertex; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Mark the vertex as dead. This makes it possible to detect dead */ - /* vertices when traversing the list of all vertices. */ - setvertextype(dyingvertex, DEADVERTEX); - pooldealloc(&m->vertices, (VOID *) dyingvertex); -} - -/*****************************************************************************/ -/* */ -/* vertextraverse() Traverse the vertices, skipping dead ones. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -vertex vertextraverse(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -vertex vertextraverse(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex newvertex; - - do { - newvertex = (vertex) traverse(&m->vertices); - if (newvertex == (vertex) NULL) { - return (vertex) NULL; - } - } while (vertextype(newvertex) == DEADVERTEX); /* Skip dead ones. */ - return newvertex; -} - -/*****************************************************************************/ -/* */ -/* badsubsegdealloc() Deallocate space for a bad subsegment, marking it */ -/* dead. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void badsubsegdealloc(struct mesh *m, struct badsubseg *dyingseg) -#else /* not ANSI_DECLARATORS */ -void badsubsegdealloc(m, dyingseg) -struct mesh *m; -struct badsubseg *dyingseg; -#endif /* not ANSI_DECLARATORS */ - -{ - /* Set subsegment's origin to NULL. This makes it possible to detect dead */ - /* badsubsegs when traversing the list of all badsubsegs . */ - dyingseg->subsegorg = (vertex) NULL; - pooldealloc(&m->badsubsegs, (VOID *) dyingseg); -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* badsubsegtraverse() Traverse the bad subsegments, skipping dead ones. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -struct badsubseg *badsubsegtraverse(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -struct badsubseg *badsubsegtraverse(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - struct badsubseg *newseg; - - do { - newseg = (struct badsubseg *) traverse(&m->badsubsegs); - if (newseg == (struct badsubseg *) NULL) { - return (struct badsubseg *) NULL; - } - } while (newseg->subsegorg == (vertex) NULL); /* Skip dead ones. */ - return newseg; -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* getvertex() Get a specific vertex, by number, from the list. */ -/* */ -/* The first vertex is number 'firstnumber'. */ -/* */ -/* Note that this takes O(n) time (with a small constant, if VERTEXPERBLOCK */ -/* is large). I don't care to take the trouble to make it work in constant */ -/* time. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -vertex getvertex(struct mesh *m, struct behavior *b, int number) -#else /* not ANSI_DECLARATORS */ -vertex getvertex(m, b, number) -struct mesh *m; -struct behavior *b; -int number; -#endif /* not ANSI_DECLARATORS */ - -{ - VOID **getblock; - char *foundvertex; - unsigned long alignptr; - int current; - - getblock = m->vertices.firstblock; - current = b->firstnumber; - - /* Find the right block. */ - if (current + m->vertices.itemsfirstblock <= number) { - getblock = (VOID **) *getblock; - current += m->vertices.itemsfirstblock; - while (current + m->vertices.itemsperblock <= number) { - getblock = (VOID **) *getblock; - current += m->vertices.itemsperblock; - } - } - - /* Now find the right vertex. */ - alignptr = (unsigned long) (getblock + 1); - foundvertex = (char *) (alignptr + (unsigned long) m->vertices.alignbytes - - (alignptr % (unsigned long) m->vertices.alignbytes)); - return (vertex) (foundvertex + m->vertices.itembytes * (number - current)); -} - -/*****************************************************************************/ -/* */ -/* triangledeinit() Free all remaining allocated memory. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void triangledeinit(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void triangledeinit(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - pooldeinit(&m->triangles); - trifree((VOID *) m->dummytribase); - if (b->usesegments) { - pooldeinit(&m->subsegs); - trifree((VOID *) m->dummysubbase); - } - pooldeinit(&m->vertices); -#ifndef CDT_ONLY - if (b->quality) { - pooldeinit(&m->badsubsegs); - if ((b->minangle > 0.0) || b->vararea || b->fixedarea || b->usertest) { - pooldeinit(&m->badtriangles); - pooldeinit(&m->flipstackers); - } - } -#endif /* not CDT_ONLY */ -} - -/** **/ -/** **/ -/********* Memory management routines end here *********/ - -/********* Constructors begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* maketriangle() Create a new triangle with orientation zero. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void maketriangle(struct mesh *m, struct behavior *b, struct otri *newotri) -#else /* not ANSI_DECLARATORS */ -void maketriangle(m, b, newotri) -struct mesh *m; -struct behavior *b; -struct otri *newotri; -#endif /* not ANSI_DECLARATORS */ - -{ - int i; - - newotri->tri = (triangle *) poolalloc(&m->triangles); - /* Initialize the three adjoining triangles to be "outer space". */ - newotri->tri[0] = (triangle) m->dummytri; - newotri->tri[1] = (triangle) m->dummytri; - newotri->tri[2] = (triangle) m->dummytri; - /* Three NULL vertices. */ - newotri->tri[3] = (triangle) NULL; - newotri->tri[4] = (triangle) NULL; - newotri->tri[5] = (triangle) NULL; - if (b->usesegments) { - /* Initialize the three adjoining subsegments to be the omnipresent */ - /* subsegment. */ - newotri->tri[6] = (triangle) m->dummysub; - newotri->tri[7] = (triangle) m->dummysub; - newotri->tri[8] = (triangle) m->dummysub; - } - for (i = 0; i < m->eextras; i++) { - setelemattribute(*newotri, i, 0.0); - } - if (b->vararea) { - setareabound(*newotri, -1.0); - } - - newotri->orient = 0; -} - -/*****************************************************************************/ -/* */ -/* makesubseg() Create a new subsegment with orientation zero. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void makesubseg(struct mesh *m, struct osub *newsubseg) -#else /* not ANSI_DECLARATORS */ -void makesubseg(m, newsubseg) -struct mesh *m; -struct osub *newsubseg; -#endif /* not ANSI_DECLARATORS */ - -{ - newsubseg->ss = (subseg *) poolalloc(&m->subsegs); - /* Initialize the two adjoining subsegments to be the omnipresent */ - /* subsegment. */ - newsubseg->ss[0] = (subseg) m->dummysub; - newsubseg->ss[1] = (subseg) m->dummysub; - /* Four NULL vertices. */ - newsubseg->ss[2] = (subseg) NULL; - newsubseg->ss[3] = (subseg) NULL; - newsubseg->ss[4] = (subseg) NULL; - newsubseg->ss[5] = (subseg) NULL; - /* Initialize the two adjoining triangles to be "outer space." */ - newsubseg->ss[6] = (subseg) m->dummytri; - newsubseg->ss[7] = (subseg) m->dummytri; - /* Set the boundary marker to zero. */ - setmark(*newsubseg, 0); - - newsubseg->ssorient = 0; -} - -/** **/ -/** **/ -/********* Constructors end here *********/ - -/********* Geometric primitives begin here *********/ -/** **/ -/** **/ - -/* The adaptive exact arithmetic geometric predicates implemented herein are */ -/* described in detail in my paper, "Adaptive Precision Floating-Point */ -/* Arithmetic and Fast Robust Geometric Predicates." See the header for a */ -/* full citation. */ - -/* Which of the following two methods of finding the absolute values is */ -/* fastest is compiler-dependent. A few compilers can inline and optimize */ -/* the fabs() call; but most will incur the overhead of a function call, */ -/* which is disastrously slow. A faster way on IEEE machines might be to */ -/* mask the appropriate bit, but that's difficult to do in C without */ -/* forcing the value to be stored to memory (rather than be kept in the */ -/* register to which the optimizer assigned it). */ - -#define Absolute(a) ((a) >= 0.0 ? (a) : -(a)) -/* #define Absolute(a) fabs(a) */ - -/* Many of the operations are broken up into two pieces, a main part that */ -/* performs an approximate operation, and a "tail" that computes the */ -/* roundoff error of that operation. */ -/* */ -/* The operations Fast_Two_Sum(), Fast_Two_Diff(), Two_Sum(), Two_Diff(), */ -/* Split(), and Two_Product() are all implemented as described in the */ -/* reference. Each of these macros requires certain variables to be */ -/* defined in the calling routine. The variables `bvirt', `c', `abig', */ -/* `_i', `_j', `_k', `_l', `_m', and `_n' are declared `INEXACT' because */ -/* they store the result of an operation that may incur roundoff error. */ -/* The input parameter `x' (or the highest numbered `x_' parameter) must */ -/* also be declared `INEXACT'. */ - -#define Fast_Two_Sum_Tail(a, b, x, y) \ - bvirt = x - a; \ - y = b - bvirt - -#define Fast_Two_Sum(a, b, x, y) \ - x = (REAL) (a + b); \ - Fast_Two_Sum_Tail(a, b, x, y) - -#define Two_Sum_Tail(a, b, x, y) \ - bvirt = (REAL) (x - a); \ - avirt = x - bvirt; \ - bround = b - bvirt; \ - around = a - avirt; \ - y = around + bround - -#define Two_Sum(a, b, x, y) \ - x = (REAL) (a + b); \ - Two_Sum_Tail(a, b, x, y) - -#define Two_Diff_Tail(a, b, x, y) \ - bvirt = (REAL) (a - x); \ - avirt = x + bvirt; \ - bround = bvirt - b; \ - around = a - avirt; \ - y = around + bround - -#define Two_Diff(a, b, x, y) \ - x = (REAL) (a - b); \ - Two_Diff_Tail(a, b, x, y) - -#define Split(a, ahi, alo) \ - c = (REAL) (splitter * a); \ - abig = (REAL) (c - a); \ - ahi = c - abig; \ - alo = a - ahi - -#define Two_Product_Tail(a, b, x, y) \ - Split(a, ahi, alo); \ - Split(b, bhi, blo); \ - err1 = x - (ahi * bhi); \ - err2 = err1 - (alo * bhi); \ - err3 = err2 - (ahi * blo); \ - y = (alo * blo) - err3 - -#define Two_Product(a, b, x, y) \ - x = (REAL) (a * b); \ - Two_Product_Tail(a, b, x, y) - -/* Two_Product_Presplit() is Two_Product() where one of the inputs has */ -/* already been split. Avoids redundant splitting. */ - -#define Two_Product_Presplit(a, b, bhi, blo, x, y) \ - x = (REAL) (a * b); \ - Split(a, ahi, alo); \ - err1 = x - (ahi * bhi); \ - err2 = err1 - (alo * bhi); \ - err3 = err2 - (ahi * blo); \ - y = (alo * blo) - err3 - -/* Square() can be done more quickly than Two_Product(). */ - -#define Square_Tail(a, x, y) \ - Split(a, ahi, alo); \ - err1 = x - (ahi * ahi); \ - err3 = err1 - ((ahi + ahi) * alo); \ - y = (alo * alo) - err3 - -#define Square(a, x, y) \ - x = (REAL) (a * a); \ - Square_Tail(a, x, y) - -/* Macros for summing expansions of various fixed lengths. These are all */ -/* unrolled versions of Expansion_Sum(). */ - -#define Two_One_Sum(a1, a0, b, x2, x1, x0) \ - Two_Sum(a0, b , _i, x0); \ - Two_Sum(a1, _i, x2, x1) - -#define Two_One_Diff(a1, a0, b, x2, x1, x0) \ - Two_Diff(a0, b , _i, x0); \ - Two_Sum( a1, _i, x2, x1) - -#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \ - Two_One_Sum(a1, a0, b0, _j, _0, x0); \ - Two_One_Sum(_j, _0, b1, x3, x2, x1) - -#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \ - Two_One_Diff(a1, a0, b0, _j, _0, x0); \ - Two_One_Diff(_j, _0, b1, x3, x2, x1) - -/* Macro for multiplying a two-component expansion by a single component. */ - -#define Two_One_Product(a1, a0, b, x3, x2, x1, x0) \ - Split(b, bhi, blo); \ - Two_Product_Presplit(a0, b, bhi, blo, _i, x0); \ - Two_Product_Presplit(a1, b, bhi, blo, _j, _0); \ - Two_Sum(_i, _0, _k, x1); \ - Fast_Two_Sum(_j, _k, x3, x2) - -/*****************************************************************************/ -/* */ -/* exactinit() Initialize the variables used for exact arithmetic. */ -/* */ -/* `epsilon' is the largest power of two such that 1.0 + epsilon = 1.0 in */ -/* floating-point arithmetic. `epsilon' bounds the relative roundoff */ -/* error. It is used for floating-point error analysis. */ -/* */ -/* `splitter' is used to split floating-point numbers into two half- */ -/* length significands for exact multiplication. */ -/* */ -/* I imagine that a highly optimizing compiler might be too smart for its */ -/* own good, and somehow cause this routine to fail, if it pretends that */ -/* floating-point arithmetic is too much like real arithmetic. */ -/* */ -/* Don't change this routine unless you fully understand it. */ -/* */ -/*****************************************************************************/ - -void exactinit() -{ - REAL half; - REAL check, lastcheck; - int every_other; -#ifdef LINUX - int cword; -#endif /* LINUX */ - -#ifdef CPU86 -#ifdef SINGLE - _control87(_PC_24, _MCW_PC); /* Set FPU control word for single precision. */ -#else /* not SINGLE */ - _control87(_PC_53, _MCW_PC); /* Set FPU control word for double precision. */ -#endif /* not SINGLE */ -#endif /* CPU86 */ -#ifdef LINUX -#ifdef SINGLE - /* cword = 4223; */ - cword = 4210; /* set FPU control word for single precision */ -#else /* not SINGLE */ - /* cword = 4735; */ - cword = 4722; /* set FPU control word for double precision */ -#endif /* not SINGLE */ - _FPU_SETCW(cword); -#endif /* LINUX */ - - every_other = 1; - half = 0.5; - epsilon = 1.0; - splitter = 1.0; - check = 1.0; - /* Repeatedly divide `epsilon' by two until it is too small to add to */ - /* one without causing roundoff. (Also check if the sum is equal to */ - /* the previous sum, for machines that round up instead of using exact */ - /* rounding. Not that these routines will work on such machines.) */ - do { - lastcheck = check; - epsilon *= half; - if (every_other) { - splitter *= 2.0; - } - every_other = !every_other; - check = 1.0 + epsilon; - } while ((check != 1.0) && (check != lastcheck)); - splitter += 1.0; - /* Error bounds for orientation and incircle tests. */ - resulterrbound = (3.0 + 8.0 * epsilon) * epsilon; - ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon; - ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon; - ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon; - iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon; - iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon; - iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon; - o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon; - o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon; - o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon; -} - -/*****************************************************************************/ -/* */ -/* fast_expansion_sum_zeroelim() Sum two expansions, eliminating zero */ -/* components from the output expansion. */ -/* */ -/* Sets h = e + f. See my Robust Predicates paper for details. */ -/* */ -/* If round-to-even is used (as with IEEE 754), maintains the strongly */ -/* nonoverlapping property. (That is, if e is strongly nonoverlapping, h */ -/* will be also.) Does NOT maintain the nonoverlapping or nonadjacent */ -/* properties. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -int fast_expansion_sum_zeroelim(int elen, REAL *e, int flen, REAL *f, REAL *h) -#else /* not ANSI_DECLARATORS */ -int fast_expansion_sum_zeroelim(elen, e, flen, f, h) /* h cannot be e or f. */ -int elen; -REAL *e; -int flen; -REAL *f; -REAL *h; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL Q; - INEXACT REAL Qnew; - INEXACT REAL hh; - INEXACT REAL bvirt; - REAL avirt, bround, around; - int eindex, findex, hindex; - REAL enow, fnow; - - enow = e[0]; - fnow = f[0]; - eindex = findex = 0; - if ((fnow > enow) == (fnow > -enow)) { - Q = enow; - enow = e[++eindex]; - } else { - Q = fnow; - fnow = f[++findex]; - } - hindex = 0; - if ((eindex < elen) && (findex < flen)) { - if ((fnow > enow) == (fnow > -enow)) { - Fast_Two_Sum(enow, Q, Qnew, hh); - enow = e[++eindex]; - } else { - Fast_Two_Sum(fnow, Q, Qnew, hh); - fnow = f[++findex]; - } - Q = Qnew; - if (hh != 0.0) { - h[hindex++] = hh; - } - while ((eindex < elen) && (findex < flen)) { - if ((fnow > enow) == (fnow > -enow)) { - Two_Sum(Q, enow, Qnew, hh); - enow = e[++eindex]; - } else { - Two_Sum(Q, fnow, Qnew, hh); - fnow = f[++findex]; - } - Q = Qnew; - if (hh != 0.0) { - h[hindex++] = hh; - } - } - } - while (eindex < elen) { - Two_Sum(Q, enow, Qnew, hh); - enow = e[++eindex]; - Q = Qnew; - if (hh != 0.0) { - h[hindex++] = hh; - } - } - while (findex < flen) { - Two_Sum(Q, fnow, Qnew, hh); - fnow = f[++findex]; - Q = Qnew; - if (hh != 0.0) { - h[hindex++] = hh; - } - } - if ((Q != 0.0) || (hindex == 0)) { - h[hindex++] = Q; - } - return hindex; -} - -/*****************************************************************************/ -/* */ -/* scale_expansion_zeroelim() Multiply an expansion by a scalar, */ -/* eliminating zero components from the */ -/* output expansion. */ -/* */ -/* Sets h = be. See my Robust Predicates paper for details. */ -/* */ -/* Maintains the nonoverlapping property. If round-to-even is used (as */ -/* with IEEE 754), maintains the strongly nonoverlapping and nonadjacent */ -/* properties as well. (That is, if e has one of these properties, so */ -/* will h.) */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -int scale_expansion_zeroelim(int elen, REAL *e, REAL b, REAL *h) -#else /* not ANSI_DECLARATORS */ -int scale_expansion_zeroelim(elen, e, b, h) /* e and h cannot be the same. */ -int elen; -REAL *e; -REAL b; -REAL *h; -#endif /* not ANSI_DECLARATORS */ - -{ - INEXACT REAL Q, sum; - REAL hh; - INEXACT REAL product1; - REAL product0; - int eindex, hindex; - REAL enow; - INEXACT REAL bvirt; - REAL avirt, bround, around; - INEXACT REAL c; - INEXACT REAL abig; - REAL ahi, alo, bhi, blo; - REAL err1, err2, err3; - - Split(b, bhi, blo); - Two_Product_Presplit(e[0], b, bhi, blo, Q, hh); - hindex = 0; - if (hh != 0) { - h[hindex++] = hh; - } - for (eindex = 1; eindex < elen; eindex++) { - enow = e[eindex]; - Two_Product_Presplit(enow, b, bhi, blo, product1, product0); - Two_Sum(Q, product0, sum, hh); - if (hh != 0) { - h[hindex++] = hh; - } - Fast_Two_Sum(product1, sum, Q, hh); - if (hh != 0) { - h[hindex++] = hh; - } - } - if ((Q != 0.0) || (hindex == 0)) { - h[hindex++] = Q; - } - return hindex; -} - -/*****************************************************************************/ -/* */ -/* estimate() Produce a one-word estimate of an expansion's value. */ -/* */ -/* See my Robust Predicates paper for details. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -REAL estimate(int elen, REAL *e) -#else /* not ANSI_DECLARATORS */ -REAL estimate(elen, e) -int elen; -REAL *e; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL Q; - int eindex; - - Q = e[0]; - for (eindex = 1; eindex < elen; eindex++) { - Q += e[eindex]; - } - return Q; -} - -/*****************************************************************************/ -/* */ -/* counterclockwise() Return a positive value if the points pa, pb, and */ -/* pc occur in counterclockwise order; a negative */ -/* value if they occur in clockwise order; and zero */ -/* if they are collinear. The result is also a rough */ -/* approximation of twice the signed area of the */ -/* triangle defined by the three points. */ -/* */ -/* Uses exact arithmetic if necessary to ensure a correct answer. The */ -/* result returned is the determinant of a matrix. This determinant is */ -/* computed adaptively, in the sense that exact arithmetic is used only to */ -/* the degree it is needed to ensure that the returned value has the */ -/* correct sign. Hence, this function is usually quite fast, but will run */ -/* more slowly when the input points are collinear or nearly so. */ -/* */ -/* See my Robust Predicates paper for details. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -REAL counterclockwiseadapt(vertex pa, vertex pb, vertex pc, REAL detsum) -#else /* not ANSI_DECLARATORS */ -REAL counterclockwiseadapt(pa, pb, pc, detsum) -vertex pa; -vertex pb; -vertex pc; -REAL detsum; -#endif /* not ANSI_DECLARATORS */ - -{ - INEXACT REAL acx, acy, bcx, bcy; - REAL acxtail, acytail, bcxtail, bcytail; - INEXACT REAL detleft, detright; - REAL detlefttail, detrighttail; - REAL det, errbound; - REAL B[4], C1[8], C2[12], D[16]; - INEXACT REAL B3; - int C1length, C2length, Dlength; - REAL u[4]; - INEXACT REAL u3; - INEXACT REAL s1, t1; - REAL s0, t0; - - INEXACT REAL bvirt; - REAL avirt, bround, around; - INEXACT REAL c; - INEXACT REAL abig; - REAL ahi, alo, bhi, blo; - REAL err1, err2, err3; - INEXACT REAL _i, _j; - REAL _0; - - acx = (REAL) (pa[0] - pc[0]); - bcx = (REAL) (pb[0] - pc[0]); - acy = (REAL) (pa[1] - pc[1]); - bcy = (REAL) (pb[1] - pc[1]); - - Two_Product(acx, bcy, detleft, detlefttail); - Two_Product(acy, bcx, detright, detrighttail); - - Two_Two_Diff(detleft, detlefttail, detright, detrighttail, - B3, B[2], B[1], B[0]); - B[3] = B3; - - det = estimate(4, B); - errbound = ccwerrboundB * detsum; - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - Two_Diff_Tail(pa[0], pc[0], acx, acxtail); - Two_Diff_Tail(pb[0], pc[0], bcx, bcxtail); - Two_Diff_Tail(pa[1], pc[1], acy, acytail); - Two_Diff_Tail(pb[1], pc[1], bcy, bcytail); - - if ((acxtail == 0.0) && (acytail == 0.0) - && (bcxtail == 0.0) && (bcytail == 0.0)) { - return det; - } - - errbound = ccwerrboundC * detsum + resulterrbound * Absolute(det); - det += (acx * bcytail + bcy * acxtail) - - (acy * bcxtail + bcx * acytail); - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - Two_Product(acxtail, bcy, s1, s0); - Two_Product(acytail, bcx, t1, t0); - Two_Two_Diff(s1, s0, t1, t0, u3, u[2], u[1], u[0]); - u[3] = u3; - C1length = fast_expansion_sum_zeroelim(4, B, 4, u, C1); - - Two_Product(acx, bcytail, s1, s0); - Two_Product(acy, bcxtail, t1, t0); - Two_Two_Diff(s1, s0, t1, t0, u3, u[2], u[1], u[0]); - u[3] = u3; - C2length = fast_expansion_sum_zeroelim(C1length, C1, 4, u, C2); - - Two_Product(acxtail, bcytail, s1, s0); - Two_Product(acytail, bcxtail, t1, t0); - Two_Two_Diff(s1, s0, t1, t0, u3, u[2], u[1], u[0]); - u[3] = u3; - Dlength = fast_expansion_sum_zeroelim(C2length, C2, 4, u, D); - - return(D[Dlength - 1]); -} - -#ifdef ANSI_DECLARATORS -REAL counterclockwise(struct mesh *m, struct behavior *b, - vertex pa, vertex pb, vertex pc) -#else /* not ANSI_DECLARATORS */ -REAL counterclockwise(m, b, pa, pb, pc) -struct mesh *m; -struct behavior *b; -vertex pa; -vertex pb; -vertex pc; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL detleft, detright, det; - REAL detsum, errbound; - - m->counterclockcount++; - - detleft = (pa[0] - pc[0]) * (pb[1] - pc[1]); - detright = (pa[1] - pc[1]) * (pb[0] - pc[0]); - det = detleft - detright; - - if (b->noexact) { - return det; - } - - if (detleft > 0.0) { - if (detright <= 0.0) { - return det; - } else { - detsum = detleft + detright; - } - } else if (detleft < 0.0) { - if (detright >= 0.0) { - return det; - } else { - detsum = -detleft - detright; - } - } else { - return det; - } - - errbound = ccwerrboundA * detsum; - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - return counterclockwiseadapt(pa, pb, pc, detsum); -} - -/*****************************************************************************/ -/* */ -/* incircle() Return a positive value if the point pd lies inside the */ -/* circle passing through pa, pb, and pc; a negative value if */ -/* it lies outside; and zero if the four points are cocircular.*/ -/* The points pa, pb, and pc must be in counterclockwise */ -/* order, or the sign of the result will be reversed. */ -/* */ -/* Uses exact arithmetic if necessary to ensure a correct answer. The */ -/* result returned is the determinant of a matrix. This determinant is */ -/* computed adaptively, in the sense that exact arithmetic is used only to */ -/* the degree it is needed to ensure that the returned value has the */ -/* correct sign. Hence, this function is usually quite fast, but will run */ -/* more slowly when the input points are cocircular or nearly so. */ -/* */ -/* See my Robust Predicates paper for details. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -REAL incircleadapt(vertex pa, vertex pb, vertex pc, vertex pd, REAL permanent) -#else /* not ANSI_DECLARATORS */ -REAL incircleadapt(pa, pb, pc, pd, permanent) -vertex pa; -vertex pb; -vertex pc; -vertex pd; -REAL permanent; -#endif /* not ANSI_DECLARATORS */ - -{ - INEXACT REAL adx, bdx, cdx, ady, bdy, cdy; - REAL det, errbound; - - INEXACT REAL bdxcdy1, cdxbdy1, cdxady1, adxcdy1, adxbdy1, bdxady1; - REAL bdxcdy0, cdxbdy0, cdxady0, adxcdy0, adxbdy0, bdxady0; - REAL bc[4], ca[4], ab[4]; - INEXACT REAL bc3, ca3, ab3; - REAL axbc[8], axxbc[16], aybc[8], ayybc[16], adet[32]; - int axbclen, axxbclen, aybclen, ayybclen, alen; - REAL bxca[8], bxxca[16], byca[8], byyca[16], bdet[32]; - int bxcalen, bxxcalen, bycalen, byycalen, blen; - REAL cxab[8], cxxab[16], cyab[8], cyyab[16], cdet[32]; - int cxablen, cxxablen, cyablen, cyyablen, clen; - REAL abdet[64]; - int ablen; - REAL fin1[1152], fin2[1152]; - REAL *finnow, *finother, *finswap; - int finlength; - - REAL adxtail, bdxtail, cdxtail, adytail, bdytail, cdytail; - INEXACT REAL adxadx1, adyady1, bdxbdx1, bdybdy1, cdxcdx1, cdycdy1; - REAL adxadx0, adyady0, bdxbdx0, bdybdy0, cdxcdx0, cdycdy0; - REAL aa[4], bb[4], cc[4]; - INEXACT REAL aa3, bb3, cc3; - INEXACT REAL ti1, tj1; - REAL ti0, tj0; - REAL u[4], v[4]; - INEXACT REAL u3, v3; - REAL temp8[8], temp16a[16], temp16b[16], temp16c[16]; - REAL temp32a[32], temp32b[32], temp48[48], temp64[64]; - int temp8len, temp16alen, temp16blen, temp16clen; - int temp32alen, temp32blen, temp48len, temp64len; - REAL axtbb[8], axtcc[8], aytbb[8], aytcc[8]; - int axtbblen, axtcclen, aytbblen, aytcclen; - REAL bxtaa[8], bxtcc[8], bytaa[8], bytcc[8]; - int bxtaalen, bxtcclen, bytaalen, bytcclen; - REAL cxtaa[8], cxtbb[8], cytaa[8], cytbb[8]; - int cxtaalen, cxtbblen, cytaalen, cytbblen; - REAL axtbc[8], aytbc[8], bxtca[8], bytca[8], cxtab[8], cytab[8]; - int axtbclen, aytbclen, bxtcalen, bytcalen, cxtablen, cytablen; - REAL axtbct[16], aytbct[16], bxtcat[16], bytcat[16], cxtabt[16], cytabt[16]; - int axtbctlen, aytbctlen, bxtcatlen, bytcatlen, cxtabtlen, cytabtlen; - REAL axtbctt[8], aytbctt[8], bxtcatt[8]; - REAL bytcatt[8], cxtabtt[8], cytabtt[8]; - int axtbcttlen, aytbcttlen, bxtcattlen, bytcattlen, cxtabttlen, cytabttlen; - REAL abt[8], bct[8], cat[8]; - int abtlen, bctlen, catlen; - REAL abtt[4], bctt[4], catt[4]; - int abttlen, bcttlen, cattlen; - INEXACT REAL abtt3, bctt3, catt3; - REAL negate; - - INEXACT REAL bvirt; - REAL avirt, bround, around; - INEXACT REAL c; - INEXACT REAL abig; - REAL ahi, alo, bhi, blo; - REAL err1, err2, err3; - INEXACT REAL _i, _j; - REAL _0; - - adx = (REAL) (pa[0] - pd[0]); - bdx = (REAL) (pb[0] - pd[0]); - cdx = (REAL) (pc[0] - pd[0]); - ady = (REAL) (pa[1] - pd[1]); - bdy = (REAL) (pb[1] - pd[1]); - cdy = (REAL) (pc[1] - pd[1]); - - Two_Product(bdx, cdy, bdxcdy1, bdxcdy0); - Two_Product(cdx, bdy, cdxbdy1, cdxbdy0); - Two_Two_Diff(bdxcdy1, bdxcdy0, cdxbdy1, cdxbdy0, bc3, bc[2], bc[1], bc[0]); - bc[3] = bc3; - axbclen = scale_expansion_zeroelim(4, bc, adx, axbc); - axxbclen = scale_expansion_zeroelim(axbclen, axbc, adx, axxbc); - aybclen = scale_expansion_zeroelim(4, bc, ady, aybc); - ayybclen = scale_expansion_zeroelim(aybclen, aybc, ady, ayybc); - alen = fast_expansion_sum_zeroelim(axxbclen, axxbc, ayybclen, ayybc, adet); - - Two_Product(cdx, ady, cdxady1, cdxady0); - Two_Product(adx, cdy, adxcdy1, adxcdy0); - Two_Two_Diff(cdxady1, cdxady0, adxcdy1, adxcdy0, ca3, ca[2], ca[1], ca[0]); - ca[3] = ca3; - bxcalen = scale_expansion_zeroelim(4, ca, bdx, bxca); - bxxcalen = scale_expansion_zeroelim(bxcalen, bxca, bdx, bxxca); - bycalen = scale_expansion_zeroelim(4, ca, bdy, byca); - byycalen = scale_expansion_zeroelim(bycalen, byca, bdy, byyca); - blen = fast_expansion_sum_zeroelim(bxxcalen, bxxca, byycalen, byyca, bdet); - - Two_Product(adx, bdy, adxbdy1, adxbdy0); - Two_Product(bdx, ady, bdxady1, bdxady0); - Two_Two_Diff(adxbdy1, adxbdy0, bdxady1, bdxady0, ab3, ab[2], ab[1], ab[0]); - ab[3] = ab3; - cxablen = scale_expansion_zeroelim(4, ab, cdx, cxab); - cxxablen = scale_expansion_zeroelim(cxablen, cxab, cdx, cxxab); - cyablen = scale_expansion_zeroelim(4, ab, cdy, cyab); - cyyablen = scale_expansion_zeroelim(cyablen, cyab, cdy, cyyab); - clen = fast_expansion_sum_zeroelim(cxxablen, cxxab, cyyablen, cyyab, cdet); - - ablen = fast_expansion_sum_zeroelim(alen, adet, blen, bdet, abdet); - finlength = fast_expansion_sum_zeroelim(ablen, abdet, clen, cdet, fin1); - - det = estimate(finlength, fin1); - errbound = iccerrboundB * permanent; - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - Two_Diff_Tail(pa[0], pd[0], adx, adxtail); - Two_Diff_Tail(pa[1], pd[1], ady, adytail); - Two_Diff_Tail(pb[0], pd[0], bdx, bdxtail); - Two_Diff_Tail(pb[1], pd[1], bdy, bdytail); - Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail); - Two_Diff_Tail(pc[1], pd[1], cdy, cdytail); - if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) - && (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0)) { - return det; - } - - errbound = iccerrboundC * permanent + resulterrbound * Absolute(det); - det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - - (bdy * cdxtail + cdx * bdytail)) - + 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx)) - + ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - - (cdy * adxtail + adx * cdytail)) - + 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx)) - + ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - - (ady * bdxtail + bdx * adytail)) - + 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx)); - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - finnow = fin1; - finother = fin2; - - if ((bdxtail != 0.0) || (bdytail != 0.0) - || (cdxtail != 0.0) || (cdytail != 0.0)) { - Square(adx, adxadx1, adxadx0); - Square(ady, adyady1, adyady0); - Two_Two_Sum(adxadx1, adxadx0, adyady1, adyady0, aa3, aa[2], aa[1], aa[0]); - aa[3] = aa3; - } - if ((cdxtail != 0.0) || (cdytail != 0.0) - || (adxtail != 0.0) || (adytail != 0.0)) { - Square(bdx, bdxbdx1, bdxbdx0); - Square(bdy, bdybdy1, bdybdy0); - Two_Two_Sum(bdxbdx1, bdxbdx0, bdybdy1, bdybdy0, bb3, bb[2], bb[1], bb[0]); - bb[3] = bb3; - } - if ((adxtail != 0.0) || (adytail != 0.0) - || (bdxtail != 0.0) || (bdytail != 0.0)) { - Square(cdx, cdxcdx1, cdxcdx0); - Square(cdy, cdycdy1, cdycdy0); - Two_Two_Sum(cdxcdx1, cdxcdx0, cdycdy1, cdycdy0, cc3, cc[2], cc[1], cc[0]); - cc[3] = cc3; - } - - if (adxtail != 0.0) { - axtbclen = scale_expansion_zeroelim(4, bc, adxtail, axtbc); - temp16alen = scale_expansion_zeroelim(axtbclen, axtbc, 2.0 * adx, - temp16a); - - axtcclen = scale_expansion_zeroelim(4, cc, adxtail, axtcc); - temp16blen = scale_expansion_zeroelim(axtcclen, axtcc, bdy, temp16b); - - axtbblen = scale_expansion_zeroelim(4, bb, adxtail, axtbb); - temp16clen = scale_expansion_zeroelim(axtbblen, axtbb, -cdy, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (adytail != 0.0) { - aytbclen = scale_expansion_zeroelim(4, bc, adytail, aytbc); - temp16alen = scale_expansion_zeroelim(aytbclen, aytbc, 2.0 * ady, - temp16a); - - aytbblen = scale_expansion_zeroelim(4, bb, adytail, aytbb); - temp16blen = scale_expansion_zeroelim(aytbblen, aytbb, cdx, temp16b); - - aytcclen = scale_expansion_zeroelim(4, cc, adytail, aytcc); - temp16clen = scale_expansion_zeroelim(aytcclen, aytcc, -bdx, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdxtail != 0.0) { - bxtcalen = scale_expansion_zeroelim(4, ca, bdxtail, bxtca); - temp16alen = scale_expansion_zeroelim(bxtcalen, bxtca, 2.0 * bdx, - temp16a); - - bxtaalen = scale_expansion_zeroelim(4, aa, bdxtail, bxtaa); - temp16blen = scale_expansion_zeroelim(bxtaalen, bxtaa, cdy, temp16b); - - bxtcclen = scale_expansion_zeroelim(4, cc, bdxtail, bxtcc); - temp16clen = scale_expansion_zeroelim(bxtcclen, bxtcc, -ady, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdytail != 0.0) { - bytcalen = scale_expansion_zeroelim(4, ca, bdytail, bytca); - temp16alen = scale_expansion_zeroelim(bytcalen, bytca, 2.0 * bdy, - temp16a); - - bytcclen = scale_expansion_zeroelim(4, cc, bdytail, bytcc); - temp16blen = scale_expansion_zeroelim(bytcclen, bytcc, adx, temp16b); - - bytaalen = scale_expansion_zeroelim(4, aa, bdytail, bytaa); - temp16clen = scale_expansion_zeroelim(bytaalen, bytaa, -cdx, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdxtail != 0.0) { - cxtablen = scale_expansion_zeroelim(4, ab, cdxtail, cxtab); - temp16alen = scale_expansion_zeroelim(cxtablen, cxtab, 2.0 * cdx, - temp16a); - - cxtbblen = scale_expansion_zeroelim(4, bb, cdxtail, cxtbb); - temp16blen = scale_expansion_zeroelim(cxtbblen, cxtbb, ady, temp16b); - - cxtaalen = scale_expansion_zeroelim(4, aa, cdxtail, cxtaa); - temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdytail != 0.0) { - cytablen = scale_expansion_zeroelim(4, ab, cdytail, cytab); - temp16alen = scale_expansion_zeroelim(cytablen, cytab, 2.0 * cdy, - temp16a); - - cytaalen = scale_expansion_zeroelim(4, aa, cdytail, cytaa); - temp16blen = scale_expansion_zeroelim(cytaalen, cytaa, bdx, temp16b); - - cytbblen = scale_expansion_zeroelim(4, bb, cdytail, cytbb); - temp16clen = scale_expansion_zeroelim(cytbblen, cytbb, -adx, temp16c); - - temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - if ((adxtail != 0.0) || (adytail != 0.0)) { - if ((bdxtail != 0.0) || (bdytail != 0.0) - || (cdxtail != 0.0) || (cdytail != 0.0)) { - Two_Product(bdxtail, cdy, ti1, ti0); - Two_Product(bdx, cdytail, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); - u[3] = u3; - negate = -bdy; - Two_Product(cdxtail, negate, ti1, ti0); - negate = -bdytail; - Two_Product(cdx, negate, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); - v[3] = v3; - bctlen = fast_expansion_sum_zeroelim(4, u, 4, v, bct); - - Two_Product(bdxtail, cdytail, ti1, ti0); - Two_Product(cdxtail, bdytail, tj1, tj0); - Two_Two_Diff(ti1, ti0, tj1, tj0, bctt3, bctt[2], bctt[1], bctt[0]); - bctt[3] = bctt3; - bcttlen = 4; - } else { - bct[0] = 0.0; - bctlen = 1; - bctt[0] = 0.0; - bcttlen = 1; - } - - if (adxtail != 0.0) { - temp16alen = scale_expansion_zeroelim(axtbclen, axtbc, adxtail, temp16a); - axtbctlen = scale_expansion_zeroelim(bctlen, bct, adxtail, axtbct); - temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, 2.0 * adx, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - if (bdytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, adxtail, - temp32a); - axtbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adxtail, axtbctt); - temp16alen = scale_expansion_zeroelim(axtbcttlen, axtbctt, 2.0 * adx, - temp16a); - temp16blen = scale_expansion_zeroelim(axtbcttlen, axtbctt, adxtail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (adytail != 0.0) { - temp16alen = scale_expansion_zeroelim(aytbclen, aytbc, adytail, temp16a); - aytbctlen = scale_expansion_zeroelim(bctlen, bct, adytail, aytbct); - temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, 2.0 * ady, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - - - temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, adytail, - temp32a); - aytbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adytail, aytbctt); - temp16alen = scale_expansion_zeroelim(aytbcttlen, aytbctt, 2.0 * ady, - temp16a); - temp16blen = scale_expansion_zeroelim(aytbcttlen, aytbctt, adytail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - if ((bdxtail != 0.0) || (bdytail != 0.0)) { - if ((cdxtail != 0.0) || (cdytail != 0.0) - || (adxtail != 0.0) || (adytail != 0.0)) { - Two_Product(cdxtail, ady, ti1, ti0); - Two_Product(cdx, adytail, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); - u[3] = u3; - negate = -cdy; - Two_Product(adxtail, negate, ti1, ti0); - negate = -cdytail; - Two_Product(adx, negate, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); - v[3] = v3; - catlen = fast_expansion_sum_zeroelim(4, u, 4, v, cat); - - Two_Product(cdxtail, adytail, ti1, ti0); - Two_Product(adxtail, cdytail, tj1, tj0); - Two_Two_Diff(ti1, ti0, tj1, tj0, catt3, catt[2], catt[1], catt[0]); - catt[3] = catt3; - cattlen = 4; - } else { - cat[0] = 0.0; - catlen = 1; - catt[0] = 0.0; - cattlen = 1; - } - - if (bdxtail != 0.0) { - temp16alen = scale_expansion_zeroelim(bxtcalen, bxtca, bdxtail, temp16a); - bxtcatlen = scale_expansion_zeroelim(catlen, cat, bdxtail, bxtcat); - temp32alen = scale_expansion_zeroelim(bxtcatlen, bxtcat, 2.0 * bdx, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - if (cdytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, aa, bdxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (adytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, cc, -bdxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, adytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - temp32alen = scale_expansion_zeroelim(bxtcatlen, bxtcat, bdxtail, - temp32a); - bxtcattlen = scale_expansion_zeroelim(cattlen, catt, bdxtail, bxtcatt); - temp16alen = scale_expansion_zeroelim(bxtcattlen, bxtcatt, 2.0 * bdx, - temp16a); - temp16blen = scale_expansion_zeroelim(bxtcattlen, bxtcatt, bdxtail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdytail != 0.0) { - temp16alen = scale_expansion_zeroelim(bytcalen, bytca, bdytail, temp16a); - bytcatlen = scale_expansion_zeroelim(catlen, cat, bdytail, bytcat); - temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, 2.0 * bdy, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - - - temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, - temp32a); - bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt); - temp16alen = scale_expansion_zeroelim(bytcattlen, bytcatt, 2.0 * bdy, - temp16a); - temp16blen = scale_expansion_zeroelim(bytcattlen, bytcatt, bdytail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - if ((cdxtail != 0.0) || (cdytail != 0.0)) { - if ((adxtail != 0.0) || (adytail != 0.0) - || (bdxtail != 0.0) || (bdytail != 0.0)) { - Two_Product(adxtail, bdy, ti1, ti0); - Two_Product(adx, bdytail, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, u3, u[2], u[1], u[0]); - u[3] = u3; - negate = -ady; - Two_Product(bdxtail, negate, ti1, ti0); - negate = -adytail; - Two_Product(bdx, negate, tj1, tj0); - Two_Two_Sum(ti1, ti0, tj1, tj0, v3, v[2], v[1], v[0]); - v[3] = v3; - abtlen = fast_expansion_sum_zeroelim(4, u, 4, v, abt); - - Two_Product(adxtail, bdytail, ti1, ti0); - Two_Product(bdxtail, adytail, tj1, tj0); - Two_Two_Diff(ti1, ti0, tj1, tj0, abtt3, abtt[2], abtt[1], abtt[0]); - abtt[3] = abtt3; - abttlen = 4; - } else { - abt[0] = 0.0; - abtlen = 1; - abtt[0] = 0.0; - abttlen = 1; - } - - if (cdxtail != 0.0) { - temp16alen = scale_expansion_zeroelim(cxtablen, cxtab, cdxtail, temp16a); - cxtabtlen = scale_expansion_zeroelim(abtlen, abt, cdxtail, cxtabt); - temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, 2.0 * cdx, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - if (adytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, bb, cdxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, adytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdytail != 0.0) { - temp8len = scale_expansion_zeroelim(4, aa, -cdxtail, temp8); - temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, - temp16a); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, - temp16a, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, cdxtail, - temp32a); - cxtabttlen = scale_expansion_zeroelim(abttlen, abtt, cdxtail, cxtabtt); - temp16alen = scale_expansion_zeroelim(cxtabttlen, cxtabtt, 2.0 * cdx, - temp16a); - temp16blen = scale_expansion_zeroelim(cxtabttlen, cxtabtt, cdxtail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdytail != 0.0) { - temp16alen = scale_expansion_zeroelim(cytablen, cytab, cdytail, temp16a); - cytabtlen = scale_expansion_zeroelim(abtlen, abt, cdytail, cytabt); - temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, 2.0 * cdy, - temp32a); - temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp32alen, temp32a, temp48); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, - temp48, finother); - finswap = finnow; finnow = finother; finother = finswap; - - - temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, - temp32a); - cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt); - temp16alen = scale_expansion_zeroelim(cytabttlen, cytabtt, 2.0 * cdy, - temp16a); - temp16blen = scale_expansion_zeroelim(cytabttlen, cytabtt, cdytail, - temp16b); - temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, - temp16blen, temp16b, temp32b); - temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, - temp32blen, temp32b, temp64); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, - temp64, finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - - return finnow[finlength - 1]; -} - -#ifdef ANSI_DECLARATORS -REAL incircle(struct mesh *m, struct behavior *b, - vertex pa, vertex pb, vertex pc, vertex pd) -#else /* not ANSI_DECLARATORS */ -REAL incircle(m, b, pa, pb, pc, pd) -struct mesh *m; -struct behavior *b; -vertex pa; -vertex pb; -vertex pc; -vertex pd; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL adx, bdx, cdx, ady, bdy, cdy; - REAL bdxcdy, cdxbdy, cdxady, adxcdy, adxbdy, bdxady; - REAL alift, blift, clift; - REAL det; - REAL permanent, errbound; - - m->incirclecount++; - - adx = pa[0] - pd[0]; - bdx = pb[0] - pd[0]; - cdx = pc[0] - pd[0]; - ady = pa[1] - pd[1]; - bdy = pb[1] - pd[1]; - cdy = pc[1] - pd[1]; - - bdxcdy = bdx * cdy; - cdxbdy = cdx * bdy; - alift = adx * adx + ady * ady; - - cdxady = cdx * ady; - adxcdy = adx * cdy; - blift = bdx * bdx + bdy * bdy; - - adxbdy = adx * bdy; - bdxady = bdx * ady; - clift = cdx * cdx + cdy * cdy; - - det = alift * (bdxcdy - cdxbdy) - + blift * (cdxady - adxcdy) - + clift * (adxbdy - bdxady); - - if (b->noexact) { - return det; - } - - permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift - + (Absolute(cdxady) + Absolute(adxcdy)) * blift - + (Absolute(adxbdy) + Absolute(bdxady)) * clift; - errbound = iccerrboundA * permanent; - if ((det > errbound) || (-det > errbound)) { - return det; - } - - return incircleadapt(pa, pb, pc, pd, permanent); -} - -/*****************************************************************************/ -/* */ -/* orient3d() Return a positive value if the point pd lies below the */ -/* plane passing through pa, pb, and pc; "below" is defined so */ -/* that pa, pb, and pc appear in counterclockwise order when */ -/* viewed from above the plane. Returns a negative value if */ -/* pd lies above the plane. Returns zero if the points are */ -/* coplanar. The result is also a rough approximation of six */ -/* times the signed volume of the tetrahedron defined by the */ -/* four points. */ -/* */ -/* Uses exact arithmetic if necessary to ensure a correct answer. The */ -/* result returned is the determinant of a matrix. This determinant is */ -/* computed adaptively, in the sense that exact arithmetic is used only to */ -/* the degree it is needed to ensure that the returned value has the */ -/* correct sign. Hence, this function is usually quite fast, but will run */ -/* more slowly when the input points are coplanar or nearly so. */ -/* */ -/* See my Robust Predicates paper for details. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -REAL orient3dadapt(vertex pa, vertex pb, vertex pc, vertex pd, - REAL aheight, REAL bheight, REAL cheight, REAL dheight, - REAL permanent) -#else /* not ANSI_DECLARATORS */ -REAL orient3dadapt(pa, pb, pc, pd, - aheight, bheight, cheight, dheight, permanent) -vertex pa; -vertex pb; -vertex pc; -vertex pd; -REAL aheight; -REAL bheight; -REAL cheight; -REAL dheight; -REAL permanent; -#endif /* not ANSI_DECLARATORS */ - -{ - INEXACT REAL adx, bdx, cdx, ady, bdy, cdy, adheight, bdheight, cdheight; - REAL det, errbound; - - INEXACT REAL bdxcdy1, cdxbdy1, cdxady1, adxcdy1, adxbdy1, bdxady1; - REAL bdxcdy0, cdxbdy0, cdxady0, adxcdy0, adxbdy0, bdxady0; - REAL bc[4], ca[4], ab[4]; - INEXACT REAL bc3, ca3, ab3; - REAL adet[8], bdet[8], cdet[8]; - int alen, blen, clen; - REAL abdet[16]; - int ablen; - REAL *finnow, *finother, *finswap; - REAL fin1[192], fin2[192]; - int finlength; - - REAL adxtail, bdxtail, cdxtail; - REAL adytail, bdytail, cdytail; - REAL adheighttail, bdheighttail, cdheighttail; - INEXACT REAL at_blarge, at_clarge; - INEXACT REAL bt_clarge, bt_alarge; - INEXACT REAL ct_alarge, ct_blarge; - REAL at_b[4], at_c[4], bt_c[4], bt_a[4], ct_a[4], ct_b[4]; - int at_blen, at_clen, bt_clen, bt_alen, ct_alen, ct_blen; - INEXACT REAL bdxt_cdy1, cdxt_bdy1, cdxt_ady1; - INEXACT REAL adxt_cdy1, adxt_bdy1, bdxt_ady1; - REAL bdxt_cdy0, cdxt_bdy0, cdxt_ady0; - REAL adxt_cdy0, adxt_bdy0, bdxt_ady0; - INEXACT REAL bdyt_cdx1, cdyt_bdx1, cdyt_adx1; - INEXACT REAL adyt_cdx1, adyt_bdx1, bdyt_adx1; - REAL bdyt_cdx0, cdyt_bdx0, cdyt_adx0; - REAL adyt_cdx0, adyt_bdx0, bdyt_adx0; - REAL bct[8], cat[8], abt[8]; - int bctlen, catlen, abtlen; - INEXACT REAL bdxt_cdyt1, cdxt_bdyt1, cdxt_adyt1; - INEXACT REAL adxt_cdyt1, adxt_bdyt1, bdxt_adyt1; - REAL bdxt_cdyt0, cdxt_bdyt0, cdxt_adyt0; - REAL adxt_cdyt0, adxt_bdyt0, bdxt_adyt0; - REAL u[4], v[12], w[16]; - INEXACT REAL u3; - int vlength, wlength; - REAL negate; - - INEXACT REAL bvirt; - REAL avirt, bround, around; - INEXACT REAL c; - INEXACT REAL abig; - REAL ahi, alo, bhi, blo; - REAL err1, err2, err3; - INEXACT REAL _i, _j, _k; - REAL _0; - - adx = (REAL) (pa[0] - pd[0]); - bdx = (REAL) (pb[0] - pd[0]); - cdx = (REAL) (pc[0] - pd[0]); - ady = (REAL) (pa[1] - pd[1]); - bdy = (REAL) (pb[1] - pd[1]); - cdy = (REAL) (pc[1] - pd[1]); - adheight = (REAL) (aheight - dheight); - bdheight = (REAL) (bheight - dheight); - cdheight = (REAL) (cheight - dheight); - - Two_Product(bdx, cdy, bdxcdy1, bdxcdy0); - Two_Product(cdx, bdy, cdxbdy1, cdxbdy0); - Two_Two_Diff(bdxcdy1, bdxcdy0, cdxbdy1, cdxbdy0, bc3, bc[2], bc[1], bc[0]); - bc[3] = bc3; - alen = scale_expansion_zeroelim(4, bc, adheight, adet); - - Two_Product(cdx, ady, cdxady1, cdxady0); - Two_Product(adx, cdy, adxcdy1, adxcdy0); - Two_Two_Diff(cdxady1, cdxady0, adxcdy1, adxcdy0, ca3, ca[2], ca[1], ca[0]); - ca[3] = ca3; - blen = scale_expansion_zeroelim(4, ca, bdheight, bdet); - - Two_Product(adx, bdy, adxbdy1, adxbdy0); - Two_Product(bdx, ady, bdxady1, bdxady0); - Two_Two_Diff(adxbdy1, adxbdy0, bdxady1, bdxady0, ab3, ab[2], ab[1], ab[0]); - ab[3] = ab3; - clen = scale_expansion_zeroelim(4, ab, cdheight, cdet); - - ablen = fast_expansion_sum_zeroelim(alen, adet, blen, bdet, abdet); - finlength = fast_expansion_sum_zeroelim(ablen, abdet, clen, cdet, fin1); - - det = estimate(finlength, fin1); - errbound = o3derrboundB * permanent; - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - Two_Diff_Tail(pa[0], pd[0], adx, adxtail); - Two_Diff_Tail(pb[0], pd[0], bdx, bdxtail); - Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail); - Two_Diff_Tail(pa[1], pd[1], ady, adytail); - Two_Diff_Tail(pb[1], pd[1], bdy, bdytail); - Two_Diff_Tail(pc[1], pd[1], cdy, cdytail); - Two_Diff_Tail(aheight, dheight, adheight, adheighttail); - Two_Diff_Tail(bheight, dheight, bdheight, bdheighttail); - Two_Diff_Tail(cheight, dheight, cdheight, cdheighttail); - - if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && - (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0) && - (adheighttail == 0.0) && - (bdheighttail == 0.0) && - (cdheighttail == 0.0)) { - return det; - } - - errbound = o3derrboundC * permanent + resulterrbound * Absolute(det); - det += (adheight * ((bdx * cdytail + cdy * bdxtail) - - (bdy * cdxtail + cdx * bdytail)) + - adheighttail * (bdx * cdy - bdy * cdx)) + - (bdheight * ((cdx * adytail + ady * cdxtail) - - (cdy * adxtail + adx * cdytail)) + - bdheighttail * (cdx * ady - cdy * adx)) + - (cdheight * ((adx * bdytail + bdy * adxtail) - - (ady * bdxtail + bdx * adytail)) + - cdheighttail * (adx * bdy - ady * bdx)); - if ((det >= errbound) || (-det >= errbound)) { - return det; - } - - finnow = fin1; - finother = fin2; - - if (adxtail == 0.0) { - if (adytail == 0.0) { - at_b[0] = 0.0; - at_blen = 1; - at_c[0] = 0.0; - at_clen = 1; - } else { - negate = -adytail; - Two_Product(negate, bdx, at_blarge, at_b[0]); - at_b[1] = at_blarge; - at_blen = 2; - Two_Product(adytail, cdx, at_clarge, at_c[0]); - at_c[1] = at_clarge; - at_clen = 2; - } - } else { - if (adytail == 0.0) { - Two_Product(adxtail, bdy, at_blarge, at_b[0]); - at_b[1] = at_blarge; - at_blen = 2; - negate = -adxtail; - Two_Product(negate, cdy, at_clarge, at_c[0]); - at_c[1] = at_clarge; - at_clen = 2; - } else { - Two_Product(adxtail, bdy, adxt_bdy1, adxt_bdy0); - Two_Product(adytail, bdx, adyt_bdx1, adyt_bdx0); - Two_Two_Diff(adxt_bdy1, adxt_bdy0, adyt_bdx1, adyt_bdx0, - at_blarge, at_b[2], at_b[1], at_b[0]); - at_b[3] = at_blarge; - at_blen = 4; - Two_Product(adytail, cdx, adyt_cdx1, adyt_cdx0); - Two_Product(adxtail, cdy, adxt_cdy1, adxt_cdy0); - Two_Two_Diff(adyt_cdx1, adyt_cdx0, adxt_cdy1, adxt_cdy0, - at_clarge, at_c[2], at_c[1], at_c[0]); - at_c[3] = at_clarge; - at_clen = 4; - } - } - if (bdxtail == 0.0) { - if (bdytail == 0.0) { - bt_c[0] = 0.0; - bt_clen = 1; - bt_a[0] = 0.0; - bt_alen = 1; - } else { - negate = -bdytail; - Two_Product(negate, cdx, bt_clarge, bt_c[0]); - bt_c[1] = bt_clarge; - bt_clen = 2; - Two_Product(bdytail, adx, bt_alarge, bt_a[0]); - bt_a[1] = bt_alarge; - bt_alen = 2; - } - } else { - if (bdytail == 0.0) { - Two_Product(bdxtail, cdy, bt_clarge, bt_c[0]); - bt_c[1] = bt_clarge; - bt_clen = 2; - negate = -bdxtail; - Two_Product(negate, ady, bt_alarge, bt_a[0]); - bt_a[1] = bt_alarge; - bt_alen = 2; - } else { - Two_Product(bdxtail, cdy, bdxt_cdy1, bdxt_cdy0); - Two_Product(bdytail, cdx, bdyt_cdx1, bdyt_cdx0); - Two_Two_Diff(bdxt_cdy1, bdxt_cdy0, bdyt_cdx1, bdyt_cdx0, - bt_clarge, bt_c[2], bt_c[1], bt_c[0]); - bt_c[3] = bt_clarge; - bt_clen = 4; - Two_Product(bdytail, adx, bdyt_adx1, bdyt_adx0); - Two_Product(bdxtail, ady, bdxt_ady1, bdxt_ady0); - Two_Two_Diff(bdyt_adx1, bdyt_adx0, bdxt_ady1, bdxt_ady0, - bt_alarge, bt_a[2], bt_a[1], bt_a[0]); - bt_a[3] = bt_alarge; - bt_alen = 4; - } - } - if (cdxtail == 0.0) { - if (cdytail == 0.0) { - ct_a[0] = 0.0; - ct_alen = 1; - ct_b[0] = 0.0; - ct_blen = 1; - } else { - negate = -cdytail; - Two_Product(negate, adx, ct_alarge, ct_a[0]); - ct_a[1] = ct_alarge; - ct_alen = 2; - Two_Product(cdytail, bdx, ct_blarge, ct_b[0]); - ct_b[1] = ct_blarge; - ct_blen = 2; - } - } else { - if (cdytail == 0.0) { - Two_Product(cdxtail, ady, ct_alarge, ct_a[0]); - ct_a[1] = ct_alarge; - ct_alen = 2; - negate = -cdxtail; - Two_Product(negate, bdy, ct_blarge, ct_b[0]); - ct_b[1] = ct_blarge; - ct_blen = 2; - } else { - Two_Product(cdxtail, ady, cdxt_ady1, cdxt_ady0); - Two_Product(cdytail, adx, cdyt_adx1, cdyt_adx0); - Two_Two_Diff(cdxt_ady1, cdxt_ady0, cdyt_adx1, cdyt_adx0, - ct_alarge, ct_a[2], ct_a[1], ct_a[0]); - ct_a[3] = ct_alarge; - ct_alen = 4; - Two_Product(cdytail, bdx, cdyt_bdx1, cdyt_bdx0); - Two_Product(cdxtail, bdy, cdxt_bdy1, cdxt_bdy0); - Two_Two_Diff(cdyt_bdx1, cdyt_bdx0, cdxt_bdy1, cdxt_bdy0, - ct_blarge, ct_b[2], ct_b[1], ct_b[0]); - ct_b[3] = ct_blarge; - ct_blen = 4; - } - } - - bctlen = fast_expansion_sum_zeroelim(bt_clen, bt_c, ct_blen, ct_b, bct); - wlength = scale_expansion_zeroelim(bctlen, bct, adheight, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - - catlen = fast_expansion_sum_zeroelim(ct_alen, ct_a, at_clen, at_c, cat); - wlength = scale_expansion_zeroelim(catlen, cat, bdheight, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - - abtlen = fast_expansion_sum_zeroelim(at_blen, at_b, bt_alen, bt_a, abt); - wlength = scale_expansion_zeroelim(abtlen, abt, cdheight, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - - if (adheighttail != 0.0) { - vlength = scale_expansion_zeroelim(4, bc, adheighttail, v); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, vlength, v, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdheighttail != 0.0) { - vlength = scale_expansion_zeroelim(4, ca, bdheighttail, v); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, vlength, v, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdheighttail != 0.0) { - vlength = scale_expansion_zeroelim(4, ab, cdheighttail, v); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, vlength, v, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - if (adxtail != 0.0) { - if (bdytail != 0.0) { - Two_Product(adxtail, bdytail, adxt_bdyt1, adxt_bdyt0); - Two_One_Product(adxt_bdyt1, adxt_bdyt0, cdheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (cdheighttail != 0.0) { - Two_One_Product(adxt_bdyt1, adxt_bdyt0, cdheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - if (cdytail != 0.0) { - negate = -adxtail; - Two_Product(negate, cdytail, adxt_cdyt1, adxt_cdyt0); - Two_One_Product(adxt_cdyt1, adxt_cdyt0, bdheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (bdheighttail != 0.0) { - Two_One_Product(adxt_cdyt1, adxt_cdyt0, bdheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - } - if (bdxtail != 0.0) { - if (cdytail != 0.0) { - Two_Product(bdxtail, cdytail, bdxt_cdyt1, bdxt_cdyt0); - Two_One_Product(bdxt_cdyt1, bdxt_cdyt0, adheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (adheighttail != 0.0) { - Two_One_Product(bdxt_cdyt1, bdxt_cdyt0, adheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - if (adytail != 0.0) { - negate = -bdxtail; - Two_Product(negate, adytail, bdxt_adyt1, bdxt_adyt0); - Two_One_Product(bdxt_adyt1, bdxt_adyt0, cdheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (cdheighttail != 0.0) { - Two_One_Product(bdxt_adyt1, bdxt_adyt0, cdheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - } - if (cdxtail != 0.0) { - if (adytail != 0.0) { - Two_Product(cdxtail, adytail, cdxt_adyt1, cdxt_adyt0); - Two_One_Product(cdxt_adyt1, cdxt_adyt0, bdheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (bdheighttail != 0.0) { - Two_One_Product(cdxt_adyt1, cdxt_adyt0, bdheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - if (bdytail != 0.0) { - negate = -cdxtail; - Two_Product(negate, bdytail, cdxt_bdyt1, cdxt_bdyt0); - Two_One_Product(cdxt_bdyt1, cdxt_bdyt0, adheight, u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - if (adheighttail != 0.0) { - Two_One_Product(cdxt_bdyt1, cdxt_bdyt0, adheighttail, - u3, u[2], u[1], u[0]); - u[3] = u3; - finlength = fast_expansion_sum_zeroelim(finlength, finnow, 4, u, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - } - } - - if (adheighttail != 0.0) { - wlength = scale_expansion_zeroelim(bctlen, bct, adheighttail, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (bdheighttail != 0.0) { - wlength = scale_expansion_zeroelim(catlen, cat, bdheighttail, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - if (cdheighttail != 0.0) { - wlength = scale_expansion_zeroelim(abtlen, abt, cdheighttail, w); - finlength = fast_expansion_sum_zeroelim(finlength, finnow, wlength, w, - finother); - finswap = finnow; finnow = finother; finother = finswap; - } - - return finnow[finlength - 1]; -} - -#ifdef ANSI_DECLARATORS -REAL orient3d(struct mesh *m, struct behavior *b, - vertex pa, vertex pb, vertex pc, vertex pd, - REAL aheight, REAL bheight, REAL cheight, REAL dheight) -#else /* not ANSI_DECLARATORS */ -REAL orient3d(m, b, pa, pb, pc, pd, aheight, bheight, cheight, dheight) -struct mesh *m; -struct behavior *b; -vertex pa; -vertex pb; -vertex pc; -vertex pd; -REAL aheight; -REAL bheight; -REAL cheight; -REAL dheight; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL adx, bdx, cdx, ady, bdy, cdy, adheight, bdheight, cdheight; - REAL bdxcdy, cdxbdy, cdxady, adxcdy, adxbdy, bdxady; - REAL det; - REAL permanent, errbound; - - m->orient3dcount++; - - adx = pa[0] - pd[0]; - bdx = pb[0] - pd[0]; - cdx = pc[0] - pd[0]; - ady = pa[1] - pd[1]; - bdy = pb[1] - pd[1]; - cdy = pc[1] - pd[1]; - adheight = aheight - dheight; - bdheight = bheight - dheight; - cdheight = cheight - dheight; - - bdxcdy = bdx * cdy; - cdxbdy = cdx * bdy; - - cdxady = cdx * ady; - adxcdy = adx * cdy; - - adxbdy = adx * bdy; - bdxady = bdx * ady; - - det = adheight * (bdxcdy - cdxbdy) - + bdheight * (cdxady - adxcdy) - + cdheight * (adxbdy - bdxady); - - if (b->noexact) { - return det; - } - - permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * Absolute(adheight) - + (Absolute(cdxady) + Absolute(adxcdy)) * Absolute(bdheight) - + (Absolute(adxbdy) + Absolute(bdxady)) * Absolute(cdheight); - errbound = o3derrboundA * permanent; - if ((det > errbound) || (-det > errbound)) { - return det; - } - - return orient3dadapt(pa, pb, pc, pd, aheight, bheight, cheight, dheight, - permanent); -} - -/*****************************************************************************/ -/* */ -/* nonregular() Return a positive value if the point pd is incompatible */ -/* with the circle or plane passing through pa, pb, and pc */ -/* (meaning that pd is inside the circle or below the */ -/* plane); a negative value if it is compatible; and zero if */ -/* the four points are cocircular/coplanar. The points pa, */ -/* pb, and pc must be in counterclockwise order, or the sign */ -/* of the result will be reversed. */ -/* */ -/* If the -w switch is used, the points are lifted onto the parabolic */ -/* lifting map, then they are dropped according to their weights, then the */ -/* 3D orientation test is applied. If the -W switch is used, the points' */ -/* heights are already provided, so the 3D orientation test is applied */ -/* directly. If neither switch is used, the incircle test is applied. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -REAL nonregular(struct mesh *m, struct behavior *b, - vertex pa, vertex pb, vertex pc, vertex pd) -#else /* not ANSI_DECLARATORS */ -REAL nonregular(m, b, pa, pb, pc, pd) -struct mesh *m; -struct behavior *b; -vertex pa; -vertex pb; -vertex pc; -vertex pd; -#endif /* not ANSI_DECLARATORS */ - -{ - if (b->weighted == 0) { - return incircle(m, b, pa, pb, pc, pd); - } else if (b->weighted == 1) { - return orient3d(m, b, pa, pb, pc, pd, - pa[0] * pa[0] + pa[1] * pa[1] - pa[2], - pb[0] * pb[0] + pb[1] * pb[1] - pb[2], - pc[0] * pc[0] + pc[1] * pc[1] - pc[2], - pd[0] * pd[0] + pd[1] * pd[1] - pd[2]); - } else { - return orient3d(m, b, pa, pb, pc, pd, pa[2], pb[2], pc[2], pd[2]); - } -} - -/*****************************************************************************/ -/* */ -/* findcircumcenter() Find the circumcenter of a triangle. */ -/* */ -/* The result is returned both in terms of x-y coordinates and xi-eta */ -/* (barycentric) coordinates. The xi-eta coordinate system is defined in */ -/* terms of the triangle: the origin of the triangle is the origin of the */ -/* coordinate system; the destination of the triangle is one unit along the */ -/* xi axis; and the apex of the triangle is one unit along the eta axis. */ -/* This procedure also returns the square of the length of the triangle's */ -/* shortest edge. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void findcircumcenter(struct mesh *m, struct behavior *b, - vertex torg, vertex tdest, vertex tapex, - vertex circumcenter, REAL *xi, REAL *eta, int offcenter) -#else /* not ANSI_DECLARATORS */ -void findcircumcenter(m, b, torg, tdest, tapex, circumcenter, xi, eta, - offcenter) -struct mesh *m; -struct behavior *b; -vertex torg; -vertex tdest; -vertex tapex; -vertex circumcenter; -REAL *xi; -REAL *eta; -int offcenter; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL xdo, ydo, xao, yao; - REAL dodist, aodist, dadist; - REAL denominator; - REAL dx, dy, dxoff, dyoff; - - m->circumcentercount++; - - /* Compute the circumcenter of the triangle. */ - xdo = tdest[0] - torg[0]; - ydo = tdest[1] - torg[1]; - xao = tapex[0] - torg[0]; - yao = tapex[1] - torg[1]; - dodist = xdo * xdo + ydo * ydo; - aodist = xao * xao + yao * yao; - dadist = (tdest[0] - tapex[0]) * (tdest[0] - tapex[0]) + - (tdest[1] - tapex[1]) * (tdest[1] - tapex[1]); - if (b->noexact) { - denominator = 0.5 / (xdo * yao - xao * ydo); - } else { - /* Use the counterclockwise() routine to ensure a positive (and */ - /* reasonably accurate) result, avoiding any possibility of */ - /* division by zero. */ - denominator = 0.5 / counterclockwise(m, b, tdest, tapex, torg); - /* Don't count the above as an orientation test. */ - m->counterclockcount--; - } - dx = (yao * dodist - ydo * aodist) * denominator; - dy = (xdo * aodist - xao * dodist) * denominator; - - /* Find the (squared) length of the triangle's shortest edge. This */ - /* serves as a conservative estimate of the insertion radius of the */ - /* circumcenter's parent. The estimate is used to ensure that */ - /* the algorithm terminates even if very small angles appear in */ - /* the input PSLG. */ - if ((dodist < aodist) && (dodist < dadist)) { - if (offcenter && (b->offconstant > 0.0)) { - /* Find the position of the off-center, as described by Alper Ungor. */ - dxoff = 0.5 * xdo - b->offconstant * ydo; - dyoff = 0.5 * ydo + b->offconstant * xdo; - /* If the off-center is closer to the origin than the */ - /* circumcenter, use the off-center instead. */ - if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { - dx = dxoff; - dy = dyoff; - } - } - } else if (aodist < dadist) { - if (offcenter && (b->offconstant > 0.0)) { - dxoff = 0.5 * xao + b->offconstant * yao; - dyoff = 0.5 * yao - b->offconstant * xao; - /* If the off-center is closer to the origin than the */ - /* circumcenter, use the off-center instead. */ - if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy) { - dx = dxoff; - dy = dyoff; - } - } - } else { - if (offcenter && (b->offconstant > 0.0)) { - dxoff = 0.5 * (tapex[0] - tdest[0]) - - b->offconstant * (tapex[1] - tdest[1]); - dyoff = 0.5 * (tapex[1] - tdest[1]) + - b->offconstant * (tapex[0] - tdest[0]); - /* If the off-center is closer to the destination than the */ - /* circumcenter, use the off-center instead. */ - if (dxoff * dxoff + dyoff * dyoff < - (dx - xdo) * (dx - xdo) + (dy - ydo) * (dy - ydo)) { - dx = xdo + dxoff; - dy = ydo + dyoff; - } - } - } - - circumcenter[0] = torg[0] + dx; - circumcenter[1] = torg[1] + dy; - - /* To interpolate vertex attributes for the new vertex inserted at */ - /* the circumcenter, define a coordinate system with a xi-axis, */ - /* directed from the triangle's origin to its destination, and */ - /* an eta-axis, directed from its origin to its apex. */ - /* Calculate the xi and eta coordinates of the circumcenter. */ - *xi = (yao * dx - xao * dy) * (2.0 * denominator); - *eta = (xdo * dy - ydo * dx) * (2.0 * denominator); -} - -/** **/ -/** **/ -/********* Geometric primitives end here *********/ - -/*****************************************************************************/ -/* */ -/* triangleinit() Initialize some variables. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void triangleinit(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -void triangleinit(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - poolzero(&m->vertices); - poolzero(&m->triangles); - poolzero(&m->subsegs); - poolzero(&m->viri); - poolzero(&m->badsubsegs); - poolzero(&m->badtriangles); - poolzero(&m->flipstackers); - poolzero(&m->splaynodes); - - m->recenttri.tri = (triangle *) NULL; /* No triangle has been visited yet. */ - m->undeads = 0; /* No eliminated input vertices yet. */ - m->samples = 1; /* Point location should take at least one sample. */ - m->checksegments = 0; /* There are no segments in the triangulation yet. */ - m->checkquality = 0; /* The quality triangulation stage has not begun. */ - m->incirclecount = m->counterclockcount = m->orient3dcount = 0; - m->hyperbolacount = m->circletopcount = m->circumcentercount = 0; - randomseed = 1; - - exactinit(); /* Initialize exact arithmetic constants. */ -} - -/*****************************************************************************/ -/* */ -/* randomnation() Generate a random number between 0 and `choices' - 1. */ -/* */ -/* This is a simple linear congruential random number generator. Hence, it */ -/* is a bad random number generator, but good enough for most randomized */ -/* geometric algorithms. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -unsigned long randomnation(unsigned int choices) -#else /* not ANSI_DECLARATORS */ -unsigned long randomnation(choices) -unsigned int choices; -#endif /* not ANSI_DECLARATORS */ - -{ - randomseed = (randomseed * 1366l + 150889l) % 714025l; - return randomseed / (714025l / choices + 1); -} - -/********* Mesh quality testing routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* checkmesh() Test the mesh for topological consistency. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void checkmesh(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void checkmesh(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop; - struct otri oppotri, oppooppotri; - vertex triorg, tridest, triapex; - vertex oppoorg, oppodest; - int horrors; - int saveexact; - triangle ptr; /* Temporary variable used by sym(). */ - - /* Temporarily turn on exact arithmetic if it's off. */ - saveexact = b->noexact; - b->noexact = 0; - if (!b->quiet) { - printf(" Checking consistency of mesh...\n"); - } - horrors = 0; - /* Run through the list of triangles, checking each one. */ - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - while (triangleloop.tri != (triangle *) NULL) { - /* Check all three edges of the triangle. */ - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - org(triangleloop, triorg); - dest(triangleloop, tridest); - if (triangleloop.orient == 0) { /* Only test for inversion once. */ - /* Test if the triangle is flat or inverted. */ - apex(triangleloop, triapex); - if (counterclockwise(m, b, triorg, tridest, triapex) <= 0.0) { - printf(" !! !! Inverted "); - printtriangle(m, b, &triangleloop); - horrors++; - } - } - /* Find the neighboring triangle on this edge. */ - sym(triangleloop, oppotri); - if (oppotri.tri != m->dummytri) { - /* Check that the triangle's neighbor knows it's a neighbor. */ - sym(oppotri, oppooppotri); - if ((triangleloop.tri != oppooppotri.tri) - || (triangleloop.orient != oppooppotri.orient)) { - printf(" !! !! Asymmetric triangle-triangle bond:\n"); - if (triangleloop.tri == oppooppotri.tri) { - printf(" (Right triangle, wrong orientation)\n"); - } - printf(" First "); - printtriangle(m, b, &triangleloop); - printf(" Second (nonreciprocating) "); - printtriangle(m, b, &oppotri); - horrors++; - } - /* Check that both triangles agree on the identities */ - /* of their shared vertices. */ - org(oppotri, oppoorg); - dest(oppotri, oppodest); - if ((triorg != oppodest) || (tridest != oppoorg)) { - printf(" !! !! Mismatched edge coordinates between two triangles:\n" - ); - printf(" First mismatched "); - printtriangle(m, b, &triangleloop); - printf(" Second mismatched "); - printtriangle(m, b, &oppotri); - horrors++; - } - } - } - triangleloop.tri = triangletraverse(m); - } - if (horrors == 0) { - if (!b->quiet) { - printf(" In my studied opinion, the mesh appears to be consistent.\n"); - } - } else if (horrors == 1) { - printf(" !! !! !! !! Precisely one festering wound discovered.\n"); - } else { - printf(" !! !! !! !! %d abominations witnessed.\n", horrors); - } - /* Restore the status of exact arithmetic. */ - b->noexact = saveexact; -} - -#endif /* not REDUCED */ - -/*****************************************************************************/ -/* */ -/* checkdelaunay() Ensure that the mesh is (constrained) Delaunay. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void checkdelaunay(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void checkdelaunay(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop; - struct otri oppotri; - struct osub opposubseg; - vertex triorg, tridest, triapex; - vertex oppoapex; - int shouldbedelaunay; - int horrors; - int saveexact; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - /* Temporarily turn on exact arithmetic if it's off. */ - saveexact = b->noexact; - b->noexact = 0; - if (!b->quiet) { - printf(" Checking Delaunay property of mesh...\n"); - } - horrors = 0; - /* Run through the list of triangles, checking each one. */ - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - while (triangleloop.tri != (triangle *) NULL) { - /* Check all three edges of the triangle. */ - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - org(triangleloop, triorg); - dest(triangleloop, tridest); - apex(triangleloop, triapex); - sym(triangleloop, oppotri); - apex(oppotri, oppoapex); - /* Only test that the edge is locally Delaunay if there is an */ - /* adjoining triangle whose pointer is larger (to ensure that */ - /* each pair isn't tested twice). */ - shouldbedelaunay = (oppotri.tri != m->dummytri) && - !deadtri(oppotri.tri) && (triangleloop.tri < oppotri.tri) && - (triorg != m->infvertex1) && (triorg != m->infvertex2) && - (triorg != m->infvertex3) && - (tridest != m->infvertex1) && (tridest != m->infvertex2) && - (tridest != m->infvertex3) && - (triapex != m->infvertex1) && (triapex != m->infvertex2) && - (triapex != m->infvertex3) && - (oppoapex != m->infvertex1) && (oppoapex != m->infvertex2) && - (oppoapex != m->infvertex3); - if (m->checksegments && shouldbedelaunay) { - /* If a subsegment separates the triangles, then the edge is */ - /* constrained, so no local Delaunay test should be done. */ - tspivot(triangleloop, opposubseg); - if (opposubseg.ss != m->dummysub){ - shouldbedelaunay = 0; - } - } - if (shouldbedelaunay) { - if (nonregular(m, b, triorg, tridest, triapex, oppoapex) > 0.0) { - if (!b->weighted) { - printf(" !! !! Non-Delaunay pair of triangles:\n"); - printf(" First non-Delaunay "); - printtriangle(m, b, &triangleloop); - printf(" Second non-Delaunay "); - } else { - printf(" !! !! Non-regular pair of triangles:\n"); - printf(" First non-regular "); - printtriangle(m, b, &triangleloop); - printf(" Second non-regular "); - } - printtriangle(m, b, &oppotri); - horrors++; - } - } - } - triangleloop.tri = triangletraverse(m); - } - if (horrors == 0) { - if (!b->quiet) { - printf( - " By virtue of my perceptive intelligence, I declare the mesh Delaunay.\n"); - } - } else if (horrors == 1) { - printf( - " !! !! !! !! Precisely one terrifying transgression identified.\n"); - } else { - printf(" !! !! !! !! %d obscenities viewed with horror.\n", horrors); - } - /* Restore the status of exact arithmetic. */ - b->noexact = saveexact; -} - -#endif /* not REDUCED */ - -/*****************************************************************************/ -/* */ -/* enqueuebadtriang() Add a bad triangle data structure to the end of a */ -/* queue. */ -/* */ -/* The queue is actually a set of 4096 queues. I use multiple queues to */ -/* give priority to smaller angles. I originally implemented a heap, but */ -/* the queues are faster by a larger margin than I'd suspected. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void enqueuebadtriang(struct mesh *m, struct behavior *b, - struct badtriang *badtri) -#else /* not ANSI_DECLARATORS */ -void enqueuebadtriang(m, b, badtri) -struct mesh *m; -struct behavior *b; -struct badtriang *badtri; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL length, multiplier; - int exponent, expincrement; - int queuenumber; - int posexponent; - int i; - - if (b->verbose > 2) { - printf(" Queueing bad triangle:\n"); - printf(" (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - badtri->triangorg[0], badtri->triangorg[1], - badtri->triangdest[0], badtri->triangdest[1], - badtri->triangapex[0], badtri->triangapex[1]); - } - - /* Determine the appropriate queue to put the bad triangle into. */ - /* Recall that the key is the square of its shortest edge length. */ - if (badtri->key >= 1.0) { - length = badtri->key; - posexponent = 1; - } else { - /* `badtri->key' is 2.0 to a negative exponent, so we'll record that */ - /* fact and use the reciprocal of `badtri->key', which is > 1.0. */ - length = 1.0 / badtri->key; - posexponent = 0; - } - /* `length' is approximately 2.0 to what exponent? The following code */ - /* determines the answer in time logarithmic in the exponent. */ - exponent = 0; - while (length > 2.0) { - /* Find an approximation by repeated squaring of two. */ - expincrement = 1; - multiplier = 0.5; - while (length * multiplier * multiplier > 1.0) { - expincrement *= 2; - multiplier *= multiplier; - } - /* Reduce the value of `length', then iterate if necessary. */ - exponent += expincrement; - length *= multiplier; - } - /* `length' is approximately squareroot(2.0) to what exponent? */ - exponent = 2.0 * exponent + (length > SQUAREROOTTWO); - /* `exponent' is now in the range 0...2047 for IEEE double precision. */ - /* Choose a queue in the range 0...4095. The shortest edges have the */ - /* highest priority (queue 4095). */ - if (posexponent) { - queuenumber = 2047 - exponent; - } else { - queuenumber = 2048 + exponent; - } - - /* Are we inserting into an empty queue? */ - if (m->queuefront[queuenumber] == (struct badtriang *) NULL) { - /* Yes, we are inserting into an empty queue. */ - /* Will this become the highest-priority queue? */ - if (queuenumber > m->firstnonemptyq) { - /* Yes, this is the highest-priority queue. */ - m->nextnonemptyq[queuenumber] = m->firstnonemptyq; - m->firstnonemptyq = queuenumber; - } else { - /* No, this is not the highest-priority queue. */ - /* Find the queue with next higher priority. */ - i = queuenumber + 1; - while (m->queuefront[i] == (struct badtriang *) NULL) { - i++; - } - /* Mark the newly nonempty queue as following a higher-priority queue. */ - m->nextnonemptyq[queuenumber] = m->nextnonemptyq[i]; - m->nextnonemptyq[i] = queuenumber; - } - /* Put the bad triangle at the beginning of the (empty) queue. */ - m->queuefront[queuenumber] = badtri; - } else { - /* Add the bad triangle to the end of an already nonempty queue. */ - m->queuetail[queuenumber]->nexttriang = badtri; - } - /* Maintain a pointer to the last triangle of the queue. */ - m->queuetail[queuenumber] = badtri; - /* Newly enqueued bad triangle has no successor in the queue. */ - badtri->nexttriang = (struct badtriang *) NULL; -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* enqueuebadtri() Add a bad triangle to the end of a queue. */ -/* */ -/* Allocates a badtriang data structure for the triangle, then passes it to */ -/* enqueuebadtriang(). */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void enqueuebadtri(struct mesh *m, struct behavior *b, struct otri *enqtri, - REAL minedge, vertex enqapex, vertex enqorg, vertex enqdest) -#else /* not ANSI_DECLARATORS */ -void enqueuebadtri(m, b, enqtri, minedge, enqapex, enqorg, enqdest) -struct mesh *m; -struct behavior *b; -struct otri *enqtri; -REAL minedge; -vertex enqapex; -vertex enqorg; -vertex enqdest; -#endif /* not ANSI_DECLARATORS */ - -{ - struct badtriang *newbad; - - /* Allocate space for the bad triangle. */ - newbad = (struct badtriang *) poolalloc(&m->badtriangles); - newbad->poortri = encode(*enqtri); - newbad->key = minedge; - newbad->triangapex = enqapex; - newbad->triangorg = enqorg; - newbad->triangdest = enqdest; - enqueuebadtriang(m, b, newbad); -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* dequeuebadtriang() Remove a triangle from the front of the queue. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -struct badtriang *dequeuebadtriang(struct mesh *m) -#else /* not ANSI_DECLARATORS */ -struct badtriang *dequeuebadtriang(m) -struct mesh *m; -#endif /* not ANSI_DECLARATORS */ - -{ - struct badtriang *result; - - /* If no queues are nonempty, return NULL. */ - if (m->firstnonemptyq < 0) { - return (struct badtriang *) NULL; - } - /* Find the first triangle of the highest-priority queue. */ - result = m->queuefront[m->firstnonemptyq]; - /* Remove the triangle from the queue. */ - m->queuefront[m->firstnonemptyq] = result->nexttriang; - /* If this queue is now empty, note the new highest-priority */ - /* nonempty queue. */ - if (result == m->queuetail[m->firstnonemptyq]) { - m->firstnonemptyq = m->nextnonemptyq[m->firstnonemptyq]; - } - return result; -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* checkseg4encroach() Check a subsegment to see if it is encroached; add */ -/* it to the list if it is. */ -/* */ -/* A subsegment is encroached if there is a vertex in its diametral lens. */ -/* For Ruppert's algorithm (-D switch), the "diametral lens" is the */ -/* diametral circle. For Chew's algorithm (default), the diametral lens is */ -/* just big enough to enclose two isosceles triangles whose bases are the */ -/* subsegment. Each of the two isosceles triangles has two angles equal */ -/* to `b->minangle'. */ -/* */ -/* Chew's algorithm does not require diametral lenses at all--but they save */ -/* time. Any vertex inside a subsegment's diametral lens implies that the */ -/* triangle adjoining the subsegment will be too skinny, so it's only a */ -/* matter of time before the encroaching vertex is deleted by Chew's */ -/* algorithm. It's faster to simply not insert the doomed vertex in the */ -/* first place, which is why I use diametral lenses with Chew's algorithm. */ -/* */ -/* Returns a nonzero value if the subsegment is encroached. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -int checkseg4encroach(struct mesh *m, struct behavior *b, - struct osub *testsubseg) -#else /* not ANSI_DECLARATORS */ -int checkseg4encroach(m, b, testsubseg) -struct mesh *m; -struct behavior *b; -struct osub *testsubseg; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri neighbortri; - struct osub testsym; - struct badsubseg *encroachedseg; - REAL dotproduct; - int encroached; - int sides; - vertex eorg, edest, eapex; - triangle ptr; /* Temporary variable used by stpivot(). */ - - encroached = 0; - sides = 0; - - sorg(*testsubseg, eorg); - sdest(*testsubseg, edest); - /* Check one neighbor of the subsegment. */ - stpivot(*testsubseg, neighbortri); - /* Does the neighbor exist, or is this a boundary edge? */ - if (neighbortri.tri != m->dummytri) { - sides++; - /* Find a vertex opposite this subsegment. */ - apex(neighbortri, eapex); - /* Check whether the apex is in the diametral lens of the subsegment */ - /* (the diametral circle if `conformdel' is set). A dot product */ - /* of two sides of the triangle is used to check whether the angle */ - /* at the apex is greater than (180 - 2 `minangle') degrees (for */ - /* lenses; 90 degrees for diametral circles). */ - dotproduct = (eorg[0] - eapex[0]) * (edest[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (edest[1] - eapex[1]); - if (dotproduct < 0.0) { - if (b->conformdel || - (dotproduct * dotproduct >= - (2.0 * b->goodangle - 1.0) * (2.0 * b->goodangle - 1.0) * - ((eorg[0] - eapex[0]) * (eorg[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (eorg[1] - eapex[1])) * - ((edest[0] - eapex[0]) * (edest[0] - eapex[0]) + - (edest[1] - eapex[1]) * (edest[1] - eapex[1])))) { - encroached = 1; - } - } - } - /* Check the other neighbor of the subsegment. */ - ssym(*testsubseg, testsym); - stpivot(testsym, neighbortri); - /* Does the neighbor exist, or is this a boundary edge? */ - if (neighbortri.tri != m->dummytri) { - sides++; - /* Find the other vertex opposite this subsegment. */ - apex(neighbortri, eapex); - /* Check whether the apex is in the diametral lens of the subsegment */ - /* (or the diametral circle, if `conformdel' is set). */ - dotproduct = (eorg[0] - eapex[0]) * (edest[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (edest[1] - eapex[1]); - if (dotproduct < 0.0) { - if (b->conformdel || - (dotproduct * dotproduct >= - (2.0 * b->goodangle - 1.0) * (2.0 * b->goodangle - 1.0) * - ((eorg[0] - eapex[0]) * (eorg[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (eorg[1] - eapex[1])) * - ((edest[0] - eapex[0]) * (edest[0] - eapex[0]) + - (edest[1] - eapex[1]) * (edest[1] - eapex[1])))) { - encroached += 2; - } - } - } - - if (encroached && (!b->nobisect || ((b->nobisect == 1) && (sides == 2)))) { - if (b->verbose > 2) { - printf( - " Queueing encroached subsegment (%.12g, %.12g) (%.12g, %.12g).\n", - eorg[0], eorg[1], edest[0], edest[1]); - } - /* Add the subsegment to the list of encroached subsegments. */ - /* Be sure to get the orientation right. */ - encroachedseg = (struct badsubseg *) poolalloc(&m->badsubsegs); - if (encroached == 1) { - encroachedseg->encsubseg = sencode(*testsubseg); - encroachedseg->subsegorg = eorg; - encroachedseg->subsegdest = edest; - } else { - encroachedseg->encsubseg = sencode(testsym); - encroachedseg->subsegorg = edest; - encroachedseg->subsegdest = eorg; - } - } - - return encroached; -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* testtriangle() Test a triangle for quality and size. */ -/* */ -/* Tests a triangle to see if it satisfies the minimum angle condition and */ -/* the maximum area condition. Triangles that aren't up to spec are added */ -/* to the bad triangle queue. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void testtriangle(struct mesh *m, struct behavior *b, struct otri *testtri) -#else /* not ANSI_DECLARATORS */ -void testtriangle(m, b, testtri) -struct mesh *m; -struct behavior *b; -struct otri *testtri; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri tri1, tri2; - struct osub testsub; - vertex torg, tdest, tapex; - vertex base1, base2; - vertex org1, dest1, org2, dest2; - vertex joinvertex; - REAL dxod, dyod, dxda, dyda, dxao, dyao; - REAL dxod2, dyod2, dxda2, dyda2, dxao2, dyao2; - REAL apexlen, orglen, destlen, minedge; - REAL angle; - REAL area; - REAL dist1, dist2; - subseg sptr; /* Temporary variable used by tspivot(). */ - triangle ptr; /* Temporary variable used by oprev() and dnext(). */ - - org(*testtri, torg); - dest(*testtri, tdest); - apex(*testtri, tapex); - dxod = torg[0] - tdest[0]; - dyod = torg[1] - tdest[1]; - dxda = tdest[0] - tapex[0]; - dyda = tdest[1] - tapex[1]; - dxao = tapex[0] - torg[0]; - dyao = tapex[1] - torg[1]; - dxod2 = dxod * dxod; - dyod2 = dyod * dyod; - dxda2 = dxda * dxda; - dyda2 = dyda * dyda; - dxao2 = dxao * dxao; - dyao2 = dyao * dyao; - /* Find the lengths of the triangle's three edges. */ - apexlen = dxod2 + dyod2; - orglen = dxda2 + dyda2; - destlen = dxao2 + dyao2; - - if ((apexlen < orglen) && (apexlen < destlen)) { - /* The edge opposite the apex is shortest. */ - minedge = apexlen; - /* Find the square of the cosine of the angle at the apex. */ - angle = dxda * dxao + dyda * dyao; - angle = angle * angle / (orglen * destlen); - base1 = torg; - base2 = tdest; - otricopy(*testtri, tri1); - } else if (orglen < destlen) { - /* The edge opposite the origin is shortest. */ - minedge = orglen; - /* Find the square of the cosine of the angle at the origin. */ - angle = dxod * dxao + dyod * dyao; - angle = angle * angle / (apexlen * destlen); - base1 = tdest; - base2 = tapex; - lnext(*testtri, tri1); - } else { - /* The edge opposite the destination is shortest. */ - minedge = destlen; - /* Find the square of the cosine of the angle at the destination. */ - angle = dxod * dxda + dyod * dyda; - angle = angle * angle / (apexlen * orglen); - base1 = tapex; - base2 = torg; - lprev(*testtri, tri1); - } - - if (b->vararea || b->fixedarea || b->usertest) { - /* Check whether the area is larger than permitted. */ - area = 0.5 * (dxod * dyda - dyod * dxda); - if (b->fixedarea && (area > b->maxarea)) { - /* Add this triangle to the list of bad triangles. */ - enqueuebadtri(m, b, testtri, minedge, tapex, torg, tdest); - return; - } - - /* Nonpositive area constraints are treated as unconstrained. */ - if ((b->vararea) && (area > areabound(*testtri)) && - (areabound(*testtri) > 0.0)) { - /* Add this triangle to the list of bad triangles. */ - enqueuebadtri(m, b, testtri, minedge, tapex, torg, tdest); - return; - } - - if (b->usertest) { - /* Check whether the user thinks this triangle is too large. */ - if (triunsuitable(torg, tdest, tapex, area)) { - enqueuebadtri(m, b, testtri, minedge, tapex, torg, tdest); - return; - } - } - } - - /* Check whether the angle is smaller than permitted. */ - if (angle > b->goodangle) { - /* Use the rules of Miller, Pav, and Walkington to decide that certain */ - /* triangles should not be split, even if they have bad angles. */ - /* A skinny triangle is not split if its shortest edge subtends a */ - /* small input angle, and both endpoints of the edge lie on a */ - /* concentric circular shell. For convenience, I make a small */ - /* adjustment to that rule: I check if the endpoints of the edge */ - /* both lie in segment interiors, equidistant from the apex where */ - /* the two segments meet. */ - /* First, check if both points lie in segment interiors. */ - if ((vertextype(base1) == SEGMENTVERTEX) && - (vertextype(base2) == SEGMENTVERTEX)) { - /* Check if both points lie in a common segment. If they do, the */ - /* skinny triangle is enqueued to be split as usual. */ - tspivot(tri1, testsub); - if (testsub.ss == m->dummysub) { - /* No common segment. Find a subsegment that contains `torg'. */ - otricopy(tri1, tri2); - do { - oprevself(tri1); - tspivot(tri1, testsub); - } while (testsub.ss == m->dummysub); - /* Find the endpoints of the containing segment. */ - segorg(testsub, org1); - segdest(testsub, dest1); - /* Find a subsegment that contains `tdest'. */ - do { - dnextself(tri2); - tspivot(tri2, testsub); - } while (testsub.ss == m->dummysub); - /* Find the endpoints of the containing segment. */ - segorg(testsub, org2); - segdest(testsub, dest2); - /* Check if the two containing segments have an endpoint in common. */ - joinvertex = (vertex) NULL; - if ((dest1[0] == org2[0]) && (dest1[1] == org2[1])) { - joinvertex = dest1; - } else if ((org1[0] == dest2[0]) && (org1[1] == dest2[1])) { - joinvertex = org1; - } - if (joinvertex != (vertex) NULL) { - /* Compute the distance from the common endpoint (of the two */ - /* segments) to each of the endpoints of the shortest edge. */ - dist1 = ((base1[0] - joinvertex[0]) * (base1[0] - joinvertex[0]) + - (base1[1] - joinvertex[1]) * (base1[1] - joinvertex[1])); - dist2 = ((base2[0] - joinvertex[0]) * (base2[0] - joinvertex[0]) + - (base2[1] - joinvertex[1]) * (base2[1] - joinvertex[1])); - /* If the two distances are equal, don't split the triangle. */ - if ((dist1 < 1.001 * dist2) && (dist1 > 0.999 * dist2)) { - /* Return now to avoid enqueueing the bad triangle. */ - return; - } - } - } - } - - /* Add this triangle to the list of bad triangles. */ - enqueuebadtri(m, b, testtri, minedge, tapex, torg, tdest); - } -} - -#endif /* not CDT_ONLY */ - -/** **/ -/** **/ -/********* Mesh quality testing routines end here *********/ - -/********* Point location routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* makevertexmap() Construct a mapping from vertices to triangles to */ -/* improve the speed of point location for segment */ -/* insertion. */ -/* */ -/* Traverses all the triangles, and provides each corner of each triangle */ -/* with a pointer to that triangle. Of course, pointers will be */ -/* overwritten by other pointers because (almost) each vertex is a corner */ -/* of several triangles, but in the end every vertex will point to some */ -/* triangle that contains it. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void makevertexmap(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void makevertexmap(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop; - vertex triorg; - - if (b->verbose) { - printf(" Constructing mapping from vertices to triangles.\n"); - } - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - while (triangleloop.tri != (triangle *) NULL) { - /* Check all three vertices of the triangle. */ - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - org(triangleloop, triorg); - setvertex2tri(triorg, encode(triangleloop)); - } - triangleloop.tri = triangletraverse(m); - } -} - -/*****************************************************************************/ -/* */ -/* preciselocate() Find a triangle or edge containing a given point. */ -/* */ -/* Begins its search from `searchtri'. It is important that `searchtri' */ -/* be a handle with the property that `searchpoint' is strictly to the left */ -/* of the edge denoted by `searchtri', or is collinear with that edge and */ -/* does not intersect that edge. (In particular, `searchpoint' should not */ -/* be the origin or destination of that edge.) */ -/* */ -/* These conditions are imposed because preciselocate() is normally used in */ -/* one of two situations: */ -/* */ -/* (1) To try to find the location to insert a new point. Normally, we */ -/* know an edge that the point is strictly to the left of. In the */ -/* incremental Delaunay algorithm, that edge is a bounding box edge. */ -/* In Ruppert's Delaunay refinement algorithm for quality meshing, */ -/* that edge is the shortest edge of the triangle whose circumcenter */ -/* is being inserted. */ -/* */ -/* (2) To try to find an existing point. In this case, any edge on the */ -/* convex hull is a good starting edge. You must screen out the */ -/* possibility that the vertex sought is an endpoint of the starting */ -/* edge before you call preciselocate(). */ -/* */ -/* On completion, `searchtri' is a triangle that contains `searchpoint'. */ -/* */ -/* This implementation differs from that given by Guibas and Stolfi. It */ -/* walks from triangle to triangle, crossing an edge only if `searchpoint' */ -/* is on the other side of the line containing that edge. After entering */ -/* a triangle, there are two edges by which one can leave that triangle. */ -/* If both edges are valid (`searchpoint' is on the other side of both */ -/* edges), one of the two is chosen by drawing a line perpendicular to */ -/* the entry edge (whose endpoints are `forg' and `fdest') passing through */ -/* `fapex'. Depending on which side of this perpendicular `searchpoint' */ -/* falls on, an exit edge is chosen. */ -/* */ -/* This implementation is empirically faster than the Guibas and Stolfi */ -/* point location routine (which I originally used), which tends to spiral */ -/* in toward its target. */ -/* */ -/* Returns ONVERTEX if the point lies on an existing vertex. `searchtri' */ -/* is a handle whose origin is the existing vertex. */ -/* */ -/* Returns ONEDGE if the point lies on a mesh edge. `searchtri' is a */ -/* handle whose primary edge is the edge on which the point lies. */ -/* */ -/* Returns INTRIANGLE if the point lies strictly within a triangle. */ -/* `searchtri' is a handle on the triangle that contains the point. */ -/* */ -/* Returns OUTSIDE if the point lies outside the mesh. `searchtri' is a */ -/* handle whose primary edge the point is to the right of. This might */ -/* occur when the circumcenter of a triangle falls just slightly outside */ -/* the mesh due to floating-point roundoff error. It also occurs when */ -/* seeking a hole or region point that a foolish user has placed outside */ -/* the mesh. */ -/* */ -/* If `stopatsubsegment' is nonzero, the search will stop if it tries to */ -/* walk through a subsegment, and will return OUTSIDE. */ -/* */ -/* WARNING: This routine is designed for convex triangulations, and will */ -/* not generally work after the holes and concavities have been carved. */ -/* However, it can still be used to find the circumcenter of a triangle, as */ -/* long as the search is begun from the triangle in question. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -enum locateresult preciselocate(struct mesh *m, struct behavior *b, - vertex searchpoint, struct otri *searchtri, - int stopatsubsegment) -#else /* not ANSI_DECLARATORS */ -enum locateresult preciselocate(m, b, searchpoint, searchtri, stopatsubsegment) -struct mesh *m; -struct behavior *b; -vertex searchpoint; -struct otri *searchtri; -int stopatsubsegment; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri backtracktri; - struct osub checkedge; - vertex forg, fdest, fapex; - REAL orgorient, destorient; - int moveleft; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (b->verbose > 2) { - printf(" Searching for point (%.12g, %.12g).\n", - searchpoint[0], searchpoint[1]); - } - /* Where are we? */ - org(*searchtri, forg); - dest(*searchtri, fdest); - apex(*searchtri, fapex); - while (1) { - if (b->verbose > 2) { - printf(" At (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - forg[0], forg[1], fdest[0], fdest[1], fapex[0], fapex[1]); - } - /* Check whether the apex is the point we seek. */ - if ((fapex[0] == searchpoint[0]) && (fapex[1] == searchpoint[1])) { - lprevself(*searchtri); - return ONVERTEX; - } - /* Does the point lie on the other side of the line defined by the */ - /* triangle edge opposite the triangle's destination? */ - destorient = counterclockwise(m, b, forg, fapex, searchpoint); - /* Does the point lie on the other side of the line defined by the */ - /* triangle edge opposite the triangle's origin? */ - orgorient = counterclockwise(m, b, fapex, fdest, searchpoint); - if (destorient > 0.0) { - if (orgorient > 0.0) { - /* Move left if the inner product of (fapex - searchpoint) and */ - /* (fdest - forg) is positive. This is equivalent to drawing */ - /* a line perpendicular to the line (forg, fdest) and passing */ - /* through `fapex', and determining which side of this line */ - /* `searchpoint' falls on. */ - moveleft = (fapex[0] - searchpoint[0]) * (fdest[0] - forg[0]) + - (fapex[1] - searchpoint[1]) * (fdest[1] - forg[1]) > 0.0; - } else { - moveleft = 1; - } - } else { - if (orgorient > 0.0) { - moveleft = 0; - } else { - /* The point we seek must be on the boundary of or inside this */ - /* triangle. */ - if (destorient == 0.0) { - lprevself(*searchtri); - return ONEDGE; - } - if (orgorient == 0.0) { - lnextself(*searchtri); - return ONEDGE; - } - return INTRIANGLE; - } - } - - /* Move to another triangle. Leave a trace `backtracktri' in case */ - /* floating-point roundoff or some such bogey causes us to walk */ - /* off a boundary of the triangulation. */ - if (moveleft) { - lprev(*searchtri, backtracktri); - fdest = fapex; - } else { - lnext(*searchtri, backtracktri); - forg = fapex; - } - sym(backtracktri, *searchtri); - - if (m->checksegments && stopatsubsegment) { - /* Check for walking through a subsegment. */ - tspivot(backtracktri, checkedge); - if (checkedge.ss != m->dummysub) { - /* Go back to the last triangle. */ - otricopy(backtracktri, *searchtri); - return OUTSIDE; - } - } - /* Check for walking right out of the triangulation. */ - if (searchtri->tri == m->dummytri) { - /* Go back to the last triangle. */ - otricopy(backtracktri, *searchtri); - return OUTSIDE; - } - - apex(*searchtri, fapex); - } -} - -/*****************************************************************************/ -/* */ -/* locate() Find a triangle or edge containing a given point. */ -/* */ -/* Searching begins from one of: the input `searchtri', a recently */ -/* encountered triangle `recenttri', or from a triangle chosen from a */ -/* random sample. The choice is made by determining which triangle's */ -/* origin is closest to the point we are searching for. Normally, */ -/* `searchtri' should be a handle on the convex hull of the triangulation. */ -/* */ -/* Details on the random sampling method can be found in the Mucke, Saias, */ -/* and Zhu paper cited in the header of this code. */ -/* */ -/* On completion, `searchtri' is a triangle that contains `searchpoint'. */ -/* */ -/* Returns ONVERTEX if the point lies on an existing vertex. `searchtri' */ -/* is a handle whose origin is the existing vertex. */ -/* */ -/* Returns ONEDGE if the point lies on a mesh edge. `searchtri' is a */ -/* handle whose primary edge is the edge on which the point lies. */ -/* */ -/* Returns INTRIANGLE if the point lies strictly within a triangle. */ -/* `searchtri' is a handle on the triangle that contains the point. */ -/* */ -/* Returns OUTSIDE if the point lies outside the mesh. `searchtri' is a */ -/* handle whose primary edge the point is to the right of. This might */ -/* occur when the circumcenter of a triangle falls just slightly outside */ -/* the mesh due to floating-point roundoff error. It also occurs when */ -/* seeking a hole or region point that a foolish user has placed outside */ -/* the mesh. */ -/* */ -/* WARNING: This routine is designed for convex triangulations, and will */ -/* not generally work after the holes and concavities have been carved. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -enum locateresult locate(struct mesh *m, struct behavior *b, - vertex searchpoint, struct otri *searchtri) -#else /* not ANSI_DECLARATORS */ -enum locateresult locate(m, b, searchpoint, searchtri) -struct mesh *m; -struct behavior *b; -vertex searchpoint; -struct otri *searchtri; -#endif /* not ANSI_DECLARATORS */ - -{ - VOID **sampleblock; - char *firsttri; - struct otri sampletri; - vertex torg, tdest; - unsigned long alignptr; - REAL searchdist, dist; - REAL ahead; - long samplesperblock, totalsamplesleft, samplesleft; - long population, totalpopulation; - triangle ptr; /* Temporary variable used by sym(). */ - - if (b->verbose > 2) { - printf(" Randomly sampling for a triangle near point (%.12g, %.12g).\n", - searchpoint[0], searchpoint[1]); - } - /* Record the distance from the suggested starting triangle to the */ - /* point we seek. */ - org(*searchtri, torg); - searchdist = (searchpoint[0] - torg[0]) * (searchpoint[0] - torg[0]) + - (searchpoint[1] - torg[1]) * (searchpoint[1] - torg[1]); - if (b->verbose > 2) { - printf(" Boundary triangle has origin (%.12g, %.12g).\n", - torg[0], torg[1]); - } - - /* If a recently encountered triangle has been recorded and has not been */ - /* deallocated, test it as a good starting point. */ - if (m->recenttri.tri != (triangle *) NULL) { - if (!deadtri(m->recenttri.tri)) { - org(m->recenttri, torg); - if ((torg[0] == searchpoint[0]) && (torg[1] == searchpoint[1])) { - otricopy(m->recenttri, *searchtri); - return ONVERTEX; - } - dist = (searchpoint[0] - torg[0]) * (searchpoint[0] - torg[0]) + - (searchpoint[1] - torg[1]) * (searchpoint[1] - torg[1]); - if (dist < searchdist) { - otricopy(m->recenttri, *searchtri); - searchdist = dist; - if (b->verbose > 2) { - printf(" Choosing recent triangle with origin (%.12g, %.12g).\n", - torg[0], torg[1]); - } - } - } - } - - /* The number of random samples taken is proportional to the cube root of */ - /* the number of triangles in the mesh. The next bit of code assumes */ - /* that the number of triangles increases monotonically (or at least */ - /* doesn't decrease enough to matter). */ - while (SAMPLEFACTOR * m->samples * m->samples * m->samples < - m->triangles.items) { - m->samples++; - } - - /* We'll draw ceiling(samples * TRIPERBLOCK / maxitems) random samples */ - /* from each block of triangles (except the first)--until we meet the */ - /* sample quota. The ceiling means that blocks at the end might be */ - /* neglected, but I don't care. */ - samplesperblock = (m->samples * TRIPERBLOCK - 1) / m->triangles.maxitems + 1; - /* We'll draw ceiling(samples * itemsfirstblock / maxitems) random samples */ - /* from the first block of triangles. */ - samplesleft = (m->samples * m->triangles.itemsfirstblock - 1) / - m->triangles.maxitems + 1; - totalsamplesleft = m->samples; - population = m->triangles.itemsfirstblock; - totalpopulation = m->triangles.maxitems; - sampleblock = m->triangles.firstblock; - sampletri.orient = 0; - while (totalsamplesleft > 0) { - /* If we're in the last block, `population' needs to be corrected. */ - if (population > totalpopulation) { - population = totalpopulation; - } - /* Find a pointer to the first triangle in the block. */ - alignptr = (unsigned long) (sampleblock + 1); - firsttri = (char *) (alignptr + - (unsigned long) m->triangles.alignbytes - - (alignptr % - (unsigned long) m->triangles.alignbytes)); - - /* Choose `samplesleft' randomly sampled triangles in this block. */ - do { - sampletri.tri = (triangle *) (firsttri + - (randomnation((unsigned int) population) * - m->triangles.itembytes)); - if (!deadtri(sampletri.tri)) { - org(sampletri, torg); - dist = (searchpoint[0] - torg[0]) * (searchpoint[0] - torg[0]) + - (searchpoint[1] - torg[1]) * (searchpoint[1] - torg[1]); - if (dist < searchdist) { - otricopy(sampletri, *searchtri); - searchdist = dist; - if (b->verbose > 2) { - printf(" Choosing triangle with origin (%.12g, %.12g).\n", - torg[0], torg[1]); - } - } - } - - samplesleft--; - totalsamplesleft--; - } while ((samplesleft > 0) && (totalsamplesleft > 0)); - - if (totalsamplesleft > 0) { - sampleblock = (VOID **) *sampleblock; - samplesleft = samplesperblock; - totalpopulation -= population; - population = TRIPERBLOCK; - } - } - - /* Where are we? */ - org(*searchtri, torg); - dest(*searchtri, tdest); - /* Check the starting triangle's vertices. */ - if ((torg[0] == searchpoint[0]) && (torg[1] == searchpoint[1])) { - return ONVERTEX; - } - if ((tdest[0] == searchpoint[0]) && (tdest[1] == searchpoint[1])) { - lnextself(*searchtri); - return ONVERTEX; - } - /* Orient `searchtri' to fit the preconditions of calling preciselocate(). */ - ahead = counterclockwise(m, b, torg, tdest, searchpoint); - if (ahead < 0.0) { - /* Turn around so that `searchpoint' is to the left of the */ - /* edge specified by `searchtri'. */ - symself(*searchtri); - } else if (ahead == 0.0) { - /* Check if `searchpoint' is between `torg' and `tdest'. */ - if (((torg[0] < searchpoint[0]) == (searchpoint[0] < tdest[0])) && - ((torg[1] < searchpoint[1]) == (searchpoint[1] < tdest[1]))) { - return ONEDGE; - } - } - return preciselocate(m, b, searchpoint, searchtri, 0); -} - -/** **/ -/** **/ -/********* Point location routines end here *********/ - -/********* Mesh transformation routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* insertsubseg() Create a new subsegment and insert it between two */ -/* triangles. */ -/* */ -/* The new subsegment is inserted at the edge described by the handle */ -/* `tri'. Its vertices are properly initialized. The marker `subsegmark' */ -/* is applied to the subsegment and, if appropriate, its vertices. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void insertsubseg(struct mesh *m, struct behavior *b, struct otri *tri, - int subsegmark) -#else /* not ANSI_DECLARATORS */ -void insertsubseg(m, b, tri, subsegmark) -struct mesh *m; -struct behavior *b; -struct otri *tri; /* Edge at which to insert the new subsegment. */ -int subsegmark; /* Marker for the new subsegment. */ -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri oppotri; - struct osub newsubseg; - vertex triorg, tridest; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - org(*tri, triorg); - dest(*tri, tridest); - /* Mark vertices if possible. */ - if (vertexmark(triorg) == 0) { - setvertexmark(triorg, subsegmark); - } - if (vertexmark(tridest) == 0) { - setvertexmark(tridest, subsegmark); - } - /* Check if there's already a subsegment here. */ - tspivot(*tri, newsubseg); - if (newsubseg.ss == m->dummysub) { - /* Make new subsegment and initialize its vertices. */ - makesubseg(m, &newsubseg); - setsorg(newsubseg, tridest); - setsdest(newsubseg, triorg); - setsegorg(newsubseg, tridest); - setsegdest(newsubseg, triorg); - /* Bond new subsegment to the two triangles it is sandwiched between. */ - /* Note that the facing triangle `oppotri' might be equal to */ - /* `dummytri' (outer space), but the new subsegment is bonded to it */ - /* all the same. */ - tsbond(*tri, newsubseg); - sym(*tri, oppotri); - ssymself(newsubseg); - tsbond(oppotri, newsubseg); - setmark(newsubseg, subsegmark); - if (b->verbose > 2) { - printf(" Inserting new "); - printsubseg(m, b, &newsubseg); - } - } else { - if (mark(newsubseg) == 0) { - setmark(newsubseg, subsegmark); - } - } -} - -/*****************************************************************************/ -/* */ -/* Terminology */ -/* */ -/* A "local transformation" replaces a small set of triangles with another */ -/* set of triangles. This may or may not involve inserting or deleting a */ -/* vertex. */ -/* */ -/* The term "casing" is used to describe the set of triangles that are */ -/* attached to the triangles being transformed, but are not transformed */ -/* themselves. Think of the casing as a fixed hollow structure inside */ -/* which all the action happens. A "casing" is only defined relative to */ -/* a single transformation; each occurrence of a transformation will */ -/* involve a different casing. */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* flip() Transform two triangles to two different triangles by flipping */ -/* an edge counterclockwise within a quadrilateral. */ -/* */ -/* Imagine the original triangles, abc and bad, oriented so that the */ -/* shared edge ab lies in a horizontal plane, with the vertex b on the left */ -/* and the vertex a on the right. The vertex c lies below the edge, and */ -/* the vertex d lies above the edge. The `flipedge' handle holds the edge */ -/* ab of triangle abc, and is directed left, from vertex a to vertex b. */ -/* */ -/* The triangles abc and bad are deleted and replaced by the triangles cdb */ -/* and dca. The triangles that represent abc and bad are NOT deallocated; */ -/* they are reused for dca and cdb, respectively. Hence, any handles that */ -/* may have held the original triangles are still valid, although not */ -/* directed as they were before. */ -/* */ -/* Upon completion of this routine, the `flipedge' handle holds the edge */ -/* dc of triangle dca, and is directed down, from vertex d to vertex c. */ -/* (Hence, the two triangles have rotated counterclockwise.) */ -/* */ -/* WARNING: This transformation is geometrically valid only if the */ -/* quadrilateral adbc is convex. Furthermore, this transformation is */ -/* valid only if there is not a subsegment between the triangles abc and */ -/* bad. This routine does not check either of these preconditions, and */ -/* it is the responsibility of the calling routine to ensure that they are */ -/* met. If they are not, the streets shall be filled with wailing and */ -/* gnashing of teeth. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void flip(struct mesh *m, struct behavior *b, struct otri *flipedge) -#else /* not ANSI_DECLARATORS */ -void flip(m, b, flipedge) -struct mesh *m; -struct behavior *b; -struct otri *flipedge; /* Handle for the triangle abc. */ -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri botleft, botright; - struct otri topleft, topright; - struct otri top; - struct otri botlcasing, botrcasing; - struct otri toplcasing, toprcasing; - struct osub botlsubseg, botrsubseg; - struct osub toplsubseg, toprsubseg; - vertex leftvertex, rightvertex, botvertex; - vertex farvertex; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - /* Identify the vertices of the quadrilateral. */ - org(*flipedge, rightvertex); - dest(*flipedge, leftvertex); - apex(*flipedge, botvertex); - sym(*flipedge, top); -#ifdef SELF_CHECK - if (top.tri == m->dummytri) { - printf("Internal error in flip(): Attempt to flip on boundary.\n"); - lnextself(*flipedge); - return; - } - if (m->checksegments) { - tspivot(*flipedge, toplsubseg); - if (toplsubseg.ss != m->dummysub) { - printf("Internal error in flip(): Attempt to flip a segment.\n"); - lnextself(*flipedge); - return; - } - } -#endif /* SELF_CHECK */ - apex(top, farvertex); - - /* Identify the casing of the quadrilateral. */ - lprev(top, topleft); - sym(topleft, toplcasing); - lnext(top, topright); - sym(topright, toprcasing); - lnext(*flipedge, botleft); - sym(botleft, botlcasing); - lprev(*flipedge, botright); - sym(botright, botrcasing); - /* Rotate the quadrilateral one-quarter turn counterclockwise. */ - bond(topleft, botlcasing); - bond(botleft, botrcasing); - bond(botright, toprcasing); - bond(topright, toplcasing); - - if (m->checksegments) { - /* Check for subsegments and rebond them to the quadrilateral. */ - tspivot(topleft, toplsubseg); - tspivot(botleft, botlsubseg); - tspivot(botright, botrsubseg); - tspivot(topright, toprsubseg); - if (toplsubseg.ss == m->dummysub) { - tsdissolve(topright); - } else { - tsbond(topright, toplsubseg); - } - if (botlsubseg.ss == m->dummysub) { - tsdissolve(topleft); - } else { - tsbond(topleft, botlsubseg); - } - if (botrsubseg.ss == m->dummysub) { - tsdissolve(botleft); - } else { - tsbond(botleft, botrsubseg); - } - if (toprsubseg.ss == m->dummysub) { - tsdissolve(botright); - } else { - tsbond(botright, toprsubseg); - } - } - - /* New vertex assignments for the rotated quadrilateral. */ - setorg(*flipedge, farvertex); - setdest(*flipedge, botvertex); - setapex(*flipedge, rightvertex); - setorg(top, botvertex); - setdest(top, farvertex); - setapex(top, leftvertex); - if (b->verbose > 2) { - printf(" Edge flip results in left "); - printtriangle(m, b, &top); - printf(" and right "); - printtriangle(m, b, flipedge); - } -} - -/*****************************************************************************/ -/* */ -/* unflip() Transform two triangles to two different triangles by */ -/* flipping an edge clockwise within a quadrilateral. Reverses */ -/* the flip() operation so that the data structures representing */ -/* the triangles are back where they were before the flip(). */ -/* */ -/* Imagine the original triangles, abc and bad, oriented so that the */ -/* shared edge ab lies in a horizontal plane, with the vertex b on the left */ -/* and the vertex a on the right. The vertex c lies below the edge, and */ -/* the vertex d lies above the edge. The `flipedge' handle holds the edge */ -/* ab of triangle abc, and is directed left, from vertex a to vertex b. */ -/* */ -/* The triangles abc and bad are deleted and replaced by the triangles cdb */ -/* and dca. The triangles that represent abc and bad are NOT deallocated; */ -/* they are reused for cdb and dca, respectively. Hence, any handles that */ -/* may have held the original triangles are still valid, although not */ -/* directed as they were before. */ -/* */ -/* Upon completion of this routine, the `flipedge' handle holds the edge */ -/* cd of triangle cdb, and is directed up, from vertex c to vertex d. */ -/* (Hence, the two triangles have rotated clockwise.) */ -/* */ -/* WARNING: This transformation is geometrically valid only if the */ -/* quadrilateral adbc is convex. Furthermore, this transformation is */ -/* valid only if there is not a subsegment between the triangles abc and */ -/* bad. This routine does not check either of these preconditions, and */ -/* it is the responsibility of the calling routine to ensure that they are */ -/* met. If they are not, the streets shall be filled with wailing and */ -/* gnashing of teeth. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void unflip(struct mesh *m, struct behavior *b, struct otri *flipedge) -#else /* not ANSI_DECLARATORS */ -void unflip(m, b, flipedge) -struct mesh *m; -struct behavior *b; -struct otri *flipedge; /* Handle for the triangle abc. */ -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri botleft, botright; - struct otri topleft, topright; - struct otri top; - struct otri botlcasing, botrcasing; - struct otri toplcasing, toprcasing; - struct osub botlsubseg, botrsubseg; - struct osub toplsubseg, toprsubseg; - vertex leftvertex, rightvertex, botvertex; - vertex farvertex; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - /* Identify the vertices of the quadrilateral. */ - org(*flipedge, rightvertex); - dest(*flipedge, leftvertex); - apex(*flipedge, botvertex); - sym(*flipedge, top); -#ifdef SELF_CHECK - if (top.tri == m->dummytri) { - printf("Internal error in unflip(): Attempt to flip on boundary.\n"); - lnextself(*flipedge); - return; - } - if (m->checksegments) { - tspivot(*flipedge, toplsubseg); - if (toplsubseg.ss != m->dummysub) { - printf("Internal error in unflip(): Attempt to flip a subsegment.\n"); - lnextself(*flipedge); - return; - } - } -#endif /* SELF_CHECK */ - apex(top, farvertex); - - /* Identify the casing of the quadrilateral. */ - lprev(top, topleft); - sym(topleft, toplcasing); - lnext(top, topright); - sym(topright, toprcasing); - lnext(*flipedge, botleft); - sym(botleft, botlcasing); - lprev(*flipedge, botright); - sym(botright, botrcasing); - /* Rotate the quadrilateral one-quarter turn clockwise. */ - bond(topleft, toprcasing); - bond(botleft, toplcasing); - bond(botright, botlcasing); - bond(topright, botrcasing); - - if (m->checksegments) { - /* Check for subsegments and rebond them to the quadrilateral. */ - tspivot(topleft, toplsubseg); - tspivot(botleft, botlsubseg); - tspivot(botright, botrsubseg); - tspivot(topright, toprsubseg); - if (toplsubseg.ss == m->dummysub) { - tsdissolve(botleft); - } else { - tsbond(botleft, toplsubseg); - } - if (botlsubseg.ss == m->dummysub) { - tsdissolve(botright); - } else { - tsbond(botright, botlsubseg); - } - if (botrsubseg.ss == m->dummysub) { - tsdissolve(topright); - } else { - tsbond(topright, botrsubseg); - } - if (toprsubseg.ss == m->dummysub) { - tsdissolve(topleft); - } else { - tsbond(topleft, toprsubseg); - } - } - - /* New vertex assignments for the rotated quadrilateral. */ - setorg(*flipedge, botvertex); - setdest(*flipedge, farvertex); - setapex(*flipedge, leftvertex); - setorg(top, farvertex); - setdest(top, botvertex); - setapex(top, rightvertex); - if (b->verbose > 2) { - printf(" Edge unflip results in left "); - printtriangle(m, b, flipedge); - printf(" and right "); - printtriangle(m, b, &top); - } -} - -/*****************************************************************************/ -/* */ -/* insertvertex() Insert a vertex into a Delaunay triangulation, */ -/* performing flips as necessary to maintain the Delaunay */ -/* property. */ -/* */ -/* The point `insertvertex' is located. If `searchtri.tri' is not NULL, */ -/* the search for the containing triangle begins from `searchtri'. If */ -/* `searchtri.tri' is NULL, a full point location procedure is called. */ -/* If `insertvertex' is found inside a triangle, the triangle is split into */ -/* three; if `insertvertex' lies on an edge, the edge is split in two, */ -/* thereby splitting the two adjacent triangles into four. Edge flips are */ -/* used to restore the Delaunay property. If `insertvertex' lies on an */ -/* existing vertex, no action is taken, and the value DUPLICATEVERTEX is */ -/* returned. On return, `searchtri' is set to a handle whose origin is the */ -/* existing vertex. */ -/* */ -/* Normally, the parameter `splitseg' is set to NULL, implying that no */ -/* subsegment should be split. In this case, if `insertvertex' is found to */ -/* lie on a segment, no action is taken, and the value VIOLATINGVERTEX is */ -/* returned. On return, `searchtri' is set to a handle whose primary edge */ -/* is the violated subsegment. */ -/* */ -/* If the calling routine wishes to split a subsegment by inserting a */ -/* vertex in it, the parameter `splitseg' should be that subsegment. In */ -/* this case, `searchtri' MUST be the triangle handle reached by pivoting */ -/* from that subsegment; no point location is done. */ -/* */ -/* `segmentflaws' and `triflaws' are flags that indicate whether or not */ -/* there should be checks for the creation of encroached subsegments or bad */ -/* quality triangles. If a newly inserted vertex encroaches upon */ -/* subsegments, these subsegments are added to the list of subsegments to */ -/* be split if `segmentflaws' is set. If bad triangles are created, these */ -/* are added to the queue if `triflaws' is set. */ -/* */ -/* If a duplicate vertex or violated segment does not prevent the vertex */ -/* from being inserted, the return value will be ENCROACHINGVERTEX if the */ -/* vertex encroaches upon a subsegment (and checking is enabled), or */ -/* SUCCESSFULVERTEX otherwise. In either case, `searchtri' is set to a */ -/* handle whose origin is the newly inserted vertex. */ -/* */ -/* insertvertex() does not use flip() for reasons of speed; some */ -/* information can be reused from edge flip to edge flip, like the */ -/* locations of subsegments. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -enum insertvertexresult insertvertex(struct mesh *m, struct behavior *b, - vertex newvertex, struct otri *searchtri, - struct osub *splitseg, - int segmentflaws, int triflaws) -#else /* not ANSI_DECLARATORS */ -enum insertvertexresult insertvertex(m, b, newvertex, searchtri, splitseg, - segmentflaws, triflaws) -struct mesh *m; -struct behavior *b; -vertex newvertex; -struct otri *searchtri; -struct osub *splitseg; -int segmentflaws; -int triflaws; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri horiz; - struct otri top; - struct otri botleft, botright; - struct otri topleft, topright; - struct otri newbotleft, newbotright; - struct otri newtopright; - struct otri botlcasing, botrcasing; - struct otri toplcasing, toprcasing; - struct otri testtri; - struct osub botlsubseg, botrsubseg; - struct osub toplsubseg, toprsubseg; - struct osub brokensubseg; - struct osub checksubseg; - struct osub rightsubseg; - struct osub newsubseg; - struct badsubseg *encroached; - struct flipstacker *newflip; - vertex first; - vertex leftvertex, rightvertex, botvertex, topvertex, farvertex; - vertex segmentorg, segmentdest; - REAL attrib; - REAL area; - enum insertvertexresult success; - enum locateresult intersect; - int doflip; - int mirrorflag; - int enq; - int i; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by spivot() and tspivot(). */ - - if (b->verbose > 1) { - printf(" Inserting (%.12g, %.12g).\n", newvertex[0], newvertex[1]); - } - - if (splitseg == (struct osub *) NULL) { - /* Find the location of the vertex to be inserted. Check if a good */ - /* starting triangle has already been provided by the caller. */ - if (searchtri->tri == m->dummytri) { - /* Find a boundary triangle. */ - horiz.tri = m->dummytri; - horiz.orient = 0; - symself(horiz); - /* Search for a triangle containing `newvertex'. */ - intersect = locate(m, b, newvertex, &horiz); - } else { - /* Start searching from the triangle provided by the caller. */ - otricopy(*searchtri, horiz); - intersect = preciselocate(m, b, newvertex, &horiz, 1); - } - } else { - /* The calling routine provides the subsegment in which */ - /* the vertex is inserted. */ - otricopy(*searchtri, horiz); - intersect = ONEDGE; - } - - if (intersect == ONVERTEX) { - /* There's already a vertex there. Return in `searchtri' a triangle */ - /* whose origin is the existing vertex. */ - otricopy(horiz, *searchtri); - otricopy(horiz, m->recenttri); - return DUPLICATEVERTEX; - } - if ((intersect == ONEDGE) || (intersect == OUTSIDE)) { - /* The vertex falls on an edge or boundary. */ - if (m->checksegments && (splitseg == (struct osub *) NULL)) { - /* Check whether the vertex falls on a subsegment. */ - tspivot(horiz, brokensubseg); - if (brokensubseg.ss != m->dummysub) { - /* The vertex falls on a subsegment, and hence will not be inserted. */ - if (segmentflaws) { - enq = b->nobisect != 2; - if (enq && (b->nobisect == 1)) { - /* This subsegment may be split only if it is an */ - /* internal boundary. */ - sym(horiz, testtri); - enq = testtri.tri != m->dummytri; - } - if (enq) { - /* Add the subsegment to the list of encroached subsegments. */ - encroached = (struct badsubseg *) poolalloc(&m->badsubsegs); - encroached->encsubseg = sencode(brokensubseg); - sorg(brokensubseg, encroached->subsegorg); - sdest(brokensubseg, encroached->subsegdest); - if (b->verbose > 2) { - printf( - " Queueing encroached subsegment (%.12g, %.12g) (%.12g, %.12g).\n", - encroached->subsegorg[0], encroached->subsegorg[1], - encroached->subsegdest[0], encroached->subsegdest[1]); - } - } - } - /* Return a handle whose primary edge contains the vertex, */ - /* which has not been inserted. */ - otricopy(horiz, *searchtri); - otricopy(horiz, m->recenttri); - return VIOLATINGVERTEX; - } - } - - /* Insert the vertex on an edge, dividing one triangle into two (if */ - /* the edge lies on a boundary) or two triangles into four. */ - lprev(horiz, botright); - sym(botright, botrcasing); - sym(horiz, topright); - /* Is there a second triangle? (Or does this edge lie on a boundary?) */ - mirrorflag = topright.tri != m->dummytri; - if (mirrorflag) { - lnextself(topright); - sym(topright, toprcasing); - maketriangle(m, b, &newtopright); - } else { - /* Splitting a boundary edge increases the number of boundary edges. */ - m->hullsize++; - } - maketriangle(m, b, &newbotright); - - /* Set the vertices of changed and new triangles. */ - org(horiz, rightvertex); - dest(horiz, leftvertex); - apex(horiz, botvertex); - setorg(newbotright, botvertex); - setdest(newbotright, rightvertex); - setapex(newbotright, newvertex); - setorg(horiz, newvertex); - for (i = 0; i < m->eextras; i++) { - /* Set the element attributes of a new triangle. */ - setelemattribute(newbotright, i, elemattribute(botright, i)); - } - if (b->vararea) { - /* Set the area constraint of a new triangle. */ - setareabound(newbotright, areabound(botright)); - } - if (mirrorflag) { - dest(topright, topvertex); - setorg(newtopright, rightvertex); - setdest(newtopright, topvertex); - setapex(newtopright, newvertex); - setorg(topright, newvertex); - for (i = 0; i < m->eextras; i++) { - /* Set the element attributes of another new triangle. */ - setelemattribute(newtopright, i, elemattribute(topright, i)); - } - if (b->vararea) { - /* Set the area constraint of another new triangle. */ - setareabound(newtopright, areabound(topright)); - } - } - - /* There may be subsegments that need to be bonded */ - /* to the new triangle(s). */ - if (m->checksegments) { - tspivot(botright, botrsubseg); - if (botrsubseg.ss != m->dummysub) { - tsdissolve(botright); - tsbond(newbotright, botrsubseg); - } - if (mirrorflag) { - tspivot(topright, toprsubseg); - if (toprsubseg.ss != m->dummysub) { - tsdissolve(topright); - tsbond(newtopright, toprsubseg); - } - } - } - - /* Bond the new triangle(s) to the surrounding triangles. */ - bond(newbotright, botrcasing); - lprevself(newbotright); - bond(newbotright, botright); - lprevself(newbotright); - if (mirrorflag) { - bond(newtopright, toprcasing); - lnextself(newtopright); - bond(newtopright, topright); - lnextself(newtopright); - bond(newtopright, newbotright); - } - - if (splitseg != (struct osub *) NULL) { - /* Split the subsegment into two. */ - setsdest(*splitseg, newvertex); - segorg(*splitseg, segmentorg); - segdest(*splitseg, segmentdest); - ssymself(*splitseg); - spivot(*splitseg, rightsubseg); - insertsubseg(m, b, &newbotright, mark(*splitseg)); - tspivot(newbotright, newsubseg); - setsegorg(newsubseg, segmentorg); - setsegdest(newsubseg, segmentdest); - sbond(*splitseg, newsubseg); - ssymself(newsubseg); - sbond(newsubseg, rightsubseg); - ssymself(*splitseg); - /* Transfer the subsegment's boundary marker to the vertex */ - /* if required. */ - if (vertexmark(newvertex) == 0) { - setvertexmark(newvertex, mark(*splitseg)); - } - } - - if (m->checkquality) { - poolrestart(&m->flipstackers); - m->lastflip = (struct flipstacker *) poolalloc(&m->flipstackers); - m->lastflip->flippedtri = encode(horiz); - m->lastflip->prevflip = (struct flipstacker *) &insertvertex; - } - -#ifdef SELF_CHECK - if (counterclockwise(m, b, rightvertex, leftvertex, botvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf( - " Clockwise triangle prior to edge vertex insertion (bottom).\n"); - } - if (mirrorflag) { - if (counterclockwise(m, b, leftvertex, rightvertex, topvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle prior to edge vertex insertion (top).\n"); - } - if (counterclockwise(m, b, rightvertex, topvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf( - " Clockwise triangle after edge vertex insertion (top right).\n"); - } - if (counterclockwise(m, b, topvertex, leftvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf( - " Clockwise triangle after edge vertex insertion (top left).\n"); - } - } - if (counterclockwise(m, b, leftvertex, botvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf( - " Clockwise triangle after edge vertex insertion (bottom left).\n"); - } - if (counterclockwise(m, b, botvertex, rightvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf( - " Clockwise triangle after edge vertex insertion (bottom right).\n"); - } -#endif /* SELF_CHECK */ - if (b->verbose > 2) { - printf(" Updating bottom left "); - printtriangle(m, b, &botright); - if (mirrorflag) { - printf(" Updating top left "); - printtriangle(m, b, &topright); - printf(" Creating top right "); - printtriangle(m, b, &newtopright); - } - printf(" Creating bottom right "); - printtriangle(m, b, &newbotright); - } - - /* Position `horiz' on the first edge to check for */ - /* the Delaunay property. */ - lnextself(horiz); - } else { - /* Insert the vertex in a triangle, splitting it into three. */ - lnext(horiz, botleft); - lprev(horiz, botright); - sym(botleft, botlcasing); - sym(botright, botrcasing); - maketriangle(m, b, &newbotleft); - maketriangle(m, b, &newbotright); - - /* Set the vertices of changed and new triangles. */ - org(horiz, rightvertex); - dest(horiz, leftvertex); - apex(horiz, botvertex); - setorg(newbotleft, leftvertex); - setdest(newbotleft, botvertex); - setapex(newbotleft, newvertex); - setorg(newbotright, botvertex); - setdest(newbotright, rightvertex); - setapex(newbotright, newvertex); - setapex(horiz, newvertex); - for (i = 0; i < m->eextras; i++) { - /* Set the element attributes of the new triangles. */ - attrib = elemattribute(horiz, i); - setelemattribute(newbotleft, i, attrib); - setelemattribute(newbotright, i, attrib); - } - if (b->vararea) { - /* Set the area constraint of the new triangles. */ - area = areabound(horiz); - setareabound(newbotleft, area); - setareabound(newbotright, area); - } - - /* There may be subsegments that need to be bonded */ - /* to the new triangles. */ - if (m->checksegments) { - tspivot(botleft, botlsubseg); - if (botlsubseg.ss != m->dummysub) { - tsdissolve(botleft); - tsbond(newbotleft, botlsubseg); - } - tspivot(botright, botrsubseg); - if (botrsubseg.ss != m->dummysub) { - tsdissolve(botright); - tsbond(newbotright, botrsubseg); - } - } - - /* Bond the new triangles to the surrounding triangles. */ - bond(newbotleft, botlcasing); - bond(newbotright, botrcasing); - lnextself(newbotleft); - lprevself(newbotright); - bond(newbotleft, newbotright); - lnextself(newbotleft); - bond(botleft, newbotleft); - lprevself(newbotright); - bond(botright, newbotright); - - if (m->checkquality) { - poolrestart(&m->flipstackers); - m->lastflip = (struct flipstacker *) poolalloc(&m->flipstackers); - m->lastflip->flippedtri = encode(horiz); - m->lastflip->prevflip = (struct flipstacker *) NULL; - } - -#ifdef SELF_CHECK - if (counterclockwise(m, b, rightvertex, leftvertex, botvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle prior to vertex insertion.\n"); - } - if (counterclockwise(m, b, rightvertex, leftvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle after vertex insertion (top).\n"); - } - if (counterclockwise(m, b, leftvertex, botvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle after vertex insertion (left).\n"); - } - if (counterclockwise(m, b, botvertex, rightvertex, newvertex) < 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle after vertex insertion (right).\n"); - } -#endif /* SELF_CHECK */ - if (b->verbose > 2) { - printf(" Updating top "); - printtriangle(m, b, &horiz); - printf(" Creating left "); - printtriangle(m, b, &newbotleft); - printf(" Creating right "); - printtriangle(m, b, &newbotright); - } - } - - /* The insertion is successful by default, unless an encroached */ - /* subsegment is found. */ - success = SUCCESSFULVERTEX; - /* Circle around the newly inserted vertex, checking each edge opposite */ - /* it for the Delaunay property. Non-Delaunay edges are flipped. */ - /* `horiz' is always the edge being checked. `first' marks where to */ - /* stop circling. */ - org(horiz, first); - rightvertex = first; - dest(horiz, leftvertex); - /* Circle until finished. */ - while (1) { - /* By default, the edge will be flipped. */ - doflip = 1; - - if (m->checksegments) { - /* Check for a subsegment, which cannot be flipped. */ - tspivot(horiz, checksubseg); - if (checksubseg.ss != m->dummysub) { - /* The edge is a subsegment and cannot be flipped. */ - doflip = 0; -#ifndef CDT_ONLY - if (segmentflaws) { - /* Does the new vertex encroach upon this subsegment? */ - if (checkseg4encroach(m, b, &checksubseg)) { - success = ENCROACHINGVERTEX; - } - } -#endif /* not CDT_ONLY */ - } - } - - if (doflip) { - /* Check if the edge is a boundary edge. */ - sym(horiz, top); - if (top.tri == m->dummytri) { - /* The edge is a boundary edge and cannot be flipped. */ - doflip = 0; - } else { - /* Find the vertex on the other side of the edge. */ - apex(top, farvertex); - /* In the incremental Delaunay triangulation algorithm, any of */ - /* `leftvertex', `rightvertex', and `farvertex' could be vertices */ - /* of the triangular bounding box. These vertices must be */ - /* treated as if they are infinitely distant, even though their */ - /* "coordinates" are not. */ - if ((leftvertex == m->infvertex1) || (leftvertex == m->infvertex2) || - (leftvertex == m->infvertex3)) { - /* `leftvertex' is infinitely distant. Check the convexity of */ - /* the boundary of the triangulation. 'farvertex' might be */ - /* infinite as well, but trust me, this same condition should */ - /* be applied. */ - doflip = counterclockwise(m, b, newvertex, rightvertex, farvertex) - > 0.0; - } else if ((rightvertex == m->infvertex1) || - (rightvertex == m->infvertex2) || - (rightvertex == m->infvertex3)) { - /* `rightvertex' is infinitely distant. Check the convexity of */ - /* the boundary of the triangulation. 'farvertex' might be */ - /* infinite as well, but trust me, this same condition should */ - /* be applied. */ - doflip = counterclockwise(m, b, farvertex, leftvertex, newvertex) - > 0.0; - } else if ((farvertex == m->infvertex1) || - (farvertex == m->infvertex2) || - (farvertex == m->infvertex3)) { - /* `farvertex' is infinitely distant and cannot be inside */ - /* the circumcircle of the triangle `horiz'. */ - doflip = 0; - } else { - /* Test whether the edge is locally Delaunay. */ - doflip = incircle(m, b, leftvertex, newvertex, rightvertex, - farvertex) > 0.0; - } - if (doflip) { - /* We made it! Flip the edge `horiz' by rotating its containing */ - /* quadrilateral (the two triangles adjacent to `horiz'). */ - /* Identify the casing of the quadrilateral. */ - lprev(top, topleft); - sym(topleft, toplcasing); - lnext(top, topright); - sym(topright, toprcasing); - lnext(horiz, botleft); - sym(botleft, botlcasing); - lprev(horiz, botright); - sym(botright, botrcasing); - /* Rotate the quadrilateral one-quarter turn counterclockwise. */ - bond(topleft, botlcasing); - bond(botleft, botrcasing); - bond(botright, toprcasing); - bond(topright, toplcasing); - if (m->checksegments) { - /* Check for subsegments and rebond them to the quadrilateral. */ - tspivot(topleft, toplsubseg); - tspivot(botleft, botlsubseg); - tspivot(botright, botrsubseg); - tspivot(topright, toprsubseg); - if (toplsubseg.ss == m->dummysub) { - tsdissolve(topright); - } else { - tsbond(topright, toplsubseg); - } - if (botlsubseg.ss == m->dummysub) { - tsdissolve(topleft); - } else { - tsbond(topleft, botlsubseg); - } - if (botrsubseg.ss == m->dummysub) { - tsdissolve(botleft); - } else { - tsbond(botleft, botrsubseg); - } - if (toprsubseg.ss == m->dummysub) { - tsdissolve(botright); - } else { - tsbond(botright, toprsubseg); - } - } - /* New vertex assignments for the rotated quadrilateral. */ - setorg(horiz, farvertex); - setdest(horiz, newvertex); - setapex(horiz, rightvertex); - setorg(top, newvertex); - setdest(top, farvertex); - setapex(top, leftvertex); - for (i = 0; i < m->eextras; i++) { - /* Take the average of the two triangles' attributes. */ - attrib = 0.5 * (elemattribute(top, i) + elemattribute(horiz, i)); - setelemattribute(top, i, attrib); - setelemattribute(horiz, i, attrib); - } - if (b->vararea) { - if ((areabound(top) <= 0.0) || (areabound(horiz) <= 0.0)) { - area = -1.0; - } else { - /* Take the average of the two triangles' area constraints. */ - /* This prevents small area constraints from migrating a */ - /* long, long way from their original location due to flips. */ - area = 0.5 * (areabound(top) + areabound(horiz)); - } - setareabound(top, area); - setareabound(horiz, area); - } - - if (m->checkquality) { - newflip = (struct flipstacker *) poolalloc(&m->flipstackers); - newflip->flippedtri = encode(horiz); - newflip->prevflip = m->lastflip; - m->lastflip = newflip; - } - -#ifdef SELF_CHECK - if (newvertex != (vertex) NULL) { - if (counterclockwise(m, b, leftvertex, newvertex, rightvertex) < - 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle prior to edge flip (bottom).\n"); - } - /* The following test has been removed because constrainededge() */ - /* sometimes generates inverted triangles that insertvertex() */ - /* removes. */ -/* - if (counterclockwise(m, b, rightvertex, farvertex, leftvertex) < - 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle prior to edge flip (top).\n"); - } -*/ - if (counterclockwise(m, b, farvertex, leftvertex, newvertex) < - 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle after edge flip (left).\n"); - } - if (counterclockwise(m, b, newvertex, rightvertex, farvertex) < - 0.0) { - printf("Internal error in insertvertex():\n"); - printf(" Clockwise triangle after edge flip (right).\n"); - } - } -#endif /* SELF_CHECK */ - if (b->verbose > 2) { - printf(" Edge flip results in left "); - lnextself(topleft); - printtriangle(m, b, &topleft); - printf(" and right "); - printtriangle(m, b, &horiz); - } - /* On the next iterations, consider the two edges that were */ - /* exposed (this is, are now visible to the newly inserted */ - /* vertex) by the edge flip. */ - lprevself(horiz); - leftvertex = farvertex; - } - } - } - if (!doflip) { - /* The handle `horiz' is accepted as locally Delaunay. */ -#ifndef CDT_ONLY - if (triflaws) { - /* Check the triangle `horiz' for quality. */ - testtriangle(m, b, &horiz); - } -#endif /* not CDT_ONLY */ - /* Look for the next edge around the newly inserted vertex. */ - lnextself(horiz); - sym(horiz, testtri); - /* Check for finishing a complete revolution about the new vertex, or */ - /* falling outside of the triangulation. The latter will happen */ - /* when a vertex is inserted at a boundary. */ - if ((leftvertex == first) || (testtri.tri == m->dummytri)) { - /* We're done. Return a triangle whose origin is the new vertex. */ - lnext(horiz, *searchtri); - lnext(horiz, m->recenttri); - return success; - } - /* Finish finding the next edge around the newly inserted vertex. */ - lnext(testtri, horiz); - rightvertex = leftvertex; - dest(horiz, leftvertex); - } - } -} - -/*****************************************************************************/ -/* */ -/* triangulatepolygon() Find the Delaunay triangulation of a polygon that */ -/* has a certain "nice" shape. This includes the */ -/* polygons that result from deletion of a vertex or */ -/* insertion of a segment. */ -/* */ -/* This is a conceptually difficult routine. The starting assumption is */ -/* that we have a polygon with n sides. n - 1 of these sides are currently */ -/* represented as edges in the mesh. One side, called the "base", need not */ -/* be. */ -/* */ -/* Inside the polygon is a structure I call a "fan", consisting of n - 1 */ -/* triangles that share a common origin. For each of these triangles, the */ -/* edge opposite the origin is one of the sides of the polygon. The */ -/* primary edge of each triangle is the edge directed from the origin to */ -/* the destination; note that this is not the same edge that is a side of */ -/* the polygon. `firstedge' is the primary edge of the first triangle. */ -/* From there, the triangles follow in counterclockwise order about the */ -/* polygon, until `lastedge', the primary edge of the last triangle. */ -/* `firstedge' and `lastedge' are probably connected to other triangles */ -/* beyond the extremes of the fan, but their identity is not important, as */ -/* long as the fan remains connected to them. */ -/* */ -/* Imagine the polygon oriented so that its base is at the bottom. This */ -/* puts `firstedge' on the far right, and `lastedge' on the far left. */ -/* The right vertex of the base is the destination of `firstedge', and the */ -/* left vertex of the base is the apex of `lastedge'. */ -/* */ -/* The challenge now is to find the right sequence of edge flips to */ -/* transform the fan into a Delaunay triangulation of the polygon. Each */ -/* edge flip effectively removes one triangle from the fan, committing it */ -/* to the polygon. The resulting polygon has one fewer edge. If `doflip' */ -/* is set, the final flip will be performed, resulting in a fan of one */ -/* (useless?) triangle. If `doflip' is not set, the final flip is not */ -/* performed, resulting in a fan of two triangles, and an unfinished */ -/* triangular polygon that is not yet filled out with a single triangle. */ -/* On completion of the routine, `lastedge' is the last remaining triangle, */ -/* or the leftmost of the last two. */ -/* */ -/* Although the flips are performed in the order described above, the */ -/* decisions about what flips to perform are made in precisely the reverse */ -/* order. The recursive triangulatepolygon() procedure makes a decision, */ -/* uses up to two recursive calls to triangulate the "subproblems" */ -/* (polygons with fewer edges), and then performs an edge flip. */ -/* */ -/* The "decision" it makes is which vertex of the polygon should be */ -/* connected to the base. This decision is made by testing every possible */ -/* vertex. Once the best vertex is found, the two edges that connect this */ -/* vertex to the base become the bases for two smaller polygons. These */ -/* are triangulated recursively. Unfortunately, this approach can take */ -/* O(n^2) time not only in the worst case, but in many common cases. It's */ -/* rarely a big deal for vertex deletion, where n is rarely larger than */ -/* ten, but it could be a big deal for segment insertion, especially if */ -/* there's a lot of long segments that each cut many triangles. I ought to */ -/* code a faster algorithm some day. */ -/* */ -/* The `edgecount' parameter is the number of sides of the polygon, */ -/* including its base. `triflaws' is a flag that determines whether the */ -/* new triangles should be tested for quality, and enqueued if they are */ -/* bad. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void triangulatepolygon(struct mesh *m, struct behavior *b, - struct otri *firstedge, struct otri *lastedge, - int edgecount, int doflip, int triflaws) -#else /* not ANSI_DECLARATORS */ -void triangulatepolygon(m, b, firstedge, lastedge, edgecount, doflip, triflaws) -struct mesh *m; -struct behavior *b; -struct otri *firstedge; -struct otri *lastedge; -int edgecount; -int doflip; -int triflaws; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri testtri; - struct otri besttri; - struct otri tempedge; - vertex leftbasevertex, rightbasevertex; - vertex testvertex; - vertex bestvertex; - int bestnumber; - int i; - triangle ptr; /* Temporary variable used by sym(), onext(), and oprev(). */ - - /* Identify the base vertices. */ - apex(*lastedge, leftbasevertex); - dest(*firstedge, rightbasevertex); - if (b->verbose > 2) { - printf(" Triangulating interior polygon at edge\n"); - printf(" (%.12g, %.12g) (%.12g, %.12g)\n", leftbasevertex[0], - leftbasevertex[1], rightbasevertex[0], rightbasevertex[1]); - } - /* Find the best vertex to connect the base to. */ - onext(*firstedge, besttri); - dest(besttri, bestvertex); - otricopy(besttri, testtri); - bestnumber = 1; - for (i = 2; i <= edgecount - 2; i++) { - onextself(testtri); - dest(testtri, testvertex); - /* Is this a better vertex? */ - if (incircle(m, b, leftbasevertex, rightbasevertex, bestvertex, - testvertex) > 0.0) { - otricopy(testtri, besttri); - bestvertex = testvertex; - bestnumber = i; - } - } - if (b->verbose > 2) { - printf(" Connecting edge to (%.12g, %.12g)\n", bestvertex[0], - bestvertex[1]); - } - if (bestnumber > 1) { - /* Recursively triangulate the smaller polygon on the right. */ - oprev(besttri, tempedge); - triangulatepolygon(m, b, firstedge, &tempedge, bestnumber + 1, 1, - triflaws); - } - if (bestnumber < edgecount - 2) { - /* Recursively triangulate the smaller polygon on the left. */ - sym(besttri, tempedge); - triangulatepolygon(m, b, &besttri, lastedge, edgecount - bestnumber, 1, - triflaws); - /* Find `besttri' again; it may have been lost to edge flips. */ - sym(tempedge, besttri); - } - if (doflip) { - /* Do one final edge flip. */ - flip(m, b, &besttri); -#ifndef CDT_ONLY - if (triflaws) { - /* Check the quality of the newly committed triangle. */ - sym(besttri, testtri); - testtriangle(m, b, &testtri); - } -#endif /* not CDT_ONLY */ - } - /* Return the base triangle. */ - otricopy(besttri, *lastedge); -} - -/*****************************************************************************/ -/* */ -/* deletevertex() Delete a vertex from a Delaunay triangulation, ensuring */ -/* that the triangulation remains Delaunay. */ -/* */ -/* The origin of `deltri' is deleted. The union of the triangles adjacent */ -/* to this vertex is a polygon, for which the Delaunay triangulation is */ -/* found. Two triangles are removed from the mesh. */ -/* */ -/* Only interior vertices that do not lie on segments or boundaries may be */ -/* deleted. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void deletevertex(struct mesh *m, struct behavior *b, struct otri *deltri) -#else /* not ANSI_DECLARATORS */ -void deletevertex(m, b, deltri) -struct mesh *m; -struct behavior *b; -struct otri *deltri; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri countingtri; - struct otri firstedge, lastedge; - struct otri deltriright; - struct otri lefttri, righttri; - struct otri leftcasing, rightcasing; - struct osub leftsubseg, rightsubseg; - vertex delvertex; - vertex neworg; - int edgecount; - triangle ptr; /* Temporary variable used by sym(), onext(), and oprev(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - org(*deltri, delvertex); - if (b->verbose > 1) { - printf(" Deleting (%.12g, %.12g).\n", delvertex[0], delvertex[1]); - } - vertexdealloc(m, delvertex); - - /* Count the degree of the vertex being deleted. */ - onext(*deltri, countingtri); - edgecount = 1; - while (!otriequal(*deltri, countingtri)) { -#ifdef SELF_CHECK - if (countingtri.tri == m->dummytri) { - printf("Internal error in deletevertex():\n"); - printf(" Attempt to delete boundary vertex.\n"); - internalerror(); - } -#endif /* SELF_CHECK */ - edgecount++; - onextself(countingtri); - } - -#ifdef SELF_CHECK - if (edgecount < 3) { - printf("Internal error in deletevertex():\n Vertex has degree %d.\n", - edgecount); - internalerror(); - } -#endif /* SELF_CHECK */ - if (edgecount > 3) { - /* Triangulate the polygon defined by the union of all triangles */ - /* adjacent to the vertex being deleted. Check the quality of */ - /* the resulting triangles. */ - onext(*deltri, firstedge); - oprev(*deltri, lastedge); - triangulatepolygon(m, b, &firstedge, &lastedge, edgecount, 0, - !b->nobisect); - } - /* Splice out two triangles. */ - lprev(*deltri, deltriright); - dnext(*deltri, lefttri); - sym(lefttri, leftcasing); - oprev(deltriright, righttri); - sym(righttri, rightcasing); - bond(*deltri, leftcasing); - bond(deltriright, rightcasing); - tspivot(lefttri, leftsubseg); - if (leftsubseg.ss != m->dummysub) { - tsbond(*deltri, leftsubseg); - } - tspivot(righttri, rightsubseg); - if (rightsubseg.ss != m->dummysub) { - tsbond(deltriright, rightsubseg); - } - - /* Set the new origin of `deltri' and check its quality. */ - org(lefttri, neworg); - setorg(*deltri, neworg); - if (!b->nobisect) { - testtriangle(m, b, deltri); - } - - /* Delete the two spliced-out triangles. */ - triangledealloc(m, lefttri.tri); - triangledealloc(m, righttri.tri); -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* undovertex() Undo the most recent vertex insertion. */ -/* */ -/* Walks through the list of transformations (flips and a vertex insertion) */ -/* in the reverse of the order in which they were done, and undoes them. */ -/* The inserted vertex is removed from the triangulation and deallocated. */ -/* Two triangles (possibly just one) are also deallocated. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void undovertex(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void undovertex(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri fliptri; - struct otri botleft, botright, topright; - struct otri botlcasing, botrcasing, toprcasing; - struct otri gluetri; - struct osub botlsubseg, botrsubseg, toprsubseg; - vertex botvertex, rightvertex; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - /* Walk through the list of transformations (flips and a vertex insertion) */ - /* in the reverse of the order in which they were done, and undo them. */ - while (m->lastflip != (struct flipstacker *) NULL) { - /* Find a triangle involved in the last unreversed transformation. */ - decode(m->lastflip->flippedtri, fliptri); - - /* We are reversing one of three transformations: a trisection of one */ - /* triangle into three (by inserting a vertex in the triangle), a */ - /* bisection of two triangles into four (by inserting a vertex in an */ - /* edge), or an edge flip. */ - if (m->lastflip->prevflip == (struct flipstacker *) NULL) { - /* Restore a triangle that was split into three triangles, */ - /* so it is again one triangle. */ - dprev(fliptri, botleft); - lnextself(botleft); - onext(fliptri, botright); - lprevself(botright); - sym(botleft, botlcasing); - sym(botright, botrcasing); - dest(botleft, botvertex); - - setapex(fliptri, botvertex); - lnextself(fliptri); - bond(fliptri, botlcasing); - tspivot(botleft, botlsubseg); - tsbond(fliptri, botlsubseg); - lnextself(fliptri); - bond(fliptri, botrcasing); - tspivot(botright, botrsubseg); - tsbond(fliptri, botrsubseg); - - /* Delete the two spliced-out triangles. */ - triangledealloc(m, botleft.tri); - triangledealloc(m, botright.tri); - } else if (m->lastflip->prevflip == (struct flipstacker *) &insertvertex) { - /* Restore two triangles that were split into four triangles, */ - /* so they are again two triangles. */ - lprev(fliptri, gluetri); - sym(gluetri, botright); - lnextself(botright); - sym(botright, botrcasing); - dest(botright, rightvertex); - - setorg(fliptri, rightvertex); - bond(gluetri, botrcasing); - tspivot(botright, botrsubseg); - tsbond(gluetri, botrsubseg); - - /* Delete the spliced-out triangle. */ - triangledealloc(m, botright.tri); - - sym(fliptri, gluetri); - if (gluetri.tri != m->dummytri) { - lnextself(gluetri); - dnext(gluetri, topright); - sym(topright, toprcasing); - - setorg(gluetri, rightvertex); - bond(gluetri, toprcasing); - tspivot(topright, toprsubseg); - tsbond(gluetri, toprsubseg); - - /* Delete the spliced-out triangle. */ - triangledealloc(m, topright.tri); - } - - /* This is the end of the list, sneakily encoded. */ - m->lastflip->prevflip = (struct flipstacker *) NULL; - } else { - /* Undo an edge flip. */ - unflip(m, b, &fliptri); - } - - /* Go on and process the next transformation. */ - m->lastflip = m->lastflip->prevflip; - } -} - -#endif /* not CDT_ONLY */ - -/** **/ -/** **/ -/********* Mesh transformation routines end here *********/ - -/********* Divide-and-conquer Delaunay triangulation begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* The divide-and-conquer bounding box */ -/* */ -/* I originally implemented the divide-and-conquer and incremental Delaunay */ -/* triangulations using the edge-based data structure presented by Guibas */ -/* and Stolfi. Switching to a triangle-based data structure doubled the */ -/* speed. However, I had to think of a few extra tricks to maintain the */ -/* elegance of the original algorithms. */ -/* */ -/* The "bounding box" used by my variant of the divide-and-conquer */ -/* algorithm uses one triangle for each edge of the convex hull of the */ -/* triangulation. These bounding triangles all share a common apical */ -/* vertex, which is represented by NULL and which represents nothing. */ -/* The bounding triangles are linked in a circular fan about this NULL */ -/* vertex, and the edges on the convex hull of the triangulation appear */ -/* opposite the NULL vertex. You might find it easiest to imagine that */ -/* the NULL vertex is a point in 3D space behind the center of the */ -/* triangulation, and that the bounding triangles form a sort of cone. */ -/* */ -/* This bounding box makes it easy to represent degenerate cases. For */ -/* instance, the triangulation of two vertices is a single edge. This edge */ -/* is represented by two bounding box triangles, one on each "side" of the */ -/* edge. These triangles are also linked together in a fan about the NULL */ -/* vertex. */ -/* */ -/* The bounding box also makes it easy to traverse the convex hull, as the */ -/* divide-and-conquer algorithm needs to do. */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* vertexsort() Sort an array of vertices by x-coordinate, using the */ -/* y-coordinate as a secondary key. */ -/* */ -/* Uses quicksort. Randomized O(n log n) time. No, I did not make any of */ -/* the usual quicksort mistakes. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void vertexsort(vertex *sortarray, int arraysize) -#else /* not ANSI_DECLARATORS */ -void vertexsort(sortarray, arraysize) -vertex *sortarray; -int arraysize; -#endif /* not ANSI_DECLARATORS */ - -{ - int left, right; - int pivot; - REAL pivotx, pivoty; - vertex temp; - - if (arraysize == 2) { - /* Recursive base case. */ - if ((sortarray[0][0] > sortarray[1][0]) || - ((sortarray[0][0] == sortarray[1][0]) && - (sortarray[0][1] > sortarray[1][1]))) { - temp = sortarray[1]; - sortarray[1] = sortarray[0]; - sortarray[0] = temp; - } - return; - } - /* Choose a random pivot to split the array. */ - pivot = (int) randomnation((unsigned int) arraysize); - pivotx = sortarray[pivot][0]; - pivoty = sortarray[pivot][1]; - /* Split the array. */ - left = -1; - right = arraysize; - while (left < right) { - /* Search for a vertex whose x-coordinate is too large for the left. */ - do { - left++; - } while ((left <= right) && ((sortarray[left][0] < pivotx) || - ((sortarray[left][0] == pivotx) && - (sortarray[left][1] < pivoty)))); - /* Search for a vertex whose x-coordinate is too small for the right. */ - do { - right--; - } while ((left <= right) && ((sortarray[right][0] > pivotx) || - ((sortarray[right][0] == pivotx) && - (sortarray[right][1] > pivoty)))); - if (left < right) { - /* Swap the left and right vertices. */ - temp = sortarray[left]; - sortarray[left] = sortarray[right]; - sortarray[right] = temp; - } - } - if (left > 1) { - /* Recursively sort the left subset. */ - vertexsort(sortarray, left); - } - if (right < arraysize - 2) { - /* Recursively sort the right subset. */ - vertexsort(&sortarray[right + 1], arraysize - right - 1); - } -} - -/*****************************************************************************/ -/* */ -/* vertexmedian() An order statistic algorithm, almost. Shuffles an */ -/* array of vertices so that the first `median' vertices */ -/* occur lexicographically before the remaining vertices. */ -/* */ -/* Uses the x-coordinate as the primary key if axis == 0; the y-coordinate */ -/* if axis == 1. Very similar to the vertexsort() procedure, but runs in */ -/* randomized linear time. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void vertexmedian(vertex *sortarray, int arraysize, int median, int axis) -#else /* not ANSI_DECLARATORS */ -void vertexmedian(sortarray, arraysize, median, axis) -vertex *sortarray; -int arraysize; -int median; -int axis; -#endif /* not ANSI_DECLARATORS */ - -{ - int left, right; - int pivot; - REAL pivot1, pivot2; - vertex temp; - - if (arraysize == 2) { - /* Recursive base case. */ - if ((sortarray[0][axis] > sortarray[1][axis]) || - ((sortarray[0][axis] == sortarray[1][axis]) && - (sortarray[0][1 - axis] > sortarray[1][1 - axis]))) { - temp = sortarray[1]; - sortarray[1] = sortarray[0]; - sortarray[0] = temp; - } - return; - } - /* Choose a random pivot to split the array. */ - pivot = (int) randomnation((unsigned int) arraysize); - pivot1 = sortarray[pivot][axis]; - pivot2 = sortarray[pivot][1 - axis]; - /* Split the array. */ - left = -1; - right = arraysize; - while (left < right) { - /* Search for a vertex whose x-coordinate is too large for the left. */ - do { - left++; - } while ((left <= right) && ((sortarray[left][axis] < pivot1) || - ((sortarray[left][axis] == pivot1) && - (sortarray[left][1 - axis] < pivot2)))); - /* Search for a vertex whose x-coordinate is too small for the right. */ - do { - right--; - } while ((left <= right) && ((sortarray[right][axis] > pivot1) || - ((sortarray[right][axis] == pivot1) && - (sortarray[right][1 - axis] > pivot2)))); - if (left < right) { - /* Swap the left and right vertices. */ - temp = sortarray[left]; - sortarray[left] = sortarray[right]; - sortarray[right] = temp; - } - } - /* Unlike in vertexsort(), at most one of the following */ - /* conditionals is true. */ - if (left > median) { - /* Recursively shuffle the left subset. */ - vertexmedian(sortarray, left, median, axis); - } - if (right < median - 1) { - /* Recursively shuffle the right subset. */ - vertexmedian(&sortarray[right + 1], arraysize - right - 1, - median - right - 1, axis); - } -} - -/*****************************************************************************/ -/* */ -/* alternateaxes() Sorts the vertices as appropriate for the divide-and- */ -/* conquer algorithm with alternating cuts. */ -/* */ -/* Partitions by x-coordinate if axis == 0; by y-coordinate if axis == 1. */ -/* For the base case, subsets containing only two or three vertices are */ -/* always sorted by x-coordinate. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void alternateaxes(vertex *sortarray, int arraysize, int axis) -#else /* not ANSI_DECLARATORS */ -void alternateaxes(sortarray, arraysize, axis) -vertex *sortarray; -int arraysize; -int axis; -#endif /* not ANSI_DECLARATORS */ - -{ - int divider; - - divider = arraysize >> 1; - if (arraysize <= 3) { - /* Recursive base case: subsets of two or three vertices will be */ - /* handled specially, and should always be sorted by x-coordinate. */ - axis = 0; - } - /* Partition with a horizontal or vertical cut. */ - vertexmedian(sortarray, arraysize, divider, axis); - /* Recursively partition the subsets with a cross cut. */ - if (arraysize - divider >= 2) { - if (divider >= 2) { - alternateaxes(sortarray, divider, 1 - axis); - } - alternateaxes(&sortarray[divider], arraysize - divider, 1 - axis); - } -} - -/*****************************************************************************/ -/* */ -/* mergehulls() Merge two adjacent Delaunay triangulations into a */ -/* single Delaunay triangulation. */ -/* */ -/* This is similar to the algorithm given by Guibas and Stolfi, but uses */ -/* a triangle-based, rather than edge-based, data structure. */ -/* */ -/* The algorithm walks up the gap between the two triangulations, knitting */ -/* them together. As they are merged, some of their bounding triangles */ -/* are converted into real triangles of the triangulation. The procedure */ -/* pulls each hull's bounding triangles apart, then knits them together */ -/* like the teeth of two gears. The Delaunay property determines, at each */ -/* step, whether the next "tooth" is a bounding triangle of the left hull */ -/* or the right. When a bounding triangle becomes real, its apex is */ -/* changed from NULL to a real vertex. */ -/* */ -/* Only two new triangles need to be allocated. These become new bounding */ -/* triangles at the top and bottom of the seam. They are used to connect */ -/* the remaining bounding triangles (those that have not been converted */ -/* into real triangles) into a single fan. */ -/* */ -/* On entry, `farleft' and `innerleft' are bounding triangles of the left */ -/* triangulation. The origin of `farleft' is the leftmost vertex, and */ -/* the destination of `innerleft' is the rightmost vertex of the */ -/* triangulation. Similarly, `innerright' and `farright' are bounding */ -/* triangles of the right triangulation. The origin of `innerright' and */ -/* destination of `farright' are the leftmost and rightmost vertices. */ -/* */ -/* On completion, the origin of `farleft' is the leftmost vertex of the */ -/* merged triangulation, and the destination of `farright' is the rightmost */ -/* vertex. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void mergehulls(struct mesh *m, struct behavior *b, struct otri *farleft, - struct otri *innerleft, struct otri *innerright, - struct otri *farright, int axis) -#else /* not ANSI_DECLARATORS */ -void mergehulls(m, b, farleft, innerleft, innerright, farright, axis) -struct mesh *m; -struct behavior *b; -struct otri *farleft; -struct otri *innerleft; -struct otri *innerright; -struct otri *farright; -int axis; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri leftcand, rightcand; - struct otri baseedge; - struct otri nextedge; - struct otri sidecasing, topcasing, outercasing; - struct otri checkedge; - vertex innerleftdest; - vertex innerrightorg; - vertex innerleftapex, innerrightapex; - vertex farleftpt, farrightpt; - vertex farleftapex, farrightapex; - vertex lowerleft, lowerright; - vertex upperleft, upperright; - vertex nextapex; - vertex checkvertex; - int changemade; - int badedge; - int leftfinished, rightfinished; - triangle ptr; /* Temporary variable used by sym(). */ - - dest(*innerleft, innerleftdest); - apex(*innerleft, innerleftapex); - org(*innerright, innerrightorg); - apex(*innerright, innerrightapex); - /* Special treatment for horizontal cuts. */ - if (b->dwyer && (axis == 1)) { - org(*farleft, farleftpt); - apex(*farleft, farleftapex); - dest(*farright, farrightpt); - apex(*farright, farrightapex); - /* The pointers to the extremal vertices are shifted to point to the */ - /* topmost and bottommost vertex of each hull, rather than the */ - /* leftmost and rightmost vertices. */ - while (farleftapex[1] < farleftpt[1]) { - lnextself(*farleft); - symself(*farleft); - farleftpt = farleftapex; - apex(*farleft, farleftapex); - } - sym(*innerleft, checkedge); - apex(checkedge, checkvertex); - while (checkvertex[1] > innerleftdest[1]) { - lnext(checkedge, *innerleft); - innerleftapex = innerleftdest; - innerleftdest = checkvertex; - sym(*innerleft, checkedge); - apex(checkedge, checkvertex); - } - while (innerrightapex[1] < innerrightorg[1]) { - lnextself(*innerright); - symself(*innerright); - innerrightorg = innerrightapex; - apex(*innerright, innerrightapex); - } - sym(*farright, checkedge); - apex(checkedge, checkvertex); - while (checkvertex[1] > farrightpt[1]) { - lnext(checkedge, *farright); - farrightapex = farrightpt; - farrightpt = checkvertex; - sym(*farright, checkedge); - apex(checkedge, checkvertex); - } - } - /* Find a line tangent to and below both hulls. */ - do { - changemade = 0; - /* Make innerleftdest the "bottommost" vertex of the left hull. */ - if (counterclockwise(m, b, innerleftdest, innerleftapex, innerrightorg) > - 0.0) { - lprevself(*innerleft); - symself(*innerleft); - innerleftdest = innerleftapex; - apex(*innerleft, innerleftapex); - changemade = 1; - } - /* Make innerrightorg the "bottommost" vertex of the right hull. */ - if (counterclockwise(m, b, innerrightapex, innerrightorg, innerleftdest) > - 0.0) { - lnextself(*innerright); - symself(*innerright); - innerrightorg = innerrightapex; - apex(*innerright, innerrightapex); - changemade = 1; - } - } while (changemade); - /* Find the two candidates to be the next "gear tooth." */ - sym(*innerleft, leftcand); - sym(*innerright, rightcand); - /* Create the bottom new bounding triangle. */ - maketriangle(m, b, &baseedge); - /* Connect it to the bounding boxes of the left and right triangulations. */ - bond(baseedge, *innerleft); - lnextself(baseedge); - bond(baseedge, *innerright); - lnextself(baseedge); - setorg(baseedge, innerrightorg); - setdest(baseedge, innerleftdest); - /* Apex is intentionally left NULL. */ - if (b->verbose > 2) { - printf(" Creating base bounding "); - printtriangle(m, b, &baseedge); - } - /* Fix the extreme triangles if necessary. */ - org(*farleft, farleftpt); - if (innerleftdest == farleftpt) { - lnext(baseedge, *farleft); - } - dest(*farright, farrightpt); - if (innerrightorg == farrightpt) { - lprev(baseedge, *farright); - } - /* The vertices of the current knitting edge. */ - lowerleft = innerleftdest; - lowerright = innerrightorg; - /* The candidate vertices for knitting. */ - apex(leftcand, upperleft); - apex(rightcand, upperright); - /* Walk up the gap between the two triangulations, knitting them together. */ - while (1) { - /* Have we reached the top? (This isn't quite the right question, */ - /* because even though the left triangulation might seem finished now, */ - /* moving up on the right triangulation might reveal a new vertex of */ - /* the left triangulation. And vice-versa.) */ - leftfinished = counterclockwise(m, b, upperleft, lowerleft, lowerright) <= - 0.0; - rightfinished = counterclockwise(m, b, upperright, lowerleft, lowerright) - <= 0.0; - if (leftfinished && rightfinished) { - /* Create the top new bounding triangle. */ - maketriangle(m, b, &nextedge); - setorg(nextedge, lowerleft); - setdest(nextedge, lowerright); - /* Apex is intentionally left NULL. */ - /* Connect it to the bounding boxes of the two triangulations. */ - bond(nextedge, baseedge); - lnextself(nextedge); - bond(nextedge, rightcand); - lnextself(nextedge); - bond(nextedge, leftcand); - if (b->verbose > 2) { - printf(" Creating top bounding "); - printtriangle(m, b, &nextedge); - } - /* Special treatment for horizontal cuts. */ - if (b->dwyer && (axis == 1)) { - org(*farleft, farleftpt); - apex(*farleft, farleftapex); - dest(*farright, farrightpt); - apex(*farright, farrightapex); - sym(*farleft, checkedge); - apex(checkedge, checkvertex); - /* The pointers to the extremal vertices are restored to the */ - /* leftmost and rightmost vertices (rather than topmost and */ - /* bottommost). */ - while (checkvertex[0] < farleftpt[0]) { - lprev(checkedge, *farleft); - farleftapex = farleftpt; - farleftpt = checkvertex; - sym(*farleft, checkedge); - apex(checkedge, checkvertex); - } - while (farrightapex[0] > farrightpt[0]) { - lprevself(*farright); - symself(*farright); - farrightpt = farrightapex; - apex(*farright, farrightapex); - } - } - return; - } - /* Consider eliminating edges from the left triangulation. */ - if (!leftfinished) { - /* What vertex would be exposed if an edge were deleted? */ - lprev(leftcand, nextedge); - symself(nextedge); - apex(nextedge, nextapex); - /* If nextapex is NULL, then no vertex would be exposed; the */ - /* triangulation would have been eaten right through. */ - if (nextapex != (vertex) NULL) { - /* Check whether the edge is Delaunay. */ - badedge = incircle(m, b, lowerleft, lowerright, upperleft, nextapex) > - 0.0; - while (badedge) { - /* Eliminate the edge with an edge flip. As a result, the */ - /* left triangulation will have one more boundary triangle. */ - lnextself(nextedge); - sym(nextedge, topcasing); - lnextself(nextedge); - sym(nextedge, sidecasing); - bond(nextedge, topcasing); - bond(leftcand, sidecasing); - lnextself(leftcand); - sym(leftcand, outercasing); - lprevself(nextedge); - bond(nextedge, outercasing); - /* Correct the vertices to reflect the edge flip. */ - setorg(leftcand, lowerleft); - setdest(leftcand, NULL); - setapex(leftcand, nextapex); - setorg(nextedge, NULL); - setdest(nextedge, upperleft); - setapex(nextedge, nextapex); - /* Consider the newly exposed vertex. */ - upperleft = nextapex; - /* What vertex would be exposed if another edge were deleted? */ - otricopy(sidecasing, nextedge); - apex(nextedge, nextapex); - if (nextapex != (vertex) NULL) { - /* Check whether the edge is Delaunay. */ - badedge = incircle(m, b, lowerleft, lowerright, upperleft, - nextapex) > 0.0; - } else { - /* Avoid eating right through the triangulation. */ - badedge = 0; - } - } - } - } - /* Consider eliminating edges from the right triangulation. */ - if (!rightfinished) { - /* What vertex would be exposed if an edge were deleted? */ - lnext(rightcand, nextedge); - symself(nextedge); - apex(nextedge, nextapex); - /* If nextapex is NULL, then no vertex would be exposed; the */ - /* triangulation would have been eaten right through. */ - if (nextapex != (vertex) NULL) { - /* Check whether the edge is Delaunay. */ - badedge = incircle(m, b, lowerleft, lowerright, upperright, nextapex) > - 0.0; - while (badedge) { - /* Eliminate the edge with an edge flip. As a result, the */ - /* right triangulation will have one more boundary triangle. */ - lprevself(nextedge); - sym(nextedge, topcasing); - lprevself(nextedge); - sym(nextedge, sidecasing); - bond(nextedge, topcasing); - bond(rightcand, sidecasing); - lprevself(rightcand); - sym(rightcand, outercasing); - lnextself(nextedge); - bond(nextedge, outercasing); - /* Correct the vertices to reflect the edge flip. */ - setorg(rightcand, NULL); - setdest(rightcand, lowerright); - setapex(rightcand, nextapex); - setorg(nextedge, upperright); - setdest(nextedge, NULL); - setapex(nextedge, nextapex); - /* Consider the newly exposed vertex. */ - upperright = nextapex; - /* What vertex would be exposed if another edge were deleted? */ - otricopy(sidecasing, nextedge); - apex(nextedge, nextapex); - if (nextapex != (vertex) NULL) { - /* Check whether the edge is Delaunay. */ - badedge = incircle(m, b, lowerleft, lowerright, upperright, - nextapex) > 0.0; - } else { - /* Avoid eating right through the triangulation. */ - badedge = 0; - } - } - } - } - if (leftfinished || (!rightfinished && - (incircle(m, b, upperleft, lowerleft, lowerright, upperright) > - 0.0))) { - /* Knit the triangulations, adding an edge from `lowerleft' */ - /* to `upperright'. */ - bond(baseedge, rightcand); - lprev(rightcand, baseedge); - setdest(baseedge, lowerleft); - lowerright = upperright; - sym(baseedge, rightcand); - apex(rightcand, upperright); - } else { - /* Knit the triangulations, adding an edge from `upperleft' */ - /* to `lowerright'. */ - bond(baseedge, leftcand); - lnext(leftcand, baseedge); - setorg(baseedge, lowerright); - lowerleft = upperleft; - sym(baseedge, leftcand); - apex(leftcand, upperleft); - } - if (b->verbose > 2) { - printf(" Connecting "); - printtriangle(m, b, &baseedge); - } - } -} - -/*****************************************************************************/ -/* */ -/* divconqrecurse() Recursively form a Delaunay triangulation by the */ -/* divide-and-conquer method. */ -/* */ -/* Recursively breaks down the problem into smaller pieces, which are */ -/* knitted together by mergehulls(). The base cases (problems of two or */ -/* three vertices) are handled specially here. */ -/* */ -/* On completion, `farleft' and `farright' are bounding triangles such that */ -/* the origin of `farleft' is the leftmost vertex (breaking ties by */ -/* choosing the highest leftmost vertex), and the destination of */ -/* `farright' is the rightmost vertex (breaking ties by choosing the */ -/* lowest rightmost vertex). */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void divconqrecurse(struct mesh *m, struct behavior *b, vertex *sortarray, - int vertices, int axis, - struct otri *farleft, struct otri *farright) -#else /* not ANSI_DECLARATORS */ -void divconqrecurse(m, b, sortarray, vertices, axis, farleft, farright) -struct mesh *m; -struct behavior *b; -vertex *sortarray; -int vertices; -int axis; -struct otri *farleft; -struct otri *farright; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri midtri, tri1, tri2, tri3; - struct otri innerleft, innerright; - REAL area; - int divider; - - if (b->verbose > 2) { - printf(" Triangulating %d vertices.\n", vertices); - } - if (vertices == 2) { - /* The triangulation of two vertices is an edge. An edge is */ - /* represented by two bounding triangles. */ - maketriangle(m, b, farleft); - setorg(*farleft, sortarray[0]); - setdest(*farleft, sortarray[1]); - /* The apex is intentionally left NULL. */ - maketriangle(m, b, farright); - setorg(*farright, sortarray[1]); - setdest(*farright, sortarray[0]); - /* The apex is intentionally left NULL. */ - bond(*farleft, *farright); - lprevself(*farleft); - lnextself(*farright); - bond(*farleft, *farright); - lprevself(*farleft); - lnextself(*farright); - bond(*farleft, *farright); - if (b->verbose > 2) { - printf(" Creating "); - printtriangle(m, b, farleft); - printf(" Creating "); - printtriangle(m, b, farright); - } - /* Ensure that the origin of `farleft' is sortarray[0]. */ - lprev(*farright, *farleft); - return; - } else if (vertices == 3) { - /* The triangulation of three vertices is either a triangle (with */ - /* three bounding triangles) or two edges (with four bounding */ - /* triangles). In either case, four triangles are created. */ - maketriangle(m, b, &midtri); - maketriangle(m, b, &tri1); - maketriangle(m, b, &tri2); - maketriangle(m, b, &tri3); - area = counterclockwise(m, b, sortarray[0], sortarray[1], sortarray[2]); - if (area == 0.0) { - /* Three collinear vertices; the triangulation is two edges. */ - setorg(midtri, sortarray[0]); - setdest(midtri, sortarray[1]); - setorg(tri1, sortarray[1]); - setdest(tri1, sortarray[0]); - setorg(tri2, sortarray[2]); - setdest(tri2, sortarray[1]); - setorg(tri3, sortarray[1]); - setdest(tri3, sortarray[2]); - /* All apices are intentionally left NULL. */ - bond(midtri, tri1); - bond(tri2, tri3); - lnextself(midtri); - lprevself(tri1); - lnextself(tri2); - lprevself(tri3); - bond(midtri, tri3); - bond(tri1, tri2); - lnextself(midtri); - lprevself(tri1); - lnextself(tri2); - lprevself(tri3); - bond(midtri, tri1); - bond(tri2, tri3); - /* Ensure that the origin of `farleft' is sortarray[0]. */ - otricopy(tri1, *farleft); - /* Ensure that the destination of `farright' is sortarray[2]. */ - otricopy(tri2, *farright); - } else { - /* The three vertices are not collinear; the triangulation is one */ - /* triangle, namely `midtri'. */ - setorg(midtri, sortarray[0]); - setdest(tri1, sortarray[0]); - setorg(tri3, sortarray[0]); - /* Apices of tri1, tri2, and tri3 are left NULL. */ - if (area > 0.0) { - /* The vertices are in counterclockwise order. */ - setdest(midtri, sortarray[1]); - setorg(tri1, sortarray[1]); - setdest(tri2, sortarray[1]); - setapex(midtri, sortarray[2]); - setorg(tri2, sortarray[2]); - setdest(tri3, sortarray[2]); - } else { - /* The vertices are in clockwise order. */ - setdest(midtri, sortarray[2]); - setorg(tri1, sortarray[2]); - setdest(tri2, sortarray[2]); - setapex(midtri, sortarray[1]); - setorg(tri2, sortarray[1]); - setdest(tri3, sortarray[1]); - } - /* The topology does not depend on how the vertices are ordered. */ - bond(midtri, tri1); - lnextself(midtri); - bond(midtri, tri2); - lnextself(midtri); - bond(midtri, tri3); - lprevself(tri1); - lnextself(tri2); - bond(tri1, tri2); - lprevself(tri1); - lprevself(tri3); - bond(tri1, tri3); - lnextself(tri2); - lprevself(tri3); - bond(tri2, tri3); - /* Ensure that the origin of `farleft' is sortarray[0]. */ - otricopy(tri1, *farleft); - /* Ensure that the destination of `farright' is sortarray[2]. */ - if (area > 0.0) { - otricopy(tri2, *farright); - } else { - lnext(*farleft, *farright); - } - } - if (b->verbose > 2) { - printf(" Creating "); - printtriangle(m, b, &midtri); - printf(" Creating "); - printtriangle(m, b, &tri1); - printf(" Creating "); - printtriangle(m, b, &tri2); - printf(" Creating "); - printtriangle(m, b, &tri3); - } - return; - } else { - /* Split the vertices in half. */ - divider = vertices >> 1; - /* Recursively triangulate each half. */ - divconqrecurse(m, b, sortarray, divider, 1 - axis, farleft, &innerleft); - divconqrecurse(m, b, &sortarray[divider], vertices - divider, 1 - axis, - &innerright, farright); - if (b->verbose > 1) { - printf(" Joining triangulations with %d and %d vertices.\n", divider, - vertices - divider); - } - /* Merge the two triangulations into one. */ - mergehulls(m, b, farleft, &innerleft, &innerright, farright, axis); - } -} - -#ifdef ANSI_DECLARATORS -long removeghosts(struct mesh *m, struct behavior *b, struct otri *startghost) -#else /* not ANSI_DECLARATORS */ -long removeghosts(m, b, startghost) -struct mesh *m; -struct behavior *b; -struct otri *startghost; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri searchedge; - struct otri dissolveedge; - struct otri deadtriangle; - vertex markorg; - long hullsize; - triangle ptr; /* Temporary variable used by sym(). */ - - if (b->verbose) { - printf(" Removing ghost triangles.\n"); - } - /* Find an edge on the convex hull to start point location from. */ - lprev(*startghost, searchedge); - symself(searchedge); - m->dummytri[0] = encode(searchedge); - /* Remove the bounding box and count the convex hull edges. */ - otricopy(*startghost, dissolveedge); - hullsize = 0; - do { - hullsize++; - lnext(dissolveedge, deadtriangle); - lprevself(dissolveedge); - symself(dissolveedge); - /* If no PSLG is involved, set the boundary markers of all the vertices */ - /* on the convex hull. If a PSLG is used, this step is done later. */ - if (!b->poly) { - /* Watch out for the case where all the input vertices are collinear. */ - if (dissolveedge.tri != m->dummytri) { - org(dissolveedge, markorg); - if (vertexmark(markorg) == 0) { - setvertexmark(markorg, 1); - } - } - } - /* Remove a bounding triangle from a convex hull triangle. */ - dissolve(dissolveedge); - /* Find the next bounding triangle. */ - sym(deadtriangle, dissolveedge); - /* Delete the bounding triangle. */ - triangledealloc(m, deadtriangle.tri); - } while (!otriequal(dissolveedge, *startghost)); - return hullsize; -} - -/*****************************************************************************/ -/* */ -/* divconqdelaunay() Form a Delaunay triangulation by the divide-and- */ -/* conquer method. */ -/* */ -/* Sorts the vertices, calls a recursive procedure to triangulate them, and */ -/* removes the bounding box, setting boundary markers as appropriate. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -long divconqdelaunay(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -long divconqdelaunay(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex *sortarray; - struct otri hullleft, hullright; - int divider; - int i, j; - - if (b->verbose) { - printf(" Sorting vertices.\n"); - } - - /* Allocate an array of pointers to vertices for sorting. */ - sortarray = (vertex *) trimalloc(m->invertices * (int) sizeof(vertex)); - traversalinit(&m->vertices); - for (i = 0; i < m->invertices; i++) { - sortarray[i] = vertextraverse(m); - } - /* Sort the vertices. */ - vertexsort(sortarray, m->invertices); - /* Discard duplicate vertices, which can really mess up the algorithm. */ - i = 0; - for (j = 1; j < m->invertices; j++) { - if ((sortarray[i][0] == sortarray[j][0]) - && (sortarray[i][1] == sortarray[j][1])) { - if (!b->quiet) { - printf( -"Warning: A duplicate vertex at (%.12g, %.12g) appeared and was ignored.\n", - sortarray[j][0], sortarray[j][1]); - } - setvertextype(sortarray[j], UNDEADVERTEX); - m->undeads++; - } else { - i++; - sortarray[i] = sortarray[j]; - } - } - i++; - if (b->dwyer) { - /* Re-sort the array of vertices to accommodate alternating cuts. */ - divider = i >> 1; - if (i - divider >= 2) { - if (divider >= 2) { - alternateaxes(sortarray, divider, 1); - } - alternateaxes(&sortarray[divider], i - divider, 1); - } - } - - if (b->verbose) { - printf(" Forming triangulation.\n"); - } - - /* Form the Delaunay triangulation. */ - divconqrecurse(m, b, sortarray, i, 0, &hullleft, &hullright); - trifree((VOID *) sortarray); - - return removeghosts(m, b, &hullleft); -} - -/** **/ -/** **/ -/********* Divide-and-conquer Delaunay triangulation ends here *********/ - -/********* Incremental Delaunay triangulation begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* boundingbox() Form an "infinite" bounding triangle to insert vertices */ -/* into. */ -/* */ -/* The vertices at "infinity" are assigned finite coordinates, which are */ -/* used by the point location routines, but (mostly) ignored by the */ -/* Delaunay edge flip routines. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void boundingbox(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void boundingbox(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri inftri; /* Handle for the triangular bounding box. */ - REAL width; - - if (b->verbose) { - printf(" Creating triangular bounding box.\n"); - } - /* Find the width (or height, whichever is larger) of the triangulation. */ - width = m->xmax - m->xmin; - if (m->ymax - m->ymin > width) { - width = m->ymax - m->ymin; - } - if (width == 0.0) { - width = 1.0; - } - /* Create the vertices of the bounding box. */ - m->infvertex1 = (vertex) trimalloc(m->vertices.itembytes); - m->infvertex2 = (vertex) trimalloc(m->vertices.itembytes); - m->infvertex3 = (vertex) trimalloc(m->vertices.itembytes); - m->infvertex1[0] = m->xmin - 50.0 * width; - m->infvertex1[1] = m->ymin - 40.0 * width; - m->infvertex2[0] = m->xmax + 50.0 * width; - m->infvertex2[1] = m->ymin - 40.0 * width; - m->infvertex3[0] = 0.5 * (m->xmin + m->xmax); - m->infvertex3[1] = m->ymax + 60.0 * width; - - /* Create the bounding box. */ - maketriangle(m, b, &inftri); - setorg(inftri, m->infvertex1); - setdest(inftri, m->infvertex2); - setapex(inftri, m->infvertex3); - /* Link dummytri to the bounding box so we can always find an */ - /* edge to begin searching (point location) from. */ - m->dummytri[0] = (triangle) inftri.tri; - if (b->verbose > 2) { - printf(" Creating "); - printtriangle(m, b, &inftri); - } -} - -#endif /* not REDUCED */ - -/*****************************************************************************/ -/* */ -/* removebox() Remove the "infinite" bounding triangle, setting boundary */ -/* markers as appropriate. */ -/* */ -/* The triangular bounding box has three boundary triangles (one for each */ -/* side of the bounding box), and a bunch of triangles fanning out from */ -/* the three bounding box vertices (one triangle for each edge of the */ -/* convex hull of the inner mesh). This routine removes these triangles. */ -/* */ -/* Returns the number of edges on the convex hull of the triangulation. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -long removebox(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -long removebox(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri deadtriangle; - struct otri searchedge; - struct otri checkedge; - struct otri nextedge, finaledge, dissolveedge; - vertex markorg; - long hullsize; - triangle ptr; /* Temporary variable used by sym(). */ - - if (b->verbose) { - printf(" Removing triangular bounding box.\n"); - } - /* Find a boundary triangle. */ - nextedge.tri = m->dummytri; - nextedge.orient = 0; - symself(nextedge); - /* Mark a place to stop. */ - lprev(nextedge, finaledge); - lnextself(nextedge); - symself(nextedge); - /* Find a triangle (on the boundary of the vertex set) that isn't */ - /* a bounding box triangle. */ - lprev(nextedge, searchedge); - symself(searchedge); - /* Check whether nextedge is another boundary triangle */ - /* adjacent to the first one. */ - lnext(nextedge, checkedge); - symself(checkedge); - if (checkedge.tri == m->dummytri) { - /* Go on to the next triangle. There are only three boundary */ - /* triangles, and this next triangle cannot be the third one, */ - /* so it's safe to stop here. */ - lprevself(searchedge); - symself(searchedge); - } - /* Find a new boundary edge to search from, as the current search */ - /* edge lies on a bounding box triangle and will be deleted. */ - m->dummytri[0] = encode(searchedge); - hullsize = -2l; - while (!otriequal(nextedge, finaledge)) { - hullsize++; - lprev(nextedge, dissolveedge); - symself(dissolveedge); - /* If not using a PSLG, the vertices should be marked now. */ - /* (If using a PSLG, markhull() will do the job.) */ - if (!b->poly) { - /* Be careful! One must check for the case where all the input */ - /* vertices are collinear, and thus all the triangles are part of */ - /* the bounding box. Otherwise, the setvertexmark() call below */ - /* will cause a bad pointer reference. */ - if (dissolveedge.tri != m->dummytri) { - org(dissolveedge, markorg); - if (vertexmark(markorg) == 0) { - setvertexmark(markorg, 1); - } - } - } - /* Disconnect the bounding box triangle from the mesh triangle. */ - dissolve(dissolveedge); - lnext(nextedge, deadtriangle); - sym(deadtriangle, nextedge); - /* Get rid of the bounding box triangle. */ - triangledealloc(m, deadtriangle.tri); - /* Do we need to turn the corner? */ - if (nextedge.tri == m->dummytri) { - /* Turn the corner. */ - otricopy(dissolveedge, nextedge); - } - } - triangledealloc(m, finaledge.tri); - - trifree((VOID *) m->infvertex1); /* Deallocate the bounding box vertices. */ - trifree((VOID *) m->infvertex2); - trifree((VOID *) m->infvertex3); - - return hullsize; -} - -#endif /* not REDUCED */ - -/*****************************************************************************/ -/* */ -/* incrementaldelaunay() Form a Delaunay triangulation by incrementally */ -/* inserting vertices. */ -/* */ -/* Returns the number of edges on the convex hull of the triangulation. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -long incrementaldelaunay(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -long incrementaldelaunay(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri starttri; - vertex vertexloop; - - /* Create a triangular bounding box. */ - boundingbox(m, b); - if (b->verbose) { - printf(" Incrementally inserting vertices.\n"); - } - traversalinit(&m->vertices); - vertexloop = vertextraverse(m); - while (vertexloop != (vertex) NULL) { - starttri.tri = m->dummytri; - if (insertvertex(m, b, vertexloop, &starttri, (struct osub *) NULL, 0, 0) - == DUPLICATEVERTEX) { - if (!b->quiet) { - printf( -"Warning: A duplicate vertex at (%.12g, %.12g) appeared and was ignored.\n", - vertexloop[0], vertexloop[1]); - } - setvertextype(vertexloop, UNDEADVERTEX); - m->undeads++; - } - vertexloop = vertextraverse(m); - } - /* Remove the bounding box. */ - return removebox(m, b); -} - -#endif /* not REDUCED */ - -/** **/ -/** **/ -/********* Incremental Delaunay triangulation ends here *********/ - -/********* Sweepline Delaunay triangulation begins here *********/ -/** **/ -/** **/ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void eventheapinsert(struct event **heap, int heapsize, struct event *newevent) -#else /* not ANSI_DECLARATORS */ -void eventheapinsert(heap, heapsize, newevent) -struct event **heap; -int heapsize; -struct event *newevent; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL eventx, eventy; - int eventnum; - int parent; - int notdone; - - eventx = newevent->xkey; - eventy = newevent->ykey; - eventnum = heapsize; - notdone = eventnum > 0; - while (notdone) { - parent = (eventnum - 1) >> 1; - if ((heap[parent]->ykey < eventy) || - ((heap[parent]->ykey == eventy) - && (heap[parent]->xkey <= eventx))) { - notdone = 0; - } else { - heap[eventnum] = heap[parent]; - heap[eventnum]->heapposition = eventnum; - - eventnum = parent; - notdone = eventnum > 0; - } - } - heap[eventnum] = newevent; - newevent->heapposition = eventnum; -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void eventheapify(struct event **heap, int heapsize, int eventnum) -#else /* not ANSI_DECLARATORS */ -void eventheapify(heap, heapsize, eventnum) -struct event **heap; -int heapsize; -int eventnum; -#endif /* not ANSI_DECLARATORS */ - -{ - struct event *thisevent; - REAL eventx, eventy; - int leftchild, rightchild; - int smallest; - int notdone; - - thisevent = heap[eventnum]; - eventx = thisevent->xkey; - eventy = thisevent->ykey; - leftchild = 2 * eventnum + 1; - notdone = leftchild < heapsize; - while (notdone) { - if ((heap[leftchild]->ykey < eventy) || - ((heap[leftchild]->ykey == eventy) - && (heap[leftchild]->xkey < eventx))) { - smallest = leftchild; - } else { - smallest = eventnum; - } - rightchild = leftchild + 1; - if (rightchild < heapsize) { - if ((heap[rightchild]->ykey < heap[smallest]->ykey) || - ((heap[rightchild]->ykey == heap[smallest]->ykey) - && (heap[rightchild]->xkey < heap[smallest]->xkey))) { - smallest = rightchild; - } - } - if (smallest == eventnum) { - notdone = 0; - } else { - heap[eventnum] = heap[smallest]; - heap[eventnum]->heapposition = eventnum; - heap[smallest] = thisevent; - thisevent->heapposition = smallest; - - eventnum = smallest; - leftchild = 2 * eventnum + 1; - notdone = leftchild < heapsize; - } - } -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void eventheapdelete(struct event **heap, int heapsize, int eventnum) -#else /* not ANSI_DECLARATORS */ -void eventheapdelete(heap, heapsize, eventnum) -struct event **heap; -int heapsize; -int eventnum; -#endif /* not ANSI_DECLARATORS */ - -{ - struct event *moveevent; - REAL eventx, eventy; - int parent; - int notdone; - - moveevent = heap[heapsize - 1]; - if (eventnum > 0) { - eventx = moveevent->xkey; - eventy = moveevent->ykey; - do { - parent = (eventnum - 1) >> 1; - if ((heap[parent]->ykey < eventy) || - ((heap[parent]->ykey == eventy) - && (heap[parent]->xkey <= eventx))) { - notdone = 0; - } else { - heap[eventnum] = heap[parent]; - heap[eventnum]->heapposition = eventnum; - - eventnum = parent; - notdone = eventnum > 0; - } - } while (notdone); - } - heap[eventnum] = moveevent; - moveevent->heapposition = eventnum; - eventheapify(heap, heapsize - 1, eventnum); -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void createeventheap(struct mesh *m, struct event ***eventheap, - struct event **events, struct event **freeevents) -#else /* not ANSI_DECLARATORS */ -void createeventheap(m, eventheap, events, freeevents) -struct mesh *m; -struct event ***eventheap; -struct event **events; -struct event **freeevents; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex thisvertex; - int maxevents; - int i; - - maxevents = (3 * m->invertices) / 2; - *eventheap = (struct event **) trimalloc(maxevents * - (int) sizeof(struct event *)); - *events = (struct event *) trimalloc(maxevents * (int) sizeof(struct event)); - traversalinit(&m->vertices); - for (i = 0; i < m->invertices; i++) { - thisvertex = vertextraverse(m); - (*events)[i].eventptr = (VOID *) thisvertex; - (*events)[i].xkey = thisvertex[0]; - (*events)[i].ykey = thisvertex[1]; - eventheapinsert(*eventheap, i, *events + i); - } - *freeevents = (struct event *) NULL; - for (i = maxevents - 1; i >= m->invertices; i--) { - (*events)[i].eventptr = (VOID *) *freeevents; - *freeevents = *events + i; - } -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -int rightofhyperbola(struct mesh *m, struct otri *fronttri, vertex newsite) -#else /* not ANSI_DECLARATORS */ -int rightofhyperbola(m, fronttri, newsite) -struct mesh *m; -struct otri *fronttri; -vertex newsite; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex leftvertex, rightvertex; - REAL dxa, dya, dxb, dyb; - - m->hyperbolacount++; - - dest(*fronttri, leftvertex); - apex(*fronttri, rightvertex); - if ((leftvertex[1] < rightvertex[1]) || - ((leftvertex[1] == rightvertex[1]) && - (leftvertex[0] < rightvertex[0]))) { - if (newsite[0] >= rightvertex[0]) { - return 1; - } - } else { - if (newsite[0] <= leftvertex[0]) { - return 0; - } - } - dxa = leftvertex[0] - newsite[0]; - dya = leftvertex[1] - newsite[1]; - dxb = rightvertex[0] - newsite[0]; - dyb = rightvertex[1] - newsite[1]; - return dya * (dxb * dxb + dyb * dyb) > dyb * (dxa * dxa + dya * dya); -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -REAL circletop(struct mesh *m, vertex pa, vertex pb, vertex pc, REAL ccwabc) -#else /* not ANSI_DECLARATORS */ -REAL circletop(m, pa, pb, pc, ccwabc) -struct mesh *m; -vertex pa; -vertex pb; -vertex pc; -REAL ccwabc; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL xac, yac, xbc, ybc, xab, yab; - REAL aclen2, bclen2, ablen2; - - m->circletopcount++; - - xac = pa[0] - pc[0]; - yac = pa[1] - pc[1]; - xbc = pb[0] - pc[0]; - ybc = pb[1] - pc[1]; - xab = pa[0] - pb[0]; - yab = pa[1] - pb[1]; - aclen2 = xac * xac + yac * yac; - bclen2 = xbc * xbc + ybc * ybc; - ablen2 = xab * xab + yab * yab; - return pc[1] + (xac * bclen2 - xbc * aclen2 + sqrt(aclen2 * bclen2 * ablen2)) - / (2.0 * ccwabc); -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -void check4deadevent(struct otri *checktri, struct event **freeevents, - struct event **eventheap, int *heapsize) -#else /* not ANSI_DECLARATORS */ -void check4deadevent(checktri, freeevents, eventheap, heapsize) -struct otri *checktri; -struct event **freeevents; -struct event **eventheap; -int *heapsize; -#endif /* not ANSI_DECLARATORS */ - -{ - struct event *deadevent; - vertex eventvertex; - int eventnum; - - org(*checktri, eventvertex); - if (eventvertex != (vertex) NULL) { - deadevent = (struct event *) eventvertex; - eventnum = deadevent->heapposition; - deadevent->eventptr = (VOID *) *freeevents; - *freeevents = deadevent; - eventheapdelete(eventheap, *heapsize, eventnum); - (*heapsize)--; - setorg(*checktri, NULL); - } -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -struct splaynode *splay(struct mesh *m, struct splaynode *splaytree, - vertex searchpoint, struct otri *searchtri) -#else /* not ANSI_DECLARATORS */ -struct splaynode *splay(m, splaytree, searchpoint, searchtri) -struct mesh *m; -struct splaynode *splaytree; -vertex searchpoint; -struct otri *searchtri; -#endif /* not ANSI_DECLARATORS */ - -{ - struct splaynode *child, *grandchild; - struct splaynode *lefttree, *righttree; - struct splaynode *leftright; - vertex checkvertex; - int rightofroot, rightofchild; - - if (splaytree == (struct splaynode *) NULL) { - return (struct splaynode *) NULL; - } - dest(splaytree->keyedge, checkvertex); - if (checkvertex == splaytree->keydest) { - rightofroot = rightofhyperbola(m, &splaytree->keyedge, searchpoint); - if (rightofroot) { - otricopy(splaytree->keyedge, *searchtri); - child = splaytree->rchild; - } else { - child = splaytree->lchild; - } - if (child == (struct splaynode *) NULL) { - return splaytree; - } - dest(child->keyedge, checkvertex); - if (checkvertex != child->keydest) { - child = splay(m, child, searchpoint, searchtri); - if (child == (struct splaynode *) NULL) { - if (rightofroot) { - splaytree->rchild = (struct splaynode *) NULL; - } else { - splaytree->lchild = (struct splaynode *) NULL; - } - return splaytree; - } - } - rightofchild = rightofhyperbola(m, &child->keyedge, searchpoint); - if (rightofchild) { - otricopy(child->keyedge, *searchtri); - grandchild = splay(m, child->rchild, searchpoint, searchtri); - child->rchild = grandchild; - } else { - grandchild = splay(m, child->lchild, searchpoint, searchtri); - child->lchild = grandchild; - } - if (grandchild == (struct splaynode *) NULL) { - if (rightofroot) { - splaytree->rchild = child->lchild; - child->lchild = splaytree; - } else { - splaytree->lchild = child->rchild; - child->rchild = splaytree; - } - return child; - } - if (rightofchild) { - if (rightofroot) { - splaytree->rchild = child->lchild; - child->lchild = splaytree; - } else { - splaytree->lchild = grandchild->rchild; - grandchild->rchild = splaytree; - } - child->rchild = grandchild->lchild; - grandchild->lchild = child; - } else { - if (rightofroot) { - splaytree->rchild = grandchild->lchild; - grandchild->lchild = splaytree; - } else { - splaytree->lchild = child->rchild; - child->rchild = splaytree; - } - child->lchild = grandchild->rchild; - grandchild->rchild = child; - } - return grandchild; - } else { - lefttree = splay(m, splaytree->lchild, searchpoint, searchtri); - righttree = splay(m, splaytree->rchild, searchpoint, searchtri); - - pooldealloc(&m->splaynodes, (VOID *) splaytree); - if (lefttree == (struct splaynode *) NULL) { - return righttree; - } else if (righttree == (struct splaynode *) NULL) { - return lefttree; - } else if (lefttree->rchild == (struct splaynode *) NULL) { - lefttree->rchild = righttree->lchild; - righttree->lchild = lefttree; - return righttree; - } else if (righttree->lchild == (struct splaynode *) NULL) { - righttree->lchild = lefttree->rchild; - lefttree->rchild = righttree; - return lefttree; - } else { -/* printf("Holy Toledo!!!\n"); */ - leftright = lefttree->rchild; - while (leftright->rchild != (struct splaynode *) NULL) { - leftright = leftright->rchild; - } - leftright->rchild = righttree; - return lefttree; - } - } -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -struct splaynode *splayinsert(struct mesh *m, struct splaynode *splayroot, - struct otri *newkey, vertex searchpoint) -#else /* not ANSI_DECLARATORS */ -struct splaynode *splayinsert(m, splayroot, newkey, searchpoint) -struct mesh *m; -struct splaynode *splayroot; -struct otri *newkey; -vertex searchpoint; -#endif /* not ANSI_DECLARATORS */ - -{ - struct splaynode *newsplaynode; - - newsplaynode = (struct splaynode *) poolalloc(&m->splaynodes); - otricopy(*newkey, newsplaynode->keyedge); - dest(*newkey, newsplaynode->keydest); - if (splayroot == (struct splaynode *) NULL) { - newsplaynode->lchild = (struct splaynode *) NULL; - newsplaynode->rchild = (struct splaynode *) NULL; - } else if (rightofhyperbola(m, &splayroot->keyedge, searchpoint)) { - newsplaynode->lchild = splayroot; - newsplaynode->rchild = splayroot->rchild; - splayroot->rchild = (struct splaynode *) NULL; - } else { - newsplaynode->lchild = splayroot->lchild; - newsplaynode->rchild = splayroot; - splayroot->lchild = (struct splaynode *) NULL; - } - return newsplaynode; -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -struct splaynode *circletopinsert(struct mesh *m, struct behavior *b, - struct splaynode *splayroot, - struct otri *newkey, - vertex pa, vertex pb, vertex pc, REAL topy) -#else /* not ANSI_DECLARATORS */ -struct splaynode *circletopinsert(m, b, splayroot, newkey, pa, pb, pc, topy) -struct mesh *m; -struct behavior *b; -struct splaynode *splayroot; -struct otri *newkey; -vertex pa; -vertex pb; -vertex pc; -REAL topy; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL ccwabc; - REAL xac, yac, xbc, ybc; - REAL aclen2, bclen2; - REAL searchpoint[2]; - struct otri dummytri; - - ccwabc = counterclockwise(m, b, pa, pb, pc); - xac = pa[0] - pc[0]; - yac = pa[1] - pc[1]; - xbc = pb[0] - pc[0]; - ybc = pb[1] - pc[1]; - aclen2 = xac * xac + yac * yac; - bclen2 = xbc * xbc + ybc * ybc; - searchpoint[0] = pc[0] - (yac * bclen2 - ybc * aclen2) / (2.0 * ccwabc); - searchpoint[1] = topy; - return splayinsert(m, splay(m, splayroot, (vertex) searchpoint, &dummytri), - newkey, (vertex) searchpoint); -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -struct splaynode *frontlocate(struct mesh *m, struct splaynode *splayroot, - struct otri *bottommost, vertex searchvertex, - struct otri *searchtri, int *farright) -#else /* not ANSI_DECLARATORS */ -struct splaynode *frontlocate(m, splayroot, bottommost, searchvertex, - searchtri, farright) -struct mesh *m; -struct splaynode *splayroot; -struct otri *bottommost; -vertex searchvertex; -struct otri *searchtri; -int *farright; -#endif /* not ANSI_DECLARATORS */ - -{ - int farrightflag; - triangle ptr; /* Temporary variable used by onext(). */ - - otricopy(*bottommost, *searchtri); - splayroot = splay(m, splayroot, searchvertex, searchtri); - - farrightflag = 0; - while (!farrightflag && rightofhyperbola(m, searchtri, searchvertex)) { - onextself(*searchtri); - farrightflag = otriequal(*searchtri, *bottommost); - } - *farright = farrightflag; - return splayroot; -} - -#endif /* not REDUCED */ - -#ifndef REDUCED - -#ifdef ANSI_DECLARATORS -long sweeplinedelaunay(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -long sweeplinedelaunay(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct event **eventheap; - struct event *events; - struct event *freeevents; - struct event *nextevent; - struct event *newevent; - struct splaynode *splayroot; - struct otri bottommost; - struct otri searchtri; - struct otri fliptri; - struct otri lefttri, righttri, farlefttri, farrighttri; - struct otri inserttri; - vertex firstvertex, secondvertex; - vertex nextvertex, lastvertex; - vertex connectvertex; - vertex leftvertex, midvertex, rightvertex; - REAL lefttest, righttest; - int heapsize; - int check4events, farrightflag; - triangle ptr; /* Temporary variable used by sym(), onext(), and oprev(). */ - - poolinit(&m->splaynodes, sizeof(struct splaynode), SPLAYNODEPERBLOCK, - SPLAYNODEPERBLOCK, 0); - splayroot = (struct splaynode *) NULL; - - if (b->verbose) { - printf(" Placing vertices in event heap.\n"); - } - createeventheap(m, &eventheap, &events, &freeevents); - heapsize = m->invertices; - - if (b->verbose) { - printf(" Forming triangulation.\n"); - } - maketriangle(m, b, &lefttri); - maketriangle(m, b, &righttri); - bond(lefttri, righttri); - lnextself(lefttri); - lprevself(righttri); - bond(lefttri, righttri); - lnextself(lefttri); - lprevself(righttri); - bond(lefttri, righttri); - firstvertex = (vertex) eventheap[0]->eventptr; - eventheap[0]->eventptr = (VOID *) freeevents; - freeevents = eventheap[0]; - eventheapdelete(eventheap, heapsize, 0); - heapsize--; - do { - if (heapsize == 0) { - printf("Error: Input vertices are all identical.\n"); - triexit(1); - } - secondvertex = (vertex) eventheap[0]->eventptr; - eventheap[0]->eventptr = (VOID *) freeevents; - freeevents = eventheap[0]; - eventheapdelete(eventheap, heapsize, 0); - heapsize--; - if ((firstvertex[0] == secondvertex[0]) && - (firstvertex[1] == secondvertex[1])) { - if (!b->quiet) { - printf( -"Warning: A duplicate vertex at (%.12g, %.12g) appeared and was ignored.\n", - secondvertex[0], secondvertex[1]); - } - setvertextype(secondvertex, UNDEADVERTEX); - m->undeads++; - } - } while ((firstvertex[0] == secondvertex[0]) && - (firstvertex[1] == secondvertex[1])); - setorg(lefttri, firstvertex); - setdest(lefttri, secondvertex); - setorg(righttri, secondvertex); - setdest(righttri, firstvertex); - lprev(lefttri, bottommost); - lastvertex = secondvertex; - while (heapsize > 0) { - nextevent = eventheap[0]; - eventheapdelete(eventheap, heapsize, 0); - heapsize--; - check4events = 1; - if (nextevent->xkey < m->xmin) { - decode(nextevent->eventptr, fliptri); - oprev(fliptri, farlefttri); - check4deadevent(&farlefttri, &freeevents, eventheap, &heapsize); - onext(fliptri, farrighttri); - check4deadevent(&farrighttri, &freeevents, eventheap, &heapsize); - - if (otriequal(farlefttri, bottommost)) { - lprev(fliptri, bottommost); - } - flip(m, b, &fliptri); - setapex(fliptri, NULL); - lprev(fliptri, lefttri); - lnext(fliptri, righttri); - sym(lefttri, farlefttri); - - if (randomnation(SAMPLERATE) == 0) { - symself(fliptri); - dest(fliptri, leftvertex); - apex(fliptri, midvertex); - org(fliptri, rightvertex); - splayroot = circletopinsert(m, b, splayroot, &lefttri, leftvertex, - midvertex, rightvertex, nextevent->ykey); - } - } else { - nextvertex = (vertex) nextevent->eventptr; - if ((nextvertex[0] == lastvertex[0]) && - (nextvertex[1] == lastvertex[1])) { - if (!b->quiet) { - printf( -"Warning: A duplicate vertex at (%.12g, %.12g) appeared and was ignored.\n", - nextvertex[0], nextvertex[1]); - } - setvertextype(nextvertex, UNDEADVERTEX); - m->undeads++; - check4events = 0; - } else { - lastvertex = nextvertex; - - splayroot = frontlocate(m, splayroot, &bottommost, nextvertex, - &searchtri, &farrightflag); -/* - otricopy(bottommost, searchtri); - farrightflag = 0; - while (!farrightflag && rightofhyperbola(m, &searchtri, nextvertex)) { - onextself(searchtri); - farrightflag = otriequal(searchtri, bottommost); - } -*/ - - check4deadevent(&searchtri, &freeevents, eventheap, &heapsize); - - otricopy(searchtri, farrighttri); - sym(searchtri, farlefttri); - maketriangle(m, b, &lefttri); - maketriangle(m, b, &righttri); - dest(farrighttri, connectvertex); - setorg(lefttri, connectvertex); - setdest(lefttri, nextvertex); - setorg(righttri, nextvertex); - setdest(righttri, connectvertex); - bond(lefttri, righttri); - lnextself(lefttri); - lprevself(righttri); - bond(lefttri, righttri); - lnextself(lefttri); - lprevself(righttri); - bond(lefttri, farlefttri); - bond(righttri, farrighttri); - if (!farrightflag && otriequal(farrighttri, bottommost)) { - otricopy(lefttri, bottommost); - } - - if (randomnation(SAMPLERATE) == 0) { - splayroot = splayinsert(m, splayroot, &lefttri, nextvertex); - } else if (randomnation(SAMPLERATE) == 0) { - lnext(righttri, inserttri); - splayroot = splayinsert(m, splayroot, &inserttri, nextvertex); - } - } - } - nextevent->eventptr = (VOID *) freeevents; - freeevents = nextevent; - - if (check4events) { - apex(farlefttri, leftvertex); - dest(lefttri, midvertex); - apex(lefttri, rightvertex); - lefttest = counterclockwise(m, b, leftvertex, midvertex, rightvertex); - if (lefttest > 0.0) { - newevent = freeevents; - freeevents = (struct event *) freeevents->eventptr; - newevent->xkey = m->xminextreme; - newevent->ykey = circletop(m, leftvertex, midvertex, rightvertex, - lefttest); - newevent->eventptr = (VOID *) encode(lefttri); - eventheapinsert(eventheap, heapsize, newevent); - heapsize++; - setorg(lefttri, newevent); - } - apex(righttri, leftvertex); - org(righttri, midvertex); - apex(farrighttri, rightvertex); - righttest = counterclockwise(m, b, leftvertex, midvertex, rightvertex); - if (righttest > 0.0) { - newevent = freeevents; - freeevents = (struct event *) freeevents->eventptr; - newevent->xkey = m->xminextreme; - newevent->ykey = circletop(m, leftvertex, midvertex, rightvertex, - righttest); - newevent->eventptr = (VOID *) encode(farrighttri); - eventheapinsert(eventheap, heapsize, newevent); - heapsize++; - setorg(farrighttri, newevent); - } - } - } - - pooldeinit(&m->splaynodes); - lprevself(bottommost); - return removeghosts(m, b, &bottommost); -} - -#endif /* not REDUCED */ - -/** **/ -/** **/ -/********* Sweepline Delaunay triangulation ends here *********/ - -/********* General mesh construction routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* delaunay() Form a Delaunay triangulation. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -long delaunay(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -long delaunay(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - long hulledges; - - m->eextras = 0; - initializetrisubpools(m, b); - -#ifdef REDUCED - if (!b->quiet) { - printf( - "Constructing Delaunay triangulation by divide-and-conquer method.\n"); - } - hulledges = divconqdelaunay(m, b); -#else /* not REDUCED */ - if (!b->quiet) { - printf("Constructing Delaunay triangulation "); - if (b->incremental) { - printf("by incremental method.\n"); - } else if (b->sweepline) { - printf("by sweepline method.\n"); - } else { - printf("by divide-and-conquer method.\n"); - } - } - if (b->incremental) { - hulledges = incrementaldelaunay(m, b); - } else if (b->sweepline) { - hulledges = sweeplinedelaunay(m, b); - } else { - hulledges = divconqdelaunay(m, b); - } -#endif /* not REDUCED */ - - if (m->triangles.items == 0) { - /* The input vertices were all collinear, so there are no triangles. */ - return 0l; - } else { - return hulledges; - } -} - -/*****************************************************************************/ -/* */ -/* reconstruct() Reconstruct a triangulation from its .ele (and possibly */ -/* .poly) file. Used when the -r switch is used. */ -/* */ -/* Reads an .ele file and reconstructs the original mesh. If the -p switch */ -/* is used, this procedure will also read a .poly file and reconstruct the */ -/* subsegments of the original mesh. If the -a switch is used, this */ -/* procedure will also read an .area file and set a maximum area constraint */ -/* on each triangle. */ -/* */ -/* Vertices that are not corners of triangles, such as nodes on edges of */ -/* subparametric elements, are discarded. */ -/* */ -/* This routine finds the adjacencies between triangles (and subsegments) */ -/* by forming one stack of triangles for each vertex. Each triangle is on */ -/* three different stacks simultaneously. Each triangle's subsegment */ -/* pointers are used to link the items in each stack. This memory-saving */ -/* feature makes the code harder to read. The most important thing to keep */ -/* in mind is that each triangle is removed from a stack precisely when */ -/* the corresponding pointer is adjusted to refer to a subsegment rather */ -/* than the next triangle of the stack. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -int reconstruct(struct mesh *m, struct behavior *b, int *trianglelist, - REAL *triangleattriblist, REAL *trianglearealist, - int elements, int corners, int attribs, - int *segmentlist,int *segmentmarkerlist, int numberofsegments) -#else /* not ANSI_DECLARATORS */ -int reconstruct(m, b, trianglelist, triangleattriblist, trianglearealist, - elements, corners, attribs, segmentlist, segmentmarkerlist, - numberofsegments) -struct mesh *m; -struct behavior *b; -int *trianglelist; -REAL *triangleattriblist; -REAL *trianglearealist; -int elements; -int corners; -int attribs; -int *segmentlist; -int *segmentmarkerlist; -int numberofsegments; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -long reconstruct(struct mesh *m, struct behavior *b, char *elefilename, - char *areafilename, char *polyfilename, FILE *polyfile) -#else /* not ANSI_DECLARATORS */ -long reconstruct(m, b, elefilename, areafilename, polyfilename, polyfile) -struct mesh *m; -struct behavior *b; -char *elefilename; -char *areafilename; -char *polyfilename; -FILE *polyfile; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - int vertexindex; - int attribindex; -#else /* not TRILIBRARY */ - FILE *elefile; - FILE *areafile; - char inputline[INPUTLINESIZE]; - char *stringptr; - int areaelements; -#endif /* not TRILIBRARY */ - struct otri triangleloop; - struct otri triangleleft; - struct otri checktri; - struct otri checkleft; - struct otri checkneighbor; - struct osub subsegloop; - triangle *vertexarray; - triangle *prevlink; - triangle nexttri; - vertex tdest, tapex; - vertex checkdest, checkapex; - vertex shorg; - vertex killvertex; - vertex segmentorg, segmentdest; - REAL area; - int corner[3]; - int end[2]; - int killvertexindex; - int incorners; - int segmentmarkers; - int boundmarker; - int aroundvertex; - long hullsize; - int notfound; - long elementnumber, segmentnumber; - int i, j; - triangle ptr; /* Temporary variable used by sym(). */ - -#ifdef TRILIBRARY - m->inelements = elements; - incorners = corners; - if (incorners < 3) { - printf("Error: Triangles must have at least 3 vertices.\n"); - triexit(1); - } - m->eextras = attribs; -#else /* not TRILIBRARY */ - /* Read the triangles from an .ele file. */ - if (!b->quiet) { - printf("Opening %s.\n", elefilename); - } - elefile = fopen(elefilename, "r"); - if (elefile == (FILE *) NULL) { - printf(" Error: Cannot access file %s.\n", elefilename); - triexit(1); - } - /* Read number of triangles, number of vertices per triangle, and */ - /* number of triangle attributes from .ele file. */ - stringptr = readline(inputline, elefile, elefilename); - m->inelements = (int) strtol(stringptr, &stringptr, 0); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - incorners = 3; - } else { - incorners = (int) strtol(stringptr, &stringptr, 0); - if (incorners < 3) { - printf("Error: Triangles in %s must have at least 3 vertices.\n", - elefilename); - triexit(1); - } - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - m->eextras = 0; - } else { - m->eextras = (int) strtol(stringptr, &stringptr, 0); - } -#endif /* not TRILIBRARY */ - - initializetrisubpools(m, b); - - /* Create the triangles. */ - for (elementnumber = 1; elementnumber <= m->inelements; elementnumber++) { - maketriangle(m, b, &triangleloop); - /* Mark the triangle as living. */ - triangleloop.tri[3] = (triangle) triangleloop.tri; - } - - segmentmarkers = 0; - if (b->poly) { -#ifdef TRILIBRARY - m->insegments = numberofsegments; - segmentmarkers = segmentmarkerlist != (int *) NULL; -#else /* not TRILIBRARY */ - /* Read number of segments and number of segment */ - /* boundary markers from .poly file. */ - stringptr = readline(inputline, polyfile, b->inpolyfilename); - m->insegments = (int) strtol(stringptr, &stringptr, 0); - stringptr = findfield(stringptr); - if (*stringptr != '\0') { - segmentmarkers = (int) strtol(stringptr, &stringptr, 0); - } -#endif /* not TRILIBRARY */ - - /* Create the subsegments. */ - for (segmentnumber = 1; segmentnumber <= m->insegments; segmentnumber++) { - makesubseg(m, &subsegloop); - /* Mark the subsegment as living. */ - subsegloop.ss[2] = (subseg) subsegloop.ss; - } - } - -#ifdef TRILIBRARY - vertexindex = 0; - attribindex = 0; -#else /* not TRILIBRARY */ - if (b->vararea) { - /* Open an .area file, check for consistency with the .ele file. */ - if (!b->quiet) { - printf("Opening %s.\n", areafilename); - } - areafile = fopen(areafilename, "r"); - if (areafile == (FILE *) NULL) { - printf(" Error: Cannot access file %s.\n", areafilename); - triexit(1); - } - stringptr = readline(inputline, areafile, areafilename); - areaelements = (int) strtol(stringptr, &stringptr, 0); - if (areaelements != m->inelements) { - printf("Error: %s and %s disagree on number of triangles.\n", - elefilename, areafilename); - triexit(1); - } - } -#endif /* not TRILIBRARY */ - - if (!b->quiet) { - printf("Reconstructing mesh.\n"); - } - /* Allocate a temporary array that maps each vertex to some adjacent */ - /* triangle. I took care to allocate all the permanent memory for */ - /* triangles and subsegments first. */ - vertexarray = (triangle *) trimalloc(m->vertices.items * - (int) sizeof(triangle)); - /* Each vertex is initially unrepresented. */ - for (i = 0; i < m->vertices.items; i++) { - vertexarray[i] = (triangle) m->dummytri; - } - - if (b->verbose) { - printf(" Assembling triangles.\n"); - } - /* Read the triangles from the .ele file, and link */ - /* together those that share an edge. */ - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - elementnumber = b->firstnumber; - while (triangleloop.tri != (triangle *) NULL) { -#ifdef TRILIBRARY - /* Copy the triangle's three corners. */ - for (j = 0; j < 3; j++) { - corner[j] = trianglelist[vertexindex++]; - if ((corner[j] < b->firstnumber) || - (corner[j] >= b->firstnumber + m->invertices)) { - printf("Error: Triangle %ld has an invalid vertex index.\n", - elementnumber); - triexit(1); - } - } -#else /* not TRILIBRARY */ - /* Read triangle number and the triangle's three corners. */ - stringptr = readline(inputline, elefile, elefilename); - for (j = 0; j < 3; j++) { - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Triangle %ld is missing vertex %d in %s.\n", - elementnumber, j + 1, elefilename); - triexit(1); - } else { - corner[j] = (int) strtol(stringptr, &stringptr, 0); - if ((corner[j] < b->firstnumber) || - (corner[j] >= b->firstnumber + m->invertices)) { - printf("Error: Triangle %ld has an invalid vertex index.\n", - elementnumber); - triexit(1); - } - } - } -#endif /* not TRILIBRARY */ - - /* Find out about (and throw away) extra nodes. */ - for (j = 3; j < incorners; j++) { -#ifdef TRILIBRARY - killvertexindex = trianglelist[vertexindex++]; -#else /* not TRILIBRARY */ - stringptr = findfield(stringptr); - if (*stringptr != '\0') { - killvertexindex = (int) strtol(stringptr, &stringptr, 0); -#endif /* not TRILIBRARY */ - if ((killvertexindex >= b->firstnumber) && - (killvertexindex < b->firstnumber + m->invertices)) { - /* Delete the non-corner vertex if it's not already deleted. */ - killvertex = getvertex(m, b, killvertexindex); - if (vertextype(killvertex) != DEADVERTEX) { - vertexdealloc(m, killvertex); - } - } -#ifndef TRILIBRARY - } -#endif /* not TRILIBRARY */ - } - - /* Read the triangle's attributes. */ - for (j = 0; j < m->eextras; j++) { -#ifdef TRILIBRARY - setelemattribute(triangleloop, j, triangleattriblist[attribindex++]); -#else /* not TRILIBRARY */ - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - setelemattribute(triangleloop, j, 0); - } else { - setelemattribute(triangleloop, j, - (REAL) strtod(stringptr, &stringptr)); - } -#endif /* not TRILIBRARY */ - } - - if (b->vararea) { -#ifdef TRILIBRARY - area = trianglearealist[elementnumber - b->firstnumber]; -#else /* not TRILIBRARY */ - /* Read an area constraint from the .area file. */ - stringptr = readline(inputline, areafile, areafilename); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - area = -1.0; /* No constraint on this triangle. */ - } else { - area = (REAL) strtod(stringptr, &stringptr); - } -#endif /* not TRILIBRARY */ - setareabound(triangleloop, area); - } - - /* Set the triangle's vertices. */ - triangleloop.orient = 0; - setorg(triangleloop, getvertex(m, b, corner[0])); - setdest(triangleloop, getvertex(m, b, corner[1])); - setapex(triangleloop, getvertex(m, b, corner[2])); - /* Try linking the triangle to others that share these vertices. */ - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - /* Take the number for the origin of triangleloop. */ - aroundvertex = corner[triangleloop.orient]; - /* Look for other triangles having this vertex. */ - nexttri = vertexarray[aroundvertex - b->firstnumber]; - /* Link the current triangle to the next one in the stack. */ - triangleloop.tri[6 + triangleloop.orient] = nexttri; - /* Push the current triangle onto the stack. */ - vertexarray[aroundvertex - b->firstnumber] = encode(triangleloop); - decode(nexttri, checktri); - if (checktri.tri != m->dummytri) { - dest(triangleloop, tdest); - apex(triangleloop, tapex); - /* Look for other triangles that share an edge. */ - do { - dest(checktri, checkdest); - apex(checktri, checkapex); - if (tapex == checkdest) { - /* The two triangles share an edge; bond them together. */ - lprev(triangleloop, triangleleft); - bond(triangleleft, checktri); - } - if (tdest == checkapex) { - /* The two triangles share an edge; bond them together. */ - lprev(checktri, checkleft); - bond(triangleloop, checkleft); - } - /* Find the next triangle in the stack. */ - nexttri = checktri.tri[6 + checktri.orient]; - decode(nexttri, checktri); - } while (checktri.tri != m->dummytri); - } - } - triangleloop.tri = triangletraverse(m); - elementnumber++; - } - -#ifdef TRILIBRARY - vertexindex = 0; -#else /* not TRILIBRARY */ - fclose(elefile); - if (b->vararea) { - fclose(areafile); - } -#endif /* not TRILIBRARY */ - - hullsize = 0; /* Prepare to count the boundary edges. */ - if (b->poly) { - if (b->verbose) { - printf(" Marking segments in triangulation.\n"); - } - /* Read the segments from the .poly file, and link them */ - /* to their neighboring triangles. */ - boundmarker = 0; - traversalinit(&m->subsegs); - subsegloop.ss = subsegtraverse(m); - segmentnumber = b->firstnumber; - while (subsegloop.ss != (subseg *) NULL) { -#ifdef TRILIBRARY - end[0] = segmentlist[vertexindex++]; - end[1] = segmentlist[vertexindex++]; - if (segmentmarkers) { - boundmarker = segmentmarkerlist[segmentnumber - b->firstnumber]; - } -#else /* not TRILIBRARY */ - /* Read the endpoints of each segment, and possibly a boundary marker. */ - stringptr = readline(inputline, polyfile, b->inpolyfilename); - /* Skip the first (segment number) field. */ - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Segment %ld has no endpoints in %s.\n", segmentnumber, - polyfilename); - triexit(1); - } else { - end[0] = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Segment %ld is missing its second endpoint in %s.\n", - segmentnumber, polyfilename); - triexit(1); - } else { - end[1] = (int) strtol(stringptr, &stringptr, 0); - } - if (segmentmarkers) { - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - boundmarker = 0; - } else { - boundmarker = (int) strtol(stringptr, &stringptr, 0); - } - } -#endif /* not TRILIBRARY */ - for (j = 0; j < 2; j++) { - if ((end[j] < b->firstnumber) || - (end[j] >= b->firstnumber + m->invertices)) { - printf("Error: Segment %ld has an invalid vertex index.\n", - segmentnumber); - triexit(1); - } - } - - /* set the subsegment's vertices. */ - subsegloop.ssorient = 0; - segmentorg = getvertex(m, b, end[0]); - segmentdest = getvertex(m, b, end[1]); - setsorg(subsegloop, segmentorg); - setsdest(subsegloop, segmentdest); - setsegorg(subsegloop, segmentorg); - setsegdest(subsegloop, segmentdest); - setmark(subsegloop, boundmarker); - /* Try linking the subsegment to triangles that share these vertices. */ - for (subsegloop.ssorient = 0; subsegloop.ssorient < 2; - subsegloop.ssorient++) { - /* Take the number for the destination of subsegloop. */ - aroundvertex = end[1 - subsegloop.ssorient]; - /* Look for triangles having this vertex. */ - prevlink = &vertexarray[aroundvertex - b->firstnumber]; - nexttri = vertexarray[aroundvertex - b->firstnumber]; - decode(nexttri, checktri); - sorg(subsegloop, shorg); - notfound = 1; - /* Look for triangles having this edge. Note that I'm only */ - /* comparing each triangle's destination with the subsegment; */ - /* each triangle's apex is handled through a different vertex. */ - /* Because each triangle appears on three vertices' lists, each */ - /* occurrence of a triangle on a list can (and does) represent */ - /* an edge. In this way, most edges are represented twice, and */ - /* every triangle-subsegment bond is represented once. */ - while (notfound && (checktri.tri != m->dummytri)) { - dest(checktri, checkdest); - if (shorg == checkdest) { - /* We have a match. Remove this triangle from the list. */ - *prevlink = checktri.tri[6 + checktri.orient]; - /* Bond the subsegment to the triangle. */ - tsbond(checktri, subsegloop); - /* Check if this is a boundary edge. */ - sym(checktri, checkneighbor); - if (checkneighbor.tri == m->dummytri) { - /* The next line doesn't insert a subsegment (because there's */ - /* already one there), but it sets the boundary markers of */ - /* the existing subsegment and its vertices. */ - insertsubseg(m, b, &checktri, 1); - hullsize++; - } - notfound = 0; - } - /* Find the next triangle in the stack. */ - prevlink = &checktri.tri[6 + checktri.orient]; - nexttri = checktri.tri[6 + checktri.orient]; - decode(nexttri, checktri); - } - } - subsegloop.ss = subsegtraverse(m); - segmentnumber++; - } - } - - /* Mark the remaining edges as not being attached to any subsegment. */ - /* Also, count the (yet uncounted) boundary edges. */ - for (i = 0; i < m->vertices.items; i++) { - /* Search the stack of triangles adjacent to a vertex. */ - nexttri = vertexarray[i]; - decode(nexttri, checktri); - while (checktri.tri != m->dummytri) { - /* Find the next triangle in the stack before this */ - /* information gets overwritten. */ - nexttri = checktri.tri[6 + checktri.orient]; - /* No adjacent subsegment. (This overwrites the stack info.) */ - tsdissolve(checktri); - sym(checktri, checkneighbor); - if (checkneighbor.tri == m->dummytri) { - insertsubseg(m, b, &checktri, 1); - hullsize++; - } - decode(nexttri, checktri); - } - } - - trifree((VOID *) vertexarray); - return hullsize; -} - -#endif /* not CDT_ONLY */ - -/** **/ -/** **/ -/********* General mesh construction routines end here *********/ - -/********* Segment insertion begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* finddirection() Find the first triangle on the path from one point */ -/* to another. */ -/* */ -/* Finds the triangle that intersects a line segment drawn from the */ -/* origin of `searchtri' to the point `searchpoint', and returns the result */ -/* in `searchtri'. The origin of `searchtri' does not change, even though */ -/* the triangle returned may differ from the one passed in. This routine */ -/* is used to find the direction to move in to get from one point to */ -/* another. */ -/* */ -/* The return value notes whether the destination or apex of the found */ -/* triangle is collinear with the two points in question. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -enum finddirectionresult finddirection(struct mesh *m, struct behavior *b, - struct otri *searchtri, - vertex searchpoint) -#else /* not ANSI_DECLARATORS */ -enum finddirectionresult finddirection(m, b, searchtri, searchpoint) -struct mesh *m; -struct behavior *b; -struct otri *searchtri; -vertex searchpoint; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri checktri; - vertex startvertex; - vertex leftvertex, rightvertex; - REAL leftccw, rightccw; - int leftflag, rightflag; - triangle ptr; /* Temporary variable used by onext() and oprev(). */ - - org(*searchtri, startvertex); - dest(*searchtri, rightvertex); - apex(*searchtri, leftvertex); - /* Is `searchpoint' to the left? */ - leftccw = counterclockwise(m, b, searchpoint, startvertex, leftvertex); - leftflag = leftccw > 0.0; - /* Is `searchpoint' to the right? */ - rightccw = counterclockwise(m, b, startvertex, searchpoint, rightvertex); - rightflag = rightccw > 0.0; - if (leftflag && rightflag) { - /* `searchtri' faces directly away from `searchpoint'. We could go left */ - /* or right. Ask whether it's a triangle or a boundary on the left. */ - onext(*searchtri, checktri); - if (checktri.tri == m->dummytri) { - leftflag = 0; - } else { - rightflag = 0; - } - } - while (leftflag) { - /* Turn left until satisfied. */ - onextself(*searchtri); - if (searchtri->tri == m->dummytri) { - printf("Internal error in finddirection(): Unable to find a\n"); - printf(" triangle leading from (%.12g, %.12g) to", startvertex[0], - startvertex[1]); - printf(" (%.12g, %.12g).\n", searchpoint[0], searchpoint[1]); - internalerror(); - } - apex(*searchtri, leftvertex); - rightccw = leftccw; - leftccw = counterclockwise(m, b, searchpoint, startvertex, leftvertex); - leftflag = leftccw > 0.0; - } - while (rightflag) { - /* Turn right until satisfied. */ - oprevself(*searchtri); - if (searchtri->tri == m->dummytri) { - printf("Internal error in finddirection(): Unable to find a\n"); - printf(" triangle leading from (%.12g, %.12g) to", startvertex[0], - startvertex[1]); - printf(" (%.12g, %.12g).\n", searchpoint[0], searchpoint[1]); - internalerror(); - } - dest(*searchtri, rightvertex); - leftccw = rightccw; - rightccw = counterclockwise(m, b, startvertex, searchpoint, rightvertex); - rightflag = rightccw > 0.0; - } - if (leftccw == 0.0) { - return LEFTCOLLINEAR; - } else if (rightccw == 0.0) { - return RIGHTCOLLINEAR; - } else { - return WITHIN; - } -} - -/*****************************************************************************/ -/* */ -/* segmentintersection() Find the intersection of an existing segment */ -/* and a segment that is being inserted. Insert */ -/* a vertex at the intersection, splitting an */ -/* existing subsegment. */ -/* */ -/* The segment being inserted connects the apex of splittri to endpoint2. */ -/* splitsubseg is the subsegment being split, and MUST adjoin splittri. */ -/* Hence, endpoints of the subsegment being split are the origin and */ -/* destination of splittri. */ -/* */ -/* On completion, splittri is a handle having the newly inserted */ -/* intersection point as its origin, and endpoint1 as its destination. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void segmentintersection(struct mesh *m, struct behavior *b, - struct otri *splittri, struct osub *splitsubseg, - vertex endpoint2) -#else /* not ANSI_DECLARATORS */ -void segmentintersection(m, b, splittri, splitsubseg, endpoint2) -struct mesh *m; -struct behavior *b; -struct otri *splittri; -struct osub *splitsubseg; -vertex endpoint2; -#endif /* not ANSI_DECLARATORS */ - -{ - struct osub opposubseg; - vertex endpoint1; - vertex torg, tdest; - vertex leftvertex, rightvertex; - vertex newvertex; - enum insertvertexresult success; - enum finddirectionresult collinear; - REAL ex, ey; - REAL tx, ty; - REAL etx, ety; - REAL split, denom; - int i; - triangle ptr; /* Temporary variable used by onext(). */ - subseg sptr; /* Temporary variable used by snext(). */ - - /* Find the other three segment endpoints. */ - apex(*splittri, endpoint1); - org(*splittri, torg); - dest(*splittri, tdest); - /* Segment intersection formulae; see the Antonio reference. */ - tx = tdest[0] - torg[0]; - ty = tdest[1] - torg[1]; - ex = endpoint2[0] - endpoint1[0]; - ey = endpoint2[1] - endpoint1[1]; - etx = torg[0] - endpoint2[0]; - ety = torg[1] - endpoint2[1]; - denom = ty * ex - tx * ey; - if (denom == 0.0) { - printf("Internal error in segmentintersection():"); - printf(" Attempt to find intersection of parallel segments.\n"); - internalerror(); - } - split = (ey * etx - ex * ety) / denom; - /* Create the new vertex. */ - newvertex = (vertex) poolalloc(&m->vertices); - /* Interpolate its coordinate and attributes. */ - for (i = 0; i < 2 + m->nextras; i++) { - newvertex[i] = torg[i] + split * (tdest[i] - torg[i]); - } - setvertexmark(newvertex, mark(*splitsubseg)); - setvertextype(newvertex, INPUTVERTEX); - if (b->verbose > 1) { - printf( - " Splitting subsegment (%.12g, %.12g) (%.12g, %.12g) at (%.12g, %.12g).\n", - torg[0], torg[1], tdest[0], tdest[1], newvertex[0], newvertex[1]); - } - /* Insert the intersection vertex. This should always succeed. */ - success = insertvertex(m, b, newvertex, splittri, splitsubseg, 0, 0); - if (success != SUCCESSFULVERTEX) { - printf("Internal error in segmentintersection():\n"); - printf(" Failure to split a segment.\n"); - internalerror(); - } - /* Record a triangle whose origin is the new vertex. */ - setvertex2tri(newvertex, encode(*splittri)); - if (m->steinerleft > 0) { - m->steinerleft--; - } - - /* Divide the segment into two, and correct the segment endpoints. */ - ssymself(*splitsubseg); - spivot(*splitsubseg, opposubseg); - sdissolve(*splitsubseg); - sdissolve(opposubseg); - do { - setsegorg(*splitsubseg, newvertex); - snextself(*splitsubseg); - } while (splitsubseg->ss != m->dummysub); - do { - setsegorg(opposubseg, newvertex); - snextself(opposubseg); - } while (opposubseg.ss != m->dummysub); - - /* Inserting the vertex may have caused edge flips. We wish to rediscover */ - /* the edge connecting endpoint1 to the new intersection vertex. */ - collinear = finddirection(m, b, splittri, endpoint1); - dest(*splittri, rightvertex); - apex(*splittri, leftvertex); - if ((leftvertex[0] == endpoint1[0]) && (leftvertex[1] == endpoint1[1])) { - onextself(*splittri); - } else if ((rightvertex[0] != endpoint1[0]) || - (rightvertex[1] != endpoint1[1])) { - printf("Internal error in segmentintersection():\n"); - printf(" Topological inconsistency after splitting a segment.\n"); - internalerror(); - } - /* `splittri' should have destination endpoint1. */ -} - -/*****************************************************************************/ -/* */ -/* scoutsegment() Scout the first triangle on the path from one endpoint */ -/* to another, and check for completion (reaching the */ -/* second endpoint), a collinear vertex, or the */ -/* intersection of two segments. */ -/* */ -/* Returns one if the entire segment is successfully inserted, and zero if */ -/* the job must be finished by conformingedge() or constrainededge(). */ -/* */ -/* If the first triangle on the path has the second endpoint as its */ -/* destination or apex, a subsegment is inserted and the job is done. */ -/* */ -/* If the first triangle on the path has a destination or apex that lies on */ -/* the segment, a subsegment is inserted connecting the first endpoint to */ -/* the collinear vertex, and the search is continued from the collinear */ -/* vertex. */ -/* */ -/* If the first triangle on the path has a subsegment opposite its origin, */ -/* then there is a segment that intersects the segment being inserted. */ -/* Their intersection vertex is inserted, splitting the subsegment. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -int scoutsegment(struct mesh *m, struct behavior *b, struct otri *searchtri, - vertex endpoint2, int newmark) -#else /* not ANSI_DECLARATORS */ -int scoutsegment(m, b, searchtri, endpoint2, newmark) -struct mesh *m; -struct behavior *b; -struct otri *searchtri; -vertex endpoint2; -int newmark; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri crosstri; - struct osub crosssubseg; - vertex leftvertex, rightvertex; - enum finddirectionresult collinear; - subseg sptr; /* Temporary variable used by tspivot(). */ - - collinear = finddirection(m, b, searchtri, endpoint2); - dest(*searchtri, rightvertex); - apex(*searchtri, leftvertex); - if (((leftvertex[0] == endpoint2[0]) && (leftvertex[1] == endpoint2[1])) || - ((rightvertex[0] == endpoint2[0]) && (rightvertex[1] == endpoint2[1]))) { - /* The segment is already an edge in the mesh. */ - if ((leftvertex[0] == endpoint2[0]) && (leftvertex[1] == endpoint2[1])) { - lprevself(*searchtri); - } - /* Insert a subsegment, if there isn't already one there. */ - insertsubseg(m, b, searchtri, newmark); - return 1; - } else if (collinear == LEFTCOLLINEAR) { - /* We've collided with a vertex between the segment's endpoints. */ - /* Make the collinear vertex be the triangle's origin. */ - lprevself(*searchtri); - insertsubseg(m, b, searchtri, newmark); - /* Insert the remainder of the segment. */ - return scoutsegment(m, b, searchtri, endpoint2, newmark); - } else if (collinear == RIGHTCOLLINEAR) { - /* We've collided with a vertex between the segment's endpoints. */ - insertsubseg(m, b, searchtri, newmark); - /* Make the collinear vertex be the triangle's origin. */ - lnextself(*searchtri); - /* Insert the remainder of the segment. */ - return scoutsegment(m, b, searchtri, endpoint2, newmark); - } else { - lnext(*searchtri, crosstri); - tspivot(crosstri, crosssubseg); - /* Check for a crossing segment. */ - if (crosssubseg.ss == m->dummysub) { - return 0; - } else { - /* Insert a vertex at the intersection. */ - segmentintersection(m, b, &crosstri, &crosssubseg, endpoint2); - otricopy(crosstri, *searchtri); - insertsubseg(m, b, searchtri, newmark); - /* Insert the remainder of the segment. */ - return scoutsegment(m, b, searchtri, endpoint2, newmark); - } - } -} - -/*****************************************************************************/ -/* */ -/* conformingedge() Force a segment into a conforming Delaunay */ -/* triangulation by inserting a vertex at its midpoint, */ -/* and recursively forcing in the two half-segments if */ -/* necessary. */ -/* */ -/* Generates a sequence of subsegments connecting `endpoint1' to */ -/* `endpoint2'. `newmark' is the boundary marker of the segment, assigned */ -/* to each new splitting vertex and subsegment. */ -/* */ -/* Note that conformingedge() does not always maintain the conforming */ -/* Delaunay property. Once inserted, segments are locked into place; */ -/* vertices inserted later (to force other segments in) may render these */ -/* fixed segments non-Delaunay. The conforming Delaunay property will be */ -/* restored by enforcequality() by splitting encroached subsegments. */ -/* */ -/*****************************************************************************/ - -#ifndef REDUCED -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void conformingedge(struct mesh *m, struct behavior *b, - vertex endpoint1, vertex endpoint2, int newmark) -#else /* not ANSI_DECLARATORS */ -void conformingedge(m, b, endpoint1, endpoint2, newmark) -struct mesh *m; -struct behavior *b; -vertex endpoint1; -vertex endpoint2; -int newmark; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri searchtri1, searchtri2; - struct osub brokensubseg; - vertex newvertex; - vertex midvertex1, midvertex2; - enum insertvertexresult success; - int i; - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (b->verbose > 2) { - printf("Forcing segment into triangulation by recursive splitting:\n"); - printf(" (%.12g, %.12g) (%.12g, %.12g)\n", endpoint1[0], endpoint1[1], - endpoint2[0], endpoint2[1]); - } - /* Create a new vertex to insert in the middle of the segment. */ - newvertex = (vertex) poolalloc(&m->vertices); - /* Interpolate coordinates and attributes. */ - for (i = 0; i < 2 + m->nextras; i++) { - newvertex[i] = 0.5 * (endpoint1[i] + endpoint2[i]); - } - setvertexmark(newvertex, newmark); - setvertextype(newvertex, SEGMENTVERTEX); - /* No known triangle to search from. */ - searchtri1.tri = m->dummytri; - /* Attempt to insert the new vertex. */ - success = insertvertex(m, b, newvertex, &searchtri1, (struct osub *) NULL, - 0, 0); - if (success == DUPLICATEVERTEX) { - if (b->verbose > 2) { - printf(" Segment intersects existing vertex (%.12g, %.12g).\n", - newvertex[0], newvertex[1]); - } - /* Use the vertex that's already there. */ - vertexdealloc(m, newvertex); - org(searchtri1, newvertex); - } else { - if (success == VIOLATINGVERTEX) { - if (b->verbose > 2) { - printf(" Two segments intersect at (%.12g, %.12g).\n", - newvertex[0], newvertex[1]); - } - /* By fluke, we've landed right on another segment. Split it. */ - tspivot(searchtri1, brokensubseg); - success = insertvertex(m, b, newvertex, &searchtri1, &brokensubseg, - 0, 0); - if (success != SUCCESSFULVERTEX) { - printf("Internal error in conformingedge():\n"); - printf(" Failure to split a segment.\n"); - internalerror(); - } - } - /* The vertex has been inserted successfully. */ - if (m->steinerleft > 0) { - m->steinerleft--; - } - } - otricopy(searchtri1, searchtri2); - /* `searchtri1' and `searchtri2' are fastened at their origins to */ - /* `newvertex', and will be directed toward `endpoint1' and `endpoint2' */ - /* respectively. First, we must get `searchtri2' out of the way so it */ - /* won't be invalidated during the insertion of the first half of the */ - /* segment. */ - finddirection(m, b, &searchtri2, endpoint2); - if (!scoutsegment(m, b, &searchtri1, endpoint1, newmark)) { - /* The origin of searchtri1 may have changed if a collision with an */ - /* intervening vertex on the segment occurred. */ - org(searchtri1, midvertex1); - conformingedge(m, b, midvertex1, endpoint1, newmark); - } - if (!scoutsegment(m, b, &searchtri2, endpoint2, newmark)) { - /* The origin of searchtri2 may have changed if a collision with an */ - /* intervening vertex on the segment occurred. */ - org(searchtri2, midvertex2); - conformingedge(m, b, midvertex2, endpoint2, newmark); - } -} - -#endif /* not CDT_ONLY */ -#endif /* not REDUCED */ - -/*****************************************************************************/ -/* */ -/* delaunayfixup() Enforce the Delaunay condition at an edge, fanning out */ -/* recursively from an existing vertex. Pay special */ -/* attention to stacking inverted triangles. */ -/* */ -/* This is a support routine for inserting segments into a constrained */ -/* Delaunay triangulation. */ -/* */ -/* The origin of fixuptri is treated as if it has just been inserted, and */ -/* the local Delaunay condition needs to be enforced. It is only enforced */ -/* in one sector, however, that being the angular range defined by */ -/* fixuptri. */ -/* */ -/* This routine also needs to make decisions regarding the "stacking" of */ -/* triangles. (Read the description of constrainededge() below before */ -/* reading on here, so you understand the algorithm.) If the position of */ -/* the new vertex (the origin of fixuptri) indicates that the vertex before */ -/* it on the polygon is a reflex vertex, then "stack" the triangle by */ -/* doing nothing. (fixuptri is an inverted triangle, which is how stacked */ -/* triangles are identified.) */ -/* */ -/* Otherwise, check whether the vertex before that was a reflex vertex. */ -/* If so, perform an edge flip, thereby eliminating an inverted triangle */ -/* (popping it off the stack). The edge flip may result in the creation */ -/* of a new inverted triangle, depending on whether or not the new vertex */ -/* is visible to the vertex three edges behind on the polygon. */ -/* */ -/* If neither of the two vertices behind the new vertex are reflex */ -/* vertices, fixuptri and fartri, the triangle opposite it, are not */ -/* inverted; hence, ensure that the edge between them is locally Delaunay. */ -/* */ -/* `leftside' indicates whether or not fixuptri is to the left of the */ -/* segment being inserted. (Imagine that the segment is pointing up from */ -/* endpoint1 to endpoint2.) */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void delaunayfixup(struct mesh *m, struct behavior *b, - struct otri *fixuptri, int leftside) -#else /* not ANSI_DECLARATORS */ -void delaunayfixup(m, b, fixuptri, leftside) -struct mesh *m; -struct behavior *b; -struct otri *fixuptri; -int leftside; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri neartri; - struct otri fartri; - struct osub faredge; - vertex nearvertex, leftvertex, rightvertex, farvertex; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - lnext(*fixuptri, neartri); - sym(neartri, fartri); - /* Check if the edge opposite the origin of fixuptri can be flipped. */ - if (fartri.tri == m->dummytri) { - return; - } - tspivot(neartri, faredge); - if (faredge.ss != m->dummysub) { - return; - } - /* Find all the relevant vertices. */ - apex(neartri, nearvertex); - org(neartri, leftvertex); - dest(neartri, rightvertex); - apex(fartri, farvertex); - /* Check whether the previous polygon vertex is a reflex vertex. */ - if (leftside) { - if (counterclockwise(m, b, nearvertex, leftvertex, farvertex) <= 0.0) { - /* leftvertex is a reflex vertex too. Nothing can */ - /* be done until a convex section is found. */ - return; - } - } else { - if (counterclockwise(m, b, farvertex, rightvertex, nearvertex) <= 0.0) { - /* rightvertex is a reflex vertex too. Nothing can */ - /* be done until a convex section is found. */ - return; - } - } - if (counterclockwise(m, b, rightvertex, leftvertex, farvertex) > 0.0) { - /* fartri is not an inverted triangle, and farvertex is not a reflex */ - /* vertex. As there are no reflex vertices, fixuptri isn't an */ - /* inverted triangle, either. Hence, test the edge between the */ - /* triangles to ensure it is locally Delaunay. */ - if (incircle(m, b, leftvertex, farvertex, rightvertex, nearvertex) <= - 0.0) { - return; - } - /* Not locally Delaunay; go on to an edge flip. */ - } /* else fartri is inverted; remove it from the stack by flipping. */ - flip(m, b, &neartri); - lprevself(*fixuptri); /* Restore the origin of fixuptri after the flip. */ - /* Recursively process the two triangles that result from the flip. */ - delaunayfixup(m, b, fixuptri, leftside); - delaunayfixup(m, b, &fartri, leftside); -} - -/*****************************************************************************/ -/* */ -/* constrainededge() Force a segment into a constrained Delaunay */ -/* triangulation by deleting the triangles it */ -/* intersects, and triangulating the polygons that */ -/* form on each side of it. */ -/* */ -/* Generates a single subsegment connecting `endpoint1' to `endpoint2'. */ -/* The triangle `starttri' has `endpoint1' as its origin. `newmark' is the */ -/* boundary marker of the segment. */ -/* */ -/* To insert a segment, every triangle whose interior intersects the */ -/* segment is deleted. The union of these deleted triangles is a polygon */ -/* (which is not necessarily monotone, but is close enough), which is */ -/* divided into two polygons by the new segment. This routine's task is */ -/* to generate the Delaunay triangulation of these two polygons. */ -/* */ -/* You might think of this routine's behavior as a two-step process. The */ -/* first step is to walk from endpoint1 to endpoint2, flipping each edge */ -/* encountered. This step creates a fan of edges connected to endpoint1, */ -/* including the desired edge to endpoint2. The second step enforces the */ -/* Delaunay condition on each side of the segment in an incremental manner: */ -/* proceeding along the polygon from endpoint1 to endpoint2 (this is done */ -/* independently on each side of the segment), each vertex is "enforced" */ -/* as if it had just been inserted, but affecting only the previous */ -/* vertices. The result is the same as if the vertices had been inserted */ -/* in the order they appear on the polygon, so the result is Delaunay. */ -/* */ -/* In truth, constrainededge() interleaves these two steps. The procedure */ -/* walks from endpoint1 to endpoint2, and each time an edge is encountered */ -/* and flipped, the newly exposed vertex (at the far end of the flipped */ -/* edge) is "enforced" upon the previously flipped edges, usually affecting */ -/* only one side of the polygon (depending upon which side of the segment */ -/* the vertex falls on). */ -/* */ -/* The algorithm is complicated by the need to handle polygons that are not */ -/* convex. Although the polygon is not necessarily monotone, it can be */ -/* triangulated in a manner similar to the stack-based algorithms for */ -/* monotone polygons. For each reflex vertex (local concavity) of the */ -/* polygon, there will be an inverted triangle formed by one of the edge */ -/* flips. (An inverted triangle is one with negative area - that is, its */ -/* vertices are arranged in clockwise order - and is best thought of as a */ -/* wrinkle in the fabric of the mesh.) Each inverted triangle can be */ -/* thought of as a reflex vertex pushed on the stack, waiting to be fixed */ -/* later. */ -/* */ -/* A reflex vertex is popped from the stack when a vertex is inserted that */ -/* is visible to the reflex vertex. (However, if the vertex behind the */ -/* reflex vertex is not visible to the reflex vertex, a new inverted */ -/* triangle will take its place on the stack.) These details are handled */ -/* by the delaunayfixup() routine above. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void constrainededge(struct mesh *m, struct behavior *b, - struct otri *starttri, vertex endpoint2, int newmark) -#else /* not ANSI_DECLARATORS */ -void constrainededge(m, b, starttri, endpoint2, newmark) -struct mesh *m; -struct behavior *b; -struct otri *starttri; -vertex endpoint2; -int newmark; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri fixuptri, fixuptri2; - struct osub crosssubseg; - vertex endpoint1; - vertex farvertex; - REAL area; - int collision; - int done; - triangle ptr; /* Temporary variable used by sym() and oprev(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - org(*starttri, endpoint1); - lnext(*starttri, fixuptri); - flip(m, b, &fixuptri); - /* `collision' indicates whether we have found a vertex directly */ - /* between endpoint1 and endpoint2. */ - collision = 0; - done = 0; - do { - org(fixuptri, farvertex); - /* `farvertex' is the extreme point of the polygon we are "digging" */ - /* to get from endpoint1 to endpoint2. */ - if ((farvertex[0] == endpoint2[0]) && (farvertex[1] == endpoint2[1])) { - oprev(fixuptri, fixuptri2); - /* Enforce the Delaunay condition around endpoint2. */ - delaunayfixup(m, b, &fixuptri, 0); - delaunayfixup(m, b, &fixuptri2, 1); - done = 1; - } else { - /* Check whether farvertex is to the left or right of the segment */ - /* being inserted, to decide which edge of fixuptri to dig */ - /* through next. */ - area = counterclockwise(m, b, endpoint1, endpoint2, farvertex); - if (area == 0.0) { - /* We've collided with a vertex between endpoint1 and endpoint2. */ - collision = 1; - oprev(fixuptri, fixuptri2); - /* Enforce the Delaunay condition around farvertex. */ - delaunayfixup(m, b, &fixuptri, 0); - delaunayfixup(m, b, &fixuptri2, 1); - done = 1; - } else { - if (area > 0.0) { /* farvertex is to the left of the segment. */ - oprev(fixuptri, fixuptri2); - /* Enforce the Delaunay condition around farvertex, on the */ - /* left side of the segment only. */ - delaunayfixup(m, b, &fixuptri2, 1); - /* Flip the edge that crosses the segment. After the edge is */ - /* flipped, one of its endpoints is the fan vertex, and the */ - /* destination of fixuptri is the fan vertex. */ - lprevself(fixuptri); - } else { /* farvertex is to the right of the segment. */ - delaunayfixup(m, b, &fixuptri, 0); - /* Flip the edge that crosses the segment. After the edge is */ - /* flipped, one of its endpoints is the fan vertex, and the */ - /* destination of fixuptri is the fan vertex. */ - oprevself(fixuptri); - } - /* Check for two intersecting segments. */ - tspivot(fixuptri, crosssubseg); - if (crosssubseg.ss == m->dummysub) { - flip(m, b, &fixuptri); /* May create inverted triangle at left. */ - } else { - /* We've collided with a segment between endpoint1 and endpoint2. */ - collision = 1; - /* Insert a vertex at the intersection. */ - segmentintersection(m, b, &fixuptri, &crosssubseg, endpoint2); - done = 1; - } - } - } - } while (!done); - /* Insert a subsegment to make the segment permanent. */ - insertsubseg(m, b, &fixuptri, newmark); - /* If there was a collision with an interceding vertex, install another */ - /* segment connecting that vertex with endpoint2. */ - if (collision) { - /* Insert the remainder of the segment. */ - if (!scoutsegment(m, b, &fixuptri, endpoint2, newmark)) { - constrainededge(m, b, &fixuptri, endpoint2, newmark); - } - } -} - -/*****************************************************************************/ -/* */ -/* insertsegment() Insert a PSLG segment into a triangulation. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void insertsegment(struct mesh *m, struct behavior *b, - vertex endpoint1, vertex endpoint2, int newmark) -#else /* not ANSI_DECLARATORS */ -void insertsegment(m, b, endpoint1, endpoint2, newmark) -struct mesh *m; -struct behavior *b; -vertex endpoint1; -vertex endpoint2; -int newmark; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri searchtri1, searchtri2; - triangle encodedtri; - vertex checkvertex; - triangle ptr; /* Temporary variable used by sym(). */ - - if (b->verbose > 1) { - printf(" Connecting (%.12g, %.12g) to (%.12g, %.12g).\n", - endpoint1[0], endpoint1[1], endpoint2[0], endpoint2[1]); - } - - /* Find a triangle whose origin is the segment's first endpoint. */ - checkvertex = (vertex) NULL; - encodedtri = vertex2tri(endpoint1); - if (encodedtri != (triangle) NULL) { - decode(encodedtri, searchtri1); - org(searchtri1, checkvertex); - } - if (checkvertex != endpoint1) { - /* Find a boundary triangle to search from. */ - searchtri1.tri = m->dummytri; - searchtri1.orient = 0; - symself(searchtri1); - /* Search for the segment's first endpoint by point location. */ - if (locate(m, b, endpoint1, &searchtri1) != ONVERTEX) { - printf( - "Internal error in insertsegment(): Unable to locate PSLG vertex\n"); - printf(" (%.12g, %.12g) in triangulation.\n", - endpoint1[0], endpoint1[1]); - internalerror(); - } - } - /* Remember this triangle to improve subsequent point location. */ - otricopy(searchtri1, m->recenttri); - /* Scout the beginnings of a path from the first endpoint */ - /* toward the second. */ - if (scoutsegment(m, b, &searchtri1, endpoint2, newmark)) { - /* The segment was easily inserted. */ - return; - } - /* The first endpoint may have changed if a collision with an intervening */ - /* vertex on the segment occurred. */ - org(searchtri1, endpoint1); - - /* Find a triangle whose origin is the segment's second endpoint. */ - checkvertex = (vertex) NULL; - encodedtri = vertex2tri(endpoint2); - if (encodedtri != (triangle) NULL) { - decode(encodedtri, searchtri2); - org(searchtri2, checkvertex); - } - if (checkvertex != endpoint2) { - /* Find a boundary triangle to search from. */ - searchtri2.tri = m->dummytri; - searchtri2.orient = 0; - symself(searchtri2); - /* Search for the segment's second endpoint by point location. */ - if (locate(m, b, endpoint2, &searchtri2) != ONVERTEX) { - printf( - "Internal error in insertsegment(): Unable to locate PSLG vertex\n"); - printf(" (%.12g, %.12g) in triangulation.\n", - endpoint2[0], endpoint2[1]); - internalerror(); - } - } - /* Remember this triangle to improve subsequent point location. */ - otricopy(searchtri2, m->recenttri); - /* Scout the beginnings of a path from the second endpoint */ - /* toward the first. */ - if (scoutsegment(m, b, &searchtri2, endpoint1, newmark)) { - /* The segment was easily inserted. */ - return; - } - /* The second endpoint may have changed if a collision with an intervening */ - /* vertex on the segment occurred. */ - org(searchtri2, endpoint2); - -#ifndef REDUCED -#ifndef CDT_ONLY - if (b->splitseg) { - /* Insert vertices to force the segment into the triangulation. */ - conformingedge(m, b, endpoint1, endpoint2, newmark); - } else { -#endif /* not CDT_ONLY */ -#endif /* not REDUCED */ - /* Insert the segment directly into the triangulation. */ - constrainededge(m, b, &searchtri1, endpoint2, newmark); -#ifndef REDUCED -#ifndef CDT_ONLY - } -#endif /* not CDT_ONLY */ -#endif /* not REDUCED */ -} - -/*****************************************************************************/ -/* */ -/* markhull() Cover the convex hull of a triangulation with subsegments. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void markhull(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void markhull(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri hulltri; - struct otri nexttri; - struct otri starttri; - triangle ptr; /* Temporary variable used by sym() and oprev(). */ - - /* Find a triangle handle on the hull. */ - hulltri.tri = m->dummytri; - hulltri.orient = 0; - symself(hulltri); - /* Remember where we started so we know when to stop. */ - otricopy(hulltri, starttri); - /* Go once counterclockwise around the convex hull. */ - do { - /* Create a subsegment if there isn't already one here. */ - insertsubseg(m, b, &hulltri, 1); - /* To find the next hull edge, go clockwise around the next vertex. */ - lnextself(hulltri); - oprev(hulltri, nexttri); - while (nexttri.tri != m->dummytri) { - otricopy(nexttri, hulltri); - oprev(hulltri, nexttri); - } - } while (!otriequal(hulltri, starttri)); -} - -/*****************************************************************************/ -/* */ -/* formskeleton() Create the segments of a triangulation, including PSLG */ -/* segments and edges on the convex hull. */ -/* */ -/* The PSLG segments are read from a .poly file. The return value is the */ -/* number of segments in the file. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void formskeleton(struct mesh *m, struct behavior *b, int *segmentlist, - int *segmentmarkerlist, int numberofsegments) -#else /* not ANSI_DECLARATORS */ -void formskeleton(m, b, segmentlist, segmentmarkerlist, numberofsegments) -struct mesh *m; -struct behavior *b; -int *segmentlist; -int *segmentmarkerlist; -int numberofsegments; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void formskeleton(struct mesh *m, struct behavior *b, - FILE *polyfile, char *polyfilename) -#else /* not ANSI_DECLARATORS */ -void formskeleton(m, b, polyfile, polyfilename) -struct mesh *m; -struct behavior *b; -FILE *polyfile; -char *polyfilename; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - char polyfilename[6]; - int index; -#else /* not TRILIBRARY */ - char inputline[INPUTLINESIZE]; - char *stringptr; -#endif /* not TRILIBRARY */ - vertex endpoint1, endpoint2; - int segmentmarkers; - int end1, end2; - int boundmarker; - int i; - - if (b->poly) { - if (!b->quiet) { - printf("Recovering segments in Delaunay triangulation.\n"); - } -#ifdef TRILIBRARY - strcpy(polyfilename, "input"); - m->insegments = numberofsegments; - segmentmarkers = segmentmarkerlist != (int *) NULL; - index = 0; -#else /* not TRILIBRARY */ - /* Read the segments from a .poly file. */ - /* Read number of segments and number of boundary markers. */ - stringptr = readline(inputline, polyfile, polyfilename); - m->insegments = (int) strtol(stringptr, &stringptr, 0); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - segmentmarkers = 0; - } else { - segmentmarkers = (int) strtol(stringptr, &stringptr, 0); - } -#endif /* not TRILIBRARY */ - /* If the input vertices are collinear, there is no triangulation, */ - /* so don't try to insert segments. */ - if (m->triangles.items == 0) { - return; - } - - /* If segments are to be inserted, compute a mapping */ - /* from vertices to triangles. */ - if (m->insegments > 0) { - makevertexmap(m, b); - if (b->verbose) { - printf(" Recovering PSLG segments.\n"); - } - } - - boundmarker = 0; - /* Read and insert the segments. */ - for (i = 0; i < m->insegments; i++) { -#ifdef TRILIBRARY - end1 = segmentlist[index++]; - end2 = segmentlist[index++]; - if (segmentmarkers) { - boundmarker = segmentmarkerlist[i]; - } -#else /* not TRILIBRARY */ - stringptr = readline(inputline, polyfile, b->inpolyfilename); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Segment %d has no endpoints in %s.\n", - b->firstnumber + i, polyfilename); - triexit(1); - } else { - end1 = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Segment %d is missing its second endpoint in %s.\n", - b->firstnumber + i, polyfilename); - triexit(1); - } else { - end2 = (int) strtol(stringptr, &stringptr, 0); - } - if (segmentmarkers) { - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - boundmarker = 0; - } else { - boundmarker = (int) strtol(stringptr, &stringptr, 0); - } - } -#endif /* not TRILIBRARY */ - if ((end1 < b->firstnumber) || - (end1 >= b->firstnumber + m->invertices)) { - if (!b->quiet) { - printf("Warning: Invalid first endpoint of segment %d in %s.\n", - b->firstnumber + i, polyfilename); - } - } else if ((end2 < b->firstnumber) || - (end2 >= b->firstnumber + m->invertices)) { - if (!b->quiet) { - printf("Warning: Invalid second endpoint of segment %d in %s.\n", - b->firstnumber + i, polyfilename); - } - } else { - /* Find the vertices numbered `end1' and `end2'. */ - endpoint1 = getvertex(m, b, end1); - endpoint2 = getvertex(m, b, end2); - if ((endpoint1[0] == endpoint2[0]) && (endpoint1[1] == endpoint2[1])) { - if (!b->quiet) { - printf("Warning: Endpoints of segment %d are coincident in %s.\n", - b->firstnumber + i, polyfilename); - } - } else { - insertsegment(m, b, endpoint1, endpoint2, boundmarker); - } - } - } - } else { - m->insegments = 0; - } - if (b->convex || !b->poly) { - /* Enclose the convex hull with subsegments. */ - if (b->verbose) { - printf(" Enclosing convex hull with segments.\n"); - } - markhull(m, b); - } -} - -/** **/ -/** **/ -/********* Segment insertion ends here *********/ - -/********* Carving out holes and concavities begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* infecthull() Virally infect all of the triangles of the convex hull */ -/* that are not protected by subsegments. Where there are */ -/* subsegments, set boundary markers as appropriate. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void infecthull(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void infecthull(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri hulltri; - struct otri nexttri; - struct otri starttri; - struct osub hullsubseg; - triangle **deadtriangle; - vertex horg, hdest; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (b->verbose) { - printf(" Marking concavities (external triangles) for elimination.\n"); - } - /* Find a triangle handle on the hull. */ - hulltri.tri = m->dummytri; - hulltri.orient = 0; - symself(hulltri); - /* Remember where we started so we know when to stop. */ - otricopy(hulltri, starttri); - /* Go once counterclockwise around the convex hull. */ - do { - /* Ignore triangles that are already infected. */ - if (!infected(hulltri)) { - /* Is the triangle protected by a subsegment? */ - tspivot(hulltri, hullsubseg); - if (hullsubseg.ss == m->dummysub) { - /* The triangle is not protected; infect it. */ - if (!infected(hulltri)) { - infect(hulltri); - deadtriangle = (triangle **) poolalloc(&m->viri); - *deadtriangle = hulltri.tri; - } - } else { - /* The triangle is protected; set boundary markers if appropriate. */ - if (mark(hullsubseg) == 0) { - setmark(hullsubseg, 1); - org(hulltri, horg); - dest(hulltri, hdest); - if (vertexmark(horg) == 0) { - setvertexmark(horg, 1); - } - if (vertexmark(hdest) == 0) { - setvertexmark(hdest, 1); - } - } - } - } - /* To find the next hull edge, go clockwise around the next vertex. */ - lnextself(hulltri); - oprev(hulltri, nexttri); - while (nexttri.tri != m->dummytri) { - otricopy(nexttri, hulltri); - oprev(hulltri, nexttri); - } - } while (!otriequal(hulltri, starttri)); -} - -/*****************************************************************************/ -/* */ -/* plague() Spread the virus from all infected triangles to any neighbors */ -/* not protected by subsegments. Delete all infected triangles. */ -/* */ -/* This is the procedure that actually creates holes and concavities. */ -/* */ -/* This procedure operates in two phases. The first phase identifies all */ -/* the triangles that will die, and marks them as infected. They are */ -/* marked to ensure that each triangle is added to the virus pool only */ -/* once, so the procedure will terminate. */ -/* */ -/* The second phase actually eliminates the infected triangles. It also */ -/* eliminates orphaned vertices. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void plague(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void plague(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri testtri; - struct otri neighbor; - triangle **virusloop; - triangle **deadtriangle; - struct osub neighborsubseg; - vertex testvertex; - vertex norg, ndest; - vertex deadorg, deaddest, deadapex; - int killorg; - triangle ptr; /* Temporary variable used by sym() and onext(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (b->verbose) { - printf(" Marking neighbors of marked triangles.\n"); - } - /* Loop through all the infected triangles, spreading the virus to */ - /* their neighbors, then to their neighbors' neighbors. */ - traversalinit(&m->viri); - virusloop = (triangle **) traverse(&m->viri); - while (virusloop != (triangle **) NULL) { - testtri.tri = *virusloop; - /* A triangle is marked as infected by messing with one of its pointers */ - /* to subsegments, setting it to an illegal value. Hence, we have to */ - /* temporarily uninfect this triangle so that we can examine its */ - /* adjacent subsegments. */ - uninfect(testtri); - if (b->verbose > 2) { - /* Assign the triangle an orientation for convenience in */ - /* checking its vertices. */ - testtri.orient = 0; - org(testtri, deadorg); - dest(testtri, deaddest); - apex(testtri, deadapex); - printf(" Checking (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - deadorg[0], deadorg[1], deaddest[0], deaddest[1], - deadapex[0], deadapex[1]); - } - /* Check each of the triangle's three neighbors. */ - for (testtri.orient = 0; testtri.orient < 3; testtri.orient++) { - /* Find the neighbor. */ - sym(testtri, neighbor); - /* Check for a subsegment between the triangle and its neighbor. */ - tspivot(testtri, neighborsubseg); - /* Check if the neighbor is nonexistent or already infected. */ - if ((neighbor.tri == m->dummytri) || infected(neighbor)) { - if (neighborsubseg.ss != m->dummysub) { - /* There is a subsegment separating the triangle from its */ - /* neighbor, but both triangles are dying, so the subsegment */ - /* dies too. */ - subsegdealloc(m, neighborsubseg.ss); - if (neighbor.tri != m->dummytri) { - /* Make sure the subsegment doesn't get deallocated again */ - /* later when the infected neighbor is visited. */ - uninfect(neighbor); - tsdissolve(neighbor); - infect(neighbor); - } - } - } else { /* The neighbor exists and is not infected. */ - if (neighborsubseg.ss == m->dummysub) { - /* There is no subsegment protecting the neighbor, so */ - /* the neighbor becomes infected. */ - if (b->verbose > 2) { - org(neighbor, deadorg); - dest(neighbor, deaddest); - apex(neighbor, deadapex); - printf( - " Marking (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - deadorg[0], deadorg[1], deaddest[0], deaddest[1], - deadapex[0], deadapex[1]); - } - infect(neighbor); - /* Ensure that the neighbor's neighbors will be infected. */ - deadtriangle = (triangle **) poolalloc(&m->viri); - *deadtriangle = neighbor.tri; - } else { /* The neighbor is protected by a subsegment. */ - /* Remove this triangle from the subsegment. */ - stdissolve(neighborsubseg); - /* The subsegment becomes a boundary. Set markers accordingly. */ - if (mark(neighborsubseg) == 0) { - setmark(neighborsubseg, 1); - } - org(neighbor, norg); - dest(neighbor, ndest); - if (vertexmark(norg) == 0) { - setvertexmark(norg, 1); - } - if (vertexmark(ndest) == 0) { - setvertexmark(ndest, 1); - } - } - } - } - /* Remark the triangle as infected, so it doesn't get added to the */ - /* virus pool again. */ - infect(testtri); - virusloop = (triangle **) traverse(&m->viri); - } - - if (b->verbose) { - printf(" Deleting marked triangles.\n"); - } - - traversalinit(&m->viri); - virusloop = (triangle **) traverse(&m->viri); - while (virusloop != (triangle **) NULL) { - testtri.tri = *virusloop; - - /* Check each of the three corners of the triangle for elimination. */ - /* This is done by walking around each vertex, checking if it is */ - /* still connected to at least one live triangle. */ - for (testtri.orient = 0; testtri.orient < 3; testtri.orient++) { - org(testtri, testvertex); - /* Check if the vertex has already been tested. */ - if (testvertex != (vertex) NULL) { - killorg = 1; - /* Mark the corner of the triangle as having been tested. */ - setorg(testtri, NULL); - /* Walk counterclockwise about the vertex. */ - onext(testtri, neighbor); - /* Stop upon reaching a boundary or the starting triangle. */ - while ((neighbor.tri != m->dummytri) && - (!otriequal(neighbor, testtri))) { - if (infected(neighbor)) { - /* Mark the corner of this triangle as having been tested. */ - setorg(neighbor, NULL); - } else { - /* A live triangle. The vertex survives. */ - killorg = 0; - } - /* Walk counterclockwise about the vertex. */ - onextself(neighbor); - } - /* If we reached a boundary, we must walk clockwise as well. */ - if (neighbor.tri == m->dummytri) { - /* Walk clockwise about the vertex. */ - oprev(testtri, neighbor); - /* Stop upon reaching a boundary. */ - while (neighbor.tri != m->dummytri) { - if (infected(neighbor)) { - /* Mark the corner of this triangle as having been tested. */ - setorg(neighbor, NULL); - } else { - /* A live triangle. The vertex survives. */ - killorg = 0; - } - /* Walk clockwise about the vertex. */ - oprevself(neighbor); - } - } - if (killorg) { - if (b->verbose > 1) { - printf(" Deleting vertex (%.12g, %.12g)\n", - testvertex[0], testvertex[1]); - } - setvertextype(testvertex, UNDEADVERTEX); - m->undeads++; - } - } - } - - /* Record changes in the number of boundary edges, and disconnect */ - /* dead triangles from their neighbors. */ - for (testtri.orient = 0; testtri.orient < 3; testtri.orient++) { - sym(testtri, neighbor); - if (neighbor.tri == m->dummytri) { - /* There is no neighboring triangle on this edge, so this edge */ - /* is a boundary edge. This triangle is being deleted, so this */ - /* boundary edge is deleted. */ - m->hullsize--; - } else { - /* Disconnect the triangle from its neighbor. */ - dissolve(neighbor); - /* There is a neighboring triangle on this edge, so this edge */ - /* becomes a boundary edge when this triangle is deleted. */ - m->hullsize++; - } - } - /* Return the dead triangle to the pool of triangles. */ - triangledealloc(m, testtri.tri); - virusloop = (triangle **) traverse(&m->viri); - } - /* Empty the virus pool. */ - poolrestart(&m->viri); -} - -/*****************************************************************************/ -/* */ -/* regionplague() Spread regional attributes and/or area constraints */ -/* (from a .poly file) throughout the mesh. */ -/* */ -/* This procedure operates in two phases. The first phase spreads an */ -/* attribute and/or an area constraint through a (segment-bounded) region. */ -/* The triangles are marked to ensure that each triangle is added to the */ -/* virus pool only once, so the procedure will terminate. */ -/* */ -/* The second phase uninfects all infected triangles, returning them to */ -/* normal. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void regionplague(struct mesh *m, struct behavior *b, - REAL attribute, REAL area) -#else /* not ANSI_DECLARATORS */ -void regionplague(m, b, attribute, area) -struct mesh *m; -struct behavior *b; -REAL attribute; -REAL area; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri testtri; - struct otri neighbor; - triangle **virusloop; - triangle **regiontri; - struct osub neighborsubseg; - vertex regionorg, regiondest, regionapex; - triangle ptr; /* Temporary variable used by sym() and onext(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (b->verbose > 1) { - printf(" Marking neighbors of marked triangles.\n"); - } - /* Loop through all the infected triangles, spreading the attribute */ - /* and/or area constraint to their neighbors, then to their neighbors' */ - /* neighbors. */ - traversalinit(&m->viri); - virusloop = (triangle **) traverse(&m->viri); - while (virusloop != (triangle **) NULL) { - testtri.tri = *virusloop; - /* A triangle is marked as infected by messing with one of its pointers */ - /* to subsegments, setting it to an illegal value. Hence, we have to */ - /* temporarily uninfect this triangle so that we can examine its */ - /* adjacent subsegments. */ - uninfect(testtri); - if (b->regionattrib) { - /* Set an attribute. */ - setelemattribute(testtri, m->eextras, attribute); - } - if (b->vararea) { - /* Set an area constraint. */ - setareabound(testtri, area); - } - if (b->verbose > 2) { - /* Assign the triangle an orientation for convenience in */ - /* checking its vertices. */ - testtri.orient = 0; - org(testtri, regionorg); - dest(testtri, regiondest); - apex(testtri, regionapex); - printf(" Checking (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - regionorg[0], regionorg[1], regiondest[0], regiondest[1], - regionapex[0], regionapex[1]); - } - /* Check each of the triangle's three neighbors. */ - for (testtri.orient = 0; testtri.orient < 3; testtri.orient++) { - /* Find the neighbor. */ - sym(testtri, neighbor); - /* Check for a subsegment between the triangle and its neighbor. */ - tspivot(testtri, neighborsubseg); - /* Make sure the neighbor exists, is not already infected, and */ - /* isn't protected by a subsegment. */ - if ((neighbor.tri != m->dummytri) && !infected(neighbor) - && (neighborsubseg.ss == m->dummysub)) { - if (b->verbose > 2) { - org(neighbor, regionorg); - dest(neighbor, regiondest); - apex(neighbor, regionapex); - printf(" Marking (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - regionorg[0], regionorg[1], regiondest[0], regiondest[1], - regionapex[0], regionapex[1]); - } - /* Infect the neighbor. */ - infect(neighbor); - /* Ensure that the neighbor's neighbors will be infected. */ - regiontri = (triangle **) poolalloc(&m->viri); - *regiontri = neighbor.tri; - } - } - /* Remark the triangle as infected, so it doesn't get added to the */ - /* virus pool again. */ - infect(testtri); - virusloop = (triangle **) traverse(&m->viri); - } - - /* Uninfect all triangles. */ - if (b->verbose > 1) { - printf(" Unmarking marked triangles.\n"); - } - traversalinit(&m->viri); - virusloop = (triangle **) traverse(&m->viri); - while (virusloop != (triangle **) NULL) { - testtri.tri = *virusloop; - uninfect(testtri); - virusloop = (triangle **) traverse(&m->viri); - } - /* Empty the virus pool. */ - poolrestart(&m->viri); -} - -/*****************************************************************************/ -/* */ -/* carveholes() Find the holes and infect them. Find the area */ -/* constraints and infect them. Infect the convex hull. */ -/* Spread the infection and kill triangles. Spread the */ -/* area constraints. */ -/* */ -/* This routine mainly calls other routines to carry out all these */ -/* functions. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void carveholes(struct mesh *m, struct behavior *b, REAL *holelist, int holes, - REAL *regionlist, int regions) -#else /* not ANSI_DECLARATORS */ -void carveholes(m, b, holelist, holes, regionlist, regions) -struct mesh *m; -struct behavior *b; -REAL *holelist; -int holes; -REAL *regionlist; -int regions; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri searchtri; - struct otri triangleloop; - struct otri *regiontris; - triangle **holetri; - triangle **regiontri; - vertex searchorg, searchdest; - enum locateresult intersect; - int i; - triangle ptr; /* Temporary variable used by sym(). */ - - if (!(b->quiet || (b->noholes && b->convex))) { - printf("Removing unwanted triangles.\n"); - if (b->verbose && (holes > 0)) { - printf(" Marking holes for elimination.\n"); - } - } - - if (regions > 0) { - /* Allocate storage for the triangles in which region points fall. */ - regiontris = (struct otri *) trimalloc(regions * - (int) sizeof(struct otri)); - } else { - regiontris = (struct otri *) NULL; - } - - if (((holes > 0) && !b->noholes) || !b->convex || (regions > 0)) { - /* Initialize a pool of viri to be used for holes, concavities, */ - /* regional attributes, and/or regional area constraints. */ - poolinit(&m->viri, sizeof(triangle *), VIRUSPERBLOCK, VIRUSPERBLOCK, 0); - } - - if (!b->convex) { - /* Mark as infected any unprotected triangles on the boundary. */ - /* This is one way by which concavities are created. */ - infecthull(m, b); - } - - if ((holes > 0) && !b->noholes) { - /* Infect each triangle in which a hole lies. */ - for (i = 0; i < 2 * holes; i += 2) { - /* Ignore holes that aren't within the bounds of the mesh. */ - if ((holelist[i] >= m->xmin) && (holelist[i] <= m->xmax) - && (holelist[i + 1] >= m->ymin) && (holelist[i + 1] <= m->ymax)) { - /* Start searching from some triangle on the outer boundary. */ - searchtri.tri = m->dummytri; - searchtri.orient = 0; - symself(searchtri); - /* Ensure that the hole is to the left of this boundary edge; */ - /* otherwise, locate() will falsely report that the hole */ - /* falls within the starting triangle. */ - org(searchtri, searchorg); - dest(searchtri, searchdest); - if (counterclockwise(m, b, searchorg, searchdest, &holelist[i]) > - 0.0) { - /* Find a triangle that contains the hole. */ - intersect = locate(m, b, &holelist[i], &searchtri); - if ((intersect != OUTSIDE) && (!infected(searchtri))) { - /* Infect the triangle. This is done by marking the triangle */ - /* as infected and including the triangle in the virus pool. */ - infect(searchtri); - holetri = (triangle **) poolalloc(&m->viri); - *holetri = searchtri.tri; - } - } - } - } - } - - /* Now, we have to find all the regions BEFORE we carve the holes, because */ - /* locate() won't work when the triangulation is no longer convex. */ - /* (Incidentally, this is the reason why regional attributes and area */ - /* constraints can't be used when refining a preexisting mesh, which */ - /* might not be convex; they can only be used with a freshly */ - /* triangulated PSLG.) */ - if (regions > 0) { - /* Find the starting triangle for each region. */ - for (i = 0; i < regions; i++) { - regiontris[i].tri = m->dummytri; - /* Ignore region points that aren't within the bounds of the mesh. */ - if ((regionlist[4 * i] >= m->xmin) && (regionlist[4 * i] <= m->xmax) && - (regionlist[4 * i + 1] >= m->ymin) && - (regionlist[4 * i + 1] <= m->ymax)) { - /* Start searching from some triangle on the outer boundary. */ - searchtri.tri = m->dummytri; - searchtri.orient = 0; - symself(searchtri); - /* Ensure that the region point is to the left of this boundary */ - /* edge; otherwise, locate() will falsely report that the */ - /* region point falls within the starting triangle. */ - org(searchtri, searchorg); - dest(searchtri, searchdest); - if (counterclockwise(m, b, searchorg, searchdest, ®ionlist[4 * i]) > - 0.0) { - /* Find a triangle that contains the region point. */ - intersect = locate(m, b, ®ionlist[4 * i], &searchtri); - if ((intersect != OUTSIDE) && (!infected(searchtri))) { - /* Record the triangle for processing after the */ - /* holes have been carved. */ - otricopy(searchtri, regiontris[i]); - } - } - } - } - } - - if (m->viri.items > 0) { - /* Carve the holes and concavities. */ - plague(m, b); - } - /* The virus pool should be empty now. */ - - if (regions > 0) { - if (!b->quiet) { - if (b->regionattrib) { - if (b->vararea) { - printf("Spreading regional attributes and area constraints.\n"); - } else { - printf("Spreading regional attributes.\n"); - } - } else { - printf("Spreading regional area constraints.\n"); - } - } - if (b->regionattrib && !b->refine) { - /* Assign every triangle a regional attribute of zero. */ - traversalinit(&m->triangles); - triangleloop.orient = 0; - triangleloop.tri = triangletraverse(m); - while (triangleloop.tri != (triangle *) NULL) { - setelemattribute(triangleloop, m->eextras, 0.0); - triangleloop.tri = triangletraverse(m); - } - } - for (i = 0; i < regions; i++) { - if (regiontris[i].tri != m->dummytri) { - /* Make sure the triangle under consideration still exists. */ - /* It may have been eaten by the virus. */ - if (!deadtri(regiontris[i].tri)) { - /* Put one triangle in the virus pool. */ - infect(regiontris[i]); - regiontri = (triangle **) poolalloc(&m->viri); - *regiontri = regiontris[i].tri; - /* Apply one region's attribute and/or area constraint. */ - regionplague(m, b, regionlist[4 * i + 2], regionlist[4 * i + 3]); - /* The virus pool should be empty now. */ - } - } - } - if (b->regionattrib && !b->refine) { - /* Note the fact that each triangle has an additional attribute. */ - m->eextras++; - } - } - - /* Free up memory. */ - if (((holes > 0) && !b->noholes) || !b->convex || (regions > 0)) { - pooldeinit(&m->viri); - } - if (regions > 0) { - trifree((VOID *) regiontris); - } -} - -/** **/ -/** **/ -/********* Carving out holes and concavities ends here *********/ - -/********* Mesh quality maintenance begins here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* tallyencs() Traverse the entire list of subsegments, and check each */ -/* to see if it is encroached. If so, add it to the list. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void tallyencs(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void tallyencs(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct osub subsegloop; - int dummy; - - traversalinit(&m->subsegs); - subsegloop.ssorient = 0; - subsegloop.ss = subsegtraverse(m); - while (subsegloop.ss != (subseg *) NULL) { - /* If the segment is encroached, add it to the list. */ - dummy = checkseg4encroach(m, b, &subsegloop); - subsegloop.ss = subsegtraverse(m); - } -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* precisionerror() Print an error message for precision problems. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -void precisionerror() -{ - printf("Try increasing the area criterion and/or reducing the minimum\n"); - printf(" allowable angle so that tiny triangles are not created.\n"); -#ifdef SINGLE - printf("Alternatively, try recompiling me with double precision\n"); - printf(" arithmetic (by removing \"#define SINGLE\" from the\n"); - printf(" source file or \"-DSINGLE\" from the makefile).\n"); -#endif /* SINGLE */ -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* splitencsegs() Split all the encroached subsegments. */ -/* */ -/* Each encroached subsegment is repaired by splitting it - inserting a */ -/* vertex at or near its midpoint. Newly inserted vertices may encroach */ -/* upon other subsegments; these are also repaired. */ -/* */ -/* `triflaws' is a flag that specifies whether one should take note of new */ -/* bad triangles that result from inserting vertices to repair encroached */ -/* subsegments. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void splitencsegs(struct mesh *m, struct behavior *b, int triflaws) -#else /* not ANSI_DECLARATORS */ -void splitencsegs(m, b, triflaws) -struct mesh *m; -struct behavior *b; -int triflaws; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri enctri; - struct otri testtri; - struct osub testsh; - struct osub currentenc; - struct badsubseg *encloop; - vertex eorg, edest, eapex; - vertex newvertex; - enum insertvertexresult success; - REAL segmentlength, nearestpoweroftwo; - REAL split; - REAL multiplier, divisor; - int acuteorg, acuteorg2, acutedest, acutedest2; - int dummy; - int i; - triangle ptr; /* Temporary variable used by stpivot(). */ - subseg sptr; /* Temporary variable used by snext(). */ - - /* Note that steinerleft == -1 if an unlimited number */ - /* of Steiner points is allowed. */ - while ((m->badsubsegs.items > 0) && (m->steinerleft != 0)) { - traversalinit(&m->badsubsegs); - encloop = badsubsegtraverse(m); - while ((encloop != (struct badsubseg *) NULL) && (m->steinerleft != 0)) { - sdecode(encloop->encsubseg, currentenc); - sorg(currentenc, eorg); - sdest(currentenc, edest); - /* Make sure that this segment is still the same segment it was */ - /* when it was determined to be encroached. If the segment was */ - /* enqueued multiple times (because several newly inserted */ - /* vertices encroached it), it may have already been split. */ - if (!deadsubseg(currentenc.ss) && - (eorg == encloop->subsegorg) && (edest == encloop->subsegdest)) { - /* To decide where to split a segment, we need to know if the */ - /* segment shares an endpoint with an adjacent segment. */ - /* The concern is that, if we simply split every encroached */ - /* segment in its center, two adjacent segments with a small */ - /* angle between them might lead to an infinite loop; each */ - /* vertex added to split one segment will encroach upon the */ - /* other segment, which must then be split with a vertex that */ - /* will encroach upon the first segment, and so on forever. */ - /* To avoid this, imagine a set of concentric circles, whose */ - /* radii are powers of two, about each segment endpoint. */ - /* These concentric circles determine where the segment is */ - /* split. (If both endpoints are shared with adjacent */ - /* segments, split the segment in the middle, and apply the */ - /* concentric circles for later splittings.) */ - - /* Is the origin shared with another segment? */ - stpivot(currentenc, enctri); - lnext(enctri, testtri); - tspivot(testtri, testsh); - acuteorg = testsh.ss != m->dummysub; - /* Is the destination shared with another segment? */ - lnextself(testtri); - tspivot(testtri, testsh); - acutedest = testsh.ss != m->dummysub; - - /* If we're using Chew's algorithm (rather than Ruppert's) */ - /* to define encroachment, delete free vertices from the */ - /* subsegment's diametral circle. */ - if (!b->conformdel && !acuteorg && !acutedest) { - apex(enctri, eapex); - while ((vertextype(eapex) == FREEVERTEX) && - ((eorg[0] - eapex[0]) * (edest[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (edest[1] - eapex[1]) < 0.0)) { - deletevertex(m, b, &testtri); - stpivot(currentenc, enctri); - apex(enctri, eapex); - lprev(enctri, testtri); - } - } - - /* Now, check the other side of the segment, if there's a triangle */ - /* there. */ - sym(enctri, testtri); - if (testtri.tri != m->dummytri) { - /* Is the destination shared with another segment? */ - lnextself(testtri); - tspivot(testtri, testsh); - acutedest2 = testsh.ss != m->dummysub; - acutedest = acutedest || acutedest2; - /* Is the origin shared with another segment? */ - lnextself(testtri); - tspivot(testtri, testsh); - acuteorg2 = testsh.ss != m->dummysub; - acuteorg = acuteorg || acuteorg2; - - /* Delete free vertices from the subsegment's diametral circle. */ - if (!b->conformdel && !acuteorg2 && !acutedest2) { - org(testtri, eapex); - while ((vertextype(eapex) == FREEVERTEX) && - ((eorg[0] - eapex[0]) * (edest[0] - eapex[0]) + - (eorg[1] - eapex[1]) * (edest[1] - eapex[1]) < 0.0)) { - deletevertex(m, b, &testtri); - sym(enctri, testtri); - apex(testtri, eapex); - lprevself(testtri); - } - } - } - - /* Use the concentric circles if exactly one endpoint is shared */ - /* with another adjacent segment. */ - if (acuteorg || acutedest) { - segmentlength = sqrt((edest[0] - eorg[0]) * (edest[0] - eorg[0]) + - (edest[1] - eorg[1]) * (edest[1] - eorg[1])); - /* Find the power of two that most evenly splits the segment. */ - /* The worst case is a 2:1 ratio between subsegment lengths. */ - nearestpoweroftwo = 1.0; - while (segmentlength > 3.0 * nearestpoweroftwo) { - nearestpoweroftwo *= 2.0; - } - while (segmentlength < 1.5 * nearestpoweroftwo) { - nearestpoweroftwo *= 0.5; - } - /* Where do we split the segment? */ - split = nearestpoweroftwo / segmentlength; - if (acutedest) { - split = 1.0 - split; - } - } else { - /* If we're not worried about adjacent segments, split */ - /* this segment in the middle. */ - split = 0.5; - } - - /* Create the new vertex. */ - newvertex = (vertex) poolalloc(&m->vertices); - /* Interpolate its coordinate and attributes. */ - for (i = 0; i < 2 + m->nextras; i++) { - newvertex[i] = eorg[i] + split * (edest[i] - eorg[i]); - } - - if (!b->noexact) { - /* Roundoff in the above calculation may yield a `newvertex' */ - /* that is not precisely collinear with `eorg' and `edest'. */ - /* Improve collinearity by one step of iterative refinement. */ - multiplier = counterclockwise(m, b, eorg, edest, newvertex); - divisor = ((eorg[0] - edest[0]) * (eorg[0] - edest[0]) + - (eorg[1] - edest[1]) * (eorg[1] - edest[1])); - if ((multiplier != 0.0) && (divisor != 0.0)) { - multiplier = multiplier / divisor; - /* Watch out for NANs. */ - if (multiplier == multiplier) { - newvertex[0] += multiplier * (edest[1] - eorg[1]); - newvertex[1] += multiplier * (eorg[0] - edest[0]); - } - } - } - - setvertexmark(newvertex, mark(currentenc)); - setvertextype(newvertex, SEGMENTVERTEX); - if (b->verbose > 1) { - printf( - " Splitting subsegment (%.12g, %.12g) (%.12g, %.12g) at (%.12g, %.12g).\n", - eorg[0], eorg[1], edest[0], edest[1], - newvertex[0], newvertex[1]); - } - /* Check whether the new vertex lies on an endpoint. */ - if (((newvertex[0] == eorg[0]) && (newvertex[1] == eorg[1])) || - ((newvertex[0] == edest[0]) && (newvertex[1] == edest[1]))) { - printf("Error: Ran out of precision at (%.12g, %.12g).\n", - newvertex[0], newvertex[1]); - printf("I attempted to split a segment to a smaller size than\n"); - printf(" can be accommodated by the finite precision of\n"); - printf(" floating point arithmetic.\n"); - precisionerror(); - triexit(1); - } - /* Insert the splitting vertex. This should always succeed. */ - success = insertvertex(m, b, newvertex, &enctri, ¤tenc, - 1, triflaws); - if ((success != SUCCESSFULVERTEX) && (success != ENCROACHINGVERTEX)) { - printf("Internal error in splitencsegs():\n"); - printf(" Failure to split a segment.\n"); - internalerror(); - } - if (m->steinerleft > 0) { - m->steinerleft--; - } - /* Check the two new subsegments to see if they're encroached. */ - dummy = checkseg4encroach(m, b, ¤tenc); - snextself(currentenc); - dummy = checkseg4encroach(m, b, ¤tenc); - } - - badsubsegdealloc(m, encloop); - encloop = badsubsegtraverse(m); - } - } -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* tallyfaces() Test every triangle in the mesh for quality measures. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void tallyfaces(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void tallyfaces(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop; - - if (b->verbose) { - printf(" Making a list of bad triangles.\n"); - } - traversalinit(&m->triangles); - triangleloop.orient = 0; - triangleloop.tri = triangletraverse(m); - while (triangleloop.tri != (triangle *) NULL) { - /* If the triangle is bad, enqueue it. */ - testtriangle(m, b, &triangleloop); - triangleloop.tri = triangletraverse(m); - } -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* splittriangle() Inserts a vertex at the circumcenter of a triangle. */ -/* Deletes the newly inserted vertex if it encroaches */ -/* upon a segment. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void splittriangle(struct mesh *m, struct behavior *b, - struct badtriang *badtri) -#else /* not ANSI_DECLARATORS */ -void splittriangle(m, b, badtri) -struct mesh *m; -struct behavior *b; -struct badtriang *badtri; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri badotri; - vertex borg, bdest, bapex; - vertex newvertex; - REAL xi, eta; - enum insertvertexresult success; - int errorflag; - int i; - - decode(badtri->poortri, badotri); - org(badotri, borg); - dest(badotri, bdest); - apex(badotri, bapex); - /* Make sure that this triangle is still the same triangle it was */ - /* when it was tested and determined to be of bad quality. */ - /* Subsequent transformations may have made it a different triangle. */ - if (!deadtri(badotri.tri) && (borg == badtri->triangorg) && - (bdest == badtri->triangdest) && (bapex == badtri->triangapex)) { - if (b->verbose > 1) { - printf(" Splitting this triangle at its circumcenter:\n"); - printf(" (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", borg[0], - borg[1], bdest[0], bdest[1], bapex[0], bapex[1]); - } - - errorflag = 0; - /* Create a new vertex at the triangle's circumcenter. */ - newvertex = (vertex) poolalloc(&m->vertices); - findcircumcenter(m, b, borg, bdest, bapex, newvertex, &xi, &eta, 1); - - /* Check whether the new vertex lies on a triangle vertex. */ - if (((newvertex[0] == borg[0]) && (newvertex[1] == borg[1])) || - ((newvertex[0] == bdest[0]) && (newvertex[1] == bdest[1])) || - ((newvertex[0] == bapex[0]) && (newvertex[1] == bapex[1]))) { - if (!b->quiet) { - printf( - "Warning: New vertex (%.12g, %.12g) falls on existing vertex.\n", - newvertex[0], newvertex[1]); - errorflag = 1; - } - vertexdealloc(m, newvertex); - } else { - for (i = 2; i < 2 + m->nextras; i++) { - /* Interpolate the vertex attributes at the circumcenter. */ - newvertex[i] = borg[i] + xi * (bdest[i] - borg[i]) - + eta * (bapex[i] - borg[i]); - } - /* The new vertex must be in the interior, and therefore is a */ - /* free vertex with a marker of zero. */ - setvertexmark(newvertex, 0); - setvertextype(newvertex, FREEVERTEX); - - /* Ensure that the handle `badotri' does not represent the longest */ - /* edge of the triangle. This ensures that the circumcenter must */ - /* fall to the left of this edge, so point location will work. */ - /* (If the angle org-apex-dest exceeds 90 degrees, then the */ - /* circumcenter lies outside the org-dest edge, and eta is */ - /* negative. Roundoff error might prevent eta from being */ - /* negative when it should be, so I test eta against xi.) */ - if (eta < xi) { - lprevself(badotri); - } - - /* Insert the circumcenter, searching from the edge of the triangle, */ - /* and maintain the Delaunay property of the triangulation. */ - success = insertvertex(m, b, newvertex, &badotri, (struct osub *) NULL, - 1, 1); - if (success == SUCCESSFULVERTEX) { - if (m->steinerleft > 0) { - m->steinerleft--; - } - } else if (success == ENCROACHINGVERTEX) { - /* If the newly inserted vertex encroaches upon a subsegment, */ - /* delete the new vertex. */ - undovertex(m, b); - if (b->verbose > 1) { - printf(" Rejecting (%.12g, %.12g).\n", newvertex[0], newvertex[1]); - } - vertexdealloc(m, newvertex); - } else if (success == VIOLATINGVERTEX) { - /* Failed to insert the new vertex, but some subsegment was */ - /* marked as being encroached. */ - vertexdealloc(m, newvertex); - } else { /* success == DUPLICATEVERTEX */ - /* Couldn't insert the new vertex because a vertex is already there. */ - if (!b->quiet) { - printf( - "Warning: New vertex (%.12g, %.12g) falls on existing vertex.\n", - newvertex[0], newvertex[1]); - errorflag = 1; - } - vertexdealloc(m, newvertex); - } - } - if (errorflag) { - if (b->verbose) { - printf(" The new vertex is at the circumcenter of triangle\n"); - printf(" (%.12g, %.12g) (%.12g, %.12g) (%.12g, %.12g)\n", - borg[0], borg[1], bdest[0], bdest[1], bapex[0], bapex[1]); - } - printf("This probably means that I am trying to refine triangles\n"); - printf(" to a smaller size than can be accommodated by the finite\n"); - printf(" precision of floating point arithmetic. (You can be\n"); - printf(" sure of this if I fail to terminate.)\n"); - precisionerror(); - } - } -} - -#endif /* not CDT_ONLY */ - -/*****************************************************************************/ -/* */ -/* enforcequality() Remove all the encroached subsegments and bad */ -/* triangles from the triangulation. */ -/* */ -/*****************************************************************************/ - -#ifndef CDT_ONLY - -#ifdef ANSI_DECLARATORS -void enforcequality(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void enforcequality(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct badtriang *badtri; - int i; - - if (!b->quiet) { - printf("Adding Steiner points to enforce quality.\n"); - } - /* Initialize the pool of encroached subsegments. */ - poolinit(&m->badsubsegs, sizeof(struct badsubseg), BADSUBSEGPERBLOCK, - BADSUBSEGPERBLOCK, 0); - if (b->verbose) { - printf(" Looking for encroached subsegments.\n"); - } - /* Test all segments to see if they're encroached. */ - tallyencs(m, b); - if (b->verbose && (m->badsubsegs.items > 0)) { - printf(" Splitting encroached subsegments.\n"); - } - /* Fix encroached subsegments without noting bad triangles. */ - splitencsegs(m, b, 0); - /* At this point, if we haven't run out of Steiner points, the */ - /* triangulation should be (conforming) Delaunay. */ - - /* Next, we worry about enforcing triangle quality. */ - if ((b->minangle > 0.0) || b->vararea || b->fixedarea || b->usertest) { - /* Initialize the pool of bad triangles. */ - poolinit(&m->badtriangles, sizeof(struct badtriang), BADTRIPERBLOCK, - BADTRIPERBLOCK, 0); - /* Initialize the queues of bad triangles. */ - for (i = 0; i < 4096; i++) { - m->queuefront[i] = (struct badtriang *) NULL; - } - m->firstnonemptyq = -1; - /* Test all triangles to see if they're bad. */ - tallyfaces(m, b); - /* Initialize the pool of recently flipped triangles. */ - poolinit(&m->flipstackers, sizeof(struct flipstacker), FLIPSTACKERPERBLOCK, - FLIPSTACKERPERBLOCK, 0); - m->checkquality = 1; - if (b->verbose) { - printf(" Splitting bad triangles.\n"); - } - while ((m->badtriangles.items > 0) && (m->steinerleft != 0)) { - /* Fix one bad triangle by inserting a vertex at its circumcenter. */ - badtri = dequeuebadtriang(m); - splittriangle(m, b, badtri); - if (m->badsubsegs.items > 0) { - /* Put bad triangle back in queue for another try later. */ - enqueuebadtriang(m, b, badtri); - /* Fix any encroached subsegments that resulted. */ - /* Record any new bad triangles that result. */ - splitencsegs(m, b, 1); - } else { - /* Return the bad triangle to the pool. */ - pooldealloc(&m->badtriangles, (VOID *) badtri); - } - } - } - /* At this point, if the "-D" switch was selected and we haven't run out */ - /* of Steiner points, the triangulation should be (conforming) Delaunay */ - /* and have no low-quality triangles. */ - - /* Might we have run out of Steiner points too soon? */ - if (!b->quiet && b->conformdel && (m->badsubsegs.items > 0) && - (m->steinerleft == 0)) { - printf("\nWarning: I ran out of Steiner points, but the mesh has\n"); - if (m->badsubsegs.items == 1) { - printf(" one encroached subsegment, and therefore might not be truly\n" - ); - } else { - printf(" %ld encroached subsegments, and therefore might not be truly\n" - , m->badsubsegs.items); - } - printf(" Delaunay. If the Delaunay property is important to you,\n"); - printf(" try increasing the number of Steiner points (controlled by\n"); - printf(" the -S switch) slightly and try again.\n\n"); - } -} - -#endif /* not CDT_ONLY */ - -/** **/ -/** **/ -/********* Mesh quality maintenance ends here *********/ - -/*****************************************************************************/ -/* */ -/* highorder() Create extra nodes for quadratic subparametric elements. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void highorder(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void highorder(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop, trisym; - struct osub checkmark; - vertex newvertex; - vertex torg, tdest; - int i; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - - if (!b->quiet) { - printf("Adding vertices for second-order triangles.\n"); - } - /* The following line ensures that dead items in the pool of nodes */ - /* cannot be allocated for the extra nodes associated with high */ - /* order elements. This ensures that the primary nodes (at the */ - /* corners of elements) will occur earlier in the output files, and */ - /* have lower indices, than the extra nodes. */ - m->vertices.deaditemstack = (VOID *) NULL; - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - /* To loop over the set of edges, loop over all triangles, and look at */ - /* the three edges of each triangle. If there isn't another triangle */ - /* adjacent to the edge, operate on the edge. If there is another */ - /* adjacent triangle, operate on the edge only if the current triangle */ - /* has a smaller pointer than its neighbor. This way, each edge is */ - /* considered only once. */ - while (triangleloop.tri != (triangle *) NULL) { - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - sym(triangleloop, trisym); - if ((triangleloop.tri < trisym.tri) || (trisym.tri == m->dummytri)) { - org(triangleloop, torg); - dest(triangleloop, tdest); - /* Create a new node in the middle of the edge. Interpolate */ - /* its attributes. */ - newvertex = (vertex) poolalloc(&m->vertices); - for (i = 0; i < 2 + m->nextras; i++) { - newvertex[i] = 0.5 * (torg[i] + tdest[i]); - } - /* Set the new node's marker to zero or one, depending on */ - /* whether it lies on a boundary. */ - setvertexmark(newvertex, trisym.tri == m->dummytri); - setvertextype(newvertex, - trisym.tri == m->dummytri ? FREEVERTEX : SEGMENTVERTEX); - if (b->usesegments) { - tspivot(triangleloop, checkmark); - /* If this edge is a segment, transfer the marker to the new node. */ - if (checkmark.ss != m->dummysub) { - setvertexmark(newvertex, mark(checkmark)); - setvertextype(newvertex, SEGMENTVERTEX); - } - } - if (b->verbose > 1) { - printf(" Creating (%.12g, %.12g).\n", newvertex[0], newvertex[1]); - } - /* Record the new node in the (one or two) adjacent elements. */ - triangleloop.tri[m->highorderindex + triangleloop.orient] = - (triangle) newvertex; - if (trisym.tri != m->dummytri) { - trisym.tri[m->highorderindex + trisym.orient] = (triangle) newvertex; - } - } - } - triangleloop.tri = triangletraverse(m); - } -} - -/********* File I/O routines begin here *********/ -/** **/ -/** **/ - -/*****************************************************************************/ -/* */ -/* readline() Read a nonempty line from a file. */ -/* */ -/* A line is considered "nonempty" if it contains something that looks like */ -/* a number. Comments (prefaced by `#') are ignored. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -char *readline(char *string, FILE *infile, char *infilename) -#else /* not ANSI_DECLARATORS */ -char *readline(string, infile, infilename) -char *string; -FILE *infile; -char *infilename; -#endif /* not ANSI_DECLARATORS */ - -{ - char *result; - - /* Search for something that looks like a number. */ - do { - result = fgets(string, INPUTLINESIZE, infile); - if (result == (char *) NULL) { - printf(" Error: Unexpected end of file in %s.\n", infilename); - triexit(1); - } - /* Skip anything that doesn't look like a number, a comment, */ - /* or the end of a line. */ - while ((*result != '\0') && (*result != '#') - && (*result != '.') && (*result != '+') && (*result != '-') - && ((*result < '0') || (*result > '9'))) { - result++; - } - /* If it's a comment or end of line, read another line and try again. */ - } while ((*result == '#') || (*result == '\0')); - return result; -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* findfield() Find the next field of a string. */ -/* */ -/* Jumps past the current field by searching for whitespace, then jumps */ -/* past the whitespace to find the next field. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -char *findfield(char *string) -#else /* not ANSI_DECLARATORS */ -char *findfield(string) -char *string; -#endif /* not ANSI_DECLARATORS */ - -{ - char *result; - - result = string; - /* Skip the current field. Stop upon reaching whitespace. */ - while ((*result != '\0') && (*result != '#') - && (*result != ' ') && (*result != '\t')) { - result++; - } - /* Now skip the whitespace and anything else that doesn't look like a */ - /* number, a comment, or the end of a line. */ - while ((*result != '\0') && (*result != '#') - && (*result != '.') && (*result != '+') && (*result != '-') - && ((*result < '0') || (*result > '9'))) { - result++; - } - /* Check for a comment (prefixed with `#'). */ - if (*result == '#') { - *result = '\0'; - } - return result; -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* readnodes() Read the vertices from a file, which may be a .node or */ -/* .poly file. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void readnodes(struct mesh *m, struct behavior *b, char *nodefilename, - char *polyfilename, FILE **polyfile) -#else /* not ANSI_DECLARATORS */ -void readnodes(m, b, nodefilename, polyfilename, polyfile) -struct mesh *m; -struct behavior *b; -char *nodefilename; -char *polyfilename; -FILE **polyfile; -#endif /* not ANSI_DECLARATORS */ - -{ - FILE *infile; - vertex vertexloop; - char inputline[INPUTLINESIZE]; - char *stringptr; - char *infilename; - REAL x, y; - int firstnode; - int nodemarkers; - int currentmarker; - int i, j; - - if (b->poly) { - /* Read the vertices from a .poly file. */ - if (!b->quiet) { - printf("Opening %s.\n", polyfilename); - } - *polyfile = fopen(polyfilename, "r"); - if (*polyfile == (FILE *) NULL) { - printf(" Error: Cannot access file %s.\n", polyfilename); - triexit(1); - } - /* Read number of vertices, number of dimensions, number of vertex */ - /* attributes, and number of boundary markers. */ - stringptr = readline(inputline, *polyfile, polyfilename); - m->invertices = (int) strtol(stringptr, &stringptr, 0); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - m->mesh_dim = 2; - } else { - m->mesh_dim = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - m->nextras = 0; - } else { - m->nextras = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - nodemarkers = 0; - } else { - nodemarkers = (int) strtol(stringptr, &stringptr, 0); - } - if (m->invertices > 0) { - infile = *polyfile; - infilename = polyfilename; - m->readnodefile = 0; - } else { - /* If the .poly file claims there are zero vertices, that means that */ - /* the vertices should be read from a separate .node file. */ - m->readnodefile = 1; - infilename = nodefilename; - } - } else { - m->readnodefile = 1; - infilename = nodefilename; - *polyfile = (FILE *) NULL; - } - - if (m->readnodefile) { - /* Read the vertices from a .node file. */ - if (!b->quiet) { - printf("Opening %s.\n", nodefilename); - } - infile = fopen(nodefilename, "r"); - if (infile == (FILE *) NULL) { - printf(" Error: Cannot access file %s.\n", nodefilename); - triexit(1); - } - /* Read number of vertices, number of dimensions, number of vertex */ - /* attributes, and number of boundary markers. */ - stringptr = readline(inputline, infile, nodefilename); - m->invertices = (int) strtol(stringptr, &stringptr, 0); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - m->mesh_dim = 2; - } else { - m->mesh_dim = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - m->nextras = 0; - } else { - m->nextras = (int) strtol(stringptr, &stringptr, 0); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - nodemarkers = 0; - } else { - nodemarkers = (int) strtol(stringptr, &stringptr, 0); - } - } - - if (m->invertices < 3) { - printf("Error: Input must have at least three input vertices.\n"); - triexit(1); - } - if (m->mesh_dim != 2) { - printf("Error: Triangle only works with two-dimensional meshes.\n"); - triexit(1); - } - if (m->nextras == 0) { - b->weighted = 0; - } - - initializevertexpool(m, b); - - /* Read the vertices. */ - for (i = 0; i < m->invertices; i++) { - vertexloop = (vertex) poolalloc(&m->vertices); - stringptr = readline(inputline, infile, infilename); - if (i == 0) { - firstnode = (int) strtol(stringptr, &stringptr, 0); - if ((firstnode == 0) || (firstnode == 1)) { - b->firstnumber = firstnode; - } - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Vertex %d has no x coordinate.\n", b->firstnumber + i); - triexit(1); - } - x = (REAL) strtod(stringptr, &stringptr); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Vertex %d has no y coordinate.\n", b->firstnumber + i); - triexit(1); - } - y = (REAL) strtod(stringptr, &stringptr); - vertexloop[0] = x; - vertexloop[1] = y; - /* Read the vertex attributes. */ - for (j = 2; j < 2 + m->nextras; j++) { - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - vertexloop[j] = 0.0; - } else { - vertexloop[j] = (REAL) strtod(stringptr, &stringptr); - } - } - if (nodemarkers) { - /* Read a vertex marker. */ - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - setvertexmark(vertexloop, 0); - } else { - currentmarker = (int) strtol(stringptr, &stringptr, 0); - setvertexmark(vertexloop, currentmarker); - } - } else { - /* If no markers are specified in the file, they default to zero. */ - setvertexmark(vertexloop, 0); - } - setvertextype(vertexloop, INPUTVERTEX); - /* Determine the smallest and largest x and y coordinates. */ - if (i == 0) { - m->xmin = m->xmax = x; - m->ymin = m->ymax = y; - } else { - m->xmin = (x < m->xmin) ? x : m->xmin; - m->xmax = (x > m->xmax) ? x : m->xmax; - m->ymin = (y < m->ymin) ? y : m->ymin; - m->ymax = (y > m->ymax) ? y : m->ymax; - } - } - if (m->readnodefile) { - fclose(infile); - } - - /* Nonexistent x value used as a flag to mark circle events in sweepline */ - /* Delaunay algorithm. */ - m->xminextreme = 10 * m->xmin - 9 * m->xmax; -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* transfernodes() Read the vertices from memory. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void transfernodes(struct mesh *m, struct behavior *b, REAL *pointlist, - REAL *pointattriblist, int *pointmarkerlist, - int numberofpoints, int numberofpointattribs) -#else /* not ANSI_DECLARATORS */ -void transfernodes(m, b, pointlist, pointattriblist, pointmarkerlist, - numberofpoints, numberofpointattribs) -struct mesh *m; -struct behavior *b; -REAL *pointlist; -REAL *pointattriblist; -int *pointmarkerlist; -int numberofpoints; -int numberofpointattribs; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex vertexloop; - REAL x, y; - int i, j; - int coordindex; - int attribindex; - - m->invertices = numberofpoints; - m->mesh_dim = 2; - m->nextras = numberofpointattribs; - m->readnodefile = 0; - if (m->invertices < 3) { - printf("Error: Input must have at least three input vertices.\n"); - triexit(1); - } - if (m->nextras == 0) { - b->weighted = 0; - } - - initializevertexpool(m, b); - - /* Read the vertices. */ - coordindex = 0; - attribindex = 0; - for (i = 0; i < m->invertices; i++) { - vertexloop = (vertex) poolalloc(&m->vertices); - /* Read the vertex coordinates. */ - x = vertexloop[0] = pointlist[coordindex++]; - y = vertexloop[1] = pointlist[coordindex++]; - /* Read the vertex attributes. */ - for (j = 0; j < numberofpointattribs; j++) { - vertexloop[2 + j] = pointattriblist[attribindex++]; - } - if (pointmarkerlist != (int *) NULL) { - /* Read a vertex marker. */ - setvertexmark(vertexloop, pointmarkerlist[i]); - } else { - /* If no markers are specified, they default to zero. */ - setvertexmark(vertexloop, 0); - } - setvertextype(vertexloop, INPUTVERTEX); - /* Determine the smallest and largest x and y coordinates. */ - if (i == 0) { - m->xmin = m->xmax = x; - m->ymin = m->ymax = y; - } else { - m->xmin = (x < m->xmin) ? x : m->xmin; - m->xmax = (x > m->xmax) ? x : m->xmax; - m->ymin = (y < m->ymin) ? y : m->ymin; - m->ymax = (y > m->ymax) ? y : m->ymax; - } - } - - /* Nonexistent x value used as a flag to mark circle events in sweepline */ - /* Delaunay algorithm. */ - m->xminextreme = 10 * m->xmin - 9 * m->xmax; -} - -#endif /* TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* readholes() Read the holes, and possibly regional attributes and area */ -/* constraints, from a .poly file. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void readholes(struct mesh *m, struct behavior *b, - FILE *polyfile, char *polyfilename, REAL **hlist, int *holes, - REAL **rlist, int *regions) -#else /* not ANSI_DECLARATORS */ -void readholes(m, b, polyfile, polyfilename, hlist, holes, rlist, regions) -struct mesh *m; -struct behavior *b; -FILE *polyfile; -char *polyfilename; -REAL **hlist; -int *holes; -REAL **rlist; -int *regions; -#endif /* not ANSI_DECLARATORS */ - -{ - REAL *holelist; - REAL *regionlist; - char inputline[INPUTLINESIZE]; - char *stringptr; - int index; - int i; - - /* Read the holes. */ - stringptr = readline(inputline, polyfile, polyfilename); - *holes = (int) strtol(stringptr, &stringptr, 0); - if (*holes > 0) { - holelist = (REAL *) trimalloc(2 * *holes * (int) sizeof(REAL)); - *hlist = holelist; - for (i = 0; i < 2 * *holes; i += 2) { - stringptr = readline(inputline, polyfile, polyfilename); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Hole %d has no x coordinate.\n", - b->firstnumber + (i >> 1)); - triexit(1); - } else { - holelist[i] = (REAL) strtod(stringptr, &stringptr); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Hole %d has no y coordinate.\n", - b->firstnumber + (i >> 1)); - triexit(1); - } else { - holelist[i + 1] = (REAL) strtod(stringptr, &stringptr); - } - } - } else { - *hlist = (REAL *) NULL; - } - -#ifndef CDT_ONLY - if ((b->regionattrib || b->vararea) && !b->refine) { - /* Read the area constraints. */ - stringptr = readline(inputline, polyfile, polyfilename); - *regions = (int) strtol(stringptr, &stringptr, 0); - if (*regions > 0) { - regionlist = (REAL *) trimalloc(4 * *regions * (int) sizeof(REAL)); - *rlist = regionlist; - index = 0; - for (i = 0; i < *regions; i++) { - stringptr = readline(inputline, polyfile, polyfilename); - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Region %d has no x coordinate.\n", - b->firstnumber + i); - triexit(1); - } else { - regionlist[index++] = (REAL) strtod(stringptr, &stringptr); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf("Error: Region %d has no y coordinate.\n", - b->firstnumber + i); - triexit(1); - } else { - regionlist[index++] = (REAL) strtod(stringptr, &stringptr); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - printf( - "Error: Region %d has no region attribute or area constraint.\n", - b->firstnumber + i); - triexit(1); - } else { - regionlist[index++] = (REAL) strtod(stringptr, &stringptr); - } - stringptr = findfield(stringptr); - if (*stringptr == '\0') { - regionlist[index] = regionlist[index - 1]; - } else { - regionlist[index] = (REAL) strtod(stringptr, &stringptr); - } - index++; - } - } - } else { - /* Set `*regions' to zero to avoid an accidental free() later. */ - *regions = 0; - *rlist = (REAL *) NULL; - } -#endif /* not CDT_ONLY */ - - fclose(polyfile); -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* finishfile() Write the command line to the output file so the user */ -/* can remember how the file was generated. Close the file. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void finishfile(FILE *outfile, int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void finishfile(outfile, argc, argv) -FILE *outfile; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -{ - int i; - - fprintf(outfile, "# Generated by"); - for (i = 0; i < argc; i++) { - fprintf(outfile, " "); - fputs(argv[i], outfile); - } - fprintf(outfile, "\n"); - fclose(outfile); -} - -#endif /* not TRILIBRARY */ - -/*****************************************************************************/ -/* */ -/* writenodes() Number the vertices and write them to a .node file. */ -/* */ -/* To save memory, the vertex numbers are written over the boundary markers */ -/* after the vertices are written to a file. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writenodes(struct mesh *m, struct behavior *b, REAL **pointlist, - REAL **pointattriblist, int **pointmarkerlist) -#else /* not ANSI_DECLARATORS */ -void writenodes(m, b, pointlist, pointattriblist, pointmarkerlist) -struct mesh *m; -struct behavior *b; -REAL **pointlist; -REAL **pointattriblist; -int **pointmarkerlist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writenodes(struct mesh *m, struct behavior *b, char *nodefilename, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writenodes(m, b, nodefilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *nodefilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - REAL *plist; - REAL *palist; - int *pmlist; - int coordindex; - int attribindex; -#else /* not TRILIBRARY */ - FILE *outfile; -#endif /* not TRILIBRARY */ - vertex vertexloop; - long outvertices; - int vertexnumber; - int i; - - if (b->jettison) { - outvertices = m->vertices.items - m->undeads; - } else { - outvertices = m->vertices.items; - } - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing vertices.\n"); - } - /* Allocate memory for output vertices if necessary. */ - if (*pointlist == (REAL *) NULL) { - *pointlist = (REAL *) trimalloc((int) (outvertices * 2 * sizeof(REAL))); - } - /* Allocate memory for output vertex attributes if necessary. */ - if ((m->nextras > 0) && (*pointattriblist == (REAL *) NULL)) { - *pointattriblist = (REAL *) trimalloc((int) (outvertices * m->nextras * - sizeof(REAL))); - } - /* Allocate memory for output vertex markers if necessary. */ - if (!b->nobound && (*pointmarkerlist == (int *) NULL)) { - *pointmarkerlist = (int *) trimalloc((int) (outvertices * sizeof(int))); - } - plist = *pointlist; - palist = *pointattriblist; - pmlist = *pointmarkerlist; - coordindex = 0; - attribindex = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", nodefilename); - } - outfile = fopen(nodefilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", nodefilename); - triexit(1); - } - /* Number of vertices, number of dimensions, number of vertex attributes, */ - /* and number of boundary markers (zero or one). */ - fprintf(outfile, "%ld %d %d %d\n", outvertices, m->mesh_dim, - m->nextras, 1 - b->nobound); -#endif /* not TRILIBRARY */ - - traversalinit(&m->vertices); - vertexnumber = b->firstnumber; - vertexloop = vertextraverse(m); - while (vertexloop != (vertex) NULL) { - if (!b->jettison || (vertextype(vertexloop) != UNDEADVERTEX)) { -#ifdef TRILIBRARY - /* X and y coordinates. */ - plist[coordindex++] = vertexloop[0]; - plist[coordindex++] = vertexloop[1]; - /* Vertex attributes. */ - for (i = 0; i < m->nextras; i++) { - palist[attribindex++] = vertexloop[2 + i]; - } - if (!b->nobound) { - /* Copy the boundary marker. */ - pmlist[vertexnumber - b->firstnumber] = vertexmark(vertexloop); - } -#else /* not TRILIBRARY */ - /* Vertex number, x and y coordinates. */ - fprintf(outfile, "%4d %.17g %.17g", vertexnumber, vertexloop[0], - vertexloop[1]); - for (i = 0; i < m->nextras; i++) { - /* Write an attribute. */ - fprintf(outfile, " %.17g", vertexloop[i + 2]); - } - if (b->nobound) { - fprintf(outfile, "\n"); - } else { - /* Write the boundary marker. */ - fprintf(outfile, " %d\n", vertexmark(vertexloop)); - } -#endif /* not TRILIBRARY */ - - setvertexmark(vertexloop, vertexnumber); - vertexnumber++; - } - vertexloop = vertextraverse(m); - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -/*****************************************************************************/ -/* */ -/* numbernodes() Number the vertices. */ -/* */ -/* Each vertex is assigned a marker equal to its number. */ -/* */ -/* Used when writenodes() is not called because no .node file is written. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void numbernodes(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void numbernodes(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - vertex vertexloop; - int vertexnumber; - - traversalinit(&m->vertices); - vertexnumber = b->firstnumber; - vertexloop = vertextraverse(m); - while (vertexloop != (vertex) NULL) { - setvertexmark(vertexloop, vertexnumber); - if (!b->jettison || (vertextype(vertexloop) != UNDEADVERTEX)) { - vertexnumber++; - } - vertexloop = vertextraverse(m); - } -} - -/*****************************************************************************/ -/* */ -/* writeelements() Write the triangles to an .ele file. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writeelements(struct mesh *m, struct behavior *b, - int **trianglelist, REAL **triangleattriblist) -#else /* not ANSI_DECLARATORS */ -void writeelements(m, b, trianglelist, triangleattriblist) -struct mesh *m; -struct behavior *b; -int **trianglelist; -REAL **triangleattriblist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writeelements(struct mesh *m, struct behavior *b, char *elefilename, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writeelements(m, b, elefilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *elefilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - int *tlist; - REAL *talist; - int vertexindex; - int attribindex; -#else /* not TRILIBRARY */ - FILE *outfile; -#endif /* not TRILIBRARY */ - struct otri triangleloop; - vertex p1, p2, p3; - vertex mid1, mid2, mid3; - long elementnumber; - int i; - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing triangles.\n"); - } - /* Allocate memory for output triangles if necessary. */ - if (*trianglelist == (int *) NULL) { - *trianglelist = (int *) trimalloc((int) (m->triangles.items * - ((b->order + 1) * (b->order + 2) / - 2) * sizeof(int))); - } - /* Allocate memory for output triangle attributes if necessary. */ - if ((m->eextras > 0) && (*triangleattriblist == (REAL *) NULL)) { - *triangleattriblist = (REAL *) trimalloc((int) (m->triangles.items * - m->eextras * - sizeof(REAL))); - } - tlist = *trianglelist; - talist = *triangleattriblist; - vertexindex = 0; - attribindex = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", elefilename); - } - outfile = fopen(elefilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", elefilename); - triexit(1); - } - /* Number of triangles, vertices per triangle, attributes per triangle. */ - fprintf(outfile, "%ld %d %d\n", m->triangles.items, - (b->order + 1) * (b->order + 2) / 2, m->eextras); -#endif /* not TRILIBRARY */ - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - triangleloop.orient = 0; - elementnumber = b->firstnumber; - while (triangleloop.tri != (triangle *) NULL) { - org(triangleloop, p1); - dest(triangleloop, p2); - apex(triangleloop, p3); - if (b->order == 1) { -#ifdef TRILIBRARY - tlist[vertexindex++] = vertexmark(p1); - tlist[vertexindex++] = vertexmark(p2); - tlist[vertexindex++] = vertexmark(p3); -#else /* not TRILIBRARY */ - /* Triangle number, indices for three vertices. */ - fprintf(outfile, "%4ld %4d %4d %4d", elementnumber, - vertexmark(p1), vertexmark(p2), vertexmark(p3)); -#endif /* not TRILIBRARY */ - } else { - mid1 = (vertex) triangleloop.tri[m->highorderindex + 1]; - mid2 = (vertex) triangleloop.tri[m->highorderindex + 2]; - mid3 = (vertex) triangleloop.tri[m->highorderindex]; -#ifdef TRILIBRARY - tlist[vertexindex++] = vertexmark(p1); - tlist[vertexindex++] = vertexmark(p2); - tlist[vertexindex++] = vertexmark(p3); - tlist[vertexindex++] = vertexmark(mid1); - tlist[vertexindex++] = vertexmark(mid2); - tlist[vertexindex++] = vertexmark(mid3); -#else /* not TRILIBRARY */ - /* Triangle number, indices for six vertices. */ - fprintf(outfile, "%4ld %4d %4d %4d %4d %4d %4d", elementnumber, - vertexmark(p1), vertexmark(p2), vertexmark(p3), vertexmark(mid1), - vertexmark(mid2), vertexmark(mid3)); -#endif /* not TRILIBRARY */ - } - -#ifdef TRILIBRARY - for (i = 0; i < m->eextras; i++) { - talist[attribindex++] = elemattribute(triangleloop, i); - } -#else /* not TRILIBRARY */ - for (i = 0; i < m->eextras; i++) { - fprintf(outfile, " %.17g", elemattribute(triangleloop, i)); - } - fprintf(outfile, "\n"); -#endif /* not TRILIBRARY */ - - triangleloop.tri = triangletraverse(m); - elementnumber++; - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -/*****************************************************************************/ -/* */ -/* writepoly() Write the segments and holes to a .poly file. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writepoly(struct mesh *m, struct behavior *b, - int **segmentlist, int **segmentmarkerlist) -#else /* not ANSI_DECLARATORS */ -void writepoly(m, b, segmentlist, segmentmarkerlist) -struct mesh *m; -struct behavior *b; -int **segmentlist; -int **segmentmarkerlist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writepoly(struct mesh *m, struct behavior *b, char *polyfilename, - REAL *holelist, int holes, REAL *regionlist, int regions, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writepoly(m, b, polyfilename, holelist, holes, regionlist, regions, - argc, argv) -struct mesh *m; -struct behavior *b; -char *polyfilename; -REAL *holelist; -int holes; -REAL *regionlist; -int regions; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - int *slist; - int *smlist; - int index; -#else /* not TRILIBRARY */ - FILE *outfile; - long holenumber, regionnumber; -#endif /* not TRILIBRARY */ - struct osub subsegloop; - vertex endpoint1, endpoint2; - long subsegnumber; - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing segments.\n"); - } - /* Allocate memory for output segments if necessary. */ - if (*segmentlist == (int *) NULL) { - *segmentlist = (int *) trimalloc((int) (m->subsegs.items * 2 * - sizeof(int))); - } - /* Allocate memory for output segment markers if necessary. */ - if (!b->nobound && (*segmentmarkerlist == (int *) NULL)) { - *segmentmarkerlist = (int *) trimalloc((int) (m->subsegs.items * - sizeof(int))); - } - slist = *segmentlist; - smlist = *segmentmarkerlist; - index = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", polyfilename); - } - outfile = fopen(polyfilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", polyfilename); - triexit(1); - } - /* The zero indicates that the vertices are in a separate .node file. */ - /* Followed by number of dimensions, number of vertex attributes, */ - /* and number of boundary markers (zero or one). */ - fprintf(outfile, "%d %d %d %d\n", 0, m->mesh_dim, m->nextras, - 1 - b->nobound); - /* Number of segments, number of boundary markers (zero or one). */ - fprintf(outfile, "%ld %d\n", m->subsegs.items, 1 - b->nobound); -#endif /* not TRILIBRARY */ - - traversalinit(&m->subsegs); - subsegloop.ss = subsegtraverse(m); - subsegloop.ssorient = 0; - subsegnumber = b->firstnumber; - while (subsegloop.ss != (subseg *) NULL) { - sorg(subsegloop, endpoint1); - sdest(subsegloop, endpoint2); -#ifdef TRILIBRARY - /* Copy indices of the segment's two endpoints. */ - slist[index++] = vertexmark(endpoint1); - slist[index++] = vertexmark(endpoint2); - if (!b->nobound) { - /* Copy the boundary marker. */ - smlist[subsegnumber - b->firstnumber] = mark(subsegloop); - } -#else /* not TRILIBRARY */ - /* Segment number, indices of its two endpoints, and possibly a marker. */ - if (b->nobound) { - fprintf(outfile, "%4ld %4d %4d\n", subsegnumber, - vertexmark(endpoint1), vertexmark(endpoint2)); - } else { - fprintf(outfile, "%4ld %4d %4d %4d\n", subsegnumber, - vertexmark(endpoint1), vertexmark(endpoint2), mark(subsegloop)); - } -#endif /* not TRILIBRARY */ - - subsegloop.ss = subsegtraverse(m); - subsegnumber++; - } - -#ifndef TRILIBRARY -#ifndef CDT_ONLY - fprintf(outfile, "%d\n", holes); - if (holes > 0) { - for (holenumber = 0; holenumber < holes; holenumber++) { - /* Hole number, x and y coordinates. */ - fprintf(outfile, "%4ld %.17g %.17g\n", b->firstnumber + holenumber, - holelist[2 * holenumber], holelist[2 * holenumber + 1]); - } - } - if (regions > 0) { - fprintf(outfile, "%d\n", regions); - for (regionnumber = 0; regionnumber < regions; regionnumber++) { - /* Region number, x and y coordinates, attribute, maximum area. */ - fprintf(outfile, "%4ld %.17g %.17g %.17g %.17g\n", - b->firstnumber + regionnumber, - regionlist[4 * regionnumber], regionlist[4 * regionnumber + 1], - regionlist[4 * regionnumber + 2], - regionlist[4 * regionnumber + 3]); - } - } -#endif /* not CDT_ONLY */ - - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -/*****************************************************************************/ -/* */ -/* writeedges() Write the edges to an .edge file. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writeedges(struct mesh *m, struct behavior *b, - int **edgelist, int **edgemarkerlist) -#else /* not ANSI_DECLARATORS */ -void writeedges(m, b, edgelist, edgemarkerlist) -struct mesh *m; -struct behavior *b; -int **edgelist; -int **edgemarkerlist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writeedges(struct mesh *m, struct behavior *b, char *edgefilename, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writeedges(m, b, edgefilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *edgefilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - int *elist; - int *emlist; - int index; -#else /* not TRILIBRARY */ - FILE *outfile; -#endif /* not TRILIBRARY */ - struct otri triangleloop, trisym; - struct osub checkmark; - vertex p1, p2; - long edgenumber; - triangle ptr; /* Temporary variable used by sym(). */ - subseg sptr; /* Temporary variable used by tspivot(). */ - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing edges.\n"); - } - /* Allocate memory for edges if necessary. */ - if (*edgelist == (int *) NULL) { - *edgelist = (int *) trimalloc((int) (m->edges * 2 * sizeof(int))); - } - /* Allocate memory for edge markers if necessary. */ - if (!b->nobound && (*edgemarkerlist == (int *) NULL)) { - *edgemarkerlist = (int *) trimalloc((int) (m->edges * sizeof(int))); - } - elist = *edgelist; - emlist = *edgemarkerlist; - index = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", edgefilename); - } - outfile = fopen(edgefilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", edgefilename); - triexit(1); - } - /* Number of edges, number of boundary markers (zero or one). */ - fprintf(outfile, "%ld %d\n", m->edges, 1 - b->nobound); -#endif /* not TRILIBRARY */ - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - edgenumber = b->firstnumber; - /* To loop over the set of edges, loop over all triangles, and look at */ - /* the three edges of each triangle. If there isn't another triangle */ - /* adjacent to the edge, operate on the edge. If there is another */ - /* adjacent triangle, operate on the edge only if the current triangle */ - /* has a smaller pointer than its neighbor. This way, each edge is */ - /* considered only once. */ - while (triangleloop.tri != (triangle *) NULL) { - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - sym(triangleloop, trisym); - if ((triangleloop.tri < trisym.tri) || (trisym.tri == m->dummytri)) { - org(triangleloop, p1); - dest(triangleloop, p2); -#ifdef TRILIBRARY - elist[index++] = vertexmark(p1); - elist[index++] = vertexmark(p2); -#endif /* TRILIBRARY */ - if (b->nobound) { -#ifndef TRILIBRARY - /* Edge number, indices of two endpoints. */ - fprintf(outfile, "%4ld %d %d\n", edgenumber, - vertexmark(p1), vertexmark(p2)); -#endif /* not TRILIBRARY */ - } else { - /* Edge number, indices of two endpoints, and a boundary marker. */ - /* If there's no subsegment, the boundary marker is zero. */ - if (b->usesegments) { - tspivot(triangleloop, checkmark); - if (checkmark.ss == m->dummysub) { -#ifdef TRILIBRARY - emlist[edgenumber - b->firstnumber] = 0; -#else /* not TRILIBRARY */ - fprintf(outfile, "%4ld %d %d %d\n", edgenumber, - vertexmark(p1), vertexmark(p2), 0); -#endif /* not TRILIBRARY */ - } else { -#ifdef TRILIBRARY - emlist[edgenumber - b->firstnumber] = mark(checkmark); -#else /* not TRILIBRARY */ - fprintf(outfile, "%4ld %d %d %d\n", edgenumber, - vertexmark(p1), vertexmark(p2), mark(checkmark)); -#endif /* not TRILIBRARY */ - } - } else { -#ifdef TRILIBRARY - emlist[edgenumber - b->firstnumber] = trisym.tri == m->dummytri; -#else /* not TRILIBRARY */ - fprintf(outfile, "%4ld %d %d %d\n", edgenumber, - vertexmark(p1), vertexmark(p2), trisym.tri == m->dummytri); -#endif /* not TRILIBRARY */ - } - } - edgenumber++; - } - } - triangleloop.tri = triangletraverse(m); - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -/*****************************************************************************/ -/* */ -/* writevoronoi() Write the Voronoi diagram to a .v.node and .v.edge */ -/* file. */ -/* */ -/* The Voronoi diagram is the geometric dual of the Delaunay triangulation. */ -/* Hence, the Voronoi vertices are listed by traversing the Delaunay */ -/* triangles, and the Voronoi edges are listed by traversing the Delaunay */ -/* edges. */ -/* */ -/* WARNING: In order to assign numbers to the Voronoi vertices, this */ -/* procedure messes up the subsegments or the extra nodes of every */ -/* element. Hence, you should call this procedure last. */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writevoronoi(struct mesh *m, struct behavior *b, REAL **vpointlist, - REAL **vpointattriblist, int **vpointmarkerlist, - int **vedgelist, int **vedgemarkerlist, REAL **vnormlist) -#else /* not ANSI_DECLARATORS */ -void writevoronoi(m, b, vpointlist, vpointattriblist, vpointmarkerlist, - vedgelist, vedgemarkerlist, vnormlist) -struct mesh *m; -struct behavior *b; -REAL **vpointlist; -REAL **vpointattriblist; -int **vpointmarkerlist; -int **vedgelist; -int **vedgemarkerlist; -REAL **vnormlist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writevoronoi(struct mesh *m, struct behavior *b, char *vnodefilename, - char *vedgefilename, int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writevoronoi(m, b, vnodefilename, vedgefilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *vnodefilename; -char *vedgefilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - REAL *plist; - REAL *palist; - int *elist; - REAL *normlist; - int coordindex; - int attribindex; -#else /* not TRILIBRARY */ - FILE *outfile; -#endif /* not TRILIBRARY */ - struct otri triangleloop, trisym; - vertex torg, tdest, tapex; - REAL circumcenter[2]; - REAL xi, eta; - long vnodenumber, vedgenumber; - int p1, p2; - int i; - triangle ptr; /* Temporary variable used by sym(). */ - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing Voronoi vertices.\n"); - } - /* Allocate memory for Voronoi vertices if necessary. */ - if (*vpointlist == (REAL *) NULL) { - *vpointlist = (REAL *) trimalloc((int) (m->triangles.items * 2 * - sizeof(REAL))); - } - /* Allocate memory for Voronoi vertex attributes if necessary. */ - if (*vpointattriblist == (REAL *) NULL) { - *vpointattriblist = (REAL *) trimalloc((int) (m->triangles.items * - m->nextras * sizeof(REAL))); - } - *vpointmarkerlist = (int *) NULL; - plist = *vpointlist; - palist = *vpointattriblist; - coordindex = 0; - attribindex = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", vnodefilename); - } - outfile = fopen(vnodefilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", vnodefilename); - triexit(1); - } - /* Number of triangles, two dimensions, number of vertex attributes, */ - /* no markers. */ - fprintf(outfile, "%ld %d %d %d\n", m->triangles.items, 2, m->nextras, 0); -#endif /* not TRILIBRARY */ - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - triangleloop.orient = 0; - vnodenumber = b->firstnumber; - while (triangleloop.tri != (triangle *) NULL) { - org(triangleloop, torg); - dest(triangleloop, tdest); - apex(triangleloop, tapex); - findcircumcenter(m, b, torg, tdest, tapex, circumcenter, &xi, &eta, 0); -#ifdef TRILIBRARY - /* X and y coordinates. */ - plist[coordindex++] = circumcenter[0]; - plist[coordindex++] = circumcenter[1]; - for (i = 2; i < 2 + m->nextras; i++) { - /* Interpolate the vertex attributes at the circumcenter. */ - palist[attribindex++] = torg[i] + xi * (tdest[i] - torg[i]) - + eta * (tapex[i] - torg[i]); - } -#else /* not TRILIBRARY */ - /* Voronoi vertex number, x and y coordinates. */ - fprintf(outfile, "%4ld %.17g %.17g", vnodenumber, circumcenter[0], - circumcenter[1]); - for (i = 2; i < 2 + m->nextras; i++) { - /* Interpolate the vertex attributes at the circumcenter. */ - fprintf(outfile, " %.17g", torg[i] + xi * (tdest[i] - torg[i]) - + eta * (tapex[i] - torg[i])); - } - fprintf(outfile, "\n"); -#endif /* not TRILIBRARY */ - - * (int *) (triangleloop.tri + 6) = (int) vnodenumber; - triangleloop.tri = triangletraverse(m); - vnodenumber++; - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing Voronoi edges.\n"); - } - /* Allocate memory for output Voronoi edges if necessary. */ - if (*vedgelist == (int *) NULL) { - *vedgelist = (int *) trimalloc((int) (m->edges * 2 * sizeof(int))); - } - *vedgemarkerlist = (int *) NULL; - /* Allocate memory for output Voronoi norms if necessary. */ - if (*vnormlist == (REAL *) NULL) { - *vnormlist = (REAL *) trimalloc((int) (m->edges * 2 * sizeof(REAL))); - } - elist = *vedgelist; - normlist = *vnormlist; - coordindex = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", vedgefilename); - } - outfile = fopen(vedgefilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", vedgefilename); - triexit(1); - } - /* Number of edges, zero boundary markers. */ - fprintf(outfile, "%ld %d\n", m->edges, 0); -#endif /* not TRILIBRARY */ - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - vedgenumber = b->firstnumber; - /* To loop over the set of edges, loop over all triangles, and look at */ - /* the three edges of each triangle. If there isn't another triangle */ - /* adjacent to the edge, operate on the edge. If there is another */ - /* adjacent triangle, operate on the edge only if the current triangle */ - /* has a smaller pointer than its neighbor. This way, each edge is */ - /* considered only once. */ - while (triangleloop.tri != (triangle *) NULL) { - for (triangleloop.orient = 0; triangleloop.orient < 3; - triangleloop.orient++) { - sym(triangleloop, trisym); - if ((triangleloop.tri < trisym.tri) || (trisym.tri == m->dummytri)) { - /* Find the number of this triangle (and Voronoi vertex). */ - p1 = * (int *) (triangleloop.tri + 6); - if (trisym.tri == m->dummytri) { - org(triangleloop, torg); - dest(triangleloop, tdest); -#ifdef TRILIBRARY - /* Copy an infinite ray. Index of one endpoint, and -1. */ - elist[coordindex] = p1; - normlist[coordindex++] = tdest[1] - torg[1]; - elist[coordindex] = -1; - normlist[coordindex++] = torg[0] - tdest[0]; -#else /* not TRILIBRARY */ - /* Write an infinite ray. Edge number, index of one endpoint, -1, */ - /* and x and y coordinates of a vector representing the */ - /* direction of the ray. */ - fprintf(outfile, "%4ld %d %d %.17g %.17g\n", vedgenumber, - p1, -1, tdest[1] - torg[1], torg[0] - tdest[0]); -#endif /* not TRILIBRARY */ - } else { - /* Find the number of the adjacent triangle (and Voronoi vertex). */ - p2 = * (int *) (trisym.tri + 6); - /* Finite edge. Write indices of two endpoints. */ -#ifdef TRILIBRARY - elist[coordindex] = p1; - normlist[coordindex++] = 0.0; - elist[coordindex] = p2; - normlist[coordindex++] = 0.0; -#else /* not TRILIBRARY */ - fprintf(outfile, "%4ld %d %d\n", vedgenumber, p1, p2); -#endif /* not TRILIBRARY */ - } - vedgenumber++; - } - } - triangleloop.tri = triangletraverse(m); - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writeneighbors(struct mesh *m, struct behavior *b, int **neighborlist) -#else /* not ANSI_DECLARATORS */ -void writeneighbors(m, b, neighborlist) -struct mesh *m; -struct behavior *b; -int **neighborlist; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -void writeneighbors(struct mesh *m, struct behavior *b, char *neighborfilename, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writeneighbors(m, b, neighborfilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *neighborfilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ -#ifdef TRILIBRARY - int *nlist; - int index; -#else /* not TRILIBRARY */ - FILE *outfile; -#endif /* not TRILIBRARY */ - struct otri triangleloop, trisym; - long elementnumber; - int neighbor1, neighbor2, neighbor3; - triangle ptr; /* Temporary variable used by sym(). */ - -#ifdef TRILIBRARY - if (!b->quiet) { - printf("Writing neighbors.\n"); - } - /* Allocate memory for neighbors if necessary. */ - if (*neighborlist == (int *) NULL) { - *neighborlist = (int *) trimalloc((int) (m->triangles.items * 3 * - sizeof(int))); - } - nlist = *neighborlist; - index = 0; -#else /* not TRILIBRARY */ - if (!b->quiet) { - printf("Writing %s.\n", neighborfilename); - } - outfile = fopen(neighborfilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", neighborfilename); - triexit(1); - } - /* Number of triangles, three neighbors per triangle. */ - fprintf(outfile, "%ld %d\n", m->triangles.items, 3); -#endif /* not TRILIBRARY */ - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - triangleloop.orient = 0; - elementnumber = b->firstnumber; - while (triangleloop.tri != (triangle *) NULL) { - * (int *) (triangleloop.tri + 6) = (int) elementnumber; - triangleloop.tri = triangletraverse(m); - elementnumber++; - } - * (int *) (m->dummytri + 6) = -1; - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - elementnumber = b->firstnumber; - while (triangleloop.tri != (triangle *) NULL) { - triangleloop.orient = 1; - sym(triangleloop, trisym); - neighbor1 = * (int *) (trisym.tri + 6); - triangleloop.orient = 2; - sym(triangleloop, trisym); - neighbor2 = * (int *) (trisym.tri + 6); - triangleloop.orient = 0; - sym(triangleloop, trisym); - neighbor3 = * (int *) (trisym.tri + 6); -#ifdef TRILIBRARY - nlist[index++] = neighbor1; - nlist[index++] = neighbor2; - nlist[index++] = neighbor3; -#else /* not TRILIBRARY */ - /* Triangle number, neighboring triangle numbers. */ - fprintf(outfile, "%4ld %d %d %d\n", elementnumber, - neighbor1, neighbor2, neighbor3); -#endif /* not TRILIBRARY */ - - triangleloop.tri = triangletraverse(m); - elementnumber++; - } - -#ifndef TRILIBRARY - finishfile(outfile, argc, argv); -#endif /* not TRILIBRARY */ -} - -/*****************************************************************************/ -/* */ -/* writeoff() Write the triangulation to an .off file. */ -/* */ -/* OFF stands for the Object File Format, a format used by the Geometry */ -/* Center's Geomview package. */ -/* */ -/*****************************************************************************/ - -#ifndef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void writeoff(struct mesh *m, struct behavior *b, char *offfilename, - int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -void writeoff(m, b, offfilename, argc, argv) -struct mesh *m; -struct behavior *b; -char *offfilename; -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -{ - FILE *outfile; - struct otri triangleloop; - vertex vertexloop; - vertex p1, p2, p3; - long outvertices; - - if (!b->quiet) { - printf("Writing %s.\n", offfilename); - } - - if (b->jettison) { - outvertices = m->vertices.items - m->undeads; - } else { - outvertices = m->vertices.items; - } - - outfile = fopen(offfilename, "w"); - if (outfile == (FILE *) NULL) { - printf(" Error: Cannot create file %s.\n", offfilename); - triexit(1); - } - /* Number of vertices, triangles, and edges. */ - fprintf(outfile, "OFF\n%ld %ld %ld\n", outvertices, m->triangles.items, - m->edges); - - /* Write the vertices. */ - traversalinit(&m->vertices); - vertexloop = vertextraverse(m); - while (vertexloop != (vertex) NULL) { - if (!b->jettison || (vertextype(vertexloop) != UNDEADVERTEX)) { - /* The "0.0" is here because the OFF format uses 3D coordinates. */ - fprintf(outfile, " %.17g %.17g %.17g\n", vertexloop[0], vertexloop[1], - 0.0); - } - vertexloop = vertextraverse(m); - } - - /* Write the triangles. */ - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - triangleloop.orient = 0; - while (triangleloop.tri != (triangle *) NULL) { - org(triangleloop, p1); - dest(triangleloop, p2); - apex(triangleloop, p3); - /* The "3" means a three-vertex polygon. */ - fprintf(outfile, " 3 %4d %4d %4d\n", vertexmark(p1) - b->firstnumber, - vertexmark(p2) - b->firstnumber, vertexmark(p3) - b->firstnumber); - triangleloop.tri = triangletraverse(m); - } - finishfile(outfile, argc, argv); -} - -#endif /* not TRILIBRARY */ - -/** **/ -/** **/ -/********* File I/O routines end here *********/ - -/*****************************************************************************/ -/* */ -/* quality_statistics() Print statistics about the quality of the mesh. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void quality_statistics(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void quality_statistics(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - struct otri triangleloop; - vertex p[3]; - REAL cossquaretable[8]; - REAL ratiotable[16]; - REAL dx[3], dy[3]; - REAL edgelength[3]; - REAL dotproduct; - REAL cossquare; - REAL triarea; - REAL shortest, longest; - REAL trilongest2; - REAL smallestarea, biggestarea; - REAL triminaltitude2; - REAL minaltitude; - REAL triaspect2; - REAL worstaspect; - REAL smallestangle, biggestangle; - REAL radconst, degconst; - int angletable[18]; - int aspecttable[16]; - int aspectindex; - int tendegree; - int acutebiggest; - int i, ii, j, k; - - printf("Mesh quality statistics:\n\n"); - radconst = PI / 18.0; - degconst = 180.0 / PI; - for (i = 0; i < 8; i++) { - cossquaretable[i] = cos(radconst * (REAL) (i + 1)); - cossquaretable[i] = cossquaretable[i] * cossquaretable[i]; - } - for (i = 0; i < 18; i++) { - angletable[i] = 0; - } - - ratiotable[0] = 1.5; ratiotable[1] = 2.0; - ratiotable[2] = 2.5; ratiotable[3] = 3.0; - ratiotable[4] = 4.0; ratiotable[5] = 6.0; - ratiotable[6] = 10.0; ratiotable[7] = 15.0; - ratiotable[8] = 25.0; ratiotable[9] = 50.0; - ratiotable[10] = 100.0; ratiotable[11] = 300.0; - ratiotable[12] = 1000.0; ratiotable[13] = 10000.0; - ratiotable[14] = 100000.0; ratiotable[15] = 0.0; - for (i = 0; i < 16; i++) { - aspecttable[i] = 0; - } - - worstaspect = 0.0; - minaltitude = m->xmax - m->xmin + m->ymax - m->ymin; - minaltitude = minaltitude * minaltitude; - shortest = minaltitude; - longest = 0.0; - smallestarea = minaltitude; - biggestarea = 0.0; - worstaspect = 0.0; - smallestangle = 0.0; - biggestangle = 2.0; - acutebiggest = 1; - - traversalinit(&m->triangles); - triangleloop.tri = triangletraverse(m); - triangleloop.orient = 0; - while (triangleloop.tri != (triangle *) NULL) { - org(triangleloop, p[0]); - dest(triangleloop, p[1]); - apex(triangleloop, p[2]); - trilongest2 = 0.0; - - for (i = 0; i < 3; i++) { - j = plus1mod3[i]; - k = minus1mod3[i]; - dx[i] = p[j][0] - p[k][0]; - dy[i] = p[j][1] - p[k][1]; - edgelength[i] = dx[i] * dx[i] + dy[i] * dy[i]; - if (edgelength[i] > trilongest2) { - trilongest2 = edgelength[i]; - } - if (edgelength[i] > longest) { - longest = edgelength[i]; - } - if (edgelength[i] < shortest) { - shortest = edgelength[i]; - } - } - - triarea = counterclockwise(m, b, p[0], p[1], p[2]); - if (triarea < smallestarea) { - smallestarea = triarea; - } - if (triarea > biggestarea) { - biggestarea = triarea; - } - triminaltitude2 = triarea * triarea / trilongest2; - if (triminaltitude2 < minaltitude) { - minaltitude = triminaltitude2; - } - triaspect2 = trilongest2 / triminaltitude2; - if (triaspect2 > worstaspect) { - worstaspect = triaspect2; - } - aspectindex = 0; - while ((triaspect2 > ratiotable[aspectindex] * ratiotable[aspectindex]) - && (aspectindex < 15)) { - aspectindex++; - } - aspecttable[aspectindex]++; - - for (i = 0; i < 3; i++) { - j = plus1mod3[i]; - k = minus1mod3[i]; - dotproduct = dx[j] * dx[k] + dy[j] * dy[k]; - cossquare = dotproduct * dotproduct / (edgelength[j] * edgelength[k]); - tendegree = 8; - for (ii = 7; ii >= 0; ii--) { - if (cossquare > cossquaretable[ii]) { - tendegree = ii; - } - } - if (dotproduct <= 0.0) { - angletable[tendegree]++; - if (cossquare > smallestangle) { - smallestangle = cossquare; - } - if (acutebiggest && (cossquare < biggestangle)) { - biggestangle = cossquare; - } - } else { - angletable[17 - tendegree]++; - if (acutebiggest || (cossquare > biggestangle)) { - biggestangle = cossquare; - acutebiggest = 0; - } - } - } - triangleloop.tri = triangletraverse(m); - } - - shortest = sqrt(shortest); - longest = sqrt(longest); - minaltitude = sqrt(minaltitude); - worstaspect = sqrt(worstaspect); - smallestarea *= 0.5; - biggestarea *= 0.5; - if (smallestangle >= 1.0) { - smallestangle = 0.0; - } else { - smallestangle = degconst * acos(sqrt(smallestangle)); - } - if (biggestangle >= 1.0) { - biggestangle = 180.0; - } else { - if (acutebiggest) { - biggestangle = degconst * acos(sqrt(biggestangle)); - } else { - biggestangle = 180.0 - degconst * acos(sqrt(biggestangle)); - } - } - - printf(" Smallest area: %16.5g | Largest area: %16.5g\n", - smallestarea, biggestarea); - printf(" Shortest edge: %16.5g | Longest edge: %16.5g\n", - shortest, longest); - printf(" Shortest altitude: %12.5g | Largest aspect ratio: %8.5g\n\n", - minaltitude, worstaspect); - - printf(" Triangle aspect ratio histogram:\n"); - printf(" 1.1547 - %-6.6g : %8d | %6.6g - %-6.6g : %8d\n", - ratiotable[0], aspecttable[0], ratiotable[7], ratiotable[8], - aspecttable[8]); - for (i = 1; i < 7; i++) { - printf(" %6.6g - %-6.6g : %8d | %6.6g - %-6.6g : %8d\n", - ratiotable[i - 1], ratiotable[i], aspecttable[i], - ratiotable[i + 7], ratiotable[i + 8], aspecttable[i + 8]); - } - printf(" %6.6g - %-6.6g : %8d | %6.6g - : %8d\n", - ratiotable[6], ratiotable[7], aspecttable[7], ratiotable[14], - aspecttable[15]); - printf(" (Aspect ratio is longest edge divided by shortest altitude)\n\n"); - - printf(" Smallest angle: %15.5g | Largest angle: %15.5g\n\n", - smallestangle, biggestangle); - - printf(" Angle histogram:\n"); - for (i = 0; i < 9; i++) { - printf(" %3d - %3d degrees: %8d | %3d - %3d degrees: %8d\n", - i * 10, i * 10 + 10, angletable[i], - i * 10 + 90, i * 10 + 100, angletable[i + 9]); - } - printf("\n"); -} - -/*****************************************************************************/ -/* */ -/* statistics() Print all sorts of cool facts. */ -/* */ -/*****************************************************************************/ - -#ifdef ANSI_DECLARATORS -void statistics(struct mesh *m, struct behavior *b) -#else /* not ANSI_DECLARATORS */ -void statistics(m, b) -struct mesh *m; -struct behavior *b; -#endif /* not ANSI_DECLARATORS */ - -{ - printf("\nStatistics:\n\n"); - printf(" Input vertices: %d\n", m->invertices); - if (b->refine) { - printf(" Input triangles: %d\n", m->inelements); - } - if (b->poly) { - printf(" Input segments: %d\n", m->insegments); - if (!b->refine) { - printf(" Input holes: %d\n", m->holes); - } - } - - printf("\n Mesh vertices: %ld\n", m->vertices.items - m->undeads); - printf(" Mesh triangles: %ld\n", m->triangles.items); - printf(" Mesh edges: %ld\n", m->edges); - printf(" Mesh exterior boundary edges: %ld\n", m->hullsize); - if (b->poly || b->refine) { - printf(" Mesh interior boundary edges: %ld\n", - m->subsegs.items - m->hullsize); - printf(" Mesh subsegments (constrained edges): %ld\n", - m->subsegs.items); - } - printf("\n"); - - if (b->verbose) { - quality_statistics(m, b); - printf("Memory allocation statistics:\n\n"); - printf(" Maximum number of vertices: %ld\n", m->vertices.maxitems); - printf(" Maximum number of triangles: %ld\n", m->triangles.maxitems); - if (m->subsegs.maxitems > 0) { - printf(" Maximum number of subsegments: %ld\n", m->subsegs.maxitems); - } - if (m->viri.maxitems > 0) { - printf(" Maximum number of viri: %ld\n", m->viri.maxitems); - } - if (m->badsubsegs.maxitems > 0) { - printf(" Maximum number of encroached subsegments: %ld\n", - m->badsubsegs.maxitems); - } - if (m->badtriangles.maxitems > 0) { - printf(" Maximum number of bad triangles: %ld\n", - m->badtriangles.maxitems); - } - if (m->flipstackers.maxitems > 0) { - printf(" Maximum number of stacked triangle flips: %ld\n", - m->flipstackers.maxitems); - } - if (m->splaynodes.maxitems > 0) { - printf(" Maximum number of splay tree nodes: %ld\n", - m->splaynodes.maxitems); - } - printf(" Approximate heap memory use (bytes): %ld\n\n", - m->vertices.maxitems * m->vertices.itembytes + - m->triangles.maxitems * m->triangles.itembytes + - m->subsegs.maxitems * m->subsegs.itembytes + - m->viri.maxitems * m->viri.itembytes + - m->badsubsegs.maxitems * m->badsubsegs.itembytes + - m->badtriangles.maxitems * m->badtriangles.itembytes + - m->flipstackers.maxitems * m->flipstackers.itembytes + - m->splaynodes.maxitems * m->splaynodes.itembytes); - - printf("Algorithmic statistics:\n\n"); - if (!b->weighted) { - printf(" Number of incircle tests: %ld\n", m->incirclecount); - } else { - printf(" Number of 3D orientation tests: %ld\n", m->orient3dcount); - } - printf(" Number of 2D orientation tests: %ld\n", m->counterclockcount); - if (m->hyperbolacount > 0) { - printf(" Number of right-of-hyperbola tests: %ld\n", - m->hyperbolacount); - } - if (m->circletopcount > 0) { - printf(" Number of circle top computations: %ld\n", - m->circletopcount); - } - if (m->circumcentercount > 0) { - printf(" Number of triangle circumcenter computations: %ld\n", - m->circumcentercount); - } - printf("\n"); - } -} - -/*****************************************************************************/ -/* */ -/* main() or triangulate() Gosh, do everything. */ -/* */ -/* The sequence is roughly as follows. Many of these steps can be skipped, */ -/* depending on the command line switches. */ -/* */ -/* - Initialize constants and parse the command line. */ -/* - Read the vertices from a file and either */ -/* - triangulate them (no -r), or */ -/* - read an old mesh from files and reconstruct it (-r). */ -/* - Insert the PSLG segments (-p), and possibly segments on the convex */ -/* hull (-c). */ -/* - Read the holes (-p), regional attributes (-pA), and regional area */ -/* constraints (-pa). Carve the holes and concavities, and spread the */ -/* regional attributes and area constraints. */ -/* - Enforce the constraints on minimum angle (-q) and maximum area (-a). */ -/* Also enforce the conforming Delaunay property (-q and -a). */ -/* - Compute the number of edges in the resulting mesh. */ -/* - Promote the mesh's linear triangles to higher order elements (-o). */ -/* - Write the output files and print the statistics. */ -/* - Check the consistency and Delaunay property of the mesh (-C). */ -/* */ -/*****************************************************************************/ - -#ifdef TRILIBRARY - -#ifdef ANSI_DECLARATORS -void triangulate(char *triswitches, struct triangulateio *in, - struct triangulateio *out, struct triangulateio *vorout) -#else /* not ANSI_DECLARATORS */ -void triangulate(triswitches, in, out, vorout) -char *triswitches; -struct triangulateio *in; -struct triangulateio *out; -struct triangulateio *vorout; -#endif /* not ANSI_DECLARATORS */ - -#else /* not TRILIBRARY */ - -#ifdef ANSI_DECLARATORS -int main(int argc, char **argv) -#else /* not ANSI_DECLARATORS */ -int main(argc, argv) -int argc; -char **argv; -#endif /* not ANSI_DECLARATORS */ - -#endif /* not TRILIBRARY */ - -{ - struct mesh m; - struct behavior b; - REAL *holearray; /* Array of holes. */ - REAL *regionarray; /* Array of regional attributes and area constraints. */ -#ifndef TRILIBRARY - FILE *polyfile; -#endif /* not TRILIBRARY */ -#ifndef NO_TIMER - /* Variables for timing the performance of Triangle. The types are */ - /* defined in sys/time.h. */ - struct timeval tv0, tv1, tv2, tv3, tv4, tv5, tv6; - struct timezone tz; -#endif /* not NO_TIMER */ - -#ifndef NO_TIMER - gettimeofday(&tv0, &tz); -#endif /* not NO_TIMER */ - - triangleinit(&m); -#ifdef TRILIBRARY - parsecommandline(1, &triswitches, &b); -#else /* not TRILIBRARY */ - parsecommandline(argc, argv, &b); -#endif /* not TRILIBRARY */ - m.steinerleft = b.steiner; - -#ifdef TRILIBRARY - transfernodes(&m, &b, in->pointlist, in->pointattributelist, - in->pointmarkerlist, in->numberofpoints, - in->numberofpointattributes); -#else /* not TRILIBRARY */ - readnodes(&m, &b, b.innodefilename, b.inpolyfilename, &polyfile); -#endif /* not TRILIBRARY */ - -#ifndef NO_TIMER - if (!b.quiet) { - gettimeofday(&tv1, &tz); - } -#endif /* not NO_TIMER */ - -#ifdef CDT_ONLY - m.hullsize = delaunay(&m, &b); /* Triangulate the vertices. */ -#else /* not CDT_ONLY */ - if (b.refine) { - /* Read and reconstruct a mesh. */ -#ifdef TRILIBRARY - m.hullsize = reconstruct(&m, &b, in->trianglelist, - in->triangleattributelist, in->trianglearealist, - in->numberoftriangles, in->numberofcorners, - in->numberoftriangleattributes, - in->segmentlist, in->segmentmarkerlist, - in->numberofsegments); -#else /* not TRILIBRARY */ - m.hullsize = reconstruct(&m, &b, b.inelefilename, b.areafilename, - b.inpolyfilename, polyfile); -#endif /* not TRILIBRARY */ - } else { - m.hullsize = delaunay(&m, &b); /* Triangulate the vertices. */ - } -#endif /* not CDT_ONLY */ - -#ifndef NO_TIMER - if (!b.quiet) { - gettimeofday(&tv2, &tz); - if (b.refine) { - printf("Mesh reconstruction"); - } else { - printf("Delaunay"); - } - printf(" milliseconds: %ld\n", 1000l * (tv2.tv_sec - tv1.tv_sec) + - (tv2.tv_usec - tv1.tv_usec) / 1000l); - } -#endif /* not NO_TIMER */ - - /* Ensure that no vertex can be mistaken for a triangular bounding */ - /* box vertex in insertvertex(). */ - m.infvertex1 = (vertex) NULL; - m.infvertex2 = (vertex) NULL; - m.infvertex3 = (vertex) NULL; - - if (b.usesegments) { - m.checksegments = 1; /* Segments will be introduced next. */ - if (!b.refine) { - /* Insert PSLG segments and/or convex hull segments. */ -#ifdef TRILIBRARY - formskeleton(&m, &b, in->segmentlist, - in->segmentmarkerlist, in->numberofsegments); -#else /* not TRILIBRARY */ - formskeleton(&m, &b, polyfile, b.inpolyfilename); -#endif /* not TRILIBRARY */ - } - } - -#ifndef NO_TIMER - if (!b.quiet) { - gettimeofday(&tv3, &tz); - if (b.usesegments && !b.refine) { - printf("Segment milliseconds: %ld\n", - 1000l * (tv3.tv_sec - tv2.tv_sec) + - (tv3.tv_usec - tv2.tv_usec) / 1000l); - } - } -#endif /* not NO_TIMER */ - - if (b.poly && (m.triangles.items > 0)) { -#ifdef TRILIBRARY - holearray = in->holelist; - m.holes = in->numberofholes; - regionarray = in->regionlist; - m.regions = in->numberofregions; -#else /* not TRILIBRARY */ - readholes(&m, &b, polyfile, b.inpolyfilename, &holearray, &m.holes, - ®ionarray, &m.regions); -#endif /* not TRILIBRARY */ - if (!b.refine) { - /* Carve out holes and concavities. */ - carveholes(&m, &b, holearray, m.holes, regionarray, m.regions); - } - } else { - /* Without a PSLG, there can be no holes or regional attributes */ - /* or area constraints. The following are set to zero to avoid */ - /* an accidental free() later. */ - m.holes = 0; - m.regions = 0; - } - -#ifndef NO_TIMER - if (!b.quiet) { - gettimeofday(&tv4, &tz); - if (b.poly && !b.refine) { - printf("Hole milliseconds: %ld\n", 1000l * (tv4.tv_sec - tv3.tv_sec) + - (tv4.tv_usec - tv3.tv_usec) / 1000l); - } - } -#endif /* not NO_TIMER */ - -#ifndef CDT_ONLY - if (b.quality && (m.triangles.items > 0)) { - enforcequality(&m, &b); /* Enforce angle and area constraints. */ - } -#endif /* not CDT_ONLY */ - -#ifndef NO_TIMER - if (!b.quiet) { - gettimeofday(&tv5, &tz); -#ifndef CDT_ONLY - if (b.quality) { - printf("Quality milliseconds: %ld\n", - 1000l * (tv5.tv_sec - tv4.tv_sec) + - (tv5.tv_usec - tv4.tv_usec) / 1000l); - } -#endif /* not CDT_ONLY */ - } -#endif /* not NO_TIMER */ - - /* Calculate the number of edges. */ - m.edges = (3l * m.triangles.items + m.hullsize) / 2l; - - if (b.order > 1) { - highorder(&m, &b); /* Promote elements to higher polynomial order. */ - } - if (!b.quiet) { - printf("\n"); - } - -#ifdef TRILIBRARY - if (b.jettison) { - out->numberofpoints = m.vertices.items - m.undeads; - } else { - out->numberofpoints = m.vertices.items; - } - out->numberofpointattributes = m.nextras; - out->numberoftriangles = m.triangles.items; - out->numberofcorners = (b.order + 1) * (b.order + 2) / 2; - out->numberoftriangleattributes = m.eextras; - out->numberofedges = m.edges; - if (b.usesegments) { - out->numberofsegments = m.subsegs.items; - } else { - out->numberofsegments = m.hullsize; - } - if (vorout != (struct triangulateio *) NULL) { - vorout->numberofpoints = m.triangles.items; - vorout->numberofpointattributes = m.nextras; - vorout->numberofedges = m.edges; - } -#endif /* TRILIBRARY */ - /* If not using iteration numbers, don't write a .node file if one was */ - /* read, because the original one would be overwritten! */ - if (b.nonodewritten || (b.noiterationnum && m.readnodefile)) { - if (!b.quiet) { -#ifdef TRILIBRARY - printf("NOT writing vertices.\n"); -#else /* not TRILIBRARY */ - printf("NOT writing a .node file.\n"); -#endif /* not TRILIBRARY */ - } - numbernodes(&m, &b); /* We must remember to number the vertices. */ - } else { - /* writenodes() numbers the vertices too. */ -#ifdef TRILIBRARY - writenodes(&m, &b, &out->pointlist, &out->pointattributelist, - &out->pointmarkerlist); -#else /* not TRILIBRARY */ - writenodes(&m, &b, b.outnodefilename, argc, argv); -#endif /* TRILIBRARY */ - } - if (b.noelewritten) { - if (!b.quiet) { -#ifdef TRILIBRARY - printf("NOT writing triangles.\n"); -#else /* not TRILIBRARY */ - printf("NOT writing an .ele file.\n"); -#endif /* not TRILIBRARY */ - } - } else { -#ifdef TRILIBRARY - writeelements(&m, &b, &out->trianglelist, &out->triangleattributelist); -#else /* not TRILIBRARY */ - writeelements(&m, &b, b.outelefilename, argc, argv); -#endif /* not TRILIBRARY */ - } - /* The -c switch (convex switch) causes a PSLG to be written */ - /* even if none was read. */ - if (b.poly || b.convex) { - /* If not using iteration numbers, don't overwrite the .poly file. */ - if (b.nopolywritten || b.noiterationnum) { - if (!b.quiet) { -#ifdef TRILIBRARY - printf("NOT writing segments.\n"); -#else /* not TRILIBRARY */ - printf("NOT writing a .poly file.\n"); -#endif /* not TRILIBRARY */ - } - } else { -#ifdef TRILIBRARY - writepoly(&m, &b, &out->segmentlist, &out->segmentmarkerlist); - out->numberofholes = m.holes; - out->numberofregions = m.regions; - if (b.poly) { - out->holelist = in->holelist; - out->regionlist = in->regionlist; - } else { - out->holelist = (REAL *) NULL; - out->regionlist = (REAL *) NULL; - } -#else /* not TRILIBRARY */ - writepoly(&m, &b, b.outpolyfilename, holearray, m.holes, regionarray, - m.regions, argc, argv); -#endif /* not TRILIBRARY */ - } - } -#ifndef TRILIBRARY -#ifndef CDT_ONLY - if (m.regions > 0) { - trifree((VOID *) regionarray); - } -#endif /* not CDT_ONLY */ - if (m.holes > 0) { - trifree((VOID *) holearray); - } - if (b.geomview) { - writeoff(&m, &b, b.offfilename, argc, argv); - } -#endif /* not TRILIBRARY */ - if (b.edgesout) { -#ifdef TRILIBRARY - writeedges(&m, &b, &out->edgelist, &out->edgemarkerlist); -#else /* not TRILIBRARY */ - writeedges(&m, &b, b.edgefilename, argc, argv); -#endif /* not TRILIBRARY */ - } - if (b.voronoi) { -#ifdef TRILIBRARY - writevoronoi(&m, &b, &vorout->pointlist, &vorout->pointattributelist, - &vorout->pointmarkerlist, &vorout->edgelist, - &vorout->edgemarkerlist, &vorout->normlist); -#else /* not TRILIBRARY */ - writevoronoi(&m, &b, b.vnodefilename, b.vedgefilename, argc, argv); -#endif /* not TRILIBRARY */ - } - if (b.neighbors) { -#ifdef TRILIBRARY - writeneighbors(&m, &b, &out->neighborlist); -#else /* not TRILIBRARY */ - writeneighbors(&m, &b, b.neighborfilename, argc, argv); -#endif /* not TRILIBRARY */ - } - - if (!b.quiet) { -#ifndef NO_TIMER - gettimeofday(&tv6, &tz); - printf("\nOutput milliseconds: %ld\n", - 1000l * (tv6.tv_sec - tv5.tv_sec) + - (tv6.tv_usec - tv5.tv_usec) / 1000l); - printf("Total running milliseconds: %ld\n", - 1000l * (tv6.tv_sec - tv0.tv_sec) + - (tv6.tv_usec - tv0.tv_usec) / 1000l); -#endif /* not NO_TIMER */ - - statistics(&m, &b); - } - -#ifndef REDUCED - if (b.docheck) { - checkmesh(&m, &b); - checkdelaunay(&m, &b); - } -#endif /* not REDUCED */ - - triangledeinit(&m, &b); -#ifndef TRILIBRARY - return 0; -#endif /* not TRILIBRARY */ -} diff --git a/external/cork/src/isct/triangle.h b/external/cork/src/isct/triangle.h deleted file mode 100644 index dbf087a13..000000000 --- a/external/cork/src/isct/triangle.h +++ /dev/null @@ -1,289 +0,0 @@ -/*****************************************************************************/ -/* */ -/* (triangle.h) */ -/* */ -/* Include file for programs that call Triangle. */ -/* */ -/* Accompanies Triangle Version 1.6 */ -/* July 28, 2005 */ -/* */ -/* Copyright 1996, 2005 */ -/* Jonathan Richard Shewchuk */ -/* 2360 Woolsey #H */ -/* Berkeley, California 94705-1927 */ -/* jrs@cs.berkeley.edu */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* How to call Triangle from another program */ -/* */ -/* */ -/* If you haven't read Triangle's instructions (run "triangle -h" to read */ -/* them), you won't understand what follows. */ -/* */ -/* Triangle must be compiled into an object file (triangle.o) with the */ -/* TRILIBRARY symbol defined (generally by using the -DTRILIBRARY compiler */ -/* switch). The makefile included with Triangle will do this for you if */ -/* you run "make trilibrary". The resulting object file can be called via */ -/* the procedure triangulate(). */ -/* */ -/* If the size of the object file is important to you, you may wish to */ -/* generate a reduced version of triangle.o. The REDUCED symbol gets rid */ -/* of all features that are primarily of research interest. Specifically, */ -/* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */ -/* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */ -/* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */ -/* eliminates Triangle's -r, -q, -a, -u, -D, -Y, -S, and -s switches. */ -/* */ -/* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */ -/* made in the makefile or in triangle.c itself. Putting these definitions */ -/* in this file (triangle.h) will not create the desired effect. */ -/* */ -/* */ -/* The calling convention for triangulate() follows. */ -/* */ -/* void triangulate(triswitches, in, out, vorout) */ -/* char *triswitches; */ -/* struct triangulateio *in; */ -/* struct triangulateio *out; */ -/* struct triangulateio *vorout; */ -/* */ -/* `triswitches' is a string containing the command line switches you wish */ -/* to invoke. No initial dash is required. Some suggestions: */ -/* */ -/* - You'll probably find it convenient to use the `z' switch so that */ -/* points (and other items) are numbered from zero. This simplifies */ -/* indexing, because the first item of any type always starts at index */ -/* [0] of the corresponding array, whether that item's number is zero or */ -/* one. */ -/* - You'll probably want to use the `Q' (quiet) switch in your final code, */ -/* but you can take advantage of Triangle's printed output (including the */ -/* `V' switch) while debugging. */ -/* - If you are not using the `q', `a', `u', `D', `j', or `s' switches, */ -/* then the output points will be identical to the input points, except */ -/* possibly for the boundary markers. If you don't need the boundary */ -/* markers, you should use the `N' (no nodes output) switch to save */ -/* memory. (If you do need boundary markers, but need to save memory, a */ -/* good nasty trick is to set out->pointlist equal to in->pointlist */ -/* before calling triangulate(), so that Triangle overwrites the input */ -/* points with identical copies.) */ -/* - The `I' (no iteration numbers) and `g' (.off file output) switches */ -/* have no effect when Triangle is compiled with TRILIBRARY defined. */ -/* */ -/* `in', `out', and `vorout' are descriptions of the input, the output, */ -/* and the Voronoi output. If the `v' (Voronoi output) switch is not used, */ -/* `vorout' may be NULL. `in' and `out' may never be NULL. */ -/* */ -/* Certain fields of the input and output structures must be initialized, */ -/* as described below. */ -/* */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* */ -/* The `triangulateio' structure. */ -/* */ -/* Used to pass data into and out of the triangulate() procedure. */ -/* */ -/* */ -/* Arrays are used to store points, triangles, markers, and so forth. In */ -/* all cases, the first item in any array is stored starting at index [0]. */ -/* However, that item is item number `1' unless the `z' switch is used, in */ -/* which case it is item number `0'. Hence, you may find it easier to */ -/* index points (and triangles in the neighbor list) if you use the `z' */ -/* switch. Unless, of course, you're calling Triangle from a Fortran */ -/* program. */ -/* */ -/* Description of fields (except the `numberof' fields, which are obvious): */ -/* */ -/* `pointlist': An array of point coordinates. The first point's x */ -/* coordinate is at index [0] and its y coordinate at index [1], followed */ -/* by the coordinates of the remaining points. Each point occupies two */ -/* REALs. */ -/* `pointattributelist': An array of point attributes. Each point's */ -/* attributes occupy `numberofpointattributes' REALs. */ -/* `pointmarkerlist': An array of point markers; one int per point. */ -/* */ -/* `trianglelist': An array of triangle corners. The first triangle's */ -/* first corner is at index [0], followed by its other two corners in */ -/* counterclockwise order, followed by any other nodes if the triangle */ -/* represents a nonlinear element. Each triangle occupies */ -/* `numberofcorners' ints. */ -/* `triangleattributelist': An array of triangle attributes. Each */ -/* triangle's attributes occupy `numberoftriangleattributes' REALs. */ -/* `trianglearealist': An array of triangle area constraints; one REAL per */ -/* triangle. Input only. */ -/* `neighborlist': An array of triangle neighbors; three ints per */ -/* triangle. Output only. */ -/* */ -/* `segmentlist': An array of segment endpoints. The first segment's */ -/* endpoints are at indices [0] and [1], followed by the remaining */ -/* segments. Two ints per segment. */ -/* `segmentmarkerlist': An array of segment markers; one int per segment. */ -/* */ -/* `holelist': An array of holes. The first hole's x and y coordinates */ -/* are at indices [0] and [1], followed by the remaining holes. Two */ -/* REALs per hole. Input only, although the pointer is copied to the */ -/* output structure for your convenience. */ -/* */ -/* `regionlist': An array of regional attributes and area constraints. */ -/* The first constraint's x and y coordinates are at indices [0] and [1], */ -/* followed by the regional attribute at index [2], followed by the */ -/* maximum area at index [3], followed by the remaining area constraints. */ -/* Four REALs per area constraint. Note that each regional attribute is */ -/* used only if you select the `A' switch, and each area constraint is */ -/* used only if you select the `a' switch (with no number following), but */ -/* omitting one of these switches does not change the memory layout. */ -/* Input only, although the pointer is copied to the output structure for */ -/* your convenience. */ -/* */ -/* `edgelist': An array of edge endpoints. The first edge's endpoints are */ -/* at indices [0] and [1], followed by the remaining edges. Two ints per */ -/* edge. Output only. */ -/* `edgemarkerlist': An array of edge markers; one int per edge. Output */ -/* only. */ -/* `normlist': An array of normal vectors, used for infinite rays in */ -/* Voronoi diagrams. The first normal vector's x and y magnitudes are */ -/* at indices [0] and [1], followed by the remaining vectors. For each */ -/* finite edge in a Voronoi diagram, the normal vector written is the */ -/* zero vector. Two REALs per edge. Output only. */ -/* */ -/* */ -/* Any input fields that Triangle will examine must be initialized. */ -/* Furthermore, for each output array that Triangle will write to, you */ -/* must either provide space by setting the appropriate pointer to point */ -/* to the space you want the data written to, or you must initialize the */ -/* pointer to NULL, which tells Triangle to allocate space for the results. */ -/* The latter option is preferable, because Triangle always knows exactly */ -/* how much space to allocate. The former option is provided mainly for */ -/* people who need to call Triangle from Fortran code, though it also makes */ -/* possible some nasty space-saving tricks, like writing the output to the */ -/* same arrays as the input. */ -/* */ -/* Triangle will not free() any input or output arrays, including those it */ -/* allocates itself; that's up to you. You should free arrays allocated by */ -/* Triangle by calling the trifree() procedure defined below. (By default, */ -/* trifree() just calls the standard free() library procedure, but */ -/* applications that call triangulate() may replace trimalloc() and */ -/* trifree() in triangle.c to use specialized memory allocators.) */ -/* */ -/* Here's a guide to help you decide which fields you must initialize */ -/* before you call triangulate(). */ -/* */ -/* `in': */ -/* */ -/* - `pointlist' must always point to a list of points; `numberofpoints' */ -/* and `numberofpointattributes' must be properly set. */ -/* `pointmarkerlist' must either be set to NULL (in which case all */ -/* markers default to zero), or must point to a list of markers. If */ -/* `numberofpointattributes' is not zero, `pointattributelist' must */ -/* point to a list of point attributes. */ -/* - If the `r' switch is used, `trianglelist' must point to a list of */ -/* triangles, and `numberoftriangles', `numberofcorners', and */ -/* `numberoftriangleattributes' must be properly set. If */ -/* `numberoftriangleattributes' is not zero, `triangleattributelist' */ -/* must point to a list of triangle attributes. If the `a' switch is */ -/* used (with no number following), `trianglearealist' must point to a */ -/* list of triangle area constraints. `neighborlist' may be ignored. */ -/* - If the `p' switch is used, `segmentlist' must point to a list of */ -/* segments, `numberofsegments' must be properly set, and */ -/* `segmentmarkerlist' must either be set to NULL (in which case all */ -/* markers default to zero), or must point to a list of markers. */ -/* - If the `p' switch is used without the `r' switch, then */ -/* `numberofholes' and `numberofregions' must be properly set. If */ -/* `numberofholes' is not zero, `holelist' must point to a list of */ -/* holes. If `numberofregions' is not zero, `regionlist' must point to */ -/* a list of region constraints. */ -/* - If the `p' switch is used, `holelist', `numberofholes', */ -/* `regionlist', and `numberofregions' is copied to `out'. (You can */ -/* nonetheless get away with not initializing them if the `r' switch is */ -/* used.) */ -/* - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */ -/* ignored. */ -/* */ -/* `out': */ -/* */ -/* - `pointlist' must be initialized (NULL or pointing to memory) unless */ -/* the `N' switch is used. `pointmarkerlist' must be initialized */ -/* unless the `N' or `B' switch is used. If `N' is not used and */ -/* `in->numberofpointattributes' is not zero, `pointattributelist' must */ -/* be initialized. */ -/* - `trianglelist' must be initialized unless the `E' switch is used. */ -/* `neighborlist' must be initialized if the `n' switch is used. If */ -/* the `E' switch is not used and (`in->numberofelementattributes' is */ -/* not zero or the `A' switch is used), `elementattributelist' must be */ -/* initialized. `trianglearealist' may be ignored. */ -/* - `segmentlist' must be initialized if the `p' or `c' switch is used, */ -/* and the `P' switch is not used. `segmentmarkerlist' must also be */ -/* initialized under these circumstances unless the `B' switch is used. */ -/* - `edgelist' must be initialized if the `e' switch is used. */ -/* `edgemarkerlist' must be initialized if the `e' switch is used and */ -/* the `B' switch is not. */ -/* - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/ -/* */ -/* `vorout' (only needed if `v' switch is used): */ -/* */ -/* - `pointlist' must be initialized. If `in->numberofpointattributes' */ -/* is not zero, `pointattributelist' must be initialized. */ -/* `pointmarkerlist' may be ignored. */ -/* - `edgelist' and `normlist' must both be initialized. */ -/* `edgemarkerlist' may be ignored. */ -/* - Everything else may be ignored. */ -/* */ -/* After a call to triangulate(), the valid fields of `out' and `vorout' */ -/* will depend, in an obvious way, on the choice of switches used. Note */ -/* that when the `p' switch is used, the pointers `holelist' and */ -/* `regionlist' are copied from `in' to `out', but no new space is */ -/* allocated; be careful that you don't free() the same array twice. On */ -/* the other hand, Triangle will never copy the `pointlist' pointer (or any */ -/* others); new space is allocated for `out->pointlist', or if the `N' */ -/* switch is used, `out->pointlist' remains uninitialized. */ -/* */ -/* All of the meaningful `numberof' fields will be properly set; for */ -/* instance, `numberofedges' will represent the number of edges in the */ -/* triangulation whether or not the edges were written. If segments are */ -/* not used, `numberofsegments' will indicate the number of boundary edges. */ -/* */ -/*****************************************************************************/ - -struct triangulateio { - REAL *pointlist; /* In / out */ - REAL *pointattributelist; /* In / out */ - int *pointmarkerlist; /* In / out */ - int numberofpoints; /* In / out */ - int numberofpointattributes; /* In / out */ - - int *trianglelist; /* In / out */ - REAL *triangleattributelist; /* In / out */ - REAL *trianglearealist; /* In only */ - int *neighborlist; /* Out only */ - int numberoftriangles; /* In / out */ - int numberofcorners; /* In / out */ - int numberoftriangleattributes; /* In / out */ - - int *segmentlist; /* In / out */ - int *segmentmarkerlist; /* In / out */ - int numberofsegments; /* In / out */ - - REAL *holelist; /* In / pointer to array copied out */ - int numberofholes; /* In / copied out */ - - REAL *regionlist; /* In / pointer to array copied out */ - int numberofregions; /* In / copied out */ - - int *edgelist; /* Out only */ - int *edgemarkerlist; /* Not used with Voronoi diagram; out only */ - REAL *normlist; /* Used only with Voronoi diagram; out only */ - int numberofedges; /* Out only */ -}; - -/*#ifdef ANSI_DECLARATORS*/ -void triangulate(char *, struct triangulateio *, struct triangulateio *, - struct triangulateio *); -void trifree(void *memptr); -/*#else*/ /* not ANSI_DECLARATORS */ -/*void triangulate(); -void trifree();*/ -/*#endif*/ /* not ANSI_DECLARATORS */ diff --git a/external/cork/src/isct/unsafeRayTriIsct.h b/external/cork/src/isct/unsafeRayTriIsct.h deleted file mode 100644 index 201e740cb..000000000 --- a/external/cork/src/isct/unsafeRayTriIsct.h +++ /dev/null @@ -1,83 +0,0 @@ -// +------------------------------------------------------------------------- -// | unsafeRayTriIsct.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "ray.h" -#include "vec.h" - -struct isct_ray_triangle_result -{ - double t; - Vec3d bary; -}; - -inline -bool isct_ray_triangle( - Ray3d ray, - Vec3d va, - Vec3d vb, - Vec3d vc, - double *t, - Vec3d *bary -) { - ENSURE(t); - ENSURE(bary); - - // re-center the problem at the base point of the ray - va -= ray.p; - vb -= ray.p; - vc -= ray.p; - - // Then compute volumes of tetrahedra spanning - // * the base point / ray direction line segment - // * an edge of the triangle - // Keeping orientations in mind... - double volAB = det(va, vb, ray.r); - double volBC = det(vb, vc, ray.r); - double volCA = - det(va, vc, ray.r); - // then also compute the volume of tet with the entire triangle as a face... - double volABC = det(va, vb, vc); - // if any of the signs of the edge tests - // disagree with the sign of the whole triangle, then - // the ray does not pass through the triangle - if(volAB * volABC < 0 || - volBC * volABC < 0 || - volCA * volABC < 0) return false; - - // otherwise, compute the t - value for the ray to intersect - // if this is negative, then the client can detect that the - // ray would have to travel backwards to hit the triangle in question. - double edgeSum = volAB + volBC + volCA; - if(edgeSum == 0) return false; - *t = volABC / (volAB + volBC + volCA); - if(*t <= 0) return false; - - *bary = Vec3d(volBC/edgeSum, volCA/edgeSum, volAB/edgeSum); - return true; -} - - - diff --git a/external/cork/src/main.cpp b/external/cork/src/main.cpp deleted file mode 100644 index d9f116628..000000000 --- a/external/cork/src/main.cpp +++ /dev/null @@ -1,322 +0,0 @@ -// +------------------------------------------------------------------------- -// | main.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- - -// This file contains a command line program that can be used -// to exercise Cork's functionality without having to write -// any code. - -#include "files.h" - -#include -using std::cout; -using std::cerr; -using std::endl; -#include -using std::stringstream; -using std::string; - -using std::ostream; - -#include "cork.h" - - -void file2corktrimesh( - const Files::FileMesh &in, CorkTriMesh *out -) { - out->n_vertices = in.vertices.size(); - out->n_triangles = in.triangles.size(); - - out->triangles = new uint[(out->n_triangles) * 3]; - out->vertices = new double[(out->n_vertices) * 3]; - - for(uint i=0; in_triangles; i++) { - (out->triangles)[3*i+0] = in.triangles[i].a; - (out->triangles)[3*i+1] = in.triangles[i].b; - (out->triangles)[3*i+2] = in.triangles[i].c; - } - - for(uint i=0; in_vertices; i++) { - (out->vertices)[3*i+0] = in.vertices[i].pos.x; - (out->vertices)[3*i+1] = in.vertices[i].pos.y; - (out->vertices)[3*i+2] = in.vertices[i].pos.z; - } -} - -void corktrimesh2file( - CorkTriMesh in, Files::FileMesh &out -) { - out.vertices.resize(in.n_vertices); - out.triangles.resize(in.n_triangles); - - for(uint i=0; i 0) { - cerr << "Unable to load in " << filename << endl; - exit(1); - } - - file2corktrimesh(filemesh, out); -} -void saveMesh(string filename, CorkTriMesh in) -{ - Files::FileMesh filemesh; - - corktrimesh2file(in, filemesh); - - if(Files::writeTriMesh(filename, &filemesh) > 0) { - cerr << "Unable to write to " << filename << endl; - exit(1); - } -} - - - -class CmdList { -public: - CmdList(); - ~CmdList() {} - - void regCmd( - string name, - string helptxt, - std::function< void(std::vector::iterator &, - const std::vector::iterator &) > body - ); - - void printHelp(ostream &out); - void runCommands(std::vector::iterator &arg_it, - const std::vector::iterator &end_it); - -private: - struct Command { - string name; // e.g. "show" will be invoked with option "-show" - string helptxt; // lines to be displayed - std::function< void(std::vector::iterator &, - const std::vector::iterator &) > body; - }; - std::vector commands; -}; - -CmdList::CmdList() -{ - regCmd("help", - "-help show this help message", - [this](std::vector::iterator &, - const std::vector::iterator &) { - printHelp(cout); - exit(0); - }); -} - -void CmdList::regCmd( - string name, - string helptxt, - std::function< void(std::vector::iterator &, - const std::vector::iterator &) > body -) { - Command cmd = { - name, - helptxt, - body - }; - commands.push_back(cmd); -} - -void CmdList::printHelp(ostream &out) -{ - out << - "Welcome to Cork. Usage:" << endl << - " > cork [-command arg0 arg1 ... argn]*" << endl << - "for example," << endl << - " > cork -union box0.off box1.off result.off" << endl << - "Options:" << endl; - for(auto &cmd : commands) - out << cmd.helptxt << endl; - out << endl; -} - -void CmdList::runCommands(std::vector::iterator &arg_it, - const std::vector::iterator &end_it) -{ - while(arg_it != end_it) { - string arg_cmd = *arg_it; - if(arg_cmd[0] != '-') { - cerr << arg_cmd << endl; - cerr << "All commands must begin with '-'" << endl; - exit(1); - } - arg_cmd = arg_cmd.substr(1); - arg_it++; - - bool found = true; - for(auto &cmd : commands) { - if(arg_cmd == cmd.name) { - cmd.body(arg_it, end_it); - found = true; - break; - } - } - if(!found) { - cerr << "Command -" + arg_cmd + " is not recognized" << endl; - exit(1); - } - } -} - - -std::function< void( - std::vector::iterator &, - const std::vector::iterator & -) > -genericBinaryOp( - std::function< void(CorkTriMesh in0, CorkTriMesh in1, CorkTriMesh *out) > - binop -) { - return [binop] - (std::vector::iterator &args, - const std::vector::iterator &end) { - // data... - CorkTriMesh in0; - CorkTriMesh in1; - CorkTriMesh out; - - if(args == end) { cerr << "too few args" << endl; exit(1); } - loadMesh(*args, &in0); - args++; - - if(args == end) { cerr << "too few args" << endl; exit(1); } - loadMesh(*args, &in1); - args++; - - binop(in0, in1, &out); - - if(args == end) { cerr << "too few args" << endl; exit(1); } - saveMesh(*args, out); - args++; - - freeCorkTriMesh(&out); - - delete[] in0.vertices; - delete[] in0.triangles; - delete[] in1.vertices; - delete[] in1.triangles; - }; -} - - -int main(int argc, char *argv[]) -{ - initRand(); // that's useful - - if(argc < 2) { - cout << "Please type 'cork -help' for instructions" << endl; - exit(0); - } - - // store arguments in a standard container - std::vector args(argc); - for(int k=0; k::iterator &args, - const std::vector::iterator &end) { - CorkTriMesh in; - if(args == end) { cerr << "too few args" << endl; exit(1); } - string filename = *args; - loadMesh(*args, &in); - args++; - - bool solid = isSolid(in); - cout << "The mesh " << filename << " is: " << endl; - cout << " " << ((solid)? "SOLID" : "NOT SOLID") << endl; - - delete[] in.vertices; - delete[] in.triangles; - }); - cmds.regCmd("union", - "-union in0 in1 out Compute the Boolean union of in0 and in1,\n" - " and output the result", - genericBinaryOp(computeUnion)); - cmds.regCmd("diff", - "-diff in0 in1 out Compute the Boolean difference of in0 and in1,\n" - " and output the result", - genericBinaryOp(computeDifference)); - cmds.regCmd("isct", - "-isct in0 in1 out Compute the Boolean intersection of in0 and in1,\n" - " and output the result", - genericBinaryOp(computeIntersection)); - cmds.regCmd("xor", - "-xor in0 in1 out Compute the Boolean XOR of in0 and in1,\n" - " and output the result\n" - " (aka. the symmetric difference)", - genericBinaryOp(computeSymmetricDifference)); - cmds.regCmd("resolve", - "-resolve in0 in1 out Intersect the two meshes in0 and in1,\n" - " and output the connected mesh with those\n" - " intersections made explicit and connected", - genericBinaryOp(resolveIntersections)); - - - cmds.runCommands(arg_it, args.end()); - - return 0; -} - - - - - - - - - diff --git a/external/cork/src/math/bbox.h b/external/cork/src/math/bbox.h deleted file mode 100644 index 854e9371c..000000000 --- a/external/cork/src/math/bbox.h +++ /dev/null @@ -1,246 +0,0 @@ -// +------------------------------------------------------------------------- -// | bbox.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "vec.h" - -#include - -// NOTE on usage of BBoxes -// all BBoxes are initialized so that -// convex(BBox(), bb) == bb -// for any bb - - -// ************************************************************************** -// * BBox2 stores 2-dimensional axis aligned bounding boxes -// ************************************************************************** -template -class BBox2 { -public: // data - Vec2 minp, maxp; -public: // constructors - BBox2(const Vec2 &minpp, const Vec2 &maxpp) : - minp(minpp), maxp(maxpp) {} - inline BBox2(const BBox2 &bb) : minp(bb.minp), maxp(bb.maxp) {} - inline BBox2(); // specialized implementations for float/double only -}; - -template<> inline -BBox2::BBox2() : - minp( FLT_MAX, FLT_MAX), - maxp(-FLT_MAX,-FLT_MAX) -{} -template<> inline -BBox2::BBox2() : - minp( DBL_MAX, DBL_MAX), - maxp(-DBL_MAX,-DBL_MAX) -{} - -template -inline bool isEmpty(const BBox2 &bb) { - return bb.maxp[0] < bb.minp[0] || - bb.maxp[1] < bb.minp[1]; -} -template -inline bool isIn(const Vec2 &p, const BBox2 &bb) { - return bb.minp[0] <= p[0] && p[0] <= bb.maxp[0] && - bb.minp[1] <= p[1] && p[1] <= bb.maxp[1]; -} -template -inline bool hasIsct(const BBox2 &lhs, const BBox2 &rhs) { - return lhs.minp[0] <= rhs.maxp[0] && lhs.maxp[0] >= rhs.minp[0] && - lhs.minp[1] <= rhs.maxp[1] && lhs.maxp[1] >= rhs.minp[1]; -} -template -inline BBox2 convex(const BBox2 &lhs, const BBox2 &rhs) { - return BBox2(min(lhs.minp, rhs.minp), max(lhs.maxp, rhs.maxp)); -} -template -inline BBox2 isct(const BBox2 &lhs, const BBox2 &rhs) { - return BBox2(max(lhs.minp, rhs.minp), min(lhs.maxp, rhs.maxp)); -} - -template -inline Vec2 dim(const BBox2 &bb) { - return bb.maxp - bb.minp; -} -template -inline N perimeter(const BBox2 &bb) { - Vec2 d = dim(bb); - return 2*(d[0] + d[1]); -} - -template -inline std::ostream& operator<<(std::ostream &out, const BBox2 &bb) { - return out << "[min" << bb.minp << ";max" << bb.maxp << ']'; -} - -// ************************************************************************** -// * BBox3 stores 3-dimensional axis aligned bounding boxes -// ************************************************************************** -template -class BBox3 { -public: // data - Vec3 minp, maxp; -public: // constructors - BBox3(const Vec3 &minpp, const Vec3 &maxpp) : - minp(minpp), maxp(maxpp) {} - inline BBox3(const BBox3 &bb) : minp(bb.minp), maxp(bb.maxp) {} - inline BBox3(); // specialized implementations for float/double only -}; - -template<> inline -BBox3::BBox3() : - minp( FLT_MAX, FLT_MAX, FLT_MAX), - maxp(-FLT_MAX,-FLT_MAX,-FLT_MAX) -{} -template<> inline -BBox3::BBox3() : - minp( DBL_MAX, DBL_MAX, DBL_MAX), - maxp(-DBL_MAX,-DBL_MAX,-DBL_MAX) -{} - -template -inline bool isEmpty(const BBox3 &bb) { - return bb.maxp[0] < bb.minp[0] || - bb.maxp[1] < bb.minp[1] || - bb.maxp[2] < bb.minp[2]; -} -template -inline bool isIn(const Vec3 &p, const BBox3 &bb) { - return bb.minp[0] <= p[0] && p[0] <= bb.maxp[0] && - bb.minp[1] <= p[1] && p[1] <= bb.maxp[1] && - bb.minp[2] <= p[2] && p[2] <= bb.maxp[2]; -} -template -inline bool hasIsct(const BBox3 &lhs, const BBox3 &rhs) { - return lhs.minp[0] <= rhs.maxp[0] && lhs.maxp[0] >= rhs.minp[0] && - lhs.minp[1] <= rhs.maxp[1] && lhs.maxp[1] >= rhs.minp[1] && - lhs.minp[2] <= rhs.maxp[2] && lhs.maxp[2] >= rhs.minp[2]; -} -template -inline BBox3 convex(const BBox3 &lhs, const BBox3 &rhs) { - return BBox3(min(lhs.minp, rhs.minp), max(lhs.maxp, rhs.maxp)); -} -template -inline BBox3 isct(const BBox3 &lhs, const BBox3 &rhs) { - return BBox3(max(lhs.minp, rhs.minp), min(lhs.maxp, rhs.maxp)); -} - -template -inline Vec3 dim(const BBox3 &bb) { - return bb.maxp - bb.minp; -} -template -inline N surfaceArea(const BBox3 &bb) { - Vec3 d = dim(bb); - return 2*(d[1]*d[2] + d[0]*d[2] + d[0]*d[1]); -} - -template -inline std::ostream& operator<<(std::ostream &out, const BBox3 &bb) { - return out << "[min" << bb.minp << ";max" << bb.maxp << ']'; -} - - -// ************************************************************************** -// * BBox4 stores 4-dimensional axis aligned bounding boxes -// ************************************************************************** -template -class BBox4 { -public: // data - Vec4 minp, maxp; -public: // constructors - BBox4(const Vec4 &minpp, const Vec4 &maxpp) : - minp(minpp), maxp(maxpp) {} - inline BBox4(const BBox4 &bb) : minp(bb.minp), maxp(bb.maxp) {} - inline BBox4(); // specialized implementations for float/double only -}; - -template<> inline -BBox4::BBox4() : - minp( FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX), - maxp(-FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX) -{} -template<> inline -BBox4::BBox4() : - minp( DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX), - maxp(-DBL_MAX,-DBL_MAX,-DBL_MAX,-DBL_MAX) -{} - -template -inline bool isEmpty(const BBox4 &bb) { - return bb.maxp[0] < bb.minp[0] || - bb.maxp[1] < bb.minp[1] || - bb.maxp[2] < bb.minp[2] || - bb.maxp[3] < bb.minp[3]; -} -template -inline bool isIn(const Vec4 &p, const BBox4 &bb) { - return bb.minp[0] <= p[0] && p[0] <= bb.maxp[0] && - bb.minp[1] <= p[1] && p[1] <= bb.maxp[1] && - bb.minp[2] <= p[2] && p[2] <= bb.maxp[2] && - bb.minp[3] <= p[3] && p[3] <= bb.maxp[3]; -} -template -inline bool hasIsct(const BBox4 &lhs, const BBox4 &rhs) { - return lhs.minp[0] <= rhs.maxp[0] && lhs.maxp[0] >= rhs.minp[0] && - lhs.minp[1] <= rhs.maxp[1] && lhs.maxp[1] >= rhs.minp[1] && - lhs.minp[2] <= rhs.maxp[2] && lhs.maxp[2] >= rhs.minp[2] && - lhs.minp[3] <= rhs.maxp[3] && lhs.maxp[3] >= rhs.minp[3]; -} -template -inline BBox4 convex(const BBox4 &lhs, const BBox4 &rhs) { - return BBox4(min(lhs.minp, rhs.minp), max(lhs.maxp, rhs.maxp)); -} -template -inline BBox4 isct(const BBox4 &lhs, const BBox4 &rhs) { - return BBox4(max(lhs.minp, rhs.minp), min(lhs.maxp, rhs.maxp)); -} - -template -inline Vec4 dim(const BBox4 &bb) { - return bb.maxp - bb.minp; -} - -template -inline std::ostream& operator<<(std::ostream &out, const BBox4 &bb) { - return out << "[min" << bb.minp << ";max" << bb.maxp << ']'; -} - - - -// define some common useful versions of the boxes -typedef BBox2 BBox2f; -typedef BBox3 BBox3f; -typedef BBox4 BBox4f; - -typedef BBox2 BBox2d; -typedef BBox3 BBox3d; -typedef BBox4 BBox4d; - - diff --git a/external/cork/src/math/ray.h b/external/cork/src/math/ray.h deleted file mode 100644 index f8e3d0b7f..000000000 --- a/external/cork/src/math/ray.h +++ /dev/null @@ -1,53 +0,0 @@ -// +------------------------------------------------------------------------- -// | ray.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "vec.h" - -template -struct Ray3 -{ - Vec3 p; // point of origin - Vec3 r; // ray direction - - Ray3() {} - Ray3(const Vec3 &point, const Vec3 &dir) : - p(point), r(dir) - {} - template - Ray3(const Ray3 &cp) : p(cp.p), r(cp.r) {} -}; - - -template -inline std::ostream& operator<<(std::ostream &out, const Ray3 &ray) { - return out << '[' << ray.p << ';' << ray.r << ']'; -} - - -typedef Ray3 Ray3f; -typedef Ray3 Ray3d; - diff --git a/external/cork/src/math/vec.h b/external/cork/src/math/vec.h deleted file mode 100644 index 456febbe9..000000000 --- a/external/cork/src/math/vec.h +++ /dev/null @@ -1,879 +0,0 @@ -// +------------------------------------------------------------------------- -// | vec.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include -#include -#include - -#include "prelude.h" - -// ************************************************************************** -// * Vec2 stores 2-dimensional vectors using whatever base type you choose -// ************************************************************************** -template -class Vec2 { -public: // names - union { - N v[2]; - struct { - N x; - N y; - }; - struct { - N s; - N t; - }; - }; -// +--------------------------------- -public: // constructors - inline Vec2() {} - inline Vec2(const N &n0, const N &n1) : x(n0), y(n1) {} - // allows implicit conversion based on generics... - template - inline Vec2(const Vec2 &cp) : x(cp.x), y(cp.y) {} - // build from short array in memory - inline Vec2(const N *ns) : x(ns[0]), y(ns[1]) {} -// +--------------------------------- -public: // indexing - inline N& operator[](uint i) { return v[i]; } - inline N operator[](uint i) const { return v[i]; } -// +--------------------------------- -public: // destructive arithmetic - inline Vec2& operator+=(const Vec2 &rhs); - inline Vec2& operator-=(const Vec2 &rhs); - inline Vec2& operator*=(const N &rhs); - inline Vec2& operator/=(const N &rhs); -}; -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec2 &lhs, const Vec2 &rhs); -template -inline bool operator!=(const Vec2 &lhs, const Vec2 &rhs); -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec2 operator+(const Vec2 &lhs, const Vec2 &rhs); -template -inline Vec2 operator-(const Vec2 &lhs, const Vec2 &rhs); -template -inline Vec2 operator*(const Vec2 &lhs, const N &rhs); -template -inline Vec2 operator*(const N &lhs, const Vec2 &rhs); -template -inline Vec2 operator/(const Vec2 &lhs, const N &rhs); -template -inline Vec2 operator-(const Vec2 &vec); -template -inline Vec2 abs(const Vec2 &vec); -// +--------------------------------- -// component-wise max/min -template -inline Vec2 max(const Vec2 &lhs, const Vec2 &rhs); -template -inline Vec2 min(const Vec2 &lhs, const Vec2 &rhs); -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec2 &vec); -template -inline uint minDim(const Vec2 &vec); -template -inline N proj(uint dim, const Vec2 &vec); -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec2 &lhs, const Vec2 &rhs); -// determinant of 2 vec2s -template -inline N det(const Vec2 &lhs, const Vec2 &rhs); -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec2 &vec); -template -inline N len(const Vec2 &vec); -template -inline N max(const Vec2 &vec); -template -inline N min(const Vec2 &vec); -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec2 &vec); -template -inline Vec2 normalized(const Vec2 &vec); -// +--------------------------------- -// output/input stream operators -template -inline std::ostream& operator<<(std::ostream &out, const Vec2 &vec) { - return out << '[' << vec.x << ',' << vec.y << ']'; -} - -// ************************************************************************** -// * Vec3 stores 3-dimensional vectors using whatever base type you choose -// ************************************************************************** -template -class Vec3 { -public: // names - union { - N v[3]; - struct { - N x; - N y; - N z; - }; - struct { - N r; - N g; - N b; - }; - }; -// +--------------------------------- -public: // constructors - inline Vec3() {} - inline Vec3(const N &n0, const N &n1, const N &n2) : x(n0), y(n1), z(n2) {} - // allows implicit conversion based on generics... - template - inline Vec3(const Vec3 &cp) : x(cp.x), y(cp.y), z(cp.z) {} - // build from short array in memory - inline Vec3(const N *ns) : x(ns[0]), y(ns[1]), z(ns[2]) {} -// +--------------------------------- -public: // indexing - inline N& operator[](uint i) { return v[i]; } - inline N operator[](uint i) const { return v[i]; } -// +--------------------------------- -public: // destructive arithmetic - inline Vec3& operator+=(const Vec3 &rhs); - inline Vec3& operator-=(const Vec3 &rhs); - inline Vec3& operator*=(const N &rhs); - inline Vec3& operator/=(const N &rhs); -}; -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec3 &lhs, const Vec3 &rhs); -template -inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs); -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec3 operator+(const Vec3 &lhs, const Vec3 &rhs); -template -inline Vec3 operator-(const Vec3 &lhs, const Vec3 &rhs); -template -inline Vec3 operator*(const Vec3 &lhs, const N &rhs); -template -inline Vec3 operator*(const N &lhs, const Vec3 &rhs); -template -inline Vec3 operator/(const Vec3 &lhs, const N &rhs); -template -inline Vec3 operator-(const Vec3 &vec); -template -inline Vec3 abs(const Vec3 &vec); -// +--------------------------------- -// component-wise max/min -template -inline Vec3 max(const Vec3 &lhs, const Vec3 &rhs); -template -inline Vec3 min(const Vec3 &lhs, const Vec3 &rhs); -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec3 &vec); -template -inline uint minDim(const Vec3 &vec); -template -inline Vec2 proj(uint dim, const Vec3 &vec); -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec3 &lhs, const Vec3 &rhs); -template -inline Vec3 cross(const Vec3 &lhs, const Vec3 &rhs); -// determinant of 3 Vec3s -template -inline N det(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2); -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec3 &vec); -template -inline N len(const Vec3 &vec); -template -inline N max(const Vec3 &vec); -template -inline N min(const Vec3 &vec); -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec3 &vec); -template -inline Vec3 normalized(const Vec3 &vec); -// +--------------------------------- -// output/input stream operators -template -inline std::ostream& operator<<(std::ostream &out, const Vec3 &vec) { - return out << '[' << vec.x << ',' << vec.y << ',' << vec.z << ']'; -} - -// ************************************************************************** -// * Vec4 stores 4-dimensional vectors using whatever base type you choose -// ************************************************************************** -template -class Vec4 { -public: // names - union { - N v[4]; - struct { - N x; - N y; - N z; - N w; - }; - struct { - N r; - N g; - N b; - N a; - }; - }; -// +--------------------------------- -public: // constructors - inline Vec4() {} - inline Vec4(const N &n0, const N &n1, const N &n2, const N &n3) : - x(n0), y(n1), z(n2), w(n3) {} - // allows implicit conversion based on generics... - template - inline Vec4(const Vec4 &cp) : x(cp.x), y(cp.y), z(cp.z), w(cp.w) {} - // build from short array in memory - inline Vec4(const N *ns) : x(ns[0]), y(ns[1]), z(ns[2]), w(ns[3]) {} -// +--------------------------------- -public: // indexing - inline N& operator[](uint i) { return v[i]; } - inline N operator[](uint i) const { return v[i]; } -// +--------------------------------- -public: // destructive arithmetic - inline Vec4& operator+=(const Vec4 &rhs); - inline Vec4& operator-=(const Vec4 &rhs); - inline Vec4& operator*=(const N &rhs); - inline Vec4& operator/=(const N &rhs); -}; -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec4 &lhs, const Vec4 &rhs); -template -inline bool operator!=(const Vec4 &lhs, const Vec4 &rhs); -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec4 operator+(const Vec4 &lhs, const Vec4 &rhs); -template -inline Vec4 operator-(const Vec4 &lhs, const Vec4 &rhs); -template -inline Vec4 operator*(const Vec4 &lhs, const N &rhs); -template -inline Vec4 operator*(const N &lhs, const Vec4 &rhs); -template -inline Vec4 operator/(const Vec4 &lhs, const N &rhs); -template -inline Vec4 operator-(const Vec4 &vec); -template -inline Vec4 abs(const Vec4 &vec); -// +--------------------------------- -// component-wise max/min -template -inline Vec4 max(const Vec4 &lhs, const Vec4 &rhs); -template -inline Vec4 min(const Vec4 &lhs, const Vec4 &rhs); -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec4 &vec); -template -inline uint minDim(const Vec4 &vec); -template -inline Vec3 proj(uint dim, const Vec4 &vec); -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec4 &lhs, const Vec4 &rhs); -// determinant of 4 Vec4s -template -inline N det(const Vec4 &v0, const Vec4 &v1, - const Vec4 &v2, const Vec4 &v3); -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec4 &vec); -template -inline N len(const Vec4 &vec); -template -inline N max(const Vec4 &vec); -template -inline N min(const Vec4 &vec); -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec4 &vec); -template -inline Vec4 normalized(const Vec4 &vec); -// +--------------------------------- -// output/input stream operators -template -inline std::ostream& operator<<(std::ostream &out, const Vec4 &vec) { - return out << '[' << vec.x << ',' << vec.y << ',' - << vec.z << ',' << vec.w << ']'; -} - -// ************************************************************************** -// * Aliases for Common Specializations -// ************************************************************************** -typedef Vec2 Vec2i; - -typedef Vec2 Vec2f; -typedef Vec3 Vec3f; -typedef Vec4 Vec4f; - -typedef Vec2 Vec2d; -typedef Vec3 Vec3d; -typedef Vec4 Vec4d; - -// ************************************************************************** -// * Conversions Between Dimensions -// ************************************************************************** -// +--------------------------------- -// Cartesian -> Homogeneous -template -inline Vec3 toHom(const Vec2 &v2) { - return Vec3(v2.x, v2.y, 1); -} -template -inline Vec4 toHom(const Vec3 &v3) { - return Vec4(v3.x, v3.y, v3.z, 1); -} -/* -// Homogeneous -> Cartesian (BEWARE when last coordinate == 0) -template -inline Vec2 cartProj(const Vec3 &v3) { - return Vec2(v3.x, v3.y) / v3.z; -} -template -inline Vec3 cartProj(const Vec4 &v4) { - return Vec3(v4.x, v4.y, v4.z) / v4.w; -}*/ - - -// ************************************************************************** -// ************************************************************************** -// *************************** IMPLEMENTATION ***************************** -// ************************************************************************** -// ************************************************************************** - -// ************************************************************************** -// * Vec2 IMPLEMENTATION -// ************************************************************************** -// +--------------------------------- -// destructive arithmetic -template -inline Vec2& Vec2::operator+=(const Vec2 &rhs) { - x += rhs.x; - y += rhs.y; - return *this; -} -template -inline Vec2& Vec2::operator-=(const Vec2 &rhs) { - x -= rhs.x; - y -= rhs.y; - return *this; -} -template -inline Vec2& Vec2::operator*=(const N &rhs) { - x *= rhs; - y *= rhs; - return *this; -} -template -inline Vec2& Vec2::operator/=(const N &rhs) { - x /= rhs; - y /= rhs; - return *this; -} -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec2 &lhs, const Vec2 &rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y; -} -template -inline bool operator!=(const Vec2 &lhs, const Vec2 &rhs) { - return lhs.x != rhs.x || lhs.y != rhs.y; -} -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec2 operator+(const Vec2 &lhs, const Vec2 &rhs) { - Vec2 res(lhs); - return res += rhs; -} -template -inline Vec2 operator-(const Vec2 &lhs, const Vec2 &rhs) { - Vec2 res(lhs); - return res -= rhs; -} -template -inline Vec2 operator*(const Vec2 &lhs, const N &rhs) { - Vec2 res(lhs); - return res *= rhs; -} -template -inline Vec2 operator*(const N &lhs, const Vec2 &rhs) { - Vec2 res(rhs); - return res *= lhs; -} -template -inline Vec2 operator/(const Vec2 &lhs, const N &rhs) { - Vec2 res(lhs); - return res /= rhs; -} -template -inline Vec2 operator-(const Vec2 &vec) { - return Vec2(-vec.x, -vec.y); -} -template<> -inline Vec2 abs(const Vec2 &vec) { - return Vec2(fabs(vec.x), fabs(vec.y)); -} -template<> -inline Vec2 abs(const Vec2 &vec) { - return Vec2(fabs(vec.x), fabs(vec.y)); -} -// +--------------------------------- -// component-wise max/min -template -inline Vec2 max(const Vec2 &lhs, const Vec2 &rhs) { - return Vec2(std::max(lhs.x, rhs.x), - std::max(lhs.y, rhs.y)); -} -template -inline Vec2 min(const Vec2 &lhs, const Vec2 &rhs) { - return Vec2(std::min(lhs.x, rhs.x), - std::min(lhs.y, rhs.y)); -} -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec2 &vec) { - return (vec.x >= vec.y)? 0 : 1; -} -template -inline uint minDim(const Vec2 &vec) { - return (vec.x <= vec.y)? 0 : 1; -} -template -inline N proj(uint dim, const Vec2 &vec) { - return (dim == 0)? vec.y : vec.x; -} -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec2 &lhs, const Vec2 &rhs) { - return lhs.x*rhs.x + lhs.y*rhs.y; -} -// determinant of 2 vec2s -template -inline N det(const Vec2 &lhs, const Vec2 &rhs) { - return lhs.x*rhs.y - lhs.y*rhs.x; -} -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec2 &vec) { - return vec.x*vec.x + vec.y*vec.y; -} -template -inline N len(const Vec2 &vec) { - return std::sqrt(len2(vec)); -} -template -inline N max(const Vec2 &vec) { - return std::max(vec.x, vec.y); -} -template -inline N min(const Vec2 &vec) { - return std::min(vec.x, vec.y); -} -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec2 &vec) { - vec /= len(vec); -} -template -inline Vec2 normalized(const Vec2 &vec) { - return vec / len(vec); -} - -// ************************************************************************** -// * Vec3 IMPLEMENTATION -// ************************************************************************** -// +--------------------------------- -// destructive arithmetic -template -inline Vec3& Vec3::operator+=(const Vec3 &rhs) { - x += rhs.x; - y += rhs.y; - z += rhs.z; - return *this; -} -template -inline Vec3& Vec3::operator-=(const Vec3 &rhs) { - x -= rhs.x; - y -= rhs.y; - z -= rhs.z; - return *this; -} -template -inline Vec3& Vec3::operator*=(const N &rhs) { - x *= rhs; - y *= rhs; - z *= rhs; - return *this; -} -template -inline Vec3& Vec3::operator/=(const N &rhs) { - x /= rhs; - y /= rhs; - z /= rhs; - return *this; -} -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec3 &lhs, const Vec3 &rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z; -} -template -inline bool operator!=(const Vec3 &lhs, const Vec3 &rhs) { - return lhs.x != rhs.x || lhs.y != rhs.y || lhs.z != rhs.z; -} -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec3 operator+(const Vec3 &lhs, const Vec3 &rhs) { - Vec3 res(lhs); - return res += rhs; -} -template -inline Vec3 operator-(const Vec3 &lhs, const Vec3 &rhs) { - Vec3 res(lhs); - return res -= rhs; -} -template -inline Vec3 operator*(const Vec3 &lhs, const N &rhs) { - Vec3 res(lhs); - return res *= rhs; -} -template -inline Vec3 operator*(const N &lhs, const Vec3 &rhs) { - Vec3 res(rhs); - return res *= lhs; -} -template -inline Vec3 operator/(const Vec3 &lhs, const N &rhs) { - Vec3 res(lhs); - return res /= rhs; -} -template -inline Vec3 operator-(const Vec3 &vec) { - return Vec3(-vec.x, -vec.y, -vec.z); -} -template<> -inline Vec3 abs(const Vec3 &vec) { - return Vec3(fabs(vec.x), fabs(vec.y), fabs(vec.z)); -} -template<> -inline Vec3 abs(const Vec3 &vec) { - return Vec3(fabs(vec.x), fabs(vec.y), fabs(vec.z)); -} -// +--------------------------------- -// component-wise max/min -template -inline Vec3 max(const Vec3 &lhs, const Vec3 &rhs) { - return Vec3(std::max(lhs.x, rhs.x), - std::max(lhs.y, rhs.y), - std::max(lhs.z, rhs.z)); -} -template -inline Vec3 min(const Vec3 &lhs, const Vec3 &rhs) { - return Vec3(std::min(lhs.x, rhs.x), - std::min(lhs.y, rhs.y), - std::min(lhs.z, rhs.z)); -} -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec3 &vec) { - return (vec.x >= vec.y)? ((vec.x >= vec.z)? 0 : 2) : - ((vec.y >= vec.z)? 1 : 2); -} -template -inline uint minDim(const Vec3 &vec) { - return (vec.x <= vec.y)? ((vec.x <= vec.z)? 0 : 2) : - ((vec.y <= vec.z)? 1 : 2); -} -template -inline Vec2 proj(uint dim, const Vec3 &vec) { - return Vec2( vec.v[(dim+1)%3], vec.v[(dim+2)%3] ); -} -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec3 &lhs, const Vec3 &rhs) { - return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z; -} -template -inline Vec3 cross(const Vec3 &lhs, const Vec3 &rhs) { - return Vec3(lhs.y*rhs.z - lhs.z*rhs.y, - lhs.z*rhs.x - lhs.x*rhs.z, - lhs.x*rhs.y - lhs.y*rhs.x); -} -// determinant of 3 Vec3s -template -inline N det(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2) { - N xy = v0.x*v1.y - v0.y*v1.x; - N xz = v0.x*v1.z - v0.z*v1.x; - N yz = v0.y*v1.z - v0.z*v1.y; - return xy*v2.z - xz*v2.y + yz*v2.x; -} -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec3 &vec) { - return vec.x*vec.x + vec.y*vec.y + vec.z*vec.z; -} -template -inline N len(const Vec3 &vec) { - return std::sqrt(len2(vec)); -} -template -inline N max(const Vec3 &vec) { - return std::max(vec.x, std::max(vec.y, vec.z)); -} -template -inline N min(const Vec3 &vec) { - return std::min(vec.x, std::min(vec.y, vec.z)); -} -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec3 &vec) { - vec /= len(vec); -} -template -inline Vec3 normalized(const Vec3 &vec) { - return vec / len(vec); -} - -// ************************************************************************** -// * Vec4 IMPLEMENTATION -// ************************************************************************** -// destructive arithmetic -template -inline Vec4& Vec4::operator+=(const Vec4 &rhs) { - x += rhs.x; - y += rhs.y; - z += rhs.z; - w += rhs.w; - return *this; -} -template -inline Vec4& Vec4::operator-=(const Vec4 &rhs) { - x -= rhs.x; - y -= rhs.y; - z -= rhs.z; - w -= rhs.w; - return *this; -} -template -inline Vec4& Vec4::operator*=(const N &rhs) { - x *= rhs; - y *= rhs; - z *= rhs; - w *= rhs; - return *this; -} -template -inline Vec4& Vec4::operator/=(const N &rhs) { - x /= rhs; - y /= rhs; - z /= rhs; - w /= rhs; - return *this; -} -// +--------------------------------- -// comparison operators -template -inline bool operator==(const Vec4 &lhs, const Vec4 &rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y && - lhs.z == rhs.z && lhs.w == rhs.w; -} -template -inline bool operator!=(const Vec4 &lhs, const Vec4 &rhs) { - return lhs.x != rhs.x || lhs.y != rhs.y || - lhs.z != rhs.z || lhs.w != rhs.w; -} -// +--------------------------------- -// non-destructive arithmetic -template -inline Vec4 operator+(const Vec4 &lhs, const Vec4 &rhs) { - Vec4 res(lhs); - return res += rhs; -} -template -inline Vec4 operator-(const Vec4 &lhs, const Vec4 &rhs) { - Vec4 res(lhs); - return res -= rhs; -} -template -inline Vec4 operator*(const Vec4 &lhs, const N &rhs) { - Vec4 res(lhs); - return res *= rhs; -} -template -inline Vec4 operator*(const N &lhs, const Vec4 &rhs) { - Vec4 res(rhs); - return res *= lhs; -} -template -inline Vec4 operator/(const Vec4 &lhs, const N &rhs) { - Vec4 res(lhs); - return res /= rhs; -} -template -inline Vec4 operator-(const Vec4 &vec) { - return Vec4(-vec.x, -vec.y, -vec.z, -vec.w); -} -template<> -inline Vec4 abs(const Vec4 &vec) { - return Vec4(fabs(vec.x), fabs(vec.y), fabs(vec.z), fabs(vec.w)); -} -template<> -inline Vec4 abs(const Vec4 &vec) { - return Vec4(fabs(vec.x), fabs(vec.y), fabs(vec.z), fabs(vec.w)); -} -// +--------------------------------- -// component-wise max/min -template -inline Vec4 max(const Vec4 &lhs, const Vec4 &rhs) { - return Vec4(std::max(lhs.x, rhs.x), - std::max(lhs.y, rhs.y), - std::max(lhs.z, rhs.z), - std::max(lhs.w, rhs.w)); -} -template -inline Vec4 min(const Vec4 &lhs, const Vec4 &rhs) { - return Vec4(std::min(lhs.x, rhs.x), - std::min(lhs.y, rhs.y), - std::min(lhs.z, rhs.z), - std::min(lhs.w, rhs.w)); -} -// +--------------------------------- -// dimension logic for projections -template -inline uint maxDim(const Vec4 &vec) { - return (vec.x >= vec.y)? - ((vec.x >= vec.z)? ((vec.x >= vec.w)? 0 : 3) : - ((vec.z >= vec.w)? 2 : 3)) : - ((vec.y >= vec.z)? ((vec.y >= vec.w)? 1 : 3) : - ((vec.z >= vec.w)? 2 : 3)); -} -template -inline uint minDim(const Vec4 &vec) { - return (vec.x <= vec.y)? - ((vec.x <= vec.z)? ((vec.x <= vec.w)? 0 : 3) : - ((vec.z <= vec.w)? 2 : 3)) : - ((vec.y <= vec.z)? ((vec.y <= vec.w)? 1 : 3) : - ((vec.z <= vec.w)? 2 : 3)); -} -template -inline Vec3 proj(uint dim, const Vec4 &vec) { - return Vec3( vec.v[(dim+1)%4], - vec.v[(dim+2)%4], - vec.v[(dim+3)%4] ); -} -// +--------------------------------- -// more sophisticated vector arithmetic -template -inline N dot(const Vec4 &lhs, const Vec4 &rhs) { - return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z + lhs.w*rhs.w; -} -// determinant of 4 Vec4s -template -inline N det(const Vec4 &v0, const Vec4 &v1, - const Vec4 &v2, const Vec4 &v3) { - N xy01 = v0.x*v1.y - v0.y*v1.x; N yz01 = v0.y*v1.z - v0.z*v1.y; - N xz01 = v0.x*v1.z - v0.z*v1.x; N yw01 = v0.y*v1.w - v0.w*v1.y; - N xw01 = v0.x*v1.w - v0.w*v1.x; N zw01 = v0.z*v1.w - v0.w*v1.z; - - N xy23 = v2.x*v3.y - v2.y*v3.x; N yz23 = v2.y*v3.z - v2.z*v3.y; - N xz23 = v2.x*v3.z - v2.z*v3.x; N yw23 = v2.y*v3.w - v2.w*v3.y; - N xw23 = v2.x*v3.w - v2.w*v3.x; N zw23 = v2.z*v3.w - v2.w*v3.z; - - return xy01*zw23 - xz01*yw23 + xw01*yz23 - + yz01*xw23 - yw01*xz23 + zw01*xy23; -} -// +--------------------------------- -// collapsing measurements -template -inline N len2(const Vec4 &vec) { - return vec.x*vec.x + vec.y*vec.y + vec.z*vec.z + vec.w*vec.w; -} -template -inline N len(const Vec4 &vec) { - return std::sqrt(len2(vec)); -} -template -inline N max(const Vec4 &vec) { - return std::max(std::max(vec.x, vec.y), std::max(vec.z, vec.w)); -} -template -inline N min(const Vec4 &vec) { - return std::min(std::min(vec.x, vec.y), std::min(vec.z, vec.w)); -} -// +--------------------------------- -// normalization functions -template -inline void normalize(Vec4 &vec) { - vec /= len(vec); -} -template -inline Vec4 normalized(const Vec4 &vec) { - return vec / len(vec); -} - diff --git a/external/cork/src/mesh/mesh.bool.tpp b/external/cork/src/mesh/mesh.bool.tpp deleted file mode 100644 index 6b76c5512..000000000 --- a/external/cork/src/mesh/mesh.bool.tpp +++ /dev/null @@ -1,372 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.bool.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include - -template -class Mesh::BoolProblem -{ -public: - BoolProblem(Mesh *owner) : mesh(owner) - {} - virtual ~BoolProblem() {} - - // do things - void doSetup(Mesh &rhs); - - // choose what to remove - enum TriCode { KEEP_TRI, DELETE_TRI, FLIP_TRI }; - void doDeleteAndFlip( - std::function classify - ); - -private: // methods - struct BoolEdata { - bool is_isct; - }; - - inline byte& boolData(uint tri_id) { - return mesh->tris[tri_id].data.bool_alg_data; - } - - void populateECache() - { - ecache = mesh->createEGraphCache(); - - // label some of the edges as intersection edges and others as not - ecache.for_each([&](uint i, uint j, EGraphEntry &entry) { - entry.data.is_isct = false; - byte operand = boolData(entry.tids[0]); - for(uint k=1; k &tids)> action - ) { - ecache.for_each([&](uint i, uint j, EGraphEntry &entry) { - if(entry.data.is_isct) { - ShortVec tid0s; - ShortVec tid1s; - for(uint tid : entry.tids) { - if(boolData(tid) & 1) - tid1s.push_back(tid); - else - tid0s.push_back(tid); - } - action(i,j, true, tid1s); - action(i,j, true, tid0s); - } else { - action(i,j, false, entry.tids); - } - }); - } - - void prepInsideOutsideTests() - { - } - - bool isInside(uint tid, byte operand) { - // find the point to trace outward from... - Vec3d p(0,0,0); - p += mesh->verts[mesh->tris[tid].a].pos; - p += mesh->verts[mesh->tris[tid].b].pos; - p += mesh->verts[mesh->tris[tid].c].pos; - p /= 3.0; - // ok, we've got the point, now let's pick a direction - Ray3d r; - r.p = p; - r.r = Vec3d(drand(0.5,1.5), drand(0.5,1.5), drand(0.5, 1.5)); - - - int winding = 0; - // pass all triangles over ray - for(Tri &tri : mesh->tris) { - // ignore triangles from the same operand surface - if((tri.data.bool_alg_data & 1) == operand) continue; - - double flip = 1.0; - uint a = tri.a; - uint b = tri.b; - uint c = tri.c; - Vec3d va = mesh->verts[a].pos; - Vec3d vb = mesh->verts[b].pos; - Vec3d vc = mesh->verts[c].pos; - // normalize vertex order (to prevent leaks) - if(a > b) { std::swap(a, b); std::swap(va, vb); flip = -flip; } - if(b > c) { std::swap(b, c); std::swap(vb, vc); flip = -flip; } - if(a > b) { std::swap(a, b); std::swap(va, vb); flip = -flip; } - - double t; - Vec3d bary; - if(isct_ray_triangle(r, va, vb, vc, &t, &bary)) { - Vec3d normal = flip * cross(vb - va, vc - va); - if(dot(normal, r.r) > 0.0) { // UNSAFE - winding++; - } else { - winding--; - } - } - } - - // now, we've got a winding number to work with... - return winding > 0; - } - -private: // data - Mesh *mesh; - EGraphCache ecache; -}; - - -static inline double triArea( - Vec3d a, Vec3d b, Vec3d c -) { - return len(cross(b-a, c-a)); -} - - -template -void Mesh::BoolProblem::doSetup( - Mesh &rhs -) { - // Label surfaces... - mesh->for_tris([](TriData &tri, VertData&, VertData&, VertData&) { - tri.bool_alg_data = 0; - }); - rhs.for_tris([](TriData &tri, VertData&, VertData&, VertData&) { - tri.bool_alg_data = 1; - }); - - mesh->disjointUnion(rhs); - mesh->resolveIntersections(); - - populateECache(); - - // form connected components; - // we get one component for each connected component in one - // of the two input meshes. - // These components are not necessarily uniformly inside or outside - // of the other operand mesh. - UnionFind uf(mesh->tris.size()); - for_ecache([&](uint, uint, bool, const ShortVec &tids) { - uint tid0 = tids[0]; - for(uint k=1; k uq_ids(mesh->tris.size(), uint(-1)); - std::vector< std::vector > components; - for(uint i=0; itris.size(); i++) { - uint ufid = uf.find(i); - if(uq_ids[ufid] == uint(-1)) { // unassigned - uint N = components.size(); - components.push_back(std::vector()); - - uq_ids[ufid] = uq_ids[i] = N; - components[N].push_back(i); - } else { // assigned already - uq_ids[i] = uq_ids[ufid]; // propagate assignment - components[uq_ids[i]].push_back(i); - } - } - - std::vector visited(mesh->tris.size(), false); - - // find the "best" triangle in each component, - // and ray cast to determine inside-ness vs. outside-ness - for(auto &comp : components) { - // find max according to score - uint best_tid = comp[0]; - double best_area = 0.0; - // SEARCH - for(uint tid : comp) { - Vec3d va = mesh->verts[mesh->tris[tid].a].pos; - Vec3d vb = mesh->verts[mesh->tris[tid].b].pos; - Vec3d vc = mesh->verts[mesh->tris[tid].c].pos; - - double area = triArea(va, vb, vc); - if(area > best_area) { - best_area = area; - best_tid = tid; - } - } - - byte operand = boolData(best_tid); - bool inside = isInside(best_tid, operand); - - // NOW PROPAGATE classification throughout the component. - // do a breadth first propagation - std::queue work; - - // begin by tagging the first triangle - boolData(best_tid) |= (inside)? 2 : 0; - visited[best_tid] = true; - work.push(best_tid); - - while(!work.empty()) { - uint curr_tid = work.front(); - work.pop(); - - for(uint k=0; k<3; k++) { - uint a = mesh->tris[curr_tid].v[k]; - uint b = mesh->tris[curr_tid].v[(k+1)%3]; - auto &entry = ecache(a,b); - byte inside_sig = boolData(curr_tid) & 2; - if(entry.data.is_isct) inside_sig ^= 2; - for(uint tid : entry.tids) { - if(visited[tid]) continue; - if((boolData(tid)&1) != operand) continue; - - boolData(tid) |= inside_sig; - visited[tid] = true; - work.push(tid); - } - } - } - } -} - - -template -void Mesh::BoolProblem::doDeleteAndFlip( - std::function classify -) { - TopoCache topocache(mesh); - - std::vector toDelete; - topocache.tris.for_each([&](Tptr tptr) { - TriCode code = classify(boolData(tptr->ref)); - switch(code) { - case DELETE_TRI: - toDelete.push_back(tptr); - break; - case FLIP_TRI: - topocache.flipTri(tptr); - break; - case KEEP_TRI: - default: - break; - } - }); - - for(Tptr tptr : toDelete) { - topocache.deleteTri(tptr); - } - - topocache.commit(); -} - - - - - -template -void Mesh::boolUnion(Mesh &rhs) -{ - BoolProblem bprob(this); - - bprob.doSetup(rhs); - - bprob.doDeleteAndFlip([](byte data) -> typename BoolProblem::TriCode { - if((data & 2) == 2) // part of op 0/1 INSIDE op 1/0 - return BoolProblem::DELETE_TRI; - else // part of op 0/1 OUTSIDE op 1/0 - return BoolProblem::KEEP_TRI; - }); -} - -template -void Mesh::boolDiff(Mesh &rhs) -{ - BoolProblem bprob(this); - - bprob.doSetup(rhs); - - bprob.doDeleteAndFlip([](byte data) -> typename BoolProblem::TriCode { - if(data == 2 || // part of op 0 INSIDE op 1 - data == 1) // part of op 1 OUTSIDE op 0 - return BoolProblem::DELETE_TRI; - else if(data == 3) // part of op 1 INSIDE op 1 - return BoolProblem::FLIP_TRI; - else // part of op 0 OUTSIDE op 1 - return BoolProblem::KEEP_TRI; - }); -} - -template -void Mesh::boolIsct(Mesh &rhs) -{ - BoolProblem bprob(this); - - bprob.doSetup(rhs); - - bprob.doDeleteAndFlip([](byte data) -> typename BoolProblem::TriCode { - if((data & 2) == 0) // part of op 0/1 OUTSIDE op 1/0 - return BoolProblem::DELETE_TRI; - else // part of op 0/1 INSIDE op 1/0 - return BoolProblem::KEEP_TRI; - }); -} - -template -void Mesh::boolXor(Mesh &rhs) -{ - BoolProblem bprob(this); - - bprob.doSetup(rhs); - - bprob.doDeleteAndFlip([](byte data) -> typename BoolProblem::TriCode { - if((data & 2) == 0) // part of op 0/1 OUTSIDE op 1/0 - return BoolProblem::KEEP_TRI; - else // part of op 0/1 INSIDE op 1/0 - return BoolProblem::FLIP_TRI; - }); -} - - - - - - - - - - - - - - - diff --git a/external/cork/src/mesh/mesh.decl.h b/external/cork/src/mesh/mesh.decl.h deleted file mode 100644 index 0adac06fc..000000000 --- a/external/cork/src/mesh/mesh.decl.h +++ /dev/null @@ -1,393 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.decl.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "rawMesh.h" - -#include "prelude.h" -#include -#include - -#include "vec.h" -#include "ray.h" -#include "shortVec.h" - -#include "iterPool.h" - - -struct BoolVertexData { -}; -struct BoolTriangleData { - byte bool_alg_data; // internal use by algorithm - // please copy value when the triangle is subdivided -}; - - -template -struct IsctVertEdgeTriInput -{ - VertData* e[2]; - VertData* t[3]; -}; - -template -struct IsctVertTriTriTriInput -{ - VertData* t[3][3]; -}; - -template -struct SubdivideTriInput -{ - TriData* pt; - VertData* pv[3]; - VertData* v[3]; -}; - -// in order to perform intersections, VertData and TriData must support -struct IsctVertexData { - // specify how to compute new data for vertices formed by intersections - /* - // vertices on edge and triangle forming an intersection... - void isct(IsctVertEdgeTriInput input); - void isct(IsctVertTriTriTriInput input); - void isctInterpolate(const VertData &v0, const VertData &v1); - */ -}; -struct IsctTriangleData { - // specify how to compute new data for a triangle in the event - // that it is merged with another triangle (merge) - // split into two triangles (split) - // or that the triangle is moved (move) - /* - void subdivide(SubdivideTriInput input); - */ -}; - - - -// in order to perform remeshing, VertData and TriData must support -struct RemeshVertexData { - bool manifold; // whether this point is manifold. - // useful for modifying interpolation behavior - // specify how to compute new data for a vertex in the event of - // either an edge collapse (via merge) or edge split (via interpolate) - /* - void merge(const VertData &v0, const VertData &v1); - void interpolate(const VertData &v0, const VertData &v1); - */ -}; -struct RemeshTriangleData { - // specify how to compute new data for a triangle in the event - // that it is merged with another triangle (merge) - // split into two triangles (split) - // or that the triangle is moved (move) - /* - void merge(const TriData &t0, const TriData &t1); - static void split(TriData &t0, TriData &t1, const TriData &t_orig); - void move(const TriData &t_old); - */ -}; - -struct RemeshOptions -{ - double maxEdgeLength; - double minEdgeLength; - double minAngle; - double maxAngle; - RemeshOptions() : - maxEdgeLength(1.0), - minEdgeLength(0.3), - minAngle(5.0), - maxAngle(170.0) - {} -}; - - -// only for internal use, please do not use as client - struct TopoVert; - struct TopoEdge; - struct TopoTri; - - typedef TopoVert* Vptr; - typedef TopoEdge* Eptr; - typedef TopoTri* Tptr; - //using Vptr = TopoVert*; - //using Eptr = TopoEdge*; - //using Tptr = TopoTri*; -// end internal items - - -template -class Mesh -{ -public: - Mesh(); - Mesh(Mesh &&src); - Mesh(const RawMesh &raw); - virtual ~Mesh(); - - void operator=(Mesh &&src); - - // validity check: - // - all numbers are well-defined and finite - // - all triangle vertex indices are in the right range - bool valid() const; - - RawMesh raw() const; - - inline int numVerts() const { return verts.size(); } - inline int numTris() const { return tris.size(); } - - inline void for_verts(std::function func); - inline void for_tris(std::function func); - inline void for_edges( - std::function start, - std::function each_tri - ); - - // form the disjoint union of two meshes - void disjointUnion(const Mesh &cp); - - struct Isct { - Ray3d ray; - bool exists; - - uint tri_id; - Vec3d isct; - Vec3d bary; - }; - Isct pick(Ray3d ray); - inline void accessIsct(const Isct &isct, - std::function func); - - // checks if the mesh is closed - bool isClosed(); - -public: // REMESHING module - // REQUIRES: - // - MinimalData - // - RemeshData - void remesh(); - RemeshOptions remesh_options; - -public: // ISCT (intersections) module - void resolveIntersections(); // makes all intersections explicit - bool isSelfIntersecting(); // is the mesh self-intersecting? - // TESTING - void testingComputeStaticIsctPoints(std::vector *points); - void testingComputeStaticIsct(std::vector *points, - std::vector< std::pair > *edges); - -public: // BOOLean operation module - // all of the form - // this = this OP rhs - void boolUnion(Mesh &rhs); - void boolDiff(Mesh &rhs); - void boolIsct(Mesh &rhs); - void boolXor(Mesh &rhs); - -private: // Internal Formats - struct Tri { - TriData data; - union { - struct { - uint a, b, c; // vertex ids - }; - uint v[3]; - }; - - inline Tri() {} - }; - - inline void merge_tris(uint tid_result, uint tid0, uint tid1); - inline void split_tris(uint t0ref, uint t1ref, uint t_orig_ref); - inline void move_tri(Tri &t_new, Tri &t_old); - inline void subdivide_tri(uint t_piece_ref, uint t_parent_ref); - -private: // DATA - std::vector tris; - std::vector verts; - -private: // caches - struct NeighborEntry { - uint vid; - ShortVec tids; - inline NeighborEntry() {} - inline NeighborEntry(uint vid_) : vid(vid_) {} - }; - struct NeighborCache { - std::vector< ShortVec > skeleton; - inline NeighborEntry& operator()(uint i, uint j) { - uint N = skeleton[i].size(); - for(uint k = 0; k < N; k++) { - if(skeleton[i][k].vid == j) - return skeleton[i][k]; - } - skeleton[i].push_back(NeighborEntry(j)); - return skeleton[i][N]; - } - }; - NeighborCache createNeighborCache(); - - // parallel to vertex array - std::vector getComponentIds(); - - // like the neighbor cache, but more customizable - template - struct EGraphEntry { - uint vid; - ShortVec tids; - Edata data; - inline EGraphEntry() {} - inline EGraphEntry(uint vid_) : vid(vid_) {} - }; - template - struct EGraphCache { - std::vector< ShortVec, 8> > skeleton; - inline EGraphEntry & operator()(uint i, uint j) { - uint N = skeleton[i].size(); - for(uint k = 0; k < N; k++) { - if(skeleton[i][k].vid == j) - return skeleton[i][k]; - } - skeleton[i].push_back(EGraphEntry(j)); - return skeleton[i][N]; - } - inline void for_each(std::function &entry - )> action - ) { - for(uint i=0; i - EGraphCache createEGraphCache(); - - -private: // TopoCache Support - struct TopoCache; -private: // Isct Support - class IsctProblem; // implements intersection functionality - class TriangleProblem; // support type for IsctProblem - typedef TriangleProblem* Tprob; - //using Tprob = TriangleProblem*; -private: // Bool Support - class BoolProblem; - -private: // Remeshing Support - struct RemeshScratchpad; - - Eptr allocateRemeshEdge(RemeshScratchpad &); - void deallocateRemeshEdge(RemeshScratchpad &, Eptr); - - void edgeSplit(RemeshScratchpad &, - Eptr e_split); - void edgeCollapse(RemeshScratchpad &, - Eptr e_collapse, - bool collapsing_tetrahedra_disappear); - - // Need edge scoring routines... - void scoreAndEnqueue( - std::set< std::pair > &queue, Eptr edge); - void dequeue( - std::set< std::pair > &queue, Eptr edge); - double computeEdgeScore(Eptr edge); - - // support functions - void populateTriFromTopoTri(Tptr t); - // calls the first function once, then the second once for each triangle - inline void edgeNeighborhood( - Eptr edge, - std::function once, - std::function each_tri - ); -}; - - -// inline functions - -template -inline void Mesh::for_verts( - std::function func -) { - for(auto &v : verts) - func(v); -} - -template -inline void Mesh::for_tris( - std::function func -) { - for(auto &tri : tris) { - auto &a = verts[tri.a]; - auto &b = verts[tri.b]; - auto &c = verts[tri.c]; - func(tri.data, a, b, c); - } -} - -template -inline void Mesh::for_edges( - std::function start, - std::function each_tri -) { - NeighborCache cache = createNeighborCache(); - for(uint i=0; i -inline void Mesh::accessIsct( - const Isct &isct, - std::function func -) { - Tri &tri = tris[isct.tri_id]; - auto &a = verts[tri.a]; - auto &b = verts[tri.b]; - auto &c = verts[tri.c]; - func(tri.data, a, b, c); -} - - - diff --git a/external/cork/src/mesh/mesh.h b/external/cork/src/mesh/mesh.h deleted file mode 100644 index ada80a7a8..000000000 --- a/external/cork/src/mesh/mesh.h +++ /dev/null @@ -1,53 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -// SIMPLE USAGE: -// In order to get standard template inclusion behavior/usage -// just include this file. Then the entire template code -// will be included in the compilation unit. -// ADVANCED USAGE: -// Only include "mesh.decl.h" where-ever you would normally include a -// header file. This will avoid including the implementation code in -// the current compilation unit. -// Then, create a seperate cpp file which includes "mesh.h" and -// explicitly instantiates the template with the desired template -// parameters. -// By following this scheme, you can prevent re-compiling the entire -// template implementation in every usage compilation unit and every -// time those compilation units are recompiled during development. - -// Declaration -#include "mesh.decl.h" - -// Implementation -#include "mesh.tpp" -#include "mesh.remesh.tpp" -#include "mesh.isct.tpp" -#include "mesh.bool.tpp" - - - diff --git a/external/cork/src/mesh/mesh.isct.tpp b/external/cork/src/mesh/mesh.isct.tpp deleted file mode 100644 index 52f5283c5..000000000 --- a/external/cork/src/mesh/mesh.isct.tpp +++ /dev/null @@ -1,1533 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.isct.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "mesh.topoCache.tpp" - -#include "bbox.h" -#include "quantization.h" -#include "empty3d.h" - -#include "aabvh.h" - -#define REAL double -extern "C" { -#include "triangle.h" -} - -// Alec: -#include -#include - -struct GenericVertType; - struct IsctVertType; - struct OrigVertType; -struct GenericEdgeType; - struct IsctEdgeType; - struct OrigEdgeType; - struct SplitEdgeType; -struct GenericTriType; - -struct GluePointMarker; - -//using GVptr = GenericVertType*; -// using IVptr = IsctVertType*; -// using OVptr = OrigVertType*; -//using GEptr = GenericEdgeType*; -// using IEptr = IsctEdgeType*; -// using OEptr = OrigEdgeType*; -// using SEptr = SplitEdgeType*; -//using GTptr = GenericTriType*; - -//using GluePt = GluePointMarker*; - -typedef GenericVertType* GVptr; -typedef IsctVertType* IVptr; -typedef OrigVertType* OVptr; -typedef GenericEdgeType* GEptr; -typedef IsctEdgeType* IEptr; -typedef OrigEdgeType* OEptr; -typedef SplitEdgeType* SEptr; -typedef GenericTriType* GTptr; - -typedef GluePointMarker* GluePt; - -struct GenericVertType -{ - virtual ~GenericVertType() {} - Vptr concrete; - Vec3d coord; - - bool boundary; - uint idx; // temporary for triangulation marshalling - - ShortVec edges; -}; -struct IsctVertType : public GenericVertType -{ - GluePt glue_marker; -}; -struct OrigVertType : public GenericVertType {}; - -struct GenericEdgeType -{ - virtual ~GenericEdgeType() {} - Eptr concrete; - - bool boundary; - uint idx; // temporary for triangulation marshalling - - GVptr ends[2]; - ShortVec interior; -}; -struct IsctEdgeType : public GenericEdgeType -{ -public: - // use to detect duplicate instances within a triangle - Tptr other_tri_key; -}; -struct OrigEdgeType : public GenericEdgeType {}; -struct SplitEdgeType : public GenericEdgeType {}; - -struct GenericTriType -{ - Tptr concrete; - - GVptr verts[3]; -}; - -struct GluePointMarker -{ - // list of all the vertices to be glued... - ShortVec copies; - bool split_type; // splits are introduced - // manually, not via intersection - // and therefore use only e pointer - bool edge_tri_type; // true if edge-tri intersection - // false if tri-tri-tri - Eptr e; - Tptr t[3]; -}; - - - -template inline -IEptr find_edge(ShortVec &vec, Tptr key) -{ - for(IEptr ie : vec) { - if(ie->other_tri_key == key) - return ie; - } - return nullptr; -} - -inline Vptr commonVert(Tptr t0, Tptr t1) -{ - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - if(t0->verts[i] == t1->verts[j]) - return t0->verts[i]; - } - } - return nullptr; -} - -inline bool hasCommonVert(Tptr t0, Tptr t1) -{ - return (t0->verts[0] == t1->verts[0] || - t0->verts[0] == t1->verts[1] || - t0->verts[0] == t1->verts[2] || - t0->verts[1] == t1->verts[0] || - t0->verts[1] == t1->verts[1] || - t0->verts[1] == t1->verts[2] || - t0->verts[2] == t1->verts[0] || - t0->verts[2] == t1->verts[1] || - t0->verts[2] == t1->verts[2]); -} - -inline bool hasCommonVert(Eptr e, Tptr t) -{ - return (e->verts[0] == t->verts[0] || - e->verts[0] == t->verts[1] || - e->verts[0] == t->verts[2] || - e->verts[1] == t->verts[0] || - e->verts[1] == t->verts[1] || - e->verts[1] == t->verts[2]); -} - -inline void disconnectGE(GEptr ge) -{ - ge->ends[0]->edges.erase(ge); - ge->ends[1]->edges.erase(ge); - for(IVptr iv : ge->interior) - iv->edges.erase(ge); -} - -// should deal with via pointers -template -class Mesh::TriangleProblem -{ -public: - TriangleProblem() {} - ~TriangleProblem() {} - - inline void init(IsctProblem *iprob, Tptr t) { - the_tri = t; - // extract original edges/verts - for(uint k=0; k<3; k++) - overts[k] = iprob->newOrigVert(the_tri->verts[k]); - for(uint k=0; k<3; k++) { - oedges[k] = iprob->newOrigEdge(the_tri->edges[k], - overts[(k+1)%3], - overts[(k+2)%3]); - } - } - -private: // may actually not add edge, but instead just hook up endpoint - inline void addEdge( - IsctProblem *iprob, IVptr iv, Tptr tri_key - ) { - IEptr ie = find_edge(iedges, tri_key); - if(ie) { // if the edge is already present - ie->ends[1] = iv; - iv->edges.push_back(ie); - } else { // if the edge is being added - ie = iprob->newIsctEdge(iv, tri_key); - iedges.push_back(ie); - } - } - void addBoundaryHelper( - Eptr edge, IVptr iv - ) { - iv->boundary = true; - iverts.push_back(iv); - // hook up point to boundary edge interior! - for(uint k=0; k<3; k++) { - OEptr oe = oedges[k]; - if(oe->concrete == edge) { - oe->interior.push_back(iv); - iv->edges.push_back(oe); - break; - } - } - } -public: - // specify reference glue point and edge piercing this triangle. - IVptr addInteriorEndpoint( - IsctProblem *iprob, Eptr edge, GluePt glue - ) { - IVptr iv = iprob->newIsctVert(edge, the_tri, glue); - iv->boundary = false; - iverts.push_back(iv); - for(Tptr tri_key : edge->tris) { - addEdge(iprob, iv, tri_key); - } - return iv; - } - // specify the other triangle cutting this one, the edge cut, - // and the resulting point of intersection - void addBoundaryEndpoint( - IsctProblem *iprob, Tptr tri_key, Eptr edge, IVptr iv - ) { - iv = iprob->copyIsctVert(iv); - addBoundaryHelper(edge, iv); - // handle edge extending into interior - addEdge(iprob, iv, tri_key); - } - IVptr addBoundaryEndpoint( - IsctProblem *iprob, Tptr tri_key, Eptr edge, Vec3d coord, GluePt glue - ) { - IVptr iv = iprob->newSplitIsctVert(coord, glue); - addBoundaryHelper(edge, iv); - // handle edge extending into interior - addEdge(iprob, iv, tri_key); - return iv; - } - // Should only happen for manually inserted split points on - // edges, not for points computed via intersection... - IVptr addBoundaryPointAlone( - IsctProblem *iprob, Eptr edge, Vec3d coord, GluePt glue - ) { - IVptr iv = iprob->newSplitIsctVert(coord, glue); - addBoundaryHelper(edge, iv); - return iv; - } - void addInteriorPoint( - IsctProblem *iprob, Tptr t0, Tptr t1, GluePt glue - ) { - // note this generates wasted re-computation of coordinates 3X - IVptr iv = iprob->newIsctVert(the_tri, t0, t1, glue); - iv->boundary = false; - iverts.push_back(iv); - // find the 2 interior edges - for(IEptr ie : iedges) { - if(ie->other_tri_key == t0 || - ie->other_tri_key == t1) { - ie->interior.push_back(iv); - iv->edges.push_back(ie); - } - } - } - - // run after we've accumulated all the elements - void consolidate(IsctProblem *iprob) { - // identify all intersection edges missing endpoints - // and check to see if we can assign an original vertex - // as the appropriate endpoint. - for(IEptr ie : iedges) { - if(ie->ends[1] == nullptr) { - // try to figure out which vertex must be the endpoint... - Vptr vert = commonVert(the_tri, ie->other_tri_key); - if(!vert) { - std::cout << "the edge is " - << ie->ends[0] << ", " - << ie->ends[1] << std::endl; - IVptr iv = dynamic_cast(ie->ends[0]); - std::cout << " " - << iv->glue_marker->edge_tri_type - << std::endl; - std::cout << "the tri is " << the_tri << ": " - << *the_tri << std::endl; - std::cout << "other tri is " << ie->other_tri_key << ": " - << *(ie->other_tri_key) << std::endl; - std::cout << "coordinates for triangles" << std::endl; - std::cout << "the tri" << std::endl; - for(uint k=0; k<3; k++) - std::cout << iprob->vPos(the_tri->verts[k]) - << std::endl; - for(uint k=0; k<3; k++) - std::cout << iprob->vPos(ie->other_tri_key->verts[k]) - << std::endl; - std::cout << "degen count:" - << Empty3d::degeneracy_count << std::endl; - std::cout << "exact count: " - << Empty3d::exact_count << std::endl; - } - ENSURE(vert); // bad if we can't find a common vertex - // then, find the corresponding OVptr, and connect - for(uint k=0; k<3; k++) { - if(overts[k]->concrete == vert) { - ie->ends[1] = overts[k]; - overts[k]->edges.push_back(ie); - break; - } - } - } - } - - ENSURE(isValid()); - } - - bool isValid() const { - ENSURE(the_tri); - - return true; - } - - void subdivide(IsctProblem *iprob) { - // collect all the points, and create more points as necessary - ShortVec points; - for(uint k=0; k<3; k++) { - points.push_back(overts[k]); - //std::cout << k << ": id " << overts[k]->concrete->ref << std::endl; - } - for(IVptr iv : iverts) { - //iprob->buildConcreteVert(iv); - points.push_back(iv); - /*std::cout << " " << points.size() - 1 - << " (" << iv->glue_marker->edge_tri_type - << ") "; - if(iv->glue_marker->edge_tri_type) { - Eptr e = iv->glue_marker->e; - Vec3d p0 = iprob->vPos(e->verts[0]); - Vec3d p1 = iprob->vPos(e->verts[1]); - std::cout << " " - << e->verts[0]->ref << p0 - << " " << e->verts[1]->ref << p1; - - Tptr t = iv->glue_marker->t[0]; - p0 = iprob->vPos(t->verts[0]); - p1 = iprob->vPos(t->verts[1]); - Vec3d p2 = iprob->vPos(t->verts[2]); - std::cout << " " - << t->verts[0]->ref << p0 - << " " << t->verts[1]->ref << p1 - << " " << t->verts[2]->ref << p2; - } - std::cout - << std::endl;*/ - } - for(uint i=0; iidx = i; - - // split edges and marshall data - // for safety, we zero out references to pre-subdivided edges, - // which may have been destroyed - ShortVec edges; - for(uint k=0; k<3; k++) { - //std::cout << "oedge: " - // << oedges[k]->ends[0]->idx << "; " - // << oedges[k]->ends[1]->idx << std::endl; - //for(IVptr iv : oedges[k]->interior) - // std::cout << " " << iv->idx << std::endl; - subdivideEdge(iprob, oedges[k], edges); - oedges[k] = nullptr; - } - //std::cout << "THE TRI: " << the_tri->verts[0]->ref - // << "; " << the_tri->verts[1]->ref - // << "; " << the_tri->verts[2]->ref - // << std::endl; - for(IEptr &ie : iedges) { - //std::cout << "iedge: " - // << ie->ends[0]->idx << "; " - // << ie->ends[1]->idx << std::endl; - //std::cout << "other tri: " << ie->other_tri_key->verts[0]->ref - // << "; " << ie->other_tri_key->verts[1]->ref - // << "; " << ie->other_tri_key->verts[2]->ref - // << std::endl; - //for(IVptr iv : ie->interior) - // std::cout << " " << iv->idx - // << " (" << iv->glue_marker->edge_tri_type - // << ") " << std::endl; - subdivideEdge(iprob, ie, edges); - ie = nullptr; - } - for(uint i=0; iidx = i; - - // find 2 dimensions to project onto - // get normal - Vec3d normal = cross( overts[1]->coord - overts[0]->coord, - overts[2]->coord - overts[0]->coord ); - uint normdim = maxDim(abs(normal)); - uint dim0 = (normdim+1)%3; - uint dim1 = (normdim+2)%3; - double sign_flip = (normal.v[normdim] < 0.0)? -1.0 : 1.0; - - struct triangulateio in, out; - - /* Define input points. */ - in.numberofpoints = points.size(); - in.numberofpointattributes = 0; - in.pointlist = new REAL[in.numberofpoints * 2]; - in.pointattributelist = nullptr; - in.pointmarkerlist = new int[in.numberofpoints]; - for(int k=0; kcoord.v[dim0]; - in.pointlist[k*2 + 1] = points[k]->coord.v[dim1] * sign_flip; - in.pointmarkerlist[k] = (points[k]->boundary)? 1 : 0; - } - - /* Define the input segments */ - in.numberofsegments = edges.size(); - in.numberofholes = 0;// yes, zero - in.numberofregions = 0;// not using regions - in.segmentlist = new int[in.numberofsegments * 2]; - in.segmentmarkerlist = new int[in.numberofsegments]; - for(int k=0; kends[0]->idx; - in.segmentlist[k*2 + 1] = edges[k]->ends[1]->idx; - in.segmentmarkerlist[k] = (edges[k]->boundary)? 1 : 0; - } - - // to be safe... declare 0 triangle attributes on input - in.numberoftriangles = 0; - in.numberoftriangleattributes = 0; - - /* set for flags.... */ - out.pointlist = nullptr; - out.pointattributelist = nullptr; // not necessary if using -N or 0 attr - out.pointmarkerlist = nullptr; - out.trianglelist = nullptr; // not necessary if using -E - //out.triangleattributelist = null; // not necessary if using -E or 0 attr - //out.trianglearealist = // only needed with -r and -a - //out.neighborlist = null; // only neccesary if -n is used - out.segmentlist = nullptr; // NEED THIS; output segments go here - out.segmentmarkerlist = nullptr; // NEED THIS for OUTPUT SEGMENTS - //out.edgelist = null; // only necessary if -e is used - //out.edgemarkerlist = null; // only necessary if -e is used - - // solve the triangulation problem - char *params = (char*)("pzQYY"); - //char *debug_params = (char*)("pzYYVC"); - triangulate(params, &in, &out, nullptr); - - if(out.numberofpoints != in.numberofpoints) { - std::cout << "out.numberofpoints: " - << out.numberofpoints << std::endl; - std::cout << "points.size(): " << points.size() << std::endl; - std::cout << "dumping out the points' coordinates" << std::endl; - for(uint k=0; kcoord - << " " << gv->idx << std::endl; - } - - std::cout << "dumping out the segments" << std::endl; - for(int k=0; knewGenericTri(gv0, gv1, gv2); - } - - - // clean up after triangulate... - // in free - free(in.pointlist); - free(in.pointmarkerlist); - free(in.segmentlist); - free(in.segmentmarkerlist); - // out free - free(out.pointlist); - //free(out.pointattributelist); - free(out.pointmarkerlist); - free(out.trianglelist); - //free(out.triangleattributelist); - //free(out.trianglearealist); - //free(out.neighborlist); - free(out.segmentlist); - free(out.segmentmarkerlist); - //free(out.edgelist); - //free(out.edgemarkerlist); - } - -private: - void subdivideEdge(IsctProblem *iprob, GEptr ge, ShortVec &edges) - { - if(ge->interior.size() == 0) { - //if(typeid(ge) == typeid(IEptr)) { // generate new edge - // iprob->buildConcreteEdge(ge); - //} - edges.push_back(ge); - } else if(ge->interior.size() == 1) { // common case - SEptr se0 = iprob->newSplitEdge(ge->ends[0], - ge->interior[0], - ge->boundary); - SEptr se1 = iprob->newSplitEdge(ge->interior[0], - ge->ends[1], - ge->boundary); - //iprob->buildConcreteEdge(se0); - //iprob->buildConcreteEdge(se1); - edges.push_back(se0); - edges.push_back(se1); - - // get rid of old edge - iprob->releaseEdge(ge); - } else { // sorting is the uncommon case - // determine the primary dimension and direction of the edge - Vec3d dir = ge->ends[1]->coord - ge->ends[0]->coord; - uint dim = (fabs(dir.x) > fabs(dir.y))? - ((fabs(dir.x) > fabs(dir.z))? 0 : 2) : - ((fabs(dir.y) > fabs(dir.z))? 1 : 2); - double sign = (dir.v[dim] > 0.0)? 1.0 : -1.0; - - // pack the interior vertices into a vector for sorting - std::vector< std::pair > verts; - for(IVptr iv : ge->interior) { - verts.push_back(std::make_pair( - // if the sort is ascending, then we're good... - sign * iv->coord.v[dim], - iv - )); - } - // ... and sort the vector - std::sort(verts.begin(), verts.end()); - // then, write the verts into a new container with the endpoints - std::vector allv(verts.size()+2); - allv[0] = ge->ends[0]; - allv[allv.size()-1] = ge->ends[1]; - for(uint k=0; knewSplitEdge(allv[i-1], - allv[i], - ge->boundary); - edges.push_back(se); - } - // get rid of old edge - iprob->releaseEdge(ge); - } - } - -public: // data - ShortVec iverts; - ShortVec iedges; - // original triangle elements - OVptr overts[3]; - OEptr oedges[3]; - - ShortVec gtris; - - Tptr the_tri; -}; - - -template -class Mesh::IsctProblem : public TopoCache -{ -public: - IsctProblem(Mesh *owner) : TopoCache(owner) - { - // initialize all the triangles to NOT have an associated tprob - TopoCache::tris.for_each([](Tptr t) { - t->data = nullptr; - }); - - // Callibrate the quantization unit... - double maxMag = 0.0; - for(VertData &v : TopoCache::mesh->verts) { - maxMag = std::max(maxMag, max(abs(v.pos))); - } - Quantization::callibrate(maxMag); - - // and use vertex auxiliary data to store quantized vertex coordinates - uint N = TopoCache::mesh->verts.size(); - quantized_coords.resize(N); - uint write = 0; - TopoCache::verts.for_each([&](Vptr v) { -#ifdef _WIN32 - Vec3d raw = mesh->verts[v->ref].pos; -#else - Vec3d raw = TopoCache::mesh->verts[v->ref].pos; -#endif - quantized_coords[write].x = Quantization::quantize(raw.x); - quantized_coords[write].y = Quantization::quantize(raw.y); - quantized_coords[write].z = Quantization::quantize(raw.z); - v->data = &(quantized_coords[write]); - write++; - }); - } - - virtual ~IsctProblem() {} - - // access auxiliary quantized coordinates - inline Vec3d vPos(Vptr v) const { - return *(reinterpret_cast(v->data)); - } - - Tprob getTprob(Tptr t) { - Tprob prob = reinterpret_cast(t->data); - if(!prob) { - t->data = prob = tprobs.alloc(); - prob->init(this, t); - } - return prob; - } - GluePt newGluePt() { - GluePt glue = glue_pts.alloc(); - glue->split_type = false; - return glue; - } - - inline IVptr newIsctVert(Eptr e, Tptr t, GluePt glue) { - IVptr iv = ivpool.alloc(); - iv->concrete = nullptr; - iv->coord = computeCoords(e, t); - iv->glue_marker = glue; - glue->copies.push_back(iv); - return iv; - } - inline IVptr newIsctVert(Tptr t0, Tptr t1, Tptr t2, GluePt glue) { - IVptr iv = ivpool.alloc(); - iv->concrete = nullptr; - iv->coord = computeCoords(t0, t1, t2); - iv->glue_marker = glue; - glue->copies.push_back(iv); - return iv; - } - inline IVptr newSplitIsctVert(Vec3d coords, GluePt glue) { - IVptr iv = ivpool.alloc(); - iv->concrete = nullptr; - iv->coord = coords; - iv->glue_marker = glue; - glue->copies.push_back(iv); - return iv; - } - inline IVptr copyIsctVert(IVptr orig) { - IVptr iv = ivpool.alloc(); - iv->concrete = nullptr; - iv->coord = orig->coord; - iv->glue_marker = orig->glue_marker; - orig->glue_marker->copies.push_back(iv); - return iv; - } - inline IEptr newIsctEdge(IVptr endpoint, Tptr tri_key) { - IEptr ie = iepool.alloc(); - ie->concrete = nullptr; - ie->boundary = false; - ie->ends[0] = endpoint; - endpoint->edges.push_back(ie); - ie->ends[1] = nullptr; // other end null - ie->other_tri_key = tri_key; - return ie; - } - - inline OVptr newOrigVert(Vptr v) { - OVptr ov = ovpool.alloc(); - ov->concrete = v; - ov->coord = vPos(v); - ov->boundary = true; - return ov; - } - inline OEptr newOrigEdge(Eptr e, OVptr v0, OVptr v1) { - OEptr oe = oepool.alloc(); - oe->concrete = e; - oe->boundary = true; - oe->ends[0] = v0; - oe->ends[1] = v1; - v0->edges.push_back(oe); - v1->edges.push_back(oe); - return oe; - } - inline SEptr newSplitEdge(GVptr v0, GVptr v1, bool boundary) { - SEptr se = sepool.alloc(); - se->concrete = nullptr; - se->boundary = boundary; - se->ends[0] = v0; - se->ends[1] = v1; - v0->edges.push_back(se); - v1->edges.push_back(se); - return se; - } - - inline GTptr newGenericTri(GVptr v0, GVptr v1, GVptr v2) { - GTptr gt = gtpool.alloc(); - gt->verts[0] = v0; - gt->verts[1] = v1; - gt->verts[2] = v2; - gt->concrete = nullptr; - return gt; - } - - inline void releaseEdge(GEptr ge) { - disconnectGE(ge); - IEptr ie = dynamic_cast(ge); - if(ie) { - iepool.free(ie); - } else { - OEptr oe = dynamic_cast(ge); - ENSURE(oe); - oepool.free(oe); - } - } - - inline void killIsctVert(IVptr iv) { - iv->glue_marker->copies.erase(iv); - if(iv->glue_marker->copies.size() == 0) - glue_pts.free(iv->glue_marker); - - for(GEptr ge : iv->edges) { - // disconnect - ge->interior.erase(iv); - if(ge->ends[0] == iv) ge->ends[0] = nullptr; - if(ge->ends[1] == iv) ge->ends[1] = nullptr; - } - - ivpool.free(iv); - } - - inline void killIsctEdge(IEptr ie) { - // an endpoint may be an original vertex - if(ie->ends[1]) - ie->ends[1]->edges.erase(ie); - iepool.free(ie); - } - - inline void killOrigVert(OVptr ov) { - ovpool.free(ov); - } - inline void killOrigEdge(OEptr oe) { - oepool.free(oe); - } - - /* - inline void buildConcreteVert(GVptr gv) { - gv->concrete = newVert(); - // NEED DATA SOMEHOW?? - } - // make sure the endpoints have concrete versions first! - inline void buildConcreteEdge(GEptr ge) { - Eptr e = ge->concrete = newEdge(); - Vptr v0 = e->verts[0] = ge->ends[0]->concrete; - Vptr v1 = e->verts[1] = ge->ends[1]->concrete; - v0->edges.push_back(e); - v1->edges.push_back(e); - } - inline void buildConcreteTri(GVptr gv0, GVptr gv1, GVptr gv2) { - // create edges as necessary... - }*/ - - bool hasIntersections(); // test for iscts, exit if one is found - - void findIntersections(); - void resolveAllIntersections(); -private: - // if we encounter ambiguous degeneracies, then this - // routine returns false, indicating that the computation aborted. - bool tryToFindIntersections(); - // In that case, we can perturb the positions of points - void perturbPositions(); - // in order to give things another try, discard partial work - void reset(); -public: - - void dumpIsctPoints(std::vector *points); - void dumpIsctEdges(std::vector< std::pair > *edges); - -protected: // DATA - IterPool glue_pts; - IterPool tprobs; - - IterPool ivpool; - IterPool ovpool; - IterPool iepool; - IterPool oepool; - IterPool sepool; - IterPool gtpool; -private: - std::vector quantized_coords; -private: - inline void for_edge_tri(std::function); - inline void bvh_edge_tri(std::function); - - inline GeomBlob edge_blob(Eptr e); - inline BBox3d bboxFromTptr(Tptr t); - - inline BBox3d buildBox(Eptr e) const; - inline BBox3d buildBox(Tptr t) const; - - inline void marshallArithmeticInput(Empty3d::TriIn &input, Tptr t) const; - inline void marshallArithmeticInput(Empty3d::EdgeIn &input, Eptr e) const; - inline void marshallArithmeticInput( - Empty3d::TriEdgeIn &input, Eptr e, Tptr t) const; - inline void marshallArithmeticInput( - Empty3d::TriTriTriIn &input, Tptr t0, Tptr t1, Tptr t2) const; - - bool checkIsct(Eptr e, Tptr t) const; - bool checkIsct(Tptr t0, Tptr t1, Tptr t2) const; - - Vec3d computeCoords(Eptr e, Tptr t) const; - Vec3d computeCoords(Tptr t0, Tptr t1, Tptr t2) const; - - void fillOutVertData(GluePt glue, VertData &data); - void fillOutTriData(Tptr tri, Tptr parent); -private: - class EdgeCache; - -private: // functions here to get around a GCC bug... - void createRealPtFromGluePt(GluePt glue); - void createRealTriangles(Tprob tprob, EdgeCache &ecache); -}; - -template inline -void for_pairs( - ShortVec &vec, - std::function func -) { - for(uint i=0; i inline -void Mesh::IsctProblem::for_edge_tri( - std::function func -) { - bool aborted = false; - TopoCache::tris.for_each([&](Tptr t) { - TopoCache::edges.for_each([&](Eptr e) { - if(!aborted) { - if(!func(e, t)) - aborted = true; - } - }); - }); -} - -template inline -GeomBlob Mesh::IsctProblem::edge_blob( - Eptr e -) { - GeomBlob blob; - blob.bbox = buildBox(e); - blob.point = (blob.bbox.minp + blob.bbox.maxp) / 2.0; - blob.id = e; - return blob; -} - -template inline -void Mesh::IsctProblem::bvh_edge_tri( - std::function func -) { - std::vector< GeomBlob > edge_geoms; - TopoCache::edges.for_each([&](Eptr e) { - edge_geoms.push_back(edge_blob(e)); - }); - AABVH edgeBVH(edge_geoms); - - // use the acceleration structure - bool aborted = false; - TopoCache::tris.for_each([&](Tptr t) { - // compute BBox - BBox3d bbox = buildBox(t); - if(!aborted) { - edgeBVH.for_each_in_box(bbox, [&](Eptr e) { - if(!func(e,t)) - aborted = true; - }); - } - }); -} - -template -bool Mesh::IsctProblem::tryToFindIntersections() -{ - Empty3d::degeneracy_count = 0; - // Find all edge-triangle intersection points - //for_edge_tri([&](Eptr eisct, Tptr tisct)->bool{ - bvh_edge_tri([&](Eptr eisct, Tptr tisct)->bool{ - if(checkIsct(eisct,tisct)) { - GluePt glue = newGluePt(); - glue->edge_tri_type = true; - glue->e = eisct; - glue->t[0] = tisct; - // first add point and edges to the pierced triangle - IVptr iv = getTprob(tisct)->addInteriorEndpoint(this, eisct, glue); - for(Tptr tri : eisct->tris) { - getTprob(tri)->addBoundaryEndpoint(this, tisct, eisct, iv); - } - } - if(Empty3d::degeneracy_count > 0) - return false; // break - else - return true; // continue - }); - if(Empty3d::degeneracy_count > 0) { - return false; // restart / abort - } - - // we're going to peek into the triangle problems in order to - // identify potential candidates for Tri-Tri-Tri intersections - std::vector triples; - tprobs.for_each([&](Tprob tprob) { - Tptr t0 = tprob->the_tri; - // Scan pairs of existing edges to create candidate triples - for_pairs(tprob->iedges, [&](IEptr &ie1, IEptr &ie2){ - Tptr t1 = ie1->other_tri_key; - Tptr t2 = ie2->other_tri_key; - // This triple might be considered three times, - // one for each triangle it contains. - // To prevent duplication, only proceed if this is - // the least triangle according to an arbitrary ordering - if(t0 < t1 && t0 < t2) { - // now look for the third edge. We're not - // sure if it exists... - Tprob prob1 = reinterpret_cast(t1->data); - for(IEptr ie : prob1->iedges) { - if(ie->other_tri_key == t2) { - // ADD THE TRIPLE - triples.push_back(TriTripleTemp(t0, t1, t2)); - } - } - } - }); - }); - // Now, we've collected a list of Tri-Tri-Tri intersection candidates. - // Check to see if the intersections actually exist. - for(TriTripleTemp t : triples) { - if(!checkIsct(t.t0, t.t1, t.t2)) continue; - - // Abort if we encounter a degeneracy - if(Empty3d::degeneracy_count > 0) break; - - GluePt glue = newGluePt(); - glue->edge_tri_type = false; - glue->t[0] = t.t0; - glue->t[1] = t.t1; - glue->t[2] = t.t2; - getTprob(t.t0)->addInteriorPoint(this, t.t1, t.t2, glue); - getTprob(t.t1)->addInteriorPoint(this, t.t0, t.t2, glue); - getTprob(t.t2)->addInteriorPoint(this, t.t0, t.t1, glue); - } - if(Empty3d::degeneracy_count > 0) { - return false; // restart / abort - } - - return true; -} - -template -void Mesh::IsctProblem::perturbPositions() -{ - // Alec - //const double EPSILON = 1.0e-5; // perturbation epsilon - const double EPSILON = 2.5e-9; // perturbation epsilon - for(Vec3d &coord : quantized_coords) { - Vec3d perturbation(Quantization::quantize(drand(-EPSILON, EPSILON)), - Quantization::quantize(drand(-EPSILON, EPSILON)), - Quantization::quantize(drand(-EPSILON, EPSILON))); - coord += perturbation; - } -} - -template -void Mesh::IsctProblem::reset() -{ - // the data pointer in the triangles points to tproblems - // that we're about to destroy, - // so zero out all those pointers first! - tprobs.for_each([](Tprob tprob) { - Tptr t = tprob->the_tri; - t->data = nullptr; - }); - - glue_pts.clear(); - tprobs.clear(); - - ivpool.clear(); - ovpool.clear(); - iepool.clear(); - oepool.clear(); - sepool.clear(); - gtpool.clear(); -} - -template -void Mesh::IsctProblem::findIntersections() -{ - // Alec: - int nTrys = 300; - //perturbPositions(); // always perturb for safety... - while(nTrys > 0) { - if(!tryToFindIntersections()) { - reset(); - perturbPositions(); - nTrys--; - } else { - break; - } - } - if(nTrys <= 0) { - CORK_ERROR("Ran out of tries to perturb the mesh"); - //exit(1); - throw std::runtime_error("Ran out of tries to perturb the mesh"); - } - - // ok all points put together, - // all triangle problems assembled. - // Some intersection edges may have original vertices as endpoints - // we consolidate the problems to check for cases like these. - tprobs.for_each([&](Tprob tprob) { - tprob->consolidate(this); - }); -} - -template -bool Mesh::IsctProblem::hasIntersections() -{ - bool foundIsct = false; - Empty3d::degeneracy_count = 0; - // Find some edge-triangle intersection point... - bvh_edge_tri([&](Eptr eisct, Tptr tisct)->bool{ - if(checkIsct(eisct,tisct)) { - foundIsct = true; - return false; // break; - } - if(Empty3d::degeneracy_count > 0) { - return false; // break; - } - return true; // continue - }); - - if(Empty3d::degeneracy_count > 0 || foundIsct) { - std::cout << "This self-intersection might be spurious. " - "Degeneracies were detected." << std::endl; - return true; - } else { - return false; - } -} - - -template inline -BBox3d Mesh::IsctProblem::buildBox(Eptr e) const -{ - Vec3d p0 = vPos(e->verts[0]); - Vec3d p1 = vPos(e->verts[1]); - return BBox3d(min(p0, p1), max(p0, p1)); -} -template inline -BBox3d Mesh::IsctProblem::buildBox(Tptr t) const -{ - Vec3d p0 = vPos(t->verts[0]); - Vec3d p1 = vPos(t->verts[1]); - Vec3d p2 = vPos(t->verts[2]); - return BBox3d(min(p0, min(p1, p2)), max(p0, max(p1, p2))); -} - -template inline -void Mesh::IsctProblem::marshallArithmeticInput( - Empty3d::EdgeIn &input, Eptr e -) const { - input.p[0] = vPos(e->verts[0]); - input.p[1] = vPos(e->verts[1]); -} -template inline -void Mesh::IsctProblem::marshallArithmeticInput( - Empty3d::TriIn &input, Tptr t -) const { - input.p[0] = vPos(t->verts[0]); - input.p[1] = vPos(t->verts[1]); - input.p[2] = vPos(t->verts[2]); -} -template inline -void Mesh::IsctProblem::marshallArithmeticInput( - Empty3d::TriEdgeIn &input, - Eptr e, Tptr t -) const { - marshallArithmeticInput(input.edge, e); - marshallArithmeticInput(input.tri, t); -} -template inline -void Mesh::IsctProblem::marshallArithmeticInput( - Empty3d::TriTriTriIn &input, - Tptr t0, Tptr t1, Tptr t2 -) const { - marshallArithmeticInput(input.tri[0], t0); - marshallArithmeticInput(input.tri[1], t1); - marshallArithmeticInput(input.tri[2], t2); -} - -template -bool Mesh::IsctProblem::checkIsct(Eptr e, Tptr t) const -{ - // simple bounding box cull; for acceleration, not correctness - BBox3d ebox = buildBox(e); - BBox3d tbox = buildBox(t); - if(!hasIsct(ebox, tbox)) - return false; - - // must check whether the edge and triangle share a vertex - // if so, then trivially we know they intersect in exactly that vertex - // so we discard this case from consideration. - if(hasCommonVert(e, t)) - return false; - - Empty3d::TriEdgeIn input; - marshallArithmeticInput(input, e, t); - //bool empty = Empty3d::isEmpty(input); - bool empty = Empty3d::emptyExact(input); - return !empty; -} - -template -bool Mesh::IsctProblem::checkIsct( - Tptr t0, Tptr t1, Tptr t2 -) const { - // This function should only be called if we've already - // identified that the intersection edges - // (t0,t1), (t0,t2), (t1,t2) - // exist. - // From this, we can conclude that each pair of triangles - // shares no more than a single vertex in common. - // If each of these shared vertices is different from each other, - // then we could legitimately have a triple intersection point, - // but if all three pairs share the same vertex in common, then - // the intersection of the three triangles must be that vertex. - // So, we must check for such a single vertex in common amongst - // the three triangles - Vptr common = commonVert(t0, t1); - if(common) { - for(uint i=0; i<3; i++) - if(common == t2->verts[i]) - return false; - } - - Empty3d::TriTriTriIn input; - marshallArithmeticInput(input, t0, t1, t2); - //bool empty = Empty3d::isEmpty(input); - bool empty = Empty3d::emptyExact(input); - return !empty; -} - -template -Vec3d Mesh::IsctProblem::computeCoords(Eptr e, Tptr t) const -{ - Empty3d::TriEdgeIn input; - marshallArithmeticInput(input, e, t); - Vec3d coords = Empty3d::coordsExact(input); - return coords; -} - -template -Vec3d Mesh::IsctProblem::computeCoords( - Tptr t0, Tptr t1, Tptr t2 -) const { - Empty3d::TriTriTriIn input; - marshallArithmeticInput(input, t0, t1, t2); - Vec3d coords = Empty3d::coordsExact(input); - return coords; -} - - -template -void Mesh::IsctProblem::fillOutVertData( - GluePt glue, VertData &data -) { - if(glue->split_type) { // manually inserted split point - uint v0i = glue->e->verts[0]->ref; - uint v1i = glue->e->verts[1]->ref; - data.isctInterpolate(TopoCache::mesh->verts[v0i], - TopoCache::mesh->verts[v1i]); - } else - if(glue->edge_tri_type) { // edge-tri type - IsctVertEdgeTriInput input; - for(uint k=0; k<2; k++) { - uint vid = glue->e->verts[k]->ref; - input.e[k] = &(TopoCache::mesh->verts[vid]); - } - for(uint k=0; k<3; k++) { - uint vid = glue->t[0]->verts[k]->ref; - input.t[k] = &(TopoCache::mesh->verts[vid]); - } - data.isct(input); - } else { // tri-tri-tri type - IsctVertTriTriTriInput input; - for(uint i=0; i<3; i++) { - for(uint j=0; j<3; j++) { - uint vid = glue->t[i]->verts[j]->ref; - input.t[i][j] = &(TopoCache::mesh->verts[vid]); - }} - data.isct(input); - } -} - -template inline -void Mesh::subdivide_tri( - uint t_piece_ref, uint t_parent_ref -) { - SubdivideTriInput input; - input.pt = &(tris[t_parent_ref].data); - for(uint k=0; k<3; k++) { - input.pv[k] = &(verts[tris[t_parent_ref].v[k]]); - input.v[k] = &(verts[tris[t_piece_ref].v[k]]); - } - tris[t_piece_ref].data.subdivide(input); -} - -template -void Mesh::IsctProblem::fillOutTriData( - Tptr piece, Tptr parent -) { - TopoCache::mesh->subdivide_tri(piece->ref, parent->ref); -} - - -template -class Mesh::IsctProblem::EdgeCache -{ -public: - EdgeCache(IsctProblem *ip) : iprob(ip), edges(ip->mesh->verts.size()) {} - - Eptr operator()(Vptr v0, Vptr v1) { - uint i = v0->ref; - uint j = v1->ref; - if(i > j) std::swap(i,j); - - uint N = edges[i].size(); - for(uint k=0; knewEdge(); - e->verts[0] = v0; - e->verts[1] = v1; - v0->edges.push_back(e); - v1->edges.push_back(e); - - return e; - } - - // k = 0, 1, or 2 - Eptr getTriangleEdge(GTptr gt, uint k, Tptr big_tri) - { - GVptr gv0 = gt->verts[(k+1)%3]; - GVptr gv1 = gt->verts[(k+2)%3]; - Vptr v0 = gv0->concrete; - Vptr v1 = gv1->concrete; - // if neither of these are intersection points, - // then this is a pre-existing edge... - Eptr e = nullptr; - if(typeid(gv0) == typeid(OVptr) && - typeid(gv1) == typeid(OVptr) - ) { - // search through edges of original triangle... - for(uint c=0; c<3; c++) { - Vptr corner0 = big_tri->verts[(c+1)%3]; - Vptr corner1 = big_tri->verts[(c+2)%3]; - if((corner0 == v0 && corner1 == v1) || - (corner0 == v1 && corner1 == v0)) { - e = big_tri->edges[c]; - } - } - ENSURE(e); // Yell if we didn't find an edge - } - // otherwise, we need to check the cache to find this edge - else - { - e = operator()(v0, v1); - } - return e; - } - - Eptr maybeEdge(GEptr ge) - { - uint i = ge->ends[0]->concrete->ref; - uint j = ge->ends[1]->concrete->ref; - if(i > j) std::swap(i,j); - - uint N = edges[i].size(); - for(uint k=0; k > edges; -}; - -template -void Mesh::IsctProblem::createRealPtFromGluePt(GluePt glue) { - ENSURE(glue->copies.size() > 0); - Vptr v = TopoCache::newVert(); - VertData &data = TopoCache::mesh->verts[v->ref]; - data.pos = glue->copies[0]->coord; - fillOutVertData(glue, data); - for(IVptr iv : glue->copies) - iv->concrete = v; -} - -template -void Mesh::IsctProblem::createRealTriangles( - Tprob tprob, EdgeCache &ecache -) { - for(GTptr gt : tprob->gtris) { - Tptr t = TopoCache::newTri(); - gt->concrete = t; - Tri &tri = TopoCache::mesh->tris[t->ref]; - for(uint k=0; k<3; k++) { - Vptr v = gt->verts[k]->concrete; - t->verts[k] = v; - v->tris.push_back(t); - tri.v[k] = v->ref; - - Eptr e = ecache.getTriangleEdge(gt, k, tprob->the_tri); - e->tris.push_back(t); - t->edges[k] = e; - } - fillOutTriData(t, tprob->the_tri); - } - // Once all the pieces are hooked up, let's kill the old triangle! - TopoCache::deleteTri(tprob->the_tri); -} - -template -void Mesh::IsctProblem::resolveAllIntersections() -{ - // solve a subdivision problem in each triangle - tprobs.for_each([&](Tprob tprob) { - tprob->subdivide(this); - }); - - // now we have diced up triangles inside each triangle problem - - // Let's go through the glue points and create a new concrete - // vertex object for each of these. - glue_pts.for_each([&](GluePt glue) { - createRealPtFromGluePt(glue); - }); - - EdgeCache ecache(this); - - // Now that we have concrete vertices plugged in, we can - // go through the diced triangle pieces and create concrete triangles - // for each of those. - // Along the way, let's go ahead and hook up edges as appropriate - tprobs.for_each([&](Tprob tprob) { - createRealTriangles(tprob, ecache); - }); - - // mark all edges as normal by zero-ing out the data pointer - TopoCache::edges.for_each([](Eptr e) { - e->data = 0; - }); - // then iterate over the edges formed by intersections - // (i.e. those edges without the boundary flag set in each triangle) - // and mark those by setting the data pointer - iepool.for_each([&](IEptr ie) { - // every ie must be non-boundary - Eptr e = ecache.maybeEdge(ie); - ENSURE(e); - e->data = (void*)1; - }); - sepool.for_each([&](SEptr se) { - //if(se->boundary) return; // continue - Eptr e = ecache.maybeEdge(se); - ENSURE(e); - e->data = (void*)1; - }); - - // This basically takes care of everything EXCEPT one detail - // *) The base mesh data structures still need to be compacted - - // This detail should be handled by the calling code... -} - -template -void Mesh::IsctProblem::dumpIsctPoints( - std::vector *points -) { - points->resize(glue_pts.size()); - uint write = 0; - glue_pts.for_each([&](GluePt glue) { - ENSURE(glue->copies.size() > 0); - IVptr iv = glue->copies[0]; - (*points)[write] = iv->coord; - write++; - }); -} - -template -void Mesh::IsctProblem::dumpIsctEdges( - std::vector< std::pair > *edges -) { - edges->clear(); - tprobs.for_each([&](Tprob tprob) { - for(IEptr ie : tprob->iedges) { - GVptr gv0 = ie->ends[0]; - GVptr gv1 = ie->ends[1]; - edges->push_back(std::make_pair(gv0->coord, gv1->coord)); - } - }); -} - -template -void Mesh::testingComputeStaticIsctPoints( - std::vector *points -) { - IsctProblem iproblem(this); - - iproblem.findIntersections(); - - iproblem.dumpIsctPoints(points); -} - - -template -void Mesh::testingComputeStaticIsct( - std::vector *points, - std::vector< std::pair > *edges -) { - IsctProblem iproblem(this); - - iproblem.findIntersections(); - - iproblem.dumpIsctPoints(points); - iproblem.dumpIsctEdges(edges); -} - -template -void Mesh::resolveIntersections() -{ - IsctProblem iproblem(this); - - iproblem.findIntersections(); - - iproblem.resolveAllIntersections(); - - iproblem.commit(); - - //iproblem.print(); -} - -template -bool Mesh::isSelfIntersecting() -{ - IsctProblem iproblem(this); - - return iproblem.hasIntersections(); -} - - - diff --git a/external/cork/src/mesh/mesh.remesh.tpp b/external/cork/src/mesh/mesh.remesh.tpp deleted file mode 100644 index feece21cb..000000000 --- a/external/cork/src/mesh/mesh.remesh.tpp +++ /dev/null @@ -1,1209 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.remesh.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include -#include - -#include "memPool.h" - -//#include "files.h" - -#include "mesh.topoCache.tpp" - - - -enum EdgeRemeshOperation { - EDGE_SPLIT, - EDGE_COLLAPSE, - EDGE_NOTHING -}; - -struct RemeshEdgeAuxiliary { - double score; // priority for queue - EdgeRemeshOperation op; // operation to perform -}; - -template -struct Mesh::RemeshScratchpad { - TopoCache cache; - MemPool edge_data; - std::set< std::pair > queue; - - RemeshScratchpad(Mesh *mesh) : cache(mesh) {} -}; - - -template -void Mesh::remesh() -{ - //std::cout << "remesh initial tri count: " << tris.size() << std::endl; - if(verts.size() == 0) return; // pathology guard - - /*{ // dump out mesh before performing re-mesh - Files::FileMesh filemesh; - filemesh = transduce - (raw(), - [](Files::FileVertex &out, const VertData &in) { - out.pos = in.pos; - }, - [](Files::FileTriangle &out, const TriData &in) { - out.a = in.a; out.b = in.b; out.c = in.c; - }); - if(Files::writeTriMesh("remesh_in.off", &filemesh) > 0) { - CORK_ERROR("Unable to write out remesh input to remesh_in.off"); - } - }*/ - - // create a scratchpad and set it up - RemeshScratchpad scratchpad(this); - - // compute which vertices are boundary or not - for(VertData &v : verts) { - v.manifold = true; - } - scratchpad.cache.edges.for_each([this, &scratchpad](Eptr edge) { - if(edge->tris.size() != 2) { - verts[edge->verts[0]->ref].manifold = false; - verts[edge->verts[1]->ref].manifold = false; - } - }); - - // Then, we set up the priority queue - // (allocating auxiliary data as we go) - scratchpad.cache.edges.for_each([this, &scratchpad](Eptr edge) { - edge->data = scratchpad.edge_data.alloc(); - scoreAndEnqueue(scratchpad.queue, edge); - }); - - int cutoff = 10000; - // now let's go into a loop pulling work off of the queue - while(scratchpad.queue.size() > 0) { - // pop the end of the queue - auto it_top = scratchpad.queue.end(); - it_top--; - //double top_score = it_top->first; - Eptr top_edge = it_top->second; - scratchpad.queue.erase(it_top); - - // Which operation should be performed to this edge? - EdgeRemeshOperation op = - reinterpret_cast(top_edge->data)->op; - if(op == EDGE_SPLIT) { - //std::cout << "edge split" << std::endl; - edgeSplit(scratchpad, top_edge); - } else if (op == EDGE_COLLAPSE) { - //std::cout << "edge collapse" << std::endl; - edgeCollapse(scratchpad, top_edge, true); - } // else do nothing (should have score <= 0.0 then...) - cutoff--; - if(cutoff < 0) - break; - } - - //std::cout << " cache.tris is " - // << scratchpad.cache.tris.size() << std::endl; - //std::cout << "prefinalize tri count: " << tris.size() << std::endl; - - // finally, we commit all of the results of this remeshing operation - // causing the data storage to defrag and clean out dead items - scratchpad.cache.commit(); - - //std::cout << "remesh final tri count: " << tris.size() << std::endl; -} - - - -template -void Mesh::scoreAndEnqueue( - std::set< std::pair > &queue, - Eptr edge -) { - double score = computeEdgeScore(edge); - if(score > 0.0) // only enqueue edges with actual work to do - queue.insert(std::make_pair(score, edge)); -} - -template -void Mesh::dequeue( - std::set< std::pair > &queue, - Eptr edge -) { - double score = - reinterpret_cast(edge->data)->score; - auto it = queue.find(std::make_pair(score, edge)); - if(it != queue.end()) - queue.erase(it); -} - - - -template -inline void Mesh::edgeNeighborhood( - Eptr edge, - std::function once, - std::function each_tri -) { - Vptr v0 = edge->verts[0]; - Vptr v1 = edge->verts[1]; - VertData &data0 = verts[v0->ref]; - VertData &data1 = verts[v1->ref]; - - once(data0, data1); - - for(Tptr tri : edge->tris) { - TriData &tdata = tris[tri->ref].data; - for(uint i=0; i<3; i++) { - if(tri->edges[i] == edge) { - Vptr vopp = tri->verts[i]; - VertData &dataopp = verts[vopp->ref]; - each_tri(data0, data1, dataopp, tdata); - } - } - } -} - -template -double Mesh::computeEdgeScore(Eptr edge) { - double edge_length; - double min_angle = 360.0; // clearly overkill - double max_angle = 0.0; - edgeNeighborhood(edge, - [&edge_length] - (VertData &v0, VertData &v1) { // once - edge_length = len(v1.pos - v0.pos); - }, - [&min_angle, &max_angle] - (VertData &v0, VertData &v1, VertData &vopp, TriData &) { // per tri - Vec3d e0 = v0.pos - vopp.pos; - Vec3d e1 = v1.pos - vopp.pos; - double cos_angle = dot(e0, e1) / (len(e0)*len(e1)); - double angle = rad2deg(acos(cos_angle)); - if(angle < min_angle) min_angle = angle; - if(angle > max_angle) max_angle = angle; - // CURRENTLY OMITTING DIHEDRAL ANGLE CRITERION - }); - - RemeshEdgeAuxiliary *edge_aux = - reinterpret_cast(edge->data); - - // extract violation quantities: - // if any of these are positive, - // then an operation should be performed to this edge - double excess_length = edge_length - remesh_options.maxEdgeLength; - double deficient_length = remesh_options.minEdgeLength - edge_length; - double excess_angle = max_angle - remesh_options.maxAngle; - double deficient_angle = remesh_options.minAngle - max_angle; - if(excess_length <= 0.0 && deficient_length <= 0.0 && - excess_angle <= 0.0 && deficient_angle <= 0.0) { - // no op on edge - edge_aux->score = -1.0; - edge_aux->op = EDGE_NOTHING; - return edge_aux->score; - } - - // rescale violation quantities: - // make quantities more commensurate for use as priorities - excess_length /= remesh_options.maxEdgeLength; - deficient_length /= remesh_options.minEdgeLength; - excess_angle /= (180.0 - remesh_options.maxAngle); - deficient_angle /= remesh_options.minAngle; - edge_aux->score = -1.0; - if(excess_length > edge_aux->score) { - edge_aux->score = excess_length; - edge_aux->op = EDGE_SPLIT; - } - if(deficient_length > edge_aux->score) { - edge_aux->score = deficient_length; - edge_aux->op = EDGE_COLLAPSE; - } - if(excess_angle > edge_aux->score) { - edge_aux->score = excess_angle; - edge_aux->op = EDGE_SPLIT; - } - if(deficient_angle > edge_aux->score) { - edge_aux->score = deficient_angle; - edge_aux->op = EDGE_COLLAPSE; - } - - return edge_aux->score; -} - - - -// erase the first occurrence of a value from a short vector, -// !!! KNOWING that it MUST BE PRESENT -template inline -void remove(ShortVec &vec, T val) -{ - uint last_i = vec.size()-1; - for(uint i=0; i inline -void maybe_erase(ShortVec &vec, T val) -{ - uint N = vec.size(); - for(uint i=0; i inline -void Mesh::populateTriFromTopoTri(Tptr tri) { - Tri &tri_ref = tris[tri->ref]; - for(uint k=0; k<3; k++) - tri_ref.v[k] = tri->verts[k]->ref; -} - -template -Eptr Mesh::allocateRemeshEdge( - RemeshScratchpad &scratchpad -) { - Eptr e = scratchpad.cache.newEdge(); - e->data = scratchpad.edge_data.alloc(); - return e; -} - -template -void Mesh::deallocateRemeshEdge( - RemeshScratchpad &scratchpad, - Eptr e -) { - dequeue(scratchpad.queue, e); - scratchpad.cache.freeEdge(e); -} - - -template -inline void Mesh::merge_tris( - uint tid_result, uint tid0, uint tid1 -) { - tris[tid_result].data.merge(tris[tid0].data, tris[tid1].data); -} -template -inline void Mesh::split_tris( - uint t0ref, uint t1ref, uint t_orig_ref -) { - TriData::split(tris[t0ref].data, tris[t1ref].data, tris[t_orig_ref].data); -} -template -inline void Mesh::move_tri(Tri &t_new, Tri &t_old) -{ - t_new.data.move(t_old.data); -} - - - - - - -/* - Strategy: - 1. Construct new geometry in parallel to old geometry w/o - tampering with old geometry in any way. - 2. Fill out data for new geometry - 3. Determine whether or not to commit or abort the operation - 4. Connect new geometry to old geometry simultaneously to old geometry. - 5. Delete the old geometry appropriately -*/ - -struct EdgeWedge { - Eptr e0, e1; - - EdgeWedge() : e0(nullptr), e1(nullptr) {} - bool full() const { return e0 && e1; } - Eptr one() const { return (e0)? e0 : e1; } -}; - -struct TriWedge { - Tptr t0, t1; - - TriWedge() : t0(nullptr), t1(nullptr) {} - bool full() const { return t0 && t1; } - Tptr one() const { return (t0)? t0 : t1; } -}; - -struct VptrRemap { - Vptr v0, v1, v_merged; - VptrRemap(Vptr v0_, Vptr v1_, Vptr v_merged_) : - v0(v0_), v1(v1_), v_merged(v_merged_) - {} - Vptr operator[](Vptr key) { - if(key == v0 || key == v1) return v_merged; - else return key; - } -}; - -template -struct PtrRemap { - std::map remap; - - void set(T* key, T* val) { - remap[key] = val; - } - - T* operator[](T* key) { - auto it = remap.find(key); - if(it == remap.end()) return key; - else return it->second; - } -}; - -template -void Mesh::edgeCollapse( - RemeshScratchpad &scratchpad, - Eptr e_collapse, - bool collapsing_tetrahedra_disappear -) { - /* - * - * Two cases: both with and without a triangle filling the - * triangular arrangement (i.e. wedge) of edges - * - * * - * / \ - * / # # # \ - * / # # # # \ - * / # # # # # # # \ - * / # # # # # # # # \ - * / # # # # # # # # # # # \ - * vid0 *---------------------------* vid1 - * eid_collapse - * - * * - * / \ - * / \ - * / \ - * / \ - * / \ - * / \ - * vid0 *---------------------------* vid1 - * eid_collapse - * - * - * Additionally, we need to worry about how tetrahedral structures - * can collapse. If the collapse will identify the two - * non-collapsing faces, then we call this structure a triangle wedge - * - * - * * - * /|\ - * / | \ - * / | \ - * / # | # \ - * / # | # \ - * / # | # # \ - * / # # * # # \ - * / # / \ # \ - * / # / \ # \ - * / / \ \ - * / / \ \ - * / / \ \ - * // \\ - * vid0 *---------------------------* vid1 - * eid_collapse - * - * - * - In summary, there are three features we should be interested in: - -- hollow edge wedges that will be collapsed - -- filled edge wedges that will be collapsed - -- triangle wedges that will be collapsed - - We can identify all edge wedges (hollow or filled) via: - JOIN FILTER(EDGES(A,X), X!=B) WITH - FILTER(EDGES(B,Y), Y!=A) - WHERE X=Y - We can identify all triangle wedges via: - JOIN FILTER(TRIANGLES(A,X,Y), X!=B && Y!=B) WITH - FILTER(TRIANGLES(B,Z,W), Z!=A && W!=A) - WHERE (X,Y)=(Z,W) or (X,Y)=(W,Z) - */ - - /* Identify all the following components - * and separate them according to type: - * - e_collapse: the collapsing edge - * - tris_collapse: the collapsing triangles - * - v0, v1: the merging vertices - * - edge_wedges: the merging edges - * - tri_wedges: the merging (or disappearing) triangles - * - edges_moving: the persisting, but moving edges - * - tris_moving: the persisting, but moving triangles - */ - ShortVec tris_collapse = e_collapse->tris; - - Vptr v0 = e_collapse->verts[0]; - Vptr v1 = e_collapse->verts[1]; - - ShortVec edge_wedges; - ShortVec edges_moving; - - ShortVec tri_wedges; - ShortVec tris_moving; - - // BUILD all the edge wedges - std::map edge_w_map; - for(Eptr e : v0->edges) { - if(e == e_collapse) continue; - Vptr ev0 = e->verts[0]; - Vptr ev1 = e->verts[1]; - Vptr key = (ev0 != v0)? ev0 : ev1; - edge_w_map[key].e0 = e; - } - for(Eptr e : v1->edges) { - if(e == e_collapse) continue; - Vptr ev0 = e->verts[0]; - Vptr ev1 = e->verts[1]; - Vptr key = (ev0 != v1)? ev0 : ev1; - edge_w_map[key].e1 = e; - } - for(const auto &pair : edge_w_map) { - if(pair.second.full()) - edge_wedges.push_back(pair.second); - else - edges_moving.push_back(pair.second.one()); - } - - // BUILD all the triangle wedges - std::map tri_w_map; - for(Tptr t : v0->tris) { - if(t->edges[0] == e_collapse || - t->edges[1] == e_collapse || - t->edges[2] == e_collapse) continue; - - Eptr key = nullptr; - for(uint k=0; k<3; k++) - if(t->verts[k] == v0) - key = t->edges[k]; - ENSURE(key != NULL); - tri_w_map[key].t0 = t; - } - for(Tptr t : v1->tris) { - if(t->edges[0] == e_collapse || - t->edges[1] == e_collapse || - t->edges[2] == e_collapse) continue; - - Eptr key = nullptr; - for(uint k=0; k<3; k++) - if(t->verts[k] == v1) - key = t->edges[k]; - ENSURE(key != NULL); - tri_w_map[key].t1 = t; - } - for(const auto &pair : tri_w_map) { - if(pair.second.full()) - tri_wedges.push_back(pair.second); - else - tris_moving.push_back(pair.second.one()); - } - - /* Next, we need to create the new geometry which will supplant - * the just enumerated parts: - * - v_merged: the merged vertex - * - edges_merged: the merged edges (parallel to edge_wedges) - * - tris_merged: the merged triangles (parallel to tri_wedges) - * - edges_moved: the moved edges (parallel to edges_moving) - * - tris_moved: the moved triangles (parallel to tris_moving) - */ - /* As part of this, we will build a record of the remapping to - * aid us when we start to connect all of this geometry - */ - - Vptr v_merged = scratchpad.cache.newVert(); - ShortVec edges_merged(edge_wedges.size()); - ShortVec edges_moved(edges_moving.size()); - ShortVec tris_merged(tri_wedges.size()); - ShortVec tris_moved(tris_moving.size()); - - VptrRemap vptr_remap(v0, v1, v_merged); - PtrRemap eptr_remap; - PtrRemap tptr_remap; - - // Create new edges and enter re-mappings - eptr_remap.set(e_collapse, nullptr); // mark this edge as dying - for(uint i=0; iverts[k] = vptr_remap[t0->verts[k]]; - t_new->edges[k] = eptr_remap[t0->edges[k]]; - } - populateTriFromTopoTri(t_new); - } - } - for(uint i=0; iverts[k] = vptr_remap[t_old->verts[k]]; - t_new->edges[k] = eptr_remap[t_old->edges[k]]; - } - populateTriFromTopoTri(t_new); - } - - // Next, the edges - for(uint i=0; itris) { - t = tptr_remap[t]; - if(t) e_new->tris.push_back(t); - } - for(Tptr t : e1->tris) { - t = tptr_remap[t]; - if(t) e_new->tris.push_back(t); - } - - if(e_new->tris.size() == 0) { // if there are no parent triangles left - // then we need to kill this edge - eptr_remap.set(e0, nullptr); - eptr_remap.set(e1, nullptr); - deallocateRemeshEdge(scratchpad, e_new); - edges_merged[i] = nullptr; - } - else { // otherwise, let's go ahead and finish hooking up this edge - for(uint k=0; k<2; k++) - e_new->verts[k] = vptr_remap[e0->verts[k]]; - } - } - for(uint i=0; itris) { - t = tptr_remap[t]; - ENSURE(t); - e_new->tris.push_back(t); - } - for(uint k=0; k<2; k++) - e_new->verts[k] = vptr_remap[e_old->verts[k]]; - } - - // Finally, the vertex - { - // Should do this directly, not via the remap translation. - // Working via re-maps will lead to duplicates of merged geometry. - // However, we can exploit the fact that this vertex is unique, - // and that we already have lists of all the incident geometry - - for(Tptr t : tris_merged) - if(t) v_merged->tris.push_back(t); - for(Tptr t : tris_moved) // cannot be dead - v_merged->tris.push_back(t); - if(v_merged->tris.size() == 0) { - scratchpad.cache.freeVert(v_merged); - v_merged = nullptr; - } else { - for(Eptr e : edges_merged) - if(e) v_merged->edges.push_back(e); - for(Eptr e : edges_moved) // cannot be dead - v_merged->edges.push_back(e); - // it's impossible to have triangles incident w/o edges too. - ENSURE(v_merged->edges.size() > 0); - } - } - - - // OK, here we get to finally compute data for all the new geometry - // Once we've done that, we can also check to see whether we actually - // want to commit this operation or not. - - // merge vertices' data - if(v_merged) { // REMEMBER: vertex could be deleted by now - VertData &data_new = verts[v_merged->ref]; - const VertData &data0 = verts[v0->ref]; - const VertData &data1 = verts[v1->ref]; - data_new.merge(data0, data1); - } - // merge triangles' data - for(uint i=0; iref, t0->ref, t1->ref); - } - // update moved triangles' data - for(uint i=0; iref]; - - Tptr t_old = tris_moving[i]; - Tri &tri_old = tris[t_old->ref]; - - move_tri(tri_new, tri_old); - } - - // TODO: COMMIT OPTION will be left as a stub for now! - if(false) { - // DESTROY THE GEOMETRY WE JUST CREATED - // AND RETURN - } - - // Find and Store all of the existing, unchanged edges - // that border this operation. We will need these references - // when we account for changes to edge operation priorities later - ShortVec borderEdges; - for(const TriWedge &e_wedge : tri_wedges) { - Tptr t0 = e_wedge.t0; - for(uint k=0; k<3; k++) { - if(t0->verts[k] == v0) { - borderEdges.push_back(t0->edges[k]); - break; - } - } - } - for(Tptr t : tris_moved) { - for(uint k=0; k<3; k++) { - if(t->verts[k] == v_merged) { - borderEdges.push_back(t->edges[k]); - break; - } - } - } - - /* Now that we've got the go ahead, let's hook in the new geometry to - * the existing geometry! - * We can do this in the following order: - * - take all the new edges, and add them to their existing endpoint's - * edge list. (all new edges must have exactly one such endpoint) - * - take all the new triangles, and add them to their two existing - * endpoints' and one existing edge's triangle lists. - */ - // first, consolidate arrays - ShortVec new_edges; - ShortVec new_tris; - { - for(Eptr e : edges_merged) - if(e) new_edges.push_back(e); - for(Eptr e : edges_moved) // cannot be deleted - new_edges.push_back(e); - for(Tptr t : tris_merged) - if(t) new_tris.push_back(t); - for(Tptr t : tris_moved) // cannot be deleted - new_tris.push_back(t); - } - // hook up edges to existing geometry - for(Eptr edge : new_edges) { - Vptr ev0 = edge->verts[0]; - Vptr ev1 = edge->verts[1]; - Vptr v_old = (ev0 != v_merged)? ev0 : ev1; - v_old->edges.push_back(edge); - } - // hook up triangles to existing geometry - for(Tptr tri : new_tris) { - for(uint k=0; k<3; k++) { - if(tri->verts[k] != v_merged) continue; - Eptr e = tri->edges[k]; - Vptr tv0 = e->verts[0]; - Vptr tv1 = e->verts[1]; - e->tris.push_back(tri); - tv0->tris.push_back(tri); - tv1->tris.push_back(tri); - break; - } - } - - /* Now, let's kill all the old geometry. We can use the checklist - * we built at the begining: - * - e_collapse: the collapsing edge - * - tris_collapse: the collapsing triangles - * - v0, v1: the merging vertices - * - edge_wedges: the merging edges - * - tri_wedges: the merging (or disappearing) triangles - * - edges_moving: the persisting, but moving edges - * - tris_moving: the persisting, but moving triangles - * - * We need to be careful to free this geometry in top down order; - * starting with the triangles and moving towards the vertices. - * If we furthermore guarantee that any singular edges or vertices - * created by a triangle deletion are also deleted, then we can - * focus all of our attention on just deleting triangles - */ - ShortVec dead_tris; - ShortVec dead_edges; - ShortVec dead_verts; - - // assemble the list of triangles to kill - for(Tptr t : tris_collapse) - dead_tris.push_back(t); - for(const auto &t_wedge : tri_wedges) { - dead_tris.push_back(t_wedge.t0); - dead_tris.push_back(t_wedge.t1); - } - for(Tptr t : tris_moving) - dead_tris.push_back(t); - - // process the list of triangles - for(Tptr tri : dead_tris) { - // Let's unhook this triangle from its faces first - for(uint k=0; k<3; k++) { - Vptr v = tri->verts[k]; - remove(v->tris, tri); - if(v->tris.size() == 0) - dead_verts.push_back(v); - - Eptr e = tri->edges[k]; - remove(e->tris, tri); - if(e->tris.size() == 0) - dead_edges.push_back(e); - } - // now that we're disconnected, go ahead and jettison the triangle - scratchpad.cache.freeTri(tri); - } - - // now, we can process the list of edges - for(Eptr edge : dead_edges) { - // Let's unhook this edge from its vertices - for(uint k=0; k<2; k++) { - Vptr v = edge->verts[k]; - remove(v->edges, edge); - // the triangle removal was enough to - // determine which vertices should die. - // re-adding them here would lead to duplicates - } - // and then jetisson the edge - deallocateRemeshEdge(scratchpad, edge); - // If this edge is in the border edge list, - // then we need to remove it right away! - maybe_erase(borderEdges, edge); - } - - // Finally, polish off by getting rid of any vertices that talked too much - for(Vptr vert : dead_verts) { - scratchpad.cache.freeVert(vert); - if(vert == v_merged) v_merged = nullptr; - } - - // We pause a moment here to update the manifoldness of any - // vertices for which it might have changed - // ONLY do if the merged vertex is still alive... - if(v_merged) { - verts[v_merged->ref].manifold = true; - for(Eptr e : v_merged->edges) { - if(e->tris.size() != 2) - verts[v_merged->ref].manifold = false; - - // process neighboring point - Vptr v = e->verts[0]; - if(v == v_merged) v = e->verts[1]; - verts[v->ref].manifold = true; - for(Eptr ee : v->edges) { - if(ee->tris.size() != 2) { - verts[v->ref].manifold = false; - break; - } - } - } - } - - // Before we're completely done, we will go through and - // adjust priorities for edges which might have been effected by this op. - // Only explicitly dequeue pre-existing edges we did not delete! - for(Eptr e : edges_merged) { if(e) { // might be deleted - scoreAndEnqueue(scratchpad.queue, e); - }} - for(Eptr e : edges_moved) { // def. not deleted - scoreAndEnqueue(scratchpad.queue, e); - } - for(Eptr e : borderEdges) { - // border edges could have been deleted... - dequeue(scratchpad.queue, e); - scoreAndEnqueue(scratchpad.queue, e); - } - - // that should more or less complete an edge collapse -} - - -/* - Strategy: - 1. Construct new geometry in parallel to old geometry w/o - tampering with old geometry in any way. - 2. Fill out data for new geometry - 3. Determine whether or not to commit or abort the operation - 4. Connect new geometry to old geometry simultaneously to old geometry. - 5. Delete the old geometry appropriately -*/ - - -template -void Mesh::edgeSplit( - RemeshScratchpad &scratchpad, - Eptr e_split -) { - /* - Clean-up picture please... - - * * vs_opp - * / \ - * / \ - * e0s / \ e1s - * / \ - * / ts_orig \ - * / \ - * v0 *---------------------------* v1 - * e_split - * _ - * | - * v - * - * * vs_opp - * / | \ - * / | \ - * e0s / | <----------- es_mid - * / | \ - * / | \ - * / t0s_new | t1s_new \ - * v0 *-------------*-------------* v1 - * e0_new v_new e1_new - * - - BEGIN - new vertex - -- invoke interpolation callback - FOR EACH TRIANGLE SUB-PROBLEM: - new next triangle (from split) - new prev triangle (from split) - -- invoke triangle split callback - delete triangle - FIXUP all of the Tri-Edges - */ - - /* Identify all the following components - * and separate them according to type: - * - e_split: the edge to be split - * - ts_orig: the triangles to be split - * - v0, v1: the two endpoint vertices of the edge - * (the following is helper data; do not delete these vertices) - * - vs_opp: the vertices opposite eid_split for each triangle - */ - - ShortVec ts_orig = e_split->tris; - - Vptr v0 = e_split->verts[0]; - Vptr v1 = e_split->verts[1]; - - ShortVec vs_opp(ts_orig.size()); - for(uint i=0; iedges[k] == e_split) { - vs_opp[i] = t_orig->verts[k]; - break; - } - } - } - - /* Next, we need to create the new geometry which will supplant - * the just enumerated parts: - * - v_new: the vertex introduced by the split - * - e0_new, - * e1_new: the two pieces of e_split - * - t0s_new, - * t1s_new: the two pieces of each triangle in tids_orig - * - es_mid: the new edges splitting each triangle - */ - Vptr v_new = scratchpad.cache.newVert(); - Eptr e0_new = allocateRemeshEdge(scratchpad); - Eptr e1_new = allocateRemeshEdge(scratchpad); - ShortVec t0s_new(ts_orig.size()); - ShortVec t1s_new(ts_orig.size()); - ShortVec es_mid(ts_orig.size()); - - for(uint i=0; iverts[k]; - Eptr e_orig = t_orig->edges[k]; - if(v_orig == v0) { - t0->verts[k] = v_orig; - t0->edges[k] = e_mid; - t1->verts[k] = v_new; - t1->edges[k] = e_orig; - } else if(v_orig == v1) { - t0->verts[k] = v_new; - t0->edges[k] = e_orig; - t1->verts[k] = v_orig; - t1->edges[k] = e_mid; - } else { - t0->verts[k] = v_orig; - t0->edges[k] = e0_new; - t1->verts[k] = v_orig; - t1->edges[k] = e1_new; - } - } - populateTriFromTopoTri(t0); - populateTriFromTopoTri(t1); - // set up the mid edge from the split - e_mid->verts[0] = v_new; - e_mid->verts[1] = vs_opp[i]; - e_mid->tris.resize(2); - e_mid->tris[0] = t0; - e_mid->tris[1] = t1; - } - // hook up e0_new and e1_new - e0_new->verts[0] = v0; - e0_new->verts[1] = v_new; - e1_new->verts[0] = v_new; - e1_new->verts[1] = v1; - for(uint i=0; itris.push_back(t0s_new[i]); - e1_new->tris.push_back(t1s_new[i]); - } - // hook up v_new - v_new->edges.push_back(e0_new); - v_new->edges.push_back(e1_new); - for(uint i=0; iedges.push_back(es_mid[i]); - v_new->tris.push_back(t0s_new[i]); - v_new->tris.push_back(t1s_new[i]); - } - - - // OK, here we get to finally compute data for all the new geometry - // Once we've done that, we can also check to see whether we actually - // want to commit this operation or not. - - // interpolate data onto the new vertex - { - VertData &data_new = verts[v_new->ref]; - const VertData &data0 = verts[v0->ref]; - const VertData &data1 = verts[v1->ref]; - data_new.interpolate(data0, data1); - data_new.manifold = (ts_orig.size() == 2); - } - - // split triangles' data - for(uint i=0; iref, t1->ref, t_orig->ref); - } - - // TODO: COMMIT OPTION will be left as a stub for now! - if(false) { - // DESTROY THE GEOMETRY WE JUST CREATED AND RETURN - } - - // record border edges for later priority updates - ShortVec borderEdges; - for(Tptr t : ts_orig) { // TODO: evacuate all of this to the end... - for(uint k=0; k<3; k++) { - if(t->edges[k] == e_split) continue; - borderEdges.push_back(t->edges[k]); - } - } - - /* Now that we've got the go ahead, let's hook in the new geometry to - * the existing geometry! - * We can do this in the following order: - * - take all the new edges, and add them to their existing endpoint's - * edge list. (all new edges must have exactly one such endpoint) - * - take all the new triangles, and add them to their two existing - * endpoints' and one existing edge's triangle lists. - */ - - // add new edges to v0 and v1 - v0->edges.push_back(e0_new); - v1->edges.push_back(e1_new); - - // now, let's tackle the other edges and triangles in tandem... - for(uint i=0; iedges.push_back(es_mid[i]); - v_opp->tris.push_back(t0s_new[i]); - v_opp->tris.push_back(t1s_new[i]); - // add resp. tris to v0 and v1 - v0->tris.push_back(t0s_new[i]); - v1->tris.push_back(t1s_new[i]); - // find the two non-split edges and add resp. tris - for(uint k=0; k<3; k++) { - if(t_orig->verts[k] == v0) { - Eptr e1 = t_orig->edges[k]; - e1->tris.push_back(t1s_new[i]); - } else if(t_orig->verts[k] == v1) { - Eptr e0 = t_orig->edges[k]; - e0->tris.push_back(t0s_new[i]); - } - } - } - - /* Now, let's kill all the old geometry. This consists of: - * - e_split: the edge to be split - * - ts_orig: the triangles to be split - * - * Luckily, in triangle splitting we know exactly which things - * must be deleted. A split cannot make any geometry newly singular. - */ - - // kill triangles - for(Tptr t : ts_orig) { - // First, unhook this triangle from its faces - for(uint k=0; k<3; k++) { - Vptr v = t->verts[k]; - remove(v->tris, t); - - Eptr e = t->edges[k]; - remove(e->tris, t); - } - // now that we're disconnected, jettison the triangle - scratchpad.cache.freeTri(t); - } - - // now, kill the edge that we split - remove(v0->edges, e_split); - remove(v1->edges, e_split); - deallocateRemeshEdge(scratchpad, e_split); - - - // recompute edge scores for all edges whose scores might be effected - // Don't need to dequeue newly created edges... - scoreAndEnqueue(scratchpad.queue, e0_new); - scoreAndEnqueue(scratchpad.queue, e1_new); - for(Eptr e : es_mid) { - scoreAndEnqueue(scratchpad.queue, e); - } - for(Eptr e : borderEdges) { - dequeue(scratchpad.queue, e); - scoreAndEnqueue(scratchpad.queue, e); - } -} - diff --git a/external/cork/src/mesh/mesh.topoCache.tpp b/external/cork/src/mesh/mesh.topoCache.tpp deleted file mode 100644 index 816048c4f..000000000 --- a/external/cork/src/mesh/mesh.topoCache.tpp +++ /dev/null @@ -1,535 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.topoCache.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "iterPool.h" - -/* - * Allows for topological algorithms to manipulate - * a more familiar pointer data structure based on a simplicial complex. - * This structure can be regenerated from the more basic - * vertex/triangle arrays using - * createTopoCache() - * Once manipulations have been satisfactorily performed, - * the underlying vertex/triangle arrays can be cleaned up for - * further use by topologically insensitive algorithms by - * commitTopoCache() - */ - -#define INVALID_ID uint(-1) - -struct TopoVert { - uint ref; // index to actual data - void* data; // algorithm specific handle - - ShortVec tris; // triangles this vertex is incident on - ShortVec edges; // edges this vertex is incident on -}; - -struct TopoEdge { - void* data; // algorithm specific handle - - Vptr verts[2]; // endpoint vertices - ShortVec tris; // incident triangles -}; - -struct TopoTri { - uint ref; // index to actual data - void* data; // algorithm specific handle - - Vptr verts[3]; // vertices of this triangle - Eptr edges[3]; // edges of this triangle - // opposite to the given vertex -}; - - -template -struct Mesh::TopoCache { - IterPool verts; - IterPool edges; - IterPool tris; - - Mesh *mesh; - TopoCache(Mesh *owner); - virtual ~TopoCache() {} - - // until commit() is called, the Mesh::verts and Mesh::tris - // arrays will still contain garbage entries - void commit(); - - bool isValid(); - void print(); - - // helpers to create bits and pieces - inline Vptr newVert(); - inline Eptr newEdge(); - inline Tptr newTri(); - - // helpers to release bits and pieces - inline void freeVert(Vptr); - inline void freeEdge(Eptr); - inline void freeTri(Tptr); - - // helper to delete geometry in a structured way - inline void deleteTri(Tptr); - - // helper to flip triangle orientation - inline void flipTri(Tptr); - -private: - void init(); -}; - - -template inline -Vptr Mesh::TopoCache::newVert() -{ - uint ref = mesh->verts.size(); - mesh->verts.push_back(VertData()); - Vptr v = verts.alloc(); // cache.verts - v->ref = ref; - return v; -} -template inline -Eptr Mesh::TopoCache::newEdge() -{ - Eptr e = edges.alloc(); // cache.edges - return e; -} -template inline -Tptr Mesh::TopoCache::newTri() -{ - uint ref = mesh->tris.size(); - mesh->tris.push_back(Tri()); - Tptr t = tris.alloc(); // cache.tris - t->ref = ref; - return t; -} - -template inline -void Mesh::TopoCache::freeVert(Vptr v) -{ - verts.free(v); -} -template inline -void Mesh::TopoCache::freeEdge(Eptr e) -{ - edges.free(e); -} -template inline -void Mesh::TopoCache::freeTri(Tptr t) -{ - tris.free(t); -} - -template inline -void Mesh::TopoCache::deleteTri(Tptr tri) -{ - // first, unhook the triangle from its faces - for(uint k=0; k<3; k++) { - Vptr v = tri->verts[k]; - v->tris.erase(tri); - Eptr e = tri->edges[k]; - e->tris.erase(tri); - } - // now, let's check for any edges which no longer border triangles - for(uint k=0; k<3; k++) { - Eptr e = tri->edges[k]; - if(e->tris.size() == 0) { - // delete edge - // unhook from vertices - Vptr v0 = e->verts[0]; - v0->edges.erase(e); - Vptr v1 = e->verts[1]; - v1->edges.erase(e); - freeEdge(e); - } - } - // now, let's check for any vertices which no longer border triangles - for(uint k=0; k<3; k++) { - Vptr v = tri->verts[k]; - if(v->tris.size() == 0) { - freeVert(v); - } - } - // finally, release the triangle - freeTri(tri); -} - -template inline -void Mesh::TopoCache::flipTri(Tptr t) -{ - std::swap(t->verts[0], t->verts[1]); - std::swap(t->edges[0], t->edges[1]); - std::swap(mesh->tris[t->ref].v[0], mesh->tris[t->ref].v[1]); -} - - - -template -Mesh::TopoCache::TopoCache( - Mesh *owner -) : mesh(owner) { - init(); -} - - - -// support structure for cache construction -struct TopoEdgePrototype { - uint vid; - ShortVec tris; - TopoEdgePrototype() {} - TopoEdgePrototype(uint v) : vid(v) {} -}; -inline TopoEdgePrototype& getTopoEdgePrototype( - uint a, uint b, - std::vector< ShortVec > &prototypes -) { - uint N = prototypes[a].size(); - for(uint i=0; i -void Mesh::TopoCache::init() -{ - // first lay out vertices - std::vector temp_verts(mesh->verts.size()); // need temp. reference - for(uint i=0; iverts.size(); i++) { - Vptr vert = verts.alloc(); // cache.verts.alloc() - vert->ref = i; - temp_verts[i] = vert; - } - - // We need to still do the following - // * Generate TopoTris - // * Generate TopoEdges - // ---- Hook up references between - // * Triangles and Vertices - // * Triangles and Edges - // * Vertices and Edges - - // We handle two of these items in a pass over the triangles, - // * Generate TopoTris - // * Hook up Triangles and Vertices - // building a structure to handle the edges as we go: - std::vector< ShortVec > edgeacc(mesh->verts.size()); - for(uint i=0; itris.size(); i++) { - Tptr tri = tris.alloc(); // cache.tris.alloc() - tri->ref = i; - const Tri &ref_tri = mesh->tris[i]; - - // triangles <--> verts - uint vids[3]; - for(uint k=0; k<3; k++) { - uint vid = vids[k] = ref_tri.v[k]; - tri->verts[k] = temp_verts[vid]; - temp_verts[vid]->tris.push_back(tri); - } - // then, put these in arbitrary but globally consistent order - if(vids[0] > vids[1]) std::swap(vids[0], vids[1]); - if(vids[1] > vids[2]) std::swap(vids[1], vids[2]); - if(vids[0] > vids[1]) std::swap(vids[0], vids[1]); - // and accrue in structure - getTopoEdgePrototype(vids[0], vids[1], edgeacc).tris.push_back(tri); - getTopoEdgePrototype(vids[0], vids[2], edgeacc).tris.push_back(tri); - getTopoEdgePrototype(vids[1], vids[2], edgeacc).tris.push_back(tri); - } - - // Now, we can unpack the edge accumulation to - // * Generate TopoEdges - // * Hook up Triangles and Edges - // * Hook up Vertices and Edges - for(uint vid0=0; vid0 < edgeacc.size(); vid0++) { - for(TopoEdgePrototype &proto : edgeacc[vid0]) { - uint vid1 = proto.vid; - Vptr v0 = temp_verts[vid0]; - Vptr v1 = temp_verts[vid1]; - - Eptr edge = edges.alloc(); // cache.edges.alloc() - // edges <--> verts - edge->verts[0] = v0; - v0->edges.push_back(edge); - edge->verts[1] = v1; - v1->edges.push_back(edge); - // edges <--> tris - for(Tptr tri : proto.tris) { - edge->tris.push_back(tri); - for(uint k=0; k<3; k++) { - if(v0 != tri->verts[k] && v1 != tri->verts[k]) { - tri->edges[k] = edge; - break; - } - } - } - }} - - //ENSURE(isValid()); - //print(); -} - - - - -template -void Mesh::TopoCache::commit() -{ - //ENSURE(isValid()); - - // record which vertices are live - std::vector live_verts(mesh->verts.size(), false); - verts.for_each([&](Vptr vert) { // cache.verts - live_verts[vert->ref] = true; - }); - - // record which triangles are live, and record connectivity - std::vector live_tris(mesh->tris.size(), false); - tris.for_each([&](Tptr tri) { // cache.tris - live_tris[tri->ref] = true; - for(uint k=0; k<3; k++) - mesh->tris[tri->ref].v[k] = tri->verts[k]->ref; - }); - - // compact the vertices and build a remapping function - std::vector vmap(mesh->verts.size()); - uint write = 0; - for(uint read = 0; read < mesh->verts.size(); read++) { - if(live_verts[read]) { - vmap[read] = write; - mesh->verts[write] = mesh->verts[read]; - write++; - } else { - vmap[read] = INVALID_ID; - } - } - mesh->verts.resize(write); - - // rewrite the vertex reference ids - verts.for_each([&](Vptr vert) { // cache.verts - vert->ref = vmap[vert->ref]; - }); - - std::vector tmap(mesh->tris.size()); - write = 0; - for(uint read = 0; read < mesh->tris.size(); read++) { - if(live_tris[read]) { - tmap[read] = write; - mesh->tris[write] = mesh->tris[read]; - for(uint k=0; k<3; k++) - mesh->tris[write].v[k] = vmap[mesh->tris[write].v[k]]; - write++; - } else { - tmap[read] = INVALID_ID; - } - } - mesh->tris.resize(write); - - // rewrite the triangle reference ids - tris.for_each([&](Tptr tri) { // cache.tris - tri->ref = tmap[tri->ref]; - }); -} - - - -// support functions for validity check -template inline -bool count(const Container &contain, const T &val) { - uint c=0; - for(const T &t : contain) - if(t == val) c++; - return c; -} -template inline -bool count2(const T arr[], const T &val) { - return ((arr[0] == val)? 1 : 0) + ((arr[1] == val)? 1 : 0); -} -template inline -bool count3(const T arr[], const T &val) { - return ((arr[0] == val)? 1 : 0) + ((arr[1] == val)? 1 : 0) - + ((arr[2] == val)? 1 : 0); -} - -template -bool Mesh::TopoCache::isValid() -{ - //print(); - std::set vaddr; - std::set eaddr; - std::set taddr; - verts.for_each([&vaddr](Vptr v) { vaddr.insert(v); }); - edges.for_each([&eaddr](Eptr e) { eaddr.insert(e); }); - tris.for_each( [&taddr](Tptr t) { taddr.insert(t); }); - - // check verts - verts.for_each([&](Vptr v) { - ENSURE(v->ref < mesh->verts.size()); - // make sure each edge pointer goes somewhere and that - // the pointed-to site also points back correctly - for(Eptr e : v->edges) { - ENSURE(eaddr.count(e) > 0); // pointer is good - ENSURE(count2(e->verts, v) == 1); // back-pointer is good - } - for(Tptr t : v->tris) { - ENSURE(taddr.count(t) > 0); - ENSURE(count3(t->verts, v) == 1); - } - }); - - // check edges - edges.for_each([&](Eptr e) { - // check for non-degeneracy - ENSURE(e->verts[0] != e->verts[1]); - for(uint k=0; k<2; k++) { - Vptr v = e->verts[k]; - ENSURE(vaddr.count(v) > 0); - ENSURE(count(v->edges, e) == 1); - } - for(Tptr t : e->tris) { - ENSURE(taddr.count(t) > 0); - ENSURE(count3(t->edges, e) == 1); - } - }); - - // check triangles - tris.for_each([&](Tptr t) { - // check for non-degeneracy - ENSURE(t->verts[0] != t->verts[1] && t->verts[1] != t->verts[2] - && t->verts[0] != t->verts[2]); - for(uint k=0; k<3; k++) { - Vptr v = t->verts[k]; - ENSURE(vaddr.count(v) > 0); - ENSURE(count(v->tris, t) == 1); - - Eptr e = t->edges[k]; - ENSURE(eaddr.count(e) == 1); - ENSURE(count(e->tris, t) == 1); - - // also need to ensure that the edges are opposite the - // vertices as expected - Vptr v0 = e->verts[0]; - Vptr v1 = e->verts[1]; - ENSURE((v0 == t->verts[(k+1)%3] && v1 == t->verts[(k+2)%3]) - || (v0 == t->verts[(k+2)%3] && v1 == t->verts[(k+1)%3])); - } - }); - - return true; -} - - - - - - - -std::ostream& operator<<(std::ostream &out, const TopoVert& vert) -{ - out << "ref(" << vert.ref << ") " - << "e(" << vert.edges.size() << "):"; - for(Eptr e : vert.edges) - out << e << ";"; - out << " " - << "t(" << vert.tris.size() << "):"; - for(Tptr t : vert.tris) - out << t << ";"; - return out; -} - -std::ostream& operator<<(std::ostream &out, const TopoEdge& edge) -{ - out << "v(2):" << edge.verts[0] << "(" << edge.verts[0]->ref << ");" - << edge.verts[1] << "(" << edge.verts[1]->ref << ");"; - out << " " - << "t(" << edge.tris.size() << "):"; - for(Tptr t : edge.tris) - out << t << ";"; - return out; -} - -std::ostream& operator<<(std::ostream &out, const TopoTri& tri) -{ - out << "ref(" << tri.ref << ") "; - out << "v(3):" << tri.verts[0] << "(" << tri.verts[0]->ref << ");" - << tri.verts[1] << "(" << tri.verts[1]->ref << ");" - << tri.verts[2] << "(" << tri.verts[2]->ref << ");"; - out << " "; - out << "e(3):" << tri.edges[0] << ";" - << tri.edges[1] << ";" - << tri.edges[2] << ";"; - return out; -} - - -template -void Mesh::TopoCache::print() -{ - using std::cout; - using std::endl; - - cout << "dumping remeshing cache for debug..." << endl; - cout << "TRIS" << endl; - int tri_count = 0; - tris.for_each([&](Tptr t) { - cout << " " << t << ": " << *t << endl; - tri_count++; - }); - cout << "There were " << tri_count << " TRIS" << endl; - cout << "EDGES" << endl; - int edge_count = 0; - edges.for_each([&](Eptr e) { - cout << " " << e << ": " << endl; - cout << " v " << e->verts[0] << "; " - << e->verts[1] << endl; - cout << " t (" << e->tris.size() << ")" << endl; - for(Tptr t : e->tris) - cout << " " << t << endl; - edge_count++; - }); - cout << "There were " << edge_count << " EDGES" << endl; - cout << "VERTS" << endl; - int vert_count = 0; - verts.for_each([&](Vptr v) { - cout << " " << v << ": ref(" << v->ref << ")" << endl; - cout << " e (" << v->edges.size() << ")" << endl; - for(Eptr e : v->edges) - cout << " " << e << endl; - cout << " t (" << v->tris.size() << ")" << endl; - for(Tptr t : v->tris) - cout << " " << t << endl; - vert_count++; - }); - cout << "There were " << vert_count << " VERTS" << endl; -} - - - - diff --git a/external/cork/src/mesh/mesh.tpp b/external/cork/src/mesh/mesh.tpp deleted file mode 100644 index 9da1614de..000000000 --- a/external/cork/src/mesh/mesh.tpp +++ /dev/null @@ -1,303 +0,0 @@ -// +------------------------------------------------------------------------- -// | mesh.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include -#include "unsafeRayTriIsct.h" -#include -#include -#include - -#include "unionFind.h" - -// constructors -template -Mesh::Mesh() {} -template -Mesh::Mesh(Mesh &&cp) - : tris(cp.tris), verts(cp.verts) -{} -template -Mesh::Mesh(const RawMesh &raw) : - tris(raw.triangles.size()), verts(raw.vertices) -{ - // fill out the triangles - for(uint i=0; i -Mesh::~Mesh() {} - -template -void Mesh::operator=(Mesh &&src) -{ - tris = src.tris; - verts = src.verts; -} - -template -bool Mesh::valid() const -{ - for(uint i=0; i= verts.size() || - tris[i].b >= verts.size() || - tris[i].c >= verts.size()) { - std::ostringstream message; - message << "triangle #" << i << " should have indices in " - << "the range 0 to " << (verts.size()-1) - << ", but it has invalid indices: " - << tris[i].a << ", " << tris[i].b << ", " << tris[i].c; - CORK_ERROR(message.str()); - return false; - } - } - - return true; -} - -template -RawMesh Mesh::raw() const -{ - RawMesh result; - result.vertices = verts; - result.triangles.resize(tris.size()); - for(uint i=0; i -void Mesh::disjointUnion(const Mesh &cp) -{ - uint oldVsize = verts.size(); - uint oldTsize = tris.size(); - uint cpVsize = cp.verts.size(); - uint cpTsize = cp.tris.size(); - uint newVsize = oldVsize + cpVsize; - uint newTsize = oldTsize + cpTsize; - - std::vector v_remap(cpVsize); // oh this is obvious... - verts.resize(newVsize); - tris.resize(newTsize); - - for(uint i=0; i -typename Mesh::Isct - Mesh::pick(Ray3d ray) -{ - Isct result; - result.ray = ray; - result.exists = false; - - double mint = DBL_MAX; - - // pass all triangles over ray - for(uint i=0; i b) { std::swap(a, b); std::swap(va, vb); } - if(b > c) { std::swap(b, c); std::swap(vb, vc); } - if(a > b) { std::swap(a, b); std::swap(va, vb); } - - double t; - Vec3d bary; - if(isct_ray_triangle(ray, va, vb, vc, &t, &bary)) { - if(t > 0 && t < mint) { - result.exists = true; - mint = t; - result.tri_id = i; - result.isct = ray.p + t * ray.r; - result.bary = bary; - } - } - } - - return result; -} - - - - -template -bool Mesh::isClosed() -{ - EGraphCache chains = createEGraphCache(); - chains.for_each([&](uint i, uint j, EGraphEntry &entry) { - entry.data = 0; - }); - // count up how many times each edge is encountered in one - // orientation vs. the other - for(Tri &tri : tris) { - chains(tri.a, tri.b).data ++; - chains(tri.b, tri.a).data --; - - chains(tri.b, tri.c).data ++; - chains(tri.c, tri.b).data --; - - chains(tri.c, tri.a).data ++; - chains(tri.a, tri.c).data --; - } - // now go through and see if any of these are non-zero - bool closed = true; - chains.for_each([&](uint i, uint j, EGraphEntry &entry) { - if(entry.data != 0) - closed = false; - }); - return closed; -} - - - - -static inline -bool contains(const ShortVec &list, uint item) -{ - for(uint k : list) - if(k == item) - return true; - return false; -} - -template -typename Mesh::NeighborCache - Mesh::createNeighborCache() -{ - NeighborCache result; - result.skeleton.resize(verts.size()); - - for(uint tid = 0; tid < tris.size(); tid++) { - const Tri &tri = tris[tid]; - - result(tri.a, tri.b).tids.push_back(tid); - result(tri.b, tri.a).tids.push_back(tid); - - result(tri.a, tri.c).tids.push_back(tid); - result(tri.c, tri.a).tids.push_back(tid); - - result(tri.b, tri.c).tids.push_back(tid); - result(tri.c, tri.b).tids.push_back(tid); - } - - return result; -} - -// This function signature is an amazing disaster... -#ifdef _WIN32 -template -template -typename Mesh::EGraphCache -#else -template -template -typename Mesh::template EGraphCache -#endif - Mesh::createEGraphCache() -{ - EGraphCache result; - result.skeleton.resize(verts.size()); - - for(uint tid = 0; tid < tris.size(); tid++) { - const Tri &tri = tris[tid]; - - result(tri.a, tri.b).tids.push_back(tid); - result(tri.b, tri.a).tids.push_back(tid); - - result(tri.a, tri.c).tids.push_back(tid); - result(tri.c, tri.a).tids.push_back(tid); - - result(tri.b, tri.c).tids.push_back(tid); - result(tri.c, tri.b).tids.push_back(tid); - } - - return result; -} - - -template -std::vector Mesh::getComponentIds() -{ - UnionFind uf(verts.size()); - for(const Tri &tri : tris) { - uf.unionIds(tri.a, tri.b); - uf.unionIds(tri.a, tri.c); - } - - return uf.dump(); -} - - - - - - - - - diff --git a/external/cork/src/off2obj.cpp b/external/cork/src/off2obj.cpp deleted file mode 100644 index 99a2dcf0f..000000000 --- a/external/cork/src/off2obj.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -#include -using std::cin; -using std::cout; -using std::endl; -#include -using std::string; -#include -using std::vector; - -int main(int argc, const char* argv[]) -{ - string input; - if(!(cin >> input) || input != "OFF") return 1; - - int numvertices; - int numfaces; - int numedges; - - if(!(cin >> numvertices >> numfaces >> numedges) || numedges > 0) - return 1; - - vector vertices(numvertices*3); - vector< vector > faces(numfaces); - - for(int i=0; i> coord; - cout << ' ' << coord; - } - cout << endl; - } - - for(int i=0; i> vcount) || vcount < 3) return 1; - - cout << "f "; - for(int v=0; v> index; - cout << ' ' << index+1; - } - cout << endl; - } - - return 0; -} - - diff --git a/external/cork/src/rawmesh/rawMesh.h b/external/cork/src/rawmesh/rawMesh.h deleted file mode 100644 index 78a70d539..000000000 --- a/external/cork/src/rawmesh/rawMesh.h +++ /dev/null @@ -1,67 +0,0 @@ -// +------------------------------------------------------------------------- -// | rawMesh.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include - -#include "vec.h" - -#include - -// vertex and triangle data must satisfy the following minimal specifications! -// These exact field names must be used! -struct MinimalVertexData -{ - Vec3d pos; // required for both RawMesh and Mesh -}; - -struct MinimalTriangleData -{ - // Vertex Ids: (only used in raw mesh form) - int a, b, c; -}; - -// Raw mesh presents an exposed interface to a mesh. -// This allows for easy input/output of data to and from the more powerful -// Mesh data structure, as well as supporting more basic mesh applications -template -struct RawMesh -{ - std::vector vertices; - std::vector triangles; -}; - -// allow for data to move between different kinds of raw meshes -template -inline RawMesh transduce( - const RawMesh &input, - std::function vertTransduce, - std::function triTransduce -); - - -#include "rawMesh.tpp" diff --git a/external/cork/src/rawmesh/rawMesh.tpp b/external/cork/src/rawmesh/rawMesh.tpp deleted file mode 100644 index f370e8a7e..000000000 --- a/external/cork/src/rawmesh/rawMesh.tpp +++ /dev/null @@ -1,50 +0,0 @@ -// +------------------------------------------------------------------------- -// | rawMesh.tpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - - -template -inline RawMesh transduce( - const RawMesh &input, - std::function vertTransduce, - std::function triTransduce -) { - RawMesh output; - - uint nVert = input.vertices.size(); - uint nTri = input.triangles.size(); - output.vertices.resize(nVert); - output.triangles.resize(nTri); - - for(uint i=0; i. -// +------------------------------------------------------------------------- -#pragma once - -#include "prelude.h" -// +------------------------------------------------------------------------- -// | WHAT IS THIS? -// | -// | An IterPool is -// | *) a memory pool -- new items can be requested, old items released -// | *) iterable -- all of the allocated items can be iterated over -// | It was built primarily to support dynamic connectivity structures -// | for triangle meshes, such as those used during re-meshing. -// | -// | These processes often require the frequent allocation and -// | deallocation of mesh elements and become easier to write when -// | elements do not move around in memory, since valid pointers can be -// | maintained. std::vector does not provide guaranteed static locations. -// | -// | Using a memory pool--threaded with a linked list--provides fast -// | allocation/deallocation and relatively speedy enumeration of all -// | currently allocated elements. While not as memory access friendly -// | as an array or std::vector, the cost of linked list enumeration -// | comes out in the wash compared to the pointer chasing performed -// | for each element. -// +------------------------------------------------------------------------- - -#include "memPool.h" -#include - -template -class IterPool -{ -private: - uint numAlloced; -public: - IterPool(int minInitBlocks=10) : - numAlloced(0), - block_list(nullptr), - pool(minInitBlocks) - {} - IterPool(IterPool &&src) - : numAlloced(src.numAlloced), - block_list(src.block_list), - pool(std::move(src.pool)) - { - src.block_list = nullptr; - } - ~IterPool() { - // run through and destruct all remaining elements - for_each([](T* obj) { - obj->~T(); - }); - } - - void clear() { - for_each([](T* obj) { - obj->~T(); - }); - numAlloced = 0; - block_list = nullptr; - pool.clear(); - } - - void operator=(IterPool &&src) - { - for_each([](T* obj) { - obj->~T(); - }); - block_list = src.block_list; - src.block_list = nullptr; - pool = std::move(src.pool); - } - - -private: - struct Block { - T datum; - Block *next; - Block *prev; - }; - Block *block_list; - -public: // allocation/deallocation support - T* alloc() { - Block *new_block = pool.alloc(); - if(block_list) block_list->prev = new_block; - new_block->next = block_list; - new_block->prev = NULL; - block_list = new_block; - - T* obj = (T*)new_block; - new (obj) T(); // invoke default constructor when allocating - - numAlloced++; - - return obj; - } - void free(T* item) { - if(item == NULL) return; - item->~T(); // invoke destructor before releasing - - numAlloced--; - - Block *ptr = (Block*)(item); - if(ptr->next) ptr->next->prev = ptr->prev; - if(ptr->prev) ptr->prev->next = ptr->next; - if(ptr == block_list) block_list = ptr->next; - pool.free(ptr); - } - -public: - inline void for_each(std::function func) const { - for(Block *block = block_list; - block != NULL; - block = block->next) { - func((T*)(block)); - } - } - inline bool contains(T* tptr) const { - for(Block *block = block_list; - block != NULL; - block = block->next) { - if(tptr == (T*)(block)) - return true; - } - return false; - } - inline uint size() const { - return numAlloced; - } -public: // iteration support - class iterator { - public: - iterator() : ptr(NULL) {} - iterator(Block *init) : ptr(init) {} - iterator(const iterator &cp) : ptr(cp.ptr) {} - - iterator& operator++() { // prefix version - ptr = ptr->next; - return *this; - } - iterator operator++(int) { - iterator it(ptr); - ptr = ptr->next; - return it; - } // postfix version - T& operator*() { - return ptr->datum; - } - T* operator->() { - return (T*)(ptr); - } - bool operator==(const iterator &rhs) { - return ptr == rhs.ptr; - } - bool operator!=(const iterator &rhs) { - return ptr != rhs.ptr; - } - private: - Block *ptr; - }; - - iterator begin() { - return iterator(block_list); - } - iterator end() { - return iterator(NULL); - } - -private: - MemPool pool; -}; - - - diff --git a/external/cork/src/util/log.cpp b/external/cork/src/util/log.cpp deleted file mode 100644 index 3c9c0bfdb..000000000 --- a/external/cork/src/util/log.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// +------------------------------------------------------------------------- -// | log.cpp -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#include "prelude.h" - -#include -using std::atexit; - -#include -#include -using std::ofstream; -using std::endl; - -namespace { - -ofstream error_log_stream; - -void on_exit() -{ - error_log_stream << "Ending error logging at " << endl; - std::time_t time_var = std::time(NULL); - error_log_stream << std::ctime(&time_var) << endl; - error_log_stream.close(); -} - -} - -void logInit() -{ - error_log_stream.open("error_log.txt", std::ios_base::app | std::ios_base::out ); - error_log_stream << "Begining error logging at " << endl; - std::time_t time_var = std::time(NULL); - error_log_stream << std::ctime(&time_var);// << endl; - - atexit(on_exit); -} - -// exposes the error log for writing -std::ostream& err() -{ - static bool first = true; - if(first) { - logInit(); - first = false; - } - return error_log_stream; -} - - diff --git a/external/cork/src/util/memPool.h b/external/cork/src/util/memPool.h deleted file mode 100644 index bb22ccbdb..000000000 --- a/external/cork/src/util/memPool.h +++ /dev/null @@ -1,209 +0,0 @@ -// +------------------------------------------------------------------------- -// | memPool.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include -#include - -/* - * RESPONSIBILITIES OF THE USER / CLIENT CODE - * - * MemPool will not invoke constructors or destructors - * on memory that it allocates or frees. There is a simple - * reason for this: One advantage of MemPool is that a large number - * of allocated entries can be disposed of very quickly by simply - * destroying the pool. However, if MemPool were to call constructors - * (and thus be obligated to call destructors), then it would have - * to run through and destruct each element individually when it, itself - * is destroyed. - * - * TAKE-AWAY: Make sure to construct/destruct objects explicity - * when they are allocated with a raw MemPool. - * - */ - -// a pool of Ts -template -class MemPool -{ -public: // constructor/destructor - MemPool(int minInitBlocks=10); - MemPool(MemPool &&src); - ~MemPool(); - - void clear(); - - void operator=(MemPool &&); -private: // seal off copying behavior from clients - MemPool(const MemPool &) {} - MemPool& operator=(const MemPool &) { return *this; } - -public: // main use functions - T* alloc(); - void free(T*); - -private: // internal data structures - union Block { - byte datum[sizeof(T)]; // enough space for a T - Block *next; - }; - struct Chunk { - Block *data; // array of size nBlocks - int nBlocks; - Chunk *next; - }; -private: // internal data instances - Chunk *chunk_list; - Block *free_list; -private: // helper functions - void addChunk(); // this should be called only when the free list is empty -}; - -template -MemPool::MemPool(int minInitBlocks) -{ - // decide on the size of the first chunk - const int MIN_BLOCKS = 2; // will not create a pool with fewer - // than 2 blocks - int nBlocks = std::max(minInitBlocks, MIN_BLOCKS); - - // allocate the first chunk - chunk_list = (Chunk*)(new byte[sizeof(Chunk)]); - chunk_list->next = NULL; - chunk_list->nBlocks = nBlocks; - chunk_list->data = (Block*)(new byte[sizeof(Block)*nBlocks]); - - // setup the free list - free_list = chunk_list->data; - Block* last_block = chunk_list->data + nBlocks - 1; - for(Block *it = free_list; it != last_block; it++) - it->next = it+1; - last_block->next = NULL; -} - -template -MemPool::MemPool(MemPool &&src) - : chunk_list(src.chunk_list), free_list(src.free_list) -{ - src.chunk_list = nullptr; - src.free_list = nullptr; -} - -template -void MemPool::operator=(MemPool &&src) -{ - chunk_list = src.chunk_list; - free_list = src.free_list; - src.chunk_list = nullptr; - src.free_list = nullptr; -} - -template -MemPool::~MemPool() -{ - // We can ignore the free list here and just go through - // destroying all of the chunks - while(chunk_list != NULL) { - delete[] (byte*)(chunk_list->data); - Chunk *next = chunk_list->next; - delete[] (byte*)(chunk_list); - chunk_list = next; - } -} - -template -void MemPool::clear() -{ - // reset the free list - free_list = nullptr; - for(Chunk *chunk = chunk_list; chunk != nullptr; chunk = chunk->next) { - // thread the blocks in this chunk - Block *last_block = chunk->data + chunk->nBlocks - 1; - for(Block *it = chunk->data; it != last_block; it++) - it->next = it+1; - // then push them onto the front of the free list - last_block->next = free_list; - free_list = chunk->data; - } -} - -template inline -T* MemPool::alloc() -{ - // if we're out of blocks, add a new chunk - if(free_list == NULL) - addChunk(); - - // pop a block off the free_list - T* ret = reinterpret_cast(free_list); - free_list = free_list->next; - - // invoke constructor on allocated block - //new (ret) T(); // SEE INSTRUCTIONS AT TOP - - return ret; -} - -template inline -void MemPool::free(T* datum) -{ - if(datum == NULL) return; // silent fail for freeing NULLed pointers - // invoke destructor - //datum->~T(); // SEE INSTRUCTIONS AT TOP - - Block *block = reinterpret_cast(datum); - - // push this block onto the front of the free_list - // so it can be re-allocated in the future - block->next = free_list; - free_list = block; -} - -template -void MemPool::addChunk() -{ - Chunk *new_chunk = (Chunk*)(new byte[sizeof(Chunk)]); - new_chunk->next = chunk_list; - // we always double the size of each new chunk. This ensures that - // the total # of times that we have to add chunks is logarithmic. - // Regardless, the amortized cost of chunk allocation is constant. - new_chunk->nBlocks = chunk_list->nBlocks * 2; - new_chunk->data = (Block*)(new byte[sizeof(Block) * - (new_chunk->nBlocks)]); - chunk_list = new_chunk; - - // now we need to lace the blocks of the fresh chunk up into the free_list - Block *last_block = new_chunk->data + new_chunk->nBlocks - 1; - last_block->next = free_list; - free_list = new_chunk->data; - for(Block *it = new_chunk->data; it != last_block; it++) - it->next = it+1; -} - - - - - diff --git a/external/cork/src/util/prelude.h b/external/cork/src/util/prelude.h deleted file mode 100644 index 00329aadc..000000000 --- a/external/cork/src/util/prelude.h +++ /dev/null @@ -1,164 +0,0 @@ -// +------------------------------------------------------------------------- -// | prelude.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include -#include -#include -#include -#include - -#ifndef uint -typedef unsigned int uint; -#endif - -#ifndef byte -typedef unsigned char byte; -#endif - -// *********** -// * Logging - -// error log -- silent; will not stop program -std::ostream &err(); - -#ifndef ENSURE -#define ENSURE(STATEMENT) { \ - if(!(STATEMENT)) { \ - std::cerr << "ENSURE FAILED at " \ - << __FILE__ << ", line #" << __LINE__ << ":\n" \ - << " " << #STATEMENT << std::endl; \ - err() << "ENSURE FAILED at " \ - << __FILE__ << ", line #" << __LINE__ << ":\n" \ - << " " << #STATEMENT << std::endl; \ - exit(1); \ - } \ -} -#endif // ENSURE - -// Use ERROR to print an error message tagged with the given file/line # -#ifndef CORK_ERROR -#define CORK_ERROR(message) { \ - std::cerr << "error at " \ - << __FILE__ << ", line #" << __LINE__ << ": " \ - << (message) << std::endl; \ - err() << "error at " \ - << __FILE__ << ", line #" << __LINE__ << ": " \ - << (message) << std::endl; \ -} -#endif // CORK_ERROR - -// Use MARKER for debugging to create a trace of control flow... -#ifndef MARKER -#define MARKER(message) { \ - std::cout << "marker at " \ - << __FILE__ << ", line #" << __LINE__ << ": " \ - << (message) << std::endl; \ -} -#endif // MARKER - -// *********** -// * Assorted - -// snap the value a into the specified range -inline double clamp(double a, double mina, double maxa) { - return std::min(maxa, std::max(mina, a)); -} -inline float clamp(float a, float mina, float maxa) { - return std::min(maxa, std::max(mina, a)); -} - -// modulo the value a into the specified range -inline double wrap(double a, double mina, double maxa) { - double val = std::fmod(a - mina, maxa - mina); - if(val < 0.0) val += maxa-mina; - return val + mina; -} -inline float wrap(float a, float mina, float maxa) { - float val = std::fmod(a - mina, maxa - mina); - if(val < 0.0) val += maxa-mina; - return val + mina; -} - -inline double deg2rad(double deg) { - return (M_PI/180.0) * deg; -} -inline double rad2deg(double rad) { - return (180.0/M_PI) * rad; -} - -// ********** -// * Timing - -#ifdef _WIN32 -#include -#endif - -class Timer { -public: - Timer(); // automatically start timer on creation - ~Timer(); -public: - void start(); - // returns lap time in milliseconds - double lap(); - // returns total ellapsed time in milliseconds - double stop(); - // re-retrieve values - // if this operation is meaningless, you will receive 0.0 instead - double lastLap() const; - double ellapsed() const; -private: - timeval init; - timeval prev; - double last_lap_duration; - double ellapsed_time_duration; - bool isRunning; -}; - -// *********** -// * Random - -// need functions that allow for the random source -// to be made more deterministic for replays... - -inline void initRand() { - // currently none! Should seed using clock - srand(uint(time(0))); -} - -inline double drand(double min, double max) { - const double invMAX = 1.0/double(RAND_MAX); - double rand0to1 = double(std::rand())*invMAX; - return (max-min)*rand0to1 + min; -} - -inline uint randMod(uint range) { - return std::rand()%range; -} - - - diff --git a/external/cork/src/util/shortVec.h b/external/cork/src/util/shortVec.h deleted file mode 100644 index 169aabc60..000000000 --- a/external/cork/src/util/shortVec.h +++ /dev/null @@ -1,266 +0,0 @@ -// +------------------------------------------------------------------------- -// | shortVec.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "prelude.h" -#include "memPool.h" - -#include - -// Don't know why, but can't get this to compile -// when I make the datablock def. a member of ShortVec -template -struct ShortVecBlock_Private { - byte data[sizeof(T)*LEN]; -}; -// We allocate these blocks instead of typed arrays -// in order to ensure that we get control of allocation/deallocation -// rather than the allocator attempting to do so. - -template -class ShortVec -{ -public: // constructor/destructor - ShortVec(uint size = 0); - ShortVec(uint size, const T &fill_val); - ShortVec(const ShortVec &cp); - //ShortVec(ShortVec &&cp); // move constructor - ~ShortVec(); - - ShortVec& operator=(const ShortVec &vec); - -public: // index accessors - inline T& operator[](uint i) { return data[i]; } - inline const T& operator[](uint i) const { return data[i]; } - -public: // iterators - typedef T* iterator; - typedef const T* const_iterator; - iterator begin() { return data; } - const_iterator begin() const { return data; } - iterator end() { return data + user_size; } - const_iterator end() const { return data + user_size; } - -public: // inspectors - inline uint size() const { return user_size; } - -public: // modifiers - void resize(uint newsize); - void push_back(const T &datum); - void erase(const T &val); // erase if it can be found - -private: // helper functions - T* allocData(uint space, uint &allocated); - void deallocData(T* data_ptr, uint allocated); - - void constructRange(T* array, int begin, int end); - void copyConstructRange(T* src, T* dest, int begin, int end); - void destructRange(T* array, int begin, int end); - - // resize, manage allocation/deallocation, - // but not construction/destruction - void resizeHelper(uint newsize); - -public: // shared data structures and data. - static MemPool< ShortVecBlock_Private > pool; - -private: // instance data - uint user_size; // actual number of entries from client perspective - uint internal_size; // number of entries allocated, if greater than LEN; - // if allocated from the memory pool, this is 0 - T* data; -}; - -template -MemPool< ShortVecBlock_Private > ShortVec::pool; - -template inline -T* ShortVec::allocData(uint space, uint &allocated) -{ - T* result; - if(space <= LEN) { - allocated = LEN; - result = reinterpret_cast(pool.alloc()); - } else { - allocated = space; - result = reinterpret_cast(new byte[sizeof(T)*space]); - } - //if(LEN == 2) std::cout << " Allocing: " << result << std::endl; - return result; -} -template inline -void ShortVec::deallocData(T* data_ptr, uint allocated) -{ - //if(LEN == 2) std::cout << " Deallocing: " << data_ptr << std::endl; - if(allocated <= LEN) - pool.free(reinterpret_cast< ShortVecBlock_Private* >(data_ptr)); - else - delete[] reinterpret_cast(data_ptr); -} - -template inline -void ShortVec::constructRange(T* array, int begin, int end) -{ - for(int i=begin; i inline -void ShortVec::copyConstructRange(T* src, T* dest, int begin, int end) -{ - // copy actual data over - for(int i=begin; i inline -void ShortVec::destructRange(T* array, int begin, int end) -{ - for(int i=begin; i~T(); -} - -// we use a strictly increasing allocation size policy -// with array length doubling to ensure that the cost of -// copying array entries on a reallocation has -// constant amortized cost. This is important when the -// vector is used to accumulate a list of values. -template inline -void ShortVec::resizeHelper(uint newsize) { - if(newsize > internal_size) { // we need more space! - // setup the new data block with at least twice as much space - uint new_space; - T *new_data = allocData(std::max(newsize, internal_size*2), new_space); - // copy data and destroy old copies - copyConstructRange(data, new_data, 0, user_size); - destructRange(data, 0, user_size); - // free old data - deallocData(data, internal_size); - data = new_data; - internal_size = new_space; - } - user_size = newsize; -} - - - - -template inline -ShortVec::ShortVec(uint size) : user_size(size) -{ - data = allocData(user_size, internal_size); - constructRange(data, 0, user_size); -} -template inline -ShortVec::ShortVec(uint size, const T &fill_val) : user_size(size) -{ - data = allocData(user_size, internal_size); - // then fill - for(uint i=0; i inline -ShortVec::ShortVec(const ShortVec &cp) : user_size(cp.user_size) -{ - data = allocData(user_size, internal_size); - // copy actual data over - copyConstructRange(cp.data, data, 0, user_size); -} -/*template inline -ShortVec::ShortVec(ShortVec &&cp) -{ - user_size = cp.user_size; - internal_size = cp.internal_size; - data = cp.data; - cp.user_size = 0; // ensure that no destructors are called - cp.internal_size = 0; // ensure that pool free is called - cp.data = NULL; // on a null pointer, which will do nothing -}*/ -template inline -ShortVec::~ShortVec() -{ - destructRange(data, 0, user_size); - deallocData(data, internal_size); -} - -template inline -ShortVec& ShortVec::operator=(const ShortVec &vec) -{ - uint old_size = user_size; - - // ensure there is enough space allocated at the destination - resizeHelper(vec.user_size); - - // copy assignment for all data in range overlap - for(uint i=0; i old_size) { - copyConstructRange(vec.data, data, old_size, vec.user_size); - } - - // if the new range is smaller, destruct old unused entries - if(vec.user_size < old_size) - destructRange(data, vec.user_size, old_size); - - return *this; -} - -template inline -void ShortVec::resize(uint newsize) { - uint oldsize = user_size; - - resizeHelper(newsize); - - if(oldsize < newsize) - constructRange(data, oldsize, newsize); - - if(newsize < oldsize) - destructRange(data, newsize, oldsize); -} - -template inline -void ShortVec::push_back(const T &datum) -{ - uint i = user_size; - resizeHelper(user_size+1); // make room - new (&(data[i])) T(datum); -} - -template inline -void ShortVec::erase(const T &val) -{ - for(uint i=0; i. -// +------------------------------------------------------------------------- -#include "prelude.h" - -#ifdef _WIN32 -#include -#include -void gettimeofday(struct timeval* t,void* timezone) -{ struct _timeb timebuffer; - _ftime( &timebuffer ); - t->tv_sec=timebuffer.time; - t->tv_usec=1000*timebuffer.millitm; -} -#else -#include -#endif - - - - - -Timer::Timer() -{ - start(); -} -Timer::~Timer() -{ -} - -inline -double timeDiff(const timeval &t0, const timeval &t1) -{ - double ms = (t1.tv_sec - t0.tv_sec) * 1000.0 - + (t1.tv_usec - t0.tv_usec) / 1000.0; - return ms; -} - -void Timer::start() -{ - gettimeofday(&init, NULL); - prev = init; - last_lap_duration = ellapsed_time_duration = 0.0; - isRunning = true; -} -// returns lap time in milliseconds -double Timer::lap() -{ - if(!isRunning) - return 0.0; - - timeval now; - gettimeofday(&now, NULL); - - last_lap_duration = timeDiff(prev, now); - return last_lap_duration; -} -// returns total ellapsed time in milliseconds -double Timer::stop() -{ - if(!isRunning) - return 0.0; - - timeval now; - gettimeofday(&now, NULL); - - last_lap_duration = timeDiff(prev, now); - ellapsed_time_duration = timeDiff(init, now); - - isRunning = false; - return ellapsed_time_duration; -} -// re-retrieve values -double Timer::lastLap() const -{ - return last_lap_duration; -} -double Timer::ellapsed() const -{ - return ellapsed_time_duration; -} diff --git a/external/cork/src/util/unionFind.h b/external/cork/src/util/unionFind.h deleted file mode 100644 index 0687ffd8a..000000000 --- a/external/cork/src/util/unionFind.h +++ /dev/null @@ -1,71 +0,0 @@ -// +------------------------------------------------------------------------- -// | unionFind.h -// | -// | Author: Gilbert Bernstein -// +------------------------------------------------------------------------- -// | COPYRIGHT: -// | Copyright Gilbert Bernstein 2013 -// | See the included COPYRIGHT file for further details. -// | -// | This file is part of the Cork library. -// | -// | Cork is free software: you can redistribute it and/or modify -// | it under the terms of the GNU Lesser General Public License as -// | published by the Free Software Foundation, either version 3 of -// | the License, or (at your option) any later version. -// | -// | Cork is distributed in the hope that it will be useful, -// | but WITHOUT ANY WARRANTY; without even the implied warranty of -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// | GNU Lesser General Public License for more details. -// | -// | You should have received a copy -// | of the GNU Lesser General Public License -// | along with Cork. If not, see . -// +------------------------------------------------------------------------- -#pragma once - -#include "prelude.h" - -class UnionFind { -public: - UnionFind(uint N) : ids(N), rank(N, 0) { - for(uint i=0; i rank[jid]) { - return ids[jid] = iid; - } else if(rank[iid] < rank[jid]) { - return ids[iid] = jid; - } else { // equal ranks - rank[jid]++; - return ids[jid] = iid; - } - } - std::vector dump() { - std::vector result(ids.size()); - for(uint i=0; i ids; - std::vector rank; -}; diff --git a/external/cork/win/wincork/wincork.sln b/external/cork/win/wincork/wincork.sln deleted file mode 100644 index 46a4177a8..000000000 --- a/external/cork/win/wincork/wincork.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2012 for Windows Desktop -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wincork", "wincork.vcxproj", "{AD6B1A8B-6983-40ED-9EF2-A7FFC457517E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD6B1A8B-6983-40ED-9EF2-A7FFC457517E}.Debug|Win32.ActiveCfg = Debug|Win32 - {AD6B1A8B-6983-40ED-9EF2-A7FFC457517E}.Debug|Win32.Build.0 = Debug|Win32 - {AD6B1A8B-6983-40ED-9EF2-A7FFC457517E}.Release|Win32.ActiveCfg = Release|Win32 - {AD6B1A8B-6983-40ED-9EF2-A7FFC457517E}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/external/cork/win/wincork/wincork.vcxproj b/external/cork/win/wincork/wincork.vcxproj deleted file mode 100644 index 92a3fae48..000000000 --- a/external/cork/win/wincork/wincork.vcxproj +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {AD6B1A8B-6983-40ED-9EF2-A7FFC457517E} - wincork - - - - Application - true - v110 - MultiByte - - - Application - false - v110 - true - MultiByte - - - - - - - - - - - - - - - Level3 - Disabled - C:\Users\Gilbert\Documents\GitHub\cork\src;C:\Users\Gilbert\Documents\GitHub\cork\src\accel;C:\Users\Gilbert\Documents\GitHub\cork\src\file_formats;C:\Users\Gilbert\Documents\GitHub\cork\src\isct;C:\Users\Gilbert\Documents\GitHub\cork\src\math;C:\Users\Gilbert\Documents\GitHub\cork\src\mesh;C:\Users\Gilbert\Documents\GitHub\cork\src\rawmesh;C:\Users\Gilbert\Documents\GitHub\cork\src\util;%(AdditionalIncludeDirectories) - _USE_MATH_DEFINES;NOMINMAX;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - true - mpir.lib %(AdditionalOptions) - - - - - Level3 - MaxSpeed - true - true - C:\Users\Gilbert\Documents\GitHub\cork\src;C:\Users\Gilbert\Documents\GitHub\cork\src\accel;C:\Users\Gilbert\Documents\GitHub\cork\src\file_formats;C:\Users\Gilbert\Documents\GitHub\cork\src\isct;C:\Users\Gilbert\Documents\GitHub\cork\src\math;C:\Users\Gilbert\Documents\GitHub\cork\src\mesh;C:\Users\Gilbert\Documents\GitHub\cork\src\rawmesh;C:\Users\Gilbert\Documents\GitHub\cork\src\util;%(AdditionalIncludeDirectories) - _USE_MATH_DEFINES;NOMINMAX;%(PreprocessorDefinitions) - - - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NO_TIMER;REDUCED;CDT_ONLY;TRILIBRARY;ANSI_DECLARATORS;%(PreprocessorDefinitions) - NO_TIMER;REDUCED;CDT_ONLY;TRILIBRARY;ANSI_DECLARATORS;%(PreprocessorDefinitions) - - - - - - - - - \ No newline at end of file diff --git a/external/cork/win/wincork/wincork.vcxproj.filters b/external/cork/win/wincork/wincork.vcxproj.filters deleted file mode 100644 index 792818b5f..000000000 --- a/external/cork/win/wincork/wincork.vcxproj.filters +++ /dev/null @@ -1,170 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {9ae3a789-4b69-4209-b7a9-bd6f776a99db} - - - {dffee6af-cc73-4111-aea0-1e3c33e7d946} - - - {c9671371-9658-48e8-8e42-42c0529667b5} - - - {c4a6b75d-ab40-4390-976e-e7c11d100c68} - - - {23d6d0a6-6cef-4390-a8c6-227728f144fd} - - - {6dae34f2-75d2-4bc3-8697-d959520be5fb} - - - {53f3b672-20eb-4a96-b7af-0b93d0b58d33} - - - {a44d6a76-9c77-490c-a481-64fa326ba037} - - - {3bafd8b3-8406-4070-84a2-41a5f27cbde1} - - - {8ef4296c-8c21-47d0-9033-e0d7e3d67549} - - - - - Header Files\accel - - - Header Files\mesh - - - Header Files\mesh - - - Header Files\rawmesh - - - Header Files\math - - - Header Files\math - - - Header Files\math - - - Header Files\util - - - Header Files\util - - - Header Files\util - - - Header Files\util - - - Header Files\util - - - Header Files\file_formats - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files\isct - - - Header Files - - - - - Header Files\mesh - - - Header Files\mesh - - - Header Files\mesh - - - Header Files\mesh - - - Header Files\mesh - - - Header Files\rawmesh - - - - - Source Files\util - - - Source Files\util - - - Source Files\file_formats - - - Source Files\file_formats - - - Source Files\file_formats - - - Source Files\isct - - - Source Files\isct - - - Source Files\isct - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/include/igl/MeshBooleanType.h b/include/igl/MeshBooleanType.h new file mode 100644 index 000000000..2eb293624 --- /dev/null +++ b/include/igl/MeshBooleanType.h @@ -0,0 +1,23 @@ +// This file is part of libigl, a simple c++ geometry processing library. +// +// Copyright (C) 2015 Alec Jacobson +// +// This Source Code Form is subject to the terms of the Mozilla Public License +// v. 2.0. If a copy of the MPL was not distributed with this file, You can +// obtain one at http://mozilla.org/MPL/2.0/. +#ifndef IGL_MESH_BOOLEAN_TYPE_H +#define IGL_MESH_BOOLEAN_TYPE_H +namespace igl +{ + enum MeshBooleanType + { + MESH_BOOLEAN_TYPE_UNION = 0, + MESH_BOOLEAN_TYPE_INTERSECT = 1, + MESH_BOOLEAN_TYPE_MINUS = 2, + MESH_BOOLEAN_TYPE_XOR = 3, + MESH_BOOLEAN_TYPE_RESOLVE = 4, + NUM_MESH_BOOLEAN_TYPES = 5 + }; +}; + +#endif diff --git a/include/igl/copyleft/boolean/MeshBooleanType.h b/include/igl/copyleft/boolean/MeshBooleanType.h deleted file mode 100644 index 70828e996..000000000 --- a/include/igl/copyleft/boolean/MeshBooleanType.h +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of libigl, a simple c++ geometry processing library. -// -// Copyright (C) 2015 Alec Jacobson -// -// This Source Code Form is subject to the terms of the Mozilla Public License -// v. 2.0. If a copy of the MPL was not distributed with this file, You can -// obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_TYPE_H -#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_TYPE_H -namespace igl -{ - namespace copyleft - { - namespace boolean - { - enum MeshBooleanType - { - MESH_BOOLEAN_TYPE_UNION = 0, - MESH_BOOLEAN_TYPE_INTERSECT = 1, - MESH_BOOLEAN_TYPE_MINUS = 2, - MESH_BOOLEAN_TYPE_XOR = 3, - MESH_BOOLEAN_TYPE_RESOLVE = 4, - NUM_MESH_BOOLEAN_TYPES = 5 - }; - } - } -}; - -#endif diff --git a/include/igl/copyleft/boolean/BinaryWindingNumberOperations.h b/include/igl/copyleft/cgal/BinaryWindingNumberOperations.h similarity index 92% rename from include/igl/copyleft/boolean/BinaryWindingNumberOperations.h rename to include/igl/copyleft/cgal/BinaryWindingNumberOperations.h index cf7348313..87ea6f8e6 100644 --- a/include/igl/copyleft/boolean/BinaryWindingNumberOperations.h +++ b/include/igl/copyleft/cgal/BinaryWindingNumberOperations.h @@ -6,21 +6,21 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. // -#ifndef IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H -#define IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H +#ifndef IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H +#define IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H #include #include "../../igl_inline.h" -#include "MeshBooleanType.h" +#include "../../MeshBooleanType.h" #include namespace igl { namespace copyleft { - namespace boolean + namespace cgal { - template + template class BinaryWindingNumberOperations { public: template @@ -72,7 +72,7 @@ namespace igl }; template <> - class BinaryWindingNumberOperations { + class BinaryWindingNumberOperations { public: template typename DerivedW::Scalar operator()( diff --git a/include/igl/copyleft/boolean/CSGTree.h b/include/igl/copyleft/cgal/CSGTree.h similarity index 98% rename from include/igl/copyleft/boolean/CSGTree.h rename to include/igl/copyleft/cgal/CSGTree.h index 60fd84982..f6b328f26 100644 --- a/include/igl/copyleft/boolean/CSGTree.h +++ b/include/igl/copyleft/cgal/CSGTree.h @@ -5,11 +5,11 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_CSG_TREE_H -#define IGL_COPYLEFT_BOOLEAN_CSG_TREE_H +#ifndef IGL_COPYLEFT_CGAL_CSG_TREE_H +#define IGL_COPYLEFT_CGAL_CSG_TREE_H +#include "../../MeshBooleanType.h" #include "string_to_mesh_boolean_type.h" -#include "MeshBooleanType.h" #include "mesh_boolean.h" #include #include @@ -18,7 +18,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cgal { // Class for defining and computing a constructive solid geometry result // out of a tree of boolean operations on "solid" triangle meshes. diff --git a/include/igl/copyleft/boolean/mesh_boolean.cpp b/include/igl/copyleft/cgal/mesh_boolean.cpp similarity index 74% rename from include/igl/copyleft/boolean/mesh_boolean.cpp rename to include/igl/copyleft/cgal/mesh_boolean.cpp index 48fb2872d..719017f31 100644 --- a/include/igl/copyleft/boolean/mesh_boolean.cpp +++ b/include/igl/copyleft/cgal/mesh_boolean.cpp @@ -9,11 +9,11 @@ // #include "mesh_boolean.h" #include "BinaryWindingNumberOperations.h" -#include "../cgal/assign_scalar.h" -#include "../cgal/propagate_winding_numbers.h" -#include "../cgal/remesh_self_intersections.h" -#include "../cgal/relabel_small_immersed_cells.h" -#include "../cgal/extract_cells.h" +#include "assign_scalar.h" +#include "propagate_winding_numbers.h" +#include "remesh_self_intersections.h" +#include "relabel_small_immersed_cells.h" +#include "extract_cells.h" #include "../../extract_manifold_patches.h" #include "../../remove_unreferenced.h" #include "../../unique_simplices.h" @@ -40,7 +40,7 @@ template < typename DerivedVC, typename DerivedFC, typename DerivedJ> -IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( +IGL_INLINE bool igl::copyleft::cgal::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -265,7 +265,7 @@ template < typename DerivedVC, typename DerivedFC, typename DerivedJ> -IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( +IGL_INLINE bool igl::copyleft::cgal::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -279,26 +279,26 @@ IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( switch (type) { case MESH_BOOLEAN_TYPE_UNION: - return igl::copyleft::boolean::mesh_boolean( - VA, FA, VB, FB, igl::copyleft::boolean::BinaryUnion(), - igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); + return igl::copyleft::cgal::mesh_boolean( + VA, FA, VB, FB, igl::copyleft::cgal::BinaryUnion(), + igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J); case MESH_BOOLEAN_TYPE_INTERSECT: - return igl::copyleft::boolean::mesh_boolean( - VA, FA, VB, FB, igl::copyleft::boolean::BinaryIntersect(), - igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); + return igl::copyleft::cgal::mesh_boolean( + VA, FA, VB, FB, igl::copyleft::cgal::BinaryIntersect(), + igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J); case MESH_BOOLEAN_TYPE_MINUS: - return igl::copyleft::boolean::mesh_boolean( - VA, FA, VB, FB, igl::copyleft::boolean::BinaryMinus(), - igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); + return igl::copyleft::cgal::mesh_boolean( + VA, FA, VB, FB, igl::copyleft::cgal::BinaryMinus(), + igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J); case MESH_BOOLEAN_TYPE_XOR: - return igl::copyleft::boolean::mesh_boolean( - VA, FA, VB, FB, igl::copyleft::boolean::BinaryXor(), - igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J); + return igl::copyleft::cgal::mesh_boolean( + VA, FA, VB, FB, igl::copyleft::cgal::BinaryXor(), + igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J); case MESH_BOOLEAN_TYPE_RESOLVE: //op = binary_resolve(); - return igl::copyleft::boolean::mesh_boolean( - VA, FA, VB, FB, igl::copyleft::boolean::BinaryResolve(), - igl::copyleft::boolean::KeepAll(), resolve_func, VC, FC, J); + return igl::copyleft::cgal::mesh_boolean( + VA, FA, VB, FB, igl::copyleft::cgal::BinaryResolve(), + igl::copyleft::cgal::KeepAll(), resolve_func, VC, FC, J); default: assert(false && "Unsupported boolean type."); return false; @@ -313,7 +313,7 @@ template < typename DerivedVC, typename DerivedFC, typename DerivedJ> -IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( +IGL_INLINE bool igl::copyleft::cgal::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -371,7 +371,7 @@ template < typename DerivedFB, typename DerivedVC, typename DerivedFC> -IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( +IGL_INLINE bool igl::copyleft::cgal::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -381,14 +381,14 @@ IGL_INLINE bool igl::copyleft::boolean::mesh_boolean( Eigen::PlainObjectBase & FC) { Eigen::Matrix J; - return igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J); + return igl::copyleft::cgal::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template bool igl::copyleft::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template bool igl::copyleft::boolean::mesh_boolean, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template bool igl::copyleft::boolean::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template bool igl::copyleft::cgal::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template bool igl::copyleft::cgal::mesh_boolean, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template bool igl::copyleft::cgal::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #undef IGL_STATIC_LIBRARY #include "../../remove_unreferenced.cpp" template void igl::remove_unreferenced, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix, -1, 3, 0, -1, 3>, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); diff --git a/include/igl/copyleft/boolean/mesh_boolean.h b/include/igl/copyleft/cgal/mesh_boolean.h similarity index 98% rename from include/igl/copyleft/boolean/mesh_boolean.h rename to include/igl/copyleft/cgal/mesh_boolean.h index f56c06388..432474509 100644 --- a/include/igl/copyleft/boolean/mesh_boolean.h +++ b/include/igl/copyleft/cgal/mesh_boolean.h @@ -7,11 +7,11 @@ // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. // -#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H -#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H +#ifndef IGL_COPYLEFT_CGAL_MESH_BOOLEAN_H +#define IGL_COPYLEFT_CGAL_MESH_BOOLEAN_H #include "../../igl_inline.h" -#include "MeshBooleanType.h" +#include "../../MeshBooleanType.h" #include #include @@ -19,7 +19,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cgal { // MESH_BOOLEAN Compute boolean csg operations on "solid", consistently // oriented meshes. diff --git a/include/igl/copyleft/boolean/minkowski_sum.cpp b/include/igl/copyleft/cgal/minkowski_sum.cpp similarity index 98% rename from include/igl/copyleft/boolean/minkowski_sum.cpp rename to include/igl/copyleft/cgal/minkowski_sum.cpp index 6a9fa9919..d7a6ee8f3 100644 --- a/include/igl/copyleft/boolean/minkowski_sum.cpp +++ b/include/igl/copyleft/cgal/minkowski_sum.cpp @@ -12,7 +12,7 @@ #include "../../unique.h" #include "../../get_seconds.h" #include "../../edges.h" -#include "../cgal/assign_scalar.h" +#include "assign_scalar.h" #include #include #include @@ -24,7 +24,7 @@ template < typename DerivedW, typename DerivedG, typename DerivedJ> -IGL_INLINE void igl::copyleft::boolean::minkowski_sum( +IGL_INLINE void igl::copyleft::cgal::minkowski_sum( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -149,7 +149,7 @@ template < typename DerivedW, typename DerivedG, typename DerivedJ> -IGL_INLINE void igl::copyleft::boolean::minkowski_sum( +IGL_INLINE void igl::copyleft::cgal::minkowski_sum( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::Matrix & s, @@ -354,7 +354,7 @@ template < typename DerivedW, typename DerivedG, typename DerivedJ> -IGL_INLINE void igl::copyleft::boolean::minkowski_sum( +IGL_INLINE void igl::copyleft::cgal::minkowski_sum( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::Matrix & s, diff --git a/include/igl/copyleft/boolean/minkowski_sum.h b/include/igl/copyleft/cgal/minkowski_sum.h similarity index 99% rename from include/igl/copyleft/boolean/minkowski_sum.h rename to include/igl/copyleft/cgal/minkowski_sum.h index 3991aa6ac..f1b57c30c 100644 --- a/include/igl/copyleft/boolean/minkowski_sum.h +++ b/include/igl/copyleft/cgal/minkowski_sum.h @@ -15,7 +15,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cgal { // Compute the Minkowski sum of a closed triangle mesh (V,F) and a // set of simplices in 3D. diff --git a/include/igl/copyleft/cgal/points_inside_component.h b/include/igl/copyleft/cgal/points_inside_component.h index c87ee3be4..f21354455 100644 --- a/include/igl/copyleft/cgal/points_inside_component.h +++ b/include/igl/copyleft/cgal/points_inside_component.h @@ -12,7 +12,8 @@ #include #include -namespace igl { +namespace igl +{ namespace copyleft { namespace cgal { diff --git a/include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp b/include/igl/copyleft/cgal/string_to_mesh_boolean_type.cpp similarity index 81% rename from include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp rename to include/igl/copyleft/cgal/string_to_mesh_boolean_type.cpp index 1dbec9fa5..acfa1f292 100644 --- a/include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp +++ b/include/igl/copyleft/cgal/string_to_mesh_boolean_type.cpp @@ -3,7 +3,7 @@ #include #include -IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( +IGL_INLINE bool igl::copyleft::cgal::string_to_mesh_boolean_type( const std::string & s, MeshBooleanType & type) { @@ -22,7 +22,8 @@ IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( { type = MESH_BOOLEAN_TYPE_INTERSECT; }else if( - find_any({"minus","subtract","difference","relative complement","m","\\"},eff_s)) + find_any( + {"minus","subtract","difference","relative complement","m","\\"},eff_s)) { type = MESH_BOOLEAN_TYPE_MINUS; }else if(find_any({"xor","symmetric difference","x","∆"},eff_s)) @@ -38,7 +39,8 @@ IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( return true; } -IGL_INLINE igl::copyleft::boolean::MeshBooleanType igl::copyleft::boolean::string_to_mesh_boolean_type( +IGL_INLINE igl::MeshBooleanType +igl::copyleft::cgal::string_to_mesh_boolean_type( const std::string & s) { MeshBooleanType type; diff --git a/include/igl/copyleft/boolean/string_to_mesh_boolean_type.h b/include/igl/copyleft/cgal/string_to_mesh_boolean_type.h similarity index 87% rename from include/igl/copyleft/boolean/string_to_mesh_boolean_type.h rename to include/igl/copyleft/cgal/string_to_mesh_boolean_type.h index 64ac324d3..4781099f1 100644 --- a/include/igl/copyleft/boolean/string_to_mesh_boolean_type.h +++ b/include/igl/copyleft/cgal/string_to_mesh_boolean_type.h @@ -5,18 +5,18 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H -#define IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H +#ifndef IGL_COPYLEFT_CGAL_STRING_TO_MESH_BOOLEAN_H +#define IGL_COPYLEFT_CGAL_STRING_TO_MESH_BOOLEAN_H #include "../../igl_inline.h" -#include "MeshBooleanType.h" +#include "../../MeshBooleanType.h" #include namespace igl { namespace copyleft { - namespace boolean + namespace cgal { // Convert string to boolean type // diff --git a/include/igl/copyleft/boolean/from_cork_mesh.cpp b/include/igl/copyleft/cork/from_cork_mesh.cpp similarity index 59% rename from include/igl/copyleft/boolean/from_cork_mesh.cpp rename to include/igl/copyleft/cork/from_cork_mesh.cpp index c3a392607..4c81d318a 100644 --- a/include/igl/copyleft/boolean/from_cork_mesh.cpp +++ b/include/igl/copyleft/cork/from_cork_mesh.cpp @@ -5,13 +5,12 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_NO_CORK #include "from_cork_mesh.h" template < typename DerivedV, typename DerivedF> -IGL_INLINE void igl::copyleft::boolean::from_cork_mesh( +IGL_INLINE void igl::copyleft::cork::from_cork_mesh( const CorkTriMesh & mesh, Eigen::PlainObjectBase & V, Eigen::PlainObjectBase & F) @@ -37,8 +36,6 @@ IGL_INLINE void igl::copyleft::boolean::from_cork_mesh( #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::copyleft::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::copyleft::boolean::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -#endif - +template void igl::copyleft::cork::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cork::from_cork_mesh, Eigen::Matrix >(CorkTriMesh const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/copyleft/boolean/from_cork_mesh.h b/include/igl/copyleft/cork/from_cork_mesh.h similarity index 88% rename from include/igl/copyleft/boolean/from_cork_mesh.h rename to include/igl/copyleft/cork/from_cork_mesh.h index 6bb632b32..a2fef28c1 100644 --- a/include/igl/copyleft/boolean/from_cork_mesh.h +++ b/include/igl/copyleft/cork/from_cork_mesh.h @@ -5,9 +5,8 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H -#define IGL_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H -#ifndef IGL_NO_CORK +#ifndef IGL_COPYLEFT_CORK_FROM_CORK_MESH_H +#define IGL_COPYLEFT_CORK_FROM_CORK_MESH_H #include "../../igl_inline.h" #include #include @@ -15,7 +14,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cork { // Convert cork's triangle mesh representation to a (V,F) mesh. // @@ -38,4 +37,3 @@ namespace igl # include "from_cork_mesh.cpp" #endif #endif -#endif diff --git a/include/igl/copyleft/boolean/mesh_boolean_cork.cpp b/include/igl/copyleft/cork/mesh_boolean.cpp similarity index 59% rename from include/igl/copyleft/boolean/mesh_boolean_cork.cpp rename to include/igl/copyleft/cork/mesh_boolean.cpp index c6d5c3381..f826d3555 100644 --- a/include/igl/copyleft/boolean/mesh_boolean_cork.cpp +++ b/include/igl/copyleft/cork/mesh_boolean.cpp @@ -5,8 +5,7 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_NO_CORK -#include "mesh_boolean_cork.h" +#include "mesh_boolean.h" #include "to_cork_mesh.h" #include "from_cork_mesh.h" @@ -17,7 +16,7 @@ template < typename DerivedFB, typename DerivedVC, typename DerivedFC> -IGL_INLINE void igl::copyleft::boolean::mesh_boolean_cork( +IGL_INLINE void igl::copyleft::cork::mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -94,8 +93,7 @@ IGL_INLINE void igl::copyleft::boolean::mesh_boolean_cork( } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization -template void igl::copyleft::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); -template void igl::copyleft::boolean::mesh_boolean_cork, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cork::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::copyleft::cork::mesh_boolean, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif -#endif diff --git a/include/igl/copyleft/boolean/mesh_boolean_cork.h b/include/igl/copyleft/cork/mesh_boolean.h similarity index 86% rename from include/igl/copyleft/boolean/mesh_boolean_cork.h rename to include/igl/copyleft/cork/mesh_boolean.h index 5e16f9666..db2589284 100644 --- a/include/igl/copyleft/boolean/mesh_boolean_cork.h +++ b/include/igl/copyleft/cork/mesh_boolean.h @@ -5,10 +5,9 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_CORK_H -#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_CORK_H -#ifndef IGL_NO_CORK -#include "MeshBooleanType.h" +#ifndef IGL_COPYLEFT_CORK_MESH_BOOLEAN_H +#define IGL_COPYLEFT_CORK_MESH_BOOLEAN_H +#include "../../MeshBooleanType.h" #include "../../igl_inline.h" #include #include // for consistent uint @@ -17,7 +16,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cork { // Compute a boolean operation on two input meshes using the cork library. // @@ -37,7 +36,7 @@ namespace igl typename DerivedFB, typename DerivedVC, typename DerivedFC> - IGL_INLINE void mesh_boolean_cork( + IGL_INLINE void mesh_boolean( const Eigen::PlainObjectBase & VA, const Eigen::PlainObjectBase & FA, const Eigen::PlainObjectBase & VB, @@ -50,8 +49,7 @@ namespace igl } #ifndef IGL_STATIC_LIBRARY -# include "mesh_boolean_cork.cpp" -#endif +# include "mesh_boolean.cpp" #endif #endif diff --git a/include/igl/copyleft/boolean/to_cork_mesh.cpp b/include/igl/copyleft/cork/to_cork_mesh.cpp similarity index 62% rename from include/igl/copyleft/boolean/to_cork_mesh.cpp rename to include/igl/copyleft/cork/to_cork_mesh.cpp index a332d8092..96537ada9 100644 --- a/include/igl/copyleft/boolean/to_cork_mesh.cpp +++ b/include/igl/copyleft/cork/to_cork_mesh.cpp @@ -5,12 +5,11 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_NO_CORK #include "to_cork_mesh.h" template < typename DerivedV, typename DerivedF> -IGL_INLINE void igl::copyleft::boolean::to_cork_mesh( +IGL_INLINE void igl::copyleft::cork::to_cork_mesh( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, CorkTriMesh & mesh) @@ -20,7 +19,7 @@ IGL_INLINE void igl::copyleft::boolean::to_cork_mesh( assert((V.cols() == 0 || V.cols() == 3) && "Vertices should be in 3D."); mesh.n_triangles = F.rows(); mesh.n_vertices = V.rows(); - mesh.vertices = new double[mesh.n_vertices*3]; + mesh.vertices = new float[mesh.n_vertices*3]; mesh.triangles = new uint[mesh.n_triangles*3]; for(size_t v = 0;v, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); -template void igl::copyleft::boolean::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); -#endif +template void igl::copyleft::cork::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); +template void igl::copyleft::cork::to_cork_mesh, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, CorkTriMesh&); #endif diff --git a/include/igl/copyleft/boolean/to_cork_mesh.h b/include/igl/copyleft/cork/to_cork_mesh.h similarity index 88% rename from include/igl/copyleft/boolean/to_cork_mesh.h rename to include/igl/copyleft/cork/to_cork_mesh.h index 60ae184b5..b034e357f 100644 --- a/include/igl/copyleft/boolean/to_cork_mesh.h +++ b/include/igl/copyleft/cork/to_cork_mesh.h @@ -5,9 +5,8 @@ // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. -#ifndef IGL_COPYLEFT_BOOLEAN_TO_CORK_MESH_H -#define IGL_COPYLEFT_BOOLEAN_TO_CORK_MESH_H -#ifndef IGL_NO_CORK +#ifndef IGL_COPYLEFT_CORK_TO_CORK_MESH_H +#define IGL_COPYLEFT_CORK_TO_CORK_MESH_H #include "../../igl_inline.h" #include #include @@ -15,7 +14,7 @@ namespace igl { namespace copyleft { - namespace boolean + namespace cork { // Convert a (V,F) mesh to a cork's triangle mesh representation. // @@ -38,4 +37,3 @@ namespace igl # include "to_cork_mesh.cpp" #endif #endif -#endif diff --git a/optional/CMakeLists.txt b/optional/CMakeLists.txt index 8ce98ff80..65669fbed 100644 --- a/optional/CMakeLists.txt +++ b/optional/CMakeLists.txt @@ -17,17 +17,21 @@ endif() option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON) -option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF) +option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" ON) option(LIBIGL_WITH_BBW "Use BBW" ON) -option(LIBIGL_WITH_BOOLEAN "Use Cork boolean" OFF) -option(LIBIGL_WITH_CGAL "Use CGAL" OFF) +find_package(CGAL QUIET) +option(LIBIGL_WITH_CGAL "Use CGAL" "${CGAL_FOUND}") option(LIBIGL_WITH_COMISO "Use CoMiso" ON) +option(LIBIGL_WITH_CORK "Use Cork" ON) option(LIBIGL_WITH_EMBREE "Use Embree" ON) option(LIBIGL_WITH_LIM "Use LIM" ON) -option(LIBIGL_WITH_MATLAB "Use Matlab" OFF) -option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF) +find_package(MATLAB QUIET) +option(LIBIGL_WITH_MATLAB "Use Matlab" "${MATLAB_FOUND}") +find_package(MOSEK QUIET) +option(LIBIGL_WITH_MOSEK "Use MOSEK" "${MOSEK_FOUND}") option(LIBIGL_WITH_NANOGUI "Use Nanogui menu" OFF) -option(LIBIGL_WITH_OPENGL_AND_PNG "Use OpenGL" ON) +option(LIBIGL_WITH_OPENGL "Use OpenGL" ON) +option(LIBIGL_WITH_PNG "Use PNG" ON) option(LIBIGL_WITH_TETGEN "Use Tetgen" ON) option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON) option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON) diff --git a/shared/cmake/CMakeLists.txt b/shared/cmake/CMakeLists.txt index f93dce277..721426525 100644 --- a/shared/cmake/CMakeLists.txt +++ b/shared/cmake/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.8.12) project(libigl) ### Available options ### -option(LIBIGL_USE_STATIC_LIBRARY "Use libIGL as static library" OFF) +option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF) option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF) option(LIBIGL_WITH_BBW "Use BBW" OFF) -option(LIBIGL_WITH_BOOLEAN "Use Cork boolean" OFF) +option(LIBIGL_WITH_CORK "Use Cork" OFF) option(LIBIGL_WITH_CGAL "Use CGAL" OFF) option(LIBIGL_WITH_COMISO "Use CoMiso" OFF) option(LIBIGL_WITH_EMBREE "Use Embree" OFF) @@ -13,7 +13,8 @@ option(LIBIGL_WITH_LIM "Use LIM" OFF) option(LIBIGL_WITH_MATLAB "Use Matlab" OFF) option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF) option(LIBIGL_WITH_NANOGUI "Use Nanogui menu" OFF) -option(LIBIGL_WITH_OPENGL_AND_PNG "Use OpenGL" OFF) +option(LIBIGL_WITH_OPENGL "Use OpenGL" OFF) +option(LIBIGL_WITH_PNG "Use PNG" OFF) option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF) option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF) option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" OFF) @@ -116,6 +117,42 @@ if(LIBIGL_WITH_BBW) endif() endif() +### Compile the cgal parts ### +if(LIBIGL_WITH_CGAL) # to be cleaned + find_package(CGAL REQUIRED) + # set(Boost_USE_MULTITHREADED ON) + # set(Boost_USE_STATIC_LIBS ON) + # + # find_package(BOOST REQUIRED) + include(${CGAL_USE_FILE}) + list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_3RD_PARTY_INCLUDE_DIRS}) + list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS}) + list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_3RD_PARTY_LIBRARIES}) + list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_LIBRARIES}) + if(LIBIGL_USE_STATIC_LIBRARY) + CompileIGL_Module_Copyleft("cgal") + target_include_directories(iglcgal PRIVATE + ${CGAL_3RD_PARTY_INCLUDE_DIRS} + ${CGAL_INCLUDE_DIRS}) + endif() +endif() + +### Compile the cork parts ### +if(LIBIGL_WITH_CORK) + set(CORK_DIR "${LIBIGL_EXTERNAL}/cork") + set(CORK_INCLUDE_DIR "${CORK_DIR}/src") + # call this "lib-cork" instead of "cork", otherwise cmake gets confused about + # "cork" executable + add_subdirectory("${CORK_DIR}" "lib-cork") + list(APPEND LIBIGL_INCLUDE_DIRS "${CORK_INCLUDE_DIR}") + list(APPEND LIBIGL_EXTRA_LIBRARIES "cork") + if(LIBIGL_USE_STATIC_LIBRARY) + CompileIGL_Module_Copyleft("cork") + target_include_directories(iglcork PRIVATE + ${CORK_INCLUDE_DIR}) + endif() +endif() + ### Compile the embree part ### if(LIBIGL_WITH_EMBREE) set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree") @@ -255,21 +292,28 @@ if(LIBIGL_WITH_VIEWER) endif() endif() -### Compile the opengl and png parts ### -if(LIBIGL_WITH_OPENGL_AND_PNG) +### Compile the opengl parts ### +if(LIBIGL_WITH_OPENGL) + if(LIBIGL_USE_STATIC_LIBRARY) + CompileIGL_Module("opengl") + CompileIGL_Module("opengl2") + if(NOT APPLE) + target_include_directories(iglopengl PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include") + target_include_directories(iglopengl2 PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include") + endif() + endif() +endif() + +### Compile the png parts ### +if(LIBIGL_WITH_PNG) set(STB_IMAGE_DIR "${LIBIGL_EXTERNAL}/stb_image") add_subdirectory("${STB_IMAGE_DIR}" "stb_image") list(APPEND LIBIGL_INCLUDE_DIRS ${STB_IMAGE_DIR}) list(APPEND LIBIGL_EXTRA_LIBRARIES "stb_image") - if(LIBIGL_USE_STATIC_LIBRARY) - CompileIGL_Module("opengl") - CompileIGL_Module("opengl2") CompileIGL_Module("png") target_include_directories(iglpng PRIVATE ${STB_IMAGE_DIR}) if(NOT APPLE) - target_include_directories(iglopengl PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include") - target_include_directories(iglopengl2 PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include") target_include_directories(iglpng PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include") endif() endif() @@ -333,7 +377,6 @@ endif() ### Compile the xml part ### if(LIBIGL_WITH_XML) set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2") - add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h) set_target_properties(tinyxml2 PROPERTIES COMPILE_DEFINITIONS "TINYXML2_EXPORT" @@ -341,62 +384,12 @@ if(LIBIGL_WITH_XML) SOVERSION "3") list(APPEND LIBIGL_INCLUDE_DIRS ${TINYXML2_DIR}) list(APPEND LIBIGL_EXTRA_LIBRARIES "tinyxml2") - if(LIBIGL_USE_STATIC_LIBRARY) CompileIGL_Module("xml") target_include_directories(iglxml PRIVATE ${TINYXML2_DIR}) endif() endif() -### Compile the boolean and cgal parts ### -if(LIBIGL_WITH_CGAL) # to be cleaned - find_package(CGAL REQUIRED) - # set(Boost_USE_MULTITHREADED ON) - # set(Boost_USE_STATIC_LIBS ON) - # - # find_package(BOOST REQUIRED) - - include(${CGAL_USE_FILE}) - - list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_3RD_PARTY_INCLUDE_DIRS}) - list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS}) - list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_3RD_PARTY_LIBRARIES}) - list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_LIBRARIES}) - - if(LIBIGL_USE_STATIC_LIBRARY) - CompileIGL_Module_Copyleft("cgal") - target_include_directories(iglcgal PRIVATE - ${CGAL_3RD_PARTY_INCLUDE_DIRS} - ${CGAL_INCLUDE_DIRS}) - endif() - - if(LIBIGL_WITH_BOOLEAN) - find_package(CORK QUIET) - if(CORK_FOUND) - list(APPEND LIBIGL_INCLUDE_DIRS ${CORK_INCLUDE_DIR}) - list(APPEND LIBIGL_EXTRA_LIBRARIES ${CORK_LIBRARIES}) - - if(LIBIGL_USE_STATIC_LIBRARY) - CompileIGL_Module_Copyleft("boolean") - target_include_directories(iglboolean PRIVATE - ${CGAL_3RD_PARTY_INCLUDE_DIRS} - ${CGAL_INCLUDE_DIRS} - ${CORK_INCLUDE_DIR}) - endif() - else() - list(APPEND LIBIGL_DEFINITIONS "-DIGL_NO_CORK") - - if(LIBIGL_USE_STATIC_LIBRARY) - CompileIGL_Module_Copyleft("boolean") - target_include_directories(iglboolean PRIVATE - ${CGAL_3RD_PARTY_INCLUDE_DIRS} - ${CGAL_INCLUDE_DIRS}) - target_compile_definitions(iglboolean PRIVATE -DIGL_NO_CORK) - endif() - endif() - endif() -endif() - # Function to print list nicely function(print_list title list) message("-- ${title}:") @@ -415,8 +408,8 @@ if(NOT ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME}) set(LIBIGL_DEFINITIONS ${LIBIGL_DEFINITIONS} PARENT_SCOPE) ### ligIGL information ### - print_list("libIGL includes" "${LIBIGL_INCLUDE_DIRS}") - print_list("libIGL libraries" "${LIBIGL_LIBRARIES}") - print_list("libIGL extra libraries" "${LIBIGL_EXTRA_LIBRARIES}") - print_list("libIGL definitions" "${LIBIGL_DEFINITIONS}") + print_list("libigl includes" "${LIBIGL_INCLUDE_DIRS}") + print_list("libigl libraries" "${LIBIGL_LIBRARIES}") + print_list("libigl extra libraries" "${LIBIGL_EXTRA_LIBRARIES}") + print_list("libigl definitions" "${LIBIGL_DEFINITIONS}") endif() diff --git a/tutorial/609_Boolean/main.cpp b/tutorial/609_Boolean/main.cpp index 66d68fc6a..38dfa36cf 100755 --- a/tutorial/609_Boolean/main.cpp +++ b/tutorial/609_Boolean/main.cpp @@ -1,7 +1,7 @@ #include //#define IGL_NO_CORK //#undef IGL_STATIC_LIBRARY -#include +#include #include #include @@ -12,8 +12,8 @@ Eigen::MatrixXd VA,VB,VC; Eigen::VectorXi J,I; Eigen::MatrixXi FA,FB,FC; -igl::copyleft::boolean::MeshBooleanType boolean_type( - igl::copyleft::boolean::MESH_BOOLEAN_TYPE_UNION); +igl::MeshBooleanType boolean_type( + igl::MESH_BOOLEAN_TYPE_UNION); const char * MESH_BOOLEAN_TYPE_NAMES[] = { @@ -26,7 +26,7 @@ const char * MESH_BOOLEAN_TYPE_NAMES[] = void update(igl::viewer::Viewer &viewer) { - igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J); + igl::copyleft::cgal::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J); Eigen::MatrixXd C(FC.rows(),3); for(size_t f = 0;f( - (boolean_type+1)% igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES); + static_cast( + (boolean_type+1)% igl::NUM_MESH_BOOLEAN_TYPES); break; case ',': boolean_type = - static_cast( - (boolean_type+igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES-1)% - igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES); + static_cast( + (boolean_type+igl::NUM_MESH_BOOLEAN_TYPES-1)% + igl::NUM_MESH_BOOLEAN_TYPES); break; case '[': viewer.core.camera_dnear -= 0.1; @@ -68,7 +68,7 @@ bool key_down(igl::viewer::Viewer &viewer, unsigned char key, int mods) return true; } std::cout<<"A "< -#include +#include #include #include #include @@ -9,7 +9,7 @@ int main(int argc, char * argv[]) { using namespace Eigen; - using namespace igl::copyleft::boolean; + using namespace igl::copyleft::cgal; using namespace std; using namespace igl; cout<