b311480e |
1 | // Created on: 1995-04-05 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
7fd59977 |
18 | #include <DBRep.hxx> |
42cf5bc1 |
19 | #include <Draw.hxx> |
20 | #include <Draw_Appli.hxx> |
21 | #include <gp_Ax3.hxx> |
22 | #include <HLRAlgo_Projector.hxx> |
23 | #include <HLRAppli_ReflectLines.hxx> |
7fd59977 |
24 | #include <HLRBRep_Algo.hxx> |
25 | #include <HLRBRep_HLRToShape.hxx> |
42cf5bc1 |
26 | #include <HLRTest.hxx> |
27 | #include <HLRTest_OutLiner.hxx> |
28 | #include <HLRTest_Projector.hxx> |
29 | #include <HLRTopoBRep_OutLiner.hxx> |
30 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
31 | #include <TopoDS_Shape.hxx> |
601b1c8d |
32 | #include <TopoDS_Compound.hxx> |
33 | #include <BRep_Builder.hxx> |
bda83605 |
34 | |
7fd59977 |
35 | static Handle(HLRBRep_Algo) hider; |
57c28b61 |
36 | #ifdef _WIN32 |
7fd59977 |
37 | Standard_IMPORT Draw_Viewer dout; |
38 | #endif |
39 | |
40 | #include <BRepTopAdaptor_MapOfShapeTool.hxx> |
41 | |
42 | //======================================================================= |
43 | //function : Set |
44 | //purpose : |
45 | //======================================================================= |
46 | void HLRTest::Set (const Standard_CString Name, |
47 | const HLRAlgo_Projector& P) |
48 | { |
49 | Draw::Set(Name,new HLRTest_Projector(P)); |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : GetProjector |
54 | //purpose : |
55 | //======================================================================= |
56 | Standard_Boolean HLRTest::GetProjector (Standard_CString& Name, |
57 | HLRAlgo_Projector& P) |
58 | { |
59 | Handle(HLRTest_Projector) HP = |
60 | Handle(HLRTest_Projector)::DownCast(Draw::Get(Name)); |
61 | if (HP.IsNull()) return Standard_False; |
62 | P = HP->Projector(); |
63 | return Standard_True; |
64 | |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : Set |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | void HLRTest::Set (const Standard_CString Name, |
73 | const TopoDS_Shape& S) |
74 | { |
75 | Draw::Set(Name,new HLRTest_OutLiner(S)); |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : GetOutLiner |
80 | //purpose : |
81 | //======================================================================= |
82 | Handle(HLRTopoBRep_OutLiner) HLRTest::GetOutLiner (Standard_CString& Name) |
83 | { |
84 | Handle(Draw_Drawable3D) D = Draw::Get(Name); |
85 | Handle(HLRTest_OutLiner) HS = Handle(HLRTest_OutLiner)::DownCast(D); |
86 | if (!HS.IsNull()) return HS->OutLiner(); |
87 | Handle(HLRTopoBRep_OutLiner) HO; |
88 | return HO; |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : hprj |
93 | //purpose : |
94 | //======================================================================= |
95 | |
96 | static Standard_Integer |
97 | hprj (Draw_Interpretor& , Standard_Integer n, const char** a) |
98 | { |
7fd59977 |
99 | if (n < 2) return 1; |
7fd59977 |
100 | // |
101 | gp_Ax2 anAx2 = gp::XOY(); |
102 | if (n == 11) |
103 | { |
91322f44 |
104 | Standard_Real x = Draw::Atof(a[2]); |
105 | Standard_Real y = Draw::Atof(a[3]); |
106 | Standard_Real z = Draw::Atof(a[4]); |
7fd59977 |
107 | |
91322f44 |
108 | Standard_Real dx = Draw::Atof(a[5]); |
109 | Standard_Real dy = Draw::Atof(a[6]); |
110 | Standard_Real dz = Draw::Atof(a[7]); |
7fd59977 |
111 | |
91322f44 |
112 | Standard_Real dx1 = Draw::Atof(a[8]); |
113 | Standard_Real dy1 = Draw::Atof(a[9]); |
114 | Standard_Real dz1 = Draw::Atof(a[10]); |
7fd59977 |
115 | |
116 | gp_Pnt anOrigin (x, y, z); |
117 | gp_Dir aNormal (dx, dy, dz); |
118 | gp_Dir aDX (dx1, dy1, dz1); |
119 | anAx2 = gp_Ax2(anOrigin, aNormal, aDX); |
120 | } |
121 | |
122 | HLRAlgo_Projector P(anAx2); |
123 | HLRTest::Set(a[1],P); |
124 | return 0; |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : hout |
129 | //purpose : |
130 | //======================================================================= |
131 | |
132 | static Standard_Integer |
133 | hout (Draw_Interpretor& di, Standard_Integer n, const char** a) |
134 | { |
135 | if (n < 2) return 1; |
136 | const char *name = a[2]; |
137 | TopoDS_Shape S = DBRep::Get(name); |
138 | if (S.IsNull()) { |
586db386 |
139 | di << name << " is not a shape.\n"; |
7fd59977 |
140 | return 1; |
141 | } |
142 | HLRTest::Set(a[1],S); |
143 | return 0; |
144 | } |
145 | |
146 | //======================================================================= |
147 | //function : hfil |
148 | //purpose : |
149 | //======================================================================= |
150 | |
151 | static Standard_Integer |
152 | hfil (Draw_Interpretor& di, Standard_Integer n, const char** a) |
153 | { |
154 | Standard_Integer nbIso = 0; |
155 | if (n < 3) return 1; |
91322f44 |
156 | if (n > 3) nbIso = Draw::Atoi(a[3]); |
7fd59977 |
157 | const char *name1 = a[1]; |
158 | Handle(HLRTopoBRep_OutLiner) HS = HLRTest::GetOutLiner(name1); |
159 | if (HS.IsNull()) { |
586db386 |
160 | di << name1 << " is not an OutLiner.\n"; |
7fd59977 |
161 | return 1; |
162 | } |
163 | const char *name2 = a[2]; |
164 | HLRAlgo_Projector P; |
165 | if (!HLRTest::GetProjector(name2,P)) { |
586db386 |
166 | di << name2 << " is not a projector.\n"; |
7fd59977 |
167 | return 1; |
168 | } |
169 | BRepTopAdaptor_MapOfShapeTool MST; |
170 | HS->Fill(P,MST,nbIso); |
171 | return 0; |
172 | } |
173 | |
174 | //======================================================================= |
175 | //function : sori |
176 | //purpose : |
177 | //======================================================================= |
178 | |
179 | static Standard_Integer |
180 | sori (Draw_Interpretor& di, Standard_Integer n, const char** a) |
181 | { |
182 | if (n < 3) return 1; |
183 | const char *name1 = a[1]; |
184 | const char *name2 = a[2]; |
185 | Handle(HLRTopoBRep_OutLiner) HS = HLRTest::GetOutLiner(name2); |
186 | if (HS.IsNull()) { |
586db386 |
187 | di << name2 << " is not an OutLiner.\n"; |
7fd59977 |
188 | return 1; |
189 | } |
190 | DBRep::Set(name1,HS->OriginalShape()); |
191 | return 0; |
192 | } |
193 | |
194 | //======================================================================= |
195 | //function : sout |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | static Standard_Integer |
200 | sout (Draw_Interpretor& di, Standard_Integer n, const char** a) |
201 | { |
202 | if (n < 3) return 1; |
203 | const char *name1 = a[1]; |
204 | const char *name2 = a[2]; |
205 | Handle(HLRTopoBRep_OutLiner) HS = HLRTest::GetOutLiner(name2); |
206 | if (HS.IsNull()) { |
586db386 |
207 | di << name2 << " is not an OutLiner.\n"; |
7fd59977 |
208 | return 1; |
209 | } |
210 | if (HS->OutLinedShape().IsNull()) { |
586db386 |
211 | di << name2 << " has no OutLinedShape.\n"; |
7fd59977 |
212 | return 1; |
213 | } |
214 | DBRep::Set(name1,HS->OutLinedShape()); |
215 | return 0; |
216 | } |
217 | |
218 | //======================================================================= |
219 | //function : hloa |
220 | //purpose : |
221 | //======================================================================= |
222 | |
223 | static Standard_Integer |
224 | hloa (Draw_Interpretor& di, Standard_Integer n, const char** a) |
225 | { |
226 | if (n < 2) return 1; |
227 | const char *name1 = a[1]; |
228 | Handle(HLRTopoBRep_OutLiner) HS = HLRTest::GetOutLiner(name1); |
229 | if (HS.IsNull()) { |
586db386 |
230 | di << name1 << " is not an OutLiner.\n"; |
7fd59977 |
231 | return 1; |
232 | } |
233 | hider->Load(HS); |
234 | return 0; |
235 | } |
236 | |
237 | //======================================================================= |
238 | //function : hrem |
239 | //purpose : |
240 | //======================================================================= |
241 | |
242 | static Standard_Integer |
243 | hrem (Draw_Interpretor& di, Standard_Integer n, const char** a) |
244 | { |
245 | if (n > 1) { |
246 | const char *name = a[1]; |
247 | Standard_Integer index; |
248 | Handle(HLRTopoBRep_OutLiner) HS = HLRTest::GetOutLiner(name); |
249 | if (HS.IsNull()) { |
250 | TopoDS_Shape S = DBRep::Get(name); |
251 | if (S.IsNull()) { |
586db386 |
252 | di << name << " is not an OutLiner and not a shape.\n"; |
7fd59977 |
253 | return 1; |
254 | } |
255 | else { |
256 | index = hider->Index(S); |
257 | if (index == 0) { |
586db386 |
258 | di << name << " not loaded shape.\n"; |
7fd59977 |
259 | return 1; |
260 | } |
261 | } |
262 | } |
263 | else { |
264 | index = hider->Index(HS->OriginalShape()); |
265 | if (index == 0) { |
586db386 |
266 | di << name << " not loaded outliner.\n"; |
7fd59977 |
267 | return 1; |
268 | } |
269 | } |
270 | hider->Remove(index); |
586db386 |
271 | di << name << " removed\n"; |
7fd59977 |
272 | } |
273 | else { |
274 | while (hider->NbShapes() > 0) { |
275 | hider->Remove(1); |
276 | } |
586db386 |
277 | di << " all shapes removed\n"; |
7fd59977 |
278 | } |
279 | return 0; |
280 | } |
281 | |
282 | //======================================================================= |
283 | //function : sprj |
284 | //purpose : |
285 | //======================================================================= |
286 | |
287 | static Standard_Integer |
288 | sprj (Draw_Interpretor& di, Standard_Integer n, const char** a) |
289 | { |
290 | if (n < 2) return 1; |
291 | const char *name = a[1]; |
292 | HLRAlgo_Projector P; |
293 | if (!HLRTest::GetProjector(name,P)) { |
586db386 |
294 | di << name << " is not a projector.\n"; |
7fd59977 |
295 | return 1; |
296 | } |
297 | hider->Projector(P); |
298 | return 0; |
299 | } |
300 | |
301 | //======================================================================= |
302 | //function : upda |
303 | //purpose : |
304 | //======================================================================= |
305 | |
306 | static Standard_Integer |
307 | upda (Draw_Interpretor& , Standard_Integer, const char**) |
308 | { |
309 | hider->Update(); |
310 | return 0; |
311 | } |
312 | |
313 | //======================================================================= |
314 | //function : hide |
315 | //purpose : |
316 | //======================================================================= |
317 | |
318 | static Standard_Integer |
319 | hide (Draw_Interpretor& , Standard_Integer, const char**) |
320 | { |
321 | hider->Hide(); |
322 | return 0; |
323 | } |
324 | |
325 | //======================================================================= |
326 | //function : show |
327 | //purpose : |
328 | //======================================================================= |
329 | |
330 | static Standard_Integer |
331 | show (Draw_Interpretor& , Standard_Integer, const char**) |
332 | { |
333 | hider->ShowAll(); |
334 | return 0; |
335 | } |
336 | |
337 | //======================================================================= |
338 | //function : hdbg |
339 | //purpose : |
340 | //======================================================================= |
341 | |
342 | static Standard_Integer |
343 | hdbg (Draw_Interpretor& di, Standard_Integer, const char**) |
344 | { |
345 | hider->Debug(!hider->Debug()); |
346 | if (hider->Debug()) |
586db386 |
347 | di << "debug\n"; |
7fd59977 |
348 | else |
586db386 |
349 | di << "no debug\n"; |
7fd59977 |
350 | return 0; |
351 | } |
352 | |
353 | //======================================================================= |
354 | //function : hnul |
355 | //purpose : |
356 | //======================================================================= |
357 | |
358 | static Standard_Integer |
359 | hnul (Draw_Interpretor& , Standard_Integer, const char**) |
360 | { |
361 | hider->OutLinedShapeNullify(); |
362 | return 0; |
363 | } |
364 | |
365 | //======================================================================= |
366 | //function : hres |
367 | //purpose : |
368 | //======================================================================= |
369 | |
370 | static Standard_Integer |
371 | hres (Draw_Interpretor& , Standard_Integer n, const char** a) |
372 | { |
373 | TopoDS_Shape S,V,V1,VN,VO,VI,H,H1,HN,HO,HI; |
374 | if (n > 1) { |
375 | const char *name = a[1]; |
376 | S = DBRep::Get(name); |
377 | } |
378 | HLRBRep_HLRToShape HS(hider); |
379 | |
380 | if (S.IsNull()) { |
381 | V = HS.VCompound(); |
382 | V1 = HS.Rg1LineVCompound(); |
383 | VN = HS.RgNLineVCompound(); |
384 | VO = HS.OutLineVCompound(); |
385 | VI = HS.IsoLineVCompound(); |
386 | H = HS.HCompound(); |
387 | H1 = HS.Rg1LineHCompound(); |
388 | HN = HS.RgNLineHCompound(); |
389 | HO = HS.OutLineHCompound(); |
390 | HI = HS.IsoLineHCompound(); |
391 | } |
392 | else { |
393 | V = HS.VCompound(S); |
394 | V1 = HS.Rg1LineVCompound(S); |
395 | VN = HS.RgNLineVCompound(S); |
396 | VO = HS.OutLineVCompound(S); |
397 | VI = HS.IsoLineVCompound(S); |
398 | H = HS.HCompound(S); |
399 | H1 = HS.Rg1LineHCompound(S); |
400 | HN = HS.RgNLineHCompound(S); |
401 | HO = HS.OutLineHCompound(S); |
402 | HI = HS.IsoLineHCompound(S); |
403 | } |
404 | if (!V .IsNull()) DBRep::Set("vl",V); |
405 | if (!V1.IsNull()) DBRep::Set("v1l",V1); |
406 | if (!VN.IsNull()) DBRep::Set("vnl",VN); |
407 | if (!VO.IsNull()) DBRep::Set("vol",VO); |
408 | if (!VI.IsNull()) DBRep::Set("vil",VI); |
409 | if (!H .IsNull()) DBRep::Set("hl",H); |
410 | if (!H1.IsNull()) DBRep::Set("h1l",H1); |
411 | if (!HN.IsNull()) DBRep::Set("hnl",HN); |
412 | if (!HO.IsNull()) DBRep::Set("hol",HO); |
413 | if (!HI.IsNull()) DBRep::Set("hil",HI); |
414 | return 0; |
415 | } |
416 | |
bda83605 |
417 | //======================================================================= |
418 | //function : reflectlines |
419 | //purpose : |
420 | //======================================================================= |
421 | |
422 | static Standard_Integer reflectlines(Draw_Interpretor& , Standard_Integer n, const char** a) |
423 | { |
424 | if (n < 6) |
425 | return 1; |
426 | |
427 | TopoDS_Shape aShape = DBRep::Get(a[2]); |
428 | if (aShape.IsNull()) |
429 | return 1; |
430 | |
431 | Standard_Real anAISViewProjX = atof(a[3]); |
432 | Standard_Real anAISViewProjY = atof(a[4]); |
433 | Standard_Real anAISViewProjZ = atof(a[5]); |
434 | |
435 | gp_Pnt anOrigin(0.,0.,0.); |
436 | gp_Dir aNormal(anAISViewProjX, anAISViewProjY, anAISViewProjZ); |
437 | gp_Ax2 theAxes(anOrigin, aNormal); |
438 | gp_Dir aDX = theAxes.XDirection(); |
439 | |
440 | HLRAppli_ReflectLines Reflector(aShape); |
441 | |
442 | Reflector.SetAxes(aNormal.X(), aNormal.Y(), aNormal.Z(), |
443 | anOrigin.X(), anOrigin.Y(), anOrigin.Z(), |
444 | aDX.X(), aDX.Y(), aDX.Z()); |
445 | |
446 | Reflector.Perform(); |
447 | |
448 | TopoDS_Shape Result = Reflector.GetResult(); |
449 | DBRep::Set(a[1], Result); |
450 | |
451 | return 0; |
452 | } |
453 | |
601b1c8d |
454 | //======================================================================= |
455 | //function : hlrin3d |
456 | //purpose : |
457 | //======================================================================= |
458 | |
459 | static Standard_Integer hlrin3d(Draw_Interpretor& , Standard_Integer n, const char** a) |
460 | { |
461 | if (n < 6) |
462 | return 1; |
463 | |
464 | TopoDS_Shape aShape = DBRep::Get(a[2]); |
465 | if (aShape.IsNull()) |
466 | return 1; |
467 | |
468 | Standard_Real anAISViewProjX = atof(a[3]); |
469 | Standard_Real anAISViewProjY = atof(a[4]); |
470 | Standard_Real anAISViewProjZ = atof(a[5]); |
471 | |
472 | gp_Pnt anOrigin(0.,0.,0.); |
473 | gp_Dir aNormal(anAISViewProjX, anAISViewProjY, anAISViewProjZ); |
474 | gp_Ax2 theAxes(anOrigin, aNormal); |
475 | gp_Dir aDX = theAxes.XDirection(); |
476 | |
477 | HLRAppli_ReflectLines Reflector(aShape); |
478 | |
479 | Reflector.SetAxes(aNormal.X(), aNormal.Y(), aNormal.Z(), |
480 | anOrigin.X(), anOrigin.Y(), anOrigin.Z(), |
481 | aDX.X(), aDX.Y(), aDX.Z()); |
482 | |
483 | Reflector.Perform(); |
484 | |
485 | TopoDS_Compound Result; |
486 | BRep_Builder BB; |
487 | BB.MakeCompound(Result); |
488 | |
5ae6e53d |
489 | TopoDS_Shape SharpEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Sharp, Standard_True, Standard_True); |
854e0d4a |
490 | if (!SharpEdges.IsNull()) |
491 | BB.Add(Result, SharpEdges); |
5ae6e53d |
492 | TopoDS_Shape OutLines = Reflector.GetCompoundOf3dEdges(HLRBRep_OutLine, Standard_True, Standard_True); |
854e0d4a |
493 | if (!OutLines.IsNull()) |
494 | BB.Add(Result, OutLines); |
5ae6e53d |
495 | TopoDS_Shape SmoothEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Rg1Line, Standard_True, Standard_True); |
854e0d4a |
496 | if (!SmoothEdges.IsNull()) |
497 | BB.Add(Result, SmoothEdges); |
601b1c8d |
498 | |
499 | DBRep::Set(a[1], Result); |
500 | |
501 | return 0; |
502 | } |
503 | |
8d795b51 |
504 | //======================================================================= |
505 | //function : hlrin2d |
506 | //purpose : |
507 | //======================================================================= |
508 | |
509 | static Standard_Integer hlrin2d(Draw_Interpretor& , Standard_Integer n, const char** a) |
510 | { |
511 | if (n < 9) |
512 | return 1; |
513 | |
514 | TopoDS_Shape aShape = DBRep::Get(a[2]); |
515 | if (aShape.IsNull()) |
516 | return 1; |
517 | |
518 | Standard_Real anAISViewProjX = atof(a[3]); |
519 | Standard_Real anAISViewProjY = atof(a[4]); |
520 | Standard_Real anAISViewProjZ = atof(a[5]); |
521 | |
522 | Standard_Real Eye_X = atof(a[6]); |
523 | Standard_Real Eye_Y = atof(a[7]); |
524 | Standard_Real Eye_Z = atof(a[8]); |
525 | |
526 | |
527 | |
528 | gp_Pnt anOrigin(0.,0.,0.); |
529 | gp_Dir aNormal(anAISViewProjX, anAISViewProjY, anAISViewProjZ); |
530 | gp_Dir aDX(Eye_X, Eye_Y, Eye_Z); |
531 | |
532 | HLRAppli_ReflectLines Reflector(aShape); |
533 | |
534 | Reflector.SetAxes(aNormal.X(), aNormal.Y(), aNormal.Z(), |
535 | anOrigin.X(), anOrigin.Y(), anOrigin.Z(), |
536 | aDX.X(), aDX.Y(), aDX.Z()); |
537 | |
538 | Reflector.Perform(); |
539 | |
540 | TopoDS_Compound Result; |
541 | BRep_Builder BB; |
542 | BB.MakeCompound(Result); |
543 | |
544 | TopoDS_Shape SharpEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Sharp, Standard_True, Standard_False); |
545 | if (!SharpEdges.IsNull()) |
546 | BB.Add(Result, SharpEdges); |
547 | TopoDS_Shape OutLines = Reflector.GetCompoundOf3dEdges(HLRBRep_OutLine, Standard_True, Standard_False); |
548 | if (!OutLines.IsNull()) |
549 | BB.Add(Result, OutLines); |
550 | TopoDS_Shape SmoothEdges = Reflector.GetCompoundOf3dEdges(HLRBRep_Rg1Line, Standard_True, Standard_False); |
551 | if (!SmoothEdges.IsNull()) |
552 | BB.Add(Result, SmoothEdges); |
553 | |
554 | DBRep::Set(a[1], Result); |
555 | |
556 | return 0; |
557 | } |
558 | |
7fd59977 |
559 | //======================================================================= |
560 | //function : Commands |
561 | //purpose : |
562 | //======================================================================= |
563 | |
564 | void HLRTest::Commands (Draw_Interpretor& theCommands) |
565 | { |
566 | const char* g = "ADVALGOS HLR Commands"; |
567 | |
568 | theCommands.Add("hprj" ,"hprj name [view-id = 1]" ,__FILE__,hprj,g); |
569 | theCommands.Add("houtl" ,"houtl name shape" ,__FILE__,hout,g); |
570 | theCommands.Add("hfill" ,"hfill name proj [nbIso]" ,__FILE__,hfil,g); |
571 | theCommands.Add("hsin" ,"hsin name outliner" ,__FILE__,sori,g); |
572 | theCommands.Add("hsout" ,"hsout name outliner" ,__FILE__,sout,g); |
573 | theCommands.Add("hload" ,"hload outliner" ,__FILE__,hloa,g); |
574 | theCommands.Add("hremove" ,"hremove [name]" ,__FILE__,hrem,g); |
575 | theCommands.Add("hsetprj" ,"hsetprj [name]" ,__FILE__,sprj,g); |
576 | theCommands.Add("hupdate" ,"hupdate" ,__FILE__,upda,g); |
577 | theCommands.Add("hhide" ,"hhide" ,__FILE__,hide,g); |
578 | theCommands.Add("hshowall" ,"hshowall" ,__FILE__,show,g); |
579 | theCommands.Add("hdebug" ,"hdebug" ,__FILE__,hdbg,g); |
580 | theCommands.Add("hnullify" ,"hnullify" ,__FILE__,hnul,g); |
581 | theCommands.Add("hres2d" ,"hres2d" ,__FILE__,hres,g); |
bda83605 |
582 | |
583 | theCommands.Add("reflectlines", |
584 | "reflectlines res shape proj_X proj_Y proj_Z", |
585 | __FILE__, reflectlines, g); |
586 | |
601b1c8d |
587 | theCommands.Add("hlrin3d", |
588 | "hlrin3d res shape proj_X proj_Y proj_Z", |
589 | __FILE__, hlrin3d, g); |
590 | |
8d795b51 |
591 | theCommands.Add("hlrin2d", |
592 | "hlrin2d res shape proj_X proj_Y proj_Z eye_x eye_y eye_z", |
593 | __FILE__, hlrin2d, g); |
594 | |
7fd59977 |
595 | hider = new HLRBRep_Algo(); |
596 | } |
597 | |
598 | //======================================================================= |
599 | //function : save and restore projector |
600 | //purpose : |
601 | //======================================================================= |
602 | |
603 | static Standard_Boolean stest(const Handle(Draw_Drawable3D)& d) |
604 | { |
605 | return d->IsInstance(STANDARD_TYPE(HLRTest_Projector)); |
606 | } |
607 | |
608 | //======================================================================= |
609 | //function : ssave |
610 | //purpose : |
611 | //======================================================================= |
612 | |
613 | static void ssave (const Handle(Draw_Drawable3D)&d, ostream& OS) |
614 | { |
615 | Handle(HLRTest_Projector) HP = |
616 | Handle(HLRTest_Projector)::DownCast(d); |
617 | |
618 | const HLRAlgo_Projector& P = HP->Projector(); |
619 | OS << (P.Perspective() ? "1" : "0") << "\n"; |
620 | if (P.Perspective()) |
621 | OS << P.Focus() << "\n"; |
622 | |
623 | gp_Trsf T = P.Transformation(); |
624 | gp_XYZ V = T.TranslationPart(); |
625 | gp_Mat M = T.VectorialPart(); |
626 | |
627 | OS << M(1,1) << " "; |
628 | OS << M(1,2) << " "; |
629 | OS << M(1,3) << " "; |
630 | OS << V.Coord(1) << " "; |
631 | OS << "\n"; |
632 | OS << M(2,1) << " "; |
633 | OS << M(2,2) << " "; |
634 | OS << M(2,3) << " "; |
635 | OS << V.Coord(2) << " "; |
636 | OS << "\n"; |
637 | OS << M(3,1) << " "; |
638 | OS << M(3,2) << " "; |
639 | OS << M(3,3) << " "; |
640 | OS << V.Coord(3) << " "; |
641 | OS << "\n"; |
642 | |
643 | } |
644 | |
645 | //======================================================================= |
646 | //function : srestore |
647 | //purpose : |
648 | //======================================================================= |
649 | |
650 | static Handle(Draw_Drawable3D) srestore (istream& IS) |
651 | { |
652 | Standard_Boolean pers; |
653 | IS >> pers; |
654 | Standard_Real focus = 1; |
655 | if (pers) IS >> focus; |
656 | |
657 | gp_Trsf T; |
658 | Standard_Real V1[3],V2[3],V3[3]; |
659 | Standard_Real V[3]; |
660 | |
661 | IS >> V1[0] >> V1[1] >> V1[2] >> V[0]; |
662 | IS >> V2[0] >> V2[1] >> V2[2] >> V[1]; |
663 | IS >> V3[0] >> V3[1] >> V3[2] >> V[2]; |
664 | |
665 | gp_Dir D1(V1[0],V1[1],V1[2]); |
666 | gp_Dir D2(V2[0],V2[1],V2[2]); |
667 | gp_Dir D3(V3[0],V3[1],V3[2]); |
668 | gp_Ax3 axes(gp_Pnt(0,0,0),D3,D1); |
669 | D3.Cross(D1); |
670 | if (D3.Dot(D2) < 0) axes.YReverse(); |
671 | T.SetTransformation(axes); |
672 | |
673 | T.SetTranslationPart(gp_Vec(V[0],V[1],V[2])); |
674 | |
675 | HLRAlgo_Projector P(T,pers,focus); |
676 | Handle(HLRTest_Projector) HP = new HLRTest_Projector(P); |
677 | return HP; |
678 | } |
679 | |
680 | //======================================================================= |
681 | //function : ssr |
682 | //purpose : |
683 | //======================================================================= |
684 | |
685 | static Draw_SaveAndRestore ssr("HLRTest_Projector",stest,ssave,srestore); |
686 | |