// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "writeOFF.h" #include #include // write mesh to an ascii off file template IGL_INLINE bool igl::writeOFF( const std::string fname, const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F) { using namespace std; using namespace Eigen; assert(V.cols() == 3 && "V should have 3 columns"); ofstream s(fname); if(!s.is_open()) { fprintf(stderr,"IOError: writeOFF() could not open %s\n",fname.c_str()); return false; } s<< "OFF\n"< IGL_INLINE bool igl::writeOFF( const std::string fname, const Eigen::PlainObjectBase& V, const Eigen::PlainObjectBase& F, const Eigen::PlainObjectBase& C) { using namespace std; using namespace Eigen; assert(V.cols() == 3 && "V should have 3 columns"); assert(C.cols() == 3 && "C should have 3 columns"); if(V.rows() != C.rows()) { fprintf(stderr,"IOError: writeOFF() Only color per vertex supported. V and C should have same size.\n"); return false; } ofstream s(fname); if(!s.is_open()) { fprintf(stderr,"IOError: writeOFF() could not open %s\n",fname.c_str()); return false; } //Check if RGB values are in the range [0..1] or [0..255] int rgbScale = (C.maxCoeff() <= 1.0)?255:1; // Use RGB_Array instead of RGB because of clash with mingw macro // (https://github.com/libigl/libigl/pull/679) Eigen::MatrixXd RGB_Array = rgbScale * C; s<< "COFF\n"<, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); // generated by autoexplicit.sh template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); // generated by autoexplicit.sh template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); template bool igl::writeOFF, Eigen::Matrix, Eigen::Matrix >(std::basic_string, std::allocator >, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&); #endif