00001 #ifndef RefineConstants_HEADER
00002 #define RefineConstants_HEADER
00003
00004 #include <stdio.h>
00005 #include <math.h>
00006 #include <algorithm>
00007 #include <string>
00008
00009
00010
00011
00012 struct RefineConstants {
00013 double rho;
00014 double rhoprime;
00015
00016 double k;
00017
00018 bool useOffcenters;
00019
00031 int bbox_points;
00032 double bbox_buffer;
00033 bool cleanup;
00034
00035 double sigma;
00036 double sliverGrowth;
00037 double perturbFactor;
00038
00042 enum OutputStyle { NO_OUTPUT, QUAKE } outputStyle;
00043 enum InputStyle { NODE, POLY, AUTOMATIC } inputStyle;
00044 std::string filename;
00045
00057 enum NodeOrder { ID_ORDER, INSERTION_ORDER_RENUMBER, INSERTION_ORDER_NORENUMBER };
00058 NodeOrder nodeOrder;
00059
00062 RefineConstants() {
00063 rho = 0.0;
00064 rhoprime = 0.0;
00065 k = 0.0;
00066
00067 useOffcenters = true;
00068
00069 bbox_points = -1;
00070 bbox_buffer = -1;
00071
00072 cleanup = false;
00073
00074 sigma = 0.0;
00075 sliverGrowth = 3;
00076 perturbFactor = 0.1;
00077
00078 outputStyle = QUAKE;
00079 inputStyle = AUTOMATIC;
00080
00081 nodeOrder = ID_ORDER;
00082 }
00083
00085 void regularize(size_t d, bool pointcloud) {
00086
00087
00088
00089
00090
00091 const double minrho = pointcloud
00092 ? 1.0
00093 : pow(2.0, d);
00094
00095 if (rho == 0.0) {
00096 rho = pointcloud ? sqrt(2.0) : minrho;
00097 } else if (rho < minrho - 1e-8) {
00098 fprintf(stderr, "Warning: rho small; we may not terminate (we need %g > %g)\n", rho, minrho);
00099 } else if (rho <= 1.0) {
00100 fprintf(stderr, "Error: rho (%g) must be strictly greater than 1.0\n", rho);
00101 exit(1);
00102 }
00103
00104 if (k == 0.0) {
00105 k = 0.9;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 const double kprime = std::min(k, 1.0-k);
00115 const double denominator = pointcloud ? kprime : pow(kprime, d);
00116 const double minrhoprime = minrho / denominator;
00117
00118 if (rhoprime == 0.0) {
00119 rhoprime = std::max(rho, minrhoprime);
00120 } else {
00121 if (rhoprime < minrhoprime - 1e-8) {
00122 fprintf(stderr, "Warning: rhoprime small (%g); we may not terminate"
00123 " (we need %g*%g > %g)\n", rhoprime, k, rhoprime, minrho);
00124 }
00125 }
00126
00127
00128
00129 if (d < 3) {
00130 sigma = 0.0;
00131 }
00132 }
00133 };
00134
00135 #endif