@@ -1401,16 +1401,21 @@ class GenericUnits {
14011401 }
14021402 return NULL ;
14031403 }
1404- // ! \brief Convert units to the system used by another set of units in place
1405- // ! and determine the conversion factors necessary to convert quantities
1406- // ! with these units to the new unit system.
1407- // ! \param x Unit system to convert to.
1408- // ! \return Array of conversion factors where the first element is the
1409- // ! factor that values should be multiplied by and the second element is
1410- // ! the offset between the zero points in this and x.
1411- std::vector<double > convert_to_units_system (const GenericUnits& x) {
1412- if (dimension () == x.dimension ())
1413- return convert_to (x);
1404+ // ! \brief Get the equivalent of this set of units in the units system
1405+ // ! used by another set of units.
1406+ // ! \param x Unit system to get units in.
1407+ // ! \return Equivalent units in the x unit system.
1408+ GenericUnits<Encoding> as_units_system (const GenericUnits& x) const {
1409+ GenericUnits<Encoding> new_Units;
1410+ as_units_system (x, new_Units);
1411+ return new_Units;
1412+ }
1413+ // ! \brief Get the equivalent of this set of units in the units system
1414+ // ! used by another set of units.
1415+ // ! \param x Unit system to get units in.
1416+ // ! \param[out] dest Destination for equivalent units in the x unit
1417+ // ! system.
1418+ void as_units_system (const GenericUnits& x, GenericUnits& dest) const {
14141419 std::vector<GenericUnit<Encoding> > new_units;
14151420 for (typename std::vector<GenericUnit<Encoding> >::const_iterator it = units_.begin (); it != units_.end (); it++) {
14161421 if (it->is_null ())
@@ -1425,7 +1430,20 @@ class GenericUnits {
14251430 new_units.push_back (tmp);
14261431 }
14271432 }
1428- GenericUnits<Encoding> new_Units (new_units);
1433+ dest = GenericUnits<Encoding>(new_units);
1434+ }
1435+
1436+ // ! \brief Convert units to the system used by another set of units in place
1437+ // ! and determine the conversion factors necessary to convert quantities
1438+ // ! with these units to the new unit system.
1439+ // ! \param x Unit system to convert to.
1440+ // ! \return Array of conversion factors where the first element is the
1441+ // ! factor that values should be multiplied by and the second element is
1442+ // ! the offset between the zero points in this and x.
1443+ std::vector<double > convert_to_units_system (const GenericUnits& x) {
1444+ if (dimension () == x.dimension ())
1445+ return convert_to (x);
1446+ GenericUnits<Encoding> new_Units = as_units_system (x);
14291447 return convert_to (new_Units);
14301448 }
14311449private:
@@ -2818,9 +2836,11 @@ class GenericQuantityArray {
28182836 }
28192837 // ! \brief Convert quantity to the system used by another set of units in
28202838 // ! place.
2821- // ! \param units Unit system to convert to.
2822- void convert_to_units_system (const UnitsType& units) {
2823- std::vector<double > factor = units_.convert_to_units_system (units);
2839+ // ! \param unitSystem Unit system to convert to.
2840+ void convert_to_units_system (const UnitsType& unitSystem) {
2841+ // UnitsType new_units = units_.as_units_system(unitSystem);
2842+ // std::vector<double> factor = units_.convert_to(new_units);
2843+ std::vector<double > factor = units_.convert_to_units_system (unitSystem);
28242844 apply_conversion_factor (factor);
28252845 }
28262846 // ! \brief Create a new quantity by converting this one to a new set of
0 commit comments