29 std::string
const& property_vector_name_in,
30 std::string
const& property_vector_name_out)
36 return std::make_pair(
false,
37 "Original property vector '" +
38 property_vector_name_in +
"' not found.");
42 orig_pv->getNumberOfTuples(), 1);
45 return std::make_pair(
false,
46 "Could not create new property vector '" +
47 property_vector_name_in +
"' not found.");
49 for (std::size_t i(0); i < new_pv->getNumberOfTuples(); ++i)
51 (*new_pv)[i] =
static_cast<T2
>((*orig_pv)[i]);
53 return std::make_pair(
true,
"");
56int main(
int argc,
char* argv[])
59 "Converts a double or floating point cell data array of a vtk "
60 "unstructured grid into a int or double cell data array.\n\n"
61 "OpenGeoSys-6 software, version " +
64 "Copyright (c) 2012-2025, OpenGeoSys Community "
65 "(http://www.opengeosys.org)",
68 std::vector<std::string> allowed_types_vector{
"int",
"double"};
69 TCLAP::ValuesConstraint<std::string> allowed_types(allowed_types_vector);
70 TCLAP::ValueArg<std::string> new_property_data_type_arg(
72 "new-property-data-type",
73 "the name of the data type as string",
77 cmd.add(new_property_data_type_arg);
79 TCLAP::ValueArg<std::string> new_property_arg(
82 "the name of the new cell data array (PropertyVector) the values are "
87 cmd.add(new_property_arg);
89 TCLAP::ValueArg<std::string> out_mesh_arg(
"o",
"out-mesh",
90 "Output (.vtk) mesh file name",
91 true,
"",
"OUTPUT_FILE");
92 cmd.add(out_mesh_arg);
94 TCLAP::ValueArg<std::string> property_arg(
96 "existing-property-name",
97 "the name of the existing cell data array (PropertyVector)",
100 "EXISTING_PROP_NAME");
101 cmd.add(property_arg);
103 TCLAP::ValueArg<std::string> mesh_arg(
104 "i",
"in-mesh",
"Input (.vtk) mesh file name",
true,
"",
"INPUT_FILE");
108 cmd.add(log_level_arg);
109 cmd.parse(argc, argv);
114 std::unique_ptr<MeshLib::Mesh> mesh(
122 bool success =
false;
123 std::string err_msg =
"Could not find cell data array '" +
124 property_arg.getValue() +
"' in the mesh '" +
125 mesh_arg.getValue() +
"'";
127 if (new_property_data_type_arg.getValue() ==
"int")
129 if (mesh->getProperties().existsPropertyVector<
double>(
132 std::tie(success, err_msg) =
134 mesh->getProperties(),
135 property_arg.getValue(),
136 new_property_arg.getValue());
139 if (mesh->getProperties().existsPropertyVector<
float>(
142 std::tie(success, err_msg) =
144 mesh->getProperties(),
145 property_arg.getValue(),
146 new_property_arg.getValue());
149 if (new_property_data_type_arg.getValue() ==
"double")
151 if (mesh->getProperties().existsPropertyVector<
float>(
154 std::tie(success, err_msg) =
156 mesh->getProperties(),
157 property_arg.getValue(),
158 new_property_arg.getValue());
164 ERR(
"{:s}", err_msg);