Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2004-01-09
0002 // Created by: Sergey KUUL
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _XCAFDoc_DimTolTool_HeaderFile
0017 #define _XCAFDoc_DimTolTool_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <TDataStd_GenericEmpty.hxx>
0023 #include <Standard_Boolean.hxx>
0024 #include <TDF_LabelSequence.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <TColStd_HArray1OfReal.hxx>
0027 #include <TopoDS_Shape.hxx>
0028 #include <NCollection_IndexedDataMap.hxx>
0029 
0030 class XCAFDoc_ShapeTool;
0031 class TDF_Label;
0032 class Standard_GUID;
0033 class TCollection_HAsciiString;
0034 
0035 
0036 class XCAFDoc_DimTolTool;
0037 DEFINE_STANDARD_HANDLE(XCAFDoc_DimTolTool, TDataStd_GenericEmpty)
0038 
0039 //! Attribute containing GD&T section of XCAF document.
0040 //! Provide tools for GD&T section management.
0041 class XCAFDoc_DimTolTool : public TDataStd_GenericEmpty
0042 {
0043 
0044 public:
0045 
0046   
0047   Standard_EXPORT XCAFDoc_DimTolTool();
0048   
0049   //! Creates (if not exist) DimTolTool attribute.
0050   Standard_EXPORT static Handle(XCAFDoc_DimTolTool) Set (const TDF_Label& L);
0051   
0052   //! Returns the standard GD&T tool GUID.
0053   Standard_EXPORT static const Standard_GUID& GetID();
0054   
0055   //! Returns the label under which GD&T table is stored.
0056   Standard_EXPORT TDF_Label BaseLabel() const;
0057   
0058   //! Returns internal XCAFDoc_ShapeTool tool
0059   Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
0060 
0061   //! Returns True if the label belongs to a GD&T table and
0062   //! is a Dimension definition.
0063   Standard_EXPORT Standard_Boolean IsDimension (const TDF_Label& theLab) const;
0064   
0065   //! Returns a sequence of Dimension labels currently stored
0066   //! in the GD&T table.
0067   Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const;
0068   
0069   //! Sets a dimension to sequences target labels.
0070   Standard_EXPORT void SetDimension (const TDF_LabelSequence& theFirstLS, 
0071                                      const TDF_LabelSequence& theSecondLS, 
0072                                      const TDF_Label& theDimL) const;
0073 
0074   //! Sets a dimension to target labels.
0075   Standard_EXPORT void SetDimension(const TDF_Label& theFirstL,
0076                                      const TDF_Label& theSecondL, 
0077                                      const TDF_Label& theDimL) const;
0078   
0079   //! Sets a dimension to the target label.
0080   Standard_EXPORT void SetDimension (const TDF_Label& theL, 
0081                                      const TDF_Label& theDimL) const;
0082   
0083   //! Returns all Dimension labels defined for theShapeL.
0084   Standard_EXPORT Standard_Boolean GetRefDimensionLabels (const TDF_Label& theShapeL, 
0085                                                           TDF_LabelSequence& theDimensions) const;
0086   
0087   //! Adds a dimension definition to the GD&T table and returns its label.
0088   Standard_EXPORT TDF_Label AddDimension() ;
0089   
0090   //! Returns True if the label belongs to the GD&T table and is a dimension tolerance.
0091   Standard_EXPORT Standard_Boolean IsGeomTolerance (const TDF_Label& theLab) const;
0092   
0093   //! Returns a sequence of Tolerance labels currently stored in the GD&T table.
0094   Standard_EXPORT void GetGeomToleranceLabels (TDF_LabelSequence& theLabels) const;
0095   
0096   //! Sets a geometry tolerance from theGeomTolL to theL label.
0097   //! Checks if theGeomTolL is a geometry tolerance definition first.
0098   Standard_EXPORT void SetGeomTolerance (const TDF_Label& theL, 
0099                                          const TDF_Label& theGeomTolL) const;
0100 
0101   //! Sets a geometry tolerance from theGeomTolL to sequence of labels theL.
0102   //! Checks if theGeomTolL is a geometry tolerance definition first.
0103   Standard_EXPORT void SetGeomTolerance(const TDF_LabelSequence& theL,
0104                                          const TDF_Label& theGeomTolL) const;
0105   
0106   //! Returns all GeomTolerance labels defined for theShapeL.
0107   Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL, 
0108                                                               TDF_LabelSequence& theDimTols) const;
0109   
0110   //! Adds a GeomTolerance definition to the GD&T table and returns its label.
0111   Standard_EXPORT TDF_Label AddGeomTolerance();
0112   
0113   //! Returns True if theLab belongs to the GD&T table and is a dmension tolerance.
0114   Standard_EXPORT Standard_Boolean IsDimTol(const TDF_Label& theLab) const;
0115   
0116   //! Returns a sequence of D&GTs currently stored in the GD&T table.
0117   Standard_EXPORT void GetDimTolLabels (TDF_LabelSequence& Labels) const;
0118   
0119   //! Finds a dimension tolerance definition in the GD&T table 
0120   //! satisfying the specified kind, values, name and description
0121   //! and returns its label if found.
0122   //! Returns False if dimension tolerance is not found in DGTtable.
0123   Standard_EXPORT Standard_Boolean FindDimTol (const Standard_Integer theKind, 
0124                                                const Handle(TColStd_HArray1OfReal)& theVal, 
0125                                                const Handle(TCollection_HAsciiString)& theName, 
0126                                                const Handle(TCollection_HAsciiString)& theDescription, 
0127                                                TDF_Label& lab) const;
0128   
0129   //! Finds a dimension tolerance in the GD&T table 
0130   //! satisfying the specified kind, values, name and description
0131   //! and returns its label if found (or Null label else).
0132   Standard_EXPORT TDF_Label FindDimTol (const Standard_Integer theKind, 
0133                                         const Handle(TColStd_HArray1OfReal)& theVal, 
0134                                         const Handle(TCollection_HAsciiString)& theName, 
0135                                         const Handle(TCollection_HAsciiString)& theDescription) const;
0136   
0137   //! Adds a dimension tolerance definition with the specified
0138   //! kind, value, name and description to the GD&T table and returns its label.
0139   Standard_EXPORT TDF_Label AddDimTol (const Standard_Integer theKind, 
0140                                        const Handle(TColStd_HArray1OfReal)& theVal, 
0141                                        const Handle(TCollection_HAsciiString)& theName, 
0142                                        const Handle(TCollection_HAsciiString)& theDescription) const;
0143   
0144   //! Sets existing dimension tolerance to theL label.
0145   Standard_EXPORT void SetDimTol (const TDF_Label& theL, 
0146                                   const TDF_Label& theDimTolL) const;
0147   
0148   //! Creates a dimension tolerance and sets it to theL label.
0149   Standard_EXPORT TDF_Label SetDimTol (const TDF_Label& theL, 
0150                                        const Standard_Integer theKind, 
0151                                        const Handle(TColStd_HArray1OfReal)& theVal, 
0152                                        const Handle(TCollection_HAsciiString)& theName, 
0153                                        const Handle(TCollection_HAsciiString)& theDescription) const;
0154   
0155   //! Gets all shape labels referred by theL label of the GD&T table.
0156   //! Returns False if there are no shape labels added to the sequences.
0157   Standard_EXPORT static Standard_Boolean GetRefShapeLabel (const TDF_Label& theL, 
0158                                                            TDF_LabelSequence& theShapeLFirst,
0159                                                            TDF_LabelSequence& theShapeLSecond);
0160   
0161   //! Returns dimension tolerance assigned to theDimTolL label.
0162   //! Returns False if no such dimension tolerance is assigned.
0163   Standard_EXPORT Standard_Boolean GetDimTol (const TDF_Label& theDimTolL, 
0164                                               Standard_Integer& theKind, 
0165                                               Handle(TColStd_HArray1OfReal)& theVal, 
0166                                               Handle(TCollection_HAsciiString)& theName, 
0167                                               Handle(TCollection_HAsciiString)& theDescription) const;
0168   
0169   //! Returns True if label belongs to the GD&T table and
0170   //! is a Datum definition.
0171   Standard_EXPORT Standard_Boolean IsDatum (const TDF_Label& lab) const;
0172   
0173   //! Returns a sequence of Datums currently stored
0174   //! in the GD&T table.
0175   Standard_EXPORT void GetDatumLabels (TDF_LabelSequence& Labels) const;
0176   
0177   //! Finds a datum satisfying the specified name, description and
0178   //! identification and returns its label if found.
0179   Standard_EXPORT Standard_Boolean FindDatum (const Handle(TCollection_HAsciiString)& theName, 
0180                                               const Handle(TCollection_HAsciiString)& theDescription, 
0181                                               const Handle(TCollection_HAsciiString)& theIdentification, 
0182                                               TDF_Label& lab) const;
0183   
0184   //! Adds a datum definition to the GD&T table and returns its label.
0185   Standard_EXPORT TDF_Label AddDatum (const Handle(TCollection_HAsciiString)& theName, 
0186                                       const Handle(TCollection_HAsciiString)& theDescription, 
0187                                       const Handle(TCollection_HAsciiString)& theIdentification) const;
0188 
0189   //! Adds a datum definition to the GD&T table and returns its label.
0190   Standard_EXPORT TDF_Label AddDatum() ;
0191   
0192   //! Sets a datum to the sequence of shape labels.
0193   Standard_EXPORT void SetDatum (const TDF_LabelSequence& theShapeLabels, 
0194                                  const TDF_Label& theDatumL) const;
0195   
0196   //! Sets a datum to theL label and binds it with theTolerL label.
0197   //! A datum with the specified name, description and identification
0198   //! is created if it isn't found in the GD&T table.
0199   Standard_EXPORT void SetDatum (const TDF_Label& theL, 
0200                                  const TDF_Label& theTolerL, 
0201                                  const Handle(TCollection_HAsciiString)& theName, 
0202                                  const Handle(TCollection_HAsciiString)& theDescription, 
0203                                  const Handle(TCollection_HAsciiString)& theIdentification) const;
0204 
0205   //! Sets a datum from theDatumL label to theToletL label.
0206   Standard_EXPORT void SetDatumToGeomTol (const TDF_Label& theDatumL, 
0207                                           const TDF_Label& theTolerL)  const;
0208   
0209   //! Returns datum assigned to theDatumL label.
0210   //! Returns False if no such datum is assigned.
0211   Standard_EXPORT Standard_Boolean GetDatum (const TDF_Label& theDatumL, 
0212                                              Handle(TCollection_HAsciiString)& theName, 
0213                                              Handle(TCollection_HAsciiString)& theDescription, 
0214                                              Handle(TCollection_HAsciiString)& theIdentification) const;
0215   
0216   //! Returns all Datum labels defined for theDimTolL label.
0217   Standard_EXPORT static Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& theDimTolL,
0218                                                                  TDF_LabelSequence& theDatums);
0219 
0220   //! Returns all Datum labels with XCAFDimTolObjects_DatumObject defined for label theDimTolL.
0221   Standard_EXPORT static Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& theDimTolL,
0222                                                                            TDF_LabelSequence& theDatums);
0223 
0224   //! Returns all GeomToleranses labels defined for theDatumL label.
0225   Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, 
0226                                                           TDF_LabelSequence& theTols)  const;
0227 
0228   //! Returns Datum label defined for theShapeL label.
0229   Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, 
0230                                                      TDF_LabelSequence& theDatum)  const;
0231 
0232   //! Returns true if the given GDT is marked as locked.
0233   Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;
0234 
0235   //! Mark the given GDT as locked.
0236   Standard_EXPORT void Lock(const TDF_Label& theViewL) const;
0237 
0238   //! fill the map GDT label -> shape presentation 
0239   Standard_EXPORT void GetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape>& theGDTLabelToShape) const;
0240 
0241   //! Set shape presentation for GDT labels according to given map (theGDTLabelToPrs)
0242   //! theGDTLabelToPrsName map is an additional argument, can be used to set presentation names.
0243   //! If label is not in the theGDTLabelToPrsName map, the presentation name will be empty
0244   Standard_EXPORT void SetGDTPresentations(NCollection_IndexedDataMap<TDF_Label, TopoDS_Shape>& theGDTLabelToPrs);
0245 
0246   //! Unlock the given GDT.
0247   Standard_EXPORT void Unlock(const TDF_Label& theViewL) const;
0248     
0249   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0250 
0251   
0252   //! Dumps the content of me into the stream
0253   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0254 
0255 
0256   DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_DimTolTool,TDataStd_GenericEmpty)
0257 
0258 
0259 private:
0260 
0261 
0262   Handle(XCAFDoc_ShapeTool) myShapeTool;
0263 
0264 
0265 };
0266 
0267 
0268 
0269 
0270 
0271 
0272 
0273 #endif // _XCAFDoc_DimTolTool_HeaderFile