28 std::string
const& property_vector_name_in,
29 std::string
const& property_vector_name_out)
35 return std::make_pair(
false,
36 "Original property vector '" +
37 property_vector_name_in +
"' not found.");
41 orig_pv->getNumberOfTuples(), 1);
44 return std::make_pair(
false,
45 "Could not create new property vector '" +
46 property_vector_name_in +
"' not found.");
48 for (std::size_t i(0); i < new_pv->getNumberOfTuples(); ++i)
50 (*new_pv)[i] =
static_cast<T2
>((*orig_pv)[i]);
52 return std::make_pair(
true,
"");
55int main(
int argc,
char* argv[])
58 "Converts a double or floating point cell data array of a vtk "
59 "unstructured grid into a int or double cell data array.\n\n"
60 "OpenGeoSys-6 software, version " +
63 "Copyright (c) 2012-2025, OpenGeoSys Community "
64 "(http://www.opengeosys.org)",
67 std::vector<std::string> allowed_types_vector{
"int",
"double"};
68 TCLAP::ValuesConstraint<std::string> allowed_types(allowed_types_vector);
69 TCLAP::ValueArg<std::string> new_property_data_type_arg(
71 "new-property-data-type",
72 "the name of the data type as string",
76 cmd.add(new_property_data_type_arg);
78 TCLAP::ValueArg<std::string> new_property_arg(
81 "the name of the new cell data array (PropertyVector) the values are "
86 cmd.add(new_property_arg);
88 TCLAP::ValueArg<std::string> out_mesh_arg(
"o",
"out-mesh",
89 "Output (.vtk) mesh file name",
90 true,
"",
"OUTPUT_FILE");
91 cmd.add(out_mesh_arg);
93 TCLAP::ValueArg<std::string> property_arg(
95 "existing-property-name",
96 "the name of the existing cell data array (PropertyVector)",
99 "EXISTING_PROP_NAME");
100 cmd.add(property_arg);
102 TCLAP::ValueArg<std::string> mesh_arg(
103 "i",
"in-mesh",
"Input (.vtk) mesh file name",
true,
"",
"INPUT_FILE");
106 cmd.parse(argc, argv);
110 std::unique_ptr<MeshLib::Mesh> mesh(
118 bool success =
false;
119 std::string err_msg =
"Could not find cell data array '" +
120 property_arg.getValue() +
"' in the mesh '" +
121 mesh_arg.getValue() +
"'";
123 if (new_property_data_type_arg.getValue() ==
"int")
125 if (mesh->getProperties().existsPropertyVector<
double>(
128 std::tie(success, err_msg) =
130 mesh->getProperties(),
131 property_arg.getValue(),
132 new_property_arg.getValue());
135 if (mesh->getProperties().existsPropertyVector<
float>(
138 std::tie(success, err_msg) =
140 mesh->getProperties(),
141 property_arg.getValue(),
142 new_property_arg.getValue());
145 if (new_property_data_type_arg.getValue() ==
"double")
147 if (mesh->getProperties().existsPropertyVector<
float>(
150 std::tie(success, err_msg) =
152 mesh->getProperties(),
153 property_arg.getValue(),
154 new_property_arg.getValue());
160 ERR(
"{:s}", err_msg);