1 // Created on: 1996-07-08
2 // Created by: Christian CAILLET
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _STEPControl_Reader_HeaderFile
18 #define _STEPControl_Reader_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <XSControl_Reader.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
27 #include <TColStd_SequenceOfAsciiString.hxx>
28 #include <TColStd_Array1OfAsciiString.hxx>
29 #include <TColStd_Array1OfReal.hxx>
30 class XSControl_WorkSession;
31 class StepData_StepModel;
32 class StepRepr_RepresentationContext;
35 //! Reads STEP files, checks them and translates their contents
36 //! into Open CASCADE models. The STEP data can be that of
37 //! a whole model or that of a specific list of entities in the model.
38 //! As in XSControl_Reader, you specify the list using a selection.
39 //! For the translation of iges files it is possible to use next sequence:
40 //! To change translation parameters
41 //! class Interface_Static should be used before beginning of
42 //! translation (see STEP Parameters and General Parameters)
43 //! Creation of reader - STEPControl_Reader reader;
44 //! To load s file in a model use method reader.ReadFile("filename.stp")
45 //! To print load results reader.PrintCheckLoad(failsonly,mode)
46 //! where mode is equal to the value of enumeration IFSelect_PrintCount
47 //! For definition number of candidates :
48 //! Standard_Integer nbroots = reader. NbRootsForTransfer();
49 //! To transfer entities from a model the following methods can be used:
50 //! for the whole model - reader.TransferRoots();
51 //! to transfer a list of entities: reader.TransferList(list);
52 //! to transfer one entity Handle(Standard_Transient)
53 //! ent = reader.RootForTransfer(num);
54 //! reader.TransferEntity(ent), or
55 //! reader.TransferOneRoot(num), or
56 //! reader.TransferOne(num), or
57 //! reader.TransferRoot(num)
58 //! To obtain the result the following method can be used:
59 //! reader.NbShapes() and reader.Shape(num); or reader.OneShape();
60 //! To print the results of transfer use method:
61 //! reader.PrintCheckTransfer(failwarn,mode);
62 //! where printfail is equal to the value of enumeration
63 //! IFSelect_PrintFail, mode see above; or reader.PrintStatsTransfer();
64 //! Gets correspondence between a STEP entity and a result
65 //! shape obtained from it.
66 //! Handle(XSControl_WorkSession)
68 //! if ( WS->TransferReader()->HasResult(ent) )
69 //! TopoDS_Shape shape = WS->TransferReader()->ShapeResult(ent);
70 class STEPControl_Reader : public XSControl_Reader
77 //! Creates a reader object with an empty STEP model.
78 Standard_EXPORT STEPControl_Reader();
80 //! Creates a Reader for STEP from an already existing Session
81 //! Clears the session if it was not yet set for STEP
82 Standard_EXPORT STEPControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
84 //! Returns the model as a StepModel.
85 //! It can then be consulted (header, product)
86 Standard_EXPORT Handle(StepData_StepModel) StepModel() const;
88 //! Transfers a root given its rank in the list of candidate roots
89 //! Default is the first one
90 //! Returns True if a shape has resulted, false else
91 //! Same as inherited TransferOneRoot, kept for compatibility
92 Standard_EXPORT Standard_Boolean TransferRoot (const Standard_Integer num = 1,
93 const Message_ProgressRange& theProgress = Message_ProgressRange());
95 //! Determines the list of root entities from Model which are candidate for
96 //! a transfer to a Shape (type of entities is PRODUCT)
97 Standard_EXPORT virtual Standard_Integer NbRootsForTransfer() Standard_OVERRIDE;
99 //! Returns sequence of all unit names for shape representations
101 Standard_EXPORT void FileUnits (TColStd_SequenceOfAsciiString& theUnitLengthNames, TColStd_SequenceOfAsciiString& theUnitAngleNames, TColStd_SequenceOfAsciiString& theUnitSolidAngleNames);
103 //! Sets system length unit used by transfer process
104 Standard_EXPORT void SetSystemLengthUnit(const Standard_Real theLengthUnit);
106 //! Returns system length unit used by transfer process
107 Standard_EXPORT Standard_Real SystemLengthUnit() const;
119 //! Returns units for length , angle and solidangle for shape representations
120 Standard_EXPORT Standard_Boolean findUnits (const Handle(StepRepr_RepresentationContext)& theReprContext, TColStd_Array1OfAsciiString& theNameUnits, TColStd_Array1OfReal& theFactorUnits);
133 #endif // _STEPControl_Reader_HeaderFile