Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:16:22

0001 // Created on: 1994-05-27
0002 // Created by: Christian CAILLET
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 _IFSelect_TransformStandard_HeaderFile
0018 #define _IFSelect_TransformStandard_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <IFSelect_GeneralModifier.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <IFSelect_Transformer.hxx>
0026 #include <Standard_Integer.hxx>
0027 class IFSelect_Selection;
0028 class Interface_CopyControl;
0029 class IFSelect_Modifier;
0030 class Interface_Graph;
0031 class Interface_Protocol;
0032 class Interface_CheckIterator;
0033 class Interface_InterfaceModel;
0034 class Interface_CopyTool;
0035 class Standard_Transient;
0036 class TCollection_AsciiString;
0037 
0038 //! This class runs transformations made by Modifiers, as
0039 //! the ModelCopier does when it produces files (the same set
0040 //! of Modifiers can then be used, as to transform the starting
0041 //! Model, as at file sending time).
0042 //!
0043 //! First, considering the resulting model, two options :
0044 //! - modifications are made directly on the starting model
0045 //! (OnTheSpot option), or
0046 //! - data are copied by the standard service Copy, only the
0047 //! remaining (not yet sent in a file) entities are copied
0048 //! (StandardCopy option)
0049 //!
0050 //! If a Selection is set, it forces the list of Entities on which
0051 //! the Modifiers are applied. Else, each Modifier is considered
0052 //! its Selection. By default, it is for the whole Model
0053 //!
0054 //! Then, the Modifiers are sequentially applied
0055 //! If at least one Modifier "May Change Graph", or if the option
0056 //! StandardCopy is selected, the graph will be recomputed
0057 //! (by the WorkSession, see method RunTransformer)
0058 //!
0059 //! Remark that a TransformStandard with option StandardCopy
0060 //! and no Modifier at all has the effect of computing the
0061 //! remaining data (those not yet sent in any output file).
0062 //! Moreover, the Protocol is not changed
0063 class IFSelect_TransformStandard : public IFSelect_Transformer
0064 {
0065 
0066 public:
0067   //! Creates a TransformStandard, option StandardCopy, no Modifier
0068   Standard_EXPORT IFSelect_TransformStandard();
0069 
0070   //! Sets the Copy option to a new value :
0071   //! True for StandardCopy. False for OnTheSpot
0072   Standard_EXPORT void SetCopyOption(const bool option);
0073 
0074   //! Returns the Copy option
0075   Standard_EXPORT bool CopyOption() const;
0076 
0077   //! Sets a Selection (or unsets if Null)
0078   //! This Selection then defines the list of entities on which the
0079   //! Modifiers will be applied
0080   //! If it is set, it has priority on Selections of Modifiers
0081   //! Else, for each Modifier its Selection is evaluated
0082   //! By default, all the Model is taken
0083   Standard_EXPORT void SetSelection(const occ::handle<IFSelect_Selection>& sel);
0084 
0085   //! Returns the Selection, Null by default
0086   Standard_EXPORT occ::handle<IFSelect_Selection> Selection() const;
0087 
0088   //! Returns the count of recorded Modifiers
0089   Standard_EXPORT int NbModifiers() const;
0090 
0091   //! Returns a Modifier given its rank in the list
0092   Standard_EXPORT occ::handle<IFSelect_Modifier> Modifier(const int num) const;
0093 
0094   //! Returns the rank of a Modifier in the list, 0 if unknown
0095   Standard_EXPORT int ModifierRank(const occ::handle<IFSelect_Modifier>& modif) const;
0096 
0097   //! Adds a Modifier to the list :
0098   //! - <atnum> = 0 (default) : at the end of the list
0099   //! - <atnum> > 0 : at rank <atnum>
0100   //! Returns True if done, False if <atnum> is out of range
0101   Standard_EXPORT bool AddModifier(const occ::handle<IFSelect_Modifier>& modif,
0102                                    const int                             atnum = 0);
0103 
0104   //! Removes a Modifier from the list
0105   //! Returns True if done, False if <modif> not in the list
0106   Standard_EXPORT bool RemoveModifier(const occ::handle<IFSelect_Modifier>& modif);
0107 
0108   //! Removes a Modifier from the list, given its rank
0109   //! Returns True if done, False if <num> is out of range
0110   Standard_EXPORT bool RemoveModifier(const int num);
0111 
0112   //! Performs the Standard Transformation, by calling Copy then
0113   //! ApplyModifiers (which can return an error status)
0114   Standard_EXPORT bool Perform(const Interface_Graph&                 G,
0115                                const occ::handle<Interface_Protocol>& protocol,
0116                                Interface_CheckIterator&               checks,
0117                                occ::handle<Interface_InterfaceModel>& newmod) override;
0118 
0119   //! This the first operation. It calls StandardCopy or OnTheSpot
0120   //! according the option
0121   //! Performs the copy operation. Calls StandardCopy or OnTheSpot
0122   //! according to the copy option.
0123   //! @param[in] G the interface graph
0124   //! @param[in,out] TC the copy tool
0125   //! @return the new model produced by the copy
0126   [[nodiscard]] Standard_EXPORT occ::handle<Interface_InterfaceModel> Copy(
0127     const Interface_Graph& G,
0128     Interface_CopyTool&    TC) const;
0129 
0130   //! @deprecated Use Copy() returning handle by value instead.
0131   Standard_DEPRECATED("Use Copy() returning handle by value instead")
0132   Standard_EXPORT void Copy(const Interface_Graph&                 G,
0133                             Interface_CopyTool&                    TC,
0134                             occ::handle<Interface_InterfaceModel>& newmod) const;
0135 
0136   //! This is the standard action of Copy : its takes into account
0137   //! only the remaining entities (noted by Graph Status positive)
0138   //! and their proper dependences of course. Produces a new model.
0139   //! Performs a standard copy of remaining entities and their dependencies.
0140   //! @param[in] G the interface graph
0141   //! @param[in,out] TC the copy tool
0142   //! @return the new model with copied entities
0143   [[nodiscard]] Standard_EXPORT occ::handle<Interface_InterfaceModel> StandardCopy(
0144     const Interface_Graph& G,
0145     Interface_CopyTool&    TC) const;
0146 
0147   //! @deprecated Use StandardCopy() returning handle by value instead.
0148   Standard_DEPRECATED("Use StandardCopy() returning handle by value instead")
0149   Standard_EXPORT void StandardCopy(const Interface_Graph&                 G,
0150                                     Interface_CopyTool&                    TC,
0151                                     occ::handle<Interface_InterfaceModel>& newmod) const;
0152 
0153   //! This is the OnTheSpot action : each entity is bound with ...
0154   //! itself. The produced model is the same as the starting one.
0155   //! Performs the on-the-spot action: each entity is bound with itself.
0156   //! The produced model is the same as the starting one.
0157   //! @param[in] G the interface graph
0158   //! @param[in,out] TC the copy tool
0159   //! @return the starting model (same instance)
0160   [[nodiscard]] Standard_EXPORT occ::handle<Interface_InterfaceModel> OnTheSpot(
0161     const Interface_Graph& G,
0162     Interface_CopyTool&    TC) const;
0163 
0164   //! @deprecated Use OnTheSpot() returning handle by value instead.
0165   Standard_DEPRECATED("Use OnTheSpot() returning handle by value instead")
0166   Standard_EXPORT void OnTheSpot(const Interface_Graph&                 G,
0167                                  Interface_CopyTool&                    TC,
0168                                  occ::handle<Interface_InterfaceModel>& newmod) const;
0169 
0170   //! Applies the modifiers sequentially.
0171   //! For each one, prepares required data (if a Selection is associated as a filter).
0172   //! For the option OnTheSpot, it determines if the graph may be
0173   //! changed and updates <newmod> if required
0174   //! If a Modifier causes an error (check "HasFailed"),
0175   //! ApplyModifier stops : the following Modifiers are ignored
0176   Standard_EXPORT bool ApplyModifiers(const Interface_Graph&                 G,
0177                                       const occ::handle<Interface_Protocol>& protocol,
0178                                       Interface_CopyTool&                    TC,
0179                                       Interface_CheckIterator&               checks,
0180                                       occ::handle<Interface_InterfaceModel>& newmod) const;
0181 
0182   //! This methods allows to know what happened to a starting
0183   //! entity after the last Perform. It reads result from the map
0184   //! which was filled by Perform.
0185   Standard_EXPORT bool Updated(const occ::handle<Standard_Transient>& entfrom,
0186                                occ::handle<Standard_Transient>&       entto) const override;
0187 
0188   //! Returns a text which defines the way a Transformer works :
0189   //! "On the spot edition" or "Standard Copy" followed by
0190   //! "<nn> Modifiers"
0191   Standard_EXPORT TCollection_AsciiString Label() const override;
0192 
0193   DEFINE_STANDARD_RTTIEXT(IFSelect_TransformStandard, IFSelect_Transformer)
0194 
0195 private:
0196   bool                                                        thecopy;
0197   occ::handle<IFSelect_Selection>                             thesel;
0198   NCollection_Sequence<occ::handle<IFSelect_GeneralModifier>> themodifs;
0199   occ::handle<Interface_CopyControl>                          themap;
0200 };
0201 
0202 #endif // _IFSelect_TransformStandard_HeaderFile