54 #define OPENMESH_DECIMATER_MODPROGMESH_CC 62 #include <OpenMesh/Core/Utils/vector_cast.hh> 63 #include <OpenMesh/Core/IO/BinaryHelper.hh> 64 #include <OpenMesh/Core/Utils/Endian.hh> 79 template <
class MeshT>
82 write(
const std::string& _ofname )
85 size_t i=0, N=Base::mesh().n_vertices(), n_base_vertices(0), n_base_faces(0);
86 std::vector<typename Mesh::VertexHandle> vhandles(N);
90 typename Mesh::VertexIter
91 v_it=Base::mesh().vertices_begin(),
92 v_end=Base::mesh().vertices_end();
94 for (; v_it != v_end; ++v_it)
95 if (!Base::mesh().status(*v_it).deleted())
98 Base::mesh().property( idx_, *v_it ) = i;
105 typename InfoList::reverse_iterator
106 r_it=pmi_.rbegin(), r_end=pmi_.rend();
108 for (; r_it!=r_end; ++r_it)
110 vhandles[i] = r_it->v0;
111 Base::mesh().property( idx_, r_it->v0) = i;
117 typename Mesh::ConstFaceIter f_it = Base::mesh().faces_begin(),
118 f_end = Base::mesh().faces_end();
119 for (; f_it != f_end; ++f_it)
120 if (!Base::mesh().status(*f_it).deleted())
125 std::ofstream out( _ofname.c_str(), std::ios::binary );
135 IO::store( out, static_cast<unsigned int>(n_base_vertices), swap );
136 IO::store( out, static_cast<unsigned int>(n_base_faces) , swap );
137 IO::store( out, static_cast<unsigned int>(pmi_.size()) , swap );
142 for (i=0; i<n_base_vertices; ++i)
144 assert (!Base::mesh().status(vhandles[i]).deleted());
147 IO::store( out, p, swap );
152 for (f_it=Base::mesh().faces_begin(); f_it != f_end; ++f_it)
154 if (!Base::mesh().status(*f_it).deleted())
158 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *fv_it )) );
159 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *(++fv_it ))) );
160 IO::store( out, static_cast<unsigned int>(Base::mesh().property( idx_, *(++fv_it ))) );
166 for (r_it=pmi_.rbegin(); r_it!=r_end; ++r_it)
169 IO::store( out, vector_cast<Vec3f>(Base::mesh().point(r_it->v0)));
170 IO::store(out, static_cast<unsigned int>(Base::mesh().property(idx_, r_it->v1)));
172 r_it->vl.is_valid() ?
static_cast<unsigned int>(Base::mesh().property(idx_, r_it->vl)) : -1);
174 r_it->vr.is_valid() ?
static_cast<unsigned int>(Base::mesh().property(idx_, r_it->vr)) : -1);
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.
Little endian (Intel family and clones)
Kernel::ConstFaceVertexIter ConstFaceVertexIter
Circulator.
static Type local()
Return endian type of host system.
bool write(const std::string &_ofname)