Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:16:28

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