61 if(_mesh.has_vertex_texcoords2D() && (userWriteOptions_ & OFFImporter::VERTEXTEXCOORDS) ) {
66 if(_mesh.has_vertex_colors() && (userWriteOptions_ & OFFImporter::VERTEXCOLOR) ) {
71 if(_mesh.has_vertex_normals() && (userWriteOptions_ & OFFImporter::VERTEXNORMAL) ) {
79 if(userWriteOptions_ & OFFImporter::BINARY) {
92 _out <<
"# %% BEGIN OPENFLIPPER_COMMENT %%" << std::endl;
94 std::string commentLine;
95 while (std::getline(comment, commentLine)) {
96 _out <<
"# " << commentLine << std::endl;
98 _out <<
"# %% END OPENFLIPPER_COMMENT %%" << std::endl;
106 if(userWriteOptions_ & OFFImporter::BINARY) {
109 if ( !OpenFlipper::Options::savingSettings() && saveOptions_ != 0)
110 _out.precision(savePrecision_->value());
121 typename MeshT::Point p;
122 typename MeshT::Normal n;
124 typename MeshT::TexCoord2D t;
130 for(
auto vit : _mesh.vertices()) {
135 p = _mesh.point(vit);
136 _out << p[0] <<
" " << p[1] <<
" " << p[2];
139 if(_mesh.has_vertex_normals() && (userWriteOptions_ & OFFImporter::VERTEXNORMAL)) {
141 _out <<
" " << n[0] <<
" " << n[1] <<
" " << n[2];
147 if(_mesh.has_vertex_colors() && (userWriteOptions_ & OFFImporter::VERTEXCOLOR)) {
148 c = OpenMesh::color_cast<OpenMesh::Vec4f> (_mesh.color(vit));
149 _out <<
" " << std::showpoint << c[0] <<
" " << std::showpoint << c[1] <<
" " << std::showpoint << c[2] <<
" " << std::showpoint << c[3];
153 if(_mesh.has_vertex_texcoords2D() && (userWriteOptions_ & OFFImporter::VERTEXTEXCOORDS)) {
154 t = _mesh.texcoord2D(vit);
155 _out <<
" " << t[0] <<
" " << t[1];
160 for(
auto fit : _mesh.faces()) {
168 for(
auto fvit : fit.vertices()) {
169 _out <<
" " << fvit.idx();
173 if(_mesh.has_face_colors() && (userWriteOptions_ & OFFImporter::FACECOLOR ) ) {
174 c = OpenMesh::color_cast<OpenMesh::Vec4f> (_mesh.color(fit));
175 _out <<
" " << std::showpoint << c[0] <<
" " << std::showpoint << c[1] <<
" " << std::showpoint << c[2];
177 if(userWriteOptions_ & OFFImporter::COLORALPHA) _out <<
" " << std::showpoint << c[3];
196 writeValue(_out, (uint)_mesh.
n_faces() );
197 writeValue(_out, (uint)_mesh.
n_edges() );
200 for(
auto vit : _mesh.vertices()) {
203 p = _mesh.point(vit);
204 writeValue(_out, p[0]);
205 writeValue(_out, p[1]);
206 writeValue(_out, p[2]);
209 if(_mesh.has_vertex_normals() && (userWriteOptions_ & OFFImporter::VERTEXNORMAL)) {
211 writeValue(_out, n[0]);
212 writeValue(_out, n[1]);
213 writeValue(_out, n[2]);
219 if(_mesh.has_vertex_colors() && (userWriteOptions_ & OFFImporter::VERTEXCOLOR)) {
220 c = OpenMesh::color_cast<OpenMesh::Vec4f> (_mesh.color(vit));
221 writeValue(_out, c[0]);
222 writeValue(_out, c[1]);
223 writeValue(_out, c[2]);
227 if(_mesh.has_vertex_texcoords2D() && (userWriteOptions_ & OFFImporter::VERTEXTEXCOORDS)) {
228 t = _mesh.texcoord2D(vit);
229 writeValue(_out, t[0]);
230 writeValue(_out, t[1]);
235 for(
auto fit : _mesh.faces()) {
238 writeValue(_out, fit.valence());
241 for(
auto fvit : fit.vertices()) {
242 writeValue(_out, fvit.idx());
246 if(_mesh.has_face_colors() && (userWriteOptions_ & OFFImporter::FACECOLOR)) {
249 if(userWriteOptions_ & OFFImporter::COLORALPHA) writeValue(_out, (uint)4);
250 else writeValue(_out, (uint)3);
253 c = OpenMesh::color_cast<OpenMesh::Vec4f> (_mesh.color(fit));
254 writeValue(_out, c[0]);
255 writeValue(_out, c[1]);
256 writeValue(_out, c[2]);
258 if(userWriteOptions_ & OFFImporter::COLORALPHA) writeValue(_out, c[3]);