Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:19:02

0001 // Created on: 1996-07-08
0002 // Created by: Christian CAILLET
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 _STEPControl_Reader_HeaderFile
0018 #define _STEPControl_Reader_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <XSControl_Reader.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <DESTEP_Parameters.hxx>
0027 #include <TCollection_AsciiString.hxx>
0028 #include <NCollection_Sequence.hxx>
0029 #include <NCollection_Array1.hxx>
0030 class XSControl_WorkSession;
0031 class StepData_StepModel;
0032 class StepRepr_RepresentationContext;
0033 
0034 //! Reads STEP files, checks them and translates their contents
0035 //! into Open CASCADE models. The STEP data can be that of
0036 //! a whole model or that of a specific list of entities in the model.
0037 //! As in XSControl_Reader, you specify the list using a selection.
0038 //! For the translation of iges files it is possible to use next sequence:
0039 //! To change translation parameters
0040 //! class Interface_Static should be used before beginning of
0041 //! translation (see STEP Parameters and General Parameters)
0042 //! Creation of reader - STEPControl_Reader reader;
0043 //! To load s file in a model use method reader.ReadFile("filename.stp")
0044 //! To print load results reader.PrintCheckLoad(failsonly,mode)
0045 //! where mode is equal to the value of enumeration IFSelect_PrintCount
0046 //! For definition number of candidates :
0047 //! int nbroots = reader. NbRootsForTransfer();
0048 //! To transfer entities from a model the following methods can be used:
0049 //! for the whole model - reader.TransferRoots();
0050 //! to transfer a list of entities: reader.TransferList(list);
0051 //! to transfer one entity occ::handle<Standard_Transient>
0052 //! ent = reader.RootForTransfer(num);
0053 //! reader.TransferEntity(ent), or
0054 //! reader.TransferOneRoot(num), or
0055 //! reader.TransferOne(num), or
0056 //! reader.TransferRoot(num)
0057 //! To obtain the result the following method can be used:
0058 //! reader.NbShapes() and reader.Shape(num); or reader.OneShape();
0059 //! To print the results of transfer use method:
0060 //! reader.PrintCheckTransfer(failwarn,mode);
0061 //! where printfail is equal to the value of enumeration
0062 //! IFSelect_PrintFail, mode see above; or reader.PrintStatsTransfer();
0063 //! Gets correspondence between a STEP entity and a result
0064 //! shape obtained from it.
0065 //! occ::handle<XSControl_WorkSession>
0066 //! WS = reader.WS();
0067 //! if ( WS->TransferReader()->HasResult(ent) )
0068 //! TopoDS_Shape shape = WS->TransferReader()->ShapeResult(ent);
0069 class STEPControl_Reader : public XSControl_Reader
0070 {
0071 public:
0072   DEFINE_STANDARD_ALLOC
0073 
0074   //! Creates a reader object with an empty STEP model.
0075   Standard_EXPORT STEPControl_Reader();
0076 
0077   //! Creates a Reader for STEP from an already existing Session
0078   //! Clears the session if it was not yet set for STEP
0079   Standard_EXPORT STEPControl_Reader(const occ::handle<XSControl_WorkSession>& WS,
0080                                      const bool                                scratch = true);
0081 
0082   //! Returns the model as a StepModel.
0083   //! It can then be consulted (header, product)
0084   Standard_EXPORT occ::handle<StepData_StepModel> StepModel() const;
0085 
0086   //! Loads a file and returns the read status
0087   //! Zero for a Model which compies with the Controller
0088   Standard_EXPORT IFSelect_ReturnStatus ReadFile(const char* const filename) override;
0089 
0090   //! Loads a file from stream and returns the read status
0091   Standard_EXPORT IFSelect_ReturnStatus ReadStream(const char* const theName,
0092                                                    std::istream&     theIStream) override;
0093 
0094   //! Loads a file and returns the read status
0095   //! Zero for a Model which compies with the Controller
0096   Standard_EXPORT IFSelect_ReturnStatus ReadFile(const char* const        filename,
0097                                                  const DESTEP_Parameters& theParams);
0098 
0099   //! Loads a file from stream and returns the read status
0100   Standard_EXPORT IFSelect_ReturnStatus ReadStream(const char* const        theName,
0101                                                    const DESTEP_Parameters& theParams,
0102                                                    std::istream&            theIStream);
0103 
0104   //! Transfers a root given its rank in the list of candidate roots
0105   //! Default is the first one
0106   //! Returns True if a shape has resulted, false else
0107   //! Same as inherited TransferOneRoot, kept for compatibility
0108   Standard_EXPORT bool TransferRoot(
0109     const int                    num         = 1,
0110     const Message_ProgressRange& theProgress = Message_ProgressRange());
0111 
0112   //! Determines the list of root entities from Model which are candidate for
0113   //! a transfer to a Shape (type of entities is PRODUCT)
0114   Standard_EXPORT int NbRootsForTransfer() override;
0115 
0116   //! Returns sequence of all unit names for shape representations
0117   //! found in file
0118   Standard_EXPORT void FileUnits(
0119     NCollection_Sequence<TCollection_AsciiString>& theUnitLengthNames,
0120     NCollection_Sequence<TCollection_AsciiString>& theUnitAngleNames,
0121     NCollection_Sequence<TCollection_AsciiString>& theUnitSolidAngleNames);
0122 
0123   //! Sets system length unit used by transfer process.
0124   //! Performs only if a model is not NULL
0125   Standard_EXPORT void SetSystemLengthUnit(const double theLengthUnit);
0126 
0127   //! Returns system length unit used by transfer process.
0128   //! Performs only if a model is not NULL
0129   Standard_EXPORT double SystemLengthUnit() const;
0130 
0131 protected:
0132   //! Returns default parameters for shape fixing.
0133   //! This method is used by the base class to get default parameters for shape fixing.
0134   //! @return default parameters for shape fixing.
0135   Standard_EXPORT DE_ShapeFixParameters GetDefaultShapeFixParameters() const override;
0136 
0137   //! Returns default flags for shape processing.
0138   //! @return Default flags for shape processing.
0139   Standard_EXPORT ShapeProcess::OperationsFlags GetDefaultShapeProcessFlags() const override;
0140 
0141 private:
0142   //! Returns units for length, angle and solidangle for shape representations
0143   Standard_EXPORT bool findUnits(const occ::handle<StepRepr_RepresentationContext>& theReprContext,
0144                                  NCollection_Array1<TCollection_AsciiString>&       theNameUnits,
0145                                  NCollection_Array1<double>&                        theFactorUnits);
0146 };
0147 
0148 #endif // _STEPControl_Reader_HeaderFile