// Copyright (c) 2026 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _BRepGraphInc_Instance_HeaderFile #define _BRepGraphInc_Instance_HeaderFile #include "BRepGraph_NodeId.hxx" #include "Standard_HashUtils.hxx" #include "TopAbs_Orientation.hxx" #include "TopLoc_Location.hxx" #include //! @file BRepGraphInc_Instance.hxx //! @brief Unified lightweight container binding a node identity with placement. //! //! Instance is the BRepGraph analogue of TopoDS_Shape: a lightweight value type //! that bundles a definition id with its location and orientation in context. //! //! Supports C++17 structured bindings (aggregate type): //! @code //! for (auto [aDefId, aLoc, anOri] : BRepGraph_ChildExplorer(aGraph, aRoot, Kind::Face)) //! { //! // ... //! } //! @endcode namespace BRepGraphInc { //! @brief Unified instance container template. //! //! Bundles a typed definition id with location and orientation. //! //! @tparam TypedIdT typed definition id (e.g. BRepGraph_FaceId, BRepGraph_NodeId). template struct Instance { TypedIdT DefId; TopLoc_Location Location; TopAbs_Orientation Orientation = TopAbs_FORWARD; //! Returns true if the instance references an existing definition id. [[nodiscard]] bool IsValid() const { return DefId.IsValid(); } }; using VertexInstance = Instance; using CoEdgeInstance = Instance; using WireInstance = Instance; using FaceInstance = Instance; using ShellInstance = Instance; using SolidInstance = Instance; using OccurrenceInstance = Instance; using CompoundInstance = Instance; using CompSolidInstance = Instance; using ProductInstance = Instance; //! NodeInstance is Instance. //! Returned by BRepGraph_ChildExplorer and BRepGraph_ParentExplorer //! with accumulated transforms from traversal root to the current node. //! Implicitly convertible from any typed Instance via BRepGraph_NodeId::Typed //! implicit conversion to BRepGraph_NodeId. using NodeInstance = Instance; } // namespace BRepGraphInc //! std::hash specialization for BRepGraphInc::Instance. template struct std::hash> { size_t operator()(const BRepGraphInc::Instance& theInstance) const noexcept { size_t aCombination[3]; aCombination[0] = std::hash{}(theInstance.DefId); aCombination[1] = theInstance.Location.HashCode(); aCombination[2] = opencascade::hash(static_cast(theInstance.Orientation)); return opencascade::hashBytes(aCombination, sizeof(aCombination)); } }; #endif // _BRepGraphInc_Instance_HeaderFile