Back to home page

EIC code displayed by LXR

 
 

    


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

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 _BRepGraphInc_Definition_HeaderFile
0015 #define _BRepGraphInc_Definition_HeaderFile
0016 
0017 #include <BRepGraph_NodeId.hxx>
0018 #include <BRepGraphInc_ParityOrientation.hxx>
0019 #include <BRepGraphInc_RepId.hxx>
0020 #include <BRepGraph_RefId.hxx>
0021 #include <BRepGraphInc_Instance.hxx>
0022 #include <GeomAbs_Shape.hxx>
0023 #include <gp_Pnt.hxx>
0024 #include <gp_Pnt2d.hxx>
0025 
0026 //! @brief Definition structs for the incidence-table topology model.
0027 //!
0028 //! Each definition holds intrinsic geometry properties. Ordered child
0029 //! incidence lives in BRepGraphInc_Relations and reusable parent/child usage
0030 //! edges live in reference records.
0031 namespace BRepGraphInc
0032 {
0033 
0034 //! Fields shared by every entity.
0035 struct BaseDef
0036 {
0037   using TypeId = BRepGraph_NodeId;
0038 
0039   //! Persistent per-kind UID counter value.
0040   //! 0 = invalid sentinel (not yet allocated). Valid UIDs start at 1.
0041   //! Kind is implicit from the concrete struct type (VertexDef, EdgeDef, etc.).
0042   uint32_t UID = 0;
0043 
0044   //! Own-data mutation counter, incremented ONLY when the entity's own
0045   //! definition fields change (tolerance, point, flags, etc.).
0046   //! NOT incremented by descendant changes.
0047   //! Used by VersionStamp for persistent identity staleness detection.
0048   uint32_t OwnGen = 0;
0049 
0050   //! Subtree mutation counter, incremented when own data OR any descendant
0051   //! data changes. Propagated upward via markParentSubtreeGen().
0052   //! Used by TransientCache and shape cache for hierarchical freshness.
0053   uint32_t SubtreeGen = 0;
0054 
0055   //! Wave counter from the last propagation that visited this node.
0056   //! Used as a re-visit guard in markParentSubtreeGen() to prevent
0057   //! exponential blowup on diamond topologies. Compared against
0058   //! BRepGraphInc_Storage::myPropagationWave.
0059   uint32_t LastPropWave = 0;
0060 };
0061 
0062 //! Vertex definition: 3D point + tolerance.
0063 struct VertexDef : public BaseDef
0064 {
0065   using TypeId = BRepGraph_VertexId;
0066 
0067   //! 3D point in definition frame (raw BRep_TVertex::Pnt, without vertex-in-edge Location).
0068   gp_Pnt Point;
0069 
0070   //! Tolerance from BRep_TVertex.
0071   double Tolerance = 0.0;
0072 };
0073 
0074 //! Edge entity: parameter range, boundary vertices.
0075 //! Geometry (curve, polygon) accessed via owned use records.
0076 //! Degeneracy, closure, SameRange, and SameParameter are derived from
0077 //! current topology and geometry via BRepGraph_CacheDerivedState.
0078 struct EdgeDef : public BaseDef
0079 {
0080   using TypeId = BRepGraph_EdgeId;
0081 
0082   BRepGraph_EdgeCurve3DRepId Curve3DRepId; //!< Owned 3D curve use id (invalid for degenerate edges)
0083 
0084   double Tolerance = 0.0; //!< Tolerance from BRep_TEdge
0085 
0086   BRepGraph_VertexRefId StartVertexRefId; //!< Start vertex reference
0087   BRepGraph_VertexRefId EndVertexRefId;   //!< End vertex reference
0088 
0089   BRepGraph_EdgePolygon3DRepId Polygon3DRepId; //!< Owned 3D polygon use id
0090 };
0091 
0092 //! CoEdge entity: use of an edge on a specific face, owns PCurve data.
0093 //!
0094 //! Each coedge represents one edge-face binding with its parametric curve.
0095 //! Wires reference coedges rather than edges directly.
0096 //! Seam edges produce two coedges on the same face with opposite Orientation;
0097 //! the seam relation is queryable via BRepGraph_Tool::CoEdge::SeamPair.
0098 struct CoEdgeDef : public BaseDef
0099 {
0100   using TypeId = BRepGraph_CoEdgeId;
0101 
0102   BRepGraph_WireId  ParentWireId; //!< Ordered owner wire
0103   BRepGraph_EdgeId  ChildEdgeId;  //!< Connected reusable edge definition
0104   BRepGraph_FaceId  FaceId;       //!< Face this coedge belongs to (invalid for free wires)
0105   ParityOrientation Orientation = TopAbs_FORWARD; //!< Orientation relative to parent edge
0106 
0107   BRepGraph_CoEdgeCurve2DRepId      Curve2DRepId;      //!< Owned 2D curve use id
0108   BRepGraph_CoEdgePolygon2DRepId    Polygon2DRepId;    //!< Owned 2D polygon use id
0109   BRepGraph_CoEdgePolygonOnTriRepId PolygonOnTriRepId; //!< Owned polygon-on-triangulation use id
0110 };
0111 
0112 //! Wire entity: ordered coedge sequence.
0113 //! Wire closure is derived from the ordered coedge chain via BRepGraph_CacheDerivedState.
0114 struct WireDef : public BaseDef
0115 {
0116   using TypeId = BRepGraph_WireId;
0117 };
0118 
0119 //! Face entity: surface, triangulations, wires.
0120 struct FaceDef : public BaseDef
0121 {
0122   using TypeId = BRepGraph_FaceId;
0123 
0124   BRepGraph_FaceSurfaceRepId SurfaceRepId; //!< Owned surface use id
0125   BRepGraph_FaceTriangulationRepId
0126     TriangulationRepId; //!< Owned triangulation use id (persistent/imported)
0127 
0128   double Tolerance = 0.0; //!< Face tolerance
0129 };
0130 
0131 //! Shell entity.
0132 //! Shell closure is derived from face-boundary edge incidence via BRepGraph_CacheDerivedState.
0133 struct ShellDef : public BaseDef
0134 {
0135   using TypeId = BRepGraph_ShellId;
0136 };
0137 
0138 //! Solid entity.
0139 struct SolidDef : public BaseDef
0140 {
0141   using TypeId = BRepGraph_SolidId;
0142 };
0143 
0144 //! Compound entity.
0145 struct CompoundDef : public BaseDef
0146 {
0147   using TypeId = BRepGraph_CompoundId;
0148 };
0149 
0150 //! Comp-solid entity.
0151 struct CompSolidDef : public BaseDef
0152 {
0153   using TypeId = BRepGraph_CompSolidId;
0154 };
0155 
0156 //! Product entity: reusable shape definition (part or assembly).
0157 //! Children are managed uniformly via ProductRelations::OccurrenceRefIds:
0158 //! - A part product has one occurrence whose ChildNodeId is a topology root node.
0159 //! - An assembly product has occurrences whose ChildNodeId values are other products.
0160 //! Products carry no location or orientation - those live on references.
0161 struct ProductDef : public BaseDef
0162 {
0163   using TypeId = BRepGraph_ProductId;
0164 };
0165 
0166 //! Occurrence entity: reference to a child node (topology root or product).
0167 //! Parent products are determined from ProductRelations owner arrays.
0168 //! Placement lives on OccurrenceRef::LocalLocation (definitions never carry location).
0169 //! Path-based traversal (BRepGraph_UsagePath) resolves DAG paths without stored
0170 //! parent-occurrence pointers.
0171 struct OccurrenceDef : public BaseDef
0172 {
0173   using TypeId = BRepGraph_OccurrenceId;
0174 
0175   BRepGraph_NodeId ChildNodeId; //!< Referenced child node (topology root or product)
0176 };
0177 
0178 } // namespace BRepGraphInc
0179 
0180 #endif // _BRepGraphInc_Definition_HeaderFile