void CModel::FacetHarmonics(int fh, int bw, double r, gsl_complex *coeff){ int i, j, sign; gsl_complex err; Triangle_3 tr; tr = Triangle_3(plist[flist[fh*3+0]],plist[flist[fh*3+1]],plist[flist[fh*3+2]]); Tetrahedron_3 tetr; tetr = Tetrahedron_3(Point_3(0.0, 0.0, 0.0),plist[flist[fh*3+0]],plist[flist[fh*3+1]],plist[flist[fh*3+2]]); if(tetr.is_degenerate()) return; sign = (tetr.volume()<0 ? -1 : 1); for(i=0; i<bw; i++){ for(j=0; j<=i; j++){ Integrate(i, j, r, tetr, &coeff[i*bw+j], &err); coeff[i*bw+j] = gsl_complex_mul_real(coeff[i*bw+j], (double)sign); } } }
bool does_intersect_convex_polygon_segment_3_in_3d(const vector<Point>& conv_poly, const Segment& s) { // dissect the polygon into a set of triangles with common apex at the centroid. Vector centroid = CGAL::NULL_VECTOR; vector<Triangle_3> t; for(int i = 0; i < (int)conv_poly.size(); i ++) centroid = centroid + (conv_poly[i] - CGAL::ORIGIN); centroid = (1./(int)conv_poly.size()) * centroid; for(int i = 0; i < (int)conv_poly.size(); i ++) t.push_back(Triangle_3(CGAL::ORIGIN + centroid, conv_poly[i], conv_poly[(i+1)%((int)conv_poly.size())])); //CGAL::Failure_function old_ff = CGAL::set_error_handler(failure_func); //CGAL::Failure_behaviour old_fb = CGAL::set_error_behaviour(CGAL::CONTINUE); // Now for every triangle in t check if the Delaunay edge e intersects it. // use CGAL routine. bool is_degenerate_poly = true; for(int i = 0; i < (int)t.size(); i ++) { cgal_failed = false; bool intersect_result = CGAL::do_intersect(t[i], s); if(cgal_failed) continue; is_degenerate_poly = false; if(intersect_result) { //CGAL::set_error_handler(old_ff); //CGAL::set_error_behaviour(old_fb); is_degenerate_poly = false; return true; } } //CGAL::set_error_handler(old_ff); //CGAL::set_error_behaviour(old_fb); if(is_degenerate_poly) cerr << "+"; return false; }
// ------------------------------------------------------------- // dg_voronoi_point // ------------------------------------------------------------- // This function computes a voronoi point when some degeneracies // have been discovered about the four points of a tetrahedron. // // In this function we assume that the degeneracies occured // because of the coplanarity. We approximate the circumcenter // of the tetrahedron by the circumcenter of one of the triangular // facets. // ------------------------------------------------------------- Point dg_voronoi_point(const Point &a, const Point &b, const Point &c, const Point &d, bool &is_correct_computation) { // First, we check if our assumption is correct. // This is more of a debugging purpose than of // actual computation. Tetrahedron t = Tetrahedron(a,b,c,d); if( ! t.is_degenerate() ) { // cerr << "error in the assumption of coplanarity." << endl; /* // debug cout << "{OFF " << endl; cout << "4 4 0" << endl; cout << a << "\n" << b << "\n" << c << "\n" << d << endl; cout << "3\t0 1 2" << endl; cout << "3\t0 2 3" << endl; cout << "3\t0 3 1" << endl; cout << "3\t1 2 3" << endl; cout << "}" << endl; // end debug */ } // Approximate the circumcenter of the tetrahedron with that of // one of its triangular facets. The facet should not be collinear. // The following boolean variable will keep track if we have found // a valid circumcenter (of a triangle) to replace that of a // tetrahedron. Point cc = CGAL::ORIGIN; is_correct_computation = false; Point p[4] = {a,b,c,d}; for(int i = 0; i < 4; i ++) { // first check if the facet is degenerate or not. Triangle_3 t = Triangle_3(p[(i+1)%4], p[(i+2)%4], p[(i+3)%4]); if( t.is_degenerate() ) continue; // since we found a non-degenerate triangle we can now compute // its circumcenter and we will be done. cc = nondg_cc_tr_3(p[(i+1)%4], p[(i+2)%4], p[(i+3)%4], is_correct_computation); if( is_correct_computation ) break; } if( is_correct_computation ) { if(cc == CGAL::ORIGIN) cerr << "<dg_vp : returning cc as ORIGIN>" << endl; return cc; } cerr << "four points are colinear. " << endl; // for the time being, I just average the four points. What should be // the circumcenter of a tetrahedron whose four points are collinear ? cc = CGAL::ORIGIN + ( 0.25*Vector ( a[0]+b[0]+c[0]+d[0], a[1]+b[1]+c[1]+d[1], a[2]+b[2]+c[2]+d[2] ) ); if(cc == CGAL::ORIGIN) cerr << "<dg_vp : returning cc as ORIGIN>" << endl; return cc; }