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_Deduplicate_HeaderFile
0015 #define _BRepGraph_Deduplicate_HeaderFile
0016 
0017 #include <BRepGraph.hxx>
0018 #include <BRepGraph_NodeId.hxx>
0019 #include <NCollection_LinearVector.hxx>
0020 #include <Precision.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 //! @brief Deep geometry deduplication algorithm over an existing BRepGraph.
0024 //!
0025 //! This algorithm canonicalizes deep-equal geometry references (surfaces and
0026 //! 3D curves) using GeomHash hashers. It updates face/edge definition links to
0027 //! canonical geometry nodes and can record lineage in graph history.
0028 //!
0029 //! First implementation intentionally does not merge edge/face definitions yet.
0030 class BRepGraph_Deduplicate
0031 {
0032 public:
0033   DEFINE_STANDARD_ALLOC
0034 
0035   //! Configuration for graph deduplication run.
0036   struct Options
0037   {
0038     bool   AnalyzeOnly           = false;
0039     bool   HistoryMode           = true;
0040     bool   MergeEntitiesWhenSafe = false;
0041     double CompTolerance         = Precision::Angular();
0042     double HashTolerance         = Precision::Confusion();
0043   };
0044 
0045   //! Result counters for diagnostics and tests.
0046   struct Result
0047   {
0048     uint32_t NbCanonicalSurfaces  = 0;
0049     uint32_t NbCanonicalCurves    = 0;
0050     uint32_t NbSurfaceRewrites    = 0;
0051     uint32_t NbCurveRewrites      = 0;
0052     uint32_t NbNullifiedSurfaces  = 0;
0053     uint32_t NbNullifiedCurves    = 0;
0054     uint32_t NbHistoryRecords     = 0;
0055     bool     IsEntityMergeApplied = false;
0056 
0057     //! Topology definition merge counters (active when MergeEntitiesWhenSafe = true).
0058     uint32_t NbMergedVertices        = 0;
0059     uint32_t NbMergedEdges           = 0;
0060     uint32_t NbMergedWires           = 0;
0061     uint32_t NbMergedFaces           = 0;
0062     uint32_t NbReorderedWires        = 0;
0063     uint32_t NbToleranceOrderedWires = 0;
0064     uint32_t NbPartialOrderedWires   = 0;
0065 
0066     NCollection_LinearVector<BRepGraph_FaceId> AffectedFaces; //!< Faces whose SurfNodeId changed.
0067     NCollection_LinearVector<BRepGraph_EdgeId> AffectedEdges; //!< Edges whose CurveNodeId changed.
0068   };
0069 
0070   //! Run deduplication on a built graph.
0071   //! @param[in,out] theGraph graph to update
0072   //! @return dedup statistics
0073   [[nodiscard]] Standard_EXPORT static Result Perform(BRepGraph& theGraph);
0074 
0075   //! Run deduplication on a built graph.
0076   //! @param[in,out] theGraph graph to update
0077   //! @param[in] theOptions dedup configuration
0078   //! @return dedup statistics
0079   [[nodiscard]] Standard_EXPORT static Result Perform(BRepGraph&     theGraph,
0080                                                       const Options& theOptions);
0081 
0082   BRepGraph_Deduplicate() = delete;
0083 
0084 private:
0085   static void CanonicalizeWireOrders(BRepGraph& theGraph, Result& theResult);
0086 };
0087 
0088 #endif // _BRepGraph_Deduplicate_HeaderFile