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_Tool_HeaderFile
0015 #define _BRepGraph_Tool_HeaderFile
0016 
0017 #include <BRepGraph.hxx>
0018 #include <BRepGraphInc_Instance.hxx>
0019 #include <Geom2dAdaptor_Curve.hxx>
0020 #include <GeomAdaptor_TransformedCurve.hxx>
0021 #include <GeomAdaptor_TransformedSurface.hxx>
0022 #include <GeomAbs_Shape.hxx>
0023 #include <NCollection_LinearVector.hxx>
0024 #include <Standard.hxx>
0025 #include <TopAbs_Orientation.hxx>
0026 #include <gp_Pnt.hxx>
0027 #include <gp_Pnt2d.hxx>
0028 
0029 #include <utility>
0030 
0031 class Adaptor3d_CurveOnSurface;
0032 
0033 //! Centralized geometry access for BRepGraph - analogue of BRep_Tool.
0034 //!
0035 //! Geometry in BRepGraph is stored in the definition frame (representation
0036 //! Location baked via applyRepresentationLocation). Instance Locations live
0037 //! on topology Instance/Ref structs (VertexInstance, CoEdgeInstance, WireInstance,
0038 //! FaceInstance, ShellInstance, SolidInstance, OccurrenceInstance). This class applies
0039 //! ref Locations automatically when accessing 3D geometry.
0040 //! Instance structs are lightweight read-only projections produced during
0041 //! traversal, while Ref structs are stored reference entries from RefsView;
0042 //! this API accepts whichever form naturally carries the required context for
0043 //! the queried property.
0044 //!
0045 //! Methods are grouped by topology kind via nested classes:
0046 //! BRepGraph_Tool::Vertex, Edge, CoEdge, Face, Wire, Shell.
0047 class BRepGraph_Tool
0048 {
0049 public:
0050   using VertexUsage = BRepGraphInc::VertexInstance;
0051   using CoEdgeUsage = BRepGraphInc::CoEdgeInstance;
0052   using FaceUsage   = BRepGraphInc::FaceInstance;
0053   using WireUsage   = BRepGraphInc::WireInstance;
0054   using ShellUsage  = BRepGraphInc::ShellInstance;
0055 
0056   //! @brief Vertex geometry accessors.
0057   //!
0058   //! Provides 3D point retrieval (with or without Location applied) and
0059   //! tolerance access.
0060   class Vertex
0061   {
0062   public:
0063     //! Resolves a vertex reference id to a lightweight usage value.
0064     //! @param[in] theGraph     source graph
0065     //! @param[in] theVertexRef typed vertex reference identifier
0066     //! @return vertex usage, or invalid usage if the reference is invalid or removed
0067     [[nodiscard]] Standard_EXPORT static VertexUsage Usage(
0068       const BRepGraph&            theGraph,
0069       const BRepGraph_VertexRefId theVertexRef);
0070 
0071     //! Returns the vertex 3D point with VertexUsage Location applied.
0072     //! @param[in] theGraph  source graph
0073     //! @param[in] theRef    vertex incidence reference carrying Location
0074     //! @return transformed 3D point
0075     [[nodiscard]] Standard_EXPORT static gp_Pnt Pnt(const BRepGraph&   theGraph,
0076                                                     const VertexUsage& theRef);
0077 
0078     //! Returns the vertex 3D point in definition frame (no Location applied).
0079     //! @param[in] theGraph  source graph
0080     //! @param[in] theVertex typed vertex definition identifier
0081     //! @return 3D point in definition frame
0082     [[nodiscard]] Standard_EXPORT static gp_Pnt Pnt(const BRepGraph&         theGraph,
0083                                                     const BRepGraph_VertexId theVertex);
0084 
0085     //! Returns the vertex 3D point with vertex reference location applied.
0086     //! @param[in] theGraph     source graph
0087     //! @param[in] theVertexRef typed vertex reference identifier
0088     //! @return transformed 3D point
0089     [[nodiscard]] Standard_EXPORT static gp_Pnt Pnt(const BRepGraph&            theGraph,
0090                                                     const BRepGraph_VertexRefId theVertexRef);
0091 
0092     //! Returns the vertex tolerance.
0093     //! @param[in] theGraph  source graph
0094     //! @param[in] theVertex typed vertex definition identifier
0095     //! @return tolerance value
0096     [[nodiscard]] Standard_EXPORT static double Tolerance(const BRepGraph&         theGraph,
0097                                                           const BRepGraph_VertexId theVertex);
0098 
0099     //! Returns the vertex tolerance by vertex reference identifier.
0100     //! @param[in] theGraph     source graph
0101     //! @param[in] theVertexRef typed vertex reference identifier
0102     //! @return tolerance value
0103     [[nodiscard]] Standard_EXPORT static double Tolerance(const BRepGraph&            theGraph,
0104                                                           const BRepGraph_VertexRefId theVertexRef);
0105 
0106     //! Returns the number of edges that reference this vertex.
0107     //! @param[in] theGraph  source graph
0108     //! @param[in] theVertex typed vertex definition identifier
0109     //! @return edge count
0110     [[nodiscard]] Standard_EXPORT static uint32_t NbEdges(const BRepGraph&         theGraph,
0111                                                           const BRepGraph_VertexId theVertex);
0112   };
0113 
0114   //! @brief Edge geometry, curve, and continuity accessors.
0115   //!
0116   //! Provides tolerance, degeneracy, and parameter flags; raw and
0117   //! location-adjusted 3D curve access; and PCurve lookup for edge-face
0118   //! contexts including seam edge support.
0119   class Edge
0120   {
0121   public:
0122     //! Returns the edge tolerance.
0123     //! @param[in] theGraph source graph
0124     //! @param[in] theEdge  typed edge definition identifier
0125     //! @return tolerance value
0126     [[nodiscard]] Standard_EXPORT static double Tolerance(const BRepGraph&       theGraph,
0127                                                           const BRepGraph_EdgeId theEdge);
0128 
0129     //! Returns true if the edge is degenerate, derived from current geometry.
0130     //! @param[in] theGraph source graph
0131     //! @param[in] theEdge  typed edge definition identifier
0132     //! @return true if degenerate
0133     [[nodiscard]] Standard_EXPORT static bool Degenerated(const BRepGraph&       theGraph,
0134                                                           const BRepGraph_EdgeId theEdge);
0135 
0136     //! Returns true if the edge forms a topological loop, derived from vertex topology.
0137     //! @param[in] theGraph source graph
0138     //! @param[in] theEdge  typed edge definition identifier
0139     //! @return true if closed
0140     [[nodiscard]] Standard_EXPORT static bool IsClosed(const BRepGraph&       theGraph,
0141                                                        const BRepGraph_EdgeId theEdge);
0142 
0143     //! Returns the 3D curve parameter range as (first, last).
0144     //! @param[in] theGraph source graph
0145     //! @param[in] theEdge  typed edge definition identifier
0146     //! @return pair of (first, last) parameters
0147     [[nodiscard]] Standard_EXPORT static std::pair<double, double> Range(
0148       const BRepGraph&       theGraph,
0149       const BRepGraph_EdgeId theEdge);
0150 
0151     //! Returns the start vertex reference id directly.
0152     //! @param[in] theGraph source graph
0153     //! @param[in] theEdge  typed edge definition identifier
0154     //! @return start vertex reference id
0155     [[nodiscard]] Standard_EXPORT static BRepGraph_VertexRefId StartVertexId(
0156       const BRepGraph&       theGraph,
0157       const BRepGraph_EdgeId theEdge);
0158 
0159     //! Returns the end vertex reference id directly.
0160     //! @param[in] theGraph source graph
0161     //! @param[in] theEdge  typed edge definition identifier
0162     //! @return end vertex reference id
0163     [[nodiscard]] Standard_EXPORT static BRepGraph_VertexRefId EndVertexId(
0164       const BRepGraph&       theGraph,
0165       const BRepGraph_EdgeId theEdge);
0166 
0167     //! Returns true if the edge has a 3D curve representation.
0168     //! @param[in] theGraph source graph
0169     //! @param[in] theEdge  typed edge definition identifier
0170     //! @return true if edge has a 3D curve
0171     [[nodiscard]] Standard_EXPORT static bool HasCurve(const BRepGraph&       theGraph,
0172                                                        const BRepGraph_EdgeId theEdge);
0173 
0174     //! Returns the raw 3D curve handle (definition frame, no copy).
0175     //! @param[in] theGraph source graph
0176     //! @param[in] theEdge  typed edge definition identifier
0177     //! @return curve handle, or null handle if no curve
0178     [[nodiscard]] Standard_EXPORT static const occ::handle<Geom_Curve>& Curve(
0179       const BRepGraph&       theGraph,
0180       const BRepGraph_EdgeId theEdge);
0181 
0182     //! Returns the transformed 3D curve handle via CoEdgeUsage (applies Location, may copy).
0183     //! @param[in] theGraph source graph
0184     //! @param[in] theRef   coedge incidence reference carrying Location
0185     //! @return transformed curve handle
0186     [[nodiscard]] Standard_EXPORT static occ::handle<Geom_Curve> Curve(const BRepGraph&   theGraph,
0187                                                                        const CoEdgeUsage& theRef);
0188 
0189     //! Returns the 3D curve adaptor in definition frame (identity Trsf).
0190     //! @param[in] theGraph source graph
0191     //! @param[in] theEdge  typed edge definition identifier
0192     //! @return curve adaptor, or empty adaptor if no curve
0193     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedCurve CurveAdaptor(
0194       const BRepGraph&       theGraph,
0195       const BRepGraph_EdgeId theEdge);
0196 
0197     //! Returns the 3D curve adaptor via CoEdgeUsage (applies edge-in-wire Location in Trsf).
0198     //! Falls back to CurveOnSurface when no 3D curve exists.
0199     //! @param[in] theGraph source graph
0200     //! @param[in] theRef   coedge incidence reference carrying Location
0201     //! @return curve adaptor with Location applied
0202     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedCurve CurveAdaptor(
0203       const BRepGraph&   theGraph,
0204       const CoEdgeUsage& theRef);
0205 
0206     //! Find an active edge by its boundary vertices.
0207     //! @param[in] theGraph source graph
0208     //! @param[in] theStartVertex start vertex to match
0209     //! @param[in] theEndVertex end vertex to match
0210     //! @param[in] theToIgnoreOrientation when true, also matches the reverse vertex order
0211     //! @return edge id, or invalid if no active edge matches
0212     [[nodiscard]] Standard_EXPORT static BRepGraph_EdgeId FindByVertices(
0213       const BRepGraph&         theGraph,
0214       const BRepGraph_VertexId theStartVertex,
0215       const BRepGraph_VertexId theEndVertex,
0216       const bool               theToIgnoreOrientation = false);
0217 
0218     //! Find an active coedge carrying PCurve data for the given edge-face use.
0219     //! @param[in] theGraph source graph
0220     //! @param[in] theEdge  edge definition to match
0221     //! @param[in] theFace  face definition to match
0222     //! @return matching coedge id, or invalid if the edge/face pair has no active PCurve coedge
0223     [[nodiscard]] Standard_EXPORT static BRepGraph_CoEdgeId FindPCurveCoEdgeId(
0224       const BRepGraph&       theGraph,
0225       const BRepGraph_EdgeId theEdge,
0226       const BRepGraph_FaceId theFace);
0227 
0228     //! Find an active PCurve coedge for the given edge-face use and preferred orientation.
0229     //! @param[in] theGraph      source graph
0230     //! @param[in] theEdge       edge definition to match
0231     //! @param[in] theFace       face definition to match
0232     //! @param[in] theOrientation preferred coedge orientation
0233     //! @return exact orientation match when present; otherwise the first active PCurve
0234     //!         coedge on the edge-face pair; invalid if there is no active PCurve coedge
0235     [[nodiscard]] Standard_EXPORT static BRepGraph_CoEdgeId FindPCurveCoEdgeId(
0236       const BRepGraph&         theGraph,
0237       const BRepGraph_EdgeId   theEdge,
0238       const BRepGraph_FaceId   theFace,
0239       const TopAbs_Orientation theOrientation);
0240 
0241     //! Find an active coedge for the given edge-face use.
0242     //! @param[in] theGraph source graph
0243     //! @param[in] theEdge  edge definition to match
0244     //! @param[in] theFace  face definition to match
0245     //! @return matching coedge id, or invalid if the edge/face pair has no active coedge
0246     [[nodiscard]] Standard_EXPORT static BRepGraph_CoEdgeId FindCoEdgeId(
0247       const BRepGraph&       theGraph,
0248       const BRepGraph_EdgeId theEdge,
0249       const BRepGraph_FaceId theFace);
0250 
0251     //! Find an active coedge for the given edge-face use and preferred orientation.
0252     //! @param[in] theGraph      source graph
0253     //! @param[in] theEdge       edge definition to match
0254     //! @param[in] theFace       face definition to match
0255     //! @param[in] theOrientation preferred coedge orientation
0256     //! @return exact orientation match when present; otherwise the first active coedge on the
0257     //!         edge-face pair; invalid if there is no active coedge for the edge-face pair
0258     [[nodiscard]] Standard_EXPORT static BRepGraph_CoEdgeId FindCoEdgeId(
0259       const BRepGraph&         theGraph,
0260       const BRepGraph_EdgeId   theEdge,
0261       const BRepGraph_FaceId   theFace,
0262       const TopAbs_Orientation theOrientation);
0263 
0264     //! Returns the number of faces that reference this edge via coedges.
0265     //! @param[in] theGraph source graph
0266     //! @param[in] theEdge  typed edge definition identifier
0267     //! @return face count
0268     [[nodiscard]] Standard_EXPORT static uint32_t NbFaces(const BRepGraph&       theGraph,
0269                                                           const BRepGraph_EdgeId theEdge);
0270 
0271     //! Returns true if the edge is shared by exactly two faces (manifold).
0272     //! @param[in] theGraph source graph
0273     //! @param[in] theEdge  typed edge definition identifier
0274     //! @return true if manifold
0275     [[nodiscard]] Standard_EXPORT static bool IsManifold(const BRepGraph&       theGraph,
0276                                                          const BRepGraph_EdgeId theEdge);
0277 
0278     //! Returns true if the edge belongs to exactly one face (boundary / free edge).
0279     //! @param[in] theGraph source graph
0280     //! @param[in] theEdge  typed edge definition identifier
0281     //! @return true if boundary
0282     [[nodiscard]] Standard_EXPORT static bool IsBoundary(const BRepGraph&       theGraph,
0283                                                          const BRepGraph_EdgeId theEdge);
0284 
0285     //! Returns true if the edge is a seam on the given face.
0286     //! @param[in] theGraph source graph
0287     //! @param[in] theEdge  typed edge definition identifier
0288     //! @param[in] theFace  typed face definition identifier
0289     //! @return true if the edge is a seam on this face
0290     [[nodiscard]] Standard_EXPORT static bool IsSeamOnFace(const BRepGraph&       theGraph,
0291                                                            const BRepGraph_EdgeId theEdge,
0292                                                            const BRepGraph_FaceId theFace);
0293 
0294     //! Returns a CurveOnSurface adaptor built from a CoEdgeUsage and face.
0295     //! @param[in] theGraph source graph
0296     //! @param[in] theRef   coedge incidence reference
0297     //! @param[in] theFace  typed face definition identifier
0298     //! @return adaptor handle, or null if PCurve or surface is missing
0299     [[nodiscard]] Standard_EXPORT static occ::handle<Adaptor3d_CurveOnSurface> CurveOnSurface(
0300       const BRepGraph&       theGraph,
0301       const CoEdgeUsage&     theRef,
0302       const BRepGraph_FaceId theFace);
0303   };
0304 
0305   //! @brief CoEdge (half-edge) parametric curve accessors.
0306   //!
0307   //! Provides PCurve retrieval, adaptor construction, UV endpoint
0308   //! access, and parameter range queries for coedge definitions.
0309   class CoEdge
0310   {
0311   public:
0312     //! Returns the coedge orientation relative to its parent edge.
0313     //! @param[in] theGraph  source graph
0314     //! @param[in] theCoEdge typed coedge definition identifier
0315     //! @return orientation enum
0316     [[nodiscard]] Standard_EXPORT static TopAbs_Orientation Orientation(
0317       const BRepGraph&         theGraph,
0318       const BRepGraph_CoEdgeId theCoEdge);
0319 
0320     //! Returns true if the coedge is REVERSED relative to its parent edge.
0321     //! Convenience shortcut for `Orientation(...) == TopAbs_REVERSED`.
0322     [[nodiscard]] Standard_EXPORT static bool IsReversed(const BRepGraph&         theGraph,
0323                                                          const BRepGraph_CoEdgeId theCoEdge);
0324 
0325     //! Returns the parent edge definition id this coedge uses.
0326     //! @param[in] theGraph  source graph
0327     //! @param[in] theCoEdge typed coedge definition identifier
0328     //! @return parent edge id (invalid for removed coedges)
0329     [[nodiscard]] Standard_EXPORT static BRepGraph_EdgeId EdgeOf(
0330       const BRepGraph&         theGraph,
0331       const BRepGraph_CoEdgeId theCoEdge);
0332 
0333     //! Returns the owning face definition id for this coedge.
0334     //! @param[in] theGraph  source graph
0335     //! @param[in] theCoEdge typed coedge definition identifier
0336     //! @return owning face id (invalid for free-wire coedges)
0337     [[nodiscard]] Standard_EXPORT static BRepGraph_FaceId FaceOf(
0338       const BRepGraph&         theGraph,
0339       const BRepGraph_CoEdgeId theCoEdge);
0340 
0341     //! Returns the seam-pair coedge for closed/seam edges.
0342     //! @param[in] theGraph  source graph
0343     //! @param[in] theCoEdge typed coedge definition identifier
0344     //! @return paired coedge id, or invalid if this coedge is not a seam half
0345     [[nodiscard]] Standard_EXPORT static BRepGraph_CoEdgeId SeamPair(
0346       const BRepGraph&         theGraph,
0347       const BRepGraph_CoEdgeId theCoEdge);
0348 
0349     //! Returns true if this coedge is one half of a seam pair.
0350     [[nodiscard]] Standard_EXPORT static bool IsSeam(const BRepGraph&         theGraph,
0351                                                      const BRepGraph_CoEdgeId theCoEdge);
0352 
0353     //! Returns true if the coedge has a PCurve representation.
0354     //! @param[in] theGraph  source graph
0355     //! @param[in] theCoEdge typed coedge definition identifier
0356     //! @return true if PCurve exists
0357     [[nodiscard]] Standard_EXPORT static bool HasPCurve(const BRepGraph&         theGraph,
0358                                                         const BRepGraph_CoEdgeId theCoEdge);
0359 
0360     //! Returns true if the coedge's PCurve parameter matches the 3D curve.
0361     //! @param[in] theGraph  source graph
0362     //! @param[in] theCoEdge typed coedge definition identifier
0363     //! @return true if same parameter
0364     [[nodiscard]] Standard_EXPORT static bool SameParameter(const BRepGraph&         theGraph,
0365                                                             const BRepGraph_CoEdgeId theCoEdge);
0366 
0367     //! Returns true if the coedge's PCurve range equals the 3D curve range.
0368     //! @param[in] theGraph  source graph
0369     //! @param[in] theCoEdge typed coedge definition identifier
0370     //! @return true if same range
0371     [[nodiscard]] Standard_EXPORT static bool SameRange(const BRepGraph&         theGraph,
0372                                                         const BRepGraph_CoEdgeId theCoEdge);
0373 
0374     //! Returns the raw PCurve handle by coedge identifier (no Location - UV space).
0375     //! @param[in] theGraph  source graph
0376     //! @param[in] theCoEdge typed coedge definition identifier
0377     //! @return curve handle, or null handle if no PCurve
0378     [[nodiscard]] Standard_EXPORT static const occ::handle<Geom2d_Curve>& PCurve(
0379       const BRepGraph&         theGraph,
0380       const BRepGraph_CoEdgeId theCoEdge);
0381 
0382     //! Returns a PCurve adaptor by coedge identifier.
0383     //! If the coedge has a stored PCurve (Curve2DRepIdx >= 0), returns it directly.
0384     //! Otherwise, for planar face surfaces, computes the PCurve on-the-fly by projecting
0385     //! the edge's 3D curve onto the plane (CurveOnPlane), mirroring the behavior of
0386     //! BRep_Tool::CurveOnSurface for planar faces without stored PCurves.
0387     //! @param[in] theGraph  source graph
0388     //! @param[in] theCoEdge typed coedge definition identifier
0389     //! @return 2D curve adaptor, or empty adaptor if no PCurve and surface is not planar
0390     [[nodiscard]] Standard_EXPORT static Geom2dAdaptor_Curve PCurveAdaptor(
0391       const BRepGraph&         theGraph,
0392       const BRepGraph_CoEdgeId theCoEdge);
0393 
0394     //! Returns a PCurve adaptor from a CoEdgeUsage.
0395     //! @param[in] theGraph source graph
0396     //! @param[in] theRef   coedge incidence reference
0397     //! @return 2D curve adaptor
0398     [[nodiscard]] Standard_EXPORT static Geom2dAdaptor_Curve PCurveAdaptor(
0399       const BRepGraph&   theGraph,
0400       const CoEdgeUsage& theRef);
0401 
0402     //! Returns the UV endpoints from a CoEdge as (UV1, UV2).
0403     //! @param[in] theGraph  source graph
0404     //! @param[in] theCoEdge typed coedge definition identifier
0405     //! @return pair of 2D points at parameter first and last
0406     [[nodiscard]] Standard_EXPORT static std::pair<gp_Pnt2d, gp_Pnt2d> UVPoints(
0407       const BRepGraph&         theGraph,
0408       const BRepGraph_CoEdgeId theCoEdge);
0409 
0410     //! Returns the PCurve parameter range as (first, last).
0411     //! @param[in] theGraph  source graph
0412     //! @param[in] theCoEdge typed coedge definition identifier
0413     //! @return pair of (first, last) parameters
0414     [[nodiscard]] Standard_EXPORT static std::pair<double, double> Range(
0415       const BRepGraph&         theGraph,
0416       const BRepGraph_CoEdgeId theCoEdge);
0417   };
0418 
0419   //! @brief Face surface and property accessors.
0420   //!
0421   //! Provides tolerance, natural restriction flag, surface handle
0422   //! and adaptor access (with optional UV bounds), and outer wire lookup.
0423   class Face
0424   {
0425   public:
0426     //! Resolves a face reference id to a lightweight usage value.
0427     //! @param[in] theGraph   source graph
0428     //! @param[in] theFaceRef typed face reference identifier
0429     //! @return face usage, or invalid usage if the reference is invalid or removed
0430     [[nodiscard]] Standard_EXPORT static FaceUsage Usage(const BRepGraph&          theGraph,
0431                                                          const BRepGraph_FaceRefId theFaceRef);
0432 
0433     //! Returns the face tolerance.
0434     //! @param[in] theGraph source graph
0435     //! @param[in] theFace  typed face definition identifier
0436     //! @return tolerance value
0437     [[nodiscard]] Standard_EXPORT static double Tolerance(const BRepGraph&       theGraph,
0438                                                           const BRepGraph_FaceId theFace);
0439 
0440     //! Returns the face tolerance by face reference identifier.
0441     [[nodiscard]] Standard_EXPORT static double Tolerance(const BRepGraph&          theGraph,
0442                                                           const BRepGraph_FaceRefId theFaceRef);
0443 
0444     //! Returns true if the face has a surface representation.
0445     //! @param[in] theGraph source graph
0446     //! @param[in] theFace  typed face definition identifier
0447     //! @return true if surface exists
0448     [[nodiscard]] Standard_EXPORT static bool HasSurface(const BRepGraph&       theGraph,
0449                                                          const BRepGraph_FaceId theFace);
0450 
0451     //! Returns true if the face reference resolves to a face with a surface.
0452     [[nodiscard]] Standard_EXPORT static bool HasSurface(const BRepGraph&          theGraph,
0453                                                          const BRepGraph_FaceRefId theFaceRef);
0454 
0455     //! Returns the outer wire definition id directly.
0456     //! @param[in] theGraph source graph
0457     //! @param[in] theFace  typed face definition identifier
0458     //! @return outer wire id, or invalid if the face has no wire
0459     [[nodiscard]] Standard_EXPORT static BRepGraph_WireId OuterWire(const BRepGraph&       theGraph,
0460                                                                     const BRepGraph_FaceId theFace);
0461 
0462     //! Returns the outer wire definition id by face reference identifier.
0463     [[nodiscard]] Standard_EXPORT static BRepGraph_WireId OuterWire(
0464       const BRepGraph&          theGraph,
0465       const BRepGraph_FaceRefId theFaceRef);
0466 
0467     //! Returns the raw surface handle (definition frame, no copy).
0468     //! @param[in] theGraph source graph
0469     //! @param[in] theFace  typed face definition identifier
0470     //! @return surface handle, or null handle if no surface
0471     [[nodiscard]] Standard_EXPORT static const occ::handle<Geom_Surface>& Surface(
0472       const BRepGraph&       theGraph,
0473       const BRepGraph_FaceId theFace);
0474 
0475     //! Returns the raw surface handle by face reference identifier.
0476     [[nodiscard]] Standard_EXPORT static const occ::handle<Geom_Surface>& Surface(
0477       const BRepGraph&          theGraph,
0478       const BRepGraph_FaceRefId theFaceRef);
0479 
0480     //! Returns a surface adaptor in definition frame.
0481     //! @param[in] theGraph source graph
0482     //! @param[in] theFace  typed face definition identifier
0483     //! @return surface adaptor, or empty adaptor if no surface
0484     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0485       const BRepGraph&       theGraph,
0486       const BRepGraph_FaceId theFace);
0487 
0488     //! Returns a surface adaptor with FaceUsage Location applied.
0489     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0490       const BRepGraph& theGraph,
0491       const FaceUsage& theRef);
0492 
0493     //! Returns a surface adaptor by face reference identifier with reference Location applied.
0494     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0495       const BRepGraph&          theGraph,
0496       const BRepGraph_FaceRefId theFaceRef);
0497 
0498     //! Returns a surface adaptor with explicit UV bounds.
0499     //! @param[in] theGraph  source graph
0500     //! @param[in] theFace   typed face definition identifier
0501     //! @param[in] theUFirst first U parameter
0502     //! @param[in] theULast  last U parameter
0503     //! @param[in] theVFirst first V parameter
0504     //! @param[in] theVLast  last V parameter
0505     //! @return surface adaptor with bounds, or empty adaptor if no surface
0506     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0507       const BRepGraph&       theGraph,
0508       const BRepGraph_FaceId theFace,
0509       const double           theUFirst,
0510       const double           theULast,
0511       const double           theVFirst,
0512       const double           theVLast);
0513 
0514     //! Returns a surface adaptor with explicit UV bounds and FaceUsage Location applied.
0515     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0516       const BRepGraph& theGraph,
0517       const FaceUsage& theRef,
0518       const double     theUFirst,
0519       const double     theULast,
0520       const double     theVFirst,
0521       const double     theVLast);
0522 
0523     //! Returns a surface adaptor with explicit UV bounds by face reference identifier.
0524     [[nodiscard]] Standard_EXPORT static GeomAdaptor_TransformedSurface SurfaceAdaptor(
0525       const BRepGraph&          theGraph,
0526       const BRepGraph_FaceRefId theFaceRef,
0527       const double              theUFirst,
0528       const double              theULast,
0529       const double              theVFirst,
0530       const double              theVLast);
0531 
0532     //! Returns the number of wire references on the face (outer + holes).
0533     //! @param[in] theGraph source graph
0534     //! @param[in] theFace  typed face definition identifier
0535     //! @return wire count (includes removed refs)
0536     [[nodiscard]] Standard_EXPORT static uint32_t NbWires(const BRepGraph&       theGraph,
0537                                                           const BRepGraph_FaceId theFace);
0538 
0539     //! Returns the number of wire references by face reference identifier.
0540     [[nodiscard]] Standard_EXPORT static uint32_t NbWires(const BRepGraph&          theGraph,
0541                                                           const BRepGraph_FaceRefId theFaceRef);
0542 
0543     //! Returns the UV parameter bounds of the face surface.
0544     //! Fills out-parameters with the surface bounds; all values are set to 0.0 if
0545     //! the face has no surface.
0546     //! @param[in]  theGraph  source graph
0547     //! @param[in]  theFace   typed face definition identifier
0548     //! @param[out] theUMin   minimum U parameter
0549     //! @param[out] theUMax   maximum U parameter
0550     //! @param[out] theVMin   minimum V parameter
0551     //! @param[out] theVMax   maximum V parameter
0552     Standard_EXPORT static void Bounds(const BRepGraph&       theGraph,
0553                                        const BRepGraph_FaceId theFace,
0554                                        double&                theUMin,
0555                                        double&                theUMax,
0556                                        double&                theVMin,
0557                                        double&                theVMax);
0558 
0559     //! Returns the UV parameter bounds by face reference identifier.
0560     Standard_EXPORT static void Bounds(const BRepGraph&          theGraph,
0561                                        const BRepGraph_FaceRefId theFaceRef,
0562                                        double&                   theUMin,
0563                                        double&                   theUMax,
0564                                        double&                   theVMin,
0565                                        double&                   theVMax);
0566   };
0567 
0568   //! @brief Wire property accessors.
0569   //!
0570   //! Provides wire closure, size, and ownership queries.
0571   //! For ordered coedge traversal, use BRepGraph_CoEdgesOfWire or
0572   //! TopoView::Wires().Relations(theWire).CoEdgeIds.
0573   class Wire
0574   {
0575   public:
0576     //! Resolves a wire reference id to a lightweight usage value.
0577     //! @param[in] theGraph   source graph
0578     //! @param[in] theWireRef typed wire reference identifier
0579     //! @return wire usage, or invalid usage if the reference is invalid or removed
0580     [[nodiscard]] Standard_EXPORT static WireUsage Usage(const BRepGraph&          theGraph,
0581                                                          const BRepGraph_WireRefId theWireRef);
0582 
0583     //! Returns true if the wire is topologically closed, derived from ordered coedge chain.
0584     //! @param[in] theGraph source graph
0585     //! @param[in] theWire  typed wire definition identifier
0586     //! @return true if closed
0587     [[nodiscard]] Standard_EXPORT static bool IsClosed(const BRepGraph&       theGraph,
0588                                                        const BRepGraph_WireId theWire);
0589 
0590     //! Returns true if the referenced wire is topologically closed.
0591     [[nodiscard]] Standard_EXPORT static bool IsClosed(const BRepGraph&          theGraph,
0592                                                        const BRepGraph_WireRefId theWireRef);
0593 
0594     //! Number of CoEdge usages in the wire (raw count: seam halves count twice,
0595     //! matching TopoDS_Iterator(wire) semantics).
0596     //! @param[in] theGraph source graph
0597     //! @param[in] theWire  typed wire definition identifier
0598     //! @return number of coedge entries
0599     [[nodiscard]] Standard_EXPORT static uint32_t NbCoEdges(const BRepGraph&       theGraph,
0600                                                             const BRepGraph_WireId theWire);
0601 
0602     //! Number of CoEdge usages in the referenced wire.
0603     [[nodiscard]] Standard_EXPORT static uint32_t NbCoEdges(const BRepGraph&          theGraph,
0604                                                             const BRepGraph_WireRefId theWireRef);
0605 
0606     //! Number of distinct underlying edges in the wire (seam halves count once).
0607     //! @param[in] theGraph source graph
0608     //! @param[in] theWire  typed wire definition identifier
0609     //! @return number of distinct ChildEdgeIds reachable from the wire's CoEdgeIds
0610     [[nodiscard]] Standard_EXPORT static uint32_t NbDistinctEdges(const BRepGraph&       theGraph,
0611                                                                   const BRepGraph_WireId theWire);
0612 
0613     //! Number of distinct underlying edges in the referenced wire.
0614     [[nodiscard]] Standard_EXPORT static uint32_t NbDistinctEdges(
0615       const BRepGraph&          theGraph,
0616       const BRepGraph_WireRefId theWireRef);
0617 
0618     //! Returns the first owning face for this wire via relation tables.
0619     //! Returns an invalid id if the wire has no owning face (free wire).
0620     //! @param[in] theGraph source graph
0621     //! @param[in] theWire  typed wire definition identifier
0622     //! @return owning face id, or invalid
0623     [[nodiscard]] Standard_EXPORT static BRepGraph_FaceId FaceOf(const BRepGraph&       theGraph,
0624                                                                  const BRepGraph_WireId theWire);
0625 
0626     //! Returns the first owning face for the referenced wire.
0627     [[nodiscard]] Standard_EXPORT static BRepGraph_FaceId FaceOf(
0628       const BRepGraph&          theGraph,
0629       const BRepGraph_WireRefId theWireRef);
0630 
0631     //! Returns true if this wire is the first active wire of its owning face.
0632     //! Scans WireRefs that reference this wire.
0633     //! Returns false for free wires (no owning face).
0634     //! @param[in] theGraph source graph
0635     //! @param[in] theWire  typed wire definition identifier
0636     //! @return true if outer wire
0637     [[nodiscard]] Standard_EXPORT static bool IsOuter(const BRepGraph&       theGraph,
0638                                                       const BRepGraph_WireId theWire);
0639 
0640     //! Returns true if the referenced wire is the outer wire of its owning face.
0641     [[nodiscard]] Standard_EXPORT static bool IsOuter(const BRepGraph&          theGraph,
0642                                                       const BRepGraph_WireRefId theWireRef);
0643   };
0644 
0645   //! @brief Shell property accessors.
0646   //!
0647   //! Provides shell closure and face count queries.
0648   class Shell
0649   {
0650   public:
0651     //! Resolves a shell reference id to a lightweight usage value.
0652     //! @param[in] theGraph    source graph
0653     //! @param[in] theShellRef typed shell reference identifier
0654     //! @return shell usage, or invalid usage if the reference is invalid or removed
0655     [[nodiscard]] Standard_EXPORT static ShellUsage Usage(const BRepGraph&           theGraph,
0656                                                           const BRepGraph_ShellRefId theShellRef);
0657 
0658     //! Returns true if the shell is topologically closed, derived from face-boundary edge
0659     //! incidence.
0660     //! @param[in] theGraph source graph
0661     //! @param[in] theShell typed shell definition identifier
0662     //! @return true if closed
0663     [[nodiscard]] Standard_EXPORT static bool IsClosed(const BRepGraph&        theGraph,
0664                                                        const BRepGraph_ShellId theShell);
0665 
0666     //! Returns true if the referenced shell is topologically closed.
0667     [[nodiscard]] Standard_EXPORT static bool IsClosed(const BRepGraph&           theGraph,
0668                                                        const BRepGraph_ShellRefId theShellRef);
0669 
0670     //! Returns the number of face references in the shell.
0671     //! @param[in] theGraph source graph
0672     //! @param[in] theShell typed shell definition identifier
0673     //! @return number of face entries (including removed)
0674     [[nodiscard]] Standard_EXPORT static uint32_t NbFaces(const BRepGraph&        theGraph,
0675                                                           const BRepGraph_ShellId theShell);
0676 
0677     //! Returns the number of face references in the referenced shell.
0678     [[nodiscard]] Standard_EXPORT static uint32_t NbFaces(const BRepGraph&           theGraph,
0679                                                           const BRepGraph_ShellRefId theShellRef);
0680   };
0681 
0682   BRepGraph_Tool() = delete;
0683 };
0684 
0685 #endif // _BRepGraph_Tool_HeaderFile