22 std::string
const& property_vector_name_in,
23 std::string
const& property_vector_name_out)
29 return std::make_pair(
false,
30 "Original property vector '" +
31 property_vector_name_in +
"' not found.");
35 orig_pv->getNumberOfTuples(), 1);
38 return std::make_pair(
false,
39 "Could not create new property vector '" +
40 property_vector_name_in +
"' not found.");
42 for (std::size_t i(0); i < new_pv->getNumberOfTuples(); ++i)
44 (*new_pv)[i] =
static_cast<T2
>((*orig_pv)[i]);
46 return std::make_pair(
true,
"");
49int main(
int argc,
char* argv[])
52 "Converts a double or floating point cell data array of a vtk "
53 "unstructured grid into a int or double cell data array.\n\n"
54 "OpenGeoSys-6 software, version " +
57 "Copyright (c) 2012-2026, OpenGeoSys Community "
58 "(http://www.opengeosys.org)",
61 std::vector<std::string> allowed_types_vector{
"int",
"double"};
62 TCLAP::ValuesConstraint<std::string> allowed_types(allowed_types_vector);
63 TCLAP::ValueArg<std::string> new_property_data_type_arg(
65 "new-property-data-type",
66 "the name of the data type as string",
70 cmd.add(new_property_data_type_arg);
72 TCLAP::ValueArg<std::string> new_property_arg(
75 "the name of the new cell data array (PropertyVector) the values are "
80 cmd.add(new_property_arg);
82 TCLAP::ValueArg<std::string> out_mesh_arg(
"o",
"out-mesh",
83 "Output (.vtk) mesh file name",
84 true,
"",
"OUTPUT_FILE");
85 cmd.add(out_mesh_arg);
87 TCLAP::ValueArg<std::string> property_arg(
89 "existing-property-name",
90 "the name of the existing cell data array (PropertyVector)",
93 "EXISTING_PROP_NAME");
94 cmd.add(property_arg);
96 TCLAP::ValueArg<std::string> mesh_arg(
97 "i",
"in-mesh",
"Input (.vtk) mesh file name",
true,
"",
"INPUT_FILE");
101 cmd.add(log_level_arg);
102 cmd.parse(argc, argv);
107 std::unique_ptr<MeshLib::Mesh> mesh(
115 bool success =
false;
116 std::string err_msg =
"Could not find cell data array '" +
117 property_arg.getValue() +
"' in the mesh '" +
118 mesh_arg.getValue() +
"'";
120 if (new_property_data_type_arg.getValue() ==
"int")
122 if (mesh->getProperties().existsPropertyVector<
double>(
125 std::tie(success, err_msg) =
127 mesh->getProperties(),
128 property_arg.getValue(),
129 new_property_arg.getValue());
132 if (mesh->getProperties().existsPropertyVector<
float>(
135 std::tie(success, err_msg) =
137 mesh->getProperties(),
138 property_arg.getValue(),
139 new_property_arg.getValue());
142 if (new_property_data_type_arg.getValue() ==
"double")
144 if (mesh->getProperties().existsPropertyVector<
float>(
147 std::tie(success, err_msg) =
149 mesh->getProperties(),
150 property_arg.getValue(),
151 new_property_arg.getValue());
157 ERR(
"{:s}", err_msg);