Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:30

0001 // Created on: 1996-01-30
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 _IGESControl_Writer_HeaderFile
0018 #define _IGESControl_Writer_HeaderFile
0019 
0020 #include <ShapeProcess.hxx>
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <Standard_Handle.hxx>
0024 #include <IGESData_BasicEditor.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_CString.hxx>
0027 #include <Standard_OStream.hxx>
0028 #include <Message_ProgressRange.hxx>
0029 #include <XSAlgo_ShapeProcessor.hxx>
0030 
0031 struct DE_ShapeFixParameters;
0032 class Transfer_FinderProcess;
0033 class IGESData_IGESModel;
0034 class TopoDS_Shape;
0035 class Standard_Transient;
0036 class IGESData_IGESEntity;
0037 
0038 //! This class creates and writes
0039 //! IGES files from CAS.CADE models. An IGES file can be written to
0040 //! an existing IGES file or to a new one.
0041 //! The translation can be performed in one or several
0042 //! operations. Each translation operation
0043 //! outputs a distinct root entity in the IGES file.
0044 //! To write an IGES file it is possible to use the following sequence:
0045 //! To modify the IGES file header or to change translation
0046 //! parameters it is necessary to use class Interface_Static (see
0047 //! IGESParameters and GeneralParameters).
0048 class IGESControl_Writer
0049 {
0050 public:
0051   DEFINE_STANDARD_ALLOC
0052 
0053 public:
0054   //! Creates a writer object with the
0055   //! default unit (millimeters) and write mode (Face).
0056   //! IGESControl_Writer (const char* const unit,
0057   //! const int modecr = 0);
0058   Standard_EXPORT IGESControl_Writer();
0059 
0060   //! Creates a writer with given
0061   //! values for units and for write mode.
0062   //! theUnit may be any unit that is accepted by the IGES standard.
0063   //! By default, it is the millimeter.
0064   //! theModecr defines the write mode and may be:
0065   //! - 0: Faces (default)
0066   //! - 1: BRep.
0067   Standard_EXPORT IGESControl_Writer(const char* const theUnit, const int theModecr = 0);
0068 
0069   //! Creates a writer object with the
0070   //! prepared IGES model theModel in write mode.
0071   //! theModecr defines the write mode and may be:
0072   //! - 0: Faces (default)
0073   //! - 1: BRep.
0074   Standard_EXPORT IGESControl_Writer(const occ::handle<IGESData_IGESModel>& theModel,
0075                                      const int                              theModecr = 0);
0076 
0077   //! Returns the IGES model to be written in output.
0078   const occ::handle<IGESData_IGESModel>& Model() const { return myModel; }
0079 
0080   const occ::handle<Transfer_FinderProcess>& TransferProcess() const { return myTP; }
0081 
0082   //! Returns/Sets the TransferProcess : it contains final results
0083   //! and if some, check messages
0084   void SetTransferProcess(const occ::handle<Transfer_FinderProcess>& TP) { myTP = TP; }
0085 
0086   //! Translates a Shape to IGES Entities and adds them to the model
0087   //! Returns True if done, False if Shape not suitable for IGES or null
0088   Standard_EXPORT bool AddShape(const TopoDS_Shape&          sh,
0089                                 const Message_ProgressRange& theProgress = Message_ProgressRange());
0090 
0091   //! Translates a Geometry (Surface or Curve) to IGES Entities and
0092   //! adds them to the model
0093   //! Returns True if done, False if geom is neither a Surface or
0094   //! a Curve suitable for IGES or is null
0095   Standard_EXPORT bool AddGeom(const occ::handle<Standard_Transient>& geom);
0096 
0097   //! Adds an IGES entity (and the ones it references) to the model
0098   Standard_EXPORT bool AddEntity(const occ::handle<IGESData_IGESEntity>& ent);
0099 
0100   //! Computes the entities found in
0101   //! the model, which is ready to be written.
0102   //! This contrasts with the default computation of headers only.
0103   Standard_EXPORT void ComputeModel();
0104 
0105   //! Computes then writes the model to an OStream
0106   //! Returns True when done, false in case of error
0107   Standard_EXPORT bool Write(Standard_OStream& S, const bool fnes = false);
0108 
0109   //! Prepares and writes an IGES model
0110   //! either to an OStream, S or to a file name,CString.
0111   //! Returns True if the operation was performed correctly and
0112   //! False if an error occurred (for instance,
0113   //! if the processor could not create the file).
0114   Standard_EXPORT bool Write(const char* const file, const bool fnes = false);
0115 
0116   //! Sets parameters for shape processing.
0117   //! @param theParameters the parameters for shape processing.
0118   Standard_EXPORT void SetShapeFixParameters(
0119     const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
0120 
0121   //! Sets parameters for shape processing.
0122   //! Parameters are moved from the input map.
0123   //! @param theParameters the parameters for shape processing.
0124   Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
0125 
0126   //! Sets parameters for shape processing.
0127   //! Parameters from @p theParameters are copied to the internal map.
0128   //! Parameters from @p theAdditionalParameters are copied to the internal map
0129   //! if they are not present in @p theParameters.
0130   //! @param theParameters the parameters for shape processing.
0131   //! @param theAdditionalParameters the additional parameters for shape processing.
0132   Standard_EXPORT void SetShapeFixParameters(
0133     const DE_ShapeFixParameters&               theParameters,
0134     const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
0135 
0136   //! Returns parameters for shape processing that was set by SetParameters() method.
0137   //! @return the parameters for shape processing. Empty map if no parameters were set.
0138   inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
0139   {
0140     return myShapeProcParams;
0141   }
0142 
0143   //! Sets flags defining operations to be performed on shapes.
0144   //! @param theFlags The flags defining operations to be performed on shapes.
0145   Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
0146 
0147   //! Returns flags defining operations to be performed on shapes.
0148   //! @return The flags defining operations to be performed on shapes.
0149   inline const ShapeProcess::OperationsFlags& GetShapeProcessFlags() const
0150   {
0151     return myShapeProcFlags.first;
0152   }
0153 
0154 private:
0155   //! If parameters haven't yet been provided, initializes them with default values
0156   //! provided by GetDefaultShapeFixParameters() method.
0157   void InitializeMissingParameters();
0158 
0159 private:
0160   occ::handle<Transfer_FinderProcess> myTP;
0161   occ::handle<IGESData_IGESModel>     myModel;
0162   IGESData_BasicEditor                myEditor;
0163   int                                 myWriteMode;
0164   bool                                myIsComputed;
0165   // clang-format off
0166   XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams;   //!< Parameters for shape processing.
0167   XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
0168   // clang-format on
0169 };
0170 
0171 #endif // _IGESControl_Writer_HeaderFile