0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / HLRBRep / HLRBRep_PolyAlgo.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-02-18
2// Created by: Christophe MARION
3// Copyright (c) 1992-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 _HLRBRep_PolyAlgo_HeaderFile
18#define _HLRBRep_PolyAlgo_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <HLRAlgo_Projector.hxx>
24#include <Standard_Real.hxx>
25#include <TopTools_SequenceOfShape.hxx>
26#include <TopTools_IndexedMapOfShape.hxx>
27#include <Standard_Boolean.hxx>
28#include <BRepAdaptor_Surface.hxx>
29#include <BRepAdaptor_Curve.hxx>
30#include <BRepAdaptor_Curve2d.hxx>
31#include <MMgt_TShared.hxx>
32#include <Standard_Integer.hxx>
33#include <TColStd_Array1OfTransient.hxx>
34#include <TColStd_Array1OfInteger.hxx>
35#include <TopTools_MapOfShape.hxx>
36#include <Standard_Address.hxx>
37#include <HLRAlgo_ListOfBPoint.hxx>
38#include <TopTools_ListOfShape.hxx>
39#include <GeomAbs_Shape.hxx>
40class HLRAlgo_PolyAlgo;
41class Geom_Surface;
42class Standard_OutOfRange;
43class TopoDS_Shape;
44class HLRAlgo_Projector;
45class TopoDS_Edge;
46class HLRAlgo_PolyInternalData;
47class HLRAlgo_EdgeStatus;
48
49
50class HLRBRep_PolyAlgo;
51DEFINE_STANDARD_HANDLE(HLRBRep_PolyAlgo, MMgt_TShared)
52
53//! to remove Hidden lines on Shapes with Triangulations.
54//! A framework to compute the shape as seen in
55//! a projection plane. This is done by calculating
56//! the visible and the hidden parts of the shape.
57//! HLRBRep_PolyAlgo works with three types of entity:
58//! - shapes to be visualized (these shapes must
59//! have already been triangulated.)
60//! - edges in these shapes (these edges are
61//! defined as polygonal lines on the
62//! triangulation of the shape, and are the basic
63//! entities which will be visualized or hidden), and
64//! - triangles in these shapes which hide the edges.
65//! HLRBRep_PolyAlgo is based on the principle
66//! of comparing each edge of the shape to be
67//! visualized with each of the triangles produced
68//! by the triangulation of the shape, and
69//! calculating the visible and the hidden parts of each edge.
70//! For a given projection, HLRBRep_PolyAlgo
71//! calculates a set of lines characteristic of the
72//! object being represented. It is also used in
73//! conjunction with the HLRBRep_PolyHLRToShape extraction
74//! utilities, which reconstruct a new, simplified
75//! shape from a selection of calculation results.
76//! This new shape is made up of edges, which
77//! represent the shape visualized in the projection.
78//! HLRBRep_PolyAlgo works with a polyhedral
79//! simplification of the shape whereas
80//! HLRBRep_Algo takes the shape itself into
81//! account. When you use HLRBRep_Algo, you
82//! obtain an exact result, whereas, when you use
83//! HLRBRep_PolyAlgo, you reduce computation
84//! time but obtain polygonal segments.
85//! An HLRBRep_PolyAlgo object provides a framework for:
86//! - defining the point of view
87//! - identifying the shape or shapes to be visualized
88//! - calculating the outlines
89//! - calculating the visible and hidden lines of the shape.
90//! Warning
91//! - Superimposed lines are not eliminated by this algorithm.
92//! - There must be no unfinished objects inside the shape you wish to visualize.
93//! - Points are not treated.
94//! - Note that this is not the sort of algorithm
95//! used in generating shading, which calculates
96//! the visible and hidden parts of each face in a
97//! shape to be visualized by comparing each
98//! face in the shape with every other face in the same shape.
99class HLRBRep_PolyAlgo : public MMgt_TShared
100{
101
102public:
103
104
105 //! Constructs an empty framework for the
106 //! calculation of the visible and hidden lines of a shape in a projection.
107 //! Use the functions:
108 //! - Projector to define the point of view
109 //! - Load to select the shape or shapes to be visualized
110 //! - Update to compute the visible and hidden lines of the shape.
111 //! Warning
112 //! The shape or shapes to be visualized must have already been triangulated.
113 Standard_EXPORT HLRBRep_PolyAlgo();
114
115 Standard_EXPORT HLRBRep_PolyAlgo(const Handle(HLRBRep_PolyAlgo)& A);
116
117 Standard_EXPORT HLRBRep_PolyAlgo(const TopoDS_Shape& S);
118
119 Standard_Integer NbShapes() const;
120
121 Standard_EXPORT TopoDS_Shape& Shape (const Standard_Integer I);
122
123 //! remove the Shape of Index <I>.
124 Standard_EXPORT void Remove (const Standard_Integer I);
125
126 //! return the index of the Shape <S> and return 0 if
127 //! the Shape <S> is not found.
128 Standard_EXPORT Standard_Integer Index (const TopoDS_Shape& S) const;
129
130 //! Loads the shape S into this framework.
131 //! Warning S must have already been triangulated.
132 void Load (const TopoDS_Shape& S);
133
134 Standard_EXPORT Handle(HLRAlgo_PolyAlgo) Algo() const;
135
136 //! Sets the parameters of the view for this framework.
137 //! These parameters are defined by an HLRAlgo_Projector object,
138 //! which is returned by the Projector function on a Prs3d_Projector object.
139 const HLRAlgo_Projector& Projector() const;
140
141 void Projector (const HLRAlgo_Projector& P);
142
143 Standard_Real Angle() const;
144
145 void Angle (const Standard_Real Ang);
146
147 Standard_Real TolAngular() const;
148
149 void TolAngular (const Standard_Real Tol);
150
151 Standard_Real TolCoef() const;
152
153 void TolCoef (const Standard_Real Tol);
154
155 //! Launches calculation of outlines of the shape
156 //! visualized by this framework. Used after setting the point of view and
157 //! defining the shape or shapes to be visualized.
158 Standard_EXPORT void Update();
159
160 void InitHide();
161
162 Standard_Boolean MoreHide() const;
163
164 void NextHide();
165
166 Standard_EXPORT void Hide (Standard_Address& Coordinates, HLRAlgo_EdgeStatus& status, TopoDS_Shape& S, Standard_Boolean& reg1, Standard_Boolean& regn, Standard_Boolean& outl, Standard_Boolean& intl);
167
168 void InitShow();
169
170 Standard_Boolean MoreShow() const;
171
172 void NextShow();
173
174 Standard_EXPORT void Show (Standard_Address& Coordinates, TopoDS_Shape& S, Standard_Boolean& reg1, Standard_Boolean& regn, Standard_Boolean& outl, Standard_Boolean& intl);
175
176 //! Make a shape with the internal outlines in each
177 //! face.
178 Standard_EXPORT TopoDS_Shape OutLinedShape (const TopoDS_Shape& S) const;
179
180 Standard_Boolean Debug() const;
181
182 void Debug (const Standard_Boolean B);
183
184
185
186
92efcf78 187 DEFINE_STANDARD_RTTIEXT(HLRBRep_PolyAlgo,MMgt_TShared)
42cf5bc1 188
189protected:
190
191
192
193
194private:
195
196
197 Standard_EXPORT TopoDS_Shape MakeShape() const;
198
199 Standard_EXPORT Standard_Integer InitShape (const TopoDS_Shape& Shape, Standard_Boolean& IsoledF, Standard_Boolean& IsoledE);
200
201 Standard_EXPORT void StoreShell (const TopoDS_Shape& Shape, Standard_Integer& iShell, TColStd_Array1OfTransient& Shell, const Standard_Boolean IsoledF, const Standard_Boolean IsoledE, TColStd_Array1OfInteger& ES, TColStd_Array1OfTransient& PD, TColStd_Array1OfTransient& PID, TopTools_MapOfShape& ShapeMap1, TopTools_MapOfShape& ShapeMap2);
202
203 Standard_EXPORT Standard_Boolean Normal (const Standard_Integer iNode, const Standard_Address Nod1Indices, const Standard_Address Nod1RValues, Standard_Address& TData, Standard_Address& PISeg, Standard_Address& PINod, const Standard_Boolean orient) const;
204
205 Standard_EXPORT Standard_Boolean AverageNormal (const Standard_Integer iNode, const Standard_Address Nod1Indices, Standard_Address& TData, Standard_Address& PISeg, Standard_Address& PINod, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
206
207 Standard_EXPORT void AddNormalOnTriangle (const Standard_Integer iTri, const Standard_Integer iNode, Standard_Integer& jNode, Standard_Address& TData, Standard_Address& PINod, Standard_Real& X, Standard_Real& Y, Standard_Real& Z, Standard_Boolean& OK) const;
208
209 Standard_EXPORT void InitBiPointsWithConnexity (const Standard_Integer e, TopoDS_Edge& E, HLRAlgo_ListOfBPoint& List, TColStd_Array1OfTransient& PID, TopTools_ListOfShape& LS, const Standard_Boolean connex);
210
211 Standard_EXPORT void Interpolation (HLRAlgo_ListOfBPoint& List, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2, Standard_Real& XTI1, Standard_Real& YTI1, Standard_Real& ZTI1, Standard_Real& XTI2, Standard_Real& YTI2, Standard_Real& ZTI2, const Standard_Integer e, Standard_Real& U1, Standard_Real& U2, Standard_Address& Nod11Indices, Standard_Address& Nod11RValues, Standard_Address& Nod12Indices, Standard_Address& Nod12RValues, const Standard_Integer i1p1, const Standard_Integer i1p2, const Standard_Integer i1, const Handle(HLRAlgo_PolyInternalData)& pid1, Standard_Address& TData1, Standard_Address& PISeg1, Standard_Address& PINod1) const;
212
213 Standard_EXPORT void Interpolation (HLRAlgo_ListOfBPoint& List, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2, Standard_Real& XTI1, Standard_Real& YTI1, Standard_Real& ZTI1, Standard_Real& XTI2, Standard_Real& YTI2, Standard_Real& ZTI2, const Standard_Integer e, Standard_Real& U1, Standard_Real& U2, const GeomAbs_Shape rg, Standard_Address& Nod11Indices, Standard_Address& Nod11RValues, Standard_Address& Nod12Indices, Standard_Address& Nod12RValues, const Standard_Integer i1p1, const Standard_Integer i1p2, const Standard_Integer i1, const Handle(HLRAlgo_PolyInternalData)& pid1, Standard_Address& TData1, Standard_Address& PISeg1, Standard_Address& PINod1, Standard_Address& Nod21Indices, Standard_Address& Nod21RValues, Standard_Address& Nod22Indices, Standard_Address& Nod22RValues, const Standard_Integer i2p1, const Standard_Integer i2p2, const Standard_Integer i2, const Handle(HLRAlgo_PolyInternalData)& pid2, Standard_Address& TData2, Standard_Address& PISeg2, Standard_Address& PINod2) const;
214
215 Standard_EXPORT Standard_Boolean Interpolation (const Standard_Real U1, const Standard_Real U2, const Standard_Address Nod1RValues, const Standard_Address Nod2RValues, Standard_Real& X3, Standard_Real& Y3, Standard_Real& Z3, Standard_Real& XT3, Standard_Real& YT3, Standard_Real& ZT3, Standard_Real& coef3, Standard_Real& U3, Standard_Boolean& mP3P1) const;
216
217 Standard_EXPORT void MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2, Standard_Real& XTI1, Standard_Real& YTI1, Standard_Real& ZTI1, Standard_Real& XTI2, Standard_Real& YTI2, Standard_Real& ZTI2, const Standard_Integer e, Standard_Real& U1, Standard_Real& U2, Standard_Address& Nod11Indices, Standard_Address& Nod11RValues, Standard_Address& Nod12Indices, Standard_Address& Nod12RValues, const Standard_Integer i1p1, const Standard_Integer i1p2, const Standard_Integer i1, const Handle(HLRAlgo_PolyInternalData)& pid1, Standard_Address& TData1, Standard_Address& PISeg1, Standard_Address& PINod1, const Standard_Real X3, const Standard_Real Y3, const Standard_Real Z3, const Standard_Real XT3, const Standard_Real YT3, const Standard_Real ZT3, const Standard_Real coef3, const Standard_Real U3, const Standard_Boolean insP3, const Standard_Boolean mP3P1, const Standard_Boolean flag) const;
218
219 Standard_EXPORT void MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2, Standard_Real& XTI1, Standard_Real& YTI1, Standard_Real& ZTI1, Standard_Real& XTI2, Standard_Real& YTI2, Standard_Real& ZTI2, const Standard_Integer e, Standard_Real& U1, Standard_Real& U2, Standard_Address& Nod11Indices, Standard_Address& Nod11RValues, Standard_Address& Nod12Indices, Standard_Address& Nod12RValues, const Standard_Integer i1p1, const Standard_Integer i1p2, const Standard_Integer i1, const Handle(HLRAlgo_PolyInternalData)& pid1, Standard_Address& TData1, Standard_Address& PISeg1, Standard_Address& PINod1, Standard_Address& Nod21Indices, Standard_Address& Nod21RValues, Standard_Address& Nod22Indices, Standard_Address& Nod22RValues, const Standard_Integer i2p1, const Standard_Integer i2p2, const Standard_Integer i2, const Handle(HLRAlgo_PolyInternalData)& pid2, Standard_Address& TData2, Standard_Address& PISeg2, Standard_Address& PINod2, const Standard_Real X3, const Standard_Real Y3, const Standard_Real Z3, const Standard_Real XT3, const Standard_Real YT3, const Standard_Real ZT3, const Standard_Real coef3, const Standard_Real U3, const Standard_Boolean insP3, const Standard_Boolean mP3P1, const Standard_Boolean flag) const;
220
221 Standard_EXPORT void MoveOrInsertPoint (HLRAlgo_ListOfBPoint& List, Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2, Standard_Real& XTI1, Standard_Real& YTI1, Standard_Real& ZTI1, Standard_Real& XTI2, Standard_Real& YTI2, Standard_Real& ZTI2, const Standard_Integer e, Standard_Real& U1, Standard_Real& U2, Standard_Address& Nod11Indices, Standard_Address& Nod11RValues, Standard_Address& Nod12Indices, Standard_Address& Nod12RValues, const Standard_Integer i1p1, const Standard_Integer i1p2, const Standard_Integer i1, const Handle(HLRAlgo_PolyInternalData)& pid1, Standard_Address& TData1, Standard_Address& PISeg1, Standard_Address& PINod1, Standard_Address& Nod21Indices, Standard_Address& Nod21RValues, Standard_Address& Nod22Indices, Standard_Address& Nod22RValues, const Standard_Integer i2p1, const Standard_Integer i2p2, const Standard_Integer i2, const Handle(HLRAlgo_PolyInternalData)& pid2, Standard_Address& TData2, Standard_Address& PISeg2, Standard_Address& PINod2, const Standard_Real X3, const Standard_Real Y3, const Standard_Real Z3, const Standard_Real XT3, const Standard_Real YT3, const Standard_Real ZT3, const Standard_Real coef3, const Standard_Real U3, const Standard_Boolean insP3, const Standard_Boolean mP3P1, const Standard_Real X4, const Standard_Real Y4, const Standard_Real Z4, const Standard_Real XT4, const Standard_Real YT4, const Standard_Real ZT4, const Standard_Real coef4, const Standard_Real U4, const Standard_Boolean insP4, const Standard_Boolean mP4P1, const Standard_Boolean flag) const;
222
223 Standard_EXPORT void InsertOnOutLine (TColStd_Array1OfTransient& PID);
224
225 Standard_EXPORT void CheckFrBackTriangles (HLRAlgo_ListOfBPoint& List, TColStd_Array1OfTransient& PID);
226
227 Standard_EXPORT void FindEdgeOnTriangle (const Standard_Address Tri1Indices, const Standard_Integer ip1, const Standard_Integer ip2, Standard_Integer& jtrouv, Standard_Boolean& isDirect) const;
228
229 Standard_EXPORT void ChangeNode (const Standard_Integer ip1, const Standard_Integer ip2, const Standard_Address Nod1Indices, const Standard_Address Nod1RValues, const Standard_Address Nod2Indices, const Standard_Address Nod2RValues, const Standard_Real coef1, const Standard_Real X3, const Standard_Real Y3, const Standard_Real Z3, const Standard_Boolean first, Standard_Address& TData, Standard_Address& PISeg, Standard_Address& PINod) const;
230
231 Standard_EXPORT void UpdateAroundNode (const Standard_Integer iNode, const Standard_Address Nod1Indices, const Standard_Address TData, const Standard_Address PISeg, const Standard_Address PINod) const;
232
233 Standard_EXPORT void OrientTriangle (const Standard_Integer iTri, const Standard_Address Tri1Indices, const Standard_Address Nod1Indices, const Standard_Address Nod1RValues, const Standard_Address Nod2Indices, const Standard_Address Nod2RValues, const Standard_Address Nod3Indices, const Standard_Address Nod3RValues) const;
234
235 Standard_EXPORT Standard_Boolean Triangles (const Standard_Integer ip1, const Standard_Integer ip2, const Standard_Address Nod1Indices, Standard_Address& PISeg, Standard_Integer& iTri1, Standard_Integer& iTri2) const;
236
237 Standard_EXPORT Standard_Boolean NewNode (const Standard_Address Nod1RValues, const Standard_Address Nod2RValues, Standard_Real& coef1, Standard_Boolean& moveP1) const;
238
239 Standard_EXPORT void UVNode (const Standard_Address Nod1RValues, const Standard_Address Nod2RValues, const Standard_Real coef1, Standard_Real& U3, Standard_Real& V3) const;
240
241 Standard_EXPORT void CheckDegeneratedSegment (const Standard_Address Nod1Indices, const Standard_Address Nod1RValues, const Standard_Address Nod2Indices, const Standard_Address Nod2RValues) const;
242
243 Standard_EXPORT void UpdateOutLines (HLRAlgo_ListOfBPoint& List, TColStd_Array1OfTransient& PID);
244
245 Standard_EXPORT void UpdateEdgesBiPoints (HLRAlgo_ListOfBPoint& List, const TColStd_Array1OfTransient& PID, const Standard_Boolean closed);
246
247 Standard_EXPORT void UpdatePolyData (TColStd_Array1OfTransient& PD, TColStd_Array1OfTransient& PID, const Standard_Boolean closed);
248
249 Standard_EXPORT void TMultiply (Standard_Real& X, Standard_Real& Y, Standard_Real& Z, const Standard_Boolean VecPartOnly = Standard_False) const;
250
251 Standard_EXPORT void TTMultiply (Standard_Real& X, Standard_Real& Y, Standard_Real& Z, const Standard_Boolean VecPartOnly = Standard_False) const;
252
253 Standard_EXPORT void TIMultiply (Standard_Real& X, Standard_Real& Y, Standard_Real& Z, const Standard_Boolean VecPartOnly = Standard_False) const;
254
255 HLRAlgo_Projector myProj;
256 Standard_Real TMat[3][3];
257 Standard_Real TLoc[3];
258 Standard_Real TTMa[3][3];
259 Standard_Real TTLo[3];
260 Standard_Real TIMa[3][3];
261 Standard_Real TILo[3];
262 TopTools_SequenceOfShape myShapes;
263 TopTools_IndexedMapOfShape myEMap;
264 TopTools_IndexedMapOfShape myFMap;
265 Handle(HLRAlgo_PolyAlgo) myAlgo;
266 Standard_Boolean myDebug;
267 Standard_Real myAngle;
268 Standard_Real myTolSta;
269 Standard_Real myTolEnd;
270 Standard_Real myTolAngular;
271 Handle(Geom_Surface) myGSurf;
272 BRepAdaptor_Surface myBSurf;
273 BRepAdaptor_Curve myBCurv;
274 BRepAdaptor_Curve2d myPC;
275
276
277};
278
279
280#include <HLRBRep_PolyAlgo.lxx>
281
282
283
284
285
286#endif // _HLRBRep_PolyAlgo_HeaderFile