Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 // Created on: 2015-08-06
0003 // Created by: Ilya Novikov
0004 // Copyright (c) 2004-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 
0018 #ifndef _XCAFDimTolObjects_DimensionObject_HeaderFile
0019 #define _XCAFDimTolObjects_DimensionObject_HeaderFile
0020 
0021 #include <Standard.hxx>
0022 #include <Standard_Type.hxx>
0023 
0024 #include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
0025 #include <XCAFDimTolObjects_DimensionType.hxx>
0026 #include <TColStd_HArray1OfReal.hxx>
0027 #include <XCAFDimTolObjects_DimensionQualifier.hxx>
0028 #include <XCAFDimTolObjects_DimensionFormVariance.hxx>
0029 #include <XCAFDimTolObjects_DimensionGrade.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
0032 #include <TopoDS_Edge.hxx>
0033 #include <gp_Dir.hxx>
0034 #include <gp_Ax2.hxx>
0035 #include <TColgp_HArray1OfPnt.hxx>
0036 #include <Standard_Transient.hxx>
0037 #include <Standard_Real.hxx>
0038 #include <XCAFDimTolObjects_DimensionModif.hxx>
0039 #include <TCollection_HAsciiString.hxx>
0040 #include <NCollection_Vector.hxx>
0041 #include <XCAFDimTolObjects_AngularQualifier.hxx>
0042 
0043 class XCAFDimTolObjects_DimensionObject;
0044 DEFINE_STANDARD_HANDLE(XCAFDimTolObjects_DimensionObject, Standard_Transient)
0045                             
0046 //! Access object to store dimension data
0047 class XCAFDimTolObjects_DimensionObject : public Standard_Transient
0048 {
0049 
0050 public:
0051   
0052   Standard_EXPORT XCAFDimTolObjects_DimensionObject();
0053   
0054   Standard_EXPORT XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj);
0055   
0056   //! Returns semantic name
0057   Standard_EXPORT Handle(TCollection_HAsciiString) GetSemanticName() const;
0058 
0059   //! Sets semantic name
0060   Standard_EXPORT void SetSemanticName(const Handle(TCollection_HAsciiString)& theName);
0061 
0062   //! Sets dimension qualifier as min., max. or average.
0063   Standard_EXPORT void SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier);
0064   
0065   //! Returns dimension qualifier.
0066   Standard_EXPORT XCAFDimTolObjects_DimensionQualifier GetQualifier() const;
0067   
0068   //! Returns True if the object has dimension qualifier.
0069   Standard_EXPORT Standard_Boolean HasQualifier() const;
0070 
0071   //! Sets angular qualifier as small, large or equal.
0072   Standard_EXPORT void SetAngularQualifier(const XCAFDimTolObjects_AngularQualifier theAngularQualifier);
0073 
0074   //! Returns angular qualifier.
0075   Standard_EXPORT XCAFDimTolObjects_AngularQualifier GetAngularQualifier() const;
0076 
0077   //! Returns True if the object has angular qualifier.
0078   Standard_EXPORT Standard_Boolean HasAngularQualifier() const;
0079   
0080   //! Sets a specific type of dimension.
0081   Standard_EXPORT void SetType (const XCAFDimTolObjects_DimensionType theTyupe);
0082   
0083   //! Returns dimension type.
0084   Standard_EXPORT XCAFDimTolObjects_DimensionType GetType() const;
0085   
0086   //! Returns the main dimension value.
0087   //! It will be the middle value in case of range dimension.
0088   Standard_EXPORT Standard_Real GetValue() const;
0089   
0090   //! Returns raw array of dimension values
0091   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetValues() const;
0092   
0093   //! Sets the main dimension value.
0094   //! Overwrites previous values.
0095   Standard_EXPORT void SetValue (const Standard_Real theValue);
0096   
0097   //! Replaces current raw array of dimension values with theValues array.
0098   Standard_EXPORT void SetValues (const Handle(TColStd_HArray1OfReal)& theValue);
0099   
0100   //! Returns True if the dimension is of range kind.
0101   //! Dimension is of range kind if its values array contains two elements
0102   //! defining lower and upper bounds.
0103   Standard_EXPORT Standard_Boolean IsDimWithRange() const;
0104   
0105   //! Sets the upper bound of the range dimension, otherwise
0106   //! resets it to an empty range with the specified upper bound.
0107   Standard_EXPORT void SetUpperBound (const Standard_Real theUpperBound);
0108   
0109   //! Sets the lower bound of the range dimension, otherwise
0110   //! resets it to an empty range with the specified lower bound.
0111   Standard_EXPORT void SetLowerBound(const Standard_Real theLowerBound);
0112   
0113   //! Returns the upper bound of the range dimension, otherwise - zero.
0114   Standard_EXPORT Standard_Real GetUpperBound() const;
0115   
0116   //! Returns the lower bound of the range dimension, otherwise - zero.
0117   Standard_EXPORT Standard_Real GetLowerBound() const;
0118   
0119   //! Returns True if the dimension is of +/- tolerance kind.
0120   //! Dimension is of +/- tolerance kind if its values array contains three elements
0121   //! defining the main value and the lower/upper tolerances.
0122   Standard_EXPORT Standard_Boolean IsDimWithPlusMinusTolerance() const;
0123   
0124   //! Sets the upper value of the toleranced dimension, otherwise
0125   //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
0126   //! Returns False in case of range dimension.
0127   Standard_EXPORT Standard_Boolean SetUpperTolValue(const Standard_Real theUperTolValue);
0128   
0129   //! Sets the lower value of the toleranced dimension, otherwise
0130   //! resets a simple dimension to toleranced one with the specified lower/upper tolerances.
0131   //! Returns False in case of range dimension.
0132   Standard_EXPORT Standard_Boolean SetLowerTolValue(const Standard_Real theLowerTolValue);
0133   
0134   //! Returns the lower value of the toleranced dimension, otherwise - zero.
0135   Standard_EXPORT Standard_Real GetUpperTolValue() const;
0136   
0137   //! Returns the upper value of the toleranced dimension, otherwise - zero.
0138   Standard_EXPORT Standard_Real GetLowerTolValue() const;
0139   
0140   //! Returns True if the form variance was set to not XCAFDimTolObjects_DimensionFormVariance_None value.
0141   Standard_EXPORT Standard_Boolean IsDimWithClassOfTolerance() const;
0142   
0143   //! Sets tolerance class of the dimension.
0144   //! \param theHole - True if the tolerance applies to an internal feature
0145   //! \param theFormVariance - represents the fundamental deviation or "position letter"
0146   //!                          of the ISO 286 limits-and-fits tolerance classification.
0147   //! \param theGrade - represents the quality or the accuracy grade of a tolerance.
0148   Standard_EXPORT void SetClassOfTolerance (const Standard_Boolean theHole, 
0149                                             const XCAFDimTolObjects_DimensionFormVariance theFormVariance, 
0150                                             const XCAFDimTolObjects_DimensionGrade theGrade);
0151   
0152   //! Retrieves tolerance class parameters of the dimension.
0153   //! Returns True if the dimension is toleranced.
0154   Standard_EXPORT Standard_Boolean GetClassOfTolerance (Standard_Boolean& theHole, 
0155                                                         XCAFDimTolObjects_DimensionFormVariance& theFormVariance, 
0156                                                         XCAFDimTolObjects_DimensionGrade& theGrade) const;
0157   
0158   //! Sets the number of places to the left and right of the decimal point respectively.
0159   Standard_EXPORT void SetNbOfDecimalPlaces (const Standard_Integer theL, const Standard_Integer theR);
0160   
0161   //! Returns the number of places to the left and right of the decimal point respectively.
0162   Standard_EXPORT void GetNbOfDecimalPlaces(Standard_Integer& theL, Standard_Integer& theR) const;
0163   
0164   //! Returns a sequence of modifiers of the dimension.
0165   Standard_EXPORT XCAFDimTolObjects_DimensionModifiersSequence GetModifiers() const;
0166   
0167   //! Sets new sequence of dimension modifiers.
0168   Standard_EXPORT void SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers);
0169   
0170   //! Adds a modifier to the dimension sequence of modifiers.
0171   Standard_EXPORT void AddModifier (const XCAFDimTolObjects_DimensionModif theModifier);
0172   
0173   //! Returns a 'curve' along which the dimension is measured.
0174   Standard_EXPORT TopoDS_Edge GetPath() const;
0175   
0176   //! Sets a 'curve' along which the dimension is measured.
0177   Standard_EXPORT void SetPath (const TopoDS_Edge& thePath);
0178   
0179   //! Returns the orientation of the dimension in annotation plane.
0180   Standard_EXPORT Standard_Boolean GetDirection (gp_Dir& theDir) const;
0181   
0182   //! Sets an orientation of the dimension in annotation plane.
0183   Standard_EXPORT Standard_Boolean SetDirection (const gp_Dir& theDir);
0184   
0185   //! Sets position of the dimension text.
0186   void SetPointTextAttach (const gp_Pnt& thePntText)
0187   {
0188     myPntText = thePntText;
0189     myHasPntText = Standard_True;
0190   }
0191 
0192   //! Returns position of the dimension text.
0193   const gp_Pnt& GetPointTextAttach() const { return myPntText; }
0194 
0195   //! Returns True if the position of dimension text is specified.
0196   Standard_Boolean HasTextPoint() const 
0197   { 
0198     return myHasPntText; 
0199   }
0200 
0201   //! Sets annotation plane.
0202   void SetPlane (const gp_Ax2& thePlane)
0203   {
0204     myPlane    = thePlane;
0205     myHasPlane = Standard_True;
0206   }
0207 
0208   //! Returns annotation plane.
0209   const gp_Ax2& GetPlane() const { return myPlane; }
0210 
0211   //! Returns True if the object has annotation plane.
0212   Standard_Boolean HasPlane() const { return myHasPlane; }
0213 
0214   //! Returns true, if connection point exists (for dimesional_size),
0215   //! if connection point for the first shape exists (for dimensional_location).
0216   Standard_Boolean HasPoint() const { return myHasPoint1; }
0217 
0218   // Returns true, if connection point for the second shape exists (for dimensional_location only).
0219   Standard_Boolean HasPoint2() const { return myHasPoint2; }
0220 
0221   //! Set connection point (for dimesional_size),
0222   //! Set connection point for the first shape (for dimensional_location).
0223   void SetPoint(const gp_Pnt& thePnt) {
0224     myPnt1 = thePnt;
0225     myHasPoint1 = Standard_True;
0226   }
0227 
0228   // Set connection point for the second shape (for dimensional_location only).
0229   void SetPoint2(const gp_Pnt& thePnt) {
0230     myPnt2 = thePnt;
0231     myHasPoint2 = Standard_True;
0232   }
0233 
0234   //! Get connection point (for dimesional_size),
0235   //! Get connection point for the first shape (for dimensional_location).
0236   gp_Pnt GetPoint() const {
0237     return myPnt1;
0238   }
0239 
0240   // Get connection point for the second shape (for dimensional_location only).
0241   gp_Pnt GetPoint2() const {
0242     return myPnt2;
0243   }
0244 
0245   //! Set graphical presentation for the object.
0246   void SetPresentation(const TopoDS_Shape& thePresentation, 
0247     const Handle(TCollection_HAsciiString)& thePresentationName)
0248   {
0249     myPresentation = thePresentation;
0250     myPresentationName = thePresentationName;
0251   }
0252 
0253   //! Returns graphical presentation of the object.
0254   TopoDS_Shape GetPresentation() const
0255   {
0256     return myPresentation;
0257   }
0258 
0259   //! Returns graphical presentation of the object
0260   Standard_EXPORT Handle(TCollection_HAsciiString) GetPresentationName() const
0261   {
0262     return myPresentationName;
0263   }
0264 
0265   //! Returns true, if the object has descriptions.
0266   Standard_Boolean HasDescriptions() const
0267   {
0268     return (myDescriptions.Length() > 0);
0269   }
0270 
0271   //! Returns number of descriptions.
0272   Standard_Integer NbDescriptions() const
0273   {
0274     return myDescriptions.Length();
0275   }
0276 
0277   //! Returns description with the given number.
0278   Handle(TCollection_HAsciiString) GetDescription(const Standard_Integer theNumber) const
0279   {
0280     if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
0281       return  new TCollection_HAsciiString();
0282     return myDescriptions.Value(theNumber);
0283   }
0284 
0285   //! Returns name of description with the given number.
0286   Handle(TCollection_HAsciiString) GetDescriptionName(const Standard_Integer theNumber) const
0287   {
0288     if (theNumber < myDescriptions.Lower() || theNumber > myDescriptions.Upper())
0289       return new TCollection_HAsciiString();
0290     return myDescriptionNames.Value(theNumber);
0291   }
0292 
0293   //! Remove description with the given number.
0294   Standard_EXPORT void RemoveDescription(const Standard_Integer theNumber);
0295 
0296   //! Add new description.
0297   void AddDescription(const Handle(TCollection_HAsciiString) theDescription, const Handle(TCollection_HAsciiString) theName)
0298   {
0299     myDescriptions.Append(theDescription);
0300     myDescriptionNames.Append(theName);
0301   }
0302 
0303   //! Dumps the content of me into the stream
0304   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0305 
0306   DEFINE_STANDARD_RTTIEXT(XCAFDimTolObjects_DimensionObject,Standard_Transient)
0307 
0308 private: 
0309 
0310   XCAFDimTolObjects_DimensionType myType;
0311   Handle(TColStd_HArray1OfReal) myVal;
0312   XCAFDimTolObjects_DimensionQualifier myQualifier;
0313   XCAFDimTolObjects_AngularQualifier myAngularQualifier;
0314   Standard_Boolean myIsHole;
0315   XCAFDimTolObjects_DimensionFormVariance myFormVariance;
0316   XCAFDimTolObjects_DimensionGrade myGrade;
0317   Standard_Integer myL;
0318   Standard_Integer myR;
0319   XCAFDimTolObjects_DimensionModifiersSequence myModifiers;
0320   TopoDS_Edge myPath;
0321   gp_Dir myDir;
0322   gp_Pnt myPnt1, myPnt2;
0323   Standard_Boolean myHasPoint1, myHasPoint2;
0324   gp_Ax2 myPlane;
0325   Standard_Boolean myHasPlane;
0326   Standard_Boolean myHasPntText;
0327   gp_Pnt myPntText;
0328   TopoDS_Shape myPresentation;
0329   Handle(TCollection_HAsciiString) mySemanticName;
0330   Handle(TCollection_HAsciiString) myPresentationName;
0331   NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptions;
0332   NCollection_Vector<Handle(TCollection_HAsciiString)> myDescriptionNames;
0333 
0334 };
0335 
0336 #endif // _XCAFDimTolObjects_DimensionObject_HeaderFile