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.");
43 return std::make_pair(
false,
44 "Could not create new property vector '" +
45 property_vector_name_in +
"' not found.");
47 new_pv->resize(orig_pv->getNumberOfTuples());
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-2024, OpenGeoSys Community "
64 "(http://www.opengeosys.org)",
67 TCLAP::ValueArg<std::string> new_property_data_type_arg(
69 "new-property-data-type",
70 "the name of the data type as string (int or double)",
73 "data type as string");
74 cmd.add(new_property_data_type_arg);
76 TCLAP::ValueArg<std::string> new_property_arg(
79 "the name of the new cell data array (PropertyVector) the values are "
83 "name of the new cell data array (PropertyVector) as string");
84 cmd.add(new_property_arg);
86 TCLAP::ValueArg<std::string> out_mesh_arg(
87 "o",
"out-mesh",
"output mesh file name",
true,
"",
"file name");
88 cmd.add(out_mesh_arg);
90 TCLAP::ValueArg<std::string> property_arg(
92 "existing-property-name",
93 "the name of the existing cell data array (PropertyVector)",
96 "property name as string");
97 cmd.add(property_arg);
99 TCLAP::ValueArg<std::string> mesh_arg(
100 "i",
"in-mesh",
"input mesh file name",
true,
"",
"file name");
103 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);