1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
// File: DBRep_HideData.cxx
// Created: Fri Sep 22 16:22:20 1995
// Author: Remi LEQUETTE
// <rle@mentox>
#include <DBRep_HideData.ixx>
#include <HLRBRep_PolyAlgo.hxx>
#include <HLRAlgo_EdgeIterator.hxx>
#include <HLRBRep_BiPoint.hxx>
#include <HLRBRep_ListIteratorOfListOfBPoint.hxx>
#define PntX1 ((Standard_Real*)Coordinates)[0]
#define PntY1 ((Standard_Real*)Coordinates)[1]
#define PntZ1 ((Standard_Real*)Coordinates)[2]
#define PntX2 ((Standard_Real*)Coordinates)[3]
#define PntY2 ((Standard_Real*)Coordinates)[4]
#define PntZ2 ((Standard_Real*)Coordinates)[5]
//=======================================================================
//function : DBRep_HideData
//purpose :
//=======================================================================
DBRep_HideData::DBRep_HideData()
{}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void DBRep_HideData::Set(const Standard_Integer viewID,
const gp_Trsf& TProj,
const Standard_Real focal,
const TopoDS_Shape& S,
const Standard_Real ang)
{
myView = viewID;
myTrsf = TProj;
myFocal = focal;
myAngle = ang;
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(S);
hider->Angle(ang);
hider->Projector(HLRAlgo_Projector(myTrsf,myFocal > 0.,myFocal));
hider->Update();
Standard_Real sta,end,dx,dy,dz;
Standard_ShortReal tolsta,tolend;
HLRAlgo_EdgeIterator It;
myBiPntVis.Clear();
myBiPntHid.Clear();
TopoDS_Shape Sori;
Standard_Boolean reg1,regn,outl,intl;
Standard_Address Coordinates;
HLRAlgo_EdgeStatus status;
for (hider->InitHide(); hider->MoreHide(); hider->NextHide()) {
hider->Hide(Coordinates,status,Sori,reg1,regn,outl,intl);
dx = PntX2 - PntX1;
dy = PntY2 - PntY1;
dz = PntZ2 - PntZ1;
for (It.InitVisible(status);
It.MoreVisible();
It.NextVisible()) {
It.Visible(sta,tolsta,end,tolend);
myBiPntVis.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
Sori,reg1,regn,outl,intl));
}
for (It.InitHidden(status);
It.MoreHidden();
It.NextHidden()) {
It.Hidden(sta,tolsta,end,tolend);
myBiPntHid.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
Sori,reg1,regn,outl,intl));
}
}
}
//=======================================================================
//function : IsSame
//purpose :
//=======================================================================
Standard_Boolean DBRep_HideData::IsSame(const gp_Trsf& TProj,
const Standard_Real focal) const
{
if (focal > 0) {
if (myFocal <= 0) return Standard_False;
if (myFocal != focal) return Standard_False;
const gp_XYZ& T1 = TProj .TranslationPart();
const gp_XYZ& T2 = myTrsf.TranslationPart();
for (Standard_Integer i = 1; i <= 3; i++) {
if (T1.Coord(i) != T2.Coord(i))
return Standard_False;
}
}
const gp_Mat& M1 = TProj .HVectorialPart();
const gp_Mat& M2 = myTrsf.HVectorialPart();
for (Standard_Integer i = 1; i <= 3; i++) {
for (Standard_Integer j = 1; j <= 3; j++) {
if (M1.Value(i,j) != M2.Value(i,j))
return Standard_False;
}
}
return Standard_True;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void DBRep_HideData::DrawOn(Draw_Display& D,
const Standard_Boolean withRg1,
const Standard_Boolean withRgN,
const Standard_Boolean withHid,
const Draw_Color& VisCol,
const Draw_Color& HidCol)
{
Standard_Boolean firstPick = Standard_True;
HLRBRep_ListIteratorOfListOfBPoint It;
// Standard_Boolean reg1,regn,outl;
if (withHid) {
D.SetColor(HidCol);
for (It.Initialize(myBiPntHid);
It.More();
It.Next()) {
const HLRBRep_BiPoint& BP = It.Value();
Standard_Boolean todraw = Standard_True;
if ((!withRg1 && BP.Rg1Line() && !BP.OutLine()) ||
(!withRgN && BP.RgNLine() && !BP.OutLine()))
todraw = Standard_False;
if (todraw) {
D.MoveTo(BP.P1());
D.DrawTo(BP.P2());
if (firstPick && D.HasPicked()) {
firstPick = Standard_False;
myPickShap = BP.Shape();
}
}
}
}
D.SetColor(VisCol);
for (It.Initialize(myBiPntVis);
It.More();
It.Next()) {
const HLRBRep_BiPoint& BP = It.Value();
Standard_Boolean todraw = Standard_True;
if ((!withRg1 && BP.Rg1Line() && !BP.OutLine()) ||
(!withRgN && BP.RgNLine() && !BP.OutLine()))
todraw = Standard_False;
if (todraw) {
D.MoveTo(BP.P1());
D.DrawTo(BP.P2());
if (firstPick && D.HasPicked()) {
firstPick = Standard_False;
myPickShap = BP.Shape();
}
}
}
}
//=======================================================================
//function : LastPick
//purpose :
//=======================================================================
const TopoDS_Shape & DBRep_HideData::LastPick () const
{ return myPickShap; }
|