diff -ur a/bigrational_vector.cc b/bigrational_vector.cc --- a/bigrational_vector.cc 2006-04-16 22:22:38.000000000 -0500 +++ b/bigrational_vector.cc 2011-04-27 12:45:41.000000000 -0500 @@ -12,6 +12,21 @@ rep = 0; } +bigrational_vector :: bigrational_vector(int x, int y) { + dim = 2; + rep = new bigrational[dim]; + rep[0] = x; + rep[1] = y; +} + +bigrational_vector :: bigrational_vector(int x, int y, int z) { + dim = 3; + rep = new bigrational[dim]; + rep[0] = x; + rep[1] = y; + rep[2] = z; +} + bigrational_vector :: bigrational_vector(const unsigned long n, const bigrational* X) : dim(n) Only in b/: bryan.cc diff -ur a/config.cc b/config.cc --- a/config.cc 2006-04-16 22:22:38.000000000 -0500 +++ b/config.cc 2011-04-27 11:26:36.000000000 -0500 @@ -8,4 +8,11 @@ bigrational epsilon = bigrational(1, 8); bigrational s_epsilon = bigrational(1, 8); bigrational t_epsilon = bigrational(1, 16); +unsigned long num_root1_isolate; +unsigned long num_kratpoly_exact_sgn_at; +unsigned long num_ksolid_boolean; +unsigned long num_kratpoly_sgn_at; +unsigned long num_root1_exact_isolate; +unsigned long num_kpoint1d_get_pts; +unsigned long num_kpoint2d_get_pts; Only in b/: .kcurve.cc.swp Only in b/: .kpoint2d.cc.swp diff -ur a/kratpoly.cc b/kratpoly.cc --- a/kratpoly.cc 2006-04-16 22:22:38.000000000 -0500 +++ b/kratpoly.cc 2011-04-25 18:40:59.000000000 -0500 @@ -6,6 +6,7 @@ #endif #include +#include #include #include Only in b/: .kratpoly.cc.swp diff -ur a/ksolid.cc b/ksolid.cc --- a/ksolid.cc 2006-04-16 22:22:38.000000000 -0500 +++ b/ksolid.cc 2011-04-30 17:02:17.000000000 -0500 @@ -15,6 +15,10 @@ #include #include +//first onnne might be [] +extern int planarize(const bigrational_vector[], bigrational_vector[], const unsigned long); +extern int perturb_box(const bigrational_vector[], bigrational_vector[], const unsigned long, const bigrational&); + K_SOLID :: K_SOLID() { num_patches = 0; @@ -39,6 +43,23 @@ patches = 0; } +void K_SOLID :: initialize_from_patches(K_PATCH* const p[], const unsigned long n) { + unsigned long i; + + if ((num_patches = n) > 0) + { + patches = new K_PATCH* [num_patches]; + + for (i = 0; i < num_patches; i++) + { + patches[i] = p[i]; + patches[i]->ref_count++; + } + } + else // if (!num_patches) + patches = 0; +} + K_SOLID :: K_SOLID(const K_SOLID& s) { unsigned long i; @@ -1886,3 +1907,334 @@ return s3; } +// K_SOLID gen_box(const bigrational_vector pts[], +// const unsigned long num_pts) +// returns a box whose corners are pts. + +void K_SOLID :: internal_gen_box(const bigrational_vector pts[], const unsigned long num_pts) +{ + assert(num_pts == 8); + + const unsigned long num_patches = 6; + + unsigned long i; + bigrational_vector four_pts[4]; + K_PATCH* patches[6]; + + // + // 7-------------6 + // /| /| + // / | / | + // / | / | + // 4-------------5 | + // | | | | + // | | | | + // | | | | + // | 0---------|---1 + // | / | / + // | / | / + // |/ |/ + // 3-------------2 + // + // 1. Set pathces. + + // patches[0]: (0 1 2 3) + + four_pts[0] = pts[0]; + four_pts[1] = pts[1]; + four_pts[2] = pts[2]; + four_pts[3] = pts[3]; + get_patch4(four_pts, patches[0]); + + // patches[1]: (1 0 7 6) + + four_pts[0] = pts[1]; + four_pts[1] = pts[0]; + four_pts[2] = pts[7]; + four_pts[3] = pts[6]; + get_patch4(four_pts, patches[1]); + + // patches[2]: (2 1 6 5) + + four_pts[0] = pts[2]; + four_pts[1] = pts[1]; + four_pts[2] = pts[6]; + four_pts[3] = pts[5]; + get_patch4(four_pts, patches[2]); + + // patches[3]: (3 2 5 4) + + four_pts[0] = pts[3]; + four_pts[1] = pts[2]; + four_pts[2] = pts[5]; + four_pts[3] = pts[4]; + get_patch4(four_pts, patches[3]); + + // patches[4]: (0 3 4 7) + + four_pts[0] = pts[0]; + four_pts[1] = pts[3]; + four_pts[2] = pts[4]; + four_pts[3] = pts[7]; + get_patch4(four_pts, patches[4]); + + // patches[5]: (4 5 6 7) + + four_pts[0] = pts[4]; + four_pts[1] = pts[5]; + four_pts[2] = pts[6]; + four_pts[3] = pts[7]; + get_patch4(four_pts, patches[5]); + + // 2. For each patch, set its adj_surfs and adj_patches. + + // patches[0]: + + patches[0]->adj_surfs[0] = patches[1]->surf; + patches[0]->adj_surfs[0]->ref_count++; + patches[0]->adj_surfs[1] = patches[2]->surf; + patches[0]->adj_surfs[1]->ref_count++; + patches[0]->adj_surfs[2] = patches[3]->surf; + patches[0]->adj_surfs[2]->ref_count++; + patches[0]->adj_surfs[3] = patches[4]->surf; + patches[0]->adj_surfs[3]->ref_count++; + + patches[0]->adj_patches[0] = patches[1]; + patches[0]->adj_patches[0]->ref_count++; + patches[0]->adj_patches[1] = patches[2]; + patches[0]->adj_patches[1]->ref_count++; + patches[0]->adj_patches[2] = patches[3]; + patches[0]->adj_patches[2]->ref_count++; + patches[0]->adj_patches[3] = patches[4]; + patches[0]->adj_patches[3]->ref_count++; + + // patches[1]: + + patches[1]->adj_surfs[0] = patches[0]->surf; + patches[1]->adj_surfs[0]->ref_count++; + patches[1]->adj_surfs[1] = patches[4]->surf; + patches[1]->adj_surfs[1]->ref_count++; + patches[1]->adj_surfs[2] = patches[5]->surf; + patches[1]->adj_surfs[2]->ref_count++; + patches[1]->adj_surfs[3] = patches[2]->surf; + patches[1]->adj_surfs[3]->ref_count++; + + patches[1]->adj_patches[0] = patches[0]; + patches[1]->adj_patches[0]->ref_count++; + patches[1]->adj_patches[1] = patches[4]; + patches[1]->adj_patches[1]->ref_count++; + patches[1]->adj_patches[2] = patches[5]; + patches[1]->adj_patches[2]->ref_count++; + patches[1]->adj_patches[3] = patches[2]; + patches[1]->adj_patches[3]->ref_count++; + + // patches[2]: + + patches[2]->adj_surfs[0] = patches[0]->surf; + patches[2]->adj_surfs[0]->ref_count++; + patches[2]->adj_surfs[1] = patches[1]->surf; + patches[2]->adj_surfs[1]->ref_count++; + patches[2]->adj_surfs[2] = patches[5]->surf; + patches[2]->adj_surfs[2]->ref_count++; + patches[2]->adj_surfs[3] = patches[3]->surf; + patches[2]->adj_surfs[3]->ref_count++; + + patches[2]->adj_patches[0] = patches[0]; + patches[2]->adj_patches[0]->ref_count++; + patches[2]->adj_patches[1] = patches[1]; + patches[2]->adj_patches[1]->ref_count++; + patches[2]->adj_patches[2] = patches[5]; + patches[2]->adj_patches[2]->ref_count++; + patches[2]->adj_patches[3] = patches[3]; + patches[2]->adj_patches[3]->ref_count++; + + // patches[3]: + + patches[3]->adj_surfs[0] = patches[0]->surf; + patches[3]->adj_surfs[0]->ref_count++; + patches[3]->adj_surfs[1] = patches[2]->surf; + patches[3]->adj_surfs[1]->ref_count++; + patches[3]->adj_surfs[2] = patches[5]->surf; + patches[3]->adj_surfs[2]->ref_count++; + patches[3]->adj_surfs[3] = patches[4]->surf; + patches[3]->adj_surfs[3]->ref_count++; + + patches[3]->adj_patches[0] = patches[0]; + patches[3]->adj_patches[0]->ref_count++; + patches[3]->adj_patches[1] = patches[2]; + patches[3]->adj_patches[1]->ref_count++; + patches[3]->adj_patches[2] = patches[5]; + patches[3]->adj_patches[2]->ref_count++; + patches[3]->adj_patches[3] = patches[4]; + patches[3]->adj_patches[3]->ref_count++; + + // patches[4]: + + patches[4]->adj_surfs[0] = patches[0]->surf; + patches[4]->adj_surfs[0]->ref_count++; + patches[4]->adj_surfs[1] = patches[3]->surf; + patches[4]->adj_surfs[1]->ref_count++; + patches[4]->adj_surfs[2] = patches[5]->surf; + patches[4]->adj_surfs[2]->ref_count++; + patches[4]->adj_surfs[3] = patches[1]->surf; + patches[4]->adj_surfs[3]->ref_count++; + + patches[4]->adj_patches[0] = patches[0]; + patches[4]->adj_patches[0]->ref_count++; + patches[4]->adj_patches[1] = patches[3]; + patches[4]->adj_patches[1]->ref_count++; + patches[4]->adj_patches[2] = patches[5]; + patches[4]->adj_patches[2]->ref_count++; + patches[4]->adj_patches[3] = patches[1]; + patches[4]->adj_patches[3]->ref_count++; + + // patches[5]: + + patches[5]->adj_surfs[0] = patches[3]->surf; + patches[5]->adj_surfs[0]->ref_count++; + patches[5]->adj_surfs[1] = patches[2]->surf; + patches[5]->adj_surfs[1]->ref_count++; + patches[5]->adj_surfs[2] = patches[1]->surf; + patches[5]->adj_surfs[2]->ref_count++; + patches[5]->adj_surfs[3] = patches[4]->surf; + patches[5]->adj_surfs[3]->ref_count++; + + patches[5]->adj_patches[0] = patches[3]; + patches[5]->adj_patches[0]->ref_count++; + patches[5]->adj_patches[1] = patches[2]; + patches[5]->adj_patches[1]->ref_count++; + patches[5]->adj_patches[2] = patches[1]; + patches[5]->adj_patches[2]->ref_count++; + patches[5]->adj_patches[3] = patches[4]; + patches[5]->adj_patches[3]->ref_count++; + + // 3. Associate edges. + + patches[0]->trim_curves[0]->assoc(patches[1]->trim_curves[0], - 1); + patches[0]->trim_curves[1]->assoc(patches[2]->trim_curves[0], - 1); + patches[0]->trim_curves[2]->assoc(patches[3]->trim_curves[0], - 1); + patches[0]->trim_curves[3]->assoc(patches[4]->trim_curves[0], - 1); + + patches[5]->trim_curves[0]->assoc(patches[3]->trim_curves[2], - 1); + patches[5]->trim_curves[1]->assoc(patches[2]->trim_curves[2], - 1); + patches[5]->trim_curves[2]->assoc(patches[1]->trim_curves[2], - 1); + patches[5]->trim_curves[3]->assoc(patches[4]->trim_curves[2], - 1); + + patches[1]->trim_curves[3]->assoc(patches[2]->trim_curves[1], - 1); + patches[2]->trim_curves[3]->assoc(patches[3]->trim_curves[1], - 1); + patches[3]->trim_curves[3]->assoc(patches[4]->trim_curves[1], - 1); + patches[4]->trim_curves[3]->assoc(patches[1]->trim_curves[1], - 1); + + for (i = 0; i < num_patches; i++) + { + patches[i]->surf->X->reduce_deg(); + patches[i]->surf->Y->reduce_deg(); + patches[i]->surf->Z->reduce_deg(); + patches[i]->surf->W->reduce_deg(); + } + + initialize_from_patches(patches, num_patches); +} + +void K_SOLID :: internal_read_box(istream& in_fs, const bigrational& perturb_factor) +{ + unsigned long i, j; +// unsigned long type; + unsigned long num_pts; + bigrational_vector* inp_pts; + bigrational_vector* pts; + bigrational_vector* perturbed_pts; + +// in_fs >> type; +// cerr << " genbox: read_box: type = " << type << endl << flush; +// assert(type == 1); + in_fs >> num_pts; +// cerr << " genbox: read_box: num_pts = " << num_pts << endl << flush; + cerr << endl << flush; + + // 1. Read inp_pts from is_fs. + + if (num_pts > 0) + { + inp_pts = new bigrational_vector [num_pts]; // num_pts > 0 + + for (i = 0; i < num_pts; i++) + { + inp_pts[i] = bigrational_vector(3); + + cerr << " genbox: read_box: inp_pts[" << i << "] = ( "; + for (j = 0; j < 3; j++) + { + in_fs >> inp_pts[i][j]; + + cerr << inp_pts[i][j]; + if (j < 2) + cerr << ", "; + } + cerr << " )" << endl << flush; + } + cerr << endl << flush; + } + else // if (num_pts == 0) + inp_pts = 0; + + // 2. Planarize inp_pts to pts. + + if (num_pts > 0) + { + pts = new bigrational_vector [num_pts]; // num_pts > 0 + + planarize(inp_pts, pts, num_pts); + + for (i = 0; i < num_pts; i++) + cerr << " genbox: read_box: pts[" << i << "] =" << pts[i] << endl << flush; + cerr << endl << flush; + + delete [] inp_pts; // num_pts > 0 => inp_pts != 0 + } + else // if (num_pts == 0) + pts = 0; + + // 3. Perturb pts if necessarily and generate a box. + + if (!sgn(perturb_factor)) + { + if (num_pts > 0) + internal_gen_box(pts, num_pts); + + if (num_pts > 0) + delete [] pts; // num_pts > 0 => pts != 0 + } + else // if (sgn(perturb_factor)) + { + if (num_pts > 0) + { + perturbed_pts = new bigrational_vector [num_pts]; // num_pts > 0 + + perturb_box(pts, perturbed_pts, num_pts, perturb_factor); + + for (i = 0; i < num_pts; i++) + cerr << " genbox: read_box: perturbed_pts[" << i << "] =" << perturbed_pts[i] << endl << flush; + cerr << endl << flush; + + delete [] pts; // num_pts > 0 => pts != 0 + } + else // if (num_pts == 0) + perturbed_pts = 0; + + if (num_pts > 0) + internal_gen_box(perturbed_pts, num_pts); + + if (num_pts > 0) + delete [] perturbed_pts; // num_pts > 0 => perturbed_pts != 0 + } + +} +void K_SOLID :: bryan_read_box_from_file(const char* filepath) { + ifstream in_file; + in_file.open(filepath); + internal_read_box(in_file, 0); + in_file.close(); +} + + diff -ur a/root1.cc b/root1.cc --- a/root1.cc 2006-04-16 22:22:38.000000000 -0500 +++ b/root1.cc 2011-04-27 10:50:35.000000000 -0500 @@ -599,9 +599,10 @@ unsigned long ROOT1 :: isolate_roots(ROOT1*& R, const bigrational& tol) { -#ifdef _EXPERIMENT +/* #ifdef _EXPERIMENT num_root1_isolate++; #endif +*/ if (num_roots == 0) R = 0; @@ -766,9 +767,11 @@ if (use_exact) // Fp estimations do not work. Use exact arithmetic. { + /* #ifdef _EXPERIMENT num_root1_exact_isolate++; #endif +*/ bigrational half; unsigned long num_perm_half, diff_num_perm_l, diff_num_perm_h;