Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:14:47

0001 // Created on: 1993-01-08
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1993-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 _IFSelect_WorkLibrary_HeaderFile
0018 #define _IFSelect_WorkLibrary_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <TCollection_HAsciiString.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <Standard_Transient.hxx>
0028 class Interface_InterfaceModel;
0029 class Interface_Protocol;
0030 class IFSelect_ContextWrite;
0031 class Interface_EntityIterator;
0032 class Interface_CopyTool;
0033 
0034 //! This class defines the (empty) frame which can be used to
0035 //! enrich a XSTEP set with new capabilities
0036 //! In particular, a specific WorkLibrary must give the way for
0037 //! Reading a File into a Model, and Writing a Model to a File
0038 //! Thus, it is possible to define several Work Libraries for each
0039 //! norm, but recommended to define one general class for each one :
0040 //! this general class will define the Read and Write methods.
0041 //!
0042 //! Also a Dump service is provided, it can produce, according the
0043 //! norm, either a parcel of a file for an entity, or any other
0044 //! kind of information relevant for the norm,
0045 class IFSelect_WorkLibrary : public Standard_Transient
0046 {
0047 
0048 public:
0049   //! Gives the way to Read a File and transfer it to a Model
0050   //! <mod> is the resulting Model, which has to be created by this
0051   //! method. In case of error, <mod> must be returned Null
0052   //! Return value is a status with free values.
0053   //! Simply, 0 is for "Execution OK"
0054   //! The Protocol can be used to work (e.g. create the Model, read
0055   //! and recognize the Entities)
0056   Standard_EXPORT virtual int ReadFile(const char* const                      name,
0057                                        occ::handle<Interface_InterfaceModel>& model,
0058                                        const occ::handle<Interface_Protocol>& protocol) const = 0;
0059 
0060   //! Interface to read a data from the specified stream.
0061   //! @param model is the resulting Model, which has to be created by this method.
0062   //!        In case of error, model must be returned Null
0063   //! Return value is a status: 0 - OK, 1 - read failure, -1 - stream failure.
0064   //!
0065   //! Default implementation returns 1 (error).
0066   Standard_EXPORT virtual int ReadStream(const char* const                      theName,
0067                                          std::istream&                          theIStream,
0068                                          occ::handle<Interface_InterfaceModel>& model,
0069                                          const occ::handle<Interface_Protocol>& protocol) const;
0070 
0071   //! Gives the way to Write a File from a Model.
0072   //! <ctx> contains all necessary information : the model, the
0073   //! protocol, the file name, and the list of File Modifiers to be
0074   //! applied, also with restricted list of selected entities for
0075   //! each one, if required.
0076   //! In return, it brings the produced check-list
0077   //!
0078   //! The WorkLibrary has to query <applied> to get then run the
0079   //! ContextWrite by looping like this (example) :
0080   //! for (numap = 1; numap <= ctx.NbModifiers(); numap ++) {
0081   //! ctx.SetModifier (numap);
0082   //! cast ctx.FileModifier()  to specific type -> variable filemod
0083   //! if (!filemod.IsNull()) filemod->Perform (ctx,writer);
0084   //! filemod then works with ctx. It can, either act on the
0085   //! model itself (for instance on its header), or iterate
0086   //! on selected entities (Start/Next/More/Value)
0087   //! it can call AddFail or AddWarning, as necessary
0088   //! }
0089   Standard_EXPORT virtual bool WriteFile(IFSelect_ContextWrite& ctx) const = 0;
0090 
0091   //! Performs the copy of entities from an original model to a new
0092   //! one. It must also copy headers if any. Returns True when done.
0093   //! The provided default works by copying the individual entities
0094   //! designated in the list, by using the general service class
0095   //! CopyTool.
0096   //! It can be redefined for a norm which, either implements Copy
0097   //! by another way (do not forget to Bind each copied result with
0098   //! its original entity in TC) and returns True, or does not know
0099   //! how to copy and returns False
0100   Standard_EXPORT virtual bool CopyModel(const occ::handle<Interface_InterfaceModel>& original,
0101                                          const occ::handle<Interface_InterfaceModel>& newmodel,
0102                                          const Interface_EntityIterator&              list,
0103                                          Interface_CopyTool&                          TC) const;
0104 
0105   //! Gives the way of dumping an entity under a form comprehensive
0106   //! for each norm. <model> helps to identify, number ... entities.
0107   //! <level> is to be interpreted for each norm (because of the
0108   //! formats which can be very different)
0109   Standard_EXPORT virtual void DumpEntity(const occ::handle<Interface_InterfaceModel>& model,
0110                                           const occ::handle<Interface_Protocol>&       protocol,
0111                                           const occ::handle<Standard_Transient>&       entity,
0112                                           Standard_OStream&                            S,
0113                                           const int level) const = 0;
0114 
0115   //! Calls deferred DumpEntity with the recorded default level
0116   Standard_EXPORT void DumpEntity(const occ::handle<Interface_InterfaceModel>& model,
0117                                   const occ::handle<Interface_Protocol>&       protocol,
0118                                   const occ::handle<Standard_Transient>&       entity,
0119                                   Standard_OStream&                            S) const;
0120 
0121   //! Records a default level and a maximum value for level
0122   //! level for DumpEntity can go between 0 and <max>
0123   //! default value will be <def>
0124   Standard_EXPORT void SetDumpLevels(const int def, const int max);
0125 
0126   //! Returns the recorded default and maximum dump levels
0127   //! If none was recorded, max is returned negative, def as zero
0128   Standard_EXPORT void DumpLevels(int& def, int& max) const;
0129 
0130   //! Records a short line of help for a level (0 - max)
0131   Standard_EXPORT void SetDumpHelp(const int level, const char* const help);
0132 
0133   //! Returns the help line recorded for <level>, or an empty string
0134   Standard_EXPORT const char* DumpHelp(const int level) const;
0135 
0136   DEFINE_STANDARD_RTTIEXT(IFSelect_WorkLibrary, Standard_Transient)
0137 
0138 protected:
0139   //! Required to initialise fields
0140   Standard_EXPORT IFSelect_WorkLibrary();
0141 
0142 private:
0143   int                                                                     thelevdef;
0144   occ::handle<NCollection_HArray1<occ::handle<TCollection_HAsciiString>>> thelevhlp;
0145 };
0146 
0147 #endif // _IFSelect_WorkLibrary_HeaderFile