예제 #1
0
파일: alpha_3.cpp 프로젝트: hksonngan/phat
// Returns whether the facet facet is attached to the cell
// that is used to represent facet
bool edge_attached_to(const DT_3& dt, const Edge& edge, const Facet& facet) {
  
  if(dt.is_infinite(facet)) {
    return false;
  }

  Vertex_handle v1 = edge.first->vertex(edge.second);
  Vertex_handle v2 = edge.first->vertex(edge.third);

  Cell_handle cell = facet.first;
  int i1 = facet.second;
  int i2 = cell->index(v1);
  int i3 = cell->index(v2);
  CGAL_assertion(i1!=i2);
  CGAL_assertion(i1!=i3);
  CGAL_assertion(i2!=i3);
  int j = 0;
  
  while(j==i1 || j==i2 || j==i3) {
    j++;
  }
  // j is the index of the third point of the facet
  Vertex_handle w = cell->vertex(j);
  
  return CGAL::side_of_bounded_sphere(v1->point(),v2->point(),w->point())==CGAL::ON_BOUNDED_SIDE;

}
예제 #2
0
int main()
{
    const int D = 5;   // we work in Euclidean 5-space
    const int N = 100; // we will insert 100 points
    // - - - - - - - - - - - - - - - - - - - - - - - - STEP 1
    CGAL::Random_points_in_cube_d<Triangulation::Point> rand_it(D, 1.0);
    std::vector<Triangulation::Point> points;
    CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));

    Triangulation t(D);                      // create triangulation
    CGAL_assertion(t.empty());
    t.insert(points.begin(), points.end());  // compute triangulation
    CGAL_assertion( t.is_valid() );
    // - - - - - - - - - - - - - - - - - - - - - - - - STEP 2
    typedef Triangulation::Face Face;
    typedef std::vector<Face> Faces;
    Faces edges;
    std::back_insert_iterator<Faces> out(edges);
    t.tds().incident_faces(t.infinite_vertex(), 1, out);  
    // collect faces of dimension 1 (edges) incident to the infinite vertex
    std::cout << "There are " << edges.size() 
              << " vertices on the convex hull." << std::endl;

#include "triangulation1.cpp" // See below
#include "triangulation2.cpp"

    return 0;
}
int get_free_edge(CDT::Face_handle fh)
{
  CGAL_assertion( number_of_existing_edge(fh)==2 );
  for (int i=0; i<3; ++i)
    if (!fh->info().exist_edge[i]) return i;
  
  CGAL_assertion(false);
  return -1;
}
예제 #4
0
inline
void MP_Float::construct_from_builtin_fp_type(T d)
{
    if (d == 0)
      return;

    // Protection against rounding mode != nearest, and extended precision.
    Set_ieee_double_precision P;

    CGAL_assertion(is_finite(d));

    // This is subtle, because ints are not symetric against 0.

    // First, scale d, and adjust exp accordingly.
    exp = 0;
    while (d < trunc_min || d > trunc_max) {
      ++exp;
      d /= base;
    }

    while (d >= trunc_min/base && d <= trunc_max/base) {
      --exp;
      d *= base;
    }

    // Then, compute the limbs.
    // Put them in v (in reverse order temporarily).
    T orig = d, sum = 0;
    while (true) {
      int r = my_nearbyint(d);
      if (d-r >= T(base/2-1)/(base-1))
        ++r;
      v.push_back(r);
      // We used to do simply "d -= v.back();", but when the most significant
      // limb is 1 and the second is -32768, then it can happen that
      // |d - v.back()| > |d|, hence a bit of precision can be lost.
      //  Hence the need for sum/orig.
      sum += v.back();
      d = orig-sum;
      if (d == 0)
        break;
      sum *= base;
      orig *= base;
      d *= base;
      --exp;
    }

    // Reverse v.
    std::reverse(v.begin(), v.end());

    CGAL_assertion(v.back() != 0);
}
예제 #5
0
int main(){
    int N = 3;
    CGAL::Timer cost;
    std::vector<Point_d> points;
   

   Point_d point1(1,3,5);
   Point_d point2(4,8,10);
   Point_d point3(2,7,9);

    Point_d point(1,2,3);


    points.push_back(point1);
    points.push_back(point2);
    points.push_back(point3);
   
    K Kernel 
    D Dt(d,Kernel,Kernel);
  //  CGAL_assertion(Dt.empty());
   
    // insert the points in the triangulation
    cost.reset();cost.start();
    std::cout << "  Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush;
    std::vector<Point_d>::iterator it;
    for(it = points.begin(); it!= points.end(); ++it){
	Dt.insert(*it); 
    }
    std::list<Simplex_handle> NL = Dt.all_simplices(D::NEAREST);
    std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
    CGAL_assertion(Dt.is_valid() );
    CGAL_assertion(!Dt.empty());
 
   
    Vertex_handle v = Dt.nearest_neighbor(point);
    Simplex_handle s = Dt.simplex(v);    
     
    std::vector<Point_d> Simplex_vertices;
    for(int j=0; j<=d; ++j){
 	  Vertex_handle vertex = Dt.vertex_of_simplex(s,j);
       	  Simplex_vertices.push_back(Dt.associated_point(vertex));
     }
    
    std::vector<K::FT> coords;
    K::Barycentric_coordinates_d BaryCoords;
    BaryCoords(Simplex_vertices.begin(), Simplex_vertices.end(),point,std::inserter(coords, coords.begin()));
    std::cout << coords[0] << std::endl; 
   return 0;
}
예제 #6
0
int main(int argc, char **argv)
{
  int N = 100; if( argc > 2 )N = atoi(argv[1]); // number of points
  CGAL::Timer cost;  // timer

  // Instanciate a random point generator
  CGAL::Random rng(0);
  typedef CGAL::Random_points_in_cube_d<T::Point> Random_points_iterator;
  Random_points_iterator rand_it(D, 1.0, rng);
  // Generate N random points
  std::vector<T::Point> points;
  CGAL::cpp11::copy_n(rand_it, N, std::back_inserter(points));
  
  T t(D);
  CGAL_assertion(t.empty());
  
  // insert the points in the triangulation
  cost.reset();cost.start();
  std::cout << "  Delaunay triangulation of "<<N<<" points in dim "<<D<< std::flush;
  t.insert(points.begin(), points.end());
  std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
  CGAL_assertion( t.is_valid() );

  // insert with special operations in conflict zone and new created cells
  cost.reset();
  std::cout << "  adding "<<N<<" other points "<< std::endl;
  for(int i=0; i<N; ++i)
  {
    T::Vertex_handle v;
    T::Face f(t.current_dimension()); 
    T::Facet ft; 
    T::Full_cell_handle c; 
    T::Locate_type lt;
    typedef std::vector<T::Full_cell_handle> Full_cells; 
    Full_cells zone, new_full_cells; 
    std::back_insert_iterator<Full_cells> out(zone); 
    c = t.locate(*++rand_it, lt, f, ft, v);
    // previously inserted vertex v is used as hint for point location (if defined)
    T::Facet ftc = t.compute_conflict_zone(*rand_it, c, out); 
    std::cout<<i<<"     conflict zone of size "<<zone.size()<<" -> "<<std::flush;
    out = std::back_inserter(new_full_cells);
    CGAL_assertion( t.is_valid() );
    v = t.insert_in_hole(*rand_it, zone.begin(), zone.end(), ftc, out);
    std::cout<<new_full_cells.size()<<" new cells"<<std::endl;
  }

  std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
  return 0;
}
예제 #7
0
int main(int argc, char* argv[]) {

  assert(argc>1 && argc < 7);
  
  int nx = argc>2 ? std::atoi(argv[2]) : 2;
  int ny = argc>3 ? std::atoi(argv[3]) : 2;
  int nz = argc>4 ? std::atoi(argv[4]) : 2;

  std::ifstream in(argv[1]);
  Nef_polyhedron Nin;
  in >> Nin;
  Nin.transform(Aff_transformation_3(CGAL::SCALING,2,1));
  std::ostringstream out1;
  ggen g(out1, Nin);
  g.print(nx,ny,nz);
  std::istringstream in1(out1.str());
  Nef_polyhedron N1;
  in1 >> N1;
  RT s = g.size_x();
  N1.transform(Aff_transformation_3(CGAL::TRANSLATION,Vector_3(s,s,s,2)));
  CGAL_assertion(N1.is_valid());

  std::ostringstream out2;
  CGAL::Random r;
  if(argc>5) {
    tgen t2(out2,s,std::atoi(argv[5]));
    t2.create_tetrahedra(nx+1,ny+1,nz+1);
  } else {
    tgen t2(out2,s);
    t2.create_tetrahedra(nx+1,ny+1,nz+1);    
  }
  std::istringstream in2(out2.str());
  Nef_polyhedron N2;
  in2 >> N2;
  CGAL_assertion(N2.is_valid());

  cgal_nef3_timer_on = true;

#if defined CGAL_NEF3_UNION
  N1.join(N2);
#elif defined CGAL_NEF3_INTERSECTION
  N1.intersection(N2);
#elif defined CGAL_NEF3_DIFFERENCE
  N1.difference(N2);
#else
  N1.symmetric_difference(N2);
#endif
}
int main()
{
  std::vector<Point> points;
  points.push_back(Point(0,0));
  points.push_back(Point(1,0));
  points.push_back(Point(0,1));
  points.push_back(Point(4,10));
  points.push_back(Point(2,2));
  points.push_back(Point(-1,0));

  
  Delaunay T;
  T.insert( boost::make_transform_iterator(points.begin(),Auto_count()),
            boost::make_transform_iterator(points.end(),  Auto_count() )  );

  CGAL_assertion( T.number_of_vertices() == 6 );
  
  // check that the info was correctly set.
  Delaunay::Finite_vertices_iterator vit;
  for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
    if( points[ vit->info() ] != vit->point() ){
      std::cerr << "Error different info" << std::endl;
      exit(EXIT_FAILURE);
    }
  std::cout << "OK" << std::endl;
  
  return 0;
}
예제 #9
0
int main() {
    Polyhedron P;
    Build_triangle<HalfedgeDS> triangle;
    P.delegate( triangle);
    CGAL_assertion( P.is_triangle( P.halfedges_begin()));
    return 0;
}
예제 #10
0
void merge_cluster(map<int, cell_cluster> &cluster_set, int rep1, int rep2)
{
   cell_cluster *c_rep1 = &cluster_set[rep1]; // head of cluster 1
   cell_cluster *c = &cluster_set[c_rep1->tail]; // tail of cluster 1
   CGAL_assertion(c != 0);
   CGAL_assertion(c->nxt == NULL);
   cell_cluster *c_rep2 = &cluster_set[rep2];
   c_rep1->tail = c_rep2->tail;

   c->nxt = c_rep2;
   while(c->nxt != 0) 
   { 
      c->nxt->rep = rep1;
      c = c->nxt; 
   }
}
예제 #11
0
void add_cell_to_cluster(map<int, cell_cluster> &cluster_set, int rep1, int rep2)
{
   cell_cluster *c_rep1 = &cluster_set[rep1]; // pointer to the head of 1st cluster.
   cell_cluster *c = &cluster_set[c_rep1->tail]; // pointer to the end of 1st cluster.
   CGAL_assertion(c != 0);
   CGAL_assertion(c->nxt == NULL);

   cell_cluster *c_rep2 = &cluster_set[rep2]; // head of 2nd cluster.
   c_rep1->tail = c_rep2->tail;
   c->nxt = c_rep2;
   while(c->nxt != 0) 
   { 
      c->nxt->rep = rep1;
      c = c->nxt; 
   }
}
예제 #12
0
파일: sweep_line.cpp 프로젝트: Asuzer/cgal
int main()
{
  // Construct the input segments.
  Segment_2 segments[] = {Segment_2 (Point_2 (1, 5), Point_2 (8, 5)),
                          Segment_2 (Point_2 (1, 1), Point_2 (8, 8)),
                          Segment_2 (Point_2 (3, 1), Point_2 (3, 8)),
                          Segment_2 (Point_2 (8, 5), Point_2 (8, 8))};
  
  // Compute all intersection points.
  std::list<Point_2>     pts;

  CGAL::compute_intersection_points (segments, segments + 4,
                                     std::back_inserter (pts));
  
  // Print the result.
  std::cout << "Found " << pts.size() << " intersection points: " << std::endl; 
  std::copy (pts.begin(), pts.end(),
             std::ostream_iterator<Point_2>(std::cout, "\n"));

  // Compute the non-intersecting sub-segments induced by the input segments.
  std::list<Segment_2>   sub_segs;

  CGAL::compute_subcurves(segments, segments + 4, std::back_inserter(sub_segs));

  std::cout << "Found " << sub_segs.size()
            << " interior-disjoint sub-segments." << std::endl;

  CGAL_assertion (CGAL::do_curves_intersect (segments, segments + 4));

  return 0;
}
int main()
{
  std::vector< std::pair<Wpoint,unsigned> > points;
  points.push_back( std::make_pair(Wpoint(Point(0,0),2),0) );
  points.push_back( std::make_pair(Wpoint(Point(1,0),2),1) );
  points.push_back( std::make_pair(Wpoint(Point(0,1),2),2) );
  points.push_back( std::make_pair(Wpoint(Point(-4,54),2),3) );
  points.push_back( std::make_pair(Wpoint(Point(2,2),2),4) );
  points.push_back( std::make_pair(Wpoint(Point(-1,0),2),5) );

  Regular rt;
  rt.insert( points.begin(),points.end() );

  CGAL_assertion( rt.number_of_vertices() == 6 );

  // check that the info was correctly set.
  Regular::Finite_vertices_iterator vit;
  for (vit = rt.finite_vertices_begin(); vit != rt.finite_vertices_end(); ++vit)
    if( points[ vit->info() ].first != vit->point() ){
      std::cerr << "Error different info" << std::endl;
      exit(EXIT_FAILURE);
    }
  std::cout << "OK" << std::endl;

  return 0;
}
예제 #14
0
inline
MP_Float
Add_Sub(const MP_Float &a, const MP_Float &b, const BinOp &op)
{
  CGAL_assertion(!b.is_zero());

  exponent_type min_exp, max_exp;

  if (a.is_zero()) {
    min_exp = b.min_exp();
    max_exp = b.max_exp();
  }
  else {
    min_exp = (std::min)(a.min_exp(), b.min_exp());
    max_exp = (std::max)(a.max_exp(), b.max_exp());
  }

  MP_Float r;
  r.exp = min_exp;
  r.v.resize(static_cast<int>(max_exp - min_exp + 1)); // One more for carry.
  r.v[0] = 0;
  for(int i = 0; i < max_exp - min_exp; i++)
  {
    MP_Float::limb2 tmp = r.v[i] + op(a.of_exp(i+min_exp),
                                      b.of_exp(i+min_exp));
    MP_Float::split(tmp, r.v[i+1], r.v[i]);
  }
  r.canonicalize();
  return r;
}
예제 #15
0
int main(int argc, char* argv[]) {

  CGAL_assertion(argc==2);
  std::ifstream in1(argv[1]);
  
  Polyhedron P1;
  in1 >> P1;

  std::transform( P1.facets_begin(), P1.facets_end(), P1.planes_begin(),
		  Plane_equation());

  CGAL_assertion(is_strongly_convex_3(P1));

  Gausian_map G1(P1);
  G1.visualize();
}
예제 #16
0
/*! Print the given envelope diagram. */
void print_diagram (const Diagram_1& diag)
{
  Diagram_1::Edge_const_handle     e = diag.leftmost();
  Diagram_1::Vertex_const_handle   v;

  while (e != diag.rightmost())
  {
    std::cout << "Edge: ";
    if (! e->is_empty())
    {
      Circle_2      circ = e->curve().supporting_circle();
      std::cout << " (x - " << CGAL::to_double(circ.center().x()) << ")^2 +"
                << " (y - " << CGAL::to_double(circ.center().y()) << ")^2 = "
                << CGAL::to_double(circ.squared_radius()) << std::endl;
    }
    else
      std::cout << " [empty]" << std::endl;

    v = e->right();
    std::cout << "Vertex (" << CGAL::to_double(v->point().x()) << ' '
              << CGAL::to_double(v->point().y()) << ')' << std::endl;

    e = v->right();
  }
  CGAL_assertion (e->is_empty());
  std::cout << "Edge: [empty]" << std::endl;

  return;
}
예제 #17
0
int main()
{
    std::vector<Point_3> points;

    points.push_back(Point_3(2.0f, 3.535533905932738f, 3.535533905932737f));
    points.push_back(Point_3(4.0f, 2.0f, 0.0f));
    points.push_back(Point_3(0.0f, 2.0f, 0.0f));
    points.push_back(Point_3(1.0f, 0.0f, 0.0f));
    points.push_back(Point_3(4.0f, 1.414213562373095f, 1.414213562373095f));
    points.push_back(Point_3(0.0f, 1.414213562373095f, 1.414213562373095f));
    points.push_back(Point_3(3.0f, 0.0f, 0.0f));
    points.push_back(Point_3(2.0f, 5.0f, 0.0f));

    Polyhedron P;

    CGAL::convex_hull_3(points.begin(), points.end(), P);

    std::cout << "- Number of vertices  = " << P.size_of_vertices()    << std::endl;
    std::cout << "- Number of edges     = " << P.size_of_halfedges()/2 << std::endl;
    std::cout << "- Number of faces     = " << P.size_of_facets()      << std::endl;

    for ( Facet_iterator i = P.facets_begin(); i != P.facets_end(); ++i)
    {
        Halfedge_facet_circulator j = i->facet_begin();
        CGAL_assertion( CGAL::circulator_size(j) >= 3);
        std::cout << CGAL::circulator_size(j) << ' ';
        do{
            //std::cout << ' ' << std::distance(P.vertices_begin(), j->vertex());
            std::cout << " (" << j->vertex()->point().x() << ' ' << j->vertex()->point().y() << ' ' << j->vertex()->point().z() << ')' << ", ";
        } while ( ++j != i->facet_begin());

        std::cout << std::endl;
    }
    return 0;
}
예제 #18
0
int main(int argc, char* argv[]) {

  int n = argc>2 ? std::atoi(argv[2]) : 10;
  int s = argc>3 ? std::atoi(argv[3]) : 100;
  int l = argc>4 ? std::atoi(argv[4]) : 2;

  std::ostringstream out1;
  if(argc>5) {
    tgen t1(out1,s,std::atoi(argv[5]));
    t1.create_tetrahedra(n,n,1);
  } else {
    tgen t1(out1,s);
    t1.create_tetrahedra(n,n,1);
  }
  std::istringstream in1(out1.str());
  Nef_polyhedron N1;
  in1 >> N1;
  CGAL_assertion(N1.is_valid());

  Nef_polyhedron N2;
  std::ifstream in2(argv[1]);
  in2 >> N2;
  Nef_polyhedron N3=N2;
  transform_big(N2,n,s);
  N1=N2.join(N1);
  
  cgal_nef3_timer_on = true;
  
  CGAL::Random r;
  int x=r.get_int(0,n-l-1);
  int y=r.get_int(0,n-1-1);
  transform_small(N3,s,l,x,y);
  N1 = N1.difference(N3);
};
예제 #19
0
int main ()
{
  // Construct the first polygon (a triangle).
  Polygon_2   P;

  P.push_back (Point_2 (0, 0));
  P.push_back (Point_2 (6, 0));
  P.push_back (Point_2 (3, 5));

  // Construct the second polygon (a triangle).
  Polygon_2   Q;

  Q.push_back (Point_2 (0, 0));
  Q.push_back (Point_2 (2, -2));
  Q.push_back (Point_2 (2, 2));

  // Compute the Minkowski sum.
  Polygon_with_holes_2  sum = minkowski_sum_2 (P, Q);

  CGAL_assertion (sum.number_of_holes() == 0);

  std::cout << "P = "; print_polygon (P);
  std::cout << "Q = "; print_polygon (Q);
  std::cout << "P (+) Q = "; print_polygon (sum.outer_boundary());

  return (0);
}
예제 #20
0
  // --------------------------------------------------------------
  // Compute the intersection of one line segment and one ray<->.
  // store the result in the hit_p point.
  // --------------------------------------------------------------
  Point
  intersect_ray3_seg3(const Ray& r, const Segment& s, bool& is_correct_intersection)
  {
    // steps are
    // transform start_p and driver to this frame
    // find the intersection between trans(p1 - p2) and 
    //                     trans(driver -> start_p)
    // step 1 : set up a local frame with p1 as origin
    Point org = s.point(0);
    Vector xaxis, yaxis, zaxis = CGAL::NULL_VECTOR;

    //   normalized([p1 -> p2]) as x axis.
    xaxis = s.point(1) - s.point(0);
    normalize(xaxis);

    //   normalized(vec(p1,p2) X vec(p1, start_p)) as z axis
    zaxis = CGAL::cross_product(xaxis, r.source() - org);
    normalize(zaxis);

    yaxis = CGAL::cross_product(zaxis, xaxis);
    normalize(yaxis);

    // convert the points into this 2d frame.
    // condition imposed : 
    //    1. segment is aligned with xaxis.
    CGAL::Point_2<Rep> _s0 = CGAL::Point_2<Rep>(0, 0);
    CGAL::Point_2<Rep> _s1 = CGAL::Point_2<Rep>(length_of_seg(s), 0);
    CGAL::Segment_2<Rep> _s = CGAL::Segment_2<Rep>(_s0, _s1);
    // condition imposed :
    //    2. ray is transformed in 2d.
    Point r0 = r.source();
    CGAL::Point_2<Rep> _r0 = CGAL::Point_2<Rep>(CGAL::to_double((r0 - org)*xaxis),
                                                CGAL::to_double((r0 - org)*yaxis)
						);
    Point r1 = r0 + r.to_vector();
    CGAL::Point_2<Rep> _r1 = CGAL::Point_2<Rep>(CGAL::to_double((r1 - org)*xaxis),
                                                CGAL::to_double((r1 - org)*yaxis)
						);
    CGAL::Ray_2<Rep> _r = CGAL::Ray_2<Rep>(_r0, _r1);

    // find the intersection between transformed ray and transformed segment.
    CGAL::Object result = CGAL::intersection(_r, _s);
    CGAL::Point_2<Rep> _p;

    // the computation is correct if the intersection is a point.
    is_correct_intersection = CGAL::assign(_p, result);
    if( ! is_correct_intersection ) 
      {
	cerr << "x"; 
	return CGAL::ORIGIN; 
      }
    else
      {
	// convert _p into 3d.
	CGAL_assertion(_s.has_on(_p));
	double t = sqrt(CGAL::to_double((_p - _s0)*(_p - _s0)))/length_of_seg(s);
	return s.point(0) + t*(s.point(1) - s.point(0));
      }
  }
예제 #21
0
int main() {

  Nef_polyhedron N1(Nef_polyhedron::COMPLETE);

  Line l(2,4,2); // l : 2x + 4y + 2 = 0
  Nef_polyhedron N2(l,Nef_polyhedron::INCLUDED);
  Nef_polyhedron N3 = N2.complement();
  CGAL_assertion(N1 == N2.join(N3));

  Point p1(0,0), p2(10,10), p3(-20,15);
  Point triangle[3] = { p1, p2, p3 };
  Nef_polyhedron N4(triangle, triangle+3);
  Nef_polyhedron N5 = N2.intersection(N4);
  CGAL_assertion(N5 <= N2 && N5 <= N4);

  return 0;
}
// Flip an edge, work only in 2D and 3D
Dart_handle
flip_edge (LCC & m, Dart_handle d)
{
  CGAL_assertion ( !m.is_free(d,2) );
  CGAL_assertion ( !m.is_free(d,1) && !m.is_free(d,0) );
  CGAL_assertion ( !m.is_free(m.beta(d,2), 0) && !m.is_free(m.beta(d, 2), 1) );
  
  if (!m.is_removable<1>(d)) return LCC::null_handle;

  Dart_handle d1 = m.beta(d,1);
  Dart_handle d2 = m.beta(d,2,0);

  CGAL_assertion ( !m.is_free(d1,1) && !m.is_free(d2,0) );

  Dart_handle d3 = m.beta(d1,1);
  Dart_handle d4 = m.beta(d2, 0);

  // We isolated the edge
  m.basic_link_beta_1(m.beta(d,0), m.beta(d,2,1));
  m.basic_link_beta_0(m.beta(d,1), m.beta(d,2,0));
  if ( !m.is_free(d,3) )
  {
    m.basic_link_beta_0(m.beta(d,0,3), m.beta(d,2,1,3));
    m.basic_link_beta_1(m.beta(d,1,3), m.beta(d,2,0,3));
  }

  // Then we push the two extremities.
  m.basic_link_beta_0(d3, d);
  m.basic_link_beta_0(d2, m.beta(d,2));
  m.link_beta_1(d4, d);
  m.link_beta_1(d1, m.beta(d,2));

  if ( !m.is_free(d,3) )
  {
    m.basic_link_beta_0(m.beta(d4,3), m.beta(d,3));
    m.basic_link_beta_0(m.beta(d1,3), m.beta(d,2,3));
    m.link_beta_1(m.beta(d3,3), m.beta(d,3));
    m.link_beta_1(m.beta(d2,3), m.beta(d,2,3));
  }
  
  // CGAL::remove_cell<LCC,1>(m, d);
  // insert_cell_1_in_cell_2(m, d1, d1->beta(1)->beta(1));

  return d;
}
예제 #23
0
void read_from_file(pp_int& V, int& n, int& d, std::string s)
{
  std::ifstream In(s.c_str());
  CGAL_assertion(In.good());
  In >> d >> n;
  create(V,n,d);int i=0,c;
  while ( In >> c ) { V[i/d][i%d]=c; ++i;}
  In.close();
}
예제 #24
0
typename QP_solver<Rep_>::ET
QP_solver<Rep_>::nonbasic_original_variable_value(int i) const
{
  if (check_tag(Is_in_standard_form()))
    return et0;

  CGAL_assertion(!is_basic(i));
  return original_variable_value(i);
}
예제 #25
0
  QColor Qt_widget_style::getColor(QString name)
  {
    if( ! map.contains(name) )
      return QColor();
    else
      {
	CGAL_assertion( map[name].type() == QVariant::Color );
	return map[name].asColor();
      }
  }
예제 #26
0
  int Qt_widget_style::getInt(QString name)
  {
    if( ! map.contains(name) )
      return 0;
    else
      {
	CGAL_assertion( map[name].type() == QVariant::Int );
	return map[name].asInt();
      }
  }
예제 #27
0
  bool Qt_widget_style::getBool(QString name)
  {
    if( ! map.contains(name) )
      return false;
    else
      {
	CGAL_assertion( map[name].type() == QVariant::Bool );
	return map[name].asBool();
      }
  }
예제 #28
0
  ::CGAL::PointStyle Qt_widget_style::getPointStyle(QString name)
  {
    if( ! map.contains(name) )
      return PointStyle();
    else
      {
	CGAL_assertion( map[name].type() == QVariant::UInt );
	return PointStyle(map[name].asUInt());
      }
  }
예제 #29
0
// Returns (first * 2^second), an interval surrounding b.
pair<pair<double, double>, int>
to_interval_exp(const MP_Float &b)
{
  if (b.is_zero())
    return std::make_pair(pair<double, double>(0, 0), 0);

  exponent_type exp = b.max_exp();
  int steps = static_cast<int>((std::min)(limbs_per_double, b.v.size()));
  double d_exp_1 = std::ldexp(1.0, - (int) log_limb);
  double d_exp   = 1.0;

  Interval_nt_advanced::Protector P;
  Interval_nt_advanced d = 0;

  exponent_type i;
  for (i = exp - 1; i > exp - 1 - steps; i--) {
    d_exp *= d_exp_1;
    if (d_exp == 0) // Take care of underflow.
      d_exp = CGAL_IA_MIN_DOUBLE;
    d += d_exp * b.of_exp(i);
  }

  if (i >= b.min_exp() && d.is_point()) {
    if (b.of_exp(i) > 0)
      d += Interval_nt_advanced(0, d_exp);
    else if (b.of_exp(i) < 0)
      d += Interval_nt_advanced(-d_exp, 0);
    else
      d += Interval_nt_advanced(-d_exp, d_exp);
  }

#ifdef CGAL_EXPENSIVE_ASSERTION // force it always in early debugging
  if (d.is_point())
    CGAL_assertion(MP_Float(d.inf()) == b);
  else
    CGAL_assertion(MP_Float(d.inf()) <= b & MP_Float(d.sup()) >= b);
#endif

  CGAL_assertion_msg(CGAL::abs(exp*log_limb) < (1<<30)*2.0,
                     "Exponent overflow in MP_Float to_interval");
  return std::make_pair(d.pair(), static_cast<int>(exp * log_limb));
}
예제 #30
0
int my_nearbyint(const T& d)
{
  int z = int(d);
  T frac = d - z;

  CGAL_assertion(CGAL::abs(frac) < T(1.0));

  if (frac > 0.5)
    ++z;
  else if (frac < -0.5)
    --z;
  else if (frac == 0.5 && (z&1) != 0) // NB: We also need the round-to-even rule.
    ++z;
  else if (frac == -0.5 && (z&1) != 0)
    --z;

  CGAL_assertion(CGAL::abs(T(z) - d) < T(0.5) ||
                 (CGAL::abs(T(z) - d) == T(0.5) && ((z&1) == 0)));
  return z;
}