59 #define OPENMESH_DECIMATER_MODPROGMESH_CC
67 #include <OpenMesh/Core/Utils/vector_cast.hh>
68 #include <OpenMesh/Core/IO/BinaryHelper.hh>
69 #include <OpenMesh/Core/Utils/Endian.hh>
84 template <
class MeshT>
87 write(
const std::string& _ofname )
90 size_t i=0, N=Base::mesh().n_vertices(), n_base_vertices(0), n_base_faces(0);
91 std::vector<typename Mesh::VertexHandle> vhandles(N);
95 typename Mesh::VertexIter
96 v_it=Base::mesh().vertices_begin(),
97 v_end=Base::mesh().vertices_end();
99 for (; v_it != v_end; ++v_it)
100 if (!Base::mesh().status(*v_it).deleted())
103 Base::mesh().property( idx_, *v_it ) = i;
110 typename InfoList::reverse_iterator
111 r_it=pmi_.rbegin(), r_end=pmi_.rend();
113 for (; r_it!=r_end; ++r_it)
115 vhandles[i] = r_it->v0;
116 Base::mesh().property( idx_, r_it->v0) = i;
122 typename Mesh::ConstFaceIter f_it = Base::mesh().faces_begin(),
123 f_end = Base::mesh().faces_end();
124 for (; f_it != f_end; ++f_it)
125 if (!Base::mesh().status(*f_it).deleted())
130 std::ofstream out( _ofname.c_str(), std::ios::binary );
140 IO::store( out, static_cast<unsigned int>(n_base_vertices), swap );
141 IO::store( out, static_cast<unsigned int>(n_base_faces) , swap );
142 IO::store( out, static_cast<unsigned int>(pmi_.size()) , swap );
147 for (i=0; i<n_base_vertices; ++i)
149 assert (!Base::mesh().status(vhandles[i]).deleted());
152 IO::store( out, p, swap );
157 for (f_it=Base::mesh().faces_begin(); f_it != f_end; ++f_it)
159 if (!Base::mesh().status(*f_it).deleted())
163 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *fv_it )) );
164 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *(++fv_it ))) );
165 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *(++fv_it ))) );
171 for (r_it=pmi_.rbegin(); r_it!=r_end; ++r_it)
174 IO::store( out, vector_cast<Vec3f>(Base::mesh().point(r_it->v0)));
175 IO::store(out, static_cast<unsigned int>(Base::mesh().property(idx_, r_it->v1)));
177 r_it->vl.is_valid() ?
static_cast<unsigned int>(Base::mesh().property(idx_, r_it->vl)) : -1);
179 r_it->vr.is_valid() ?
static_cast<unsigned int>(Base::mesh().property(idx_, r_it->vr)) : -1);
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
void vector_cast(const src_t &_src, dst_t &_dst, GenProg::Int2Type< n >)
Cast vector type to another vector type by copying the vector elements.
bool write(const std::string &_ofname)
static Type local()
Return endian type of host system.
Little endian (Intel family and clones)