Skip to content

Commit d54137f

Browse files
author
Ayla Khan
committed
Use more reliable data conversion in FieldInformation. Use new function to change fielddata type.
1 parent 7677330 commit d54137f

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

src/Core/Algorithms/Legacy/Fields/FieldData/SetFieldDataToConstantValue.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ SetFieldDataToConstantValueAlgo::runImpl(FieldHandle input, FieldHandle& output)
6868
std::string data_type = get_option(DataType);
6969
if (data_type != "same as input")
7070
{
71-
fi.set_data_type(data_type);
71+
fi.set_data_type_by_string(data_type);
7272
}
73-
else if (!(fi.is_scalar()))
73+
else if (! fi.is_scalar() )
7474
{
7575
fi.make_double();
7676
}
@@ -81,7 +81,7 @@ SetFieldDataToConstantValueAlgo::runImpl(FieldHandle input, FieldHandle& output)
8181
fi.set_basis_type(basis_order);
8282
}
8383

84-
output = CreateField(fi,input->mesh());
84+
output = CreateField(fi, input->mesh());
8585

8686
if (!output)
8787
{
@@ -90,10 +90,10 @@ SetFieldDataToConstantValueAlgo::runImpl(FieldHandle input, FieldHandle& output)
9090
}
9191

9292
double new_value = get(Value).toDouble();
93-
93+
9494
output->vfield()->resize_values();
9595
output->vfield()->set_all_values(new_value);
96-
96+
9797
return (true);
9898
}
9999

src/Core/Datatypes/Legacy/Field/FieldInformation.cc

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -565,64 +565,61 @@ FieldInformation::set_data_type(const std::string& type1)
565565
data_type = type;
566566
}
567567

568-
void
568+
bool
569569
FieldInformation::set_data_type_by_string(const std::string& type)
570570
{
571-
data_info_type data_type;
572571
if (type == "char")
573572
{
574-
data_type = CHAR_E;
573+
return make_char();
575574
}
576575
else if (type == "unsigned char")
577576
{
578-
data_type = UNSIGNED_CHAR_E;
577+
return make_unsigned_char();
579578
}
580579
else if (type == "short")
581580
{
582-
data_type = SHORT_E;
581+
return make_short();
583582
}
584583
else if (type == "unsigned short")
585584
{
586-
data_type = UNSIGNED_SHORT_E;
585+
return make_unsigned_short();
587586
}
588587
else if (type == "int")
589588
{
590-
data_type = INT_E;
589+
return make_int();
591590
}
592591
else if (type == "unsigned int")
593592
{
594-
data_type = UNSIGNED_INT_E;
593+
return make_unsigned_int();
595594
}
596595
else if (type == "long long")
597596
{
598-
data_type = LONGLONG_E;
597+
return make_long_long();
599598
}
600599
else if (type == "unsigned long long")
601600
{
602-
data_type = UNSIGNED_LONGLONG_E;
601+
return make_unsigned_long_long();
603602
}
604-
if (type == "float")
603+
else if (type == "float")
605604
{
606-
data_type = FLOAT_E;
605+
return make_float();
607606
}
608607
else if (type == "double")
609608
{
610-
data_type = DOUBLE_E;
609+
return make_double();
611610
}
612611
else if (type == "Vector")
613612
{
614-
data_type = VECTOR_E;
613+
return make_vector();
615614
}
616615
else if (type == "Tensor")
617616
{
618-
data_type = TENSOR_E;
617+
return make_tensor();
619618
}
620619
else
621620
{
622-
// TODO: log this
623-
data_type = NONE_E;
621+
BOOST_THROW_EXCEPTION(UnknownMeshType() << Core::ErrorMessage("INTERNAL ERROR - unknown type"));
624622
}
625-
return set_data_type(data_type);
626623
}
627624

628625
void

src/Core/Datatypes/Legacy/Field/FieldInformation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class SCISHARE FieldInformation : public FieldTypeInformation {
193193

194194
std::string get_data_type() const;
195195
void set_data_type(const std::string&);
196-
void set_data_type_by_string(const std::string& type);
196+
bool set_data_type_by_string(const std::string& type);
197197
void set_data_type(data_info_type);
198198

199199
std::string get_container_type() const;

0 commit comments

Comments
 (0)