Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-27 10:38:06

0001 // Created on: 1994-11-07
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_SignCounter_HeaderFile
0018 #define _IFSelect_SignCounter_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Transient.hxx>
0024 #include <NCollection_Map.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <IFSelect_SignatureList.hxx>
0027 #include <NCollection_Sequence.hxx>
0028 #include <NCollection_HSequence.hxx>
0029 class IFSelect_Signature;
0030 class IFSelect_Selection;
0031 class Standard_Transient;
0032 class Interface_InterfaceModel;
0033 class Interface_Graph;
0034 class TCollection_HAsciiString;
0035 
0036 //! SignCounter gives the frame to count signatures associated
0037 //! with entities, deducted from them. Ex.: their Dynamic Type.
0038 //!
0039 //! It can sort a set of Entities according a signature, i.e. :
0040 //! - list of different values found for this Signature
0041 //! - for each one, count and list of entities
0042 //! Results are returned as a SignatureList, which can be queried
0043 //! on the count (list of strings, count per signature, or list of
0044 //! entities per signature)
0045 //!
0046 //! A SignCounter can be filled, either directly from lists, or
0047 //! from the result of a Selection : hence, its content can be
0048 //! automatically recomputed as desired
0049 //!
0050 //! SignCounter works by using a Signature in its method AddSign
0051 //!
0052 //! Methods can be redefined to, either
0053 //! - directly compute the value without a Signature
0054 //! - compute the value in the context of a Graph
0055 class IFSelect_SignCounter : public IFSelect_SignatureList
0056 {
0057 
0058 public:
0059   //! Creates a SignCounter, without proper Signature
0060   //! If <withmap> is True (default), added entities are counted
0061   //! only if they are not yet recorded in the map
0062   //! Map control can be set off if the input guarantees uniqueness of data
0063   //! <withlist> is transmitted to SignatureList (option to list
0064   //! entities, not only to count them).
0065   Standard_EXPORT IFSelect_SignCounter(const bool withmap = true, const bool withlist = false);
0066 
0067   //! Creates a SignCounter, with a predefined Signature
0068   //! Other arguments as for Create without Signature.
0069   Standard_EXPORT IFSelect_SignCounter(const occ::handle<IFSelect_Signature>& matcher,
0070                                        const bool                             withmap  = true,
0071                                        const bool                             withlist = false);
0072 
0073   //! Returns the Signature used to count entities. It can be null.
0074   Standard_EXPORT occ::handle<IFSelect_Signature> Signature() const;
0075 
0076   //! Changes the control status. The map is not cleared, simply
0077   //! its use changes
0078   Standard_EXPORT void SetMap(const bool withmap);
0079 
0080   //! Adds an entity by considering its signature, which is given by
0081   //! call to method AddSign
0082   //! Returns True if added, False if already in the map (and
0083   //! map control status set)
0084   Standard_EXPORT virtual bool AddEntity(const occ::handle<Standard_Transient>&       ent,
0085                                          const occ::handle<Interface_InterfaceModel>& model);
0086 
0087   //! Adds an entity (already filtered by Map) with its signature.
0088   //! This signature can be computed with the containing model.
0089   //! Its value is provided by the object Signature given at start,
0090   //! if no Signature is defined, it does nothing.
0091   //!
0092   //! Can be redefined (in this case, see also Sign)
0093   Standard_EXPORT virtual void AddSign(const occ::handle<Standard_Transient>&       ent,
0094                                        const occ::handle<Interface_InterfaceModel>& model);
0095 
0096   //! Adds a list of entities by adding each of the items
0097   Standard_EXPORT void AddList(
0098     const occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>& list,
0099     const occ::handle<Interface_InterfaceModel>&                               model);
0100 
0101   //! Adds a list of entities in the context given by the graph
0102   //! Default just call basic AddList
0103   //! Can be redefined to get a signature computed with the graph
0104   Standard_EXPORT virtual void AddWithGraph(
0105     const occ::handle<NCollection_HSequence<occ::handle<Standard_Transient>>>& list,
0106     const Interface_Graph&                                                     graph);
0107 
0108   //! Adds all the entities contained in a Model
0109   Standard_EXPORT void AddModel(const occ::handle<Interface_InterfaceModel>& model);
0110 
0111   //! Adds the result determined by a Selection from a Graph
0112   //! Remark : does not impact at all data from SetSelection & Co
0113   Standard_EXPORT void AddFromSelection(const occ::handle<IFSelect_Selection>& sel,
0114                                         const Interface_Graph&                 G);
0115 
0116   //! Sets a Selection as input : this causes content to be cleared
0117   //! then the Selection to be ready to compute (but not immediately)
0118   Standard_EXPORT void SetSelection(const occ::handle<IFSelect_Selection>& sel);
0119 
0120   //! Returns the selection, or a null Handle
0121   Standard_EXPORT occ::handle<IFSelect_Selection> Selection() const;
0122 
0123   //! Changes the mode of working with the selection :
0124   //! -1 just clears optimisation data and nothing else
0125   //! 0 clears it
0126   //! 1 inhibits it for computing (but no clearing)
0127   //! 2 sets it active for computing
0128   //! Default at creation is 0, after SetSelection (not null) is 2
0129   Standard_EXPORT void SetSelMode(const int selmode);
0130 
0131   //! Returns the mode of working with the selection
0132   Standard_EXPORT int SelMode() const;
0133 
0134   //! Computes from the selection result, if selection is active
0135   //! (mode 2). If selection is not defined (mode 0) or is inhibited
0136   //! (mode 1) does nothing.
0137   //! Returns True if computation is done (or optimised), False else
0138   //! This method is called by ComputeCounter from WorkSession
0139   //!
0140   //! If <forced> is True, recomputes systematically
0141   //! Else (D), if the counter was not cleared and if the former
0142   //! computed result started from the same total size of Graph and
0143   //! same count of selected entities : computation is not redone
0144   //! unless <forced> is given as True
0145   Standard_EXPORT bool ComputeSelected(const Interface_Graph& G, const bool forced = false);
0146 
0147   //! Determines and returns the value of the signature for an
0148   //! entity as an HAsciiString. This method works exactly as
0149   //! AddSign, which is optimized
0150   //!
0151   //! Can be redefined, accorded with AddSign
0152   Standard_EXPORT virtual occ::handle<TCollection_HAsciiString> Sign(
0153     const occ::handle<Standard_Transient>&       ent,
0154     const occ::handle<Interface_InterfaceModel>& model) const;
0155 
0156   //! Applies AddWithGraph on one entity, and returns the Signature
0157   //! Value which has been recorded
0158   //! To do this, Add is called with SignOnly Mode True during the
0159   //! call, the returned value is LastValue
0160   Standard_EXPORT const char* ComputedSign(const occ::handle<Standard_Transient>& ent,
0161                                            const Interface_Graph&                 G);
0162 
0163   DEFINE_STANDARD_RTTIEXT(IFSelect_SignCounter, IFSelect_SignatureList)
0164 
0165 private:
0166   bool                                             themapstat;
0167   NCollection_Map<occ::handle<Standard_Transient>> themap;
0168   occ::handle<IFSelect_Signature>                  thematcher;
0169   occ::handle<IFSelect_Selection>                  theselect;
0170   int                                              theselmode;
0171   int                                              thenbcomp1;
0172   int                                              thenbcomp2;
0173 };
0174 
0175 #endif // _IFSelect_SignCounter_HeaderFile