1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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

@@ -42,6 +42,7 @@
#include <STEPConstruct_UnitContext.hxx>
#include <STEPControl_ActorRead.hxx>
#include <StepData_StepModel.hxx>
#include <StepData_GlobalFactors.hxx>
#include <StepDimTol_DatumFeature.hxx>
#include <StepDimTol_GeometricTolerance.hxx>
#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
@@ -1752,7 +1753,7 @@ void STEPControl_ActorRead::PrepareUnits(const Handle(StepRepr_Representation)&
Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode");
Standard_Real angleFactor = ( anglemode == 0 ? myUnit.PlaneAngleFactor() :
anglemode == 1 ? 1. : M_PI/180. );
UnitsMethods::InitializeFactors(myUnit.LengthFactor(),
StepData_GlobalFactors::Intance().InitializeFactors(myUnit.LengthFactor(),
angleFactor,
myUnit.SolidAngleFactor());
if (stat1 != 0) TP->AddWarning (theRepCont,myUnit.StatusMessage(stat1));
@@ -1787,7 +1788,7 @@ void STEPControl_ActorRead::PrepareUnits(const Handle(StepRepr_Representation)&
void STEPControl_ActorRead::ResetUnits ()
{
UnitsMethods::InitializeFactors ( 1, 1, 1 );
StepData_GlobalFactors::Intance().InitializeFactors ( 1, 1, 1 );
myPrecision = Interface_Static::RVal("read.precision.val");
myMaxTol = Max ( myPrecision, Interface_Static::RVal("read.maxprecision.val") );
}

View File

@@ -45,6 +45,7 @@
#include <STEPConstruct_UnitContext.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_StepModelType.hxx>
#include <StepData_GlobalFactors.hxx>
#include <StepData_StepModel.hxx>
#include <StepGeom_Axis2Placement3d.hxx>
#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
@@ -231,7 +232,7 @@ static Standard_Boolean IsManifoldShape(const TopoDS_Shape& theShape) {
STEPControl_ActorWrite::STEPControl_ActorWrite ()
: mygroup (0) , mytoler (-1.)
{
SetMode(STEPControl_ShellBasedSurfaceModel);
SetMode(STEPControl_ShellBasedSurfaceModel);
}
//=======================================================================
@@ -450,8 +451,6 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::Transfer (const Handle(Transfer_
const Handle(Transfer_FinderProcess)& FP,
const Message_ProgressRange& theProgress)
{
XSAlgo::AlgoContainer()->PrepareForTransfer();
Handle(TransferBRep_ShapeMapper) mapper = Handle(TransferBRep_ShapeMapper)::DownCast(start);
if (mapper.IsNull()) return NullResult();
@@ -462,12 +461,15 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::Transfer (const Handle(Transfer_
if ( ! model.IsNull() ) myContext.SetModel ( model ); //: abv 04.11.00: take APD from model
myContext.AddAPD ( Standard_False ); // update APD
myContext.SetLevel ( 1 ); // set assembly level to 1 (to ensure)
//:S4136: init UnitsMethods to reset angle unit factors (see TopoDSToStep)
Standard_Real lFactor = UnitsMethods::GetLengthFactorValue ( Interface_Static::IVal ( "write.step.unit" ) );
lFactor /= UnitsMethods::GetCasCadeLengthUnit();
if (!model->IsInitializedUnit())
{
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
model->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
Standard_Real aLFactor = model->WriteLengthUnit();
aLFactor /= model->LocalLengthUnit();
Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode");
UnitsMethods::InitializeFactors ( lFactor, ( anglemode <= 1 ? 1. : M_PI/180. ), 1. );
StepData_GlobalFactors::Intance().InitializeFactors (aLFactor, ( anglemode <= 1 ? 1. : M_PI/180. ), 1. );
// create SDR
STEPConstruct_Part SDRTool;

View File

@@ -442,6 +442,24 @@ void STEPControl_Reader::FileUnits( TColStd_SequenceOfAsciiString& theUnitLength
}
}
//=======================================================================
//function : SetSystemLengthUnit
//purpose :
//=======================================================================
void STEPControl_Reader::SetSystemLengthUnit(const Standard_Real theLengthUnit)
{
StepModel()->SetLocalLengthUnit(theLengthUnit);
}
//=======================================================================
//function : SystemLengthUnit
//purpose :
//=======================================================================
Standard_Real STEPControl_Reader::SystemLengthUnit() const
{
return StepModel()->LocalLengthUnit();
}
//=======================================================================
//function : getSiName
//purpose :

View File

@@ -100,7 +100,11 @@ public:
//! found in file
Standard_EXPORT void FileUnits (TColStd_SequenceOfAsciiString& theUnitLengthNames, TColStd_SequenceOfAsciiString& theUnitAngleNames, TColStd_SequenceOfAsciiString& theUnitSolidAngleNames);
//! Sets system length unit used by transfer process
Standard_EXPORT void SetSystemLengthUnit(const Standard_Real theLengthUnit);
//! Returns system length unit used by transfer process
Standard_EXPORT Standard_Real SystemLengthUnit() const;
protected:

View File

@@ -21,8 +21,11 @@
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
#include <Transfer_FinderProcess.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_TransferWriter.hxx>
#include <XSControl_WorkSession.hxx>
#include <UnitsMethods.hxx>
//=======================================================================
//function : STEPControl_Writer
@@ -136,7 +139,11 @@ IFSelect_ReturnStatus STEPControl_Writer::Transfer
}
if (mws < 0) return IFSelect_RetError; // cas non reconnu
thesession->TransferWriter()->SetTransferMode (mws);
if (!Model()->IsInitializedUnit())
{
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
Model()->SetLocalLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
}
return thesession->TransferWriteShape(sh, compgraph, theProgress);
}