|
|
|||
File indexing completed on 2026-09-13 09:17:43
0001 // Created on: 1998-06-03 0002 // Created by: data exchange team 0003 // Copyright (c) 1998-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _ShapeExtend_WireData_HeaderFile 0018 #define _ShapeExtend_WireData_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 0023 #include <TopoDS_Shape.hxx> 0024 #include <NCollection_Sequence.hxx> 0025 #include <NCollection_HSequence.hxx> 0026 #include <Standard_Integer.hxx> 0027 #include <Standard_Transient.hxx> 0028 #include <TColStd_PackedMapOfInteger.hxx> 0029 0030 class TopoDS_Wire; 0031 class TopoDS_Edge; 0032 class TopoDS_Shape; 0033 class TopoDS_Face; 0034 0035 //! This class provides a data structure necessary for work with the wire as with 0036 //! ordered list of edges, what is required for many algorithms. The advantage of 0037 //! this class is that it allows to work with wires which are not correct. 0038 //! The object of the class ShapeExtend_WireData can be initialized by 0039 //! TopoDS_Wire, and converted back to TopoDS_Wire. 0040 //! An edge in the wire is defined by its rank number. Operations of accessing, 0041 //! adding and removing edge at the given rank number are provided. On the whole 0042 //! wire, operations of circular permutation and reversing (both orientations of 0043 //! all edges and order of edges) are provided as well. 0044 //! This class also provides a method to check if the edge in the wire is a seam 0045 //! (if the wire lies on a face). 0046 //! This class is handled by reference. Such an approach gives the following advantages: 0047 //! 1. Sharing the object of this class strongly optimizes the processes of 0048 //! analysis and fixing performed in parallel on the wire stored in the form 0049 //! of this class. Fixing tool (e.g. ShapeFix_Wire) fixes problems one by 0050 //! one using analyzing tool (e.g. ShapeAnalysis_Wire). Sharing allows not 0051 //! to reinitialize each time the analyzing tool with modified 0052 //! ShapeExtend_WireData what consumes certain time. 0053 //! 2. No copying of contents. The object of ShapeExtend_WireData class has 0054 //! quite big size, returning it as a result of the function would cause 0055 //! additional copying of contents if this class were one handled by value. 0056 //! Moreover, this class is stored as a field in other classes which are 0057 //! they returned as results of functions, storing only a handle to 0058 //! ShapeExtend_WireData saves time and memory. 0059 class ShapeExtend_WireData : public Standard_Transient 0060 { 0061 0062 public: 0063 //! Empty constructor, creates empty wire with no edges 0064 Standard_EXPORT ShapeExtend_WireData(); 0065 0066 //! Constructor initializing the data from TopoDS_Wire. Calls Init(wire,chained). 0067 Standard_EXPORT ShapeExtend_WireData(const TopoDS_Wire& wire, 0068 const bool chained = true, 0069 const bool theManifoldMode = true); 0070 0071 //! Copies data from another WireData 0072 Standard_EXPORT void Init(const occ::handle<ShapeExtend_WireData>& other); 0073 0074 //! Loads an already existing wire 0075 //! If <chained> is True (default), edges are added in the 0076 //! sequence as they are explored by TopoDS_Iterator 0077 //! Else, if <chained> is False, wire is explored by 0078 //! BRepTools_WireExplorer and it is guaranteed that edges will 0079 //! be sequentially connected. 0080 //! Remark : In the latter case it can happen that not all edges 0081 //! will be found (because of limitations of 0082 //! BRepTools_WireExplorer for disconnected wires and wires 0083 //! with seam edges). 0084 Standard_EXPORT bool Init(const TopoDS_Wire& wire, 0085 const bool chained = true, 0086 const bool theManifoldMode = true); 0087 0088 //! Clears data about Wire. 0089 Standard_EXPORT void Clear(); 0090 0091 //! Computes the list of seam edges 0092 //! By default (direct call), computing is enforced 0093 //! For indirect call (from IsSeam) it is redone only if not yet 0094 //! already done or if the list of edges has changed 0095 //! Remark : A Seam Edge is an Edge present twice in the list, once as 0096 //! FORWARD and once as REVERSED 0097 //! Each sense has its own PCurve, the one for FORWARD 0098 //! must be set in first 0099 Standard_EXPORT void ComputeSeams(const bool enforce = true); 0100 0101 //! Does a circular permutation in order to set <num>th edge last 0102 Standard_EXPORT void SetLast(const int num); 0103 0104 //! When the wire contains at least one degenerated edge, sets it 0105 //! as last one 0106 //! Note : It is useful to process pcurves, for instance, while the pcurve 0107 //! of a DGNR may not be computed from its 3D part (there is none) 0108 //! it is computed after the other edges have been computed and 0109 //! chained. 0110 Standard_EXPORT void SetDegeneratedLast(); 0111 0112 //! Adds an edge to a wire, being defined (not yet ended) 0113 //! This is the plain, basic, function to add an edge 0114 //! <num> = 0 (D): Appends at end 0115 //! <num> = 1: Preprends at start 0116 //! else, Insert before <num> 0117 //! Remark : Null Edge is simply ignored 0118 Standard_EXPORT void Add(const TopoDS_Edge& edge, const int atnum = 0); 0119 0120 //! Adds an entire wire, considered as a list of edges 0121 //! Remark : The wire is assumed to be ordered (TopoDS_Iterator 0122 //! is used) 0123 Standard_EXPORT void Add(const TopoDS_Wire& wire, const int atnum = 0); 0124 0125 //! Adds a wire in the form of WireData 0126 Standard_EXPORT void Add(const occ::handle<ShapeExtend_WireData>& wire, const int atnum = 0); 0127 0128 //! Adds an edge or a wire invoking corresponding method Add 0129 Standard_EXPORT void Add(const TopoDS_Shape& shape, const int atnum = 0); 0130 0131 //! Adds an edge to start or end of <me>, according to <mode> 0132 //! 0: at end, as direct 0133 //! 1: at end, as reversed 0134 //! 2: at start, as direct 0135 //! 3: at start, as reversed 0136 //! < 0: no adding 0137 Standard_EXPORT void AddOriented(const TopoDS_Edge& edge, const int mode); 0138 0139 //! Adds a wire to start or end of <me>, according to <mode> 0140 //! 0: at end, as direct 0141 //! 1: at end, as reversed 0142 //! 2: at start, as direct 0143 //! 3: at start, as reversed 0144 //! < 0: no adding 0145 Standard_EXPORT void AddOriented(const TopoDS_Wire& wire, const int mode); 0146 0147 //! Adds an edge or a wire invoking corresponding method 0148 //! AddOriented 0149 Standard_EXPORT void AddOriented(const TopoDS_Shape& shape, const int mode); 0150 0151 //! Removes an Edge, given its rank. By default removes the last edge. 0152 Standard_EXPORT void Remove(const int num = 0); 0153 0154 //! Replaces an edge at the given 0155 //! rank number <num> with new one. Default is last edge (<num> = 0). 0156 Standard_EXPORT void Set(const TopoDS_Edge& edge, const int num = 0); 0157 0158 //! Reverses the sense of the list and the orientation of each Edge 0159 //! This method should be called when either wire has no seam edges 0160 //! or face is not available 0161 Standard_EXPORT void Reverse(); 0162 0163 //! Reverses the sense of the list and the orientation of each Edge 0164 //! The face is necessary for swapping pcurves for seam edges 0165 //! (first pcurve corresponds to orientation FORWARD, and second to 0166 //! REVERSED; when edge is reversed, pcurves must be swapped) 0167 //! If face is NULL, no swapping is performed 0168 Standard_EXPORT void Reverse(const TopoDS_Face& face); 0169 0170 //! Returns the count of currently recorded edges 0171 Standard_EXPORT int NbEdges() const; 0172 0173 //! Returns the count of currently recorded non-manifold edges 0174 Standard_EXPORT int NbNonManifoldEdges() const; 0175 0176 //! Returns <num>th nonmanifold Edge 0177 Standard_EXPORT TopoDS_Edge NonmanifoldEdge(const int num) const; 0178 0179 //! Returns sequence of non-manifold edges 0180 //! This sequence can be not empty if wire data set in manifold mode but 0181 //! initial wire has INTERNAL orientation or contains INTERNAL edges 0182 Standard_EXPORT occ::handle<NCollection_HSequence<TopoDS_Shape>> NonmanifoldEdges() const; 0183 0184 //! Returns mode defining manifold wire data or not. 0185 //! If manifold that nonmanifold edges will not be not 0186 //! consider during operations(previous behaviour) 0187 //! and they will be added only in result wire 0188 //! else non-manifold edges will consider during operations 0189 Standard_EXPORT bool& ManifoldMode(); 0190 0191 //! Returns <num>th Edge 0192 Standard_EXPORT TopoDS_Edge Edge(const int num) const; 0193 0194 //! Returns the index of the edge 0195 //! If the edge is a seam the orientation is also checked 0196 //! Returns 0 if the edge is not found in the list 0197 Standard_EXPORT int Index(const TopoDS_Edge& edge); 0198 0199 //! Tells if an Edge is seam (see ComputeSeams) 0200 //! An edge is considered as seam if it presents twice in 0201 //! the edge list, once as FORWARD and once as REVERSED. 0202 Standard_EXPORT bool IsSeam(const int num); 0203 0204 //! Makes TopoDS_Wire using 0205 //! BRep_Builder (just creates the TopoDS_Wire object and adds 0206 //! all edges into it). This method should be called when 0207 //! the wire is correct (for example, after successful 0208 //! fixes by ShapeFix_Wire) and adjacent edges share common 0209 //! vertices. In case if adjacent edges do not share the same 0210 //! vertices the resulting TopoDS_Wire will be invalid. 0211 Standard_EXPORT TopoDS_Wire Wire() const; 0212 0213 //! Makes TopoDS_Wire using 0214 //! BRepAPI_MakeWire. Class BRepAPI_MakeWire merges 0215 //! geometrically coincided vertices and can disturb 0216 //! correct order of edges in the wire. If this class fails, 0217 //! null shape is returned. 0218 Standard_EXPORT TopoDS_Wire WireAPIMake() const; 0219 0220 DEFINE_STANDARD_RTTIEXT(ShapeExtend_WireData, Standard_Transient) 0221 0222 private: 0223 occ::handle<NCollection_HSequence<TopoDS_Shape>> myEdges; 0224 occ::handle<NCollection_HSequence<TopoDS_Shape>> myNonmanifoldEdges; 0225 occ::handle<NCollection_HSequence<int>> mySeams; 0226 TColStd_PackedMapOfInteger mySeamsCache; 0227 int mySeamF; 0228 int mySeamR; 0229 bool myManifoldMode; 0230 }; 0231 0232 #endif // _ShapeExtend_WireData_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|