Changeset 80
- Timestamp:
- Sep 30, 2005, 5:30:24 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpUnits.cc
r79 r80 777 777 double value = val; 778 778 RpUnits* basis = this->getBasis(); 779 RpUnits* toBasis = toUnit->getBasis(); 779 780 RpUnits* fromUnit = this; 780 781 RpUnits* dictToUnit = NULL; … … 809 810 810 811 // find the toUnit in our dictionary. 811 812 dictToUnit = find(toUnit->getUnits()); 812 // if the toUnits has a basis, we need to search for the basis 813 // and convert between basis' and then convert again back to the 814 // original unit. 815 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 816 dictToUnit = find(toBasis->getUnits()); 817 } 818 else { 819 dictToUnit = find(toUnit->getUnits()); 820 } 813 821 814 822 // did we find the unit in the dictionary? … … 841 849 842 850 value = p->conv->convForwFxnPtr(value); 851 852 // check to see if we converted to the actual requested unit 853 // or to the requested unit's basis. 854 // if we converted to the requested unit's basis. we need to 855 // do one last conversion from the requested unit's basis back 856 // to the requested unit. 857 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 858 my_result = 0; 859 value = toBasis->convert(toUnit,value,&my_result); 860 if (my_result != 0) { 861 if (result) { 862 *result += 1; 863 } 864 } 865 } 866 867 // we can probably remove this 843 868 if (result) { 844 *result = 0;869 *result += 0; 845 870 } 846 871 break; … … 852 877 853 878 value = p->conv->convBackFxnPtr(value); 879 880 // check to see if we converted to the actual requested unit 881 // or to the requested unit's basis. 882 // if we converted to the requested unit's basis. we need to 883 // do one last conversion from the requested unit's basis back 884 // to the requested unit. 885 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 886 my_result = 0; 887 value = toBasis->convert(toUnit,value,&my_result); 888 if (my_result != 0) { 889 if (result) { 890 *result += 1; 891 } 892 } 893 } 894 895 // we can probably remove this 854 896 if (result) { 855 *result = 0;897 *result += 0; 856 898 } 857 899 break; … … 865 907 if ( p == NULL) { 866 908 // we did not find the conversion 909 if (result) { 910 *result += 1; 911 } 867 912 return val; 868 913 } … … 883 928 void* value = val; 884 929 RpUnits* basis = this->getBasis(); 930 RpUnits* toBasis = toUnit->getBasis(); 885 931 RpUnits* fromUnit = this; 886 932 RpUnits* dictToUnit = NULL; … … 915 961 916 962 // find the toUnit in our dictionary. 917 918 dictToUnit = find(toUnit->getUnits()); 963 // if the toUnits has a basis, we need to search for the basis 964 // and convert between basis' and then convert again back to the 965 // original unit. 966 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 967 dictToUnit = find(toBasis->getUnits()); 968 } 969 else { 970 dictToUnit = find(toUnit->getUnits()); 971 } 919 972 920 973 // did we find the unit in the dictionary? … … 948 1001 value = p->conv->convForwFxnPtrVoid(p->conv->convForwData,value); 949 1002 1003 // check to see if we converted to the actual requested unit 1004 // or to the requested unit's basis. 1005 // if we converted to the requested unit's basis. we need to 1006 // do one last conversion from the requested unit's basis back 1007 // to the requested unit. 1008 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 1009 my_result = 0; 1010 value = toBasis->convert(toUnit,value,&my_result); 1011 if (my_result != 0) { 1012 if (result) { 1013 *result += 1; 1014 } 1015 } 1016 } 1017 1018 // we can probably remove this 950 1019 if (result) { 951 1020 *result = 0; … … 959 1028 960 1029 value = p->conv->convBackFxnPtrVoid(p->conv->convBackData,value); 1030 1031 // check to see if we converted to the actual requested unit 1032 // or to the requested unit's basis. 1033 // if we converted to the requested unit's basis. we need to 1034 // do one last conversion from the requested unit's basis back 1035 // to the requested unit. 1036 if ( (toBasis) && (toBasis->getUnits() != fromUnit->getUnits()) ) { 1037 my_result = 0; 1038 value = toBasis->convert(toUnit,value,&my_result); 1039 if (my_result != 0) { 1040 if (result) { 1041 *result += 1; 1042 } 1043 } 1044 } 1045 1046 // we can probably remove this 961 1047 if (result) { 962 1048 *result = 0; … … 972 1058 if ( p == NULL) { 973 1059 // we did not find the conversion 1060 if (result) { 1061 *result += 1; 1062 } 974 1063 return val; 975 1064 }
Note: See TracChangeset
for help on using the changeset viewer.