28 std::vector<std::string>* errors)
31 std::ifstream in(fname.c_str());
34 WARN(
"readTIN(): could not open stream from {:s}.", fname);
37 errors->push_back(
"readTINFile error opening stream from " + fname);
48 while (std::getline(in, line).good())
57 std::stringstream input(line);
66 if (!(input >> p0[0] >> p0[1] >> p0[2]))
68 ERR(
"Could not read coords of 1st point of triangle {:d}.",
id);
72 std::string(
"readTIN error: ") +
74 "Could not read coords of 1st point in triangle ") +
82 if (!(input >> p1[0] >> p1[1] >> p1[2]))
84 ERR(
"Could not read coords of 2nd point of triangle {:d}.",
id);
88 std::string(
"readTIN error: ") +
90 "Could not read coords of 2nd point in triangle ") +
98 if (!(input >> p2[0] >> p2[1] >> p2[2]))
100 ERR(
"Could not read coords of 3rd point of triangle {:d}.",
id);
104 std::string(
"readTIN error: ") +
106 "Could not read coords of 3rd point in triangle ") +
115 double const d_eps(std::numeric_limits<double>::epsilon());
118 ERR(
"readTIN: Triangle {:d} has zero area.",
id);
121 errors->push_back(std::string(
"readTIN: Triangle ") +
123 std::string(
" has zero area."));
130 std::size_t
const s(pnt_vec.
getVector()->size());
132 std::size_t
const pnt_pos_0(
134 std::size_t
const pnt_pos_1(
136 std::size_t
const pnt_pos_2(
139 if (pnt_pos_0 != std::numeric_limits<std::size_t>::max() &&
140 pnt_pos_1 != std::numeric_limits<std::size_t>::max() &&
141 pnt_pos_2 != std::numeric_limits<std::size_t>::max())
143 sfc->addTriangle(pnt_pos_0, pnt_pos_1, pnt_pos_2);
147 if (sfc->getNumberOfTriangles() == 0)
149 WARN(
"readTIN(): No triangle found.", fname);
152 errors->push_back(
"readTIN error because of no triangle found");
162 std::string
const& file_name)
164 std::ofstream os(file_name.c_str());
167 WARN(
"writeSurfaceAsTIN(): could not open stream to {:s}.", file_name);
170 os.precision(std::numeric_limits<double>::digits10);
172 for (std::size_t l(0); l < n_tris; l++)
Definition of analytical geometry functions.
void ERR(char const *fmt, Args const &... args)
void WARN(char const *fmt, Args const &... 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 deletin...
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
const std::vector< T * > * 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)