mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023567: Wrong STEP unit is returned by STEPControl_Reader.FileUnits() function
Fix bug with using of uninitialized variable. New version of patch: pass unit object to the getSiName() function directly. Test case for this bug
This commit is contained in:
parent
4e76d93bf1
commit
e9c15c4cec
@ -433,34 +433,35 @@ void STEPControl_Reader::FileUnits( TColStd_SequenceOfAsciiString& theUnitLength
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
inline static TCollection_AsciiString getSiName(StepBasic_SiUnitName theName,
|
inline static TCollection_AsciiString getSiName(const Handle(StepBasic_SiUnit)& theUnit)
|
||||||
StepBasic_SiPrefix thePrefix)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
TCollection_AsciiString aName;
|
TCollection_AsciiString aName;
|
||||||
switch (thePrefix) {
|
if (theUnit->HasPrefix()) {
|
||||||
case StepBasic_spExa: aName += "exa"; break;
|
switch (theUnit->Prefix()) {
|
||||||
case StepBasic_spPeta: aName += "peta"; break;
|
case StepBasic_spExa: aName += "exa"; break;
|
||||||
case StepBasic_spTera: aName += "tera"; break;
|
case StepBasic_spPeta: aName += "peta"; break;
|
||||||
case StepBasic_spGiga: aName += "giga"; break;
|
case StepBasic_spTera: aName += "tera"; break;
|
||||||
case StepBasic_spMega: aName += "mega"; break;
|
case StepBasic_spGiga: aName += "giga"; break;
|
||||||
case StepBasic_spHecto: aName += "hecto"; break;
|
case StepBasic_spMega: aName += "mega"; break;
|
||||||
case StepBasic_spDeca: aName += "deca"; break;
|
case StepBasic_spHecto: aName += "hecto"; break;
|
||||||
case StepBasic_spDeci: aName += "deci"; break;
|
case StepBasic_spDeca: aName += "deca"; break;
|
||||||
|
case StepBasic_spDeci: aName += "deci"; break;
|
||||||
|
|
||||||
case StepBasic_spPico: aName += "pico"; break;
|
case StepBasic_spPico: aName += "pico"; break;
|
||||||
case StepBasic_spFemto: aName += "femto"; break;
|
case StepBasic_spFemto: aName += "femto"; break;
|
||||||
case StepBasic_spAtto: aName += "atto"; break;
|
case StepBasic_spAtto: aName += "atto"; break;
|
||||||
|
|
||||||
case StepBasic_spKilo : aName += "kilo"; break;
|
case StepBasic_spKilo : aName += "kilo"; break;
|
||||||
case StepBasic_spCenti :aName += "centi"; break;
|
case StepBasic_spCenti :aName += "centi"; break;
|
||||||
case StepBasic_spMilli :aName += "milli"; break;
|
case StepBasic_spMilli :aName += "milli"; break;
|
||||||
case StepBasic_spMicro :aName += "micro"; break;
|
case StepBasic_spMicro :aName += "micro"; break;
|
||||||
case StepBasic_spNano :aName += "nano"; break;
|
case StepBasic_spNano :aName += "nano"; break;
|
||||||
default: break;
|
default: break;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
switch(theName) {
|
switch(theUnit->Name()) {
|
||||||
case StepBasic_sunMetre : aName += "metre"; break;
|
case StepBasic_sunMetre : aName += "metre"; break;
|
||||||
case StepBasic_sunRadian : aName += "radian"; break;
|
case StepBasic_sunRadian : aName += "radian"; break;
|
||||||
case StepBasic_sunSteradian : aName += "steradian"; break;
|
case StepBasic_sunSteradian : aName += "steradian"; break;
|
||||||
@ -540,7 +541,7 @@ Standard_Boolean STEPControl_Reader::findUnits(
|
|||||||
continue;
|
continue;
|
||||||
anUnitFact = (!aSiUnit->HasPrefix() ?
|
anUnitFact = (!aSiUnit->HasPrefix() ?
|
||||||
1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix()));
|
1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix()));
|
||||||
aName = getSiName(aSiUnit->Name(), aSiUnit->Prefix());
|
aName = getSiName(aSiUnit);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
15
tests/bugs/step/bug23567
Executable file
15
tests/bugs/step/bug23567
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
puts "========================"
|
||||||
|
puts "OCC23567"
|
||||||
|
puts "========================"
|
||||||
|
puts ""
|
||||||
|
#######################################################################
|
||||||
|
# Wrong STEP unit is returned by STEPControl_Reader.FileUnits() function
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
set info [ stepfileunits [locate_data_file bug23567_a.step] ]
|
||||||
|
set index1 [lsearch $info metre]
|
||||||
|
|
||||||
|
puts ""
|
||||||
|
if { ${index1} == -1 } {
|
||||||
|
puts "Error : bad unit"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user