Ejemplo n.º 1
0
void transform_big(Nef_polyhedron& N,int n, int s) {
  Vertex_const_iterator vi(N.vertices_begin());
  x_min = vi->point().hx()/vi->point().hw();
  x_max = vi->point().hx()/vi->point().hw();
  y_min = vi->point().hy()/vi->point().hw();
  y_max = vi->point().hy()/vi->point().hw();
  z_min = vi->point().hz()/vi->point().hw();
  z_max = vi->point().hz()/vi->point().hw();
  for(;vi != N.vertices_end();++vi) {
    if(vi->point().hx()/vi->point().hw() < x_min) 
      x_min = vi->point().hx()/vi->point().hw();
    if(vi->point().hx()/vi->point().hw() > x_max) 
      x_max = vi->point().hx()/vi->point().hw();
    if(vi->point().hy()/vi->point().hw() < y_min) 
      y_min = vi->point().hy()/vi->point().hw();
    if(vi->point().hy()/vi->point().hw() > y_max) 
      y_max = vi->point().hy()/vi->point().hw();
    if(vi->point().hz()/vi->point().hw() < z_min) 
      z_min = vi->point().hz()/vi->point().hw();
    if(vi->point().hz()/vi->point().hw() > z_max) 
      z_max = vi->point().hz()/vi->point().hw();
  }

  //  x_min-=(x_min<=0?0:1);
  //  y_min-=(y_min<=0?0:1);
  //  z_max+=(z_max<=0?1:0);
  
  N.transform(Aff_transformation_3(CGAL::TRANSLATION, Vector_3(-x_min,-y_min,-z_max)));
  N.transform(Aff_transformation_3(CGAL::SCALING, n*s+2,x_max-x_min));
  N.transform(Aff_transformation_3(CGAL::TRANSLATION, Vector_3(0,0,s/2)));
}
Ejemplo n.º 2
0
void transform_form(const Nef_polyhedron& N, Nef_polyhedron& F) {

    Vertex_const_iterator vi(N.vertices_begin());
    x_max = CGAL_NTS abs(vi->point().hx()/vi->point().hw());
    y_max = CGAL_NTS abs(vi->point().hy()/vi->point().hw());
    z_max = CGAL_NTS abs(vi->point().hz()/vi->point().hw());
    for(; vi != N.vertices_end(); ++vi) {
        if(CGAL_NTS abs(vi->point().hx()/vi->point().hw()) > x_max)
            x_max = CGAL_NTS abs(vi->point().hx()/vi->point().hw());
        if(CGAL_NTS abs(vi->point().hy()/vi->point().hw()) > y_max)
            y_max = CGAL_NTS abs(vi->point().hy()/vi->point().hw());
        if(CGAL_NTS abs(vi->point().hz()/vi->point().hw()) > z_max)
            z_max = CGAL_NTS abs(vi->point().hz()/vi->point().hw());
    }

    x_max*105/100;
    y_max*105/100;
    z_max*105/100;

    F.transform(Aff_transformation_3(x_max,0,0, 0,y_max,0, 0,0,z_max, 1));
    F.transform(Aff_transformation_3(CGAL::TRANSLATION,Vector_3(0,0,z_max)));
}
Ejemplo n.º 3
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
}
Ejemplo n.º 4
0
void transform_small(Nef_polyhedron& N, int s, int l, int x, int y) {
  N.transform(Aff_transformation_3(CGAL::TRANSLATION, Vector_3(-x_min,-y_min,-z_min))); 
  N.transform(Aff_transformation_3(CGAL::SCALING, s*l, x_max-x_min));
  N.transform(Aff_transformation_3(CGAL::TRANSLATION, Vector_3((2*x+1)*s/2,(2*y+1)*s/2,s/4)));
}
Ejemplo n.º 5
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());

  char* dir="nef3/";
  char* tetrahedra="tetrahedra";
  char* grid="grid";
  char* suffix=".nef3";
  char* us="_";
  
  char* full_suffix = new char[strlen(argv[2])+strlen(argv[3])+strlen(argv[4])+strlen(argv[5])+strlen(suffix)+5];
  strcpy(full_suffix, us);
  strcat(full_suffix, argv[2]);
  strcat(full_suffix, us);
  strcat(full_suffix, argv[3]);
  strcat(full_suffix, us);
  strcat(full_suffix, argv[4]);
  strcat(full_suffix, us);
  strcat(full_suffix, argv[5]);
  strcat(full_suffix, suffix);

  char* full_tetrahedra = new char[strlen(dir)+strlen(tetrahedra)+strlen(full_suffix)+1];
  strcpy(full_tetrahedra, dir);
  strcat(full_tetrahedra, tetrahedra);
  strcat(full_tetrahedra, full_suffix);
  std::ofstream out_tetrahedra(full_tetrahedra);
  out_tetrahedra << N2;

  char* full_grid = new char[strlen(dir)+strlen(grid)+strlen(full_suffix)+1];
  strcpy(full_grid, dir);
  strcat(full_grid, grid);
  strcat(full_grid, full_suffix);
  std::ofstream out_grid(full_grid);
  out_grid << N1;  
}
Ejemplo n.º 6
0
int main(int argc, char* argv[]) {

  assert(argc>1 && argc < 8);
  
  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;
  int n  = argc>5 ? std::atoi(argv[5]) : 2;

  std::ifstream in(argv[1]);
  Nef_polyhedron Nin;
  in >> Nin;
  Nin.transform(Aff_transformation_3(CGAL::SCALING,100,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;
  if(argc>6) {
    tgen t2(out2,s,std::atoi(argv[6]));
    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());

#if defined CGAL_NEF3_UNION
  N1=N1.join(N2);
#elif defined CGAL_NEF3_INTERSECTION
  N1=N1.intersection(N2);
#elif defined CGAL_NEF3_DIFFERENCE
  N1=N1.difference(N2);
#else
  N1=N1.symmetric_difference(N2);
#endif

  RT b=s*(nx+1);
  N1.transform(Aff_transformation_3(CGAL::TRANSLATION,Vector_3(-b,-b,-b,2)));

  CGAL::Timer pl;
  pl.start();

  Point_source P(CGAL::to_double(b)/2);
  for(int i=0;i<n;++i) {
    N1.locate(*P++);
  }
  pl.stop();

  std::cout << "Input_size: " << N1.number_of_vertices() << std::endl;
  std::cout << "Number_of_point_location_queries: " << n << std::endl;
  std::cout << "Total_runtime: " << pl.time() << std::endl;
  std::cout << "Runtime_per_query: " << pl.time()/n << std::endl;
}