29 std::vector<std::string>* errors)
32 std::ifstream in(fname.c_str());
35 WARN(
"readTIN(): could not open stream from {:s}.", fname);
38 errors->push_back(
"readTINFile error opening stream from " + fname);
49 while (std::getline(in, line).good())
58 std::stringstream input(line);
67 if (!(input >> p0[0] >> p0[1] >> p0[2]))
69 ERR(
"Could not read coords of 1st point of triangle {:d}.",
id);
73 std::string(
"readTIN error: ") +
75 "Could not read coords of 1st point in triangle ") +
83 if (!(input >> p1[0] >> p1[1] >> p1[2]))
85 ERR(
"Could not read coords of 2nd point of triangle {:d}.",
id);
89 std::string(
"readTIN error: ") +
91 "Could not read coords of 2nd point in triangle ") +
99 if (!(input >> p2[0] >> p2[1] >> p2[2]))
101 ERR(
"Could not read coords of 3rd point of triangle {:d}.",
id);
105 std::string(
"readTIN error: ") +
107 "Could not read coords of 3rd point in triangle ") +
116 double const d_eps(std::numeric_limits<double>::epsilon());
119 ERR(
"readTIN: Triangle {:d} has zero area.",
id);
122 errors->push_back(std::string(
"readTIN: Triangle ") +
124 std::string(
" has zero area."));
131 std::size_t
const s(pnt_vec.
getVector().size());
133 std::size_t
const pnt_pos_0(
135 std::size_t
const pnt_pos_1(
137 std::size_t
const pnt_pos_2(
140 if (pnt_pos_0 != std::numeric_limits<std::size_t>::max() &&
141 pnt_pos_1 != std::numeric_limits<std::size_t>::max() &&
142 pnt_pos_2 != std::numeric_limits<std::size_t>::max())
144 sfc->addTriangle(pnt_pos_0, pnt_pos_1, pnt_pos_2);
148 if (sfc->getNumberOfTriangles() == 0)
150 WARN(
"readTIN(): No triangle found.", fname);
153 errors->push_back(
"readTIN error because of no triangle found");
163 std::string
const& file_name)
165 std::ofstream os(file_name.c_str());
168 WARN(
"writeSurfaceAsTIN(): could not open stream to {:s}.", file_name);
171 os.precision(std::numeric_limits<double>::max_digits10);
173 for (std::size_t l(0); l < n_tris; l++)
Definition of analytical geometry functions.
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
static GeoLib::Surface * readTIN(std::string const &fname, GeoLib::PointVec &pnt_vec, std::vector< std::string > *errors=nullptr)
static void writeSurfaceAsTIN(GeoLib::Surface const &surface, std::string const &file_name)
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
std::size_t push_back(Point *pnt)
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
std::size_t getNumberOfTriangles() const
std::vector< T * > const & getVector() const
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
const Point * getPoint(std::size_t i) const
const access operator to access the i-th triangle Point
double calcTriangleArea(MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)