1 // Created on: 2016-10-13
2 // Created by: Alexander MALYSHEV
3 // Copyright (c) 1999-2016 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BRepOffset_MakeSimpleOffset_HeaderFile
17 #define _BRepOffset_MakeSimpleOffset_HeaderFile
19 #include <BRepTools_Modifier.hxx>
20 #include <ShapeBuild_ReShape.hxx>
21 #include <NCollection_DataMap.hxx>
22 #include <Standard_Macro.hxx>
23 #include <Standard_Real.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Face.hxx>
27 #include <TopoDS_Vertex.hxx>
28 #include <TopoDS_Shape.hxx>
31 enum BRepOffsetSimple_Status
34 BRepOffsetSimple_NullInputShape,
35 BRepOffsetSimple_ErrorOffsetComputation,
36 BRepOffsetSimple_ErrorWallFaceComputation,
37 BRepOffsetSimple_ErrorInvalidNbShells,
38 BRepOffsetSimple_ErrorNonClosedShell
41 //! This class represents simple offset algorithm itself. It builds simple offset without intersection.
42 //! Solid can be created using SetBuildSolidFlag method (set flag to true). By default shell will be constructed.
45 //! 1. Build source-image maps for vertices, edges and faces.BRepTools_Modification class will be used
46 //! to store this information. An image of a shared edge can be constructed from the corresponding edge
47 //! of the first iterated face.
48 //! 2. Run BRepTools_Modifier to obtain offset shape.
49 // 3. Ensure topological integrity of the output shape.
52 //! According to the algorithm nature result depends on the smoothness of input data. Smooth (G1-continuity) input shape
53 //! will lead to the good result.
55 //! The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing.
56 //! The tolerances have to grow in order to cover the gaps between the neighbor faces in the output.
57 //! It should be noted that the actual tolerance growth depends on the offset distance and the quality of
58 //! joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces)
59 //! will lead to good result.
60 class BRepOffset_MakeSimpleOffset
65 //! Constructor. Does nothing.
66 Standard_EXPORT BRepOffset_MakeSimpleOffset();
69 Standard_EXPORT BRepOffset_MakeSimpleOffset(const TopoDS_Shape& theInputShape,
70 const Standard_Real theOffsetValue);
72 //! Initialies shape for modifications.
73 Standard_EXPORT void Initialize(const TopoDS_Shape& theInputShape,
74 const Standard_Real theOffsetValue);
76 //! Computes offset shape.
77 Standard_EXPORT void Perform();
79 //! Gets error message.
80 Standard_EXPORT TCollection_AsciiString GetErrorMessage() const;
83 BRepOffsetSimple_Status GetError() const { return myError; }
86 //! Gets solid building flag.
87 Standard_Boolean GetBuildSolidFlag() const { return myIsBuildSolid; }
89 //! Sets solid building flag.
90 void SetBuildSolidFlag(const Standard_Boolean theBuildFlag) { myIsBuildSolid = theBuildFlag; }
92 //! Gets offset value.
93 Standard_Real GetOffsetValue() const { return myOffsetValue; }
95 //! Sets offset value.
96 void SetOffsetValue(const Standard_Real theOffsetValue) { myOffsetValue = theOffsetValue; }
98 //! Gets tolerance (used for handling singularities).
99 Standard_Real GetTolerance() const { return myTolerance; }
101 //! Sets tolerance (used for handling singularities).
102 void SetTolerance (const Standard_Real theValue) { myTolerance = theValue; }
105 Standard_Boolean IsDone() const { return myIsDone; }
107 //! Returns result shape.
108 const TopoDS_Shape& GetResultShape() const { return myResShape; }
110 //! Computes max safe offset value for the given tolerance.
111 Standard_Real GetSafeOffset(const Standard_Real theExpectedToler);
113 //! Returnes result shape for the given one (if exists).
114 Standard_EXPORT const TopoDS_Shape Generated(const TopoDS_Shape& theShape) const;
116 //! Returnes modified shape for the given one (if exists).
117 Standard_EXPORT const TopoDS_Shape Modified(const TopoDS_Shape& theShape) const;
121 //! Computes max angle in faces junction.
122 void ComputeMaxAngle();
124 //! Clears previous result.
129 //! Builds face on specified wall.
130 TopoDS_Face BuildWallFace(const TopoDS_Edge& theOrigEdge);
132 //! Builds missing walls.
133 Standard_Boolean BuildMissingWalls();
138 TopoDS_Shape myInputShape;
141 Standard_Real myOffsetValue;
143 //! Tolerance (for singularities)
144 Standard_Real myTolerance;
146 //! Solid building flag. True means solid construction.
147 Standard_Boolean myIsBuildSolid;
151 //! Maximal angle in faces junction. This value helps to estimate result tolerance.
152 Standard_Real myMaxAngle;
155 BRepOffsetSimple_Status myError;
158 Standard_Boolean myIsDone;
160 //! Map of vertex - wall edge.
161 //! Used to build shared edge between adjacent wall faces.
162 NCollection_DataMap<TopoDS_Vertex, TopoDS_Edge> myMapVE;
164 //! Used for histrory support.
165 BRepTools_Modifier myBuilder;
167 //! Used for history support.
168 Handle(ShapeBuild_ReShape) myReShape;
173 TopoDS_Shape myResShape;
177 #endif // _BRepOffset_MakeSimpleOffset_HeaderFile