0028968: Incorrect offset for the faces with singularities
[occt.git] / src / BRepOffset / BRepOffset_SimpleOffset.hxx
CommitLineData
8013367c 1// Created on: 2016-10-14
2// Created by: Alexander MALYSHEV
3// Copyright (c) 1999-2016 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _BRepOffset_SimpleOffset_HeaderFile
17#define _BRepOffset_SimpleOffset_HeaderFile
18
19#include <BRepTools_Modification.hxx>
20#include <GeomAbs_Shape.hxx>
21#include <Geom2d_Curve.hxx>
22#include <Standard_Real.hxx>
23#include <Standard_Macro.hxx>
24#include <Standard_Type.hxx>
25#include <TopoDS_Shape.hxx>
26#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
27#include <NCollection_DataMap.hxx>
28
29
30class BRepOffset_SimpleOffset;
31DEFINE_STANDARD_HANDLE(BRepOffset_SimpleOffset, BRepTools_Modification)
32
33//! This class represents mechanism of simple offset algorithm i. e.
34//! topology-preserve offset construction without intersection.
35//!
36//! The list below shows mapping scheme:
37//! - Each surface is mapped to its geometric offset surface.
38//! - For each edge, pcurves are mapped to the same pcurves on offset surfaces.
39//! - For each edge, 3d curve is constructed by re-approximation of pcurve on the first offset face.
40//! - Position of each vertex in a result shell is computed as average point of all ends of edges shared by that vertex.
41//! - Tolerances are updated according to the resulting geometry.
42class BRepOffset_SimpleOffset : public BRepTools_Modification
43{
44public:
45
46 DEFINE_STANDARD_RTTI_INLINE(BRepOffset_SimpleOffset, BRepTools_Modification)
47
48 //! Constructor.
8574e329 49 //! @param theInputShape shape to be offset
50 //! @param theOffsetValue offset distance (signed)
51 //! @param theTolerance tolerance for handling singular points
8013367c 52 Standard_EXPORT BRepOffset_SimpleOffset(const TopoDS_Shape& theInputShape,
8574e329 53 const Standard_Real theOffsetValue,
54 const Standard_Real theTolerance);
8013367c 55
56 //! Returns Standard_True if the face <F> has been
57 //! modified. In this case, <S> is the new geometric
58 //! support of the face, <L> the new location,<Tol>
59 //! the new tolerance.<RevWires> has to be set to
60 //! Standard_True when the modification reverses the
61 //! normal of the surface.(the wires have to be
62 //! reversed). <RevFace> has to be set to
63 //! Standard_True if the orientation of the modified
64 //! face changes in the shells which contain it. --
65 //! Here, <RevFace> will return Standard_True if the
66 //! -- gp_Trsf is negative.
67 Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F,
68 Handle(Geom_Surface)& S,
69 TopLoc_Location& L,
70 Standard_Real& Tol,
71 Standard_Boolean& RevWires,
72 Standard_Boolean& RevFace) Standard_OVERRIDE;
73
74 //! Returns Standard_True if the edge <E> has been
75 //! modified. In this case, <C> is the new geometric
76 //! support of the edge, <L> the new location, <Tol>
77 //! the new tolerance. Otherwise, returns
78 //! Standard_False, and <C>, <L>, <Tol> are not
79 //! significant.
80 Standard_EXPORT Standard_Boolean NewCurve (const TopoDS_Edge& E,
81 Handle(Geom_Curve)& C,
82 TopLoc_Location& L,
83 Standard_Real& Tol) Standard_OVERRIDE;
84
85 //! Returns Standard_True if the vertex <V> has been
86 //! modified. In this case, <P> is the new geometric
87 //! support of the vertex, <Tol> the new tolerance.
88 //! Otherwise, returns Standard_False, and <P>, <Tol>
89 //! are not significant.
90 Standard_EXPORT Standard_Boolean NewPoint (const TopoDS_Vertex& V,
91 gp_Pnt& P,
92 Standard_Real& Tol) Standard_OVERRIDE;
93
94 //! Returns Standard_True if the edge <E> has a new
95 //! curve on surface on the face <F>.In this case, <C>
96 //! is the new geometric support of the edge, <L> the
97 //! new location, <Tol> the new tolerance.
98 //! Otherwise, returns Standard_False, and <C>, <L>,
99 //! <Tol> are not significant.
100 Standard_EXPORT Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
101 const TopoDS_Face& F,
102 const TopoDS_Edge& NewE,
103 const TopoDS_Face& NewF,
104 Handle(Geom2d_Curve)& C,
105 Standard_Real& Tol) Standard_OVERRIDE;
106
107 //! Returns Standard_True if the Vertex <V> has a new
108 //! parameter on the edge <E>. In this case, <P> is
109 //! the parameter, <Tol> the new tolerance.
110 //! Otherwise, returns Standard_False, and <P>, <Tol>
111 //! are not significant.
112 Standard_EXPORT Standard_Boolean NewParameter (const TopoDS_Vertex& V,
113 const TopoDS_Edge& E,
114 Standard_Real& P,
115 Standard_Real& Tol) Standard_OVERRIDE;
116
117 //! Returns the continuity of <NewE> between <NewF1>
118 //! and <NewF2>.
119 //!
120 //! <NewE> is the new edge created from <E>. <NewF1>
121 //! (resp. <NewF2>) is the new face created from <F1>
122 //! (resp. <F2>).
123 Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E,
124 const TopoDS_Face& F1,
125 const TopoDS_Face& F2,
126 const TopoDS_Edge& NewE,
127 const TopoDS_Face& NewF1,
128 const TopoDS_Face& NewF2) Standard_OVERRIDE;
129
130private:
131
132 //! Method to fill new face data for single face.
133 void FillFaceData(const TopoDS_Face& theFace);
134
135 //! Method to fill new edge data for single edge.
136 void FillEdgeData(const TopoDS_Edge& theEdge,
137 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeFaceMap,
138 const Standard_Integer theIdx);
139
140 //! Method to fill new vertex data for single vertex.
141 void FillVertexData(const TopoDS_Vertex& theVertex,
142 const TopTools_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
143 const Standard_Integer theIdx);
144
145 struct NewFaceData
146 {
147 Handle(Geom_Surface) myOffsetS;
148 TopLoc_Location myL;
149 Standard_Real myTol;
150 Standard_Boolean myRevWires;
151 Standard_Boolean myRevFace;
152 };
153
154 struct NewEdgeData
155 {
156 Handle(Geom_Curve) myOffsetC; // Resulting curve.
157 TopLoc_Location myL;
158 Standard_Real myTol;
159 };
160
161 struct NewVertexData
162 {
163 gp_Pnt myP;
164 Standard_Real myTol;
165 };
166
167 //! Fills offset data.
168 void FillOffsetData(const TopoDS_Shape& theInputShape);
169
170 //! Copy-assignment constructor and copy constructor are not allowed.
171 void operator=(const BRepOffset_SimpleOffset&);
172 BRepOffset_SimpleOffset(const BRepOffset_SimpleOffset&);
173
174 //! Map of faces to new faces information.
175 NCollection_DataMap<TopoDS_Face, NewFaceData> myFaceInfo;
176
177 //! Map of edges to new edges information.
178 NCollection_DataMap<TopoDS_Edge, NewEdgeData> myEdgeInfo;
179
180 //! Map of vertices to new vertices information.
181 NCollection_DataMap<TopoDS_Vertex, NewVertexData> myVertexInfo;
182
183 //! Offset value.
184 Standard_Real myOffsetValue;
8574e329 185
186 //! Tolerance.
187 Standard_Real myTolerance;
8013367c 188};
189
190#endif // _BRepOffset_SimpleOffset_HeaderFile