46 int const number_of_subdivisions,
47 std::string&& polyline_name,
48 std::string&& geometry_name,
52 point0, point1, number_of_subdivisions);
53 std::vector<GeoLib::Point*> points(intermediate_points.begin(),
54 intermediate_points.end());
55 geometry.
addPointVec(std::move(points), geometry_name,
59 std::vector<std::size_t> polyline_point_ids(point_vec.getVector().size());
60 std::iota(begin(polyline_point_ids), end(polyline_point_ids), 0);
64 std::move(polyline_name));
71 std::array<GeoLib::Point, 4>
const& points,
72 std::array<int, 4>
const& number_of_subdivisions_per_edge)
74 std::vector<GeoLib::Point*> quad_points;
76 auto addPointsOnLine = [&quad_points](
auto const& begin,
auto const& end,
77 auto const number_of_subdivisions)
80 begin, end, number_of_subdivisions);
81 quad_points.insert(quad_points.end(), intermediate_points.begin(),
82 --intermediate_points.end());
83 delete intermediate_points.back();
87 addPointsOnLine(points[0], points[1], number_of_subdivisions_per_edge[0]);
88 addPointsOnLine(points[1], points[2], number_of_subdivisions_per_edge[1]);
89 addPointsOnLine(points[2], points[3], number_of_subdivisions_per_edge[2]);
90 addPointsOnLine(points[3], points[0], number_of_subdivisions_per_edge[3]);
97 int const number_of_subdivisions_first_x,
98 int const number_of_subdivisions_second_x,
99 int const number_of_subdivisions_first_y,
100 int const number_of_subdivisions_second_y,
101 int const number_of_subdivisions_first_z,
102 int const number_of_subdivisions_second_z,
103 std::string&& quad_name, std::string&& geometry_name,
106 std::array<GeoLib::Point, 4> edge_points;
107 edge_points[0] = point0;
108 edge_points[2] = point1;
109 std::array<int, 4> number_of_subdivisions;
110 if (point0[0] != point1[0] && point0[1] != point1[1] &&
111 point0[2] == point1[2])
118 number_of_subdivisions = {
119 number_of_subdivisions_first_x, number_of_subdivisions_first_y,
120 number_of_subdivisions_second_x, number_of_subdivisions_second_y};
122 else if (point0[0] != point1[0] && point0[1] == point1[1] &&
123 point0[2] != point1[2])
130 number_of_subdivisions = {
131 number_of_subdivisions_first_x, number_of_subdivisions_first_z,
132 number_of_subdivisions_second_x, number_of_subdivisions_second_z};
134 else if (point0[0] == point1[0] && point0[1] != point1[1] &&
135 point0[2] != point1[2])
142 number_of_subdivisions = {
143 number_of_subdivisions_first_y, number_of_subdivisions_first_z,
144 number_of_subdivisions_second_y, number_of_subdivisions_second_z};
148 ERR(
"Input coordinates don't describe an axis aligned polyline or "
158 std::vector<std::size_t> polyline_point_ids(point_vec.getVector().size() +
160 std::iota(begin(polyline_point_ids), end(polyline_point_ids), 0);
161 polyline_point_ids.back() = polyline_point_ids.front();
165 std::move(quad_name));
168 std::move(name_map));
172int main(
int argc,
char* argv[])
175 "Generate point, axis parallel polyline or axis parallel quad "
177 "OpenGeoSys-6 software, version " +
180 "Copyright (c) 2012-2026, OpenGeoSys Community "
181 "(http://www.opengeosys.org)",
183 TCLAP::ValueArg<double> z0(
"",
"z0",
"z coordinate of the first point",
186 TCLAP::ValueArg<double> y0(
"",
"y0",
"y coordinate of the first point",
189 TCLAP::ValueArg<double> x0(
"",
"x0",
"x coordinate of the first point",
192 TCLAP::ValueArg<double> z1(
"",
"z1",
"z coordinate of the first point",
195 TCLAP::ValueArg<double> y1(
"",
"y1",
"y coordinate of the first point",
198 TCLAP::ValueArg<double> x1(
"",
"x1",
"x coordinate of the first point",
201 TCLAP::ValueArg<int> nx(
"",
"nx",
"number of subdivisions in x direction",
204 TCLAP::ValueArg<int> nx1(
"",
"nx1",
"number of subdivisions in x direction",
207 TCLAP::ValueArg<int> ny(
"",
"ny",
"number of subdivisions in y direction",
210 TCLAP::ValueArg<int> ny1(
"",
"ny1",
"number of subdivisions in y direction",
213 TCLAP::ValueArg<int> nz(
"",
"nz",
"number of subdivisions in z direction",
214 false, 0,
"number of subdivisions in z direction");
216 TCLAP::ValueArg<int> nz1(
"",
"nz1",
"number of subdivisions in z direction",
219 TCLAP::ValueArg<std::string> geometry_name(
220 "",
"geometry_name",
"name of the generated geometry",
false,
221 "conceptual model",
"GEOMETRY_NAME");
222 cmd.add(geometry_name);
223 TCLAP::ValueArg<std::string> polyline_name(
224 "",
"polyline_name",
"name of the generated polyline",
false,
225 "polyline",
"POLYLINE_NAME");
226 cmd.add(polyline_name);
227 TCLAP::ValueArg<std::string> geo_output_arg(
228 "o",
"output",
"Output (.gml) geometry file",
true,
"",
"OUTPUT_FILE");
229 cmd.add(geo_output_arg);
231 cmd.add(log_level_arg);
232 cmd.parse(argc, argv);
237 auto const p0 =
GeoLib::Point{x0.getValue(), y0.getValue(), z0.getValue()};
238 auto const p1 =
GeoLib::Point{x1.getValue(), y1.getValue(), z1.getValue()};
241 auto constexpr eps = std::numeric_limits<double>::epsilon();
242 if (p1[0] - p0[0] < eps && p1[1] - p0[1] < eps && p1[2] - p0[2] < eps)
245 std::string(geometry_name.getValue()),
248 else if ((p1[0] - p0[0] >= eps && p1[1] - p0[1] < eps &&
249 p1[2] - p0[2] < eps) ||
250 (p1[0] - p0[0] < eps && p1[1] - p0[1] >= eps &&
251 p1[2] - p0[2] < eps) ||
252 (p1[0] - p0[0] < eps && p1[1] - p0[1] < eps &&
253 p1[2] - p0[2] >= eps))
256 p0, p1, nx.getValue(), std::string(polyline_name.getValue()),
257 std::string(geometry_name.getValue()), geometry);
261 auto eval = [](
int v,
int v1)
273 p0, p1, nx.getValue(), eval(nx.getValue(), nx1.getValue()),
274 ny.getValue(), eval(ny.getValue(), ny1.getValue()),
275 nz.getValue(), eval(nz.getValue(), nz1.getValue()),
276 std::string(polyline_name.getValue()),
277 std::string(geometry_name.getValue()),
278 geometry) == EXIT_FAILURE)
287 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)