Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:34

0001 // Copyright (c) 2026 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepGraph_Compact_HeaderFile
0015 #define _BRepGraph_Compact_HeaderFile
0016 
0017 #include <BRepGraph.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 
0020 //! @brief Graph compaction algorithm that reclaims removed node slots.
0021 //!
0022 //! After deduplication or other operations that mark nodes as removed,
0023 //! this algorithm rebuilds the graph with dense index arrays, eliminating
0024 //! all removed nodes and reassigning indices to be contiguous.
0025 //!
0026 //! Strategy: rebuild-and-swap. A fresh BRepGraph is constructed from
0027 //! non-removed nodes with remapped indices, then move-assigned into
0028 //! the input graph.
0029 class BRepGraph_Compact
0030 {
0031 public:
0032   DEFINE_STANDARD_ALLOC
0033 
0034   //! Configuration for compaction.
0035   struct Options
0036   {
0037     enum class CachePolicy
0038     {
0039       Drop,     //!< Keep registered cache services but clear transient entries.
0040       CopyFresh //!< Copy fresh, remappable transient entries into the compacted graph.
0041     };
0042 
0043     bool        HistoryMode = true;              //!< Record index remapping in history.
0044     CachePolicy CacheMode   = CachePolicy::Drop; //!< Runtime cache migration policy.
0045   };
0046 
0047   //! Result counters for diagnostics.
0048   struct Result
0049   {
0050     uint32_t NbRemovedVertices   = 0;
0051     uint32_t NbRemovedEdges      = 0;
0052     uint32_t NbRemovedWires      = 0;
0053     uint32_t NbRemovedFaces      = 0;
0054     uint32_t NbRemovedShells     = 0;
0055     uint32_t NbRemovedSolids     = 0;
0056     uint32_t NbRemovedCompounds  = 0;
0057     uint32_t NbRemovedCompSolids = 0;
0058     uint32_t NbRemovedSurfaces   = 0;
0059     uint32_t NbRemovedCurves     = 0;
0060     uint32_t NbNodesBefore       = 0;
0061     uint32_t NbNodesAfter        = 0;
0062     uint32_t NbUnmappedActiveDefs =
0063       0; //!< Active defs not present in any remap (orphans + drop-outs).
0064   };
0065 
0066   //! Run compaction with default options.
0067   //! @param[in,out] theGraph graph to compact
0068   //! @return compaction statistics
0069   [[nodiscard]] Standard_EXPORT static Result Perform(BRepGraph& theGraph);
0070 
0071   //! Run compaction with specified options.
0072   //! @param[in,out] theGraph graph to compact
0073   //! @param[in] theOptions compaction configuration
0074   //! @return compaction statistics
0075   [[nodiscard]] Standard_EXPORT static Result Perform(BRepGraph&     theGraph,
0076                                                       const Options& theOptions);
0077 
0078   BRepGraph_Compact() = delete;
0079 };
0080 
0081 #endif // _BRepGraph_Compact_HeaderFile