mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-13 14:27:08 +03:00
0033351: Data Exchange, Step - Improvement for thread safety of the STEP translator
Local StepData_Factors object usage for each session Static variables isolated
This commit is contained in:
@@ -82,6 +82,15 @@ void STEPConstruct_ContextTool::SetModel (const Handle(StepData_StepModel)& aSte
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetGlobalFactor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void STEPConstruct_ContextTool::SetGlobalFactor(const StepData_Factors& theGlobalFactor)
|
||||
{
|
||||
myGlobalFactor = theGlobalFactor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetAPD
|
||||
//purpose :
|
||||
@@ -445,7 +454,7 @@ void STEPConstruct_ContextTool::SetSDR (const Handle(StepShape_ShapeDefinitionRe
|
||||
Handle(StepGeom_Axis2Placement3d) STEPConstruct_ContextTool::GetDefaultAxis ()
|
||||
{
|
||||
if ( myAxis.IsNull() ) {
|
||||
GeomToStep_MakeAxis2Placement3d mkax;
|
||||
GeomToStep_MakeAxis2Placement3d mkax(myGlobalFactor);
|
||||
myAxis = mkax.Value();
|
||||
}
|
||||
return myAxis;
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <STEPConstruct_AP203Context.hxx>
|
||||
#include <StepData_Factors.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
class StepBasic_ApplicationProtocolDefinition;
|
||||
@@ -54,6 +55,8 @@ public:
|
||||
//! Initialize ApplicationProtocolDefinition by the first
|
||||
//! entity of that type found in the model
|
||||
Standard_EXPORT void SetModel (const Handle(StepData_StepModel)& aStepModel);
|
||||
|
||||
Standard_EXPORT void SetGlobalFactor(const StepData_Factors& theGlobalFactor);
|
||||
|
||||
Standard_EXPORT Handle(StepBasic_ApplicationProtocolDefinition) GetAPD();
|
||||
|
||||
@@ -139,7 +142,7 @@ private:
|
||||
Handle(StepBasic_ApplicationProtocolDefinition) theAPD;
|
||||
STEPConstruct_AP203Context theAP203;
|
||||
Handle(StepGeom_Axis2Placement3d) myAxis;
|
||||
|
||||
StepData_Factors myGlobalFactor;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -33,8 +33,8 @@
|
||||
#include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
|
||||
#include <StepBasic_SiUnitAndSolidAngleUnit.hxx>
|
||||
#include <StepBasic_SiUnitAndVolumeUnit.hxx>
|
||||
#include <StepData_GlobalFactors.hxx>
|
||||
#include <STEPConstruct_UnitContext.hxx>
|
||||
#include <StepData_Factors.hxx>
|
||||
#include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
|
||||
#include <StepRepr_GlobalUncertaintyAssignedContext.hxx>
|
||||
#include <StepRepr_GlobalUnitAssignedContext.hxx>
|
||||
@@ -63,7 +63,8 @@ STEPConstruct_UnitContext::STEPConstruct_UnitContext()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d)
|
||||
void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d,
|
||||
const StepData_Factors& theLocalFactors)
|
||||
{
|
||||
done = Standard_True;
|
||||
|
||||
@@ -155,7 +156,7 @@ void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d)
|
||||
|
||||
Handle(StepBasic_MeasureValueMember) mvs = new StepBasic_MeasureValueMember;
|
||||
mvs->SetName("LENGTH_MEASURE");
|
||||
mvs->SetReal ( Tol3d / StepData_GlobalFactors::Intance().LengthFactor() );
|
||||
mvs->SetReal ( Tol3d / theLocalFactors.LengthFactor() );
|
||||
StepBasic_Unit Unit;
|
||||
Unit.SetValue ( lengthUnit );
|
||||
theTol3d->Init(mvs, Unit, TolName, TolDesc);
|
||||
@@ -242,7 +243,8 @@ Standard_Boolean STEPConstruct_UnitContext::SiUnitNameFactor(const Handle(StepBa
|
||||
// Purpose :
|
||||
// ==========================================================================
|
||||
|
||||
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr_GlobalUnitAssignedContext)& aContext)
|
||||
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr_GlobalUnitAssignedContext)& aContext,
|
||||
const StepData_Factors& theLocalFactors)
|
||||
{
|
||||
Standard_Integer status = 0;
|
||||
|
||||
@@ -268,7 +270,7 @@ Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr
|
||||
|
||||
for (Standard_Integer i = 1; i <= nbU; i++) {
|
||||
Handle(StepBasic_NamedUnit) theNamedUnit = aContext->UnitsValue(i);
|
||||
status = ComputeFactors(theNamedUnit);
|
||||
status = ComputeFactors(theNamedUnit, theLocalFactors);
|
||||
#ifdef OCCT_DEBUG
|
||||
if(status == -1)
|
||||
std::cout << " -- STEPConstruct_UnitContext:ComputeFactor: Unit item no." << i << " is not recognized" << std::endl;
|
||||
@@ -278,7 +280,8 @@ Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepRepr
|
||||
}
|
||||
|
||||
|
||||
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasic_NamedUnit)& aUnit)
|
||||
Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasic_NamedUnit)& aUnit,
|
||||
const StepData_Factors& theLocalFactors)
|
||||
{
|
||||
|
||||
//:f3 abv 8 Apr 98: ProSTEP TR8 tr8_as_sd_sw: the case of unrecognized entity
|
||||
@@ -379,7 +382,7 @@ Standard_Integer STEPConstruct_UnitContext::ComputeFactors(const Handle(StepBasi
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Standard_Real aCascadeUnit = StepData_GlobalFactors::Intance().CascadeUnit();
|
||||
const Standard_Real aCascadeUnit = theLocalFactors.CascadeUnit();
|
||||
if (aUnit->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndLengthUnit))||
|
||||
aUnit->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
|
||||
#ifdef METER
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <StepBasic_SiPrefix.hxx>
|
||||
class StepData_Factors;
|
||||
class StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx;
|
||||
class StepRepr_GlobalUnitAssignedContext;
|
||||
class StepBasic_NamedUnit;
|
||||
@@ -45,7 +46,8 @@ public:
|
||||
|
||||
//! Creates new context (units are MM and radians,
|
||||
//! uncertainty equal to Tol3d)
|
||||
Standard_EXPORT void Init (const Standard_Real Tol3d);
|
||||
Standard_EXPORT void Init (const Standard_Real Tol3d,
|
||||
const StepData_Factors& theLocalFactors);
|
||||
|
||||
//! Returns True if Init was called successfully
|
||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||
@@ -55,9 +57,11 @@ public:
|
||||
|
||||
//! Computes the length, plane angle and solid angle conversion
|
||||
//! factor . Returns a status, 0 if OK
|
||||
Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepRepr_GlobalUnitAssignedContext)& aContext);
|
||||
Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepRepr_GlobalUnitAssignedContext)& aContext,
|
||||
const StepData_Factors& theLocalFactors);
|
||||
|
||||
Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepBasic_NamedUnit)& aUnit);
|
||||
Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepBasic_NamedUnit)& aUnit,
|
||||
const StepData_Factors& theLocalFactors);
|
||||
|
||||
//! Computes the uncertainty value (for length)
|
||||
Standard_EXPORT Standard_Integer ComputeTolerance (const Handle(StepRepr_GlobalUncertaintyAssignedContext)& aContext);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include <StepBasic_SiUnitAndLengthUnit.hxx>
|
||||
#include <STEPConstruct_UnitContext.hxx>
|
||||
#include <STEPConstruct_ValidationProps.hxx>
|
||||
#include <StepData_Factors.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
#include <StepGeom_CartesianPoint.hxx>
|
||||
#include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
|
||||
@@ -623,7 +624,9 @@ TopoDS_Shape STEPConstruct_ValidationProps::GetPropShape (const Handle(StepRepr_
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean STEPConstruct_ValidationProps::GetPropReal (const Handle(StepRepr_RepresentationItem) &item,
|
||||
Standard_Real &Val, Standard_Boolean &isArea) const
|
||||
Standard_Real &Val,
|
||||
Standard_Boolean &isArea,
|
||||
const StepData_Factors& theLocalFactors) const
|
||||
{
|
||||
// decode volume & area
|
||||
if ( ! item->IsKind(STANDARD_TYPE(StepRepr_MeasureRepresentationItem)) )
|
||||
@@ -644,7 +647,7 @@ Standard_Boolean STEPConstruct_ValidationProps::GetPropReal (const Handle(StepRe
|
||||
Standard_Real exp = DUE->Exponent();
|
||||
Handle(StepBasic_NamedUnit) NU = DUE->Unit();
|
||||
STEPConstruct_UnitContext unit;
|
||||
unit.ComputeFactors(NU);
|
||||
unit.ComputeFactors(NU, theLocalFactors);
|
||||
if(unit.LengthDone()) {
|
||||
Standard_Real lengthFactor = unit.LengthFactor();
|
||||
scale *= pow(lengthFactor,exp);
|
||||
@@ -655,7 +658,7 @@ Standard_Boolean STEPConstruct_ValidationProps::GetPropReal (const Handle(StepRe
|
||||
Handle(StepBasic_NamedUnit) NU = Unit.NamedUnit();
|
||||
if(!NU.IsNull()) {
|
||||
STEPConstruct_UnitContext unit;
|
||||
unit.ComputeFactors(NU);
|
||||
unit.ComputeFactors(NU, theLocalFactors);
|
||||
if(unit.AreaDone())
|
||||
scale = unit.AreaFactor();
|
||||
if(unit.VolumeDone())
|
||||
@@ -682,8 +685,9 @@ Standard_Boolean STEPConstruct_ValidationProps::GetPropReal (const Handle(StepRe
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean STEPConstruct_ValidationProps::GetPropPnt (const Handle(StepRepr_RepresentationItem) &item,
|
||||
const Handle(StepRepr_RepresentationContext) &Context,
|
||||
gp_Pnt &Pnt) const
|
||||
const Handle(StepRepr_RepresentationContext) &Context,
|
||||
gp_Pnt &Pnt,
|
||||
const StepData_Factors& theLocalFactors) const
|
||||
{
|
||||
// centroid
|
||||
if ( ! item->IsKind(STANDARD_TYPE(StepGeom_CartesianPoint)) )
|
||||
@@ -713,7 +717,7 @@ Standard_Boolean STEPConstruct_ValidationProps::GetPropPnt (const Handle(StepRep
|
||||
}
|
||||
if ( ! theGUAC.IsNull() ) {
|
||||
STEPConstruct_UnitContext UnitTool;
|
||||
UnitTool.ComputeFactors(theGUAC);
|
||||
UnitTool.ComputeFactors(theGUAC, theLocalFactors);
|
||||
gp_Pnt zero(0,0,0);
|
||||
pos.Scale ( zero, UnitTool.LengthFactor() );
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <Standard_CString.hxx>
|
||||
#include <TColStd_SequenceOfTransient.hxx>
|
||||
class StepBasic_ProductDefinition;
|
||||
class StepData_Factors;
|
||||
class XSControl_WorkSession;
|
||||
class TopoDS_Shape;
|
||||
class StepRepr_RepresentationItem;
|
||||
@@ -111,10 +112,16 @@ public:
|
||||
//! If Property is neither Area nor Volume, returns False
|
||||
//! Else returns True and isArea indicates whether property
|
||||
//! is area or volume
|
||||
Standard_EXPORT Standard_Boolean GetPropReal (const Handle(StepRepr_RepresentationItem)& item, Standard_Real& Val, Standard_Boolean& isArea) const;
|
||||
Standard_EXPORT Standard_Boolean GetPropReal (const Handle(StepRepr_RepresentationItem)& item,
|
||||
Standard_Real& Val,
|
||||
Standard_Boolean& isArea,
|
||||
const StepData_Factors& theLocalFactors) const;
|
||||
|
||||
//! Returns value of Centriod property (or False if it is not)
|
||||
Standard_EXPORT Standard_Boolean GetPropPnt (const Handle(StepRepr_RepresentationItem)& item, const Handle(StepRepr_RepresentationContext)& Context, gp_Pnt& Pnt) const;
|
||||
Standard_EXPORT Standard_Boolean GetPropPnt (const Handle(StepRepr_RepresentationItem)& item,
|
||||
const Handle(StepRepr_RepresentationContext)& Context,
|
||||
gp_Pnt& Pnt,
|
||||
const StepData_Factors& theLocalFactors) const;
|
||||
|
||||
//! Sets current assembly shape SDR (for FindCDSR calls)
|
||||
Standard_EXPORT void SetAssemblyShape (const TopoDS_Shape& shape);
|
||||
|
Reference in New Issue
Block a user