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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _BRepTools_ReShape_HeaderFile
18 #define _BRepTools_ReShape_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TopTools_DataMapOfShapeShape.hxx>
24 #include <TopTools_MapOfShape.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <MMgt_TShared.hxx>
28 #include <TopAbs_ShapeEnum.hxx>
33 class BRepTools_ReShape;
34 DEFINE_STANDARD_HANDLE(BRepTools_ReShape, MMgt_TShared)
36 //! Rebuilds a Shape by making pre-defined substitutions on some
39 //! In a first phase, it records requests to replace or remove
40 //! some individual shapes
41 //! For each shape, the last given request is recorded
42 //! Requests may be applied "Oriented" (i.e. only to an item with
43 //! the SAME orientation) or not (the orientation of replacing
44 //! shape is respectful of that of the original one)
46 //! Then, these requests may be applied to any shape which may
47 //! contain one or more of these individual shapes
48 class BRepTools_ReShape : public MMgt_TShared
54 //! Returns an empty Reshape
55 Standard_EXPORT BRepTools_ReShape();
57 //! Clears all substitutions requests
58 Standard_EXPORT virtual void Clear();
60 //! Sets a request to Remove a Shape
61 //! If <oriented> is True, only for a shape with the SAME
62 //! orientation. Else, whatever the orientation
63 Standard_EXPORT virtual void Remove (const TopoDS_Shape& shape, const Standard_Boolean oriented = Standard_False);
65 //! Sets a request to Replace a Shape by a new one
66 //! If <oriented> is True, only if the orientation is the same
67 //! Else, whatever the orientation, and the new shape takes the
68 //! same orientation as <newshape> if the replaced one has the
69 //! same as <shape>, else it is reversed
70 Standard_EXPORT virtual void Replace (const TopoDS_Shape& shape, const TopoDS_Shape& newshape, const Standard_Boolean oriented = Standard_False);
72 //! Tells if a shape is recorded for Replace/Remove
73 Standard_EXPORT virtual Standard_Boolean IsRecorded (const TopoDS_Shape& shape) const;
75 //! Returns the new value for an individual shape
76 //! If not recorded, returns the original shape itself
77 //! If to be Removed, returns a Null Shape
78 //! Else, returns the replacing item
79 Standard_EXPORT virtual TopoDS_Shape Value (const TopoDS_Shape& shape) const;
81 //! Returns a complete substitution status for a shape
82 //! 0 : not recorded, <newsh> = original <shape>
83 //! < 0: to be removed, <newsh> is NULL
84 //! > 0: to be replaced, <newsh> is a new item
85 //! If <last> is False, returns status and new shape recorded in
86 //! the map directly for the shape, if True and status > 0 then
87 //! recursively searches for the last status and new shape.
88 Standard_EXPORT virtual Standard_Integer Status (const TopoDS_Shape& shape, TopoDS_Shape& newsh, const Standard_Boolean last = Standard_False);
90 //! Applies the substitutions requests to a shape
92 //! <until> gives the level of type until which requests are taken
93 //! into account. For subshapes of the type <until> no rebuild
94 //! and futher exploring are done.
95 //! ACTUALLY, NOT IMPLEMENTED BELOW TopAbs_FACE
97 //! <buildmode> says how to do on a SOLID,SHELL ... if one of its
98 //! sub-shapes has been changed:
99 //! 0: at least one Replace or Remove -> COMPOUND, else as such
100 //! 1: at least one Remove (Replace are ignored) -> COMPOUND
101 //! 2: Replace and Remove are both ignored
102 //! If Replace/Remove are ignored or absent, the result as same
103 //! type as the starting shape
104 Standard_EXPORT virtual TopoDS_Shape Apply (const TopoDS_Shape& shape, const TopAbs_ShapeEnum until, const Standard_Integer buildmode);
106 //! Applies the substitutions requests to a shape.
108 //! <until> gives the level of type until which requests are taken
109 //! into account. For subshapes of the type <until> no rebuild
110 //! and futher exploring are done.
112 //! NOTE: each subshape can be replaced by shape of the same type
113 //! or by shape containing only shapes of that type (for
114 //! example, TopoDS_Edge can be replaced by TopoDS_Edge,
115 //! TopoDS_Wire or TopoDS_Compound containing TopoDS_Edges).
116 //! If incompatible shape type is encountered, it is ignored
117 //! and flag FAIL1 is set in Status.
118 Standard_EXPORT virtual TopoDS_Shape Apply (const TopoDS_Shape& shape, const TopAbs_ShapeEnum until = TopAbs_SHAPE);
120 //! Returns (modifiable) the flag which defines whether Location of shape take into account
121 //! during replacing shapes.
122 Standard_EXPORT virtual Standard_Boolean& ModeConsiderLocation();
124 //! Returns (modifiable) the flag which defines whether Orientation of shape take into account
125 //! during replacing shapes.
126 Standard_EXPORT virtual Standard_Boolean& ModeConsiderOrientation();
128 //! Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.
129 //@param theV - original vertex.
130 //@param theTol - new tolerance of vertex, optional.
131 Standard_EXPORT TopoDS_Vertex CopyVertex(const TopoDS_Vertex& theV,
132 const Standard_Real theTol = -1.0);
134 //! Returns modified copy of vertex if original one is not recorded or returns modified original vertex otherwise.
135 //@param theV - original vertex.
136 //@param theNewPos - new position for vertex copy.
137 //@param theTol - new tolerance of vertex.
138 Standard_EXPORT TopoDS_Vertex CopyVertex(const TopoDS_Vertex& theV,
139 const gp_Pnt& theNewPos,
140 const Standard_Real aTol);
142 //! Checks if shape has been recorded by reshaper as a value
143 //@param theShape is the given shape
144 Standard_EXPORT Standard_Boolean IsNewShape(const TopoDS_Shape& theShape) const;
147 DEFINE_STANDARD_RTTIEXT(BRepTools_ReShape,MMgt_TShared)
152 TopTools_DataMapOfShapeShape myNMap;
153 TopTools_DataMapOfShapeShape myRMap;
154 TopTools_MapOfShape myNewShapes;
155 Standard_Integer myStatus;
161 Standard_Boolean myConsiderLocation;
162 Standard_Boolean myConsiderOrientation;
173 #endif // _BRepTools_ReShape_HeaderFile