当前位置: 首页>>代码示例>>C++>>正文


C++ TestScene::run方法代码示例

本文整理汇总了C++中TestScene::run方法的典型用法代码示例。如果您正苦于以下问题:C++ TestScene::run方法的具体用法?C++ TestScene::run怎么用?C++ TestScene::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestScene的用法示例。


在下文中一共展示了TestScene::run方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv) {
  carve::poly::Polyhedron *input = readPLY(argv[1]);
  double offset = strtod(argv[2], NULL);

  TestScene *scene = new TestScene(argc, argv, 3);

  glNewList(scene->draw_list_base, GL_COMPILE);
  doOffset(input, offset);
  glEndList();

  glNewList(scene->draw_list_base + 1, GL_COMPILE);
  drawPolyhedron(input, .6, .6, .6, 1.0, false);
  glEndList();

  glNewList(scene->draw_list_base + 2, GL_COMPILE);
  drawPolyhedronWireframe(input);
  glEndList();

  scene->draw_flags[0] = true;
  scene->draw_flags[1] = true;
  scene->draw_flags[2] = true;

  scene->run();

  delete scene;

  return 0;
}
开发者ID:dbc,项目名称:pyPolyCSG,代码行数:28,代码来源:offset.cpp

示例2: main

int main(int argc, char **argv) {
  TestScene *scene = new TestScene(argc, argv, std::min(1, argc - 1));
  options.parse(argc, argv);

  size_t count = 0;

  carve::input::Input inputs;
  std::vector<carve::poly::Polyhedron *> polys;
  std::vector<carve::line::PolylineSet *> lines;
  std::vector<carve::point::PointSet *> points;

  // Test polyhedron


  carve::poly::Polyhedron *test1 = makeCube(-1,-1,-1,1,1,1);
  carve::poly::Polyhedron *test2 = makeCube(0,0,0,2,2,2);
  polys.push_back(test1);
  polys.push_back(test2);

  carve::csg::CSG testt;
  carve::poly::Polyhedron *test3 = testt.compute(test1, test2, carve::csg::CSG::INTERSECTION);
  polys.push_back(test3);

  scene->draw_list_base = genSceneDisplayList(polys, lines, points, &count, scene->is_wireframe);
  scene->draw_flags.assign(count, true);

  scene->run();

  delete scene;

  return 0;
}
开发者ID:pigoblock,项目名称:TFYP,代码行数:32,代码来源:view.cpp

示例3: main

int main(int argc, char **argv) {
  TestScene *scene = new TestScene(argc, argv, 2);

  GLuint tex_1 = initTexture(128, 128, carve_texture);
  GLuint tex_2 = initTexture(128, 128, brick_texture);
  GLuint tex_3 = initTexture(128, 128, leaf_texture);

  g_scale = 10.0;

  carve::interpolate::FaceVertexAttr<tex_t> fv_tex;
  carve::interpolate::FaceAttr<GLuint> f_tex_num;
  carve::mesh::MeshSet<3> *base = NULL;

  bool b = true;
  for (int x = -10; x <= +10; x += 5) {
    for (int y = -10; y <= +10; y += 5) {
      for (int z = -10; z <= +10; z += 5) {
        double rot = x * .17 + y * .06 + z * .09;
        carve::mesh::MeshSet<3> *r = texturedCube(fv_tex, f_tex_num, b ? tex_2 : tex_3,
                                 carve::math::Matrix::TRANS(x/2.5, y/2.5, z/2.5) *
                                 carve::math::Matrix::ROT(rot, 1,2,3));
        b = !b;
        if (base) {
          carve::mesh::MeshSet<3> *temp = base;
          carve::csg::CSG csg;
          fv_tex.installHooks(csg);
          f_tex_num.installHooks(csg);

          base = csg.compute(temp, r, carve::csg::CSG::UNION);
          delete temp;
          delete r;
        } else {
          base = r;
        }
      }
    }
  }

  carve::mesh::MeshSet<3> *r1 = texturedCube(fv_tex, f_tex_num, tex_1,
                            carve::math::Matrix::TRANS(0,0,4) *
                            carve::math::Matrix::SCALE(4,4,4));

  carve::mesh::MeshSet<3> *r2 = texturedCube(fv_tex, f_tex_num, tex_1,
                            carve::math::Matrix::TRANS(0,0,5) *
                            carve::math::Matrix::SCALE(2, 2, 2));

  carve::csg::CSG csg;
  fv_tex.installHooks(csg);
  f_tex_num.installHooks(csg);

  carve::mesh::MeshSet<3> *r3 = csg.compute(base, r1, carve::csg::CSG::INTERSECTION, NULL, carve::csg::CSG::CLASSIFY_EDGE);
  carve::mesh::MeshSet<3> *r4 = csg.compute(r3, r2, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE);

  glNewList(scene->draw_list_base, GL_COMPILE);
  drawTexturedPolyhedron(r4, fv_tex, f_tex_num);
  glEndList();

  glNewList(scene->draw_list_base+1, GL_COMPILE);
  drawWireframePolyhedron(r3);
  glEndList();

  scene->draw_flags[0] = true;
  scene->draw_flags[1] = true;

  scene->run();

  destroyTexture(tex_1);
  destroyTexture(tex_2);
  destroyTexture(tex_3);

  delete scene;

  return 0;
}
开发者ID:ManojRollo,项目名称:carve,代码行数:74,代码来源:texture_example.cpp

示例4: main

int main(int argc, char **argv) {
  carve::mesh::MeshSet<3> *a = makeTorus(30, 30, 2.0, 0.8, carve::math::Matrix::ROT(0.5, 1.0, 1.0, 1.0));
  

  carve::input::PolyhedronData data;

  for (int i = 0; i < DIM; i++) {
    double x = -3.0 + 6.0 * i / double(DIM - 1);
    for (int j = 0; j < DIM; j++) {
      double y = -3.0 + 6.0 * j / double(DIM - 1);
      double z = -1.0 + 2.0 * cos(sqrt(x * x + y * y) * 2.0) / sqrt(1.0 + x * x + y * y);
      size_t n = data.addVertex(carve::geom::VECTOR(x, y, z));
      if (i && j) {
        data.addFace(n - DIM - 1, n - 1, n - DIM);
        data.addFace(n - 1, n, n - DIM);
      }
    }
  }

  for (int i = 0; i < DIM; i++) {
    double x = -3.0 + 6.0 * i / double(DIM - 1);
    for (int j = 0; j < DIM; j++) {
      double y = -3.0 + 6.0 * j / double(DIM - 1);
      double z = 1.0 + 2.0 * cos(sqrt(x * x + y * y) * 2.0) / sqrt(1.0 + x * x + y * y);
      size_t n = data.addVertex(carve::geom::VECTOR(x, y, z));
      if (i && j) {
        data.addFace(n - DIM - 1, n - 1, n - DIM);
        data.addFace(n - 1, n, n - DIM);
      }
    }
  }

  carve::mesh::MeshSet<3> *b = data.createMesh(carve::input::opts());
  CARVE_ASSERT(b->meshes.size() == 2);

  Between between_collector(a, b);
  carve::mesh::MeshSet<3> *c = carve::csg::CSG().compute(a, b, between_collector, NULL, carve::csg::CSG::CLASSIFY_EDGE);

  TestScene *scene = new TestScene(argc, argv, 3);

  glNewList(scene->draw_list_base + 0, GL_COMPILE);
  drawMeshSet(a, .4, .6, .8, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 1, GL_COMPILE);
  drawMeshSet(b, .8, .6, .4, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 2, GL_COMPILE);
  drawMeshSet(c, .2, .2, .8, 1.0);
  drawMeshSetWireframe(c, -1, false, false);
  glEndList();

  scene->run();

  delete scene;

  delete a;
  delete b;
  delete c;

  return 0;
}
开发者ID:barche,项目名称:carve,代码行数:63,代码来源:custom_collector.cpp

示例5: main

int main(int argc, char **argv) {
  TestScene *scene = new TestScene(argc, argv, std::min(1, argc - 1));
  options.parse(argc, argv);

  size_t count = 0;

  carve::input::Input inputs;
  std::vector<carve::mesh::MeshSet<3> *> polys;
  std::vector<carve::line::PolylineSet *> lines;
  std::vector<carve::point::PointSet *> points;

  if (options.files.size() == 0) {
    if (options.obj) {
      readOBJ(std::cin, inputs);
    } else if (options.vtk) {
      readVTK(std::cin, inputs);
    } else {
      readPLY(std::cin, inputs);
    }

  } else {
    for (size_t idx = 0; idx < options.files.size(); ++idx) {
      std::string &s(options.files[idx]);
      std::string::size_type i = s.rfind(".");

      if (i != std::string::npos) {
        std::string ext = s.substr(i, s.size() - i);
        if (!strcasecmp(ext.c_str(), ".obj")) {
          readOBJ(s, inputs);
        } else if (!strcasecmp(ext.c_str(), ".vtk")) {
          readVTK(s, inputs);
        } else {
          readPLY(s, inputs);
        }
      } else {
        readPLY(s, inputs);
      }
    }
  }

  for (std::list<carve::input::Data *>::const_iterator i = inputs.input.begin(); i != inputs.input.end(); ++i) {
    carve::mesh::MeshSet<3> *p;
    carve::point::PointSet *ps;
    carve::line::PolylineSet *l;

    if ((p = carve::input::Input::create<carve::mesh::MeshSet<3> >(*i, carve::input::opts("avoid_cavities", "true"))) != NULL)  {
      polys.push_back(p);
      std::cerr << "loaded polyhedron "
                << polys.back() << " has " << polys.back()->meshes.size()
                << " manifolds (" << std::count_if(polys.back()->meshes.begin(),
                                                   polys.back()->meshes.end(),
                                                   carve::mesh::Mesh<3>::IsClosed()) << " closed)" << std::endl; 

      std::cerr << "closed:    ";
      for (size_t i = 0; i < polys.back()->meshes.size(); ++i) {
        std::cerr << (polys.back()->meshes[i]->isClosed() ? '+' : '-');
      }
      std::cerr << std::endl;

      std::cerr << "negative:  ";
      for (size_t i = 0; i < polys.back()->meshes.size(); ++i) {
        std::cerr << (polys.back()->meshes[i]->isNegative() ? '+' : '-');
      }
      std::cerr << std::endl;

    } else if ((l = carve::input::Input::create<carve::line::PolylineSet>(*i)) != NULL)  {
      lines.push_back(l);
      std::cerr << "loaded polyline set "
                << lines.back() << std::endl; 
    } else if ((ps = carve::input::Input::create<carve::point::PointSet>(*i)) != NULL)  {
      points.push_back(ps);
      std::cerr << "loaded point set "
                << points.back() << std::endl; 
    }
  }

  scene->draw_list_base = genSceneDisplayList(polys, lines, points, &count, scene->is_wireframe);
  scene->draw_flags.assign(count, true);

  scene->run();

  delete scene;

  return 0;
}
开发者ID:barche,项目名称:carve,代码行数:85,代码来源:view.cpp

示例6: main

int main(int argc, char **argv) {
  carve::mesh::MeshSet<3> *a = makeCube(carve::math::Matrix::ROT(1.0, 1.0, 1.0, 1.0));
  
  std::vector<carve::mesh::MeshSet<3>::vertex_t> shape;

  for (int i = 0; i < POINTS; ++i) {
    double r = 2.0 + .4 * sin(i * 3 * M_TWOPI / POINTS) + .8 * sin(i * 5 * M_TWOPI / POINTS);
    shape.push_back(carve::mesh::MeshSet<3>::vertex_t(carve::geom::VECTOR(r * cos(i * M_TWOPI / POINTS), r * sin(i * M_TWOPI / POINTS), 0.0)));
  }
  std::vector<carve::mesh::MeshSet<3>::vertex_t *> face_verts;
  for (int i = 0; i < POINTS; ++i) {
    face_verts.push_back(&shape[i]);
  }
  std::vector<carve::mesh::MeshSet<3>::face_t *> faces;
  faces.push_back(new carve::mesh::MeshSet<3>::face_t(face_verts.begin(), face_verts.end()));

  carve::mesh::MeshSet<3> *b = new carve::mesh::MeshSet<3>(faces);

  std::list<std::pair<carve::csg::FaceClass, carve::mesh::MeshSet<3> *> > b_sliced;

  carve::csg::CSG csg;

  csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
  csg.sliceAndClassify(a, b, b_sliced);

  TestScene *scene = new TestScene(argc, argv, 6);

  glNewList(scene->draw_list_base + 0, GL_COMPILE);

  drawMeshSet(a, .4, .6, .8, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 1, GL_COMPILE);
  drawMeshSet(b, .8, .6, .4, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 2, GL_COMPILE);
  {
    int n = 0;
    for (std::list<std::pair<carve::csg::FaceClass, carve::mesh::MeshSet<3> *> >::iterator i = b_sliced.begin(); i != b_sliced.end(); ++i) {
      float r, g, b;
      switch ((*i).first) {
      case carve::csg::FACE_IN:             r = 0.0; g = 0.0; b = 1.0; break;
      case carve::csg::FACE_OUT:            r = 1.0; g = 0.0; b = 0.0; break;
      case carve::csg::FACE_ON_ORIENT_OUT:  r = 1.0; g = 1.0; b = 0.0; break;
      case carve::csg::FACE_ON_ORIENT_IN:   r = 0.0; g = 1.0; b = 1.0; break;
      }
      drawMeshSet((*i).second, r, g, b, 1.0);
      ++n;
    }
  }
  glEndList();

  glNewList(scene->draw_list_base + 3, GL_COMPILE);
  {
    int n = 0;
    for (std::list<std::pair<carve::csg::FaceClass, carve::mesh::MeshSet<3> *> >::iterator i = b_sliced.begin(); i != b_sliced.end(); ++i) {
      float r, g, b;
      switch ((*i).first) {
      case carve::csg::FACE_IN:             r = 0.3; g = 0.3; b = 0.7; break;
      case carve::csg::FACE_OUT:            r = 0.7; g = 0.3; b = 0.3; break;
      case carve::csg::FACE_ON_ORIENT_OUT:  r = 0.7; g = 0.7; b = 0.3; break;
      case carve::csg::FACE_ON_ORIENT_IN:   r = 0.3; g = 0.7; b = 0.7; break;
      }
      drawMeshSetWireframe((*i).second, -1, false, false);
      ++n;
    }
  }
  glEndList();

  scene->run();

  delete scene;

  return 0;
}
开发者ID:ManojRollo,项目名称:carve,代码行数:76,代码来源:test_slice_classify.cpp

示例7: main

int main(int argc, char **argv) {
  carve::mesh::MeshSet<3> *a = makeCube(carve::math::Matrix::ROT(1.0, 1.0, 1.0, 1.0));
  
  std::vector<carve::geom3d::Vector> shape;

  carve::input::PolyhedronData data;
  for (int i = 0; i < POINTS; ++i) {
    double r = 2.0 + .4 * sin(i * 3 * M_TWOPI / POINTS) + .8 * sin(i * 5 * M_TWOPI / POINTS);
    data.addVertex(carve::geom::VECTOR(r * cos(i * M_TWOPI / POINTS), r * sin(i * M_TWOPI / POINTS), 0.0));
  }
  std::vector<int> face_verts;
  for (int i = 0; i < POINTS; ++i) {
    face_verts.push_back(i);
  }
  data.addFace(face_verts.begin(), face_verts.end());

  carve::mesh::MeshSet<3> *b = new carve::mesh::MeshSet<3>(data.points, data.getFaceCount(), data.faceIndices);

  std::list<carve::mesh::MeshSet<3> *> a_sliced, b_sliced;

  carve::csg::CSG csg;

  csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT);
  csg.slice(a, b, a_sliced, b_sliced);

  TestScene *scene = new TestScene(argc, argv, 6);

  glNewList(scene->draw_list_base + 0, GL_COMPILE);
  drawMeshSet(a, .4, .6, .8, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 1, GL_COMPILE);
  drawMeshSet(b, .8, .6, .4, 1.0);
  glEndList();

  glNewList(scene->draw_list_base + 2, GL_COMPILE);
  {
    int n = 0;
    for (std::list<carve::mesh::MeshSet<3> *>::iterator i = a_sliced.begin(); i != a_sliced.end(); ++i) {
      float r  = n & 1 ? .3 : .7;
      float g  = n & 2 ? .3 : .7;
      float b  = n & 4 ? .3 : .7;
      drawMeshSet(*i, r, g, b, 1.0);
      ++n;
    }
  }
  glEndList();

  glNewList(scene->draw_list_base + 3, GL_COMPILE);
  {
    int n = 0;
    for (std::list<carve::mesh::MeshSet<3> *>::iterator i = a_sliced.begin(); i != a_sliced.end(); ++i) {
      drawMeshSetWireframe(*i, -1, false, false);
      ++n;
    }
  }
  glEndList();

  glNewList(scene->draw_list_base + 4, GL_COMPILE);
  {
    int n = 0;
    for (std::list<carve::mesh::MeshSet<3> *>::iterator i = b_sliced.begin(); i != b_sliced.end(); ++i) {
      float r  = n & 1 ? .3 : .7;
      float g  = n & 2 ? .3 : .7;
      float b  = n & 4 ? .3 : .7;
      drawMeshSet(*i, r, g, b, 1.0);
      ++n;
    }
  }
  glEndList();

  glNewList(scene->draw_list_base + 5, GL_COMPILE);
  {
    int n = 0;
    for (std::list<carve::mesh::MeshSet<3> *>::iterator i = b_sliced.begin(); i != b_sliced.end(); ++i) {
      drawMeshSetWireframe(*i, -1, false, false);
      ++n;
    }
  }
  glEndList();

  scene->run();

  delete scene;

  return 0;
}
开发者ID:DarkOfTheMoon,项目名称:Carve,代码行数:87,代码来源:test_slice.cpp

示例8: main

int main(int argc, char **argv) {
  TestScene *scene = new TestScene(argc, argv);

  typedef std::vector<carve::geom2d::P2> loop_t;
  std::vector<loop_t> poly;

  std::ifstream in(argv[1]);
  while (in.good()) {
    std::string s;
    std::getline(in, s);
    if (s == "BEGIN") {
      poly.push_back(loop_t());
    } else {
      std::istringstream in_s(s);
      double x,y;
      in_s >> x >> y;
      poly.back().push_back(carve::geom::VECTOR(x, y));
    }
  }

  std::vector<std::pair<size_t, size_t> > result;
  std::vector<carve::geom2d::P2> merged;
  std::vector<carve::triangulate::tri_idx> triangulated;

  try {
    result = carve::triangulate::incorporateHolesIntoPolygon(poly);
    merged.reserve(result.size());
    for (size_t i = 0; i < result.size(); ++i) {
      merged.push_back(poly[result[i].first][result[i].second]);
    }
    carve::triangulate::triangulate(merged, triangulated);
    carve::triangulate::improve(merged, triangulated);

  } catch (carve::exception exc) {
    std::cerr << "FAIL: " << exc.str() << std::endl;
    return -1;
  }

  carve::geom::aabb<2> aabb;
  aabb.fit(merged.begin(), merged.end());
  double scale = 20.0 / std::max(aabb.extent.x, aabb.extent.y);

  glNewList(scene->d_list, GL_COMPILE);

  glDisable(GL_LIGHTING);

  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  glColor4f(0.2, 0.3, 0.4, 1.0);

  glBegin(GL_TRIANGLES);
  for (size_t i = 0; i != triangulated.size(); ++i) {
    double x, y;
    x = (merged[triangulated[i].a].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].a].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
    x = (merged[triangulated[i].b].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].b].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
    x = (merged[triangulated[i].c].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].c].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
  }
  glEnd();

  glColor4f(0.0, 0.0, 0.0, 0.1);

  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glDisable(GL_DEPTH_TEST);
  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  glBegin(GL_TRIANGLES);
  for (size_t i = 0; i != triangulated.size(); ++i) {
    double x, y;
    x = (merged[triangulated[i].a].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].a].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
    x = (merged[triangulated[i].b].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].b].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
    x = (merged[triangulated[i].c].x - aabb.pos.x) * scale;
    y = (merged[triangulated[i].c].y - aabb.pos.y) * scale;
    glVertex3f(x, y, 0.0);
  }
  glEnd();
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glEnable(GL_DEPTH_TEST);

  glColor4f(1, 1, 1, 1);
  glBegin(GL_LINE_LOOP);
  for (int i = 0; i < merged.size(); ++i) {
    glVertex3f((merged[i].x - aabb.pos.x) * scale, (merged[i].y - aabb.pos.y) * scale, 2.0);
  }
  glEnd();

  glEndList();

  scene->run();

  delete scene;
//.........这里部分代码省略.........
开发者ID:dbc,项目名称:pyPolyCSG,代码行数:101,代码来源:test_hole_incorporate.cpp


注:本文中的TestScene::run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。