⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vdpmsynthesizerviewerwidget.cc

📁 penMesh is a generic and efficient data structure for representing and manipulating polygonal meshes
💻 CC
📖 第 1 页 / 共 2 页
字号:
    (frustum_plane_[1].signed_distance(pos) < -radius) ||    (frustum_plane_[2].signed_distance(pos) < -radius) ||    (frustum_plane_[3].signed_distance(pos) < -radius);#else    Plane3d   frustum_plane[4];    viewing_parameters_.frustum_planes(frustum_plane);  for (int i = 0; i < 4; i++) {    if (frustum_plane[i].singed_distance(pos) < -radius)      return true;  }    return false;#endif}bool VDPMSynthesizerViewerWidget::oriented_away(float sin_square, float distance_square, float product_value){#if 0  return (product_value > 0)    &&   ((product_value * product_value) > (distance_square * sin_square));#else  if (product_value > 0 &&       product_value * product_value > distance_square * sin_square)    return true;  else    return false;#endif}bool VDPMSynthesizerViewerWidget::screen_space_error(float mue_square, float sigma_square, 		   float distance_square, float product_value){#if 0  float ks_ds = kappa_square_ * distance_square;  float pv_pv = product_value * product_value;  return (mue_square >= ks_ds)     ||   (sigma_square*( distance_square - pv_pv) >= ks_ds*distance_square);#else  if ((mue_square >= kappa_square_ * distance_square) ||       (sigma_square * (distance_square - product_value * product_value) >= kappa_square_ * distance_square * distance_square))    return	false;  else    return	true;#endif}voidVDPMSynthesizerViewerWidget::open_vd_prog_mesh(const char* _filename){  unsigned int                    i;  unsigned int                    value;  unsigned int                    fvi[3];  char                            fileformat[16];  Vec3f                           p, normal;  float                           radius, sin_square, mue_square, sigma_square;  VHierarchyNodeHandleContainer   roots;  VertexHandle                    vertex_handle;    VHierarchyNodeIndex             node_index;  VHierarchyNodeIndex             fund_lcut_index, fund_rcut_index;  VHierarchyNodeHandle            node_handle;  std::map<VHierarchyNodeIndex, VHierarchyNodeHandle> index2handle_map;  std::ifstream ifs(_filename, std::ios::binary);  if (!ifs)  {    std::cerr << "read error\n";    exit(1);  }  //  bool swap = Endian::local() != Endian::LSB;  // read header    ifs.read(fileformat, 10); fileformat[10] = '\0';  if (std::string(fileformat) != std::string("VDProgMesh"))  {    std::cerr << "Wrong file format.\n";    ifs.close();    exit(1);  }  IO::restore(ifs, n_base_vertices_, swap);  IO::restore(ifs, n_base_faces_, swap);  IO::restore(ifs, n_details_, swap);    mesh_.clear();  vfront_.clear();  vhierarchy_.clear();  vhierarchy_.set_num_roots(n_base_vertices_);  // load base mesh  for (i=0; i<n_base_vertices_; ++i)  {    IO::restore(ifs, p, swap);    IO::restore(ifs, radius, swap);    IO::restore(ifs, normal, swap);    IO::restore(ifs, sin_square, swap);    IO::restore(ifs, mue_square, swap);    IO::restore(ifs, sigma_square, swap);    vertex_handle = mesh_.add_vertex(p);    node_index    = vhierarchy_.generate_node_index(i, 1);    node_handle   = vhierarchy_.add_node();    VHierarchyNode &node = vhierarchy_.node(node_handle);    node.set_index(node_index);    node.set_vertex_handle(vertex_handle);    mesh_.vertex(vertex_handle).set_vhierarchy_node_handle(node_handle);        node.set_radius(radius);    node.set_normal(normal);    node.set_sin_square(sin_square);    node.set_mue_square(mue_square);    node.set_sigma_square(sigma_square);    mesh_.set_normal(vertex_handle, normal);    index2handle_map[node_index] = node_handle;    roots.push_back(node_handle);  }  vfront_.init(roots, n_details_);  for (i=0; i<n_base_faces_; ++i)  {    IO::restore(ifs, fvi[0], swap);    IO::restore(ifs, fvi[1], swap);    IO::restore(ifs, fvi[2], swap);    mesh_.add_face(mesh_.vertex_handle(fvi[0]), 		   mesh_.vertex_handle(fvi[1]), 		   mesh_.vertex_handle(fvi[2]));  }  // load details  for (i=0; i<n_details_; ++i)  {    // position of v0    IO::restore(ifs, p, swap);        // vsplit info.    IO::restore(ifs, value, swap);    node_index = VHierarchyNodeIndex(value);    IO::restore(ifs, value, swap);    fund_lcut_index = VHierarchyNodeIndex(value);    IO::restore(ifs, value, swap);    fund_rcut_index = VHierarchyNodeIndex(value);    node_handle = index2handle_map[node_index];    vhierarchy_.make_children(node_handle);    VHierarchyNode &node   = vhierarchy_.node(node_handle);    VHierarchyNode &lchild = vhierarchy_.node(node.lchild_handle());    VHierarchyNode &rchild = vhierarchy_.node(node.rchild_handle());    node.set_fund_lcut(fund_lcut_index);    node.set_fund_rcut(fund_rcut_index);        vertex_handle = mesh_.add_vertex(p);    lchild.set_vertex_handle(vertex_handle);    rchild.set_vertex_handle(node.vertex_handle());        index2handle_map[lchild.node_index()] = node.lchild_handle();    index2handle_map[rchild.node_index()] = node.rchild_handle();    // view-dependent parameters    IO::restore(ifs, radius, swap);    IO::restore(ifs, normal, swap);    IO::restore(ifs, sin_square, swap);    IO::restore(ifs, mue_square, swap);    IO::restore(ifs, sigma_square, swap);    lchild.set_radius(radius);    lchild.set_normal(normal);    lchild.set_sin_square(sin_square);    lchild.set_mue_square(mue_square);    lchild.set_sigma_square(sigma_square);    IO::restore(ifs, radius, swap);    IO::restore(ifs, normal, swap);    IO::restore(ifs, sin_square, swap);    IO::restore(ifs, mue_square, swap);    IO::restore(ifs, sigma_square, swap);    rchild.set_radius(radius);    rchild.set_normal(normal);    rchild.set_sin_square(sin_square);    rchild.set_mue_square(mue_square);    rchild.set_sigma_square(sigma_square);  }  ifs.close();  // update face and vertex normals  mesh_.update_face_normals();  // bounding box  VDPMMesh::ConstVertexIter       vIt(mesh_.vertices_begin()),      vEnd(mesh_.vertices_end());   VDPMMesh::Point bbMin, bbMax;   bbMin = bbMax = mesh_.point(vIt);   for (; vIt!=vEnd; ++vIt)   {      bbMin.minimize(mesh_.point(vIt));      bbMax.maximize(mesh_.point(vIt));   }    // set center and radius  set_scene_pos(0.5f*(bbMin + bbMax), 0.5*(bbMin - bbMax).norm());      // info  std::cerr << mesh_.n_vertices() << " vertices, "    << mesh_.n_edges()    << " edge, "    << mesh_.n_faces()    << " faces, "    << n_details_ << " detail vertices\n";  updateGL();}void VDPMSynthesizerViewerWidget::keyPressEvent(QKeyEvent* _event){  switch (_event->key())  {    case Key_Home:      updateGL();      break;        case Key_End:      updateGL();      break;          case Key_Plus:      viewing_parameters_.increase_tolerance();      std::cout << "Scree-space error tolerance^2 is increased by " 		<< viewing_parameters_.tolerance_square() << std::endl;      updateGL();      break;          case Key_Minus:      viewing_parameters_.decrease_tolerance();      std::cout << "Screen-space error tolerance^2 is decreased by " 		<< viewing_parameters_.tolerance_square() << std::endl;      updateGL();      break;          case Key_A:      adaptive_mode_ = !(adaptive_mode_);      std::cout << "Adaptive refinement mode is " 		<< (adaptive_mode_ ? "on" : "off") << std::endl;      updateGL();      break;    case Key_O:      qFilename_ = QFileDialog::getOpenFileName("", "*.spm");      open_vd_prog_mesh(qFilename_);      break;          default:      MeshViewerWidget::keyPressEvent( _event );  }  }voidVDPMSynthesizerViewerWidget::update_viewing_parameters(){  viewing_parameters_.set_modelview_matrix(modelview_matrix());  viewing_parameters_.set_aspect((float) width()/ (float) height());  viewing_parameters_.set_fovy(fovy());    viewing_parameters_.update_viewing_configurations();}//=============================================================================} // namespace OpenMesh//=============================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -