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>
32 // resolve name collisions with X11 headers
37 class BRepTools_ReShape;
38 DEFINE_STANDARD_HANDLE(BRepTools_ReShape, MMgt_TShared)
40 //! Rebuilds a Shape by making pre-defined substitutions on some
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)
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
58 //! Returns an empty Reshape
59 Standard_EXPORT BRepTools_ReShape();
61 //! Clears all substitutions requests
62 Standard_EXPORT virtual void Clear();
64 //! Sets a request to Remove a Shape whatever the orientation
65 Standard_EXPORT virtual void Remove (const TopoDS_Shape& shape);
67 //! Sets a request to Replace a Shape by a new one.
68 virtual void Replace (const TopoDS_Shape& shape, const TopoDS_Shape& newshape)
70 replace (shape, newshape);
73 //! Tells if a shape is recorded for Replace/Remove
74 Standard_EXPORT virtual Standard_Boolean IsRecorded (const TopoDS_Shape& shape) const;
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;
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);
91 //! Applies the substitutions requests to a shape.
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.
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);
105 //! Returns (modifiable) the flag which defines whether Location of shape take into account
106 //! during replacing shapes.
107 virtual Standard_Boolean& ModeConsiderLocation()
109 return myConsiderLocation;
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);
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);
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;
130 DEFINE_STANDARD_RTTIEXT(BRepTools_ReShape,MMgt_TShared)
133 //! Replaces the first shape by the second one
134 //! after the following reorientation.
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);
147 TopTools_DataMapOfShapeShape myNMap;
148 TopTools_MapOfShape myNewShapes;
149 Standard_Integer myStatus;
155 Standard_Boolean myConsiderLocation;
166 #endif // _BRepTools_ReShape_HeaderFile