52 int const number_of_subdivisions,
53 std::string&& polyline_name,
54 std::string& geometry_name,
58 point0, point1, number_of_subdivisions);
59 std::vector<GeoLib::Point*> points(intermediate_points.begin(),
60 intermediate_points.end());
61 geometry.
addPointVec(std::move(points), geometry_name,
65 std::vector<std::size_t> polyline_point_ids(point_vec.getVector().size());
66 std::iota(begin(polyline_point_ids), end(polyline_point_ids), 0);
70 std::move(polyline_name));
77 std::array<GeoLib::Point, 4>
const& points,
78 std::array<int, 4>
const& number_of_subdivisions_per_edge)
80 std::vector<GeoLib::Point*> quad_points;
82 auto addPointsOnLine = [&quad_points](
auto const& begin,
auto const& end,
83 auto const number_of_subdivisions)
86 begin, end, number_of_subdivisions);
87 quad_points.insert(quad_points.end(), intermediate_points.begin(),
88 --intermediate_points.end());
89 delete intermediate_points.back();
93 addPointsOnLine(points[0], points[1], number_of_subdivisions_per_edge[0]);
94 addPointsOnLine(points[1], points[2], number_of_subdivisions_per_edge[1]);
95 addPointsOnLine(points[2], points[3], number_of_subdivisions_per_edge[2]);
96 addPointsOnLine(points[3], points[0], number_of_subdivisions_per_edge[3]);
103 int const number_of_subdivisions_first_x,
104 int const number_of_subdivisions_second_x,
105 int const number_of_subdivisions_first_y,
106 int const number_of_subdivisions_second_y,
107 int const number_of_subdivisions_first_z,
108 int const number_of_subdivisions_second_z,
109 std::string&& quad_name, std::string& geometry_name,
112 std::array<GeoLib::Point, 4> edge_points;
113 edge_points[0] = point0;
114 edge_points[2] = point1;
115 std::array<int, 4> number_of_subdivisions;
116 if (point0[0] != point1[0] && point0[1] != point1[1] &&
117 point0[2] == point1[2])
124 number_of_subdivisions = {
125 number_of_subdivisions_first_x, number_of_subdivisions_first_y,
126 number_of_subdivisions_second_x, number_of_subdivisions_second_y};
128 else if (point0[0] != point1[0] && point0[1] == point1[1] &&
129 point0[2] != point1[2])
136 number_of_subdivisions = {
137 number_of_subdivisions_first_x, number_of_subdivisions_first_z,
138 number_of_subdivisions_second_x, number_of_subdivisions_second_z};
140 else if (point0[0] == point1[0] && point0[1] != point1[1] &&
141 point0[2] != point1[2])
148 number_of_subdivisions = {
149 number_of_subdivisions_first_y, number_of_subdivisions_first_z,
150 number_of_subdivisions_second_y, number_of_subdivisions_second_z};
154 ERR(
"Input coordinates don't describe an axis aligned polyline or "
164 std::vector<std::size_t> polyline_point_ids(point_vec.getVector().size() +
166 std::iota(begin(polyline_point_ids), end(polyline_point_ids), 0);
167 polyline_point_ids.back() = polyline_point_ids.front();
171 std::move(quad_name));
174 std::move(name_map));
178int main(
int argc,
char* argv[])
181 "Generate point, axis parallel polyline or axis parallel quad "
183 "OpenGeoSys-6 software, version " +
186 "Copyright (c) 2012-2024, OpenGeoSys Community "
187 "(http://www.opengeosys.org)",
189 TCLAP::ValueArg<double> z0(
"",
"z0",
"z coordinate of the first point",
192 TCLAP::ValueArg<double> y0(
"",
"y0",
"y coordinate of the first point",
195 TCLAP::ValueArg<double> x0(
"",
"x0",
"x coordinate of the first point",
198 TCLAP::ValueArg<double> z1(
"",
"z1",
"z coordinate of the first point",
201 TCLAP::ValueArg<double> y1(
"",
"y1",
"y coordinate of the first point",
204 TCLAP::ValueArg<double> x1(
"",
"x1",
"x coordinate of the first point",
207 TCLAP::ValueArg<int> nx(
"",
"nx",
"number of subdivisions in x direction",
208 false, 0,
"number of subdivisions in x direction");
210 TCLAP::ValueArg<int> nx1(
"",
"nx1",
"number of subdivisions in x direction",
212 "number of subdivisions in x direction");
214 TCLAP::ValueArg<int> ny(
"",
"ny",
"number of subdivisions in y direction",
215 false, 0,
"number of subdivisions in y direction");
217 TCLAP::ValueArg<int> ny1(
"",
"ny1",
"number of subdivisions in y direction",
219 "number of subdivisions in y direction");
221 TCLAP::ValueArg<int> nz(
"",
"nz",
"number of subdivisions in z direction",
222 false, 0,
"number of subdivisions in z direction");
224 TCLAP::ValueArg<int> nz1(
"",
"nz1",
"number of subdivisions in z direction",
226 "number of subdivisions in z direction");
228 TCLAP::ValueArg<std::string> geometry_name(
229 "",
"geometry_name",
"name of the generated geometry",
false,
230 "conceptual model",
"name of the geometry");
231 cmd.add(geometry_name);
232 TCLAP::ValueArg<std::string> polyline_name(
233 "",
"polyline_name",
"name of the generated polyline",
false,
234 "polyline",
"name of the generated polyline");
235 cmd.add(polyline_name);
236 TCLAP::ValueArg<std::string> geo_output_arg(
237 "o",
"output",
"output geometry file (*.gml)",
true,
"",
"output file");
238 cmd.add(geo_output_arg);
239 cmd.parse(argc, argv);
243 auto const p0 =
GeoLib::Point{x0.getValue(), y0.getValue(), z0.getValue()};
244 auto const p1 =
GeoLib::Point{x1.getValue(), y1.getValue(), z1.getValue()};
247 auto constexpr eps = std::numeric_limits<double>::epsilon();
248 if (p1[0] - p0[0] < eps && p1[1] - p0[1] < eps && p1[2] - p0[2] < eps)
251 geometry_name.getValue(), geometry);
253 else if ((p1[0] - p0[0] >= eps && p1[1] - p0[1] < eps &&
254 p1[2] - p0[2] < eps) ||
255 (p1[0] - p0[0] < eps && p1[1] - p0[1] >= eps &&
256 p1[2] - p0[2] < eps) ||
257 (p1[0] - p0[0] < eps && p1[1] - p0[1] < eps &&
258 p1[2] - p0[2] >= eps))
261 std::move(polyline_name.getValue()),
262 geometry_name.getValue(), geometry);
266 auto eval = [](
int v,
int v1)
278 p0, p1, nx.getValue(), eval(nx.getValue(), nx1.getValue()),
279 ny.getValue(), eval(ny.getValue(), ny1.getValue()),
280 nz.getValue(), eval(nz.getValue(), nz1.getValue()),
281 std::move(polyline_name.getValue()), geometry_name.getValue(),
282 geometry) == EXIT_FAILURE)
291 geo_output_arg.getValue());
int generateQuadGeometry(GeoLib::Point const &point0, GeoLib::Point const &point1, int const number_of_subdivisions_first_x, int const number_of_subdivisions_second_x, int const number_of_subdivisions_first_y, int const number_of_subdivisions_second_y, int const number_of_subdivisions_first_z, int const number_of_subdivisions_second_z, std::string &&quad_name, std::string &geometry_name, GeoLib::GEOObjects &geometry)