Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:20:23

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 <StepData_Factors.hxx>
0027 #include <StepBasic_SiPrefix.hxx>
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 //! Tool for creation (encoding) and decoding (for writing and reading
0036 //! accordingly) context defining units and tolerances (uncerntanties)
0037 class STEPConstruct_UnitContext
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   //! Creates empty tool
0043   Standard_EXPORT STEPConstruct_UnitContext();
0044 
0045   //! Creates new context (units are MM and radians,
0046   //! uncertainty equal to Tol3d)
0047   Standard_EXPORT void Init(const double                           Tol3d,
0048                             const occ::handle<StepData_StepModel>& theModel,
0049                             const StepData_Factors& theLocalFactors = StepData_Factors());
0050 
0051   //! Returns True if Init was called successfully
0052   Standard_EXPORT bool IsDone() const;
0053 
0054   //! Returns context (or Null if not done)
0055   Standard_EXPORT occ::handle<StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx>
0056                   Value() const;
0057 
0058   //! Computes the length, plane angle and solid angle conversion factor.
0059   //! Returns a status, 0 if OK
0060   Standard_EXPORT int ComputeFactors(
0061     const occ::handle<StepRepr_GlobalUnitAssignedContext>& aContext,
0062     const StepData_Factors&                                theLocalFactors = StepData_Factors());
0063 
0064   Standard_EXPORT int ComputeFactors(const occ::handle<StepBasic_NamedUnit>& aUnit,
0065                                      const StepData_Factors& theLocalFactors = StepData_Factors());
0066 
0067   //! Computes the uncertainty value (for length)
0068   Standard_EXPORT int ComputeTolerance(
0069     const occ::handle<StepRepr_GlobalUncertaintyAssignedContext>& aContext);
0070 
0071   //! Returns the lengthFactor
0072   Standard_EXPORT double LengthFactor() const;
0073 
0074   //! Returns the planeAngleFactor
0075   Standard_EXPORT double PlaneAngleFactor() const;
0076 
0077   //! Returns the solidAngleFactor
0078   Standard_EXPORT double SolidAngleFactor() const;
0079 
0080   //! Returns the Uncertainty value (for length)
0081   //! It has been converted with LengthFactor
0082   Standard_EXPORT double Uncertainty() const;
0083 
0084   //! Returns the areaFactor
0085   Standard_EXPORT double AreaFactor() const;
0086 
0087   //! Returns the volumeFactor
0088   Standard_EXPORT double VolumeFactor() const;
0089 
0090   //! Tells if a Uncertainty (for length) is recorded
0091   Standard_EXPORT bool HasUncertainty() const;
0092 
0093   //! Returns true if ComputeFactors has calculated
0094   //! a LengthFactor
0095   Standard_EXPORT bool LengthDone() const;
0096 
0097   //! Returns true if ComputeFactors has calculated
0098   //! a PlaneAngleFactor
0099   Standard_EXPORT bool PlaneAngleDone() const;
0100 
0101   //! Returns true if ComputeFactors has calculated
0102   //! a SolidAngleFactor
0103   Standard_EXPORT bool SolidAngleDone() const;
0104 
0105   //! Returns true if areaFactor is computed
0106   Standard_EXPORT bool AreaDone() const;
0107 
0108   //! Returns true if volumeFactor is computed
0109   Standard_EXPORT bool 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 const char* StatusMessage(const int status) const;
0114 
0115   //! Convert SI prefix defined by enumeration to corresponding
0116   //! real factor (e.g. 1e6 for mega)
0117   Standard_EXPORT static double ConvertSiPrefix(const StepBasic_SiPrefix aPrefix);
0118 
0119 private:
0120   //! Fills numerical equivalent of SiUnitName (in SI value)
0121   //! Returns False if name SiUnit Name not recognized
0122   Standard_EXPORT bool SiUnitNameFactor(const occ::handle<StepBasic_SiUnit>& aSiUnit,
0123                                         double&                              val) const;
0124 
0125   bool                                                                          done;
0126   occ::handle<StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx> GRC;
0127   double                                                                        lengthFactor;
0128   double                                                                        planeAngleFactor;
0129   double                                                                        solidAngleFactor;
0130   double                                                                        theUncertainty;
0131   double                                                                        areaFactor;
0132   double                                                                        volumeFactor;
0133   bool                                                                          areaDone;
0134   bool                                                                          volumeDone;
0135   bool                                                                          lengthDone;
0136   bool                                                                          planeAngleDone;
0137   bool                                                                          solidAngleDone;
0138   bool                                                                          hasUncertainty;
0139 };
0140 
0141 #endif // _STEPConstruct_UnitContext_HeaderFile