├── stamp-h1 ├── matlab version ├── MVs.mat ├── isLeftSide.m ├── LButtonFcn.m ├── triSmooth.m ├── afmSearch.m ├── afce.m ├── mafce.m ├── afront.m └── mafront.m ├── 科研训练报告-朱光穆-2009031200.pdf ├── README.md ├── test └── test.off ├── Makefile.am ├── configure.ac ├── config.h.in ├── config.h ├── src ├── MAFM.hpp ├── smooth_tri.cpp ├── VET.hpp ├── check_VE.cpp ├── format_off.cpp ├── Advancing-Front-Method_2D.cpp ├── matlab_fun.cpp ├── interpolation.cpp ├── create_tri.cpp └── matlab_fun.hpp ├── missing ├── install-sh ├── depcomp ├── config.log └── LICENSE /stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for config.h 2 | -------------------------------------------------------------------------------- /matlab version/MVs.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedyF/advancing-front-method_2D/HEAD/matlab version/MVs.mat -------------------------------------------------------------------------------- /科研训练报告-朱光穆-2009031200.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpeedyF/advancing-front-method_2D/HEAD/科研训练报告-朱光穆-2009031200.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | advancing-front-method_2D 2 | ========================= 3 | 4 | 前沿波向法是数值模拟计算中产生非结构化网格的一种方法,这是我大三科研训练的内容。详细信息请参阅“科研训练报告-朱光穆-2009031200.pdf”。 5 | -------------------------------------------------------------------------------- /test/test.off: -------------------------------------------------------------------------------- 1 | OFF 2 | 8 2 0 3 | 0 0 0 4 | 10.1 -3 0 5 | 8.8 11 0 6 | 3 7.8 0 7 | 4.3 3.1 0 8 | 7.4 2.9 0 9 | 6.8 7.1 0 10 | 4.1 6.7 0 11 | 4 0 1 2 3 12 | 4 4 5 6 7 -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS=foreign 2 | bin_PROGRAMS=Advancing_Front_Method_2D 3 | Advancing_Front_Method_2D_CPPFLAGS=-std=c++11 4 | Advancing_Front_Method_2D_SOURCES=src/Advancing-Front-Method_2D.cpp src/MAFM.hpp src/matlab_fun.cpp src/matlab_fun.hpp src/format_off.cpp src/VET.hpp src/check_VE.cpp src/interpolation.cpp src/create_tri.cpp src/smooth_tri.cpp 5 | -------------------------------------------------------------------------------- /matlab version/isLeftSide.m: -------------------------------------------------------------------------------- 1 | function ls = isLeftSide(pt1,pt2,pt3) 2 | % isLeftSide: is pt3 on the left side of vector from pt1 to pt2? 3 | % function ls = isLeftSide(pt1,pt2,pt3) 4 | if (pt3(1)==pt1(1)&&pt3(2)==pt1(2))||(pt3(1)==pt2(1)&&pt3(2)==pt2(2)) 5 | ls=false; 6 | return; 7 | end 8 | % Lack of precision 9 | % if mod(mod(cart2pol(pt2(1)-pt1(1),pt2(2)-pt1(2)),2*pi)-mod(cart2pol(pt3(1)-pt1(1),pt3(2)-pt1(2)),2*pi),2*pi)>pi 10 | if (pt1(2)-pt2(2))*pt3(1)-(pt1(1)-pt2(1))*pt3(2)+(pt1(1)*pt2(2)-pt2(1)*pt1(2))>1e-8 % this number should be reconsidered 11 | ls=true; 12 | else 13 | ls=false; 14 | end 15 | end 16 | 17 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.69]) 5 | AC_INIT([Advancing-Front-Method_2D], [1.0], [guangmuzhu@gmail.com]) 6 | AM_INIT_AUTOMAKE 7 | AC_CONFIG_SRCDIR([src/matlab_fun.cpp]) 8 | AC_CONFIG_HEADERS([config.h]) 9 | 10 | # Checks for programs. 11 | ${CXXFLAGS="-g0 -O3"} 12 | AC_PROG_CXX 13 | 14 | # Checks for libraries. 15 | 16 | # Checks for header files. 17 | 18 | # Checks for typedefs, structures, and compiler characteristics. 19 | AC_CHECK_HEADER_STDBOOL 20 | 21 | # Checks for library functions. 22 | AC_CHECK_FUNCS([pow sqrt]) 23 | 24 | AC_CONFIG_FILES([Makefile]) 25 | 26 | AC_OUTPUT 27 | -------------------------------------------------------------------------------- /matlab version/LButtonFcn.m: -------------------------------------------------------------------------------- 1 | function LButtonFcn(mode,step) 2 | persistent VX; 3 | persistent VY; 4 | persistent i; 5 | persistent LeftDown; 6 | if isempty(i) 7 | i=1; 8 | end 9 | if isempty(LeftDown) 10 | LeftDown=false; 11 | end 12 | if strcmp(get(gcf,'SelectionType'),'normal') 13 | % strcmp(get(gcf,'SelectionType'),'alt') 14 | switch(mode) 15 | case 'down' 16 | LeftDown=true; 17 | i=1; 18 | pt=get(gca,'CurrentPoint'); 19 | VX(i)=pt(1,1); 20 | VY(i)=pt(1,2); 21 | i=i+1; 22 | case 'move' 23 | if LeftDown==true 24 | pt=get(gca,'CurrentPoint'); 25 | if sqrt((pt(1,1)-VX(i-1))^2+(pt(1,2)-VY(i-1))^2)>step 26 | VX(i)=pt(1,1); 27 | VY(i)=pt(1,2); 28 | i=i+1; 29 | plot(VX,VY,'r-'); 30 | end 31 | end 32 | case 'up' 33 | LeftDown=false; 34 | set(gcf,'WindowButtonDownFcn',''); 35 | set(gcf,'WindowButtonMotionFcn',''); 36 | set(gcf,'WindowButtonUpFcn',''); 37 | save('Vs.mat','VX','VY'); 38 | end 39 | end 40 | end 41 | 42 | -------------------------------------------------------------------------------- /matlab version/triSmooth.m: -------------------------------------------------------------------------------- 1 | function [IAVs,err] = triSmooth(IAVs,count,ITs,rf,VStep,CC,EC) 2 | %TRISMOOTH Smooth triangles via making vertexes central 3 | % function [IAVs,err] = triSmooth(IAVs,count,ITs,rf,VStep,CC,EC) 4 | % IAVs: [ x, y, node index ], [ inner vertexes; boundary vertexes ] 5 | % count: inner vertexes count 6 | % ITs: indexed triangles 7 | % rf: relaxation factor, >0 8 | % VStep: standard step between vertexes. 9 | % CC: convergence coefficient 10 | % EC: error coefficient 11 | VVs=cell(size(IAVs,1),1); 12 | for i=1:size(ITs,1) 13 | VVs(ITs(i,1))={[VVs{ITs(i,1)},ITs(i,2),ITs(i,3)]}; 14 | VVs(ITs(i,2))={[VVs{ITs(i,2)},ITs(i,3),ITs(i,1)]}; 15 | VVs(ITs(i,3))={[VVs{ITs(i,3)},ITs(i,1),ITs(i,2)]}; 16 | end 17 | VVs=VVs(1:count); 18 | for i=1:size(VVs,1) 19 | VVs(i)={unique(VVs{i})}; 20 | end 21 | err1=2*VStep; 22 | err2=VStep; 23 | while err1-err2>=VStep*CC||err2>VStep*EC 24 | err1=err2; 25 | err2=0; 26 | for i=1:size(VVs,1) 27 | tmp=VVs{i}; 28 | tmp1=0; 29 | tmp2=0; 30 | for j=1:length(tmp) 31 | tmp1=tmp1+IAVs(tmp(j),1)-IAVs(i,1); 32 | tmp2=tmp2+IAVs(tmp(j),2)-IAVs(i,2); 33 | end 34 | err2=max(err2,sqrt(tmp1^2+tmp2^2)); 35 | IAVs(i,1)=IAVs(i,1)+rf/length(tmp)*tmp1; 36 | IAVs(i,2)=IAVs(i,2)+rf/length(tmp)*tmp2; 37 | end 38 | end 39 | err=err2/VStep; 40 | end -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #undef HAVE_INTTYPES_H 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_MEMORY_H 8 | 9 | /* Define to 1 if you have the `pow' function. */ 10 | #undef HAVE_POW 11 | 12 | /* Define to 1 if you have the `sqrt' function. */ 13 | #undef HAVE_SQRT 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_STDINT_H 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_STDLIB_H 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_STRINGS_H 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_STRING_H 26 | 27 | /* Define to 1 if you have the header file. */ 28 | #undef HAVE_SYS_STAT_H 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_SYS_TYPES_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_UNISTD_H 35 | 36 | /* Define to 1 if the system has the type `_Bool'. */ 37 | #undef HAVE__BOOL 38 | 39 | /* Name of package */ 40 | #undef PACKAGE 41 | 42 | /* Define to the address where bug reports for this package should be sent. */ 43 | #undef PACKAGE_BUGREPORT 44 | 45 | /* Define to the full name of this package. */ 46 | #undef PACKAGE_NAME 47 | 48 | /* Define to the full name and version of this package. */ 49 | #undef PACKAGE_STRING 50 | 51 | /* Define to the one symbol short name of this package. */ 52 | #undef PACKAGE_TARNAME 53 | 54 | /* Define to the home page for this package. */ 55 | #undef PACKAGE_URL 56 | 57 | /* Define to the version of this package. */ 58 | #undef PACKAGE_VERSION 59 | 60 | /* Define to 1 if you have the ANSI C header files. */ 61 | #undef STDC_HEADERS 62 | 63 | /* Version number of package */ 64 | #undef VERSION 65 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_INTTYPES_H 1 6 | 7 | /* Define to 1 if you have the header file. */ 8 | #define HAVE_MEMORY_H 1 9 | 10 | /* Define to 1 if you have the `pow' function. */ 11 | /* #undef HAVE_POW */ 12 | 13 | /* Define to 1 if you have the `sqrt' function. */ 14 | /* #undef HAVE_SQRT */ 15 | 16 | /* Define to 1 if you have the header file. */ 17 | #define HAVE_STDINT_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_STDLIB_H 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_STRINGS_H 1 24 | 25 | /* Define to 1 if you have the header file. */ 26 | #define HAVE_STRING_H 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_SYS_STAT_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_SYS_TYPES_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_UNISTD_H 1 36 | 37 | /* Define to 1 if the system has the type `_Bool'. */ 38 | #define HAVE__BOOL 1 39 | 40 | /* Name of package */ 41 | #define PACKAGE "advancing-front-method_2d" 42 | 43 | /* Define to the address where bug reports for this package should be sent. */ 44 | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 45 | 46 | /* Define to the full name of this package. */ 47 | #define PACKAGE_NAME "Advancing-Front-Method_2D" 48 | 49 | /* Define to the full name and version of this package. */ 50 | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 51 | 52 | /* Define to the one symbol short name of this package. */ 53 | #define PACKAGE_TARNAME "advancing-front-method_2d" 54 | 55 | /* Define to the home page for this package. */ 56 | #define PACKAGE_URL "" 57 | 58 | /* Define to the version of this package. */ 59 | #define PACKAGE_VERSION "1.0" 60 | 61 | /* Define to 1 if you have the ANSI C header files. */ 62 | #define STDC_HEADERS 1 63 | 64 | /* Version number of package */ 65 | #define VERSION "1.0" 66 | -------------------------------------------------------------------------------- /src/MAFM.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * MAFM.hpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #ifndef MAFM_HPP_ 28 | #define MAFM_HPP_ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include "matlab_fun.hpp" 35 | #include "VET.hpp" 36 | 37 | bool load_off(const std::string&, std::vector>&); 38 | 39 | bool check_off(std::vector>&); 40 | 41 | bool _is_inner_outof_outer(const std::vector>&); 42 | 43 | bool _has_intersecting_lines(const std::vector>&); 44 | 45 | void _check_direction(std::vector>&); 46 | 47 | std::vector boundary_interpolation( 48 | const std::vector>&, double); 49 | 50 | matrix inner_interpolation(const std::vector>&, 51 | const matrix&, double); 52 | 53 | matrix filter_inner_interpolation(const std::vector&, const matrix&, 54 | double); 55 | 56 | // create triangles 57 | std::pair create_triangles(const std::vector&, 58 | const matrix&, double); 59 | 60 | // smooth triangles 61 | std::pair smooth_triangles(matrix, unsigned, 62 | const matrix&, double, double, double, double); 63 | 64 | void save_OFF(const matrix&, const matrix&, const std::string&); 65 | 66 | #endif /* MAFM_HPP_ */ 67 | -------------------------------------------------------------------------------- /matlab version/afmSearch.m: -------------------------------------------------------------------------------- 1 | function innerNearest = afmSearch(pt1,pt2,Vs,FEs,VStep,flag) 2 | % AFMSEARCH Search the nearest point from pt1 and pt2 in Vs on the left 3 | % side 4 | % function innerNearest = afmSearch(pt1,pt2,Vs,VStep,flag,except) 5 | % vector is from pt1 to pt2, Vs is a n*2 matrix with [x,y] and Vs 6 | % must be sorted by sortrows(Vs,[2,1]).FEs is a collection of cells for 7 | % front egdes. innerNearest is the nearest point from pt1 and pt2 8 | % according to sum of square. VStep is the standard step between 9 | % vertexes. flag: see afce.m 10 | MXY=[min(pt1(1),pt2(1))-2*VStep,max(pt1(1),pt2(1))+2*VStep;min(pt1(2),pt2(2))-2*VStep,max(pt1(2),pt2(2))+2*VStep]; 11 | for i=1:size(Vs,1) 12 | if Vs(i,2)>=MXY(2,1) 13 | break; 14 | end 15 | end 16 | minDist=2*(3*VStep)^2; % actually it can't be larger than this. 17 | while Vs(i,2)<=MXY(2,2) 18 | if Vs(i,1)>=MXY(1,1)&&Vs(i,1)<=MXY(1,2)&&flag(Vs(i,3))~=0&&~segCrs(pt1,pt2,Vs(i,1:2),FEs)&&isLeftSide(pt1,pt2,Vs(i,:)) 19 | currDist=(Vs(i,1)-pt1(1))^2+(Vs(i,2)-pt1(2))^2+(Vs(i,1)-pt2(1))^2+(Vs(i,2)-pt2(2))^2; 20 | if minDist>=currDist 21 | minDist=currDist; 22 | innerNearest=i; 23 | end 24 | end 25 | i=i+1; 26 | if i>size(Vs,1) 27 | break; 28 | end 29 | end 30 | innerNearest=Vs(innerNearest,:); 31 | end 32 | 33 | function FOUND=segCrs(pt1,pt2,pt3,FEs) 34 | for i=1:size(FEs,1) 35 | if abs(det([pt1(1)-pt3(1),FEs{i,2}(1)-FEs{i,1}(1);pt1(2)-pt3(2),FEs{i,2}(2)-FEs{i,1}(2)]))1e-8&&k(1)<1-1e-8)&&(k(2)>1e-8&&k(2)<1-1e-8) 40 | FOUND=true; 41 | return; 42 | end 43 | if abs(det([pt2(1)-pt3(1),FEs{i,2}(1)-FEs{i,1}(1);pt2(2)-pt3(2),FEs{i,2}(2)-FEs{i,1}(2)]))1e-8&&k(1)<1-1e-8)&&(k(2)>1e-8&&k(2)<1-1e-8) 48 | FOUND=true; 49 | return; 50 | end 51 | end 52 | FOUND=false; 53 | end 54 | -------------------------------------------------------------------------------- /src/smooth_tri.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * smooth_tri.cpp 22 | * 23 | * Created on: May 26, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include 28 | 29 | #include "MAFM.hpp" 30 | 31 | using namespace std; 32 | 33 | pair smooth_triangles(matrix _IAVs, unsigned _cIVs, 34 | const matrix &_TRI, double _rf, double _VStep, double _CC, double _EC) { 35 | vector _VVs[_IAVs.get_size().first]; 36 | for (unsigned i = 1; i <= _TRI.get_size().first; ++i) { 37 | _VVs[static_cast(_TRI(i, 1)) - 1].push_back(_TRI(i, 2)); 38 | _VVs[static_cast(_TRI(i, 1)) - 1].push_back(_TRI(i, 3)); 39 | _VVs[static_cast(_TRI(i, 2)) - 1].push_back(_TRI(i, 1)); 40 | _VVs[static_cast(_TRI(i, 2)) - 1].push_back(_TRI(i, 3)); 41 | _VVs[static_cast(_TRI(i, 3)) - 1].push_back(_TRI(i, 1)); 42 | _VVs[static_cast(_TRI(i, 3)) - 1].push_back(_TRI(i, 2)); 43 | } 44 | vector::iterator _end_unique; 45 | for (unsigned i = 0; i < _cIVs; ++i) { 46 | sort(_VVs[i].begin(), _VVs[i].end()); 47 | _end_unique = unique(_VVs[i].begin(), _VVs[i].end()); 48 | _VVs[i].erase(_end_unique, _VVs[i].end()); 49 | } 50 | double _err1 = 2 * _VStep, _err2 = _VStep; 51 | double _tmp1, _tmp2; 52 | vector _tmp; 53 | while (_err1 - _err2 >= _VStep * _CC || _err2 > _VStep * _EC) { 54 | _err1 = _err2; 55 | _err2 = 0; 56 | for (unsigned i = 0; i < _cIVs; ++i) { 57 | _tmp = _VVs[i]; 58 | _tmp1 = _tmp2 = 0; 59 | for (auto &_ttmp : _tmp) { 60 | _tmp1 += _IAVs(_ttmp, 1) - _IAVs(i + 1, 1); 61 | _tmp2 += _IAVs(_ttmp, 2) - _IAVs(i + 1, 2); 62 | } 63 | _err2 = fmax(_err2, sqrt(pow(_tmp1, 2) + pow(_tmp2, 2))); 64 | _IAVs(i + 1, 1) = _IAVs(i + 1, 1) + _rf / _tmp.size() * _tmp1; 65 | _IAVs(i + 1, 2) = _IAVs(i + 1, 2) + _rf / _tmp.size() * _tmp2; 66 | } 67 | } 68 | return make_pair(_IAVs, _err2 / _VStep); 69 | } 70 | -------------------------------------------------------------------------------- /src/VET.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * VET.hpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #ifndef VET_HPP_ 28 | #define VET_HPP_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | struct Point { 36 | double x; 37 | double y; 38 | 39 | Point() : 40 | x(0), y(0) { 41 | } 42 | 43 | Point(double x, double y) : 44 | x(x), y(y) { 45 | } 46 | 47 | Point operator+(const Point& _p) const { 48 | return Point(x + _p.x, y + _p.y); 49 | } 50 | 51 | Point operator-(const Point& _p) const { 52 | return Point(x - _p.x, y - _p.y); 53 | } 54 | 55 | bool operator==(const Point &_p) const { 56 | return (x == _p.x && y == _p.y) ? true : false; 57 | } 58 | 59 | bool operator!=(const Point &_p) const { 60 | return (x == _p.x && y == _p.y) ? false : true; 61 | } 62 | 63 | std::string to_string() const { 64 | return to_string("[", "]", " "); 65 | } 66 | 67 | std::string to_string(std::string _prefix, std::string _suffix, std::string _delim) const { 68 | std::stringstream _ret; 69 | _ret << _prefix << x << _delim << y << _suffix; 70 | return _ret.str(); 71 | } 72 | 73 | double distance(const Point &_p) const { 74 | return std::sqrt(std::pow(x - _p.x, 2) + std::pow(y - _p.y, 2)); 75 | } 76 | }; 77 | 78 | struct Edge { 79 | Point a; 80 | Point b; 81 | 82 | Edge() : a(), b() {} 83 | 84 | Edge(const Point &a, const Point&b) : 85 | a(a), b(b) { 86 | } 87 | }; 88 | 89 | struct Triangle { 90 | Point a; 91 | Point b; 92 | Point c; 93 | 94 | Triangle() : a(), b(), c() {} 95 | 96 | Triangle(const Point &a, const Point &b, const Point &c) : 97 | a(a), b(b), c(c) { 98 | } 99 | }; 100 | 101 | struct IPoint: Point { 102 | unsigned index; 103 | 104 | IPoint() : 105 | Point(), index(0) { 106 | } 107 | 108 | IPoint(double x, double y, unsigned index) : 109 | Point(x, y), index(index) { 110 | } 111 | }; 112 | 113 | struct IEdge: Edge { 114 | IPoint a; 115 | IPoint b; 116 | 117 | IEdge(const IPoint &a, const IPoint&b) : 118 | Edge(a, b), a(a), b(b) { 119 | } 120 | }; 121 | 122 | struct ITriangle: Triangle { 123 | IPoint a; 124 | IPoint b; 125 | IPoint c; 126 | 127 | ITriangle(const IPoint &a, const IPoint &b, const IPoint &c) : 128 | Triangle(a, b, c), a(a), b(b), c(c) { 129 | } 130 | }; 131 | 132 | #endif /* VET_HPP_ */ 133 | -------------------------------------------------------------------------------- /matlab version/afce.m: -------------------------------------------------------------------------------- 1 | function [IAVs,VTs] = afce(BVs,IVs,VStep) 2 | %AFCE Triangular meshes via Advancing Front Method 3 | % function [IAVs,VTs] = afce(BVs,IVs,VStep) 4 | % BVs is a m*2 matrix for boundary vertexes, and IVs is a n*2 matrix 5 | % for inner vertexes. VStep is the stantard step between vertexes. AFCE 6 | % return [vertexes coordination and index, triangles indexes sharing a vertex] 7 | flag=[-1.*ones(size(IVs,1),1);2.*ones(size(BVs,1),1)]; 8 | IAVs=[IVs;BVs]; 9 | IAVs=[IAVs,(1:size(IAVs,1))']; % indexed all vertexes(-1: nerver used; >0: usage count; 0: can't be used for out of boundary) 10 | % IIVs=IAVs(1:size(IVs,1),:); 11 | IBVs=IAVs(size(IVs,1)+1:end,:); 12 | IAVs=sortrows(IAVs,[2,1]); 13 | FEs=cell(size(IBVs,1),2); % Front Edges 14 | for i=1:size(IBVs,1)-1 15 | FEs(i,:)={IBVs(i,:),IBVs(i+1,:)}; 16 | end 17 | FEs(end,:)={IBVs(end,:),IBVs(1,:)}; 18 | % show progress bar 19 | ptotal=size(IVs,1); 20 | pnow=0; 21 | hwait=waitbar(0,'Calculating...'); 22 | i=1; 23 | while size(FEs,1)>3 24 | waitbar(pnow/ptotal,hwait,['Calculating...',num2str(floor(pnow/ptotal*100)),'%']); 25 | % for t=1:size(FEs,1) 26 | % plot([FEs{t,1}(1),FEs{t,2}(1)],[FEs{t,1}(2),FEs{t,2}(2)],'r-'); 27 | % end % only for debug 28 | % pause(0.1); % only for debug 29 | tri={FEs{1,1},FEs{1,2},afmSearch(FEs{1,1},FEs{1,2},IAVs,FEs,VStep,flag)}; 30 | VTs(i,:)=[tri{1}(3),tri{2}(3),tri{3}(3)]; 31 | % plot([FEs{1,1}(1),FEs{1,2}(1)],[FEs{1,1}(2),FEs{1,2}(2)],'w-'); % only for debug 32 | if flag(tri{3}(3))==-1 33 | pnow=pnow+1; 34 | end 35 | flag(FEs{1,1}(3))=flag(FEs{1,1}(3))-1; 36 | flag(FEs{1,2}(3))=flag(FEs{1,2}(3))-1; 37 | FEs(1,:)=[]; 38 | j=1; 39 | found=[0,0]; 40 | while j<=size(FEs,1) 41 | if (FEs{j,1}(3)==tri{1}(3)&&FEs{j,2}(3)==tri{3}(3))||(FEs{j,1}(3)==tri{3}(3)&&FEs{j,2}(3)==tri{1}(3)) 42 | % plot([FEs{j,1}(1),FEs{j,2}(1)],[FEs{j,1}(2),FEs{j,2}(2)],'w-'); % only for debug 43 | flag(FEs{j,1}(3))=flag(FEs{j,1}(3))-1; 44 | flag(FEs{j,2}(3))=flag(FEs{j,2}(3))-1; 45 | FEs(j,:)=[]; 46 | found(1)=1; 47 | continue; 48 | end 49 | if (FEs{j,1}(3)==tri{3}(3)&&FEs{j,2}(3)==tri{2}(3))||(FEs{j,1}(3)==tri{2}(3)&&FEs{j,2}(3)==tri{3}(3)) 50 | % plot([FEs{j,1}(1),FEs{j,2}(1)],[FEs{j,1}(2),FEs{j,2}(2)],'w-'); % only for debug 51 | flag(FEs{j,1}(3))=flag(FEs{j,1}(3))-1; 52 | flag(FEs{j,2}(3))=flag(FEs{j,2}(3))-1; 53 | FEs(j,:)=[]; 54 | found(2)=1; 55 | continue; 56 | end 57 | j=j+1; 58 | end 59 | if found(1)==0 60 | FEs(end+1,:)={tri{1},tri{3}}; 61 | flag(FEs{end,1}(3))=flag(FEs{end,1}(3))+1; 62 | if flag(FEs{end,2}(3))==-1 63 | flag(FEs{end,2}(3))=1; 64 | else 65 | flag(FEs{end,2}(3))=flag(FEs{end,2}(3))+1; 66 | end 67 | end 68 | if found(2)==0 69 | FEs(end+1,:)={tri{3},tri{2}}; 70 | if flag(FEs{end,1}(3))==-1 71 | flag(FEs{end,1}(3))=1; 72 | else 73 | flag(FEs{end,1}(3))=flag(FEs{end,1}(3))+1; 74 | end 75 | flag(FEs{end,2}(3))=flag(FEs{end,2}(3))+1; 76 | end 77 | i=i+1; 78 | end 79 | waitbar(1,hwait,'Finishing...'); 80 | tri={FEs{1,1},FEs{1,2},FEs{2,2}}; 81 | VTs(end+1,:)=[tri{1}(3),tri{2}(3),tri{3}(3)]; 82 | close(hwait); 83 | IAVs=sortrows(IAVs,3); 84 | end -------------------------------------------------------------------------------- /src/check_VE.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * check_VE.cpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "MAFM.hpp" 31 | 32 | using namespace std; 33 | 34 | namespace { 35 | /*** help function ***/ 36 | 37 | template bool __check_direction(const FWIter &_bg, const FWIter &_ed) { 38 | double _angle = 0, _tmpagl = 0; 39 | FWIter _tmp1, _tmp2, _tmp3; 40 | for (_tmp1 = _tmp2 = _tmp3 = _bg, ++_tmp2, ++++_tmp3; _tmp3 != _ed; 41 | ++_tmp1, ++_tmp2, ++_tmp3) { 42 | _tmpagl = mmod(cart2pol(*_tmp3 - *_tmp2)- cart2pol(*_tmp2 - *_tmp1), 2 * M_PI); 43 | _angle += (mmod(_tmpagl, 2 * M_PI) > M_PI) ? _tmpagl - 2 * M_PI : _tmpagl; 44 | } 45 | _tmpagl = mmod(cart2pol(*_bg - *_tmp2) - cart2pol(*_tmp2 - *_tmp1), 2 * M_PI); 46 | _angle += (mmod(_tmpagl, 2 * M_PI) > M_PI) ? _tmpagl - 2 * M_PI : _tmpagl; 47 | return _angle > 0; 48 | } 49 | } 50 | 51 | bool check_off(vector>& _PVs) { 52 | if (_is_inner_outof_outer(_PVs) || _has_intersecting_lines(_PVs)) { 53 | return false; 54 | } else { 55 | _check_direction(_PVs); 56 | return true; 57 | } 58 | } 59 | 60 | bool _is_inner_outof_outer(const vector>& _PVs) { 61 | for (auto _iter = ++_PVs.cbegin(); _iter != _PVs.end(); ++_iter) { 62 | if (!iopolygon(_PVs.front().cbegin(), _PVs.front().end(), _iter->begin(),_iter->end())) 63 | return true; 64 | } 65 | return false; 66 | } 67 | 68 | bool _has_intersecting_lines(const vector>& _PVs) { 69 | vector _PEs; 70 | vector::const_iterator _tmp; 71 | for (auto _iter1 = _PVs.cbegin(); _iter1 != _PVs.cend(); ++_iter1) { 72 | for (auto _iter2 = _iter1->cbegin(); _iter2 != _iter1->cend(); ++_iter2) { 73 | if (_tmp = _iter2, ++_tmp, _tmp == _iter1->cend()) { 74 | _PEs.push_back(Edge(*_iter2, *_iter1->begin())); 75 | continue; 76 | } 77 | _PEs.push_back(Edge(*_iter2, *_tmp)); 78 | } 79 | } 80 | for (auto _iter1 = _PEs.cbegin(); _iter1 != _PEs.cend(); ++_iter1) { 81 | for (auto _iter2 = _iter1; _iter2 != _PEs.cend(); ++_iter2) { 82 | if (_iter1 == _iter2) 83 | continue; 84 | if (segCrs(*_iter1, *_iter2)) 85 | return true; 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | void _check_direction(vector>& _PVs) { 92 | if (!__check_direction(_PVs.cbegin()->cbegin(), _PVs.cbegin()->cend())) { 93 | cerr << "Outer boundary has negative direction, fixed. " << endl; 94 | reverse(_PVs.begin()->begin(), _PVs.begin()->end()); 95 | } 96 | for (auto _iter = ++_PVs.begin(); _iter != _PVs.end(); ++_iter) { 97 | if (__check_direction(_iter->cbegin(), _iter->cend())) { 98 | cerr << "Inner boundary has positive direction, fixed. " << endl; 99 | reverse(_iter->begin(), _iter->end()); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /matlab version/mafce.m: -------------------------------------------------------------------------------- 1 | function [IAVs,VTs] = mafce(BVs,IVs,VStep) 2 | %MAFCE Triangular meshes via Advancing Front Method For Multi-boundary 3 | % function [IAVs,VTs] = mafce(BVs,IVs,VStep) 4 | % BVs is cells with m*2 matrix for boundary vertexes, and IVs is a n*2 matrix 5 | % for inner vertexes. VStep is the stantard step between vertexes. AFCE 6 | % return [vertexes coordination and index, triangles indexes sharing a vertex] 7 | IAVs=[IVs]; 8 | for i=1:length(BVs) 9 | IAVs=[IAVs;BVs{i}]; 10 | end 11 | IAVs=[IAVs,(1:size(IAVs,1))']; % indexed all vertexes(-1: nerver used; >0: usage count; 0: can't be used for out of boundary) 12 | flag=[-1.*ones(size(IVs,1),1);2.*ones(size(IAVs,1)-size(IVs,1),1)]; 13 | IBVs=IAVs(size(IVs,1)+1:end,:); 14 | IAVs=sortrows(IAVs,[2,1]); 15 | FEs=cell(size(IBVs,1),2); % Front Edges 16 | m=1; 17 | n=1; 18 | for i=1:length(BVs) 19 | for j=1:size(BVs{i},1)-1 20 | FEs(m,:)={IBVs(n,:),IBVs(n+1,:)}; 21 | m=m+1; 22 | n=n+1; 23 | end 24 | FEs(m,:)={IBVs(n,:),IBVs(n-size(BVs{i},1)+1,:)}; 25 | m=m+1; 26 | n=n+1; 27 | end 28 | % show progress bar 29 | ptotal=size(IVs,1); 30 | pnow=0; 31 | hwait=waitbar(0,'Calculating...'); 32 | i=1; 33 | while size(FEs,1)>3 34 | waitbar(pnow/ptotal,hwait,['Calculating...',num2str(floor(pnow/ptotal*100)),'%']); 35 | % for t=1:size(FEs,1) 36 | % plot([FEs{t,1}(1),FEs{t,2}(1)],[FEs{t,1}(2),FEs{t,2}(2)],'r-'); 37 | % end % only for debug 38 | % pause(0.1); % only for debug 39 | tri={FEs{1,1},FEs{1,2},afmSearch(FEs{1,1},FEs{1,2},IAVs,FEs,VStep,flag)}; 40 | VTs(i,:)=[tri{1}(3),tri{2}(3),tri{3}(3)]; 41 | % plot([FEs{1,1}(1),FEs{1,2}(1)],[FEs{1,1}(2),FEs{1,2}(2)],'w-'); % only for debug 42 | if flag(tri{3}( 3))==-1 43 | pnow=pnow+1; 44 | end 45 | flag(FEs{1,1}(3))=flag(FEs{1,1}(3))-1; 46 | flag(FEs{1,2}(3))=flag(FEs{1,2}(3))-1; 47 | FEs(1,:)=[]; 48 | j=1; 49 | found=[0,0]; 50 | while j<=size(FEs,1) 51 | if (FEs{j,1}(3)==tri{1}(3)&&FEs{j,2}(3)==tri{3}(3))||(FEs{j,1}(3)==tri{3}(3)&&FEs{j,2}(3)==tri{1}(3)) 52 | % plot([FEs{j,1}(1),FEs{j,2}(1)],[FEs{j,1}(2),FEs{j,2}(2)],'w-'); % only for debug 53 | flag(FEs{j,1}(3))=flag(FEs{j,1}(3))-1; 54 | flag(FEs{j,2}(3))=flag(FEs{j,2}(3))-1; 55 | FEs(j,:)=[]; 56 | found(1)=1; 57 | continue; 58 | end 59 | if (FEs{j,1}(3)==tri{3}(3)&&FEs{j,2}(3)==tri{2}(3))||(FEs{j,1}(3)==tri{2}(3)&&FEs{j,2}(3)==tri{3}(3)) 60 | % plot([FEs{j,1}(1),FEs{j,2}(1)],[FEs{j,1}(2),FEs{j,2}(2)],'w-'); % only for debug 61 | flag(FEs{j,1}(3))=flag(FEs{j,1}(3))-1; 62 | flag(FEs{j,2}(3))=flag(FEs{j,2}(3))-1; 63 | FEs(j,:)=[]; 64 | found(2)=1; 65 | continue; 66 | end 67 | j=j+1; 68 | end 69 | if found(1)==0 70 | FEs(end+1,:)={tri{1},tri{3}}; 71 | flag(FEs{end,1}(3))=flag(FEs{end,1}(3))+1; 72 | if flag(FEs{end,2}(3))==-1 73 | flag(FEs{end,2}(3))=1; 74 | else 75 | flag(FEs{end,2}(3))=flag(FEs{end,2}(3))+1; 76 | end 77 | end 78 | if found(2)==0 79 | FEs(end+1,:)={tri{3},tri{2}}; 80 | flag(FEs{end,2}(3))=flag(FEs{end,2}(3))+1; 81 | if flag(FEs{end,1}(3))==-1 82 | flag(FEs{end,1}(3))=1; 83 | else 84 | flag(FEs{end,1}(3))=flag(FEs{end,1}(3))+1; 85 | end 86 | end 87 | i=i+1; 88 | end 89 | waitbar(1,hwait,'Finishing...'); 90 | tri={FEs{1,1},FEs{1,2},FEs{2,2}}; 91 | VTs(end+1,:)=[tri{1}(3),tri{2}(3),tri{3}(3)]; 92 | close(hwait); 93 | IAVs=sortrows(IAVs,3); 94 | end 95 | -------------------------------------------------------------------------------- /src/format_off.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * format_off.cpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "MAFM.hpp" 32 | 33 | using namespace std; 34 | 35 | namespace { 36 | vector _APVs; 37 | } 38 | 39 | /* 40 | * _path: path of ._off file 41 | * _PVs: polygon vertexes 42 | */ 43 | bool load_off(const std::string &_path, std::vector> &_PVs) { 44 | ifstream _off(_path); 45 | if (!_off) { 46 | cerr << "File: " << _path << " doesn't exist. " << endl; 47 | _off.close(); 48 | return false; 49 | } 50 | 51 | string _line; 52 | stringstream _sline; 53 | unsigned _cv = 0; // count of vertexes 54 | unsigned _cf = 0; // count of faces 55 | double _x = 0; 56 | double _y = 0; 57 | unsigned _count; 58 | unsigned _index; 59 | 60 | if (getline(_off, _line)) { 61 | if (_line != "OFF") { 62 | cerr << "File: " << _path << " isn't _off format. " << endl; 63 | _off.close(); 64 | return false; 65 | } 66 | } else { 67 | cerr << "File: " << _path << " is broken. " << endl; 68 | _off.close(); 69 | return false; 70 | } 71 | if (getline(_off, _line)) { 72 | _sline.str(_line); 73 | _sline >> _cv; 74 | _sline >> _cf; 75 | // Regardless of edges 76 | if (!_sline && !_sline.eof()) { 77 | cerr << "File: " << _path << " is broken. " << endl; 78 | _off.close(); 79 | return false; 80 | } 81 | } else { 82 | cerr << "File: " << _path << " is broken. " << endl; 83 | _off.close(); 84 | return false; 85 | } 86 | for (unsigned i = 0; i < _cv; ++i) { 87 | _sline.clear(); 88 | if (getline(_off, _line)) { 89 | _sline.str(_line); 90 | _sline >> _x; 91 | _sline >> _y; 92 | _APVs.push_back(Point(_x, _y)); 93 | // Regardless of z 94 | if (!_sline && !_sline.eof()) { 95 | cerr << "File: " << _path << " is broken. " << endl; 96 | _off.close(); 97 | return false; 98 | } 99 | } else { 100 | cerr << "File: " << _path << " is broken. " << endl; 101 | _off.close(); 102 | return false; 103 | } 104 | } 105 | for (unsigned i = 0; i < _cf; ++i) { 106 | _sline.clear(); 107 | if (getline(_off, _line)) { 108 | _sline.str(_line); 109 | _sline >> _count; 110 | if (!_sline && !_sline.eof()) { 111 | cerr << "File: " << _path << " is broken. " << endl; 112 | _off.close(); 113 | return false; 114 | } 115 | if (_count < 3) { 116 | cerr << "File: " << _path << " is broken. " << endl; 117 | _off.close(); 118 | return false; 119 | } 120 | _PVs.push_back(vector()); 121 | for (unsigned j = 0; j < _count; ++j) { 122 | if (_sline >> _index) { 123 | _PVs.back().push_back(_APVs.at(_index)); 124 | } else { 125 | cerr << "File: " << _path << " is broken. " << endl; 126 | _off.close(); 127 | return false; 128 | } 129 | } 130 | } else { 131 | cerr << "File: " << _path << " is broken. " << endl; 132 | _off.close(); 133 | return false; 134 | } 135 | } 136 | return true; 137 | } 138 | 139 | void save_OFF(const matrix &_MP, const matrix &_MT, const std::string& _Path) { 140 | ofstream of(_Path, ofstream::trunc); 141 | of << "OFF\n"; 142 | of << _MP.get_size().first << ' ' << _MT.get_size().first << ' ' << 0 143 | << '\n'; 144 | of << _MP.to_string("", "", " ") << '\n'; 145 | of << _MT.to_string("", "", " ") << '\n'; 146 | of.flush(); 147 | of.close(); 148 | } 149 | -------------------------------------------------------------------------------- /src/Advancing-Front-Method_2D.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | 21 | //============================================================================ 22 | // Name : Advancing-Front-Method_2D.cpp 23 | // Author : Guangmu Zhu 24 | // email : guangmuzhu@gmail.com 25 | // Version : 0.1.0 26 | // Copyright : Copyright 2013 27 | // Description : Advancing Front Method for Multi-boundary with 2D 28 | //============================================================================ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include "MAFM.hpp" 35 | 36 | using namespace std; 37 | 38 | int main(int argc, char** argv) { 39 | try { 40 | string path; 41 | cout << "Input File Path: " << flush; 42 | if (cin >> path) { 43 | vector> PVs; 44 | if (load_off(path, PVs)) { 45 | if (!check_off(PVs)) { 46 | cerr << "Bad boundaries. " << endl; 47 | return EXIT_FAILURE; 48 | } 49 | matrix BMXY(2, 2, { PVs.at(0).at(0).x, PVs.at(0).at(0).x, 50 | PVs.at(0).at(0).y, PVs.at(0).at(0).y }); 51 | for (auto iter = ++PVs.cbegin()->cbegin(); 52 | iter != PVs.cbegin()->cend(); ++iter) { 53 | if (iter->x < BMXY(1, 1)) 54 | BMXY(1, 1) = iter->x; 55 | if (iter->x > BMXY(1, 2)) 56 | BMXY(1, 2) = iter->x; 57 | if (iter->y < BMXY(2, 1)) 58 | BMXY(2, 1) = iter->y; 59 | if (iter->y > BMXY(2, 2)) 60 | BMXY(2, 2) = iter->y; 61 | } 62 | double VStep; 63 | cout << "VStep: " << flush; 64 | while (true) { 65 | cin >> VStep; 66 | if (cin) { 67 | if ((BMXY(2, 2) - BMXY(2, 1)) / VStep < 4.5) { 68 | cerr << "Size is too large." << endl; 69 | continue; 70 | } else 71 | break; 72 | } else { 73 | cin.clear(); 74 | } 75 | } 76 | vector BVs = boundary_interpolation(PVs, VStep); 77 | matrix IVs = inner_interpolation(PVs, BMXY, VStep); 78 | IVs = filter_inner_interpolation(BVs, IVs, VStep); 79 | pair result = create_triangles(BVs, IVs, VStep); 80 | double rf = 1, CC = 1e-4, EC = 1e-2; 81 | cin.ignore(1024, '\n'); 82 | cin.clear(); 83 | cout << "Relaxation factor:(default 1) " << flush; 84 | if (cin.peek() != '\n') { 85 | cin >> rf; 86 | } 87 | cin.ignore(1024, '\n'); 88 | cin.clear(); 89 | cout << "Convergence coefficient:(default 1e-4) " << flush; 90 | if (cin.peek() != '\n') { 91 | cin >> CC; 92 | } 93 | cin.ignore(1024, '\n'); 94 | cin.clear(); 95 | cout << "Error coefficient:(default 1e-2) " << flush; 96 | if (cin.peek() != '\n') { 97 | cin >> EC; 98 | } 99 | pair smooth_result = smooth_triangles( 100 | result.first, IVs.get_size().first, result.second, rf, 101 | VStep, CC, EC); 102 | printf("%.2f%% Error\n", smooth_result.second * 100); 103 | cout << "Output File Path: " << flush; 104 | cin.clear(); 105 | if (cin >> path) { 106 | smooth_result.first = smooth_result.first | 3 | matrix(result.first.get_size().first, 1); 107 | result.second = 108 | matrix(result.second.get_size().first, 1).init(3) 109 | | result.second; 110 | save_OFF(smooth_result.first, result.second, path); 111 | } else { 112 | cout << result.first.to_string("", "", " ") << '\n'; 113 | cout << result.second.to_string("", "", " ") << '\n'; 114 | cout << flush; 115 | } 116 | return EXIT_SUCCESS; 117 | } else 118 | return EXIT_FAILURE; 119 | } else 120 | return EXIT_FAILURE; 121 | } catch (exception &e) { 122 | cerr << "Exception occurred: " << e.what() << endl; 123 | return EXIT_FAILURE; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/matlab_fun.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * matlab_fun.cpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include "matlab_fun.hpp" 28 | 29 | using namespace std; 30 | 31 | bool is_zero(double _d) { 32 | return _d > -DERR && _d < DERR; 33 | } 34 | 35 | double det2(const matrix &_mtx) { 36 | if (!_mtx.is_square_matrix() || _mtx.get_length() != 2) 37 | throw std::invalid_argument("det only for 2-order matrix"); 38 | return _mtx(1, 1) * _mtx(2, 2) - _mtx(1, 2) * _mtx(2, 1); 39 | } 40 | 41 | matrix inv2(const matrix &_mtx) { 42 | if (!_mtx.is_square_matrix() || _mtx.get_length() != 2) 43 | throw std::invalid_argument("det only for 2-order matrix"); 44 | if (is_zero(det2(_mtx))) 45 | throw std::invalid_argument("det equals zero"); 46 | return matrix(2, 2, {_mtx(2, 2), -_mtx(1, 2), -_mtx(2, 1), _mtx(1, 1)}) / det2(_mtx); 47 | } 48 | 49 | double det2(const Edge &_e1, const Edge &_e2) { 50 | Point _p1 = _e1.b - _e1.a; 51 | Point _p2 = _e2.b - _e2.a; 52 | return _p1.x * _p2.y - _p2.x * _p1.y; 53 | } 54 | 55 | bool is_leftside(const Point &_p1, const Point &_p2, const Point &_p3) { 56 | if (_p1 == _p3 || _p2 == _p3) 57 | return false; 58 | if ((_p1.y - _p2.y) * _p3.x - (_p1.x - _p2.x) * _p3.y 59 | + (_p1.x * _p2.y - _p2.x * _p1.y) > DERR) 60 | return true; 61 | else 62 | return false; 63 | } 64 | 65 | double mmod(double _d1, double _d2) { 66 | if (_d2 <= 0) 67 | return _d1; 68 | if (_d1 == 0) { 69 | return 0; 70 | } else if (_d1 > 0) { 71 | return fmod(_d1, _d2); 72 | } else { 73 | return _d2 -fmod(-_d1, _d2); 74 | } 75 | } 76 | 77 | matrix linspace(int _bg, int _ed) { 78 | if (_bg == _ed) 79 | return matrix(1, 0); 80 | int _step = (_ed > _bg) ? 1 : -1; 81 | int _count = (_ed > _bg) ? _ed - _bg - 1 : _bg - _ed - 1; 82 | matrix _ret(1, _count); 83 | for (int i = 1; i <= _count; ++i) { 84 | _ret(1, i) = _bg + i * _step; 85 | } 86 | return move(_ret); 87 | } 88 | 89 | matrix linspace_st(double _bg, double _ed, double _step, bool _round) { 90 | double _dc = (_ed - _bg) / _step; 91 | if (_dc < 0) 92 | return matrix(1, 0); 93 | if (_round) { 94 | _dc = round(_dc); 95 | _step = (_ed - _bg) / _dc; 96 | } 97 | unsigned _uc = _dc; 98 | matrix _ret(1, _uc - 1); 99 | for (unsigned i = 1; i < _uc; ++i) { 100 | _ret(1, i) = _bg + i * _step; 101 | } 102 | return move(_ret); 103 | } 104 | 105 | matrix linspace_ct(double _bg, double _ed, unsigned _count) { 106 | double _step = (_ed - _bg) / (_count + 1); 107 | matrix _ret(1, _count); 108 | for (unsigned i = 1; i <= _count; ++i) { 109 | _ret(1, i) = _bg + i * _step; 110 | } 111 | return move(_ret); 112 | } 113 | 114 | double cart2pol(const Point &_p) { 115 | double _x = _p.x; 116 | double _y = _p.y; 117 | double _length = sqrt(pow(_x, 2) + pow(_y, 2)); 118 | double _angle; 119 | double _anglec = acos(_x / _length); 120 | double _angles = asin(_y / _length); 121 | if (_angles > 0) { 122 | _angle = _anglec; 123 | } else { 124 | _angle = 2 * M_PI - _anglec; 125 | } 126 | return _angle; 127 | } 128 | 129 | double cart2pol(double _x, double _y) { 130 | double _length = sqrt(pow(_x, 2) + pow(_y, 2)); 131 | double _angle; 132 | double _anglec = acos(_x / _length); 133 | double _angles = asin(_y / _length); 134 | if (_angles > 0) { 135 | _angle = _anglec; 136 | } else { 137 | _angle = 2 * M_PI - _anglec; 138 | } 139 | return _angle; 140 | } 141 | 142 | void cart2pol(const Point &_p, double &_angle, double &_length) { 143 | double _x = _p.x; 144 | double _y = _p.y; 145 | _length = sqrt(pow(_x, 2) + pow(_y, 2)); 146 | double _anglec = acos(_x / _length); 147 | double _angles = asin(_y / _length); 148 | if (_angles > 0) { 149 | _angle = _anglec; 150 | } else { 151 | _angle = 2 * M_PI - _anglec; 152 | } 153 | return; 154 | } 155 | 156 | void cart2pol(double _x, double _y, double &_angle, double &_length) { 157 | _length = sqrt(pow(_x, 2) + pow(_y, 2)); 158 | double _anglec = acos(_x / _length); 159 | double _angles = asin(_y / _length); 160 | if (_angles > 0) { 161 | _angle = _anglec; 162 | } else { 163 | _angle = 2 * M_PI - _anglec; 164 | } 165 | return; 166 | } 167 | 168 | bool segCrs(const Edge &_e1, const Edge &_e2) { 169 | if (is_zero(det2(_e1, _e2))) 170 | return false; 171 | matrix _ret = matrix (2, 1, {_e1.a.y - _e2.a.y, 172 | _e1.a.x - _e2.a.x}) 173 | / 174 | matrix (2, 2, {_e1.a.y - _e1.b.y, _e2.b.y -_e2.a.y, 175 | _e1.a.x - _e1.b.x, _e2.b.x - _e2.a.x}); 176 | return _ret(1, 1) > DERR && _ret(1, 1) < 1 - DERR && _ret(2, 1) > DERR && _ret(2, 1) < 1 - DERR; 177 | } 178 | 179 | bool segCrs(const Edge &_e1, const Edge &_e2, Point &_p) { 180 | if (is_zero(det2(_e1, _e2))) 181 | return false; 182 | matrix _ret = matrix (2, 1, {_e1.a.y - _e2.a.y, 183 | _e1.a.x - _e2.a.x}) 184 | / 185 | matrix (2, 2, {_e1.a.y - _e1.b.y, _e2.b.y -_e2.a.y, 186 | _e1.a.x - _e1.b.x, _e2.b.x - _e2.a.x}); 187 | _p.x = (_e1.b.x - _e1.a.x) * _ret(1, 1) + _e1.a.x; 188 | _p.y = (_e1.b.y - _e1.a.y) * _ret(1, 1) + _e1.a.y; 189 | return _ret(1, 1) > DERR && _ret(1, 1) < 1 - DERR && _ret(2, 1) > DERR && _ret(2, 1) < 1 - DERR; 190 | } 191 | -------------------------------------------------------------------------------- /src/interpolation.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * interpolation.cpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "MAFM.hpp" 31 | 32 | using namespace std; 33 | 34 | namespace { 35 | matrix linspace(const Point &_p1, const Point &_p2, double _VStep) { 36 | double _dc; 37 | unsigned _uc; 38 | double _tx, _ty; 39 | _dc = _p1.distance(_p2) / _VStep; // 10% error 40 | if (_dc > 4.5) { 41 | _uc = round(_dc); 42 | matrix _ret(_uc - 1, 2); 43 | _tx = (_p2.x - _p1.x) / _uc; 44 | _ty = (_p2.y - _p1.y) / _uc; 45 | for (unsigned i = 1; i < _uc; ++i) { 46 | _ret.assign_row(i, 47 | matrix(1, 2, { _p1.x + i * _tx, _p1.y + i * _ty })); 48 | } 49 | return move(_ret); 50 | } else if (_dc >= 1.8) { 51 | if (_dc < 2.7) { 52 | matrix _ret(1, 2); 53 | _ret.assign_row(1, 54 | matrix(1, 2, { (_p1.x + _p2.x) / 2, (_p1.y + _p2.y) / 2 })); 55 | return move(_ret); 56 | } else if (_dc < 3.6) { 57 | _uc = 3; 58 | matrix _ret(_uc - 1, 2); 59 | _tx = (_p2.x - _p1.x) / _uc; 60 | _ty = (_p2.y - _p1.y) / _uc; 61 | for (unsigned i = 1; i < _uc; ++i) { 62 | _ret.assign_row(i, 63 | matrix(1, 2, { _p1.x + i * _tx, _p1.y + i * _ty })); 64 | } 65 | return move(_ret); 66 | } else { 67 | _uc = 4; 68 | matrix _ret(_uc - 1, 2); 69 | _tx = (_p2.x - _p1.x) / _uc; 70 | _ty = (_p2.y - _p1.y) / _uc; 71 | for (unsigned i = 1; i < _uc; ++i) { 72 | _ret.assign_row(i, 73 | matrix(1, 2, { _p1.x + i * _tx, _p1.y + i * _ty })); 74 | } 75 | return move(_ret); 76 | } 77 | } else { 78 | return matrix(0, 2); 79 | } 80 | } 81 | } 82 | 83 | vector boundary_interpolation( 84 | const std::vector>& _PVs, double _VStep) { 85 | vector _ret; 86 | for (auto _iter1 = _PVs.cbegin(); _iter1 != _PVs.cend(); ++_iter1) { 87 | matrix _mtx(0, 2); 88 | for (auto _iter2 = _iter1->cbegin(), _iter3 = ++_iter1->cbegin(); 89 | _iter3 != _iter1->cend(); ++_iter2, ++_iter3) { 90 | _mtx ^= matrix(1, 2, { _iter2->x, _iter2->y }); 91 | _mtx ^= linspace(*_iter2, *_iter3, _VStep); 92 | } 93 | _mtx ^= matrix(1, 2, { (--_iter1->cend())->x, (--_iter1->cend())->y }); 94 | _mtx ^= linspace(*--_iter1->cend(), *_iter1->cbegin(), _VStep); 95 | _ret.push_back(_mtx); 96 | } 97 | return move(_ret); 98 | } 99 | 100 | matrix inner_interpolation(const std::vector>& _PVs, 101 | const matrix& _BMXY, double _VStep) { 102 | matrix _LYs = linspace_st(_BMXY(2, 1), _BMXY(2, 2), _VStep, true); 103 | matrix _ret(0, 2); 104 | Point _tp; 105 | vector>::const_iterator _iter1; 106 | vector::const_iterator _iter, _iter2, _iter3; 107 | vector _tps; 108 | for (unsigned i = 1; i <= _LYs.get_length(); ++i) { 109 | _tps.clear(); 110 | for (_iter1 = _PVs.cbegin(); _iter1 != _PVs.cend(); ++_iter1) { 111 | for (_iter2 = _iter1->cbegin(), _iter3 = ++_iter1->cbegin(); 112 | _iter3 != _iter1->cend(); ++_iter2, ++_iter3) { 113 | if (segCrs(Edge(*_iter2, *_iter3), 114 | Edge(Point(_BMXY(1, 1) - 1, _LYs(1, i)), 115 | Point(_BMXY(1, 2) + 1, _LYs(1, i))), _tp)) { 116 | _tp.y = _LYs(1, i); 117 | _tps.push_back(_tp); 118 | } 119 | if (_iter3->y == _LYs(1, i)) { 120 | _iter = _iter3; 121 | if (++_iter == _iter1->cend()) { 122 | _iter = _iter1->cbegin(); 123 | } 124 | if ((_iter2->y > _iter3->y && _iter3->y > _iter->y) 125 | || (_iter2->y < _iter3->y && _iter3->y < _iter->y)) { 126 | _tps.push_back(*_iter3); 127 | } 128 | } 129 | } 130 | _iter3 = _iter1->cbegin(); 131 | if (segCrs(Edge(*_iter2, *_iter3), 132 | Edge(Point(_BMXY(1, 1) - 1, _LYs(1, i)), 133 | Point(_BMXY(1, 2) + 1, _LYs(1, i))), _tp)) { 134 | _tp.y = _LYs(1, i); 135 | _tps.push_back(_tp); 136 | } 137 | if (_iter3->y == _LYs(1, i)) { 138 | _iter = _iter3; 139 | ++_iter; 140 | if ((_iter2->y > _iter3->y && _iter3->y > _iter->y) 141 | || (_iter2->y < _iter3->y && _iter3->y < _iter->y)) { 142 | _tps.push_back(*_iter3); 143 | } 144 | } 145 | } 146 | sort(_tps.begin(), _tps.end(), 147 | [](const Point &_p1, const Point &_p2) {return _p1.x < _p2.x;}); 148 | for (_iter2 = _tps.cbegin(), _iter3 = ++_tps.cbegin(); 149 | _iter2 != _tps.cend() && _iter3 != _tps.cend(); 150 | ++++_iter2, ++++_iter3) { 151 | _ret ^= linspace(*_iter2, *_iter3, _VStep); 152 | } 153 | } 154 | return move(_ret); 155 | } 156 | 157 | matrix filter_inner_interpolation(const std::vector &_BVs, 158 | const matrix &_IVs, double _VStep) { 159 | matrix _ret(_IVs); 160 | bool _flag; 161 | for (unsigned i = 1; i <= _ret.get_size().first; ++i) { 162 | _flag = true; 163 | for (auto _iter1 = _BVs.cbegin(); _iter1 != _BVs.cend() && _flag; 164 | ++_iter1) { 165 | for (unsigned j = 1; j <= _iter1->get_size().first; ++j) { 166 | if (Point(_ret(i, 1), _ret(i, 2)).distance( 167 | Point((*_iter1)(j, 1), (*_iter1)(j, 2))) 168 | < 0.9 * _VStep - DERR) { 169 | _ret ^= i; 170 | --i; 171 | _flag = false; 172 | break; 173 | } 174 | } 175 | } 176 | } 177 | return move(_ret); 178 | } 179 | -------------------------------------------------------------------------------- /matlab version/afront.m: -------------------------------------------------------------------------------- 1 | % AFRONT Advancing Front Method 2 | % Author: Guangmu Zhu 3 | % email: guangmuzhu@gmail.com 4 | clc; 5 | clear all; 6 | close all; 7 | %% ginput vertexes for polygon 8 | MXY=input('width and height of polygon[x,y]: '); 9 | figure(1); 10 | hold on; 11 | box on; 12 | axis([0,MXY(1),0,MXY(2)]); 13 | 14 | VX=zeros(1,1); 15 | VY=zeros(1,1); 16 | 17 | InMod=input('Curve or Polygon or File? C/P/F[P]: ','s'); 18 | if isempty(InMod) 19 | InMod='P'; 20 | end 21 | InMod=upper(InMod); 22 | if InMod=='P' 23 | i=1; 24 | while true 25 | [x,y,button]=ginput(1); 26 | if x<0||x>MXY(1)||y<0||y>MXY(2) 27 | continue 28 | end 29 | %{ 30 | [x,y,button] = ginput(...) 31 | return coodinates of x and y 32 | as well as code of button 33 | (1=left, 2=mid, 3=right, otherwise ASCII code) 34 | %} 35 | if button~=1 36 | break; 37 | end 38 | if i>1&&(x==VX(1)&&y==VY(1)) 39 | break; 40 | end 41 | VX(i)=x; 42 | VY(i)=y; 43 | i=i+1; 44 | plot(VX,VY,'r-'); 45 | end 46 | elseif InMod=='C' 47 | VStep=input('Step between vertexes is: '); 48 | % set(gcf,'WindowButtonDownFcn',@LButtonDownFcn); 49 | % set(gcf,'WindowButtonMotionFcn',@LButtonMotionFcn); 50 | % set(gcf,'WindowButtonUpFcn',@LButtonUpFcn); 51 | set(gcf,'WindowButtonDownFcn','LButtonFcn(''down'',VStep)'); 52 | set(gcf,'WindowButtonMotionFcn','LButtonFcn(''move'',VStep)'); 53 | set(gcf,'WindowButtonUpFcn','LButtonFcn(''up'',VStep)'); 54 | disp('Curve finished? Any key to continue...'); 55 | pause; 56 | load('Vs.mat'); 57 | elseif InMod=='F' 58 | file=input('File path: ','s'); 59 | Vs=load(file); 60 | VX=Vs(1,:); 61 | VY=Vs(2,:); 62 | else 63 | fprintf(2,'Error with input!'); 64 | return; 65 | end 66 | if size(VX,2)>2 67 | VX=[VX,VX(1)]; 68 | VY=[VY,VY(1)]; 69 | plot(VX,VY,'r-'); 70 | plot(VX,VY,'b.'); 71 | else 72 | fprintf(2,'More vertexes required!\n'); 73 | return; 74 | end 75 | %% turned to the positive direction 76 | k1=0; 77 | k2=0; 78 | for i=1:size(VX,2)-2 79 | k2=mod(mod(cart2pol(VX(i+2)-VX(i+1),VY(i+2)-VY(i+1)),2*pi)-mod(cart2pol(VX(i+1)-VX(i),VY(i+1)-VY(i)),2*pi),2*pi); 80 | if k2>pi 81 | k2=k2-2*pi; 82 | end 83 | k1=k1+k2; 84 | end 85 | if k1<0 86 | fprintf(2,'negative direction, fixed.\n'); 87 | VX=fliplr(VX); 88 | VY=fliplr(VY); 89 | end 90 | %% check intersecting lines 91 | % if size(VX,2)~=3 92 | % for i=4:size(VX,2)-1 93 | % [IN,ON]=inpolygon(VX(i),VY(i),VX(1:i-1),VY(1:i-1)); 94 | % if ON 95 | % fprintf(2,'Vertex is on lines!\n'); 96 | % return; 97 | % end 98 | % if ~IN 99 | % % concave polygon? 100 | % [IN,ON]=inpolygon(VX(i-1),VY(i-1),VX(1:i-2),VY(1:i-2)); 101 | % if IN 102 | % prefix=-1; 103 | % else 104 | % prefix=1; 105 | % end 106 | % pol1=mod(cart2pol(VX(i-2)-VX(i-1),VY(i-2)-VY(i-1)),2*pi); 107 | % pol2=mod(cart2pol(VX(1)-VX(i-1),VY(1)-VY(i-1)),2*pi); 108 | % pol3=mod(cart2pol(VX(i)-VX(i-1),VY(i)-VY(i-1)),2*pi); 109 | % if prefix*(pol3(1)-pol1(1))*(pol3(1)-pol2(1))<0 110 | % fprintf(2,'Intersecting lines found!\n'); 111 | % return; 112 | % end 113 | % end 114 | % end 115 | % end 116 | 117 | if size(VX,2)~=3 118 | for i=1:size(VX,2)-3 119 | for j=i+2:size(VX,2)-1 120 | if i==1&&j==size(VX,2)-1 121 | continue; 122 | end 123 | if abs(det([VX(i)-VX(i+1),VX(j+1)-VX(j);VY(i)-VY(i+1),VY(j+1)-VY(j)]))1e-8&&k(1)<1-1e-8)&&(k(2)>1e-8&&k(2)<1-1e-8) 128 | fprintf(2,'Intersecting lines found!\n'); 129 | return; 130 | end 131 | end 132 | end 133 | end 134 | %% boundary interpolation 135 | BMXY=[min(VX),max(VX);min(VY),max(VY)]; 136 | while true 137 | VStep=input('Grid size: '); 138 | k=(BMXY(2,2)-BMXY(2,1))/VStep; 139 | if k>=4.5 % 10% error of VStep between vertexes is allowed 140 | k=round(k); 141 | break; 142 | else 143 | fprintf(2,'Size is too large.\n'); 144 | end 145 | end 146 | LYs=BMXY(2,1):(BMXY(2,2)-BMXY(2,1))/k:BMXY(2,2); 147 | BVs=[0,0]; % Boundary Vertexes 148 | for i=1:size(VX,2)-1 149 | BVs=[BVs;VX(i),VY(i)]; 150 | k=sqrt((VX(i)-VX(i+1))^2+(VY(i)-VY(i+1))^2)/VStep; 151 | if k>=4.5 % 10% error of VStep between vertexes is allowed 152 | k=round(k); 153 | tmp1=linspace(VX(i),VX(i+1),k+1); 154 | tmp2=linspace(VY(i),VY(i+1),k+1); 155 | BVs=[BVs;[tmp1(2:end-1);tmp2(2:end-1)]']; 156 | elseif k>=1.8 % 90% VStep between vertexes is allowed 157 | if k<2.7 158 | BVs=[BVs;(VX(i)+VX(i+1))/2,(VY(i)+VY(i+1))/2]; 159 | elseif k<3.6 160 | tmp1=linspace(VX(i),VX(i+1),4); 161 | tmp2=linspace(VY(i),VY(i+1),4); 162 | BVs=[BVs;[tmp1(2:end-1);tmp2(2:end-1)]']; 163 | else 164 | tmp1=linspace(VX(i),VX(i+1),5); 165 | tmp2=linspace(VY(i),VY(i+1),5); 166 | BVs=[BVs;[tmp1(2:end-1);tmp2(2:end-1)]']; 167 | end 168 | else 169 | continue; 170 | end 171 | end 172 | BVs(1,:)=[]; 173 | plot(BVs(:,1),BVs(:,2),'k.'); 174 | %% inner interpolation 175 | IBVs=[0,0,0,0]; % Indexed Boundary Vertexes for inner interpolation:[Y index, Edge vertex index, X, Y] 176 | for i=2:size(LYs,2)-1 177 | for j=1:size(VX,2)-1 178 | k=(LYs(i)-VY(j))/(VY(j+1)-VY(j)); 179 | if k>1e-8&&k<1-1e-8 180 | IBVs=[IBVs;i,j,(VX(j+1)-VX(j))*k+VX(j),LYs(i)]; 181 | elseif k>-1e-8&&k<1e-8 % k==0 should be taken into consideration 182 | if j==1 183 | if (VY(2)-VY(1))*(VY(1)-VY(end-1))>0 184 | IBVs=[IBVs;i,(VX(j+1)-VX(j))*k+VX(j),LYs(i)]; 185 | end 186 | else 187 | if (VY(j+1)-VY(j))*(VY(j)-VY(j-1))>0 188 | IBVs=[IBVs;i,(VX(j+1)-VX(j))*k+VX(j),LYs(i)]; 189 | end 190 | end 191 | end 192 | end 193 | end 194 | IBVs(1,:)=[]; 195 | IBVs=sortrows(IBVs,[1,3]); 196 | IVs=[0,0]; % Inner Vertexex 197 | for i=1:2:size(IBVs,1)-1 198 | k=(IBVs(i+1,3)-IBVs(i,3))/VStep; 199 | if k>=4.5 % 10% error of VStep between vertexes is allowed 200 | k=round(k); 201 | tmp=linspace(IBVs(i,3),IBVs(i+1,3),k+1); 202 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,k-1)]']; 203 | elseif k>=1.8 % 90% VStep between vertexes is allowed 204 | if k<2.7 205 | IVs=[IVs;(IBVs(i,3)+IBVs(i+1,3))/2,LYs(IBVs(i,1))]; 206 | elseif k<3.6 207 | tmp=linspace(IBVs(i,3),IBVs(i+1,3),4); 208 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,2)]']; 209 | else 210 | tmp=linspace(IBVs(i,3),IBVs(i+1,3),5); 211 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,3)]']; 212 | end 213 | else 214 | continue; 215 | end 216 | end 217 | IVs(1,:)=[]; 218 | i=1; 219 | while i<=size(IVs,1) 220 | for j=1:size(BVs,1) 221 | if sqrt((IVs(i,1)-BVs(j,1))^2+(IVs(i,2)-BVs(j,2))^2)<0.9*VStep 222 | IVs(i,:)=[]; 223 | i=i-1; 224 | break; 225 | end 226 | end 227 | i=i+1; 228 | end 229 | IVs=sortrows(IVs,[2,1]); 230 | plot(IVs(:,1),IVs(:,2),'k.'); 231 | %% create elements 232 | % IAVs: [ x, y, node index] 233 | % ITs: [ node index, node index, node index ] 234 | [IAVs,ITs]=afce(BVs,IVs,VStep); 235 | for i=1:size(ITs,1) 236 | plot([IAVs(ITs(i,1),1),IAVs(ITs(i,2),1),IAVs(ITs(i,3),1),IAVs(ITs(i,1),1)],[IAVs(ITs(i,1),2),IAVs(ITs(i,2),2),IAVs(ITs(i,3),2),IAVs(ITs(i,1),2)],'r-'); 237 | end 238 | %% smooth triangles 239 | figure(2); 240 | hold on; 241 | box on; 242 | axis([0,MXY(1),0,MXY(2)]); 243 | rf=[]; 244 | if isempty(rf)||rf<0 245 | rf=input('Relaxation factor:(>0) '); 246 | end 247 | [SIAVs,err]=triSmooth(IAVs,size(IVs,1),ITs,rf,VStep,1e-4,1e-2); 248 | fprintf('%.2f%% Error\n',err*100); 249 | for i=1:size(ITs,1) 250 | plot([SIAVs(ITs(i,1),1),SIAVs(ITs(i,2),1),SIAVs(ITs(i,3),1),SIAVs(ITs(i,1),1)],[SIAVs(ITs(i,1),2),SIAVs(ITs(i,2),2),SIAVs(ITs(i,3),2),SIAVs(ITs(i,1),2)],'r-'); 251 | end -------------------------------------------------------------------------------- /matlab version/mafront.m: -------------------------------------------------------------------------------- 1 | % MAFRONT Advancing Front Method For Multi-boundary 2 | % Author: Guangmu Zhu 3 | % email: guangmuzhu@gmail.com 4 | % 2013/05/14 5 | 6 | clc; 7 | clear all; 8 | close all; 9 | %% ginput vertexes for polygon 10 | MXY=input('width and height of polygon[x,y]: '); 11 | figure(1); 12 | hold on; 13 | box on; 14 | axis([0,MXY(1),0,MXY(2)]); 15 | 16 | InMod=input('Plot polygon or File? P/F[P]: ','s'); 17 | if isempty(InMod) 18 | InMod='P'; 19 | end 20 | InMod=upper(InMod); 21 | VX=cell(0,0); 22 | VY=cell(0,0); 23 | if InMod=='P' 24 | fprintf('Right click is to close boundary, and middle click or any key to finish input.\nThe first boundary must be the outer boundary.\n'); 25 | i=1; 26 | while true 27 | if length(VX)MXY(1)||y<0||y>MXY(2) 33 | continue 34 | end 35 | %{ 36 | [x,y,button] = ginput(...) 37 | return coodinates of x and y 38 | as well as code of button 39 | (1=left, 2=mid, 3=right, otherwise ASCII code) 40 | %} 41 | if button==3 42 | VX{i}=[VX{i},VX{i}(1)]; 43 | VY{i}=[VY{i},VY{i}(1)]; 44 | plot(VX{i},VY{i},'r-'); 45 | i=i+1; 46 | continue; 47 | end 48 | if button==2 || button>3 49 | if length(VX)pi 87 | k2=k2-2*pi; 88 | end 89 | k1=k1+k2; 90 | end 91 | if i==1&&k1<0 92 | fprintf(2,'Outer boundary has negative direction, fixed.\n'); 93 | VX{i}=fliplr(VX{i}); 94 | VY{i}=fliplr(VY{i}); 95 | elseif i>1&&k1>0 96 | fprintf(2,'Inner boundary has positive direction, fixed.\n'); 97 | VX{i}=fliplr(VX{i}); 98 | VY{i}=fliplr(VY{i}); 99 | end 100 | end 101 | %% check intersecting lines 102 | for m=1:length(VX) 103 | for i=1:length(VX{m})-1 104 | for n=m:length(VX) 105 | for j=1:1:length(VX{n})-1 106 | if m==n&&j<=i 107 | continue; 108 | end 109 | if abs(det([VX{m}(i)-VX{m}(i+1),VX{n}(j+1)-VX{n}(j);VY{m}(i)-VY{m}(i+1),VY{n}(j+1)-VY{n}(j)]))1e-8&&k(1)<1-1e-8)&&(k(2)>1e-8&&k(2)<1-1e-8) 114 | fprintf(2,'Intersecting lines found!\n'); 115 | return; 116 | end 117 | end 118 | end 119 | end 120 | end 121 | %% boundary interpolation 122 | BMXY=[min(VX{1}),max(VX{1});min(VY{1}),max(VY{1})]; 123 | while true 124 | VStep=input('Grid size: '); 125 | k=(BMXY(2,2)-BMXY(2,1))/VStep; 126 | if k>=4.5 % 10% error of VStep between vertexes is allowed 127 | k=round(k); 128 | break; 129 | else 130 | fprintf(2,'Size is too large.\n'); 131 | end 132 | end 133 | LYs=BMXY(2,1):(BMXY(2,2)-BMXY(2,1))/k:BMXY(2,2); 134 | % BVs: Boundary Vertexes 135 | for i=1:length(VX) 136 | BVs(i)={[]}; 137 | for j=1:length(VX{i})-1 138 | BVs{i}=[BVs{i};VX{i}(j),VY{i}(j)]; 139 | k=sqrt((VX{i}(j)-VX{i}(j+1))^2+(VY{i}(j)-VY{i}(j+1))^2)/VStep; 140 | if k>=4.5 % 10% error of VStep between vertexes is allowed 141 | k=round(k); 142 | tmp1=linspace(VX{i}(j),VX{i}(j+1),k+1); 143 | tmp2=linspace(VY{i}(j),VY{i}(j+1),k+1); 144 | BVs{i}=[BVs{i};[tmp1(2:end-1);tmp2(2:end-1)]']; 145 | elseif k>=1.8 % 90% VStep between vertexes is allowed 146 | if k<2.7 147 | BVs{i}=[BVs{i};(VX{i}(j)+VX{i}(j+1))/2,(VY{i}(j)+VY{i}(j+1))/2]; 148 | elseif k<3.6 149 | tmp1=linspace(VX{i}(j),VX{i}(j+1),4); 150 | tmp2=linspace(VY{i}(j),VY{i}(j+1),4); 151 | BVs{i}=[BVs{i};[tmp1(2:end-1);tmp2(2:end-1)]']; 152 | else 153 | tmp1=linspace(VX{i}(j),VX{i}(j+1),5); 154 | tmp2=linspace(VY{i}(j),VY{i}(j+1),5); 155 | BVs{i}=[BVs{i};[tmp1(2:end-1);tmp2(2:end-1)]']; 156 | end 157 | else 158 | continue; 159 | end 160 | end 161 | end 162 | for i=1:length(BVs) 163 | plot(BVs{i}(:,1),BVs{i}(:,2),'k.'); 164 | end 165 | %% inner interpolation 166 | IBVs=[0,0,0]; % Indexed Boundary Vertexes for inner interpolation:[Y index of LYs, X, Y] 167 | for i=2:length(LYs)-1 168 | for m=1:length(VX) 169 | for j=1:length(VX{m})-1 170 | k=(LYs(i)-VY{m}(j))/(VY{m}(j+1)-VY{m}(j)); 171 | if k>1e-8&&k<1-1e-8 172 | IBVs=[IBVs;i,(VX{m}(j+1)-VX{m}(j))*k+VX{m}(j),LYs(i)]; 173 | elseif k>-1e-8&&k<1e-8 % k==0 should be taken into consideration 174 | if j==1 175 | if (VY{m}(2)-VY{m}(1))*(VY{m}(1)-VY{m}(end-1))>0 176 | IBVs=[IBVs;i,(VX{m}(j+1)-VX{m}(j))*k+VX{m}(j),LYs(i)]; 177 | end 178 | else 179 | if (VY{m}(j+1)-VY{m}(j))*(VY{m}(j)-VY{m}(j-1))>0 180 | IBVs=[IBVs;i,(VX{m}(j+1)-VX{m}(j))*k+VX{m}(j),LYs(i)]; 181 | end 182 | end 183 | end 184 | end 185 | end 186 | end 187 | IBVs(1,:)=[]; 188 | IBVs=sortrows(IBVs,[1,2]); 189 | IVs=[0,0]; % Inner Vertexex 190 | for i=1:2:size(IBVs,1)-1 191 | k=(IBVs(i+1,2)-IBVs(i,2))/VStep; 192 | if k>=4.5 % 10% error of VStep between vertexes is allowed 193 | k=round(k); 194 | tmp=linspace(IBVs(i,2),IBVs(i+1,2),k+1); 195 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,k-1)]']; 196 | elseif k>=1.8 % 90% VStep between vertexes is allowed 197 | if k<2.7 198 | IVs=[IVs;(IBVs(i,2)+IBVs(i+1,2))/2,LYs(IBVs(i,1))]; 199 | elseif k<3.6 200 | tmp=linspace(IBVs(i,2),IBVs(i+1,2),4); 201 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,2)]']; 202 | else 203 | tmp=linspace(IBVs(i,2),IBVs(i+1,2),5); 204 | IVs=[IVs;[tmp(2:end-1);repmat(LYs(IBVs(i,1)),1,3)]']; 205 | end 206 | else 207 | continue; 208 | end 209 | end 210 | IVs(1,:)=[]; 211 | i=1; 212 | while i<=size(IVs,1) 213 | label=false; 214 | for m=1:length(BVs) 215 | for j=1:length(BVs{m}) 216 | if sqrt((IVs(i,1)-BVs{m}(j,1))^2+(IVs(i,2)-BVs{m}(j,2))^2)<0.9*VStep 217 | IVs(i,:)=[]; 218 | label=true; 219 | i=i-1; 220 | break; 221 | end 222 | end 223 | if label 224 | break; 225 | end 226 | end 227 | i=i+1; 228 | end 229 | IVs=sortrows(IVs,[2,1]); 230 | plot(IVs(:,1),IVs(:,2),'k.'); 231 | %% create elements 232 | % IAVs: [ x, y, node index] 233 | % ITs: [ node index, node index, node index ] 234 | [IAVs,ITs]=mafce(BVs,IVs,VStep); 235 | for i=1:size(ITs,1) 236 | plot([IAVs(ITs(i,1),1),IAVs(ITs(i,2),1),IAVs(ITs(i,3),1),IAVs(ITs(i,1),1)],[IAVs(ITs(i,1),2),IAVs(ITs(i,2),2),IAVs(ITs(i,3),2),IAVs(ITs(i,1),2)],'r-'); 237 | end 238 | %% smooth triangles 239 | figure(2); 240 | hold on; 241 | box on; 242 | axis([0,MXY(1),0,MXY(2)]); 243 | rf=[]; 244 | if isempty(rf)||rf<0 245 | rf=input('Relaxation factor:(>0) '); 246 | end 247 | [SIAVs,err]=triSmooth(IAVs,size(IVs,1),ITs,rf,VStep,1e-4,1e-2); 248 | fprintf('%.2f%% Error\n',err*100); 249 | for i=1:size(ITs,1) 250 | plot([SIAVs(ITs(i,1),1),SIAVs(ITs(i,2),1),SIAVs(ITs(i,3),1),SIAVs(ITs(i,1),1)],[SIAVs(ITs(i,1),2),SIAVs(ITs(i,2),2),SIAVs(ITs(i,3),2),SIAVs(ITs(i,1),2)],'r-'); 251 | end -------------------------------------------------------------------------------- /src/create_tri.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * create_tri.cpp 22 | * 23 | * Created on: May 23, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "MAFM.hpp" 31 | 32 | using namespace std; 33 | 34 | namespace { 35 | matrix _IAVs; 36 | deque> _AFEs; 37 | matrix _flag; 38 | matrix _TRI(0, 3); 39 | 40 | matrix _map; // index->line num 41 | 42 | unsigned progress = 0, total, percent = 0; 43 | } 44 | 45 | bool _search_segCrs(const Point&, const Point&, const Point&); 46 | 47 | unsigned _tri_search(const IPoint&, const IPoint&, double); 48 | 49 | unsigned _tri_search(const IEdge&, double); 50 | 51 | void _check_edges(deque&); 52 | 53 | void _create_triangles(double); 54 | 55 | pair create_triangles(const vector &_BVs, 56 | const matrix& _IVs, double _VStep) { 57 | total = _IVs.get_size().first; 58 | 59 | unsigned _cm = 0; 60 | vector::const_iterator _iter; 61 | for (_iter = _BVs.cbegin(); _iter != _BVs.cend(); ++_iter) { 62 | _cm += _iter->get_size().first; 63 | } 64 | _IAVs = matrix(_cm + _IVs.get_size().first, 2); 65 | _IAVs.assign_row(1, _IVs.get_size().first, _IVs); 66 | for (_cm = _IVs.get_size().first + 1, _iter = _BVs.cbegin(); 67 | _iter != _BVs.cend(); _cm += _iter->get_size().first, ++_iter) { 68 | _IAVs.assign_row(_cm, _cm + _iter->get_size().first - 1, *_iter); 69 | } 70 | _IAVs |= !linspace(0, _IAVs.get_size().first + 1); 71 | _flag = 72 | matrix( 73 | matrix(1, _IVs.get_size().first).init(-1) 74 | | matrix(1, 75 | _IAVs.get_size().first 76 | - _IVs.get_size().first).init(2)); 77 | matrix _IBVs( 78 | _IAVs(_IVs.get_size().first + 1, _IAVs.get_size().first, "row")); 79 | _IAVs.sort_row(matrix(1, 2, { 2, 1 })); 80 | _map = _IAVs(3, "col") | !linspace(0, _IAVs.get_size().first + 1); 81 | _map.sort_row(matrix(1, 1, { 1 })); 82 | _map |= 1; 83 | for (unsigned m = 1, i = 0; i < _BVs.size(); ++i) { 84 | _AFEs.push_back(deque()); 85 | for (unsigned j = 1; j < _BVs.at(i).get_size().first; ++j) { 86 | _AFEs.back().push_back( 87 | IEdge(IPoint(_IBVs(m, 1), _IBVs(m, 2), _IBVs(m, 3)), 88 | IPoint(_IBVs(m + 1, 1), _IBVs(m + 1, 2), 89 | _IBVs(m + 1, 3)))); 90 | ++m; 91 | } 92 | _AFEs.back().push_back( 93 | IEdge(IPoint(_IBVs(m, 1), _IBVs(m, 2), _IBVs(m, 3)), 94 | IPoint(_IBVs(m - _BVs.at(i).get_size().first + 1, 1), 95 | _IBVs(m - _BVs.at(i).get_size().first + 1, 2), 96 | _IBVs(m - _BVs.at(i).get_size().first + 1, 97 | 3)))); 98 | ++m; 99 | } 100 | printf("Progress: 0%%...\b\b\b\b"); 101 | fflush(stdout); 102 | _create_triangles(_VStep); 103 | printf("\b\b\b\b\b\b\b\b\b\b\b\b\bFinishing.\n"); 104 | fflush(stdout); 105 | for (unsigned i = 1; i <= _TRI.get_size().first; ++i) { 106 | for (unsigned j = 1; j <= 3; ++j) { 107 | _TRI(i, j) = _IAVs(_TRI(i, j), 3); 108 | } 109 | } 110 | _IAVs.sort_row(matrix({1, 1, {3}})); 111 | return make_pair(_IAVs, _TRI); 112 | } 113 | 114 | void _create_triangles(double _VStep) { 115 | unsigned _count; 116 | 117 | unsigned _index; 118 | 119 | Edge _e1, _e2, _e3, _e4; 120 | 121 | while (true) { 122 | while (_AFEs.size() > 0 && _AFEs.front().size() == 0) 123 | _AFEs.pop_front(); 124 | if (_AFEs.size() == 0) 125 | break; 126 | for (auto _iter = _AFEs.begin(); _iter != _AFEs.end(); ++_iter) { 127 | deque &_FEs = *_iter; 128 | _count = _FEs.size(); 129 | for (unsigned c = 1; c <= _count && _FEs.size() > 0; ++c) { 130 | _index = _tri_search(_FEs.front(), _VStep); 131 | _TRI ^= matrix(1, 3, 132 | { _map(_FEs.front().a.index, 1), _map(_FEs.front().b.index, 133 | 1), _index }); // line num 134 | if (_flag(1, _IAVs(_index, 3)) == -1) { 135 | ++progress; 136 | if (progress * 100 / total > percent) { 137 | percent = progress * 100 / total; 138 | printf("\b\b\b%3u", percent); 139 | fflush(stdout); 140 | } 141 | } 142 | --_flag(1, _FEs.front().a.index); 143 | --_flag(1, _FEs.front().b.index); 144 | _FEs.pop_front(); 145 | _check_edges(_FEs); 146 | } 147 | } 148 | } 149 | } 150 | 151 | bool _search_segCrs(const Point &_p1, const Point &_p2, const Point &_p3) { 152 | for (auto _iter1 = _AFEs.cbegin(); _iter1 != _AFEs.cend(); ++_iter1) { 153 | for (auto _iter2 = _iter1->cbegin(); _iter2 != _iter1->cend(); 154 | ++_iter2) { 155 | if (segCrs(Edge(_p1, _p3), *_iter2) 156 | || segCrs(Edge(_p2, _p3), *_iter2)) 157 | return true; 158 | } 159 | } 160 | return false; 161 | } 162 | 163 | unsigned _tri_search(const IPoint &_p1, const IPoint &_p2, double _VStep) { 164 | matrix _MXY(2, 2, 165 | { fmin(_p1.x, _p2.x) - 2 * _VStep, fmax(_p1.x, _p2.x) + 2 * _VStep, 166 | fmin(_p1.y, _p2.y) - 2 * _VStep, fmax(_p1.y, _p2.y) 167 | + 2 * _VStep }); 168 | unsigned _index, _ret = 0; 169 | for (_index = 1; 170 | _index <= _IAVs.get_size().first && _IAVs(_index, 2) < _MXY(2, 1); 171 | ++_index) 172 | ; 173 | double _min_dist = 2 * pow((3 * _VStep), 2), _curr_dist; 174 | while (_index <= _IAVs.get_size().first && _IAVs(_index, 2) <= _MXY(2, 2)) { 175 | if (_IAVs(_index, 1) >= _MXY(1, 1) && _IAVs(_index, 1) <= _MXY(1, 2) 176 | && _flag(1, _IAVs(_index, 3)) != 0 177 | && !_search_segCrs(_p1, _p2, 178 | Point(_IAVs(_index, 1), _IAVs(_index, 2))) 179 | && is_leftside(_p1, _p2, 180 | IPoint(_IAVs(_index, 1), _IAVs(_index, 2), 181 | _IAVs(_index, 3)))) { 182 | _curr_dist = pow(_IAVs(_index, 1) - _p1.x, 2) 183 | + pow(_IAVs(_index, 2) - _p1.y, 2) 184 | + pow(_IAVs(_index, 1) - _p2.x, 2) 185 | + pow(_IAVs(_index, 2) - _p2.y, 2); 186 | if (_min_dist >= _curr_dist) { 187 | _min_dist = _curr_dist; 188 | _ret = _index; 189 | } 190 | } 191 | ++_index; 192 | } 193 | return _ret; 194 | } 195 | 196 | unsigned _tri_search(const IEdge &_eg, double _VStep) { 197 | return _tri_search(_eg.a, _eg.b, _VStep); 198 | } 199 | 200 | void _check_edges(deque& _FEs) { 201 | bool _found[2] { false, false }; 202 | unsigned _last_TRi = _TRI.get_size().first; 203 | for (auto _iter1 = _AFEs.begin(); _iter1 != _AFEs.end(); ++_iter1) { 204 | for (auto _iter2 = _iter1->begin(); _iter2 != _iter1->end(); ++_iter2) { 205 | if ((_map(_iter2->a.index, 1) == _TRI(_last_TRi, 1) 206 | && _map(_iter2->b.index, 1) == _TRI(_last_TRi, 3)) 207 | || (_map(_iter2->a.index, 1) == _TRI(_last_TRi, 3) 208 | && _map(_iter2->b.index, 1) == _TRI(_last_TRi, 1))) { 209 | --_flag(1, _iter2->a.index); 210 | --_flag(1, _iter2->b.index); 211 | _iter2 = _iter1->erase(_iter2); 212 | --_iter2; 213 | _found[0] = true; 214 | continue; 215 | } 216 | if ((_map(_iter2->a.index, 1) == _TRI(_last_TRi, 2) 217 | && _map(_iter2->b.index, 1) == _TRI(_last_TRi, 3)) 218 | || (_map(_iter2->a.index, 1) == _TRI(_last_TRi, 3) 219 | && _map(_iter2->b.index, 1) == _TRI(_last_TRi, 2))) { 220 | --_flag(1, _iter2->a.index); 221 | --_flag(1, _iter2->b.index); 222 | _iter2 = _iter1->erase(_iter2); 223 | --_iter2; 224 | _found[1] = true; 225 | continue; 226 | } 227 | } 228 | } 229 | if (_found[0] == 0) { 230 | _FEs.push_back( 231 | IEdge( 232 | IPoint(_IAVs(_TRI(_last_TRi, 1), 1), 233 | _IAVs(_TRI(_last_TRi, 1), 2), 234 | _IAVs(_TRI(_last_TRi, 1), 3)), 235 | IPoint(_IAVs(_TRI(_last_TRi, 3), 1), 236 | _IAVs(_TRI(_last_TRi, 3), 2), 237 | _IAVs(_TRI(_last_TRi, 3), 3)))); 238 | ++_flag(1, _IAVs(_TRI(_last_TRi, 1), 3)); 239 | if (_flag(1, _IAVs(_TRI(_last_TRi, 3), 3)) == -1) { 240 | _flag(1, _IAVs(_TRI(_last_TRi, 3), 3)) = 1; 241 | } else { 242 | ++_flag(1, _IAVs(_TRI(_last_TRi, 3), 3)); 243 | } 244 | } 245 | if (_found[1] == 0) { 246 | _FEs.push_back( 247 | IEdge( 248 | IPoint(_IAVs(_TRI(_last_TRi, 3), 1), 249 | _IAVs(_TRI(_last_TRi, 3), 2), 250 | _IAVs(_TRI(_last_TRi, 3), 3)), 251 | IPoint(_IAVs(_TRI(_last_TRi, 2), 1), 252 | _IAVs(_TRI(_last_TRi, 2), 2), 253 | _IAVs(_TRI(_last_TRi, 2), 3)))); 254 | ++_flag(1, _IAVs(_TRI(_last_TRi, 2), 3)); 255 | if (_flag(1, _IAVs(_TRI(_last_TRi, 3), 3)) == -1) { 256 | _flag(1, _IAVs(_TRI(_last_TRi, 3), 3)) = 1; 257 | } else { 258 | ++_flag(1, _IAVs(_TRI(_last_TRi, 3), 3)); 259 | } 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2012-01-06.18; # UTC 5 | 6 | # Copyright (C) 1996-2012 Free Software Foundation, Inc. 7 | # Originally by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | run=: 33 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 34 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 35 | 36 | # In the cases where this matters, 'missing' is being run in the 37 | # srcdir already. 38 | if test -f configure.ac; then 39 | configure_ac=configure.ac 40 | else 41 | configure_ac=configure.in 42 | fi 43 | 44 | msg="missing on your system" 45 | 46 | case $1 in 47 | --run) 48 | # Try to run requested program, and just exit if it succeeds. 49 | run= 50 | shift 51 | "$@" && exit 0 52 | # Exit code 63 means version mismatch. This often happens 53 | # when the user try to use an ancient version of a tool on 54 | # a file that requires a minimum version. In this case we 55 | # we should proceed has if the program had been absent, or 56 | # if --run hadn't been passed. 57 | if test $? = 63; then 58 | run=: 59 | msg="probably too old" 60 | fi 61 | ;; 62 | 63 | -h|--h|--he|--hel|--help) 64 | echo "\ 65 | $0 [OPTION]... PROGRAM [ARGUMENT]... 66 | 67 | Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 68 | error status if there is no known handling for PROGRAM. 69 | 70 | Options: 71 | -h, --help display this help and exit 72 | -v, --version output version information and exit 73 | --run try to run the given command, and emulate it if it fails 74 | 75 | Supported PROGRAM values: 76 | aclocal touch file 'aclocal.m4' 77 | autoconf touch file 'configure' 78 | autoheader touch file 'config.h.in' 79 | autom4te touch the output file, or create a stub one 80 | automake touch all 'Makefile.in' files 81 | bison create 'y.tab.[ch]', if possible, from existing .[ch] 82 | flex create 'lex.yy.c', if possible, from existing .c 83 | help2man touch the output file 84 | lex create 'lex.yy.c', if possible, from existing .c 85 | makeinfo touch the output file 86 | yacc create 'y.tab.[ch]', if possible, from existing .[ch] 87 | 88 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 89 | 'g' are ignored when checking the name. 90 | 91 | Send bug reports to ." 92 | exit $? 93 | ;; 94 | 95 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 96 | echo "missing $scriptversion (GNU Automake)" 97 | exit $? 98 | ;; 99 | 100 | -*) 101 | echo 1>&2 "$0: Unknown '$1' option" 102 | echo 1>&2 "Try '$0 --help' for more information" 103 | exit 1 104 | ;; 105 | 106 | esac 107 | 108 | # normalize program name to check for. 109 | program=`echo "$1" | sed ' 110 | s/^gnu-//; t 111 | s/^gnu//; t 112 | s/^g//; t'` 113 | 114 | # Now exit if we have it, but it failed. Also exit now if we 115 | # don't have it and --version was passed (most likely to detect 116 | # the program). This is about non-GNU programs, so use $1 not 117 | # $program. 118 | case $1 in 119 | lex*|yacc*) 120 | # Not GNU programs, they don't have --version. 121 | ;; 122 | 123 | *) 124 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 125 | # We have it, but it failed. 126 | exit 1 127 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 128 | # Could not run --version or --help. This is probably someone 129 | # running '$TOOL --version' or '$TOOL --help' to check whether 130 | # $TOOL exists and not knowing $TOOL uses missing. 131 | exit 1 132 | fi 133 | ;; 134 | esac 135 | 136 | # If it does not exist, or fails to run (possibly an outdated version), 137 | # try to emulate it. 138 | case $program in 139 | aclocal*) 140 | echo 1>&2 "\ 141 | WARNING: '$1' is $msg. You should only need it if 142 | you modified 'acinclude.m4' or '${configure_ac}'. You might want 143 | to install the Automake and Perl packages. Grab them from 144 | any GNU archive site." 145 | touch aclocal.m4 146 | ;; 147 | 148 | autoconf*) 149 | echo 1>&2 "\ 150 | WARNING: '$1' is $msg. You should only need it if 151 | you modified '${configure_ac}'. You might want to install the 152 | Autoconf and GNU m4 packages. Grab them from any GNU 153 | archive site." 154 | touch configure 155 | ;; 156 | 157 | autoheader*) 158 | echo 1>&2 "\ 159 | WARNING: '$1' is $msg. You should only need it if 160 | you modified 'acconfig.h' or '${configure_ac}'. You might want 161 | to install the Autoconf and GNU m4 packages. Grab them 162 | from any GNU archive site." 163 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 164 | test -z "$files" && files="config.h" 165 | touch_files= 166 | for f in $files; do 167 | case $f in 168 | *:*) touch_files="$touch_files "`echo "$f" | 169 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 170 | *) touch_files="$touch_files $f.in";; 171 | esac 172 | done 173 | touch $touch_files 174 | ;; 175 | 176 | automake*) 177 | echo 1>&2 "\ 178 | WARNING: '$1' is $msg. You should only need it if 179 | you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'. 180 | You might want to install the Automake and Perl packages. 181 | Grab them from any GNU archive site." 182 | find . -type f -name Makefile.am -print | 183 | sed 's/\.am$/.in/' | 184 | while read f; do touch "$f"; done 185 | ;; 186 | 187 | autom4te*) 188 | echo 1>&2 "\ 189 | WARNING: '$1' is needed, but is $msg. 190 | You might have modified some files without having the 191 | proper tools for further handling them. 192 | You can get '$1' as part of Autoconf from any GNU 193 | archive site." 194 | 195 | file=`echo "$*" | sed -n "$sed_output"` 196 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 197 | if test -f "$file"; then 198 | touch $file 199 | else 200 | test -z "$file" || exec >$file 201 | echo "#! /bin/sh" 202 | echo "# Created by GNU Automake missing as a replacement of" 203 | echo "# $ $@" 204 | echo "exit 0" 205 | chmod +x $file 206 | exit 1 207 | fi 208 | ;; 209 | 210 | bison*|yacc*) 211 | echo 1>&2 "\ 212 | WARNING: '$1' $msg. You should only need it if 213 | you modified a '.y' file. You may need the Bison package 214 | in order for those modifications to take effect. You can get 215 | Bison from any GNU archive site." 216 | rm -f y.tab.c y.tab.h 217 | if test $# -ne 1; then 218 | eval LASTARG=\${$#} 219 | case $LASTARG in 220 | *.y) 221 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 222 | if test -f "$SRCFILE"; then 223 | cp "$SRCFILE" y.tab.c 224 | fi 225 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 226 | if test -f "$SRCFILE"; then 227 | cp "$SRCFILE" y.tab.h 228 | fi 229 | ;; 230 | esac 231 | fi 232 | if test ! -f y.tab.h; then 233 | echo >y.tab.h 234 | fi 235 | if test ! -f y.tab.c; then 236 | echo 'main() { return 0; }' >y.tab.c 237 | fi 238 | ;; 239 | 240 | lex*|flex*) 241 | echo 1>&2 "\ 242 | WARNING: '$1' is $msg. You should only need it if 243 | you modified a '.l' file. You may need the Flex package 244 | in order for those modifications to take effect. You can get 245 | Flex from any GNU archive site." 246 | rm -f lex.yy.c 247 | if test $# -ne 1; then 248 | eval LASTARG=\${$#} 249 | case $LASTARG in 250 | *.l) 251 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 252 | if test -f "$SRCFILE"; then 253 | cp "$SRCFILE" lex.yy.c 254 | fi 255 | ;; 256 | esac 257 | fi 258 | if test ! -f lex.yy.c; then 259 | echo 'main() { return 0; }' >lex.yy.c 260 | fi 261 | ;; 262 | 263 | help2man*) 264 | echo 1>&2 "\ 265 | WARNING: '$1' is $msg. You should only need it if 266 | you modified a dependency of a manual page. You may need the 267 | Help2man package in order for those modifications to take 268 | effect. You can get Help2man from any GNU archive site." 269 | 270 | file=`echo "$*" | sed -n "$sed_output"` 271 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 272 | if test -f "$file"; then 273 | touch $file 274 | else 275 | test -z "$file" || exec >$file 276 | echo ".ab help2man is required to generate this page" 277 | exit $? 278 | fi 279 | ;; 280 | 281 | makeinfo*) 282 | echo 1>&2 "\ 283 | WARNING: '$1' is $msg. You should only need it if 284 | you modified a '.texi' or '.texinfo' file, or any other file 285 | indirectly affecting the aspect of the manual. The spurious 286 | call might also be the consequence of using a buggy 'make' (AIX, 287 | DU, IRIX). You might want to install the Texinfo package or 288 | the GNU make package. Grab either from any GNU archive site." 289 | # The file to touch is that specified with -o ... 290 | file=`echo "$*" | sed -n "$sed_output"` 291 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 292 | if test -z "$file"; then 293 | # ... or it is the one specified with @setfilename ... 294 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 295 | file=`sed -n ' 296 | /^@setfilename/{ 297 | s/.* \([^ ]*\) *$/\1/ 298 | p 299 | q 300 | }' $infile` 301 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 302 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 303 | fi 304 | # If the file does not exist, the user really needs makeinfo; 305 | # let's fail without touching anything. 306 | test -f $file || exit 1 307 | touch $file 308 | ;; 309 | 310 | *) 311 | echo 1>&2 "\ 312 | WARNING: '$1' is needed, and is $msg. 313 | You might have modified some files without having the 314 | proper tools for further handling them. Check the 'README' file, 315 | it often tells you about the needed prerequisites for installing 316 | this package. You may also peek at any GNU archive site, in case 317 | some other package would contain this missing '$1' program." 318 | exit 1 319 | ;; 320 | esac 321 | 322 | exit 0 323 | 324 | # Local variables: 325 | # eval: (add-hook 'write-file-hooks 'time-stamp) 326 | # time-stamp-start: "scriptversion=" 327 | # time-stamp-format: "%:y-%02m-%02d.%02H" 328 | # time-stamp-time-zone: "UTC" 329 | # time-stamp-end: "; # UTC" 330 | # End: 331 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2011-11-20.07; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | # Protect names problematic for 'test' and other utilities. 160 | case $dst_arg in 161 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 162 | esac 163 | shift;; 164 | 165 | -T) no_target_directory=true;; 166 | 167 | --version) echo "$0 $scriptversion"; exit $?;; 168 | 169 | --) shift 170 | break;; 171 | 172 | -*) echo "$0: invalid option: $1" >&2 173 | exit 1;; 174 | 175 | *) break;; 176 | esac 177 | shift 178 | done 179 | 180 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 181 | # When -d is used, all remaining arguments are directories to create. 182 | # When -t is used, the destination is already specified. 183 | # Otherwise, the last argument is the destination. Remove it from $@. 184 | for arg 185 | do 186 | if test -n "$dst_arg"; then 187 | # $@ is not empty: it contains at least $arg. 188 | set fnord "$@" "$dst_arg" 189 | shift # fnord 190 | fi 191 | shift # arg 192 | dst_arg=$arg 193 | # Protect names problematic for 'test' and other utilities. 194 | case $dst_arg in 195 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 196 | esac 197 | done 198 | fi 199 | 200 | if test $# -eq 0; then 201 | if test -z "$dir_arg"; then 202 | echo "$0: no input file specified." >&2 203 | exit 1 204 | fi 205 | # It's OK to call 'install-sh -d' without argument. 206 | # This can happen when creating conditional directories. 207 | exit 0 208 | fi 209 | 210 | if test -z "$dir_arg"; then 211 | do_exit='(exit $ret); exit $ret' 212 | trap "ret=129; $do_exit" 1 213 | trap "ret=130; $do_exit" 2 214 | trap "ret=141; $do_exit" 13 215 | trap "ret=143; $do_exit" 15 216 | 217 | # Set umask so as not to create temps with too-generous modes. 218 | # However, 'strip' requires both read and write access to temps. 219 | case $mode in 220 | # Optimize common cases. 221 | *644) cp_umask=133;; 222 | *755) cp_umask=22;; 223 | 224 | *[0-7]) 225 | if test -z "$stripcmd"; then 226 | u_plus_rw= 227 | else 228 | u_plus_rw='% 200' 229 | fi 230 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 231 | *) 232 | if test -z "$stripcmd"; then 233 | u_plus_rw= 234 | else 235 | u_plus_rw=,u+rw 236 | fi 237 | cp_umask=$mode$u_plus_rw;; 238 | esac 239 | fi 240 | 241 | for src 242 | do 243 | # Protect names problematic for 'test' and other utilities. 244 | case $src in 245 | -* | [=\(\)!]) src=./$src;; 246 | esac 247 | 248 | if test -n "$dir_arg"; then 249 | dst=$src 250 | dstdir=$dst 251 | test -d "$dstdir" 252 | dstdir_status=$? 253 | else 254 | 255 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 256 | # might cause directories to be created, which would be especially bad 257 | # if $src (and thus $dsttmp) contains '*'. 258 | if test ! -f "$src" && test ! -d "$src"; then 259 | echo "$0: $src does not exist." >&2 260 | exit 1 261 | fi 262 | 263 | if test -z "$dst_arg"; then 264 | echo "$0: no destination specified." >&2 265 | exit 1 266 | fi 267 | dst=$dst_arg 268 | 269 | # If destination is a directory, append the input filename; won't work 270 | # if double slashes aren't ignored. 271 | if test -d "$dst"; then 272 | if test -n "$no_target_directory"; then 273 | echo "$0: $dst_arg: Is a directory" >&2 274 | exit 1 275 | fi 276 | dstdir=$dst 277 | dst=$dstdir/`basename "$src"` 278 | dstdir_status=0 279 | else 280 | # Prefer dirname, but fall back on a substitute if dirname fails. 281 | dstdir=` 282 | (dirname "$dst") 2>/dev/null || 283 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 284 | X"$dst" : 'X\(//\)[^/]' \| \ 285 | X"$dst" : 'X\(//\)$' \| \ 286 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 287 | echo X"$dst" | 288 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 289 | s//\1/ 290 | q 291 | } 292 | /^X\(\/\/\)[^/].*/{ 293 | s//\1/ 294 | q 295 | } 296 | /^X\(\/\/\)$/{ 297 | s//\1/ 298 | q 299 | } 300 | /^X\(\/\).*/{ 301 | s//\1/ 302 | q 303 | } 304 | s/.*/./; q' 305 | ` 306 | 307 | test -d "$dstdir" 308 | dstdir_status=$? 309 | fi 310 | fi 311 | 312 | obsolete_mkdir_used=false 313 | 314 | if test $dstdir_status != 0; then 315 | case $posix_mkdir in 316 | '') 317 | # Create intermediate dirs using mode 755 as modified by the umask. 318 | # This is like FreeBSD 'install' as of 1997-10-28. 319 | umask=`umask` 320 | case $stripcmd.$umask in 321 | # Optimize common cases. 322 | *[2367][2367]) mkdir_umask=$umask;; 323 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 324 | 325 | *[0-7]) 326 | mkdir_umask=`expr $umask + 22 \ 327 | - $umask % 100 % 40 + $umask % 20 \ 328 | - $umask % 10 % 4 + $umask % 2 329 | `;; 330 | *) mkdir_umask=$umask,go-w;; 331 | esac 332 | 333 | # With -d, create the new directory with the user-specified mode. 334 | # Otherwise, rely on $mkdir_umask. 335 | if test -n "$dir_arg"; then 336 | mkdir_mode=-m$mode 337 | else 338 | mkdir_mode= 339 | fi 340 | 341 | posix_mkdir=false 342 | case $umask in 343 | *[123567][0-7][0-7]) 344 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 345 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 346 | ;; 347 | *) 348 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 349 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 350 | 351 | if (umask $mkdir_umask && 352 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 353 | then 354 | if test -z "$dir_arg" || { 355 | # Check for POSIX incompatibilities with -m. 356 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 357 | # other-writable bit of parent directory when it shouldn't. 358 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 359 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 360 | case $ls_ld_tmpdir in 361 | d????-?r-*) different_mode=700;; 362 | d????-?--*) different_mode=755;; 363 | *) false;; 364 | esac && 365 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 366 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 367 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 368 | } 369 | } 370 | then posix_mkdir=: 371 | fi 372 | rmdir "$tmpdir/d" "$tmpdir" 373 | else 374 | # Remove any dirs left behind by ancient mkdir implementations. 375 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 376 | fi 377 | trap '' 0;; 378 | esac;; 379 | esac 380 | 381 | if 382 | $posix_mkdir && ( 383 | umask $mkdir_umask && 384 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 385 | ) 386 | then : 387 | else 388 | 389 | # The umask is ridiculous, or mkdir does not conform to POSIX, 390 | # or it failed possibly due to a race condition. Create the 391 | # directory the slow way, step by step, checking for races as we go. 392 | 393 | case $dstdir in 394 | /*) prefix='/';; 395 | [-=\(\)!]*) prefix='./';; 396 | *) prefix='';; 397 | esac 398 | 399 | eval "$initialize_posix_glob" 400 | 401 | oIFS=$IFS 402 | IFS=/ 403 | $posix_glob set -f 404 | set fnord $dstdir 405 | shift 406 | $posix_glob set +f 407 | IFS=$oIFS 408 | 409 | prefixes= 410 | 411 | for d 412 | do 413 | test X"$d" = X && continue 414 | 415 | prefix=$prefix$d 416 | if test -d "$prefix"; then 417 | prefixes= 418 | else 419 | if $posix_mkdir; then 420 | (umask=$mkdir_umask && 421 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 422 | # Don't fail if two instances are running concurrently. 423 | test -d "$prefix" || exit 1 424 | else 425 | case $prefix in 426 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 427 | *) qprefix=$prefix;; 428 | esac 429 | prefixes="$prefixes '$qprefix'" 430 | fi 431 | fi 432 | prefix=$prefix/ 433 | done 434 | 435 | if test -n "$prefixes"; then 436 | # Don't fail if two instances are running concurrently. 437 | (umask $mkdir_umask && 438 | eval "\$doit_exec \$mkdirprog $prefixes") || 439 | test -d "$dstdir" || exit 1 440 | obsolete_mkdir_used=true 441 | fi 442 | fi 443 | fi 444 | 445 | if test -n "$dir_arg"; then 446 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 447 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 448 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 449 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 450 | else 451 | 452 | # Make a couple of temp file names in the proper directory. 453 | dsttmp=$dstdir/_inst.$$_ 454 | rmtmp=$dstdir/_rm.$$_ 455 | 456 | # Trap to clean up those temp files at exit. 457 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 458 | 459 | # Copy the file name to the temp name. 460 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 461 | 462 | # and set any options; do chmod last to preserve setuid bits. 463 | # 464 | # If any of these fail, we abort the whole thing. If we want to 465 | # ignore errors from any of these, just make sure not to ignore 466 | # errors from the above "$doit $cpprog $src $dsttmp" command. 467 | # 468 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 469 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 470 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 471 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 472 | 473 | # If -C, don't bother to copy if it wouldn't change the file. 474 | if $copy_on_change && 475 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 476 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 477 | 478 | eval "$initialize_posix_glob" && 479 | $posix_glob set -f && 480 | set X $old && old=:$2:$4:$5:$6 && 481 | set X $new && new=:$2:$4:$5:$6 && 482 | $posix_glob set +f && 483 | 484 | test "$old" = "$new" && 485 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 486 | then 487 | rm -f "$dsttmp" 488 | else 489 | # Rename the file to the real destination. 490 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 491 | 492 | # The rename failed, perhaps because mv can't rename something else 493 | # to itself, or perhaps because mv is so ancient that it does not 494 | # support -f. 495 | { 496 | # Now remove or move aside any old file at destination location. 497 | # We try this two ways since rm can't unlink itself on some 498 | # systems and the destination file might be busy for other 499 | # reasons. In this case, the final cleanup might fail but the new 500 | # file should still install successfully. 501 | { 502 | test ! -f "$dst" || 503 | $doit $rmcmd -f "$dst" 2>/dev/null || 504 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 505 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 506 | } || 507 | { echo "$0: cannot unlink or rename $dst" >&2 508 | (exit 1); exit 1 509 | } 510 | } && 511 | 512 | # Now rename the file to the real destination. 513 | $doit $mvcmd "$dsttmp" "$dst" 514 | } 515 | fi || exit 1 516 | 517 | trap '' 0 518 | fi 519 | done 520 | 521 | # Local variables: 522 | # eval: (add-hook 'write-file-hooks 'time-stamp) 523 | # time-stamp-start: "scriptversion=" 524 | # time-stamp-format: "%:y-%02m-%02d.%02H" 525 | # time-stamp-time-zone: "UTC" 526 | # time-stamp-end: "; # UTC" 527 | # End: 528 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2012-03-27.16; # UTC 5 | 6 | # Copyright (C) 1999-2012 Free Software Foundation, Inc. 7 | 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | # As a special exception to the GNU General Public License, if you 22 | # distribute this file as part of a program that contains a 23 | # configuration script generated by Autoconf, you may include it under 24 | # the same distribution terms that you use for the rest of that program. 25 | 26 | # Originally written by Alexandre Oliva . 27 | 28 | case $1 in 29 | '') 30 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 31 | exit 1; 32 | ;; 33 | -h | --h*) 34 | cat <<\EOF 35 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 36 | 37 | Run PROGRAMS ARGS to compile a file, generating dependencies 38 | as side-effects. 39 | 40 | Environment variables: 41 | depmode Dependency tracking mode. 42 | source Source file read by 'PROGRAMS ARGS'. 43 | object Object file output by 'PROGRAMS ARGS'. 44 | DEPDIR directory where to store dependencies. 45 | depfile Dependency file to output. 46 | tmpdepfile Temporary file to use when outputting dependencies. 47 | libtool Whether libtool is used (yes/no). 48 | 49 | Report bugs to . 50 | EOF 51 | exit $? 52 | ;; 53 | -v | --v*) 54 | echo "depcomp $scriptversion" 55 | exit $? 56 | ;; 57 | esac 58 | 59 | # A tabulation character. 60 | tab=' ' 61 | # A newline character. 62 | nl=' 63 | ' 64 | 65 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 66 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 67 | exit 1 68 | fi 69 | 70 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 71 | depfile=${depfile-`echo "$object" | 72 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 73 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 74 | 75 | rm -f "$tmpdepfile" 76 | 77 | # Some modes work just like other modes, but use different flags. We 78 | # parameterize here, but still list the modes in the big case below, 79 | # to make depend.m4 easier to write. Note that we *cannot* use a case 80 | # here, because this file can only contain one case statement. 81 | if test "$depmode" = hp; then 82 | # HP compiler uses -M and no extra arg. 83 | gccflag=-M 84 | depmode=gcc 85 | fi 86 | 87 | if test "$depmode" = dashXmstdout; then 88 | # This is just like dashmstdout with a different argument. 89 | dashmflag=-xM 90 | depmode=dashmstdout 91 | fi 92 | 93 | cygpath_u="cygpath -u -f -" 94 | if test "$depmode" = msvcmsys; then 95 | # This is just like msvisualcpp but w/o cygpath translation. 96 | # Just convert the backslash-escaped backslashes to single forward 97 | # slashes to satisfy depend.m4 98 | cygpath_u='sed s,\\\\,/,g' 99 | depmode=msvisualcpp 100 | fi 101 | 102 | if test "$depmode" = msvc7msys; then 103 | # This is just like msvc7 but w/o cygpath translation. 104 | # Just convert the backslash-escaped backslashes to single forward 105 | # slashes to satisfy depend.m4 106 | cygpath_u='sed s,\\\\,/,g' 107 | depmode=msvc7 108 | fi 109 | 110 | if test "$depmode" = xlc; then 111 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations. 112 | gccflag=-qmakedep=gcc,-MF 113 | depmode=gcc 114 | fi 115 | 116 | case "$depmode" in 117 | gcc3) 118 | ## gcc 3 implements dependency tracking that does exactly what 119 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 120 | ## it if -MD -MP comes after the -MF stuff. Hmm. 121 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 122 | ## the command line argument order; so add the flags where they 123 | ## appear in depend2.am. Note that the slowdown incurred here 124 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 125 | for arg 126 | do 127 | case $arg in 128 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 129 | *) set fnord "$@" "$arg" ;; 130 | esac 131 | shift # fnord 132 | shift # $arg 133 | done 134 | "$@" 135 | stat=$? 136 | if test $stat -eq 0; then : 137 | else 138 | rm -f "$tmpdepfile" 139 | exit $stat 140 | fi 141 | mv "$tmpdepfile" "$depfile" 142 | ;; 143 | 144 | gcc) 145 | ## There are various ways to get dependency output from gcc. Here's 146 | ## why we pick this rather obscure method: 147 | ## - Don't want to use -MD because we'd like the dependencies to end 148 | ## up in a subdir. Having to rename by hand is ugly. 149 | ## (We might end up doing this anyway to support other compilers.) 150 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 151 | ## -MM, not -M (despite what the docs say). 152 | ## - Using -M directly means running the compiler twice (even worse 153 | ## than renaming). 154 | if test -z "$gccflag"; then 155 | gccflag=-MD, 156 | fi 157 | "$@" -Wp,"$gccflag$tmpdepfile" 158 | stat=$? 159 | if test $stat -eq 0; then : 160 | else 161 | rm -f "$tmpdepfile" 162 | exit $stat 163 | fi 164 | rm -f "$depfile" 165 | echo "$object : \\" > "$depfile" 166 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 167 | ## The second -e expression handles DOS-style file names with drive letters. 168 | sed -e 's/^[^:]*: / /' \ 169 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 170 | ## This next piece of magic avoids the "deleted header file" problem. 171 | ## The problem is that when a header file which appears in a .P file 172 | ## is deleted, the dependency causes make to die (because there is 173 | ## typically no way to rebuild the header). We avoid this by adding 174 | ## dummy dependencies for each header file. Too bad gcc doesn't do 175 | ## this for us directly. 176 | tr ' ' "$nl" < "$tmpdepfile" | 177 | ## Some versions of gcc put a space before the ':'. On the theory 178 | ## that the space means something, we add a space to the output as 179 | ## well. hp depmode also adds that space, but also prefixes the VPATH 180 | ## to the object. Take care to not repeat it in the output. 181 | ## Some versions of the HPUX 10.20 sed can't process this invocation 182 | ## correctly. Breaking it into two sed invocations is a workaround. 183 | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 184 | | sed -e 's/$/ :/' >> "$depfile" 185 | rm -f "$tmpdepfile" 186 | ;; 187 | 188 | hp) 189 | # This case exists only to let depend.m4 do its work. It works by 190 | # looking at the text of this script. This case will never be run, 191 | # since it is checked for above. 192 | exit 1 193 | ;; 194 | 195 | sgi) 196 | if test "$libtool" = yes; then 197 | "$@" "-Wp,-MDupdate,$tmpdepfile" 198 | else 199 | "$@" -MDupdate "$tmpdepfile" 200 | fi 201 | stat=$? 202 | if test $stat -eq 0; then : 203 | else 204 | rm -f "$tmpdepfile" 205 | exit $stat 206 | fi 207 | rm -f "$depfile" 208 | 209 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 210 | echo "$object : \\" > "$depfile" 211 | 212 | # Clip off the initial element (the dependent). Don't try to be 213 | # clever and replace this with sed code, as IRIX sed won't handle 214 | # lines with more than a fixed number of characters (4096 in 215 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 216 | # the IRIX cc adds comments like '#:fec' to the end of the 217 | # dependency line. 218 | tr ' ' "$nl" < "$tmpdepfile" \ 219 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 220 | tr "$nl" ' ' >> "$depfile" 221 | echo >> "$depfile" 222 | 223 | # The second pass generates a dummy entry for each header file. 224 | tr ' ' "$nl" < "$tmpdepfile" \ 225 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 226 | >> "$depfile" 227 | else 228 | # The sourcefile does not contain any dependencies, so just 229 | # store a dummy comment line, to avoid errors with the Makefile 230 | # "include basename.Plo" scheme. 231 | echo "#dummy" > "$depfile" 232 | fi 233 | rm -f "$tmpdepfile" 234 | ;; 235 | 236 | xlc) 237 | # This case exists only to let depend.m4 do its work. It works by 238 | # looking at the text of this script. This case will never be run, 239 | # since it is checked for above. 240 | exit 1 241 | ;; 242 | 243 | aix) 244 | # The C for AIX Compiler uses -M and outputs the dependencies 245 | # in a .u file. In older versions, this file always lives in the 246 | # current directory. Also, the AIX compiler puts '$object:' at the 247 | # start of each line; $object doesn't have directory information. 248 | # Version 6 uses the directory in both cases. 249 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 250 | test "x$dir" = "x$object" && dir= 251 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 252 | if test "$libtool" = yes; then 253 | tmpdepfile1=$dir$base.u 254 | tmpdepfile2=$base.u 255 | tmpdepfile3=$dir.libs/$base.u 256 | "$@" -Wc,-M 257 | else 258 | tmpdepfile1=$dir$base.u 259 | tmpdepfile2=$dir$base.u 260 | tmpdepfile3=$dir$base.u 261 | "$@" -M 262 | fi 263 | stat=$? 264 | 265 | if test $stat -eq 0; then : 266 | else 267 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 268 | exit $stat 269 | fi 270 | 271 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 272 | do 273 | test -f "$tmpdepfile" && break 274 | done 275 | if test -f "$tmpdepfile"; then 276 | # Each line is of the form 'foo.o: dependent.h'. 277 | # Do two passes, one to just change these to 278 | # '$object: dependent.h' and one to simply 'dependent.h:'. 279 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 280 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 281 | else 282 | # The sourcefile does not contain any dependencies, so just 283 | # store a dummy comment line, to avoid errors with the Makefile 284 | # "include basename.Plo" scheme. 285 | echo "#dummy" > "$depfile" 286 | fi 287 | rm -f "$tmpdepfile" 288 | ;; 289 | 290 | icc) 291 | # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. 292 | # However on 293 | # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c 294 | # ICC 7.0 will fill foo.d with something like 295 | # foo.o: sub/foo.c 296 | # foo.o: sub/foo.h 297 | # which is wrong. We want 298 | # sub/foo.o: sub/foo.c 299 | # sub/foo.o: sub/foo.h 300 | # sub/foo.c: 301 | # sub/foo.h: 302 | # ICC 7.1 will output 303 | # foo.o: sub/foo.c sub/foo.h 304 | # and will wrap long lines using '\': 305 | # foo.o: sub/foo.c ... \ 306 | # sub/foo.h ... \ 307 | # ... 308 | # tcc 0.9.26 (FIXME still under development at the moment of writing) 309 | # will emit a similar output, but also prepend the continuation lines 310 | # with horizontal tabulation characters. 311 | "$@" -MD -MF "$tmpdepfile" 312 | stat=$? 313 | if test $stat -eq 0; then : 314 | else 315 | rm -f "$tmpdepfile" 316 | exit $stat 317 | fi 318 | rm -f "$depfile" 319 | # Each line is of the form 'foo.o: dependent.h', 320 | # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. 321 | # Do two passes, one to just change these to 322 | # '$object: dependent.h' and one to simply 'dependent.h:'. 323 | sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ 324 | < "$tmpdepfile" > "$depfile" 325 | sed ' 326 | s/[ '"$tab"'][ '"$tab"']*/ /g 327 | s/^ *// 328 | s/ *\\*$// 329 | s/^[^:]*: *// 330 | /^$/d 331 | /:$/d 332 | s/$/ :/ 333 | ' < "$tmpdepfile" >> "$depfile" 334 | rm -f "$tmpdepfile" 335 | ;; 336 | 337 | hp2) 338 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 339 | # compilers, which have integrated preprocessors. The correct option 340 | # to use with these is +Maked; it writes dependencies to a file named 341 | # 'foo.d', which lands next to the object file, wherever that 342 | # happens to be. 343 | # Much of this is similar to the tru64 case; see comments there. 344 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 345 | test "x$dir" = "x$object" && dir= 346 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 347 | if test "$libtool" = yes; then 348 | tmpdepfile1=$dir$base.d 349 | tmpdepfile2=$dir.libs/$base.d 350 | "$@" -Wc,+Maked 351 | else 352 | tmpdepfile1=$dir$base.d 353 | tmpdepfile2=$dir$base.d 354 | "$@" +Maked 355 | fi 356 | stat=$? 357 | if test $stat -eq 0; then : 358 | else 359 | rm -f "$tmpdepfile1" "$tmpdepfile2" 360 | exit $stat 361 | fi 362 | 363 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 364 | do 365 | test -f "$tmpdepfile" && break 366 | done 367 | if test -f "$tmpdepfile"; then 368 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 369 | # Add 'dependent.h:' lines. 370 | sed -ne '2,${ 371 | s/^ *// 372 | s/ \\*$// 373 | s/$/:/ 374 | p 375 | }' "$tmpdepfile" >> "$depfile" 376 | else 377 | echo "#dummy" > "$depfile" 378 | fi 379 | rm -f "$tmpdepfile" "$tmpdepfile2" 380 | ;; 381 | 382 | tru64) 383 | # The Tru64 compiler uses -MD to generate dependencies as a side 384 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 385 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 386 | # dependencies in 'foo.d' instead, so we check for that too. 387 | # Subdirectories are respected. 388 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 389 | test "x$dir" = "x$object" && dir= 390 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 391 | 392 | if test "$libtool" = yes; then 393 | # With Tru64 cc, shared objects can also be used to make a 394 | # static library. This mechanism is used in libtool 1.4 series to 395 | # handle both shared and static libraries in a single compilation. 396 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 397 | # 398 | # With libtool 1.5 this exception was removed, and libtool now 399 | # generates 2 separate objects for the 2 libraries. These two 400 | # compilations output dependencies in $dir.libs/$base.o.d and 401 | # in $dir$base.o.d. We have to check for both files, because 402 | # one of the two compilations can be disabled. We should prefer 403 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 404 | # automatically cleaned when .libs/ is deleted, while ignoring 405 | # the former would cause a distcleancheck panic. 406 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 407 | tmpdepfile2=$dir$base.o.d # libtool 1.5 408 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 409 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 410 | "$@" -Wc,-MD 411 | else 412 | tmpdepfile1=$dir$base.o.d 413 | tmpdepfile2=$dir$base.d 414 | tmpdepfile3=$dir$base.d 415 | tmpdepfile4=$dir$base.d 416 | "$@" -MD 417 | fi 418 | 419 | stat=$? 420 | if test $stat -eq 0; then : 421 | else 422 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 423 | exit $stat 424 | fi 425 | 426 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 427 | do 428 | test -f "$tmpdepfile" && break 429 | done 430 | if test -f "$tmpdepfile"; then 431 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 432 | sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 433 | else 434 | echo "#dummy" > "$depfile" 435 | fi 436 | rm -f "$tmpdepfile" 437 | ;; 438 | 439 | msvc7) 440 | if test "$libtool" = yes; then 441 | showIncludes=-Wc,-showIncludes 442 | else 443 | showIncludes=-showIncludes 444 | fi 445 | "$@" $showIncludes > "$tmpdepfile" 446 | stat=$? 447 | grep -v '^Note: including file: ' "$tmpdepfile" 448 | if test "$stat" = 0; then : 449 | else 450 | rm -f "$tmpdepfile" 451 | exit $stat 452 | fi 453 | rm -f "$depfile" 454 | echo "$object : \\" > "$depfile" 455 | # The first sed program below extracts the file names and escapes 456 | # backslashes for cygpath. The second sed program outputs the file 457 | # name when reading, but also accumulates all include files in the 458 | # hold buffer in order to output them again at the end. This only 459 | # works with sed implementations that can handle large buffers. 460 | sed < "$tmpdepfile" -n ' 461 | /^Note: including file: *\(.*\)/ { 462 | s//\1/ 463 | s/\\/\\\\/g 464 | p 465 | }' | $cygpath_u | sort -u | sed -n ' 466 | s/ /\\ /g 467 | s/\(.*\)/'"$tab"'\1 \\/p 468 | s/.\(.*\) \\/\1:/ 469 | H 470 | $ { 471 | s/.*/'"$tab"'/ 472 | G 473 | p 474 | }' >> "$depfile" 475 | rm -f "$tmpdepfile" 476 | ;; 477 | 478 | msvc7msys) 479 | # This case exists only to let depend.m4 do its work. It works by 480 | # looking at the text of this script. This case will never be run, 481 | # since it is checked for above. 482 | exit 1 483 | ;; 484 | 485 | #nosideeffect) 486 | # This comment above is used by automake to tell side-effect 487 | # dependency tracking mechanisms from slower ones. 488 | 489 | dashmstdout) 490 | # Important note: in order to support this mode, a compiler *must* 491 | # always write the preprocessed file to stdout, regardless of -o. 492 | "$@" || exit $? 493 | 494 | # Remove the call to Libtool. 495 | if test "$libtool" = yes; then 496 | while test "X$1" != 'X--mode=compile'; do 497 | shift 498 | done 499 | shift 500 | fi 501 | 502 | # Remove '-o $object'. 503 | IFS=" " 504 | for arg 505 | do 506 | case $arg in 507 | -o) 508 | shift 509 | ;; 510 | $object) 511 | shift 512 | ;; 513 | *) 514 | set fnord "$@" "$arg" 515 | shift # fnord 516 | shift # $arg 517 | ;; 518 | esac 519 | done 520 | 521 | test -z "$dashmflag" && dashmflag=-M 522 | # Require at least two characters before searching for ':' 523 | # in the target name. This is to cope with DOS-style filenames: 524 | # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 525 | "$@" $dashmflag | 526 | sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" 527 | rm -f "$depfile" 528 | cat < "$tmpdepfile" > "$depfile" 529 | tr ' ' "$nl" < "$tmpdepfile" | \ 530 | ## Some versions of the HPUX 10.20 sed can't process this invocation 531 | ## correctly. Breaking it into two sed invocations is a workaround. 532 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 533 | rm -f "$tmpdepfile" 534 | ;; 535 | 536 | dashXmstdout) 537 | # This case only exists to satisfy depend.m4. It is never actually 538 | # run, as this mode is specially recognized in the preamble. 539 | exit 1 540 | ;; 541 | 542 | makedepend) 543 | "$@" || exit $? 544 | # Remove any Libtool call 545 | if test "$libtool" = yes; then 546 | while test "X$1" != 'X--mode=compile'; do 547 | shift 548 | done 549 | shift 550 | fi 551 | # X makedepend 552 | shift 553 | cleared=no eat=no 554 | for arg 555 | do 556 | case $cleared in 557 | no) 558 | set ""; shift 559 | cleared=yes ;; 560 | esac 561 | if test $eat = yes; then 562 | eat=no 563 | continue 564 | fi 565 | case "$arg" in 566 | -D*|-I*) 567 | set fnord "$@" "$arg"; shift ;; 568 | # Strip any option that makedepend may not understand. Remove 569 | # the object too, otherwise makedepend will parse it as a source file. 570 | -arch) 571 | eat=yes ;; 572 | -*|$object) 573 | ;; 574 | *) 575 | set fnord "$@" "$arg"; shift ;; 576 | esac 577 | done 578 | obj_suffix=`echo "$object" | sed 's/^.*\././'` 579 | touch "$tmpdepfile" 580 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 581 | rm -f "$depfile" 582 | # makedepend may prepend the VPATH from the source file name to the object. 583 | # No need to regex-escape $object, excess matching of '.' is harmless. 584 | sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 585 | sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ 586 | ## Some versions of the HPUX 10.20 sed can't process this invocation 587 | ## correctly. Breaking it into two sed invocations is a workaround. 588 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 589 | rm -f "$tmpdepfile" "$tmpdepfile".bak 590 | ;; 591 | 592 | cpp) 593 | # Important note: in order to support this mode, a compiler *must* 594 | # always write the preprocessed file to stdout. 595 | "$@" || exit $? 596 | 597 | # Remove the call to Libtool. 598 | if test "$libtool" = yes; then 599 | while test "X$1" != 'X--mode=compile'; do 600 | shift 601 | done 602 | shift 603 | fi 604 | 605 | # Remove '-o $object'. 606 | IFS=" " 607 | for arg 608 | do 609 | case $arg in 610 | -o) 611 | shift 612 | ;; 613 | $object) 614 | shift 615 | ;; 616 | *) 617 | set fnord "$@" "$arg" 618 | shift # fnord 619 | shift # $arg 620 | ;; 621 | esac 622 | done 623 | 624 | "$@" -E | 625 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 626 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 627 | sed '$ s: \\$::' > "$tmpdepfile" 628 | rm -f "$depfile" 629 | echo "$object : \\" > "$depfile" 630 | cat < "$tmpdepfile" >> "$depfile" 631 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 632 | rm -f "$tmpdepfile" 633 | ;; 634 | 635 | msvisualcpp) 636 | # Important note: in order to support this mode, a compiler *must* 637 | # always write the preprocessed file to stdout. 638 | "$@" || exit $? 639 | 640 | # Remove the call to Libtool. 641 | if test "$libtool" = yes; then 642 | while test "X$1" != 'X--mode=compile'; do 643 | shift 644 | done 645 | shift 646 | fi 647 | 648 | IFS=" " 649 | for arg 650 | do 651 | case "$arg" in 652 | -o) 653 | shift 654 | ;; 655 | $object) 656 | shift 657 | ;; 658 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 659 | set fnord "$@" 660 | shift 661 | shift 662 | ;; 663 | *) 664 | set fnord "$@" "$arg" 665 | shift 666 | shift 667 | ;; 668 | esac 669 | done 670 | "$@" -E 2>/dev/null | 671 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 672 | rm -f "$depfile" 673 | echo "$object : \\" > "$depfile" 674 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 675 | echo "$tab" >> "$depfile" 676 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 677 | rm -f "$tmpdepfile" 678 | ;; 679 | 680 | msvcmsys) 681 | # This case exists only to let depend.m4 do its work. It works by 682 | # looking at the text of this script. This case will never be run, 683 | # since it is checked for above. 684 | exit 1 685 | ;; 686 | 687 | none) 688 | exec "$@" 689 | ;; 690 | 691 | *) 692 | echo "Unknown depmode $depmode" 1>&2 693 | exit 1 694 | ;; 695 | esac 696 | 697 | exit 0 698 | 699 | # Local Variables: 700 | # mode: shell-script 701 | # sh-indentation: 2 702 | # eval: (add-hook 'write-file-hooks 'time-stamp) 703 | # time-stamp-start: "scriptversion=" 704 | # time-stamp-format: "%:y-%02m-%02d.%02H" 705 | # time-stamp-time-zone: "UTC" 706 | # time-stamp-end: "; # UTC" 707 | # End: 708 | -------------------------------------------------------------------------------- /src/matlab_fun.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Guangmu Zhu 3 | * 4 | * This file is part of Advancing-Front-Method_2D. 5 | * 6 | * Advancing-Front-Method_2D is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * Advancing-Front-Method_2D is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with Foobar. If not, see . 18 | */ 19 | 20 | /* 21 | * matlab_fun.hpp 22 | * 23 | * Created on: May 22, 2013 24 | * Author: guangmu 25 | */ 26 | 27 | #ifndef MATLAB_FUN_HPP_ 28 | #define MATLAB_FUN_HPP_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "VET.hpp" 38 | 39 | const double DERR = 2.67e-9; 40 | 41 | bool is_zero(double _d); 42 | 43 | class matrix; 44 | 45 | double det2(const matrix&); 46 | 47 | matrix inv2(const matrix&); 48 | 49 | double det2(const Edge&, const Edge&); 50 | 51 | bool is_leftside(const Point&, const Point&, const Point&); 52 | 53 | class matrix { 54 | unsigned _m = 0; 55 | unsigned _n = 0; 56 | double *_dmtx = nullptr; 57 | 58 | public: 59 | matrix() : 60 | _m(0), _n(0), _dmtx(nullptr) { 61 | } 62 | 63 | matrix(unsigned _m, unsigned _n) : 64 | _m(_m), _n(_n) { 65 | _dmtx = new double[_m * _n](); 66 | } 67 | 68 | matrix(unsigned _m, unsigned _n, double *_dmtx) : 69 | _m(_m), _n(_n), _dmtx(_dmtx) { 70 | } 71 | 72 | matrix(unsigned _m, unsigned _n, const std::initializer_list &_dmtx) : 73 | _m(_m), _n(_n) { 74 | if (_dmtx.size() < _m * _n) 75 | throw std::bad_alloc(); 76 | this->_dmtx = new double[_m * _n](); 77 | auto __iter = _dmtx.begin(); 78 | for (unsigned i = 0; i < _m * _n; ++i, ++__iter) { 79 | this->_dmtx[i] = *__iter; 80 | } 81 | } 82 | 83 | matrix(const matrix &_mtx) : 84 | _m(_mtx._m), _n(_mtx._n) { 85 | if (_dmtx != nullptr) 86 | delete[] _dmtx; 87 | _dmtx = new double[_m * _n](); 88 | if (_mtx._dmtx != nullptr) 89 | std::memcpy(_dmtx, _mtx._dmtx, _m * _n * sizeof(double)); 90 | } 91 | 92 | matrix(matrix &&_mtx) noexcept : _m(_mtx._m), _n(_mtx._n) { 93 | if (_dmtx != nullptr) 94 | delete [] _dmtx; 95 | if (_mtx._dmtx == nullptr) { 96 | _dmtx = nullptr; 97 | return; 98 | } else { 99 | _dmtx = _mtx._dmtx; 100 | _mtx._dmtx = nullptr; 101 | } 102 | } 103 | 104 | ~matrix() { 105 | if (_dmtx != nullptr) { 106 | delete [] _dmtx; 107 | } 108 | } 109 | 110 | matrix& init(double _d) { 111 | for (unsigned i = 0; i < _m * _n; ++i) { 112 | *(_dmtx + i) = _d; 113 | } 114 | return *this; 115 | } 116 | 117 | matrix& release() { 118 | if (_dmtx != nullptr) 119 | _dmtx = nullptr; 120 | return *this; 121 | } 122 | 123 | bool is_square_matrix() const { 124 | return _m == _n; 125 | } 126 | 127 | unsigned get_length() const { 128 | return _m > _n ? _m : _n; 129 | } 130 | 131 | void get_size(unsigned &_m, unsigned &_n) const { 132 | _m = this->_m; 133 | _n = this->_n; 134 | } 135 | 136 | std::pair get_size() const { 137 | return std::make_pair(_m, _n); 138 | } 139 | 140 | void set_size(unsigned _m, unsigned _n) { 141 | if (_m * _n != this->_m * this->_n) 142 | throw std::invalid_argument("Dimension unmatched"); 143 | this->_m = _m; 144 | this->_n = _n; 145 | } 146 | 147 | std::string to_string() const { 148 | return to_string("[", "]", " "); 149 | } 150 | 151 | std::string to_string(std::string _prefix, std::string _suffix, std::string _delim) const { 152 | std::stringstream _ret; 153 | for (unsigned i = 0; i < _m; ++i) { 154 | _ret << _prefix; 155 | for (unsigned j = 0; j < _n; ++j) { 156 | _ret << *(_dmtx + i * _n + j); 157 | if (j != _n - 1) 158 | _ret << _delim; 159 | } 160 | _ret << _suffix; 161 | if (i != _m - 1) 162 | _ret << '\n'; 163 | } 164 | return std::move(_ret.str()); 165 | } 166 | 167 | matrix& operator=(const matrix &_mtx) { 168 | _m = _mtx._m; 169 | _n = _mtx._n; 170 | if (_dmtx != nullptr) 171 | delete [] _dmtx; 172 | _dmtx = new double[_m * _n](); 173 | if (_mtx._dmtx != nullptr) 174 | std::memcpy(_dmtx, _mtx._dmtx, _m * _n * sizeof(double)); 175 | return *this; 176 | } 177 | 178 | matrix& operator=(matrix &&_mtx) noexcept { 179 | _m = _mtx._m; 180 | _n = _mtx._n; 181 | if (_dmtx != nullptr) 182 | delete [] _dmtx; 183 | if (_mtx._dmtx == nullptr) { 184 | _dmtx = nullptr; 185 | } else { 186 | _dmtx = _mtx._dmtx; 187 | _mtx._dmtx = nullptr; 188 | } 189 | return *this; 190 | } 191 | 192 | bool operator==(const matrix &_mtx) const { 193 | unsigned __m1, __n1, __m2, __n2; 194 | if (_dmtx == nullptr && _mtx._dmtx == nullptr) { 195 | return true; 196 | } else if (_dmtx == nullptr || _mtx._dmtx == nullptr) { 197 | return false; 198 | } else if (get_size(__m1, __n1), _mtx.get_size(__m2, __n2), __m1 != __m2 || __n1 != __n2) { 199 | return false; 200 | } else { 201 | return std::memcmp(_dmtx, _mtx._dmtx, _m * _n * sizeof(double)) == 0; 202 | } 203 | } 204 | 205 | bool operator!=(const matrix &_mtx) const { 206 | return !(*this == _mtx); 207 | } 208 | 209 | double& operator()(unsigned _midx, unsigned _nidx) const { 210 | if (_midx > 0 &&_midx <= _m && _nidx > 0 && _nidx <= _n) { 211 | return *(_dmtx + (_midx - 1) * _n + _nidx - 1); 212 | } else { 213 | throw std::out_of_range("out of range in matrix: " 214 | "double& operator()(unsigned _midx, unsigned _nidx)"); 215 | } 216 | } 217 | 218 | matrix operator()(unsigned _idx, std::string _rc) const { 219 | if (_rc != "row" && _rc != "col") 220 | throw std::invalid_argument("row or col"); 221 | if (_rc == "row" && _idx > 0 && _idx <= _m) { 222 | matrix _ret(1, _n); 223 | std::memcpy(_ret._dmtx, _dmtx + (_idx - 1) * _n, _n * sizeof(double)); 224 | return std::move(_ret); 225 | } else if (_rc == "col" && _idx > 0 && _idx <= _n) { 226 | matrix _ret(_m, 1); 227 | for (unsigned i = 0; i < _m; ++i) { 228 | _ret(i + 1, 1) = *(_dmtx + i * _n + _idx - 1); 229 | } 230 | return std::move(_ret); 231 | } else { 232 | throw std::out_of_range("out of range in matrix: " 233 | "matrix operator()(unsigned _idx, std::string _rc)"); 234 | } 235 | } 236 | 237 | matrix operator()(unsigned _idxbg, unsigned _idxed, std::string _rc) const { 238 | if (_idxbg > _idxed) 239 | throw std::invalid_argument("error with matrix operator()"); 240 | if (_rc != "row" && _rc != "col") 241 | throw std::invalid_argument("row or col"); 242 | if (_rc == "row" && _idxbg > 0 && _idxed <= _m) { 243 | if (_idxbg == _idxed) 244 | return matrix(0, _n); 245 | matrix _ret(_idxed - _idxbg + 1, _n); 246 | std::memcpy(_ret._dmtx, _dmtx + (_idxbg - 1) * _n, (_idxed - _idxbg + 1) * _n * sizeof(double)); 247 | return std::move(_ret); 248 | } else if (_rc == "col" && _idxbg > 0 && _idxed <= _n) { 249 | if (_idxbg == _idxed) 250 | return matrix(_m, 0); 251 | matrix _ret(_m, _idxed - _idxbg + 1); 252 | for (unsigned i = 0; i < _m; ++i) { 253 | for (unsigned j = _idxbg; j <= _idxed; ++j) { 254 | _ret(i + 1, j - _idxbg + 1) = *(_dmtx + i * _n + j - 1); 255 | } 256 | } 257 | return std::move(_ret); 258 | } else { 259 | throw std::out_of_range("out of range in matrix: " 260 | "matrix operator()(unsigned _idxbg, unsigned _idxed, std::string _rc)"); 261 | } 262 | } 263 | 264 | matrix operator()(unsigned _rb, unsigned _rd, unsigned _cb, unsigned _cd) const { 265 | if (_rb > 0 && _rb <= _m && _rd > 0 && _rd <= _m && 266 | _cb > 0 && _cb <= _n && _cd > 0 && _cd <= _n) { 267 | matrix _ret(_rd - _rb + 1, _cd -_cb + 1); 268 | for (unsigned i = _rb; i <= _rd; ++i) { 269 | for (unsigned j = _cb; j <= _cd; ++j) { 270 | _ret(i - _rb + 1, j - _cb + 1) = *(_dmtx + (i - 1) * _n + j - 1); 271 | } 272 | } 273 | return std::move(_ret); 274 | } else { 275 | throw std::out_of_range("out of range in matrix: " 276 | "matrix operator()(unsigned _rb, unsigned _rd, unsigned _cb, unsigned _cd)"); 277 | } 278 | } 279 | 280 | matrix operator+(double _d) const { 281 | matrix _ret(*this); 282 | for (unsigned i = 0; i < _m; ++i) { 283 | for (unsigned j = 0; j < _n; ++j) { 284 | *(_ret._dmtx + i * _n + j) += _d; 285 | } 286 | } 287 | return std::move(_ret); 288 | } 289 | 290 | matrix& operator+=(double _d) { 291 | for (unsigned i = 0; i < _m; ++i) { 292 | for (unsigned j = 0; j < _n; ++j) { 293 | *(_dmtx + i * _n + j) += _d; 294 | } 295 | } 296 | return *this; 297 | } 298 | 299 | matrix operator-(double _d) const { 300 | matrix _ret(*this); 301 | for (unsigned i = 0; i < _m; ++i) { 302 | for (unsigned j = 0; j < _n; ++j) { 303 | *(_ret._dmtx + i * _n + j) -= _d; 304 | } 305 | } 306 | return std::move(_ret); 307 | } 308 | 309 | matrix& operator-=(double _d) { 310 | for (unsigned i = 0; i < _m; ++i) { 311 | for (unsigned j = 0; j < _n; ++j) { 312 | *(_dmtx + i * _n + j) -= _d; 313 | } 314 | } 315 | return *this; 316 | } 317 | 318 | matrix operator&(const matrix &_mtx) const { 319 | if (_n != _mtx._m) 320 | throw std::invalid_argument("col not equal to row"); 321 | matrix _ret(_m, _mtx._n); 322 | double _tmp; 323 | for (unsigned i = 0; i < _m; ++i) { 324 | for (unsigned j = 0; j < _mtx._n; ++j) { 325 | _tmp = 0; 326 | for (unsigned k = 0; k < _n; ++k) { 327 | _tmp += *(_dmtx + i * _n + k) * *(_mtx._dmtx + k * _mtx._n + j); 328 | } 329 | *(_ret._dmtx + i * _mtx._n + j) = _tmp; 330 | } 331 | } 332 | return std::move(_ret); 333 | } 334 | 335 | matrix& operator&=(const matrix &_mtx) { 336 | if (_n != _mtx._m) 337 | throw std::invalid_argument("col not equal to row"); 338 | matrix _ret(_m, _mtx._n); 339 | double _tmp; 340 | for (unsigned i = 0; i < _m; ++i) { 341 | for (unsigned j = 0; j < _mtx._n; ++j) { 342 | _tmp = 0; 343 | for (unsigned k = 0; k < _n; ++k) { 344 | _tmp += *(_dmtx + i * _n + k) * *(_mtx._dmtx + k * _mtx._n + j); 345 | } 346 | *(_ret._dmtx + i * _mtx._n + j) = _tmp; 347 | } 348 | } 349 | *this = std::move(_ret); 350 | return *this; 351 | } 352 | 353 | matrix operator&(double _d) const { 354 | matrix _ret(*this); 355 | for (unsigned i = 0; i < _m; ++i) { 356 | for (unsigned j = 0; j < _n; ++j) { 357 | *(_ret._dmtx + i * _n + j) *= _d; 358 | } 359 | } 360 | return std::move(_ret); 361 | } 362 | 363 | matrix& operator&=(double _d) { 364 | for (unsigned i = 0; i < _m; ++i) { 365 | for (unsigned j = 0; j < _n; ++j) { 366 | *(_dmtx + i * _n + j) *= _d; 367 | } 368 | } 369 | return *this; 370 | } 371 | 372 | matrix operator/(const matrix &_mtx) const { 373 | return inv2(_mtx) & *this; 374 | } 375 | 376 | matrix& operator/=(const matrix &_mtx) { 377 | *this = inv2(_mtx) & *this; 378 | return *this; 379 | } 380 | 381 | matrix operator/(double _d) const { 382 | matrix _ret(*this); 383 | for (unsigned i = 0; i < _m; ++i) { 384 | for (unsigned j = 0; j < _n; ++j) { 385 | *(_ret._dmtx + i * _n + j) /= _d; 386 | } 387 | } 388 | return std::move(_ret); 389 | } 390 | 391 | matrix& operator/=(double _d) { 392 | for (unsigned i = 0; i < _m; ++i) { 393 | for (unsigned j = 0; j < _n; ++j) { 394 | *(_dmtx + i * _n + j) /= _d; 395 | } 396 | } 397 | return *this; 398 | } 399 | 400 | matrix operator|(const matrix &_mtx) const { 401 | if (_m != _mtx._m) 402 | throw std::invalid_argument("Dimension unmatched"); 403 | matrix _ret(_m, _n + _mtx._n); 404 | for (unsigned i = 0; i < _m; ++i) { 405 | for (unsigned j = 0; j < _n; ++j) { 406 | *(_ret._dmtx + i * (_n + _mtx._n) + j) = *(_dmtx + i * _n + j); 407 | } 408 | for (unsigned k = 0; k < _mtx._n; ++k) { 409 | *(_ret._dmtx + i * (_n + _mtx._n) + _n + k) = *(_mtx._dmtx + i * _mtx._n + k); 410 | } 411 | } 412 | return std::move(_ret); 413 | } 414 | 415 | matrix& operator|=(const matrix &_mtx) { 416 | if (_m != _mtx._m) 417 | throw std::invalid_argument("Dimension unmatched"); 418 | matrix _ret(_m, _n + _mtx._n); 419 | for (unsigned i = 0; i < _m; ++i) { 420 | for (unsigned j = 0; j < _n; ++j) { 421 | *(_ret._dmtx + i * (_n + _mtx._n) + j) = *(_dmtx + i * _n + j); 422 | } 423 | for (unsigned k = 0; k < _mtx._n; ++k) { 424 | *(_ret._dmtx + i * (_n + _mtx._n) + _n + k) = *(_mtx._dmtx + i * _mtx._n + k); 425 | } 426 | } 427 | *this = std::move(_ret); 428 | return *this; 429 | } 430 | 431 | matrix operator|(unsigned _idx) const { 432 | if (_idx < 1 || _idx > _n) 433 | throw std::out_of_range("out of range in matrix: " 434 | "matrix operator|(unsigned _idx)"); 435 | matrix _ret(_m, _n -1); 436 | for (unsigned i = 0; i < _m; ++i) { 437 | for (unsigned j = 0; j < _idx - 1; ++j) { 438 | *(_ret._dmtx + i * (_n - 1) + j) = *(_dmtx + i * _n + j); 439 | } 440 | for (unsigned k = _idx; k < _n; ++k) { 441 | *(_ret._dmtx + i * (_n - 1) + k - 1) = *(_dmtx + i * _n + k); 442 | } 443 | } 444 | return std::move(_ret); 445 | } 446 | 447 | matrix& operator|=(unsigned _idx) { 448 | if (_idx < 1 || _idx > _n) 449 | throw std::out_of_range("out of range in matrix: " 450 | "matrix& operator|=(unsigned _idx)"); 451 | matrix _ret(_m, _n -1); 452 | for (unsigned i = 0; i < _m; ++i) { 453 | for (unsigned j = 0; j < _idx - 1; ++j) { 454 | *(_ret._dmtx + i * (_n - 1) + j) = *(_dmtx + i * _n + j); 455 | } 456 | for (unsigned k = _idx; k < _n; ++k) { 457 | *(_ret._dmtx + i * (_n - 1) + k - 1) = *(_dmtx + i * _n + k); 458 | } 459 | } 460 | *this = std::move(_ret); 461 | return *this; 462 | } 463 | 464 | matrix operator^(const matrix &_mtx) const { 465 | if (_n != _mtx._n) 466 | throw std::invalid_argument("Dimension unmatched"); 467 | matrix _ret(_m + _mtx._m, _n); 468 | std::memcpy(_ret._dmtx, _dmtx, _m * _n * sizeof(double)); 469 | std::memcpy(_ret._dmtx + _m * _n, _mtx._dmtx, _mtx._m * _n * sizeof(double)); 470 | return std::move(_ret); 471 | } 472 | 473 | matrix& operator^=(const matrix &_mtx) { 474 | if (_n != _mtx._n) 475 | throw std::invalid_argument("Dimension unmatched"); 476 | matrix _ret(_m + _mtx._m, _n); 477 | std::memcpy(_ret._dmtx, _dmtx, _m * _n * sizeof(double)); 478 | std::memcpy(_ret._dmtx + _m * _n, _mtx._dmtx, _mtx._m * _n * sizeof(double)); 479 | *this = std::move(_ret); 480 | return *this; 481 | } 482 | 483 | matrix operator^(unsigned _idx) const { 484 | if (_idx < 1 || _idx > _m) 485 | throw std::out_of_range("out of range in matrix: " 486 | "matrix operator^(unsigned _idx)"); 487 | matrix _ret(_m - 1, _n); 488 | std::memcpy(_ret._dmtx, _dmtx, (_idx - 1) * _n * sizeof(double)); 489 | std::memcpy(_ret._dmtx + (_idx - 1) * _n, _dmtx + _idx * _n, (_m - _idx) * _n * sizeof(double)); 490 | return std::move(_ret); 491 | } 492 | 493 | matrix& operator^=(unsigned _idx) { 494 | if (_idx < 1 || _idx > _m) 495 | throw std::out_of_range("out of range in matrix: " 496 | "matrix& operator^=(unsigned _idx)"); 497 | matrix _ret(_m - 1, _n); 498 | std::memcpy(_ret._dmtx, _dmtx, (_idx - 1) * _n * sizeof(double)); 499 | std::memcpy(_ret._dmtx + (_idx - 1) * _n, _dmtx + _idx * _n, (_m - _idx) * _n * sizeof(double)); 500 | *this = std::move(_ret); 501 | return *this; 502 | } 503 | 504 | matrix operator~() const { 505 | if (_m == 1 || _n == 1) { 506 | matrix _ret(*this); 507 | _ret.set_size(_n, _m); 508 | return std::move(_ret); 509 | } 510 | matrix _ret(_n, _m); 511 | for (unsigned i = 0; i < _m; ++i) { 512 | for (unsigned j = 0; j < _n; ++j) { 513 | *(_ret._dmtx + j * _m + i) = *(_dmtx + i * _n + j); 514 | } 515 | } 516 | return std::move(_ret); 517 | } 518 | 519 | matrix& operator!() { 520 | if (_m == 1 || _n == 1) { 521 | this->set_size(_n, _m); 522 | return *this; 523 | } 524 | matrix _ret(_n, _m); 525 | for (unsigned i = 0; i < _m; ++i) { 526 | for (unsigned j = 0; j < _n; ++j) { 527 | *(_ret._dmtx + j * _m + i) = *(_dmtx + i * _n + j); 528 | } 529 | } 530 | *this = std::move(_ret); 531 | return *this; 532 | } 533 | 534 | void assign_row(unsigned _idx, const matrix &_mtx) { 535 | if (_mtx.get_size().first < 1) 536 | throw std::invalid_argument("empty matrix"); 537 | if (_idx < 1 || _idx > _m) 538 | throw std::out_of_range("out of range in matrix: " 539 | "void assign_row(unsigned _idx, const matrix &_mtx)"); 540 | if (_n != _mtx._n) 541 | throw std::invalid_argument("Dimension unmatched"); 542 | std::memcpy(_dmtx + (_idx - 1) * _n, _mtx._dmtx, _n * sizeof(double)); 543 | } 544 | 545 | void assign_row(unsigned _idxbg, unsigned _idxed, const matrix &_mtx) { 546 | if (_idxbg > _idxed) 547 | throw std::invalid_argument("error with assign_row"); 548 | if (_mtx.get_size().first < _idxed - _idxbg + 1) 549 | throw std::invalid_argument("matrix is too small"); 550 | if (_idxbg < 1 || _idxed > _m) 551 | throw std::out_of_range("out of range in matrix: " 552 | "void assign_row(unsigned _idxbg, unsigned _idxed, const matrix &_mtx)"); 553 | if (_n != _mtx._n) 554 | throw std::invalid_argument("Dimension unmatched"); 555 | std::memcpy(_dmtx + (_idxbg - 1) * _n, _mtx._dmtx, (_idxed - _idxbg + 1) * _n * sizeof(double)); 556 | } 557 | 558 | void swap_row(unsigned _idx1, unsigned _idx2) { 559 | if (_idx1 < 1 || _idx1 > _m || _idx2 < 1 || _idx2 > _m) 560 | throw std::out_of_range("out of range in matrix: " 561 | "void swap_row(unsigned _idx1, unsigned _idx2)"); 562 | if (_idx1 == _idx2) 563 | return; 564 | matrix _tmp(1, _n); 565 | std::memcpy(_tmp._dmtx, _dmtx + (_idx1 - 1) * _n, _n * sizeof(double)); 566 | std::memcpy(_dmtx + (_idx1 - 1) * _n, _dmtx + (_idx2 - 1) * _n, _n * sizeof(double)); 567 | std::memcpy(_dmtx + (_idx2 - 1) * _n, _tmp._dmtx, _n * sizeof(double)); 568 | } 569 | 570 | int compare_row(unsigned _ridx1, unsigned _ridx2, const matrix& _cidx) { 571 | if (_ridx1 < 1 || _ridx1 > _m || _ridx2 < 1 || _ridx2 > _m) 572 | throw std::out_of_range("out of range in matrix: " 573 | "int compare_row(unsigned _ridx1, unsigned _ridx2, const matrix& _cidx)"); 574 | if (_cidx.get_size().first < 1 || _cidx.get_size().second < 1) 575 | throw std::invalid_argument("Dimension unmatched"); 576 | for (unsigned i = 1; i <= _cidx.get_size().second; ++i) { 577 | if (this->operator()(_ridx1, _cidx(1, i)) == this->operator()(_ridx2, _cidx(1, i))) 578 | continue; 579 | return (this->operator()(_ridx1, _cidx(1, i)) < this->operator()(_ridx2, _cidx(1, i)) ? 1 : -1) 580 | * (_cidx(1, i) > 0 ? 1 : -1); 581 | } 582 | return 0; 583 | } 584 | 585 | void sort_row(const matrix& _cidx) { 586 | sort_row(1, _m, _cidx); 587 | } 588 | 589 | void sort_row(unsigned _ridxbg, unsigned _ridxed, const matrix& _cidx) { 590 | if (_ridxbg < 1 || _ridxbg > _m || _ridxed < 1 || _ridxed > _m) 591 | throw std::out_of_range("out of range in matrix: " 592 | "void sort_row(unsigned _ridxbg, unsigned _ridxed, const matrix& _cidx)"); 593 | if (_ridxbg >= _ridxed) 594 | return; 595 | if (_cidx.get_size().first < 1 || _cidx.get_size().second < 1) 596 | throw std::invalid_argument("Dimension unmatched"); 597 | 598 | 599 | matrix _tmp(1, _n); 600 | unsigned _bg = _ridxbg, _ed = _ridxed; 601 | unsigned _key = _bg++; 602 | while(_bg != _ed) { 603 | if (compare_row(_bg, _key, _cidx) > 0) { 604 | ++_bg; 605 | } else { 606 | while(_bg != _ed && compare_row(_key, _ed, _cidx) > 0) { 607 | _ed--; 608 | } 609 | if (_bg != _ed) { 610 | std::memcpy(_tmp._dmtx, _dmtx + (_bg - 1) * _n, _n * sizeof(double)); 611 | std::memcpy(_dmtx + (_bg - 1) * _n, _dmtx + (_ed - 1) * _n, _n * sizeof(double)); 612 | std::memcpy(_dmtx + (_ed - 1) * _n, _tmp._dmtx, _n * sizeof(double)); 613 | } 614 | } 615 | } 616 | 617 | if (compare_row(_bg, _key, _cidx) < 0) 618 | --_bg; 619 | if (_bg != _key) { 620 | std::memcpy(_tmp._dmtx, _dmtx + (_bg - 1) * _n, _n * sizeof(double)); 621 | std::memcpy(_dmtx + (_bg - 1) * _n, _dmtx + (_key - 1) * _n, _n * sizeof(double)); 622 | std::memcpy(_dmtx + (_key - 1) * _n, _tmp._dmtx, _n * sizeof(double)); 623 | } 624 | 625 | sort_row(_ridxbg, _bg, _cidx); 626 | sort_row(_ed, _ridxed, _cidx); 627 | } 628 | }; 629 | 630 | double mmod(double, double); 631 | 632 | matrix linspace(int, int); 633 | 634 | matrix linspace_st(double, double, double, bool); 635 | 636 | matrix linspace_ct(double, double, unsigned); 637 | 638 | double cart2pol(const Point&); 639 | 640 | double cart2pol(double, double); 641 | 642 | void cart2pol(const Point&, double&, double&); 643 | 644 | void cart2pol(double, double, double&, double&); 645 | 646 | template bool inpolygon(const FWIter&, const FWIter&, 647 | const FWIter&, const FWIter&); 648 | 649 | template bool onpolygon(const FWIter&, const FWIter&, 650 | const FWIter&, const FWIter&); 651 | 652 | template bool iopolygon(const FWIter&, const FWIter&, 653 | const FWIter&, const FWIter&); 654 | 655 | bool segCrs(const Edge&, const Edge&); 656 | 657 | bool segCrs(const Edge&, const Edge&, Point&); 658 | 659 | /*** Definitions ***/ 660 | 661 | template bool inpolygon(const FWIter &_Bbg, const FWIter &_Bed, 662 | const FWIter &_Ibg, const FWIter &_Ied) { 663 | double _angle, _tmpagl; 664 | FWIter _tmp1, _tmp2; 665 | for (FWIter __iter = _Ibg; __iter != _Ied; ++__iter) { 666 | _angle = 0; 667 | for (_tmp1 = _Bbg, _tmp2 = _tmp1, ++_tmp2; _tmp2 != _Bed; 668 | ++_tmp1, ++_tmp2) { 669 | if (*__iter == *_tmp1) { 670 | return false; 671 | } 672 | if (is_zero( 673 | fabs( 674 | cart2pol(*_tmp2 - *__iter) 675 | - cart2pol(*_tmp1 - *__iter)) - M_PI)) { 676 | return false; 677 | } 678 | _tmpagl = mmod( 679 | cart2pol(*_tmp2 - *__iter) - cart2pol(*_tmp1 - *__iter), 680 | 2 * M_PI); 681 | _angle += 682 | (mmod(_tmpagl, 2 * M_PI) > M_PI) ? 683 | _tmpagl - 2 * M_PI : _tmpagl; 684 | } 685 | _tmpagl = mmod(cart2pol(*_Bbg - *__iter) - cart2pol(*_tmp1 - *__iter), 686 | 2 * M_PI); 687 | _angle += 688 | (mmod(_tmpagl, 2 * M_PI) > M_PI) ? _tmpagl - 2 * M_PI : _tmpagl; 689 | if (*__iter == *_tmp1 || is_zero(_angle)) { 690 | return false; 691 | } 692 | } 693 | return true; 694 | } 695 | 696 | template bool onpolygon(const FWIter &_Bbg, const FWIter &_Bed, 697 | const FWIter &_Ibg, const FWIter &_Ied) { 698 | bool _flag; 699 | FWIter _tmp1, _tmp2; 700 | for (FWIter __iter = _Ibg; __iter != _Ied; ++__iter) { 701 | _flag = false; 702 | for (_tmp1 = _Bbg, _tmp2 = _tmp1, ++_tmp2; _tmp2 != _Bed; 703 | ++_tmp1, ++_tmp2) { 704 | if (*__iter == *_tmp1) { 705 | _flag = true; 706 | break; 707 | } 708 | if (is_zero( 709 | fabs( 710 | cart2pol(*_tmp2 - *__iter) 711 | - cart2pol(*_tmp1 - *__iter)) - M_PI)) { 712 | _flag = true; 713 | break; 714 | } 715 | } 716 | if (_flag) { 717 | continue; 718 | } else { 719 | if (*__iter != *_tmp1 720 | && !is_zero( 721 | fabs( 722 | cart2pol(*_Bbg - *__iter) 723 | - cart2pol(*_tmp1 - *__iter)) - M_PI)) { 724 | return false; 725 | } 726 | } 727 | } 728 | return true; 729 | } 730 | 731 | template bool iopolygon(const FWIter &_Bbg, const FWIter &_Bed, 732 | const FWIter &_Ibg, const FWIter &_Ied) { 733 | bool _flag; 734 | double _angle, _tmpagl; 735 | FWIter _tmp1, _tmp2; 736 | for (FWIter __iter = _Ibg; __iter != _Ied; ++__iter) { 737 | _flag = false; 738 | _angle = 0; 739 | for (_tmp1 = _Bbg, _tmp2 = _tmp1, ++_tmp2; _tmp2 != _Bed; 740 | ++_tmp1, ++_tmp2) { 741 | if (*__iter == *_tmp1) { 742 | _flag = true; 743 | break; 744 | } 745 | _tmpagl = mmod( 746 | cart2pol(*_tmp2 - *__iter) - cart2pol(*_tmp1 - *__iter), 747 | 2 * M_PI); 748 | if (is_zero(fabs(_tmpagl) - M_PI)) { 749 | _flag = true; 750 | break; 751 | } 752 | _angle += 753 | (mmod(_tmpagl, 2 * M_PI) > M_PI) ? 754 | _tmpagl - 2 * M_PI : _tmpagl; 755 | } 756 | _tmpagl = mmod(cart2pol(*_Bbg - *__iter) - cart2pol(*_tmp1 - *__iter), 757 | 2 * M_PI); 758 | if (_flag) { 759 | continue; 760 | } else { 761 | if (*__iter != *_tmp1 && !is_zero(fabs(_tmpagl) - M_PI) 762 | && is_zero( 763 | _angle += 764 | (mmod(_tmpagl, 2 * M_PI) > M_PI) ? 765 | _tmpagl - 2 * M_PI : _tmpagl)) { 766 | return false; 767 | } 768 | } 769 | } 770 | return true; 771 | } 772 | 773 | #endif /* MATLAB_FUN_HPP_ */ 774 | -------------------------------------------------------------------------------- /config.log: -------------------------------------------------------------------------------- 1 | This file contains any messages produced by compilers while 2 | running configure, to aid debugging if configure makes a mistake. 3 | 4 | It was created by Advancing-Front-Method_2D configure 1.0, which was 5 | generated by GNU Autoconf 2.69. Invocation command line was 6 | 7 | $ ./configure 8 | 9 | ## --------- ## 10 | ## Platform. ## 11 | ## --------- ## 12 | 13 | hostname = guangmu-ThinkPad-X240s 14 | uname -m = x86_64 15 | uname -r = 3.11.0-15-generic 16 | uname -s = Linux 17 | uname -v = #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 18 | 19 | /usr/bin/uname -p = unknown 20 | /bin/uname -X = unknown 21 | 22 | /bin/arch = unknown 23 | /usr/bin/arch -k = unknown 24 | /usr/convex/getsysinfo = unknown 25 | /usr/bin/hostinfo = unknown 26 | /bin/machine = unknown 27 | /usr/bin/oslevel = unknown 28 | /bin/universe = unknown 29 | 30 | PATH: /usr/lib/lightdm/lightdm 31 | PATH: /usr/local/sbin 32 | PATH: /usr/local/bin 33 | PATH: /usr/sbin 34 | PATH: /usr/bin 35 | PATH: /sbin 36 | PATH: /bin 37 | PATH: /usr/games 38 | PATH: /usr/local/games 39 | 40 | 41 | ## ----------- ## 42 | ## Core tests. ## 43 | ## ----------- ## 44 | 45 | configure:2194: checking for a BSD-compatible install 46 | configure:2262: result: /usr/bin/install -c 47 | configure:2273: checking whether build environment is sane 48 | configure:2328: result: yes 49 | configure:2479: checking for a thread-safe mkdir -p 50 | configure:2518: result: /bin/mkdir -p 51 | configure:2525: checking for gawk 52 | configure:2555: result: no 53 | configure:2525: checking for mawk 54 | configure:2541: found /usr/bin/mawk 55 | configure:2552: result: mawk 56 | configure:2563: checking whether make sets $(MAKE) 57 | configure:2585: result: yes 58 | configure:2735: checking for g++ 59 | configure:2751: found /usr/bin/g++ 60 | configure:2762: result: g++ 61 | configure:2789: checking for C++ compiler version 62 | configure:2798: g++ --version >&5 63 | g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 64 | Copyright (C) 2013 Free Software Foundation, Inc. 65 | This is free software; see the source for copying conditions. There is NO 66 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 67 | 68 | configure:2809: $? = 0 69 | configure:2798: g++ -v >&5 70 | Using built-in specs. 71 | COLLECT_GCC=g++ 72 | COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 73 | Target: x86_64-linux-gnu 74 | Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 75 | Thread model: posix 76 | gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) 77 | configure:2809: $? = 0 78 | configure:2798: g++ -V >&5 79 | g++: error: unrecognized command line option '-V' 80 | g++: fatal error: no input files 81 | compilation terminated. 82 | configure:2809: $? = 4 83 | configure:2798: g++ -qversion >&5 84 | g++: error: unrecognized command line option '-qversion' 85 | g++: fatal error: no input files 86 | compilation terminated. 87 | configure:2809: $? = 4 88 | configure:2829: checking whether the C++ compiler works 89 | configure:2851: g++ -g0 -O3 conftest.cpp >&5 90 | configure:2855: $? = 0 91 | configure:2903: result: yes 92 | configure:2906: checking for C++ compiler default output file name 93 | configure:2908: result: a.out 94 | configure:2914: checking for suffix of executables 95 | configure:2921: g++ -o conftest -g0 -O3 conftest.cpp >&5 96 | configure:2925: $? = 0 97 | configure:2947: result: 98 | configure:2969: checking whether we are cross compiling 99 | configure:2977: g++ -o conftest -g0 -O3 conftest.cpp >&5 100 | configure:2981: $? = 0 101 | configure:2988: ./conftest 102 | configure:2992: $? = 0 103 | configure:3007: result: no 104 | configure:3012: checking for suffix of object files 105 | configure:3034: g++ -c -g0 -O3 conftest.cpp >&5 106 | configure:3038: $? = 0 107 | configure:3059: result: o 108 | configure:3063: checking whether we are using the GNU C++ compiler 109 | configure:3082: g++ -c -g0 -O3 conftest.cpp >&5 110 | configure:3082: $? = 0 111 | configure:3091: result: yes 112 | configure:3100: checking whether g++ accepts -g 113 | configure:3120: g++ -c -g conftest.cpp >&5 114 | configure:3120: $? = 0 115 | configure:3161: result: yes 116 | configure:3195: checking for style of include used by make 117 | configure:3223: result: GNU 118 | configure:3249: checking dependency style of g++ 119 | configure:3360: result: gcc3 120 | configure:3429: checking for gcc 121 | configure:3445: found /usr/bin/gcc 122 | configure:3456: result: gcc 123 | configure:3685: checking for C compiler version 124 | configure:3694: gcc --version >&5 125 | gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 126 | Copyright (C) 2013 Free Software Foundation, Inc. 127 | This is free software; see the source for copying conditions. There is NO 128 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 129 | 130 | configure:3705: $? = 0 131 | configure:3694: gcc -v >&5 132 | Using built-in specs. 133 | COLLECT_GCC=gcc 134 | COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 135 | Target: x86_64-linux-gnu 136 | Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.1-10ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 137 | Thread model: posix 138 | gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) 139 | configure:3705: $? = 0 140 | configure:3694: gcc -V >&5 141 | gcc: error: unrecognized command line option '-V' 142 | gcc: fatal error: no input files 143 | compilation terminated. 144 | configure:3705: $? = 4 145 | configure:3694: gcc -qversion >&5 146 | gcc: error: unrecognized command line option '-qversion' 147 | gcc: fatal error: no input files 148 | compilation terminated. 149 | configure:3705: $? = 4 150 | configure:3709: checking whether we are using the GNU C compiler 151 | configure:3728: gcc -c conftest.c >&5 152 | configure:3728: $? = 0 153 | configure:3737: result: yes 154 | configure:3746: checking whether gcc accepts -g 155 | configure:3766: gcc -c -g conftest.c >&5 156 | configure:3766: $? = 0 157 | configure:3807: result: yes 158 | configure:3824: checking for gcc option to accept ISO C89 159 | configure:3887: gcc -c -g -O2 conftest.c >&5 160 | configure:3887: $? = 0 161 | configure:3900: result: none needed 162 | configure:3922: checking dependency style of gcc 163 | configure:4033: result: gcc3 164 | configure:4054: checking how to run the C preprocessor 165 | configure:4085: gcc -E conftest.c 166 | configure:4085: $? = 0 167 | configure:4099: gcc -E conftest.c 168 | conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory 169 | #include 170 | ^ 171 | compilation terminated. 172 | configure:4099: $? = 1 173 | configure: failed program was: 174 | | /* confdefs.h */ 175 | | #define PACKAGE_NAME "Advancing-Front-Method_2D" 176 | | #define PACKAGE_TARNAME "advancing-front-method_2d" 177 | | #define PACKAGE_VERSION "1.0" 178 | | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 179 | | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 180 | | #define PACKAGE_URL "" 181 | | #define PACKAGE "advancing-front-method_2d" 182 | | #define VERSION "1.0" 183 | | /* end confdefs.h. */ 184 | | #include 185 | configure:4124: result: gcc -E 186 | configure:4144: gcc -E conftest.c 187 | configure:4144: $? = 0 188 | configure:4158: gcc -E conftest.c 189 | conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory 190 | #include 191 | ^ 192 | compilation terminated. 193 | configure:4158: $? = 1 194 | configure: failed program was: 195 | | /* confdefs.h */ 196 | | #define PACKAGE_NAME "Advancing-Front-Method_2D" 197 | | #define PACKAGE_TARNAME "advancing-front-method_2d" 198 | | #define PACKAGE_VERSION "1.0" 199 | | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 200 | | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 201 | | #define PACKAGE_URL "" 202 | | #define PACKAGE "advancing-front-method_2d" 203 | | #define VERSION "1.0" 204 | | /* end confdefs.h. */ 205 | | #include 206 | configure:4187: checking for grep that handles long lines and -e 207 | configure:4245: result: /bin/grep 208 | configure:4250: checking for egrep 209 | configure:4312: result: /bin/grep -E 210 | configure:4317: checking for ANSI C header files 211 | configure:4337: gcc -c -g -O2 conftest.c >&5 212 | configure:4337: $? = 0 213 | configure:4410: gcc -o conftest -g -O2 conftest.c >&5 214 | configure:4410: $? = 0 215 | configure:4410: ./conftest 216 | configure:4410: $? = 0 217 | configure:4421: result: yes 218 | configure:4434: checking for sys/types.h 219 | configure:4434: gcc -c -g -O2 conftest.c >&5 220 | configure:4434: $? = 0 221 | configure:4434: result: yes 222 | configure:4434: checking for sys/stat.h 223 | configure:4434: gcc -c -g -O2 conftest.c >&5 224 | configure:4434: $? = 0 225 | configure:4434: result: yes 226 | configure:4434: checking for stdlib.h 227 | configure:4434: gcc -c -g -O2 conftest.c >&5 228 | configure:4434: $? = 0 229 | configure:4434: result: yes 230 | configure:4434: checking for string.h 231 | configure:4434: gcc -c -g -O2 conftest.c >&5 232 | configure:4434: $? = 0 233 | configure:4434: result: yes 234 | configure:4434: checking for memory.h 235 | configure:4434: gcc -c -g -O2 conftest.c >&5 236 | configure:4434: $? = 0 237 | configure:4434: result: yes 238 | configure:4434: checking for strings.h 239 | configure:4434: gcc -c -g -O2 conftest.c >&5 240 | configure:4434: $? = 0 241 | configure:4434: result: yes 242 | configure:4434: checking for inttypes.h 243 | configure:4434: gcc -c -g -O2 conftest.c >&5 244 | configure:4434: $? = 0 245 | configure:4434: result: yes 246 | configure:4434: checking for stdint.h 247 | configure:4434: gcc -c -g -O2 conftest.c >&5 248 | configure:4434: $? = 0 249 | configure:4434: result: yes 250 | configure:4434: checking for unistd.h 251 | configure:4434: gcc -c -g -O2 conftest.c >&5 252 | configure:4434: $? = 0 253 | configure:4434: result: yes 254 | configure:4446: checking for stdbool.h that conforms to C99 255 | configure:4513: gcc -c -g -O2 conftest.c >&5 256 | configure:4513: $? = 0 257 | configure:4520: result: yes 258 | configure:4522: checking for _Bool 259 | configure:4522: gcc -c -g -O2 conftest.c >&5 260 | configure:4522: $? = 0 261 | configure:4522: gcc -c -g -O2 conftest.c >&5 262 | conftest.c: In function 'main': 263 | conftest.c:57:20: error: expected expression before ')' token 264 | if (sizeof ((_Bool))) 265 | ^ 266 | configure:4522: $? = 1 267 | configure: failed program was: 268 | | /* confdefs.h */ 269 | | #define PACKAGE_NAME "Advancing-Front-Method_2D" 270 | | #define PACKAGE_TARNAME "advancing-front-method_2d" 271 | | #define PACKAGE_VERSION "1.0" 272 | | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 273 | | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 274 | | #define PACKAGE_URL "" 275 | | #define PACKAGE "advancing-front-method_2d" 276 | | #define VERSION "1.0" 277 | | #define STDC_HEADERS 1 278 | | #define HAVE_SYS_TYPES_H 1 279 | | #define HAVE_SYS_STAT_H 1 280 | | #define HAVE_STDLIB_H 1 281 | | #define HAVE_STRING_H 1 282 | | #define HAVE_MEMORY_H 1 283 | | #define HAVE_STRINGS_H 1 284 | | #define HAVE_INTTYPES_H 1 285 | | #define HAVE_STDINT_H 1 286 | | #define HAVE_UNISTD_H 1 287 | | /* end confdefs.h. */ 288 | | #include 289 | | #ifdef HAVE_SYS_TYPES_H 290 | | # include 291 | | #endif 292 | | #ifdef HAVE_SYS_STAT_H 293 | | # include 294 | | #endif 295 | | #ifdef STDC_HEADERS 296 | | # include 297 | | # include 298 | | #else 299 | | # ifdef HAVE_STDLIB_H 300 | | # include 301 | | # endif 302 | | #endif 303 | | #ifdef HAVE_STRING_H 304 | | # if !defined STDC_HEADERS && defined HAVE_MEMORY_H 305 | | # include 306 | | # endif 307 | | # include 308 | | #endif 309 | | #ifdef HAVE_STRINGS_H 310 | | # include 311 | | #endif 312 | | #ifdef HAVE_INTTYPES_H 313 | | # include 314 | | #endif 315 | | #ifdef HAVE_STDINT_H 316 | | # include 317 | | #endif 318 | | #ifdef HAVE_UNISTD_H 319 | | # include 320 | | #endif 321 | | int 322 | | main () 323 | | { 324 | | if (sizeof ((_Bool))) 325 | | return 0; 326 | | ; 327 | | return 0; 328 | | } 329 | configure:4522: result: yes 330 | configure:4538: checking for pow 331 | configure:4538: gcc -o conftest -g -O2 conftest.c >&5 332 | conftest.c:45:6: warning: conflicting types for built-in function 'pow' [enabled by default] 333 | char pow (); 334 | ^ 335 | /tmp/cc1y022p.o: In function `main': 336 | /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/conftest.c:56: undefined reference to `pow' 337 | collect2: error: ld returned 1 exit status 338 | configure:4538: $? = 1 339 | configure: failed program was: 340 | | /* confdefs.h */ 341 | | #define PACKAGE_NAME "Advancing-Front-Method_2D" 342 | | #define PACKAGE_TARNAME "advancing-front-method_2d" 343 | | #define PACKAGE_VERSION "1.0" 344 | | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 345 | | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 346 | | #define PACKAGE_URL "" 347 | | #define PACKAGE "advancing-front-method_2d" 348 | | #define VERSION "1.0" 349 | | #define STDC_HEADERS 1 350 | | #define HAVE_SYS_TYPES_H 1 351 | | #define HAVE_SYS_STAT_H 1 352 | | #define HAVE_STDLIB_H 1 353 | | #define HAVE_STRING_H 1 354 | | #define HAVE_MEMORY_H 1 355 | | #define HAVE_STRINGS_H 1 356 | | #define HAVE_INTTYPES_H 1 357 | | #define HAVE_STDINT_H 1 358 | | #define HAVE_UNISTD_H 1 359 | | #define HAVE__BOOL 1 360 | | /* end confdefs.h. */ 361 | | /* Define pow to an innocuous variant, in case declares pow. 362 | | For example, HP-UX 11i declares gettimeofday. */ 363 | | #define pow innocuous_pow 364 | | 365 | | /* System header to define __stub macros and hopefully few prototypes, 366 | | which can conflict with char pow (); below. 367 | | Prefer to if __STDC__ is defined, since 368 | | exists even on freestanding compilers. */ 369 | | 370 | | #ifdef __STDC__ 371 | | # include 372 | | #else 373 | | # include 374 | | #endif 375 | | 376 | | #undef pow 377 | | 378 | | /* Override any GCC internal prototype to avoid an error. 379 | | Use char because int might match the return type of a GCC 380 | | builtin and then its argument prototype would still apply. */ 381 | | #ifdef __cplusplus 382 | | extern "C" 383 | | #endif 384 | | char pow (); 385 | | /* The GNU C library defines this for functions which it implements 386 | | to always fail with ENOSYS. Some functions are actually named 387 | | something starting with __ and the normal name is an alias. */ 388 | | #if defined __stub_pow || defined __stub___pow 389 | | choke me 390 | | #endif 391 | | 392 | | int 393 | | main () 394 | | { 395 | | return pow (); 396 | | ; 397 | | return 0; 398 | | } 399 | configure:4538: result: no 400 | configure:4538: checking for sqrt 401 | configure:4538: gcc -o conftest -g -O2 conftest.c >&5 402 | conftest.c:45:6: warning: conflicting types for built-in function 'sqrt' [enabled by default] 403 | char sqrt (); 404 | ^ 405 | /tmp/ccVnXWLq.o: In function `main': 406 | /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/conftest.c:56: undefined reference to `sqrt' 407 | collect2: error: ld returned 1 exit status 408 | configure:4538: $? = 1 409 | configure: failed program was: 410 | | /* confdefs.h */ 411 | | #define PACKAGE_NAME "Advancing-Front-Method_2D" 412 | | #define PACKAGE_TARNAME "advancing-front-method_2d" 413 | | #define PACKAGE_VERSION "1.0" 414 | | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 415 | | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 416 | | #define PACKAGE_URL "" 417 | | #define PACKAGE "advancing-front-method_2d" 418 | | #define VERSION "1.0" 419 | | #define STDC_HEADERS 1 420 | | #define HAVE_SYS_TYPES_H 1 421 | | #define HAVE_SYS_STAT_H 1 422 | | #define HAVE_STDLIB_H 1 423 | | #define HAVE_STRING_H 1 424 | | #define HAVE_MEMORY_H 1 425 | | #define HAVE_STRINGS_H 1 426 | | #define HAVE_INTTYPES_H 1 427 | | #define HAVE_STDINT_H 1 428 | | #define HAVE_UNISTD_H 1 429 | | #define HAVE__BOOL 1 430 | | /* end confdefs.h. */ 431 | | /* Define sqrt to an innocuous variant, in case declares sqrt. 432 | | For example, HP-UX 11i declares gettimeofday. */ 433 | | #define sqrt innocuous_sqrt 434 | | 435 | | /* System header to define __stub macros and hopefully few prototypes, 436 | | which can conflict with char sqrt (); below. 437 | | Prefer to if __STDC__ is defined, since 438 | | exists even on freestanding compilers. */ 439 | | 440 | | #ifdef __STDC__ 441 | | # include 442 | | #else 443 | | # include 444 | | #endif 445 | | 446 | | #undef sqrt 447 | | 448 | | /* Override any GCC internal prototype to avoid an error. 449 | | Use char because int might match the return type of a GCC 450 | | builtin and then its argument prototype would still apply. */ 451 | | #ifdef __cplusplus 452 | | extern "C" 453 | | #endif 454 | | char sqrt (); 455 | | /* The GNU C library defines this for functions which it implements 456 | | to always fail with ENOSYS. Some functions are actually named 457 | | something starting with __ and the normal name is an alias. */ 458 | | #if defined __stub_sqrt || defined __stub___sqrt 459 | | choke me 460 | | #endif 461 | | 462 | | int 463 | | main () 464 | | { 465 | | return sqrt (); 466 | | ; 467 | | return 0; 468 | | } 469 | configure:4538: result: no 470 | configure:4660: checking that generated files are newer than configure 471 | configure:4666: result: done 472 | configure:4693: creating ./config.status 473 | 474 | ## ---------------------- ## 475 | ## Running config.status. ## 476 | ## ---------------------- ## 477 | 478 | This file was extended by Advancing-Front-Method_2D config.status 1.0, which was 479 | generated by GNU Autoconf 2.69. Invocation command line was 480 | 481 | CONFIG_FILES = 482 | CONFIG_HEADERS = 483 | CONFIG_LINKS = 484 | CONFIG_COMMANDS = 485 | $ ./config.status 486 | 487 | on guangmu-ThinkPad-X240s 488 | 489 | config.status:855: creating Makefile 490 | config.status:855: creating config.h 491 | config.status:1084: executing depfiles commands 492 | 493 | ## ---------------- ## 494 | ## Cache variables. ## 495 | ## ---------------- ## 496 | 497 | ac_cv_c_compiler_gnu=yes 498 | ac_cv_cxx_compiler_gnu=yes 499 | ac_cv_env_CCC_set= 500 | ac_cv_env_CCC_value= 501 | ac_cv_env_CC_set= 502 | ac_cv_env_CC_value= 503 | ac_cv_env_CFLAGS_set= 504 | ac_cv_env_CFLAGS_value= 505 | ac_cv_env_CPPFLAGS_set= 506 | ac_cv_env_CPPFLAGS_value= 507 | ac_cv_env_CPP_set= 508 | ac_cv_env_CPP_value= 509 | ac_cv_env_CXXFLAGS_set= 510 | ac_cv_env_CXXFLAGS_value= 511 | ac_cv_env_CXX_set= 512 | ac_cv_env_CXX_value= 513 | ac_cv_env_LDFLAGS_set= 514 | ac_cv_env_LDFLAGS_value= 515 | ac_cv_env_LIBS_set= 516 | ac_cv_env_LIBS_value= 517 | ac_cv_env_build_alias_set= 518 | ac_cv_env_build_alias_value= 519 | ac_cv_env_host_alias_set= 520 | ac_cv_env_host_alias_value= 521 | ac_cv_env_target_alias_set= 522 | ac_cv_env_target_alias_value= 523 | ac_cv_func_pow=no 524 | ac_cv_func_sqrt=no 525 | ac_cv_header_inttypes_h=yes 526 | ac_cv_header_memory_h=yes 527 | ac_cv_header_stdbool_h=yes 528 | ac_cv_header_stdc=yes 529 | ac_cv_header_stdint_h=yes 530 | ac_cv_header_stdlib_h=yes 531 | ac_cv_header_string_h=yes 532 | ac_cv_header_strings_h=yes 533 | ac_cv_header_sys_stat_h=yes 534 | ac_cv_header_sys_types_h=yes 535 | ac_cv_header_unistd_h=yes 536 | ac_cv_objext=o 537 | ac_cv_path_EGREP='/bin/grep -E' 538 | ac_cv_path_GREP=/bin/grep 539 | ac_cv_path_install='/usr/bin/install -c' 540 | ac_cv_path_mkdir=/bin/mkdir 541 | ac_cv_prog_AWK=mawk 542 | ac_cv_prog_CPP='gcc -E' 543 | ac_cv_prog_ac_ct_CC=gcc 544 | ac_cv_prog_ac_ct_CXX=g++ 545 | ac_cv_prog_cc_c89= 546 | ac_cv_prog_cc_g=yes 547 | ac_cv_prog_cxx_g=yes 548 | ac_cv_prog_make_make_set=yes 549 | ac_cv_type__Bool=yes 550 | am_cv_CC_dependencies_compiler_type=gcc3 551 | am_cv_CXX_dependencies_compiler_type=gcc3 552 | 553 | ## ----------------- ## 554 | ## Output variables. ## 555 | ## ----------------- ## 556 | 557 | ACLOCAL='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/missing --run aclocal-1.12' 558 | AMDEPBACKSLASH='\' 559 | AMDEP_FALSE='#' 560 | AMDEP_TRUE='' 561 | AMTAR='$${TAR-tar}' 562 | AUTOCONF='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/missing --run autoconf' 563 | AUTOHEADER='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/missing --run autoheader' 564 | AUTOMAKE='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/missing --run automake-1.12' 565 | AWK='mawk' 566 | CC='gcc' 567 | CCDEPMODE='depmode=gcc3' 568 | CFLAGS='-g -O2' 569 | CPP='gcc -E' 570 | CPPFLAGS='' 571 | CXX='g++' 572 | CXXDEPMODE='depmode=gcc3' 573 | CXXFLAGS='-g0 -O3' 574 | CYGPATH_W='echo' 575 | DEFS='-DHAVE_CONFIG_H' 576 | DEPDIR='.deps' 577 | ECHO_C='' 578 | ECHO_N='-n' 579 | ECHO_T='' 580 | EGREP='/bin/grep -E' 581 | EXEEXT='' 582 | GREP='/bin/grep' 583 | INSTALL_DATA='${INSTALL} -m 644' 584 | INSTALL_PROGRAM='${INSTALL}' 585 | INSTALL_SCRIPT='${INSTALL}' 586 | INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' 587 | LDFLAGS='' 588 | LIBOBJS='' 589 | LIBS='' 590 | LTLIBOBJS='' 591 | MAKEINFO='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/missing --run makeinfo' 592 | MKDIR_P='/bin/mkdir -p' 593 | OBJEXT='o' 594 | PACKAGE='advancing-front-method_2d' 595 | PACKAGE_BUGREPORT='guangmuzhu@gmail.com' 596 | PACKAGE_NAME='Advancing-Front-Method_2D' 597 | PACKAGE_STRING='Advancing-Front-Method_2D 1.0' 598 | PACKAGE_TARNAME='advancing-front-method_2d' 599 | PACKAGE_URL='' 600 | PACKAGE_VERSION='1.0' 601 | PATH_SEPARATOR=':' 602 | SET_MAKE='' 603 | SHELL='/bin/sh' 604 | STRIP='' 605 | VERSION='1.0' 606 | ac_ct_CC='gcc' 607 | ac_ct_CXX='g++' 608 | am__EXEEXT_FALSE='' 609 | am__EXEEXT_TRUE='#' 610 | am__fastdepCC_FALSE='#' 611 | am__fastdepCC_TRUE='' 612 | am__fastdepCXX_FALSE='#' 613 | am__fastdepCXX_TRUE='' 614 | am__include='include' 615 | am__isrc='' 616 | am__leading_dot='.' 617 | am__nodep='_no' 618 | am__quote='' 619 | am__tar='$${TAR-tar} chof - "$$tardir"' 620 | am__untar='$${TAR-tar} xf -' 621 | bindir='${exec_prefix}/bin' 622 | build_alias='' 623 | datadir='${datarootdir}' 624 | datarootdir='${prefix}/share' 625 | docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' 626 | dvidir='${docdir}' 627 | exec_prefix='${prefix}' 628 | host_alias='' 629 | htmldir='${docdir}' 630 | includedir='${prefix}/include' 631 | infodir='${datarootdir}/info' 632 | install_sh='${SHELL} /home/guangmu/Documents/C-C++/advancing-front-method_2d-1.0/install-sh' 633 | libdir='${exec_prefix}/lib' 634 | libexecdir='${exec_prefix}/libexec' 635 | localedir='${datarootdir}/locale' 636 | localstatedir='${prefix}/var' 637 | mandir='${datarootdir}/man' 638 | mkdir_p='$(MKDIR_P)' 639 | oldincludedir='/usr/include' 640 | pdfdir='${docdir}' 641 | prefix='/usr/local' 642 | program_transform_name='s,x,x,' 643 | psdir='${docdir}' 644 | sbindir='${exec_prefix}/sbin' 645 | sharedstatedir='${prefix}/com' 646 | sysconfdir='${prefix}/etc' 647 | target_alias='' 648 | 649 | ## ----------- ## 650 | ## confdefs.h. ## 651 | ## ----------- ## 652 | 653 | /* confdefs.h */ 654 | #define PACKAGE_NAME "Advancing-Front-Method_2D" 655 | #define PACKAGE_TARNAME "advancing-front-method_2d" 656 | #define PACKAGE_VERSION "1.0" 657 | #define PACKAGE_STRING "Advancing-Front-Method_2D 1.0" 658 | #define PACKAGE_BUGREPORT "guangmuzhu@gmail.com" 659 | #define PACKAGE_URL "" 660 | #define PACKAGE "advancing-front-method_2d" 661 | #define VERSION "1.0" 662 | #define STDC_HEADERS 1 663 | #define HAVE_SYS_TYPES_H 1 664 | #define HAVE_SYS_STAT_H 1 665 | #define HAVE_STDLIB_H 1 666 | #define HAVE_STRING_H 1 667 | #define HAVE_MEMORY_H 1 668 | #define HAVE_STRINGS_H 1 669 | #define HAVE_INTTYPES_H 1 670 | #define HAVE_STDINT_H 1 671 | #define HAVE_UNISTD_H 1 672 | #define HAVE__BOOL 1 673 | 674 | configure: exit 0 675 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------