13#include <boost/algorithm/string.hpp>
23 if (!getline(
m_file, line)) {
27 while (line.empty() || line.substr(0, 1) ==
"#") {
28 if (!getline(
m_file, line)) {
40 std::vector<std::string> tokens;
41 boost::split(tokens, line, boost::is_any_of(
" "), boost::token_compress_on);
42 if (tokens.size() == 3) {
44 boost::lexical_cast<double>(tokens[1]),
45 boost::lexical_cast<double>(tokens[2]));
48 throw std::runtime_error(
"Error on reading OFF vertex");
51 throw std::runtime_error(
"Unexpected end of file, while reading OFF m_vertices");
62 std::vector<std::string> tokens;
63 boost::split(tokens, line, boost::is_any_of(
" "), boost::token_compress_on);
64 if (tokens.size() >= 4) {
65 nFaceVertices = boost::lexical_cast<size_t>(tokens[0]);
66 if (nFaceVertices == 3) {
67 t1 = boost::lexical_cast<uint32_t>(tokens[1]);
68 t2 = boost::lexical_cast<uint32_t>(tokens[2]);
69 t3 = boost::lexical_cast<uint32_t>(tokens[3]);
71 throw std::runtime_error(
"OFF face is not a triangle.");
77 throw std::runtime_error(
"Error on reading OFF triangle");
80 throw std::runtime_error(
"Unexpected end of file, while reading OFF triangles");
90 std::vector<std::string> tokens;
91 boost::split(tokens, line, boost::is_any_of(
" "), boost::token_compress_on);
92 if (tokens.size() == 3) {
94 m_nVertices = boost::lexical_cast<uint32_t>(tokens[0]);
97 throw std::runtime_error(
"Error in reading numbers of OFF m_vertices and "
98 "triangles, which may be too large");
103 throw std::runtime_error(
"Error on reading OFF number of m_vertices, faces & edges");
106 throw std::runtime_error(
"Unexpected end of OFF file");
112 std::unique_ptr<Geometry::MeshObject> retVal =
121 throw std::runtime_error(
"Expected first line to be 'OFF' keyword");
std::unique_ptr< Geometry::MeshObject > readOFFMeshObject()
std::unique_ptr< Geometry::MeshObject > readShape() override
LoadOff(const std::string &filename, ScaleUnits scaleType)
bool getOFFline(std::string &line)
std::vector< uint32_t > m_triangle
Kernel::V3D createScaledV3D(double xVal, double yVal, double zVal)
scales a 3D point according the units defined in the MeshFileIO class
std::vector< Kernel::V3D > m_vertices
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...