|
|
|||
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_Transform_HeaderFile 0015 #define _BRepGraph_Transform_HeaderFile 0016 0017 #include <BRepGraph.hxx> 0018 #include <BRepGraph_Copy.hxx> 0019 #include <BRepGraph_NodeId.hxx> 0020 #include <BRepGraph_ShapesView.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <gp_Trsf.hxx> 0023 0024 //! @brief Graph-to-graph transformation. 0025 //! 0026 //! Applies a geometric transformation to vertex points and geometry node 0027 //! locations by copying into a target graph, then transforming in-place. 0028 //! 0029 //! Two geometry modes (matching BRepBuilderAPI_Transform semantics): 0030 //! - GeomPolicy::Copy (geometry-level): deep-copy geometry, create new 0031 //! transformed handles via Geom_Geometry::Transformed(), reset locations 0032 //! to identity. 0033 //! - GeomPolicy::Share (root-level): light-copy with shared geometry, apply 0034 //! transform via location modification only. 0035 //! 0036 //! Mesh handling (MeshPolicy parameter): 0037 //! - MeshPolicy::Drop (default for Transform): triangulations and polygons are 0038 //! discarded after a geometry-level transform and must be recomputed. 0039 //! - MeshPolicy::Copy: all mesh data (Poly_Triangulation on FaceDefs and the 0040 //! MeshLayer cache, Poly_Polygon3D on edges, Poly_PolygonOnTriangulation on 0041 //! coedges) is copied and transformed in sync with the geometry. 0042 //! In location-only mode the mesh data is copied as-is (nodes stay in the 0043 //! graph coordinate system, which is unaffected by a pure location compose). 0044 //! 0045 //! @note Check the return value for success: Perform returns bool, 0046 //! TransformNode returns the mapped root NodeId (invalid on failure). 0047 //! 0048 //! ## Typical usage 0049 //! @code 0050 //! BRepGraph aGraph; 0051 //! aGraph.Shapes().Add(myShape); 0052 //! gp_Trsf aTrsf; 0053 //! aTrsf.SetTranslation(gp_Vec(10.0, 0.0, 0.0)); 0054 //! BRepGraph aTransformed; 0055 //! BRepGraph_Transform::Perform(aGraph, aTransformed, aTrsf); 0056 //! TopoDS_Shape aShape = aTransformed.Shapes().Shape(); 0057 //! @endcode 0058 class BRepGraph_Transform 0059 { 0060 public: 0061 DEFINE_STANDARD_ALLOC 0062 0063 //! Transform the entire graph into a target graph. 0064 //! 0065 //! Self-transform (theSourceGraph == theTargetGraph): 0066 //! Applies transform in-place on theTargetGraph. 0067 //! 0068 //! External transform to empty target (theTargetGraph.IsEmpty()): 0069 //! Copies source into target, then transforms. 0070 //! 0071 //! External transform to non-empty target: 0072 //! Appends source entities into target with explicit mapping, then transforms. 0073 //! 0074 //! @param[in] theSourceGraph a pre-built BRepGraph (must not be empty) 0075 //! @param[in,out] theTargetGraph destination graph (may already contain data) 0076 //! @param[in] theTrsf the transformation to apply 0077 //! @param[in] theGeomPolicy geometry handle policy (default: Copy) 0078 //! @param[in] theMeshPolicy mesh data policy (default: Drop) 0079 //! @return true on success, false on failure (empty source, or Drop + 0080 //! geometry-modification-required) 0081 Standard_EXPORT static bool Perform( 0082 const BRepGraph& theSourceGraph, 0083 BRepGraph& theTargetGraph, 0084 const gp_Trsf& theTrsf, 0085 const BRepGraph_Copy::GeomPolicy theGeomPolicy = BRepGraph_Copy::GeomPolicy::Copy, 0086 const BRepGraph_Copy::MeshPolicy theMeshPolicy = BRepGraph_Copy::MeshPolicy::Drop); 0087 0088 //! Transform a single node sub-graph of any kind. 0089 //! Topology nodes are copied and transformed by baking the transform into their definitions. 0090 //! 0091 //! Self-transform (theSourceGraph == theTargetGraph): 0092 //! Duplicates the sub-graph with new entity IDs, then transforms the copy. 0093 //! 0094 //! External transform: 0095 //! Copies the sub-graph into theTargetGraph, then transforms. 0096 //! 0097 //! @param[in] theSourceGraph a pre-built BRepGraph 0098 //! @param[in,out] theTargetGraph destination graph (may already contain data) 0099 //! @param[in] theNodeId node identifier (any kind) 0100 //! @param[in] theTrsf the transformation to apply 0101 //! @param[in] theGeomPolicy geometry handle policy (default: Copy; Drop is invalid for topology) 0102 //! @param[in] theMeshPolicy mesh data policy (default: Drop) 0103 //! @return the mapped root NodeId in theTargetGraph, or invalid NodeId on failure 0104 [[nodiscard]] Standard_EXPORT static BRepGraph_NodeId TransformNode( 0105 const BRepGraph& theSourceGraph, 0106 BRepGraph& theTargetGraph, 0107 const BRepGraph_NodeId theNodeId, 0108 const gp_Trsf& theTrsf, 0109 const BRepGraph_Copy::GeomPolicy theGeomPolicy = BRepGraph_Copy::GeomPolicy::Copy, 0110 const BRepGraph_Copy::MeshPolicy theMeshPolicy = BRepGraph_Copy::MeshPolicy::Drop); 0111 0112 //! Apply an in-place location-only transform to a child reference. 0113 //! Composes theTrsf into ChildRef placement without copying any geometry. 0114 //! Cached mesh data on entities downstream of the moved ref is stored in the 0115 //! entity's local frame and is unaffected; callers that bake a world transform 0116 //! into a cache key own the invalidation responsibility. 0117 //! @note Only pure rotation/translation transforms (scale == 1) are supported. 0118 //! The method returns false if |scaleFactor| != 1. 0119 //! @param[in] theGraph the graph containing the reference 0120 //! @param[in] theRefId child reference to move 0121 //! @param[in] theTrsf the transformation to compose into the location 0122 //! @return true on success; false if the ref is invalid/removed or theTrsf has non-unit scale 0123 Standard_EXPORT static bool MoveRef(BRepGraph& theGraph, 0124 const BRepGraph_ChildRefId theRefId, 0125 const gp_Trsf& theTrsf); 0126 0127 //! Apply an in-place location-only transform to an occurrence reference. 0128 //! Composes theTrsf into OccurrenceRef placement without copying any geometry. 0129 //! @note Only pure rotation/translation transforms (scale == 1) are supported. 0130 //! @return true on success; false if the ref is invalid/removed or theTrsf has non-unit scale 0131 Standard_EXPORT static bool MoveRef(BRepGraph& theGraph, 0132 const BRepGraph_OccurrenceRefId theRefId, 0133 const gp_Trsf& theTrsf); 0134 0135 BRepGraph_Transform() = delete; 0136 0137 private: 0138 //! Apply location-only transform by storing per-node locations. 0139 static void applyLocationTransform(BRepGraph& theGraph, const gp_Trsf& theTrsf); 0140 }; 0141 0142 #endif // _BRepGraph_Transform_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|