1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031382: Data Exchange - BinXCAF should preserve length unit information

Possibility for adding LengthUnit info to XCAF document using special class XCAFDoc_LenghtUnit and XCAFDoc_LenghtUnitTool is implemented.
Package UnitsMethods is split: geom methods were placed to new file GeomConvert_Units which is in the toolkit TKXSBase, internal step scale factors was placed to StepData.
Updated UnitMethods to convert scale factor to different unit types.
Now, XSAlgo::XSAlgo_AlgoContainer is used to update unit info from static interface values.
New Draw command "XSetLengthUnit" and "XGetLengthUnit" for set or get XDE attribute.
Upgraded tests for STEP, IGES, OBJ, glTF, VRML formats to check area regressing with used unit.
Upgraded tests\de test cases to use any units in the "loop back" algorithms.
This commit is contained in:
dpasukhi
2020-11-10 07:52:30 +03:00
committed by bugmaster
parent 9592ae247b
commit da80ff68f1
106 changed files with 2258 additions and 662 deletions

View File

@@ -34,7 +34,6 @@
#include <Interface_Static.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <UnitsMethods.hxx>
IGESData_BasicEditor::IGESData_BasicEditor(const Handle(IGESData_Protocol)& protocol)
{
@@ -92,7 +91,7 @@ void IGESData_BasicEditor::Init (const Handle(IGESData_IGESModel)& model, const
(const Standard_Real val)
{
if (val <= 0.) return Standard_False;
Standard_Real vmm = val * UnitsMethods::GetCasCadeLengthUnit(); //abv 20 Feb 00: adding cascade unit factor
Standard_Real vmm = val * themodel->GlobalSection().CascadeUnit();
//#73 rln 10.03.99 S4135: "read.scale.unit" does not affect GlobalSection
//if (Interface_Static::IVal("read.scale.unit") == 1) vmm = vmm * 1000.;
// vmm est exprime en MILLIMETRES
@@ -358,20 +357,19 @@ Standard_Integer IGESData_BasicEditor::UnitNameFlag (const Standard_CString nam
Standard_Real IGESData_BasicEditor::UnitFlagValue (const Standard_Integer flag)
{
switch (flag) {
case 1 : return 0.0254;
case 2 : return 0.001;
case 3 : return 1.;
case 4 : return 0.3048;
case 5 : return 1609.27;
case 6 : return 1.;
case 7 : return 1000.;
case 8 : return 0.0000254;
case 9 : return 0.000001;
case 10 : return 0.01;
case 11 : return 0.0000000254;
default : break;
case 1: return 25.4; // inch
case 2: return 1.; // millimeter
case 3: return 1.;
case 4: return 304.8; // foot
case 5: return 1609344.; // mile
case 6: return 1000.; // meter
case 7: return 1000000.; // kilometer
case 8: return 0.0254; // mil (0.001 inch)
case 9: return 0.001; // micron
case 10: return 10.; // centimeter
case 11: return 0.0000254; // microinch
default: return 0.;
}
return 0.;
}
Standard_CString IGESData_BasicEditor::UnitFlagName (const Standard_Integer flag)

View File

@@ -26,6 +26,8 @@
#include <OSD_Process.hxx>
#include <Quantity_Date.hxx>
#include <TCollection_HAsciiString.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <UnitsMethods.hxx>
#include <stdio.h>
@@ -66,6 +68,7 @@ IGESData_GlobalSection::IGESData_GlobalSection()
theMaxPower10Double (308),
theMaxDigitsDouble (15),
theScale (1.0),
theCascadeUnit (1.0),
theUnitFlag (0),
theLineWeightGrad (1),
theMaxLineWeight (0.0),
@@ -115,7 +118,7 @@ void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params,
//Message_Msg Msg48 ("XSTEP_48");
//Message_Msg Msg49 ("XSTEP_49");
//======================================
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
theSeparator = ','; theEndMark = ';';
theSendName.Nullify(); theFileName.Nullify(); theSystemId.Nullify();
theInterfaceVersion.Nullify();
@@ -131,6 +134,7 @@ void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params,
theAuthorName.Nullify(); theCompanyName.Nullify();
theIGESVersion = 11;//3 //#66 rln Setting IGES 5.3 by default(To avoid misleading fails below)
theDraftingStandard = 0;
theCascadeUnit = UnitsMethods::GetCasCadeLengthUnit();
theLastChangeDate.Nullify(); // nouveaute 5.1 (peut etre absente)
theAppliProtocol.Nullify(); // nouveaute 5.3 (peut etre absente)
@@ -528,6 +532,15 @@ Standard_Real IGESData_GlobalSection::Scale () const
}
//=======================================================================
//function : CascadeUnit
//purpose :
//=======================================================================
Standard_Real IGESData_GlobalSection::CascadeUnit() const
{
return theCascadeUnit;
}
//=======================================================================
//function : UnitFlag
//purpose :
@@ -802,8 +815,7 @@ Handle(TCollection_HAsciiString) IGESData_GlobalSection::NewDateString
Standard_Real IGESData_GlobalSection::UnitValue () const
{
return UnitsMethods::GetLengthFactorValue ( theUnitFlag ) /
UnitsMethods::GetCasCadeLengthUnit(); //abv 22 Feb 00: adding cascade unit factor
return IGESData_BasicEditor::UnitFlagValue(theUnitFlag) / theCascadeUnit;
}
@@ -848,6 +860,9 @@ Standard_Real IGESData_GlobalSection::UnitValue () const
void IGESData_GlobalSection::SetScale (const Standard_Real val)
{ theScale = val; }
void IGESData_GlobalSection::SetCascadeUnit (const Standard_Real theUnit)
{ theCascadeUnit = theUnit; }
void IGESData_GlobalSection::SetUnitFlag (const Standard_Integer val)
{ theUnitFlag = val; }

View File

@@ -105,6 +105,9 @@ public:
//! Returns the scale used in the IGES file.
Standard_EXPORT Standard_Real Scale() const;
//! Returns the system length unit
Standard_EXPORT Standard_Real CascadeUnit() const;
//! Returns the unit flag that was used to write the IGES file.
Standard_EXPORT Standard_Integer UnitFlag() const;
@@ -203,6 +206,8 @@ public:
Standard_EXPORT void SetReceiveName (const Handle(TCollection_HAsciiString)& val);
Standard_EXPORT void SetCascadeUnit(const Standard_Real theUnit);
Standard_EXPORT void SetScale (const Standard_Real val);
Standard_EXPORT void SetUnitFlag (const Standard_Integer val);
@@ -250,6 +255,7 @@ private:
Standard_Integer theMaxDigitsDouble;
Handle(TCollection_HAsciiString) theReceiveName;
Standard_Real theScale;
Standard_Real theCascadeUnit;
Standard_Integer theUnitFlag;
Handle(TCollection_HAsciiString) theUnitName;
Standard_Integer theLineWeightGrad;

View File

@@ -230,17 +230,6 @@ void IGESData_IGESModel::AddStartLine
else thestart->InsertBefore (atnum,new TCollection_HAsciiString(line));
}
//=======================================================================
//function : GlobalSection
//purpose :
//=======================================================================
const IGESData_GlobalSection& IGESData_IGESModel::GlobalSection () const
{ return theheader; }
//=======================================================================
//function : SetGlobalSection
//purpose :

View File

@@ -92,7 +92,10 @@ public:
Standard_EXPORT void AddStartLine (const Standard_CString line, const Standard_Integer atnum = 0);
//! Returns the Global section of the IGES file.
Standard_EXPORT const IGESData_GlobalSection& GlobalSection() const;
const IGESData_GlobalSection& GlobalSection() const { return theheader; }
//! Returns the Global section of the IGES file.
IGESData_GlobalSection& ChangeGlobalSection() { return theheader; }
//! Sets the Global section of the IGES file.
Standard_EXPORT void SetGlobalSection (const IGESData_GlobalSection& header);