42cf5bc1 |
1 | // Created on: 1998-06-03 |
2 | // Created by: data exchange team |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _BRepTools_ReShape_HeaderFile |
18 | #define _BRepTools_ReShape_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TopTools_DataMapOfShapeShape.hxx> |
b60e8432 |
24 | #include <TopTools_MapOfShape.hxx> |
42cf5bc1 |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <MMgt_TShared.hxx> |
28 | #include <TopAbs_ShapeEnum.hxx> |
29 | class TopoDS_Shape; |
ed5ca017 |
30 | class TopoDS_Vertex; |
42cf5bc1 |
31 | |
9fd2d2c3 |
32 | // resolve name collisions with X11 headers |
33 | #ifdef Status |
34 | #undef Status |
35 | #endif |
42cf5bc1 |
36 | |
37 | class BRepTools_ReShape; |
38 | DEFINE_STANDARD_HANDLE(BRepTools_ReShape, MMgt_TShared) |
39 | |
40 | //! Rebuilds a Shape by making pre-defined substitutions on some |
41 | //! of its components |
42 | //! |
43 | //! In a first phase, it records requests to replace or remove |
44 | //! some individual shapes |
45 | //! For each shape, the last given request is recorded |
46 | //! Requests may be applied "Oriented" (i.e. only to an item with |
47 | //! the SAME orientation) or not (the orientation of replacing |
48 | //! shape is respectful of that of the original one) |
49 | //! |
50 | //! Then, these requests may be applied to any shape which may |
51 | //! contain one or more of these individual shapes |
52 | class BRepTools_ReShape : public MMgt_TShared |
53 | { |
54 | |
55 | public: |
56 | |
57 | |
58 | //! Returns an empty Reshape |
59 | Standard_EXPORT BRepTools_ReShape(); |
60 | |
61 | //! Clears all substitutions requests |
62 | Standard_EXPORT virtual void Clear(); |
63 | |
669cd76e |
64 | //! Sets a request to Remove a Shape whatever the orientation |
65 | Standard_EXPORT virtual void Remove (const TopoDS_Shape& shape); |
42cf5bc1 |
66 | |
669cd76e |
67 | //! Sets a request to Replace a Shape by a new one. |
68 | virtual void Replace (const TopoDS_Shape& shape, const TopoDS_Shape& newshape) |
69 | { |
70 | replace (shape, newshape); |
71 | } |
42cf5bc1 |
72 | |
73 | //! Tells if a shape is recorded for Replace/Remove |
74 | Standard_EXPORT virtual Standard_Boolean IsRecorded (const TopoDS_Shape& shape) const; |
75 | |
76 | //! Returns the new value for an individual shape |
77 | //! If not recorded, returns the original shape itself |
78 | //! If to be Removed, returns a Null Shape |
79 | //! Else, returns the replacing item |
80 | Standard_EXPORT virtual TopoDS_Shape Value (const TopoDS_Shape& shape) const; |
81 | |
82 | //! Returns a complete substitution status for a shape |
83 | //! 0 : not recorded, <newsh> = original <shape> |
84 | //! < 0: to be removed, <newsh> is NULL |
85 | //! > 0: to be replaced, <newsh> is a new item |
86 | //! If <last> is False, returns status and new shape recorded in |
87 | //! the map directly for the shape, if True and status > 0 then |
88 | //! recursively searches for the last status and new shape. |
89 | Standard_EXPORT virtual Standard_Integer Status (const TopoDS_Shape& shape, TopoDS_Shape& newsh, const Standard_Boolean last = Standard_False); |
669cd76e |
90 | |
42cf5bc1 |
91 | //! Applies the substitutions requests to a shape. |
92 | //! |
93 | //! <until> gives the level of type until which requests are taken |
94 | //! into account. For subshapes of the type <until> no rebuild |
95 | //! and futher exploring are done. |
96 | //! |
97 | //! NOTE: each subshape can be replaced by shape of the same type |
98 | //! or by shape containing only shapes of that type (for |
99 | //! example, TopoDS_Edge can be replaced by TopoDS_Edge, |
100 | //! TopoDS_Wire or TopoDS_Compound containing TopoDS_Edges). |
101 | //! If incompatible shape type is encountered, it is ignored |
102 | //! and flag FAIL1 is set in Status. |
103 | Standard_EXPORT virtual TopoDS_Shape Apply (const TopoDS_Shape& shape, const TopAbs_ShapeEnum until = TopAbs_SHAPE); |
669cd76e |
104 | |
42cf5bc1 |
105 | //! Returns (modifiable) the flag which defines whether Location of shape take into account |
106 | //! during replacing shapes. |
669cd76e |
107 | virtual Standard_Boolean& ModeConsiderLocation() |
108 | { |
109 | return myConsiderLocation; |
110 | } |
42cf5bc1 |
111 | |
ed5ca017 |
112 | //! Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise. |
113 | //@param theV - original vertex. |
114 | //@param theTol - new tolerance of vertex, optional. |
115 | Standard_EXPORT TopoDS_Vertex CopyVertex(const TopoDS_Vertex& theV, |
116 | const Standard_Real theTol = -1.0); |
117 | |
118 | //! Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise. |
119 | //@param theV - original vertex. |
120 | //@param theNewPos - new position for vertex copy. |
121 | //@param theTol - new tolerance of vertex. |
122 | Standard_EXPORT TopoDS_Vertex CopyVertex(const TopoDS_Vertex& theV, |
123 | const gp_Pnt& theNewPos, |
124 | const Standard_Real aTol); |
42cf5bc1 |
125 | |
b60e8432 |
126 | //! Checks if shape has been recorded by reshaper as a value |
127 | //@param theShape is the given shape |
128 | Standard_EXPORT Standard_Boolean IsNewShape(const TopoDS_Shape& theShape) const; |
129 | |
92efcf78 |
130 | DEFINE_STANDARD_RTTIEXT(BRepTools_ReShape,MMgt_TShared) |
42cf5bc1 |
131 | |
669cd76e |
132 | private: |
133 | //! Replaces the first shape by the second one |
134 | //! after the following reorientation. |
135 | //! |
136 | //! If the first shape has the reversed orientation |
137 | //! then the both shapes are reversed. |
138 | //! If the first shape has the internal or external orientation then: <br> |
139 | //! - the second shape is oriented forward (reversed) if it's orientation |
140 | //! is equal (not equal) to the orientation of the first shape; <br> |
141 | //! - the first shape is oriented forward. |
142 | Standard_EXPORT virtual void replace (const TopoDS_Shape& shape, const TopoDS_Shape& newshape); |
143 | |
42cf5bc1 |
144 | protected: |
145 | |
146 | |
147 | TopTools_DataMapOfShapeShape myNMap; |
b60e8432 |
148 | TopTools_MapOfShape myNewShapes; |
42cf5bc1 |
149 | Standard_Integer myStatus; |
150 | |
151 | |
152 | private: |
153 | |
154 | |
155 | Standard_Boolean myConsiderLocation; |
42cf5bc1 |
156 | |
157 | |
158 | }; |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | |
166 | #endif // _BRepTools_ReShape_HeaderFile |