31 std::string
const& property_vector_name_in,
32 std::string
const& property_vector_name_out)
38 return std::make_pair(
false,
39 "Original property vector '" +
40 property_vector_name_in +
"' not found.");
46 return std::make_pair(
false,
47 "Could not create new property vector '" +
48 property_vector_name_in +
"' not found.");
50 new_pv->resize(orig_pv->getNumberOfTuples());
51 for (std::size_t i(0); i < new_pv->getNumberOfTuples(); ++i)
53 (*new_pv)[i] =
static_cast<T2
>((*orig_pv)[i]);
55 return std::make_pair(
true,
"");
58int main(
int argc,
char* argv[])
61 "Converts a double or floating point cell data array of a vtk "
62 "unstructured grid into a int or double cell data array.\n\n"
63 "OpenGeoSys-6 software, version " +
66 "Copyright (c) 2012-2024, OpenGeoSys Community "
67 "(http://www.opengeosys.org)",
70 TCLAP::ValueArg<std::string> new_property_data_type_arg(
72 "new-property-data-type",
73 "the name of the data type as string (int or double)",
76 "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 "
86 "name of the new cell data array (PropertyVector) as string");
87 cmd.add(new_property_arg);
89 TCLAP::ValueArg<std::string> out_mesh_arg(
90 "o",
"out-mesh",
"output mesh file name",
true,
"",
"file name");
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 "property name as string");
100 cmd.add(property_arg);
102 TCLAP::ValueArg<std::string> mesh_arg(
103 "i",
"in-mesh",
"input mesh file name",
true,
"",
"file name");
106 cmd.parse(argc, argv);
109 MPI_Init(&argc, &argv);
112 std::unique_ptr<MeshLib::Mesh> mesh(
123 bool success =
false;
124 std::string err_msg =
"Could not find cell data array '" +
125 property_arg.getValue() +
"' in the mesh '" +
126 mesh_arg.getValue() +
"'";
128 if (new_property_data_type_arg.getValue() ==
"int")
130 if (mesh->getProperties().existsPropertyVector<
double>(
133 std::tie(success, err_msg) =
135 mesh->getProperties(),
136 property_arg.getValue(),
137 new_property_arg.getValue());
140 if (mesh->getProperties().existsPropertyVector<
float>(
143 std::tie(success, err_msg) =
145 mesh->getProperties(),
146 property_arg.getValue(),
147 new_property_arg.getValue());
150 if (new_property_data_type_arg.getValue() ==
"double")
152 if (mesh->getProperties().existsPropertyVector<
float>(
155 std::tie(success, err_msg) =
157 mesh->getProperties(),
158 property_arg.getValue(),
159 new_property_arg.getValue());
165 ERR(
"{:s}", err_msg);