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 _BRepGraph_TopoView_HeaderFile
0015 #define _BRepGraph_TopoView_HeaderFile
0016 
0017 #include <BRepGraph.hxx>
0018 #include <BRepGraphInc_RepId.hxx>
0019 #include <BRepGraphInc_Definition.hxx>
0020 #include <BRepGraphInc_Relations.hxx>
0021 #include <BRepGraphInc_Representation.hxx>
0022 #include <GeomAdaptor_TransformedCurve.hxx>
0023 #include <GeomAdaptor_TransformedSurface.hxx>
0024 #include <NCollection_LinearVector.hxx>
0025 #include <TopLoc_Location.hxx>
0026 
0027 class Adaptor3d_CurveOnSurface;
0028 class Geom_Surface;
0029 class Geom_Curve;
0030 class Geom2d_Curve;
0031 class Poly_Triangulation;
0032 class BRepGraph_FacesOfEdge;
0033 class BRepGraph_WiresOfEdge;
0034 
0035 //! @brief Unified read-only view over topology definitions, adjacency, and representations.
0036 //!
0037 //! Provides topology definition lookup, representation lookup, read-only
0038 //! adjacency queries, and assembly classification over the incidence-table
0039 //! model stored in BRepGraph.
0040 //! Obtained via BRepGraph::Topo().
0041 //!
0042 //! ## Soft-deletion convention
0043 //! Per-kind count methods (Faces().Nb(), Edges().Nb(), etc.) return totals
0044 //! including soft-removed nodes. Prefer per-kind NbActive() variants for
0045 //! traversal and validation code that should ignore removed entities.
0046 //! Definition accessors (Face, Edge, etc.) do not filter removed nodes - callers should check
0047 //! IsRemoved() if needed.
0048 //!
0049 //! ## TopoView vs RefsView naming
0050 //! TopoView accessors take definition IDs (BRepGraph_FaceId, BRepGraph_ShellId, etc.)
0051 //! and return definition structs (FaceDef, ShellDef). RefsView accessors take
0052 //! reference IDs (BRepGraph_FaceRefId, BRepGraph_ShellRefId) and return
0053 //! reference-entry structs carrying per-use orientation and location.
0054 //!
0055 //! Relations() is the single entry point for ordered topology relation containers.
0056 //! Adjacency helpers return references only into existing relation storage.
0057 //! Ref-owned parent links are exposed as reference-id containers; callers resolve
0058 //! parent definitions through RefsView entries or typed iterators.
0059 class BRepGraph::TopoView
0060 {
0061 public:
0062   //! @brief Face-oriented topology queries.
0063   class FaceOps
0064   {
0065   public:
0066     //! Return the total number of face definitions (including soft-removed).
0067     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0068 
0069     //! Return the number of active (non-soft-removed) face definitions.
0070     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0071 
0072     //! Return the first valid face identifier for iteration.
0073     [[nodiscard]] BRepGraph_FaceId StartId() const { return BRepGraph_FaceId::Start(); }
0074 
0075     //! Return the past-the-end face identifier (one past the last valid id).
0076     [[nodiscard]] BRepGraph_FaceId EndId() const { return BRepGraph_FaceId(Nb()); }
0077 
0078     //! Return the definition struct for the given face.
0079     //! @param[in] theFace typed face identifier
0080     [[nodiscard]] Standard_EXPORT const BRepGraphInc::FaceDef& Definition(
0081       const BRepGraph_FaceId theFace) const;
0082 
0083     //! Return the relation struct (adjacency lists) for the given face.
0084     //! @param[in] theFace typed face identifier
0085     [[nodiscard]] Standard_EXPORT const BRepGraphInc::FaceRelations& Relations(
0086       const BRepGraph_FaceId theFace) const;
0087 
0088     //! Return the surface handle for the given face.
0089     //! May be null if the face has no surface representation.
0090     //! @param[in] theFace typed face identifier
0091     [[nodiscard]] Standard_EXPORT occ::handle<Geom_Surface> Surface(
0092       const BRepGraph_FaceId theFace) const;
0093 
0094     //! Return the active triangulation for the given face.
0095     //! Returns null if the face has no triangulation or it has been invalidated.
0096     //! @param[in] theFace typed face identifier
0097     [[nodiscard]] Standard_EXPORT occ::handle<Poly_Triangulation> ActiveTriangulation(
0098       const BRepGraph_FaceId theFace) const;
0099 
0100   private:
0101     friend class TopoView;
0102 
0103     explicit FaceOps(BRepGraph* theGraph)
0104         : myGraph(theGraph)
0105     {
0106     }
0107 
0108     BRepGraph* myGraph;
0109   };
0110 
0111   //! @brief Edge-oriented topology queries.
0112   class EdgeOps
0113   {
0114   public:
0115     //! Return the total number of edge definitions (including soft-removed).
0116     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0117 
0118     //! Return the number of active (non-soft-removed) edge definitions.
0119     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0120 
0121     //! Return the first valid edge identifier for iteration.
0122     [[nodiscard]] BRepGraph_EdgeId StartId() const { return BRepGraph_EdgeId::Start(); }
0123 
0124     //! Return the past-the-end edge identifier (one past the last valid id).
0125     [[nodiscard]] BRepGraph_EdgeId EndId() const { return BRepGraph_EdgeId(Nb()); }
0126 
0127     //! Return the definition struct for the given edge.
0128     //! @param[in] theEdge typed edge identifier
0129     [[nodiscard]] Standard_EXPORT const BRepGraphInc::EdgeDef& Definition(
0130       const BRepGraph_EdgeId theEdge) const;
0131 
0132     //! Return the relation struct (adjacency lists) for the given edge.
0133     //! @param[in] theEdge typed edge identifier
0134     [[nodiscard]] Standard_EXPORT const BRepGraphInc::EdgeRelations& Relations(
0135       const BRepGraph_EdgeId theEdge) const;
0136 
0137     //! Return the number of active faces adjacent to the given edge through active coedges.
0138     //! @param[in] theEdge typed edge definition identifier
0139     //! @return active adjacent face count
0140     [[nodiscard]] Standard_EXPORT uint32_t NbFaces(const BRepGraph_EdgeId theEdge) const;
0141 
0142     //! Return an iterator over active wires that reference the given edge through active coedges.
0143     //! @param[in] theEdge typed edge definition identifier
0144     //! @return iterator positioned at the first active wire, or at end if none exists
0145     [[nodiscard]] Standard_EXPORT BRepGraph_WiresOfEdge
0146       WiresOf(const BRepGraph_EdgeId theEdge) const;
0147 
0148     //! Return an iterator over active wires from a stored edge-coedge relation index.
0149     //! @param[in] theEdge       typed edge definition identifier
0150     //! @param[in] theStartIndex zero-based index in EdgeRelations::CoEdgeIds to resume from
0151     //! @return iterator positioned at the first active wire at or after theStartIndex
0152     [[nodiscard]] Standard_EXPORT BRepGraph_WiresOfEdge WiresOf(const BRepGraph_EdgeId theEdge,
0153                                                                 const uint32_t theStartIndex) const;
0154 
0155     //! Return an iterator over active faces adjacent to the given edge through active coedges.
0156     //! @param[in] theEdge typed edge definition identifier
0157     //! @return iterator positioned at the first active face, or at end if none exists
0158     [[nodiscard]] Standard_EXPORT BRepGraph_FacesOfEdge
0159       FacesOf(const BRepGraph_EdgeId theEdge) const;
0160 
0161     //! Return an iterator over active faces from a stored edge-coedge relation index.
0162     //! @param[in] theEdge       typed edge definition identifier
0163     //! @param[in] theStartIndex zero-based index in EdgeRelations::CoEdgeIds to resume from
0164     //! @return iterator positioned at the first active face at or after theStartIndex
0165     [[nodiscard]] Standard_EXPORT BRepGraph_FacesOfEdge FacesOf(const BRepGraph_EdgeId theEdge,
0166                                                                 const uint32_t theStartIndex) const;
0167 
0168     //! Return the coedges that reference the given edge.
0169     //! @param[in] theEdge typed edge identifier
0170     [[nodiscard]] Standard_EXPORT const NCollection_LinearVector<BRepGraph_CoEdgeId>& CoEdges(
0171       const BRepGraph_EdgeId theEdge) const;
0172 
0173     //! Return the 3D curve handle for the given edge.
0174     //! May be null if the edge has no 3D curve representation.
0175     //! @param[in] theEdge typed edge identifier
0176     [[nodiscard]] Standard_EXPORT occ::handle<Geom_Curve> Curve3D(
0177       const BRepGraph_EdgeId theEdge) const;
0178 
0179   private:
0180     friend class TopoView;
0181 
0182     explicit EdgeOps(BRepGraph* theGraph)
0183         : myGraph(theGraph)
0184     {
0185     }
0186 
0187     BRepGraph* myGraph;
0188   };
0189 
0190   //! @brief Vertex-oriented topology queries.
0191   class VertexOps
0192   {
0193   public:
0194     //! Return the total number of vertex definitions (including soft-removed).
0195     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0196 
0197     //! Return the number of active (non-soft-removed) vertex definitions.
0198     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0199 
0200     //! Return the first valid vertex identifier for iteration.
0201     [[nodiscard]] BRepGraph_VertexId StartId() const { return BRepGraph_VertexId::Start(); }
0202 
0203     //! Return the past-the-end vertex identifier (one past the last valid id).
0204     [[nodiscard]] BRepGraph_VertexId EndId() const { return BRepGraph_VertexId(Nb()); }
0205 
0206     //! Return the definition struct for the given vertex.
0207     //! @param[in] theVertex typed vertex identifier
0208     [[nodiscard]] Standard_EXPORT const BRepGraphInc::VertexDef& Definition(
0209       const BRepGraph_VertexId theVertex) const;
0210 
0211     //! Return the relation struct (adjacency lists) for the given vertex.
0212     //! @param[in] theVertex typed vertex identifier
0213     [[nodiscard]] Standard_EXPORT const BRepGraphInc::VertexRelations& Relations(
0214       const BRepGraph_VertexId theVertex) const;
0215 
0216     //! Return the edges incident to the given vertex.
0217     //! @param[in] theVertex typed vertex identifier
0218     [[nodiscard]] Standard_EXPORT const NCollection_LinearVector<BRepGraph_EdgeId>& Edges(
0219       const BRepGraph_VertexId theVertex) const;
0220 
0221   private:
0222     friend class TopoView;
0223 
0224     explicit VertexOps(BRepGraph* theGraph)
0225         : myGraph(theGraph)
0226     {
0227     }
0228 
0229     BRepGraph* myGraph;
0230   };
0231 
0232   //! @brief Wire-oriented topology queries.
0233   class WireOps
0234   {
0235   public:
0236     //! Return the total number of wire definitions (including soft-removed).
0237     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0238 
0239     //! Return the number of active (non-soft-removed) wire definitions.
0240     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0241 
0242     //! Return the first valid wire identifier for iteration.
0243     [[nodiscard]] BRepGraph_WireId StartId() const { return BRepGraph_WireId::Start(); }
0244 
0245     //! Return the past-the-end wire identifier (one past the last valid id).
0246     [[nodiscard]] BRepGraph_WireId EndId() const { return BRepGraph_WireId(Nb()); }
0247 
0248     //! Return the definition struct for the given wire.
0249     //! @param[in] theWire typed wire identifier
0250     [[nodiscard]] Standard_EXPORT const BRepGraphInc::WireDef& Definition(
0251       const BRepGraph_WireId theWire) const;
0252 
0253     //! Return the relation struct (adjacency lists) for the given wire.
0254     //! @param[in] theWire typed wire identifier
0255     [[nodiscard]] Standard_EXPORT const BRepGraphInc::WireRelations& Relations(
0256       const BRepGraph_WireId theWire) const;
0257 
0258   private:
0259     friend class TopoView;
0260 
0261     explicit WireOps(BRepGraph* theGraph)
0262         : myGraph(theGraph)
0263     {
0264     }
0265 
0266     BRepGraph* myGraph;
0267   };
0268 
0269   //! @brief Shell-oriented topology queries.
0270   class ShellOps
0271   {
0272   public:
0273     //! Return the total number of shell definitions (including soft-removed).
0274     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0275 
0276     //! Return the number of active (non-soft-removed) shell definitions.
0277     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0278 
0279     //! Return the first valid shell identifier for iteration.
0280     [[nodiscard]] BRepGraph_ShellId StartId() const { return BRepGraph_ShellId::Start(); }
0281 
0282     //! Return the past-the-end shell identifier (one past the last valid id).
0283     [[nodiscard]] BRepGraph_ShellId EndId() const { return BRepGraph_ShellId(Nb()); }
0284 
0285     //! Return the definition struct for the given shell.
0286     //! @param[in] theShell typed shell identifier
0287     [[nodiscard]] Standard_EXPORT const BRepGraphInc::ShellDef& Definition(
0288       const BRepGraph_ShellId theShell) const;
0289 
0290     //! Return the relation struct (adjacency lists) for the given shell.
0291     //! @param[in] theShell typed shell identifier
0292     [[nodiscard]] Standard_EXPORT const BRepGraphInc::ShellRelations& Relations(
0293       const BRepGraph_ShellId theShell) const;
0294 
0295   private:
0296     friend class TopoView;
0297 
0298     explicit ShellOps(BRepGraph* theGraph)
0299         : myGraph(theGraph)
0300     {
0301     }
0302 
0303     BRepGraph* myGraph;
0304   };
0305 
0306   //! @brief Solid-oriented topology queries.
0307   class SolidOps
0308   {
0309   public:
0310     //! Return the total number of solid definitions (including soft-removed).
0311     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0312 
0313     //! Return the number of active (non-soft-removed) solid definitions.
0314     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0315 
0316     //! Return the first valid solid identifier for iteration.
0317     [[nodiscard]] BRepGraph_SolidId StartId() const { return BRepGraph_SolidId::Start(); }
0318 
0319     //! Return the past-the-end solid identifier (one past the last valid id).
0320     [[nodiscard]] BRepGraph_SolidId EndId() const { return BRepGraph_SolidId(Nb()); }
0321 
0322     //! Return the definition struct for the given solid.
0323     //! @param[in] theSolid typed solid identifier
0324     [[nodiscard]] Standard_EXPORT const BRepGraphInc::SolidDef& Definition(
0325       const BRepGraph_SolidId theSolid) const;
0326 
0327     //! Return the relation struct (adjacency lists) for the given solid.
0328     //! @param[in] theSolid typed solid identifier
0329     [[nodiscard]] Standard_EXPORT const BRepGraphInc::SolidRelations& Relations(
0330       const BRepGraph_SolidId theSolid) const;
0331 
0332   private:
0333     friend class TopoView;
0334 
0335     explicit SolidOps(BRepGraph* theGraph)
0336         : myGraph(theGraph)
0337     {
0338     }
0339 
0340     BRepGraph* myGraph;
0341   };
0342 
0343   //! @brief Coedge-oriented topology and representation queries.
0344   class CoEdgeOps
0345   {
0346   public:
0347     //! Return the total number of coedge definitions (including soft-removed).
0348     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0349 
0350     //! Return the number of active (non-soft-removed) coedge definitions.
0351     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0352 
0353     //! Return the first valid coedge identifier for iteration.
0354     [[nodiscard]] BRepGraph_CoEdgeId StartId() const { return BRepGraph_CoEdgeId::Start(); }
0355 
0356     //! Return the past-the-end coedge identifier (one past the last valid id).
0357     [[nodiscard]] BRepGraph_CoEdgeId EndId() const { return BRepGraph_CoEdgeId(Nb()); }
0358 
0359     //! Return the definition struct for the given coedge.
0360     //! @param[in] theCoEdge typed coedge identifier
0361     [[nodiscard]] Standard_EXPORT const BRepGraphInc::CoEdgeDef& Definition(
0362       const BRepGraph_CoEdgeId theCoEdge) const;
0363 
0364     //! Return the parent edge of the given coedge.
0365     //! @param[in] theCoEdge typed coedge identifier
0366     [[nodiscard]] Standard_EXPORT BRepGraph_EdgeId Edge(const BRepGraph_CoEdgeId theCoEdge) const;
0367 
0368     //! Return the face that owns the given coedge.
0369     //! @param[in] theCoEdge typed coedge identifier
0370     [[nodiscard]] Standard_EXPORT BRepGraph_FaceId Face(const BRepGraph_CoEdgeId theCoEdge) const;
0371 
0372     //! Return the wire that owns the given coedge.
0373     //! @param[in] theCoEdge typed coedge identifier
0374     [[nodiscard]] Standard_EXPORT BRepGraph_WireId Wire(const BRepGraph_CoEdgeId theCoEdge) const;
0375 
0376     //! Return the 2D PCurve handle for the given coedge.
0377     //! May be null if the coedge has no PCurve representation.
0378     //! @param[in] theCoEdge typed coedge identifier
0379     [[nodiscard]] Standard_EXPORT occ::handle<Geom2d_Curve> Curve2D(
0380       const BRepGraph_CoEdgeId theCoEdge) const;
0381 
0382   private:
0383     friend class TopoView;
0384 
0385     explicit CoEdgeOps(BRepGraph* theGraph)
0386         : myGraph(theGraph)
0387     {
0388     }
0389 
0390     BRepGraph* myGraph;
0391   };
0392 
0393   //! @brief Compound-oriented topology queries.
0394   class CompoundOps
0395   {
0396   public:
0397     //! Return the total number of compound definitions (including soft-removed).
0398     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0399 
0400     //! Return the number of active (non-soft-removed) compound definitions.
0401     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0402 
0403     //! Return the first valid compound identifier for iteration.
0404     [[nodiscard]] BRepGraph_CompoundId StartId() const { return BRepGraph_CompoundId::Start(); }
0405 
0406     //! Return the past-the-end compound identifier (one past the last valid id).
0407     [[nodiscard]] BRepGraph_CompoundId EndId() const { return BRepGraph_CompoundId(Nb()); }
0408 
0409     //! Return the definition struct for the given compound.
0410     //! @param[in] theCompound typed compound identifier
0411     [[nodiscard]] Standard_EXPORT const BRepGraphInc::CompoundDef& Definition(
0412       const BRepGraph_CompoundId theCompound) const;
0413 
0414     //! Return the relation struct (child references) for the given compound.
0415     //! @param[in] theCompound typed compound identifier
0416     [[nodiscard]] Standard_EXPORT const BRepGraphInc::CompoundRelations& Relations(
0417       const BRepGraph_CompoundId theCompound) const;
0418 
0419   private:
0420     friend class TopoView;
0421 
0422     explicit CompoundOps(BRepGraph* theGraph)
0423         : myGraph(theGraph)
0424     {
0425     }
0426 
0427     BRepGraph* myGraph;
0428   };
0429 
0430   //! @brief Comp-solid oriented topology queries.
0431   class CompSolidOps
0432   {
0433   public:
0434     //! Return the total number of comp-solid definitions (including soft-removed).
0435     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0436 
0437     //! Return the number of active (non-soft-removed) comp-solid definitions.
0438     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0439 
0440     //! Return the first valid comp-solid identifier for iteration.
0441     [[nodiscard]] BRepGraph_CompSolidId StartId() const { return BRepGraph_CompSolidId::Start(); }
0442 
0443     //! Return the past-the-end comp-solid identifier (one past the last valid id).
0444     [[nodiscard]] BRepGraph_CompSolidId EndId() const { return BRepGraph_CompSolidId(Nb()); }
0445 
0446     //! Return the definition struct for the given comp-solid.
0447     //! @param[in] theCompSolid typed comp-solid identifier
0448     [[nodiscard]] Standard_EXPORT const BRepGraphInc::CompSolidDef& Definition(
0449       const BRepGraph_CompSolidId theCompSolid) const;
0450 
0451     //! Return the relation struct (child solids) for the given comp-solid.
0452     //! @param[in] theCompSolid typed comp-solid identifier
0453     [[nodiscard]] Standard_EXPORT const BRepGraphInc::CompSolidRelations& Relations(
0454       const BRepGraph_CompSolidId theCompSolid) const;
0455 
0456   private:
0457     friend class TopoView;
0458 
0459     explicit CompSolidOps(BRepGraph* theGraph)
0460         : myGraph(theGraph)
0461     {
0462     }
0463 
0464     BRepGraph* myGraph;
0465   };
0466 
0467   //! @brief Product-oriented raw assembly queries.
0468   class ProductOps
0469   {
0470   public:
0471     //! Return the total number of product definitions (including soft-removed).
0472     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0473 
0474     //! Return the number of active (non-soft-removed) product definitions.
0475     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0476 
0477     //! Return the first valid product identifier for iteration.
0478     [[nodiscard]] BRepGraph_ProductId StartId() const { return BRepGraph_ProductId::Start(); }
0479 
0480     //! Return the past-the-end product identifier (one past the last valid id).
0481     [[nodiscard]] BRepGraph_ProductId EndId() const { return BRepGraph_ProductId(Nb()); }
0482 
0483     //! Return the definition struct for the given product.
0484     //! @param[in] theProduct typed product definition identifier
0485     [[nodiscard]] Standard_EXPORT const BRepGraphInc::ProductDef& Definition(
0486       const BRepGraph_ProductId theProduct) const;
0487 
0488     //! Return the relation struct (occurrences, shape root) for the given product.
0489     //! @param[in] theProduct typed product definition identifier
0490     [[nodiscard]] Standard_EXPORT const BRepGraphInc::ProductRelations& Relations(
0491       const BRepGraph_ProductId theProduct) const;
0492 
0493     //! Return the topology root NodeId for the given product.
0494     //! For assemblies (no topology root) returns an invalid NodeId.
0495     //! @param[in] theProduct typed product definition identifier
0496     [[nodiscard]] Standard_EXPORT BRepGraph_NodeId
0497       ShapeRoot(const BRepGraph_ProductId theProduct) const;
0498 
0499     //! True if the product is an assembly (has active child occurrences and no topology root).
0500     //! @param[in] theProduct typed product definition identifier
0501     [[nodiscard]] Standard_EXPORT bool IsAssembly(const BRepGraph_ProductId theProduct) const;
0502 
0503     //! True if the product is a part (has a valid topology root).
0504     //! @param[in] theProduct typed product definition identifier
0505     [[nodiscard]] Standard_EXPORT bool IsPart(const BRepGraph_ProductId theProduct) const;
0506 
0507     //! Return the topology root NodeId for a part product.
0508     //! For assemblies (no topology root) returns an invalid NodeId.
0509     //! @param[in] theProduct typed product definition identifier
0510     [[nodiscard]] Standard_EXPORT BRepGraph_NodeId
0511       ShapeRootNode(const BRepGraph_ProductId theProduct) const;
0512 
0513     //! Number of active child occurrences of a product.
0514     //! @param[in] theProduct typed product definition identifier
0515     [[nodiscard]] Standard_EXPORT uint32_t NbComponents(const BRepGraph_ProductId theProduct) const;
0516 
0517     //! Return the i-th active child occurrence identifier of a product.
0518     //! @param[in] theProduct typed product definition identifier
0519     //! @param[in] theComponentIdx zero-based active occurrence index within the product
0520     [[nodiscard]] Standard_EXPORT BRepGraph_OccurrenceId
0521       Component(const BRepGraph_ProductId theProduct, const int theComponentIdx) const;
0522 
0523   private:
0524     friend class TopoView;
0525 
0526     explicit ProductOps(BRepGraph* theGraph)
0527         : myGraph(theGraph)
0528     {
0529     }
0530 
0531     BRepGraph* myGraph;
0532   };
0533 
0534   //! @brief Occurrence-oriented raw assembly queries.
0535   class OccurrenceOps
0536   {
0537   public:
0538     //! Return the total number of occurrence definitions (including soft-removed).
0539     [[nodiscard]] Standard_EXPORT uint32_t Nb() const;
0540 
0541     //! Return the number of active (non-soft-removed) occurrence definitions.
0542     [[nodiscard]] Standard_EXPORT uint32_t NbActive() const;
0543 
0544     //! Return the first valid occurrence identifier for iteration.
0545     [[nodiscard]] BRepGraph_OccurrenceId StartId() const { return BRepGraph_OccurrenceId::Start(); }
0546 
0547     //! Return the past-the-end occurrence identifier (one past the last valid id).
0548     [[nodiscard]] BRepGraph_OccurrenceId EndId() const { return BRepGraph_OccurrenceId(Nb()); }
0549 
0550     //! Return the definition struct for the given occurrence.
0551     //! @param[in] theOccurrence typed occurrence identifier
0552     [[nodiscard]] Standard_EXPORT const BRepGraphInc::OccurrenceDef& Definition(
0553       const BRepGraph_OccurrenceId theOccurrence) const;
0554 
0555     //! Return the relation struct (parent, placement) for the given occurrence.
0556     //! @param[in] theOccurrence typed occurrence identifier
0557     [[nodiscard]] Standard_EXPORT const BRepGraphInc::OccurrenceRelations& Relations(
0558       const BRepGraph_OccurrenceId theOccurrence) const;
0559 
0560     //! Return the product that this occurrence instantiates.
0561     //! @param[in] theOccurrence typed occurrence identifier
0562     [[nodiscard]] Standard_EXPORT BRepGraph_ProductId
0563       Product(const BRepGraph_OccurrenceId theOccurrence) const;
0564 
0565     //! Return the parent product that owns this occurrence.
0566     //! @param[in] theOccurrence typed occurrence identifier
0567     [[nodiscard]] Standard_EXPORT BRepGraph_ProductId
0568       ParentProduct(const BRepGraph_OccurrenceId theOccurrence) const;
0569     //! Return the local placement of an occurrence (OccurrenceRef::LocalLocation).
0570     //! This is the placement relative to the parent product, not the global placement.
0571     //! For global placement, use ChildExplorer with cumulative location tracking.
0572     //! @param[in] theOccurrence typed occurrence identifier
0573     //! @return OccurrenceRef::LocalLocation, or identity if not found
0574     [[nodiscard]] Standard_EXPORT TopLoc_Location
0575       OccurrenceLocation(const BRepGraph_OccurrenceId theOccurrence) const;
0576 
0577   private:
0578     friend class TopoView;
0579 
0580     explicit OccurrenceOps(BRepGraph* theGraph)
0581         : myGraph(theGraph)
0582     {
0583     }
0584 
0585     BRepGraph* myGraph;
0586   };
0587 
0588   //! @brief Generic topology and assembly count / meta queries.
0589   class GenOps
0590   {
0591   public:
0592     //! Return the base definition pointer for any topology node (polymorphic).
0593     //! Returns null if the node id is invalid, out of range, or soft-removed.
0594     //! @param[in] theId node identifier (any kind)
0595     [[nodiscard]] Standard_EXPORT const BRepGraphInc::BaseDef* TopoEntity(
0596       const BRepGraph_NodeId theId) const;
0597 
0598     //! Return the compound (child) reference identifiers that point to the given node.
0599     //! @param[in] theChild node identifier
0600     [[nodiscard]] Standard_EXPORT const NCollection_LinearVector<BRepGraph_ChildRefId>&
0601                                         CompoundRefIds(const BRepGraph_NodeId theChild) const;
0602 
0603     //! Return the occurrence reference identifiers that point to the given node.
0604     //! @param[in] theChild node identifier
0605     [[nodiscard]] Standard_EXPORT const NCollection_LinearVector<BRepGraph_OccurrenceRefId>&
0606                                         OccurrenceRefIds(const BRepGraph_NodeId theChild) const;
0607 
0608     //! True if the node has at least one compound parent.
0609     //! @param[in] theNode node identifier
0610     [[nodiscard]] Standard_EXPORT bool HasCompoundParents(const BRepGraph_NodeId theNode) const;
0611 
0612     //! True if the node has at least one occurrence parent.
0613     //! @param[in] theNode node identifier
0614     [[nodiscard]] Standard_EXPORT bool HasOccurrenceParents(const BRepGraph_NodeId theNode) const;
0615 
0616     //! Return the total number of nodes across all topology kinds (including soft-removed).
0617     [[nodiscard]] Standard_EXPORT uint32_t NbNodes() const;
0618 
0619     //! Return the number of node definitions of the specified kind (including soft-removed).
0620     [[nodiscard]] Standard_EXPORT uint32_t Nb(const BRepGraph_NodeId::Kind theKind) const;
0621 
0622     //! Return true if the node id kind and index are within storage bounds.
0623     [[nodiscard]] Standard_EXPORT bool IsValid(const BRepGraph_NodeId theNode) const;
0624 
0625     //! Return true if the node id is valid and not soft-removed.
0626     [[nodiscard]] Standard_EXPORT bool IsActive(const BRepGraph_NodeId theNode) const;
0627 
0628     //! Return true if the given node is invalid or has been soft-removed.
0629     //! @param[in] theNode node identifier
0630     [[nodiscard]] Standard_EXPORT bool IsRemoved(const BRepGraph_NodeId theNode) const;
0631 
0632   private:
0633     friend class TopoView;
0634 
0635     explicit GenOps(BRepGraph* theGraph)
0636         : myGraph(theGraph)
0637     {
0638     }
0639 
0640     BRepGraph* myGraph;
0641   };
0642 
0643   //! @brief Analytic geometry representation queries.
0644   class GeometryOps
0645   {
0646   public:
0647     //! Return the total number of face surface representations (including soft-removed).
0648     [[nodiscard]] Standard_EXPORT uint32_t NbFaceSurfaces() const;
0649 
0650     //! Return the total number of edge 3D curve representations (including soft-removed).
0651     [[nodiscard]] Standard_EXPORT uint32_t NbEdgeCurves3D() const;
0652 
0653     //! Return the total number of coedge 2D PCurve representations (including soft-removed).
0654     [[nodiscard]] Standard_EXPORT uint32_t NbCoEdgeCurves2D() const;
0655 
0656     //! Return the number of active (non-soft-removed) face surface representations.
0657     [[nodiscard]] Standard_EXPORT uint32_t NbActiveFaceSurfaces() const;
0658 
0659     //! Return the number of active (non-soft-removed) edge 3D curve representations.
0660     [[nodiscard]] Standard_EXPORT uint32_t NbActiveEdgeCurves3D() const;
0661 
0662     //! Return the number of active (non-soft-removed) coedge 2D PCurve representations.
0663     [[nodiscard]] Standard_EXPORT uint32_t NbActiveCoEdgeCurves2D() const;
0664 
0665   private:
0666     friend class TopoView;
0667 
0668     explicit GeometryOps(BRepGraph* theGraph)
0669         : myGraph(theGraph)
0670     {
0671     }
0672 
0673     BRepGraph* myGraph;
0674   };
0675 
0676   //! Grouped face-oriented queries.
0677   [[nodiscard]] const FaceOps& Faces() const { return myFaces; }
0678 
0679   //! Grouped edge-oriented queries.
0680   [[nodiscard]] const EdgeOps& Edges() const { return myEdges; }
0681 
0682   //! Grouped vertex-oriented queries.
0683   [[nodiscard]] const VertexOps& Vertices() const { return myVertices; }
0684 
0685   //! Grouped wire-oriented queries.
0686   [[nodiscard]] const WireOps& Wires() const { return myWires; }
0687 
0688   //! Grouped shell-oriented queries.
0689   [[nodiscard]] const ShellOps& Shells() const { return myShells; }
0690 
0691   //! Grouped solid-oriented queries.
0692   [[nodiscard]] const SolidOps& Solids() const { return mySolids; }
0693 
0694   //! Grouped coedge-oriented queries.
0695   [[nodiscard]] const CoEdgeOps& CoEdges() const { return myCoEdges; }
0696 
0697   //! Grouped compound-oriented queries.
0698   [[nodiscard]] const CompoundOps& Compounds() const { return myCompounds; }
0699 
0700   //! Grouped comp-solid oriented queries.
0701   [[nodiscard]] const CompSolidOps& CompSolids() const { return myCompSolids; }
0702 
0703   //! Grouped product-oriented queries.
0704   [[nodiscard]] const ProductOps& Products() const { return myProducts; }
0705 
0706   //! Grouped occurrence-oriented queries.
0707   [[nodiscard]] const OccurrenceOps& Occurrences() const { return myOccurrences; }
0708 
0709   //! Grouped generic topology and assembly counts / meta queries.
0710   [[nodiscard]] const GenOps& Gen() const { return myGen; }
0711 
0712   //! Grouped analytic geometry representation queries.
0713   [[nodiscard]] const GeometryOps& Geometry() const { return myGeometry; }
0714 
0715   //! Representations use dense 0-based indexing. Iterate through grouped accessors:
0716   //! @code
0717   //!   for (BRepGraph_FaceId aFId = aGraph.Topo().Faces().StartId();
0718   //!        aFId < aGraph.Topo().Faces().EndId(); aFId = aFId.Next())
0719   //!   {
0720   //!     occ::handle<Geom_Surface> aSurf = aGraph.Topo().Faces().Surface(aFId);
0721   //!   }
0722   //! @endcode
0723 
0724 private:
0725   friend class BRepGraph;
0726   friend struct BRepGraph_Data;
0727   friend class BRepGraph_Tool;
0728 
0729   explicit TopoView(BRepGraph* theGraph)
0730       : myGraph(theGraph),
0731         myFaces(theGraph),
0732         myEdges(theGraph),
0733         myVertices(theGraph),
0734         myWires(theGraph),
0735         myShells(theGraph),
0736         mySolids(theGraph),
0737         myCoEdges(theGraph),
0738         myCompounds(theGraph),
0739         myCompSolids(theGraph),
0740         myProducts(theGraph),
0741         myOccurrences(theGraph),
0742         myGen(theGraph),
0743         myGeometry(theGraph)
0744   {
0745   }
0746 
0747   BRepGraph*    myGraph;
0748   FaceOps       myFaces;
0749   EdgeOps       myEdges;
0750   VertexOps     myVertices;
0751   WireOps       myWires;
0752   ShellOps      myShells;
0753   SolidOps      mySolids;
0754   CoEdgeOps     myCoEdges;
0755   CompoundOps   myCompounds;
0756   CompSolidOps  myCompSolids;
0757   ProductOps    myProducts;
0758   OccurrenceOps myOccurrences;
0759   GenOps        myGen;
0760   GeometryOps   myGeometry;
0761 };
0762 
0763 #endif // _BRepGraph_TopoView_HeaderFile