|
|
|||
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_Copy_HeaderFile 0015 #define _BRepGraph_Copy_HeaderFile 0016 0017 #include <BRepGraph.hxx> 0018 #include <BRepGraph_NodeId.hxx> 0019 #include <BRepGraph_ShapesView.hxx> 0020 #include <Standard_DefineAlloc.hxx> 0021 0022 //! @brief Graph-to-graph deep copy. 0023 //! 0024 //! Produces a new BRepGraph from an existing one in a single bottom-up pass, 0025 //! avoiding the 5-7 traversals of BRepTools_Modifier used by BRepBuilderAPI_Copy. 0026 //! 0027 //! Two copy modes: 0028 //! - External: source and target are different graphs. Target receives the copied data. 0029 //! - Self-copy: source and target are the same graph. The specified sub-graph is 0030 //! duplicated with new entity IDs; shared dependencies (geometry, vertices referenced 0031 //! from outside the sub-graph) are preserved. 0032 //! 0033 //! Geometry and mesh policies are controlled by the GeomPolicy and MeshPolicy enums. 0034 //! 0035 //! @note Check the return value for success: Perform returns bool, 0036 //! CopyNode returns the mapped root NodeId (invalid on failure). 0037 //! 0038 //! ## Typical usage 0039 //! @code 0040 //! BRepGraph aGraph; 0041 //! aGraph.Shapes().Add(myShape); 0042 //! BRepGraph aCopy; 0043 //! BRepGraph_Copy::Perform(aGraph, aCopy); 0044 //! TopoDS_Shape aShape = aCopy.Shapes().Shape(); 0045 //! @endcode 0046 class BRepGraph_Copy 0047 { 0048 public: 0049 DEFINE_STANDARD_ALLOC 0050 0051 //! Policy for handling geometry handles (Geom_Curve, Geom_Surface, Geom2d_Curve). 0052 enum class GeomPolicy 0053 { 0054 Copy, //!< Deep-clone geometry handles; result is fully independent 0055 Share, //!< Reuse source geometry handles; only topology is duplicated 0056 Drop //!< Pure topology: edges carry no curves, faces carry no surfaces 0057 }; 0058 0059 //! Policy for handling mesh data (Poly_Triangulation, Poly_Polygon3D, 0060 //! Poly_PolygonOnTriangulation). 0061 enum class MeshPolicy 0062 { 0063 Copy, //!< Deep-clone mesh data; independent result 0064 Share, //!< Reuse source mesh handle references; no cloning 0065 Drop //!< Discard all mesh data on copied entities 0066 }; 0067 0068 //! Policy for handling transient runtime cache services. 0069 enum class CachePolicy 0070 { 0071 Drop, //!< Do not copy runtime cache services or entries. 0072 CopyFresh //!< Copy fresh, remappable runtime cache entries. 0073 }; 0074 0075 //! Copy the entire source graph into the target graph. 0076 //! 0077 //! Self-copy (theSourceGraph == theTargetGraph): 0078 //! Identity no-op, returns true immediately. 0079 //! 0080 //! External copy to empty target (theTargetGraph.IsEmpty()): 0081 //! Uses identity-mapped fast path (old index == new index). 0082 //! 0083 //! External copy to non-empty target: 0084 //! Uses explicit mapping; IDs in theTargetGraph will differ from theSourceGraph. 0085 //! Entities from theSourceGraph are appended to theTargetGraph. 0086 //! 0087 //! @param[in] theSourceGraph a pre-built BRepGraph (must not be empty) 0088 //! @param[in,out] theTargetGraph destination graph (may already contain data) 0089 //! @param[in] theGeomPolicy geometry handle policy (default: Copy) 0090 //! @param[in] theMeshPolicy mesh data policy (default: Copy) 0091 //! @return true on success, false on failure (empty source) 0092 Standard_EXPORT static bool Perform(const BRepGraph& theSourceGraph, 0093 BRepGraph& theTargetGraph, 0094 GeomPolicy theGeomPolicy = GeomPolicy::Copy, 0095 MeshPolicy theMeshPolicy = MeshPolicy::Copy, 0096 CachePolicy theCachePolicy = CachePolicy::Drop); 0097 0098 //! Copy a single node sub-graph of any kind (Face, Shell, Solid, Wire, Edge, Vertex, etc.). 0099 //! The target graph receives the specified node and all entities it references. 0100 //! 0101 //! External copy (theSourceGraph != theTargetGraph): 0102 //! New entities are appended to theTargetGraph. Entities already present 0103 //! in theTargetGraph are reused (not duplicated). 0104 //! 0105 //! Self-copy (theSourceGraph == theTargetGraph): 0106 //! The specified sub-graph is duplicated with new entity IDs within the same graph. 0107 //! Shared dependencies (vertices, edges referenced from outside the sub-graph) 0108 //! are preserved as-is. 0109 //! 0110 //! @param[in] theSourceGraph a pre-built BRepGraph 0111 //! @param[in,out] theTargetGraph destination graph (may already contain data) 0112 //! @param[in] theNodeId node identifier (any kind) 0113 //! @param[in] theGeomPolicy geometry handle policy (default: Copy) 0114 //! @param[in] theMeshPolicy mesh data policy (default: Copy) 0115 //! @return the mapped root NodeId in theTargetGraph, or invalid NodeId on failure 0116 [[nodiscard]] Standard_EXPORT static BRepGraph_NodeId CopyNode( 0117 const BRepGraph& theSourceGraph, 0118 BRepGraph& theTargetGraph, 0119 const BRepGraph_NodeId theNodeId, 0120 GeomPolicy theGeomPolicy = GeomPolicy::Copy, 0121 MeshPolicy theMeshPolicy = MeshPolicy::Copy, 0122 CachePolicy theCachePolicy = CachePolicy::Drop); 0123 0124 BRepGraph_Copy() = delete; 0125 }; 0126 0127 #endif // _BRepGraph_Copy_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|