Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:05

0001 // Created on: 1996-01-18
0002 // Created by: Frederic MAUPAS
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _STEPConstruct_UnitContext_HeaderFile
0018 #define _STEPConstruct_UnitContext_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <Standard_CString.hxx>
0026 #include <StepBasic_SiPrefix.hxx>
0027 class StepData_Factors;
0028 class StepData_StepModel;
0029 class StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx;
0030 class StepRepr_GlobalUnitAssignedContext;
0031 class StepBasic_NamedUnit;
0032 class StepRepr_GlobalUncertaintyAssignedContext;
0033 class StepBasic_SiUnit;
0034 
0035 
0036 //! Tool for creation (encoding) and decoding (for writing and reading
0037 //! accordingly) context defining units and tolerances (uncerntanties)
0038 class STEPConstruct_UnitContext 
0039 {
0040 public:
0041 
0042   DEFINE_STANDARD_ALLOC
0043 
0044   
0045   //! Creates empty tool
0046   Standard_EXPORT STEPConstruct_UnitContext();
0047   
0048   //! Creates new context (units are MM and radians,
0049   //! uncertainty equal to Tol3d)
0050   Standard_EXPORT void Init (const Standard_Real Tol3d,
0051                              const Handle(StepData_StepModel)& theModel,
0052                              const StepData_Factors& theLocalFactors);
0053   
0054   //! Returns True if Init was called successfully
0055   Standard_EXPORT Standard_Boolean IsDone() const;
0056   
0057   //! Returns context (or Null if not done)
0058   Standard_EXPORT Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) Value() const;
0059   
0060   //! Computes the length, plane angle and solid angle conversion
0061   //! factor  .  Returns a status, 0 if OK
0062   Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepRepr_GlobalUnitAssignedContext)& aContext,
0063                                                    const StepData_Factors& theLocalFactors);
0064   
0065   Standard_EXPORT Standard_Integer ComputeFactors (const Handle(StepBasic_NamedUnit)& aUnit,
0066                                                    const StepData_Factors& theLocalFactors);
0067   
0068   //! Computes the uncertainty value (for length)
0069   Standard_EXPORT Standard_Integer ComputeTolerance (const Handle(StepRepr_GlobalUncertaintyAssignedContext)& aContext);
0070   
0071   //! Returns the lengthFactor
0072   Standard_EXPORT Standard_Real LengthFactor() const;
0073   
0074   //! Returns the planeAngleFactor
0075   Standard_EXPORT Standard_Real PlaneAngleFactor() const;
0076   
0077   //! Returns the solidAngleFactor
0078   Standard_EXPORT Standard_Real SolidAngleFactor() const;
0079   
0080   //! Returns the Uncertainty value (for length)
0081   //! It has been converted  with LengthFactor
0082   Standard_EXPORT Standard_Real Uncertainty() const;
0083   
0084   //! Returns the areaFactor
0085   Standard_EXPORT Standard_Real AreaFactor() const;
0086   
0087   //! Returns the volumeFactor
0088   Standard_EXPORT Standard_Real VolumeFactor() const;
0089   
0090   //! Tells if a Uncertainty (for length) is recorded
0091   Standard_EXPORT Standard_Boolean HasUncertainty() const;
0092   
0093   //! Returns true if ComputeFactors has calculated
0094   //! a LengthFactor
0095   Standard_EXPORT Standard_Boolean LengthDone() const;
0096   
0097   //! Returns true if ComputeFactors has calculated
0098   //! a PlaneAngleFactor
0099   Standard_EXPORT Standard_Boolean PlaneAngleDone() const;
0100   
0101   //! Returns true if ComputeFactors has calculated
0102   //! a SolidAngleFactor
0103   Standard_EXPORT Standard_Boolean SolidAngleDone() const;
0104   
0105   //! Returns true if areaFactor is computed
0106   Standard_EXPORT Standard_Boolean AreaDone() const;
0107   
0108   //! Returns true if volumeFactor is computed
0109   Standard_EXPORT Standard_Boolean VolumeDone() const;
0110   
0111   //! Returns a message for a given status (0 - empty)
0112   //! This message can then be added as warning for transfer
0113   Standard_EXPORT Standard_CString StatusMessage (const Standard_Integer status) const;
0114   
0115   //! Convert SI prefix defined by enumeration to corresponding
0116   //! real factor (e.g. 1e6 for mega)
0117   Standard_EXPORT static Standard_Real ConvertSiPrefix (const StepBasic_SiPrefix aPrefix);
0118 
0119 
0120 
0121 
0122 protected:
0123 
0124 
0125 
0126 
0127 
0128 private:
0129 
0130   
0131   //! Fills numerical equivalent of SiUnitName (in SI value)
0132   //! Returns False if name SiUnit Name not recognized
0133   Standard_EXPORT Standard_Boolean SiUnitNameFactor (const Handle(StepBasic_SiUnit)& aSiUnit, Standard_Real& val) const;
0134 
0135 
0136   Standard_Boolean done;
0137   Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) GRC;
0138   Standard_Real lengthFactor;
0139   Standard_Real planeAngleFactor;
0140   Standard_Real solidAngleFactor;
0141   Standard_Real theUncertainty;
0142   Standard_Real areaFactor;
0143   Standard_Real volumeFactor;
0144   Standard_Boolean areaDone;
0145   Standard_Boolean volumeDone;
0146   Standard_Boolean lengthDone;
0147   Standard_Boolean planeAngleDone;
0148   Standard_Boolean solidAngleDone;
0149   Standard_Boolean hasUncertainty;
0150 
0151 
0152 };
0153 
0154 
0155 
0156 
0157 
0158 
0159 
0160 #endif // _STEPConstruct_UnitContext_HeaderFile