1 // Created on: 1994-08-25
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1994-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_Modifier_HeaderFile
18 #define _BRepTools_Modifier_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <TopTools_DataMapOfShapeShape.hxx>
25 #include <TopTools_MapOfShape.hxx>
26 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <TopoDS_Face.hxx>
29 #include <TopoDS_Vertex.hxx>
30 #include <Standard_Boolean.hxx>
31 
32 #include <NCollection_DataMap.hxx>
33 #include <TopoDS_Shape.hxx>
34 #include <TopTools_ShapeMapHasher.hxx>
35 #include <TopLoc_Location.hxx>
36 #include <Message_ProgressRange.hxx>
37 
38 class BRepTools_Modification;
39 class Geom_Curve;
40 class Geom_Surface;
41 
42 //! Performs geometric modifications on a shape.
43 class BRepTools_Modifier
44 {
45 public:
46 
47   DEFINE_STANDARD_ALLOC
48 
49   //! Creates an empty Modifier.
50   Standard_EXPORT BRepTools_Modifier(Standard_Boolean theMutableInput = Standard_False);
51 
52   //! Creates a modifier on the shape <S>.
53   Standard_EXPORT BRepTools_Modifier(const TopoDS_Shape& S);
54 
55   //! Creates a modifier on  the shape <S>, and performs
56   //! the modifications described by <M>.
57   Standard_EXPORT BRepTools_Modifier(const TopoDS_Shape& S, const Handle(BRepTools_Modification)& M);
58 
59   //! Initializes the modifier with the shape <S>.
60   Standard_EXPORT void Init (const TopoDS_Shape& S);
61 
62   //! Performs the modifications described by <M>.
63   Standard_EXPORT void Perform (const Handle(BRepTools_Modification)& M,
64                                 const Message_ProgressRange& theProgress = Message_ProgressRange());
65 
66   //! Returns Standard_True if the modification has
67   //! been computed successfully.
68   Standard_Boolean IsDone() const;
69 
70   //! Returns the current mutable input state
71   Standard_EXPORT Standard_Boolean IsMutableInput() const;
72 
73   //! Sets the mutable input state
74   //! If true then the input (original) shape can be modified
75   //! during modification process
76   Standard_EXPORT void SetMutableInput(Standard_Boolean theMutableInput);
77 
78   //! Returns the modified shape corresponding to <S>.
79   const TopoDS_Shape& ModifiedShape (const TopoDS_Shape& S) const;
80 
81 
82 protected:
83 
84 
85 
86 private:
87 
88   struct NewCurveInfo
89   {
90     Handle(Geom_Curve) myCurve;
91     TopLoc_Location myLoc;
92     Standard_Real myToler;
93   };
94 
95   struct NewSurfaceInfo
96   {
97     Handle(Geom_Surface) mySurface;
98     TopLoc_Location myLoc;
99     Standard_Real myToler;
100     Standard_Boolean myRevWires;
101     Standard_Boolean myRevFace;
102   };
103 
104   Standard_EXPORT void Put (const TopoDS_Shape& S);
105 
106   Standard_EXPORT Standard_Boolean Rebuild (const TopoDS_Shape& S,
107                                             const Handle(BRepTools_Modification)& M,
108                                             Standard_Boolean& theNewGeom,
109                                             const Message_ProgressRange& theProgress = Message_ProgressRange());
110 
111   Standard_EXPORT void CreateNewVertices(
112     const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
113     const Handle(BRepTools_Modification)& M);
114 
115   Standard_EXPORT void FillNewCurveInfo(
116     const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
117     const Handle(BRepTools_Modification)& M);
118 
119   Standard_EXPORT void FillNewSurfaceInfo(const Handle(BRepTools_Modification)& M);
120 
121   Standard_EXPORT void CreateOtherVertices(
122     const TopTools_IndexedDataMapOfShapeListOfShape& theMVE,
123     const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,
124     const Handle(BRepTools_Modification)& M);
125 
126   TopTools_DataMapOfShapeShape myMap;
127   TopoDS_Shape myShape;
128   Standard_Boolean myDone;
129   NCollection_DataMap<TopoDS_Edge, NewCurveInfo, TopTools_ShapeMapHasher> myNCInfo;
130   NCollection_DataMap<TopoDS_Face, NewSurfaceInfo, TopTools_ShapeMapHasher> myNSInfo;
131   TopTools_MapOfShape myNonUpdFace;
132   TopTools_MapOfShape myHasNewGeom;
133   Standard_Boolean myMutableInput;
134 
135 };
136 
137 
138 #include <BRepTools_Modifier.lxx>
139 
140 
141 
142 
143 
144 #endif // _BRepTools_Modifier_HeaderFile
145