/*===========================================================================*\ * * * OpenMesh * * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen * * www.openmesh.org * * * *---------------------------------------------------------------------------* * This file is part of OpenMesh. * * * * OpenMesh is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version with the * * following exceptions: * * * * If other files instantiate templates or use macros * * or inline functions from this file, or you compile this file and * * link it with other files to produce an executable, this file does * * not by itself cause the resulting executable to be covered by the * * GNU Lesser General Public License. This exception does not however * * invalidate any other reasons why the executable file might be * * covered by the GNU Lesser General Public License. * * * * OpenMesh is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU LesserGeneral Public * * License along with OpenMesh. If not, * * see . * * * \*===========================================================================*/ /*===========================================================================*\ * * * $Revision$ * * $Date$ * * * \*===========================================================================*/ #include #include #include #include #include #include #include "ServerSideVDPM.hh" using OpenMesh::VDPM::VHierarchyNode; using OpenMesh::VDPM::VHierarchyNodeIndex; using OpenMesh::VDPM::VHierarchyNodeHandle; void ServerSideVDPM:: clear() { points_.clear(); triangles_.clear(); vhierarchy_.clear(); n_base_vertices_ = 0; n_base_faces_ = 0; n_details_ = 0; } OpenMesh::VertexHandle ServerSideVDPM:: add_vertex(const OpenMesh::Vec3f &p) { points_.push_back(p); return OpenMesh::VertexHandle(points_.size() - 1); } OpenMesh::FaceHandle ServerSideVDPM:: add_face(const unsigned int _triangle[3]) { OpenMesh::Vec3ui fvi; fvi[0] = _triangle[0]; fvi[1] = _triangle[1]; fvi[2] = _triangle[2]; triangles_.push_back(fvi); return OpenMesh::FaceHandle(triangles_.size() - 1); } void ServerSideVDPM:: vhierarchy_roots(VHierarchyNodeHandleContainer &roots) const { unsigned int i; roots.clear(); for (i=0; i index2handle_map; std::ifstream ifs(_filename, std::ios::binary); if (!ifs) { std::cerr << "read error\n"; return false; } // bool swap = OpenMesh::Endian::local() != OpenMesh::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(); return false; } clear(); OpenMesh::IO::restore(ifs, n_base_vertices_, swap); OpenMesh::IO::restore(ifs, n_base_faces_, swap); OpenMesh::IO::restore(ifs, n_details_, swap); // update tree_id_bits_ vhierarchy_.set_num_roots(n_base_vertices_); // read base_mesh for (i=0; i