Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:15:56

0001 // Created on: 1994-09-01
0002 // Created by: Marie Jose MARTZ
0003 // Copyright (c) 1994-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 _IGESToBRep_Reader_HeaderFile
0018 #define _IGESToBRep_Reader_HeaderFile
0019 
0020 #include <Message_ProgressRange.hxx>
0021 #include <ShapeProcess.hxx>
0022 #include <Standard.hxx>
0023 #include <Standard_DefineAlloc.hxx>
0024 #include <Standard_Handle.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_CString.hxx>
0027 #include <TopTools_SequenceOfShape.hxx>
0028 #include <XSAlgo_ShapeProcessor.hxx>
0029 
0030 struct DE_ShapeFixParameters;
0031 class IGESData_IGESModel;
0032 class IGESToBRep_Actor;
0033 class Transfer_TransientProcess;
0034 class TopoDS_Shape;
0035 
0036 //! A simple way to read geometric IGES data.
0037 //! Encapsulates reading file and calling transfer tools
0038 class IGESToBRep_Reader
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043 public:
0044   //! Creates a Reader
0045   Standard_EXPORT IGESToBRep_Reader();
0046 
0047   //! Loads a Model from a file.Returns 0 if success.
0048   //! returns 1 if the file could not be opened,
0049   //! returns -1 if an error occurred while the file was being loaded.
0050   Standard_EXPORT Standard_Integer LoadFile(const Standard_CString filename);
0051 
0052   //! Specifies a Model to work on
0053   //! Also clears the result and Done status, sets TransientProcess
0054   Standard_EXPORT void SetModel(const Handle(IGESData_IGESModel)& model);
0055 
0056   //! Returns the Model to be worked on.
0057   Standard_EXPORT Handle(IGESData_IGESModel) Model() const;
0058 
0059   //! Allows to set an already defined TransientProcess
0060   //! (to be called after LoadFile or SetModel)
0061   Standard_EXPORT void SetTransientProcess(const Handle(Transfer_TransientProcess)& TP);
0062 
0063   //! Returns the TransientProcess
0064   Standard_EXPORT Handle(Transfer_TransientProcess) TransientProcess() const;
0065 
0066   //! Returns "theActor"
0067   Standard_EXPORT Handle(IGESToBRep_Actor) Actor() const;
0068 
0069   //! Clears the results between two translation operations.
0070   Standard_EXPORT void Clear();
0071 
0072   //! Checks the IGES file that was
0073   //! loaded into memory. Displays error messages in the default
0074   //! message file if withprint is true. Returns True if no fail
0075   //! message was found and False if there was at least one fail message.
0076   Standard_EXPORT Standard_Boolean Check(const Standard_Boolean withprint) const;
0077 
0078   //! Translates root entities in an
0079   //! IGES file. Standard_True is the default value and means that only
0080   //! visible root entities are translated. Standard_False
0081   //! translates all of the roots (visible and invisible).
0082   Standard_EXPORT void TransferRoots(
0083     const Standard_Boolean       onlyvisible = Standard_True,
0084     const Message_ProgressRange& theProgress = Message_ProgressRange());
0085 
0086   //! Transfers an Entity given its rank in the Model (Root or not)
0087   //! Returns True if it is recognized as Geom-Topol.
0088   //! (But it can have failed : see IsDone)
0089   Standard_EXPORT Standard_Boolean
0090     Transfer(const Standard_Integer       num,
0091              const Message_ProgressRange& theProgress = Message_ProgressRange());
0092 
0093   //! Returns True if the LAST Transfer/TransferRoots was a success
0094   Standard_EXPORT Standard_Boolean IsDone() const;
0095 
0096   //! Returns the Tolerance which has been actually used, converted
0097   //! in millimeters
0098   //! (either that from File or that from Session, according the mode)
0099   Standard_EXPORT Standard_Real UsedTolerance() const;
0100 
0101   //! Returns the number of shapes produced by the translation.
0102   Standard_EXPORT Standard_Integer NbShapes() const;
0103 
0104   //! Returns the num the resulting shape in a translation operation.
0105   Standard_EXPORT TopoDS_Shape Shape(const Standard_Integer num = 1) const;
0106 
0107   //! Returns all of the results in a
0108   //! single shape which is:
0109   //! - a null shape if there are no results,
0110   //! - a shape if there is one result,
0111   //! - a compound containing the resulting shapes if there are several.
0112   Standard_EXPORT TopoDS_Shape OneShape() const;
0113 
0114   //! Sets parameters for shape processing.
0115   //! @param theParameters the parameters for shape processing.
0116   Standard_EXPORT void SetShapeFixParameters(
0117     const XSAlgo_ShapeProcessor::ParameterMap& theParameters);
0118 
0119   //! Sets parameters for shape processing.
0120   //! Parameters are moved from the input map.
0121   //! @param theParameters the parameters for shape processing.
0122   Standard_EXPORT void SetShapeFixParameters(XSAlgo_ShapeProcessor::ParameterMap&& theParameters);
0123 
0124   //! Sets parameters for shape processing.
0125   //! Parameters from @p theParameters are copied to the internal map.
0126   //! Parameters from @p theAdditionalParameters are copied to the internal map
0127   //! if they are not present in @p theParameters.
0128   //! @param theParameters the parameters for shape processing.
0129   //! @param theAdditionalParameters the additional parameters for shape processing.
0130   Standard_EXPORT void SetShapeFixParameters(
0131     const DE_ShapeFixParameters&               theParameters,
0132     const XSAlgo_ShapeProcessor::ParameterMap& theAdditionalParameters = {});
0133 
0134   //! Returns parameters for shape processing that was set by SetParameters() method.
0135   //! @return the parameters for shape processing. Empty map if no parameters were set.
0136   inline const XSAlgo_ShapeProcessor::ParameterMap& GetShapeFixParameters() const
0137   {
0138     return myShapeProcParams;
0139   }
0140 
0141   //! Sets flags defining operations to be performed on shapes.
0142   //! @param theFlags The flags defining operations to be performed on shapes.
0143   Standard_EXPORT void SetShapeProcessFlags(const ShapeProcess::OperationsFlags& theFlags);
0144 
0145   //! Returns flags defining operations to be performed on shapes.
0146   //! @return The flags defining operations to be performed on shapes.
0147   inline const ShapeProcess::OperationsFlags& GetShapeProcessFlags() const
0148   {
0149     return myShapeProcFlags.first;
0150   }
0151 
0152 private:
0153   //! If parameters haven't yet been provided, initializes them with default values.
0154   void InitializeMissingParameters();
0155 
0156 private:
0157   Handle(IGESData_IGESModel)        theModel;
0158   Standard_Boolean                  theDone;
0159   TopTools_SequenceOfShape          theShapes;
0160   Handle(IGESToBRep_Actor)          theActor;
0161   Handle(Transfer_TransientProcess) theProc;
0162   // clang-format off
0163   XSAlgo_ShapeProcessor::ParameterMap myShapeProcParams; //!< Parameters for shape processing.
0164   XSAlgo_ShapeProcessor::ProcessingFlags myShapeProcFlags; //!< Flags defining operations to be performed on shapes.
0165   // clang-format on
0166 };
0167 
0168 #endif // _IGESToBRep_Reader_HeaderFile