0032337: Visualization - rename Overlaps() method in selection to more self-describab...
[occt.git] / src / SelectMgr / SelectMgr_SelectingVolumeManager.cxx
CommitLineData
f751596e 1// Created on: 2014-05-22
2// Created by: Varvara POSKONINA
3// Copyright (c) 2005-2014 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#include <SelectMgr_SelectingVolumeManager.hxx>
e1eb39d2 17
18#include <Graphic3d_SequenceOfHClipPlane.hxx>
0461e7fd 19#include <SelectMgr_AxisIntersector.hxx>
e1eb39d2 20#include <SelectMgr_RectangularFrustum.hxx>
21#include <SelectMgr_TriangularFrustumSet.hxx>
22
23#include <BVH_Tools.hxx>
bc73b006 24#include <Standard_Dump.hxx>
f751596e 25
26//=======================================================================
27// function : SelectMgr_SelectingVolumeManager
28// purpose : Creates instances of all available selecting volume types
29//=======================================================================
e1eb39d2 30SelectMgr_SelectingVolumeManager::SelectMgr_SelectingVolumeManager()
31: myActiveSelectingVolume (NULL),
32 myToAllowOverlap (Standard_False)
f751596e 33{
f751596e 34}
35
36//=======================================================================
3bf9a45f 37// function : ScaleAndTransform
38// purpose : IMPORTANT: Scaling makes sense only for frustum built on a single point!
39// Note that this method does not perform any checks on type of the frustum.
40//
41// Returns a copy of the frustum resized according to the scale factor given
42// and transforms it using the matrix given.
43// There are no default parameters, but in case if:
44// - transformation only is needed: @theScaleFactor must be initialized
45// as any negative value;
46// - scale only is needed: @theTrsf must be set to gp_Identity.
099f3513 47// Builder is an optional argument that represents corresponding settings for
48// re-constructing transformed frustum from scratch. Can be null if reconstruction
49// is not needed furthermore in the code.
3bf9a45f 50//=======================================================================
51SelectMgr_SelectingVolumeManager SelectMgr_SelectingVolumeManager::ScaleAndTransform (const Standard_Integer theScaleFactor,
099f3513 52 const gp_GTrsf& theTrsf,
53 const Handle(SelectMgr_FrustumBuilder)& theBuilder) const
f751596e 54{
e1eb39d2 55 SelectMgr_SelectingVolumeManager aMgr;
56 if (myActiveSelectingVolume.IsNull())
57 {
f751596e 58 return aMgr;
e1eb39d2 59 }
f751596e 60
e1eb39d2 61 aMgr.myActiveSelectingVolume = myActiveSelectingVolume->ScaleAndTransform (theScaleFactor, theTrsf, theBuilder);
2157d6ac 62 aMgr.myToAllowOverlap = myToAllowOverlap;
8b1441e3 63 aMgr.myViewClipPlanes = myViewClipPlanes;
fe525c6f 64 aMgr.myObjectClipPlanes = myObjectClipPlanes;
d7fa57a7 65 aMgr.myViewClipRange = myViewClipRange;
f751596e 66
67 return aMgr;
68}
69
70//=======================================================================
71// function : GetActiveSelectionType
72// purpose :
73//=======================================================================
7ab15952 74Standard_Integer SelectMgr_SelectingVolumeManager::GetActiveSelectionType() const
f751596e 75{
e1eb39d2 76 if (myActiveSelectingVolume.IsNull())
77 {
78 return SelectMgr_SelectionType_Unknown;
79 }
80 return myActiveSelectingVolume->GetSelectionType();
f751596e 81}
82
83//=======================================================================
e1eb39d2 84// function : Camera
f751596e 85// purpose :
86//=======================================================================
e1eb39d2 87const Handle(Graphic3d_Camera)& SelectMgr_SelectingVolumeManager::Camera() const
f751596e 88{
e1eb39d2 89 if (myActiveSelectingVolume.IsNull())
90 {
91 static const Handle(Graphic3d_Camera) anEmptyCamera;
92 return anEmptyCamera;
93 }
94 return myActiveSelectingVolume->Camera();
f751596e 95}
96
97//=======================================================================
98// function : SetCamera
e1eb39d2 99// purpose :
f751596e 100//=======================================================================
101void SelectMgr_SelectingVolumeManager::SetCamera (const Handle(Graphic3d_Camera) theCamera)
102{
e1eb39d2 103 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
104 "SelectMgr_SelectingVolumeManager::SetCamera() should be called after initialization of selection volume ");
105 myActiveSelectingVolume->SetCamera (theCamera);
f751596e 106}
107
108//=======================================================================
109// function : SetCamera
110// purpose : Updates camera projection and orientation matrices in all
111// selecting volumes
112//=======================================================================
113void SelectMgr_SelectingVolumeManager::SetCamera (const Graphic3d_Mat4d& theProjection,
825aa485 114 const Graphic3d_Mat4d& theWorldView,
115 const Standard_Boolean theIsOrthographic,
116 const Graphic3d_WorldViewProjState& theWVPState)
f751596e 117{
e1eb39d2 118 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
119 "SelectMgr_SelectingVolumeManager::SetCamera() should be called after initialization of selection volume ");
120 myActiveSelectingVolume->SetCamera (theProjection, theWorldView, theIsOrthographic, theWVPState);
f751596e 121}
122
825aa485 123//=======================================================================
124// function : ProjectionMatrix
125// purpose : Returns current projection transformation common for all
126// selecting volumes
127//=======================================================================
128const Graphic3d_Mat4d& SelectMgr_SelectingVolumeManager::ProjectionMatrix() const
129{
e1eb39d2 130 if (myActiveSelectingVolume.IsNull())
131 {
132 static const Graphic3d_Mat4d anEmptyMatrix;
133 return anEmptyMatrix;
134 }
135 return myActiveSelectingVolume->ProjectionMatrix();
825aa485 136}
137
138//=======================================================================
139// function : WorldViewMatrix
140// purpose : Returns current world view transformation common for all
141// selecting volumes
142//=======================================================================
143const Graphic3d_Mat4d& SelectMgr_SelectingVolumeManager::WorldViewMatrix() const
144{
e1eb39d2 145 if (myActiveSelectingVolume.IsNull())
146 {
147 static const Graphic3d_Mat4d anEmptyMatrix;
148 return anEmptyMatrix;
149 }
150 return myActiveSelectingVolume->WorldViewMatrix();
825aa485 151}
152
153//=======================================================================
154// function : WorldViewProjState
155// purpose : Returns current camera world view projection transformation
156// state common for all selecting volumes
157//=======================================================================
158const Graphic3d_WorldViewProjState& SelectMgr_SelectingVolumeManager::WorldViewProjState() const
159{
e1eb39d2 160 if (myActiveSelectingVolume.IsNull())
161 {
162 static const Graphic3d_WorldViewProjState anEmptyState;
163 return anEmptyState;
164 }
165 return myActiveSelectingVolume->WorldViewProjState();
825aa485 166}
167
91d96372 168//=======================================================================
169// function : WindowSize
170// purpose :
171//=======================================================================
099f3513 172void SelectMgr_SelectingVolumeManager::WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const
91d96372 173{
e1eb39d2 174 if (myActiveSelectingVolume.IsNull())
175 {
176 return;
177 }
178 myActiveSelectingVolume->WindowSize (theWidth, theHeight);
179}
180
181//=======================================================================
182// function : SetWindowSize
183// purpose : Updates window size in all selecting volumes
184//=======================================================================
185void SelectMgr_SelectingVolumeManager::SetWindowSize (const Standard_Integer theWidth,
186 const Standard_Integer theHeight)
187{
188 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
189 "SelectMgr_SelectingVolumeManager::SetWindowSize() should be called after initialization of selection volume ");
190 myActiveSelectingVolume->SetWindowSize (theWidth, theHeight);
91d96372 191}
192
f751596e 193//=======================================================================
194// function : SetCamera
195// purpose : Updates viewport in all selecting volumes
196//=======================================================================
197void SelectMgr_SelectingVolumeManager::SetViewport (const Standard_Real theX,
198 const Standard_Real theY,
199 const Standard_Real theWidth,
200 const Standard_Real theHeight)
201{
e1eb39d2 202 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
203 "SelectMgr_SelectingVolumeManager::SetViewport() should be called after initialization of selection volume ");
204 myActiveSelectingVolume->SetViewport (theX, theY, theWidth, theHeight);
205}
206
207//=======================================================================
208// function : SetPixelTolerance
209// purpose : Updates pixel tolerance in all selecting volumes
210//=======================================================================
211void SelectMgr_SelectingVolumeManager::SetPixelTolerance (const Standard_Integer theTolerance)
212{
213 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
214 "SelectMgr_SelectingVolumeManager::SetPixelTolerance() should be called after initialization of selection volume ");
215 myActiveSelectingVolume->SetPixelTolerance (theTolerance);
216}
217
218//=======================================================================
219// function : InitPointSelectingVolume
220// purpose :
221//=======================================================================
222void SelectMgr_SelectingVolumeManager::InitPointSelectingVolume (const gp_Pnt2d& thePoint)
223{
224 Handle(SelectMgr_RectangularFrustum) aPntVolume = Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
225 if (aPntVolume.IsNull())
f751596e 226 {
e1eb39d2 227 aPntVolume = new SelectMgr_RectangularFrustum();
f751596e 228 }
e1eb39d2 229 aPntVolume->Init (thePoint);
230 myActiveSelectingVolume = aPntVolume;
f751596e 231}
232
233//=======================================================================
e1eb39d2 234// function : InitBoxSelectingVolume
235// purpose :
f751596e 236//=======================================================================
e1eb39d2 237void SelectMgr_SelectingVolumeManager::InitBoxSelectingVolume (const gp_Pnt2d& theMinPt,
238 const gp_Pnt2d& theMaxPt)
f751596e 239{
e1eb39d2 240 Handle(SelectMgr_RectangularFrustum) aBoxVolume = Handle(SelectMgr_RectangularFrustum)::DownCast(myActiveSelectingVolume);
241 if (aBoxVolume.IsNull())
f751596e 242 {
e1eb39d2 243 aBoxVolume = new SelectMgr_RectangularFrustum();
f751596e 244 }
e1eb39d2 245 aBoxVolume->Init (theMinPt, theMaxPt);
246 myActiveSelectingVolume = aBoxVolume;
f751596e 247}
248
249//=======================================================================
e1eb39d2 250// function : InitPolylineSelectingVolume
251// purpose :
f751596e 252//=======================================================================
e1eb39d2 253void SelectMgr_SelectingVolumeManager::InitPolylineSelectingVolume (const TColgp_Array1OfPnt2d& thePoints)
f751596e 254{
e1eb39d2 255 Handle(SelectMgr_TriangularFrustumSet) aPolylineVolume = Handle(SelectMgr_TriangularFrustumSet)::DownCast(myActiveSelectingVolume);
256 if (aPolylineVolume.IsNull())
f751596e 257 {
e1eb39d2 258 aPolylineVolume = new SelectMgr_TriangularFrustumSet();
f751596e 259 }
e1eb39d2 260 aPolylineVolume->Init (thePoints);
261 myActiveSelectingVolume = aPolylineVolume;
262 aPolylineVolume->SetAllowOverlapDetection (IsOverlapAllowed());
263}
264
0461e7fd 265//=======================================================================
266// function : InitAxisSelectingVolume
267// purpose :
268//=======================================================================
269void SelectMgr_SelectingVolumeManager::InitAxisSelectingVolume (const gp_Ax1& theAxis)
270{
271 Handle(SelectMgr_AxisIntersector) anAxisVolume = Handle(SelectMgr_AxisIntersector)::DownCast(myActiveSelectingVolume);
272 if (anAxisVolume.IsNull())
273 {
274 anAxisVolume = new SelectMgr_AxisIntersector();
275 }
276 anAxisVolume->Init (theAxis);
277 myActiveSelectingVolume = anAxisVolume;
278}
279
e1eb39d2 280//=======================================================================
281// function : InitSelectingVolume
282// purpose :
283//=======================================================================
284void SelectMgr_SelectingVolumeManager::InitSelectingVolume(const Handle(SelectMgr_BaseIntersector)& theVolume)
285{
286 myActiveSelectingVolume = theVolume;
f751596e 287}
288
289//=======================================================================
290// function : BuildSelectingVolume
e1eb39d2 291// purpose :
f751596e 292//=======================================================================
e1eb39d2 293void SelectMgr_SelectingVolumeManager::BuildSelectingVolume()
f751596e 294{
e1eb39d2 295 Standard_ASSERT_RAISE (!myActiveSelectingVolume.IsNull(),
296 "SelectMgr_SelectingVolumeManager::BuildSelectingVolume() should be called after initialization of active selection volume.");
297 myActiveSelectingVolume->Build();
298}
f751596e 299
e1eb39d2 300//=======================================================================
301// function : BuildSelectingVolume
302// purpose :
303//=======================================================================
304void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const gp_Pnt2d& thePoint)
305{
306 InitPointSelectingVolume (thePoint);
307 myActiveSelectingVolume->Build();
f751596e 308}
309
310//=======================================================================
311// function : BuildSelectingVolume
e1eb39d2 312// purpose :
f751596e 313//=======================================================================
314void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const gp_Pnt2d& theMinPt,
315 const gp_Pnt2d& theMaxPt)
316{
e1eb39d2 317 InitBoxSelectingVolume (theMinPt, theMaxPt);
318 myActiveSelectingVolume->Build();
f751596e 319}
320
321//=======================================================================
322// function : BuildSelectingVolume
e1eb39d2 323// purpose :
f751596e 324//=======================================================================
325void SelectMgr_SelectingVolumeManager::BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints)
326{
e1eb39d2 327 InitPolylineSelectingVolume (thePoints);
328 myActiveSelectingVolume->Build();
f751596e 329}
330
331//=======================================================================
03c9cc86 332// function : OverlapsBox
f751596e 333// purpose : SAT intersection test between defined volume and
334// given axis-aligned box
335//=======================================================================
03c9cc86 336Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox (const SelectMgr_Vec3& theBoxMin,
337 const SelectMgr_Vec3& theBoxMax,
338 SelectBasics_PickResult& thePickResult) const
f751596e 339{
e1eb39d2 340 if (myActiveSelectingVolume.IsNull())
341 {
f751596e 342 return Standard_False;
e1eb39d2 343 }
f751596e 344
03c9cc86 345 return myActiveSelectingVolume->OverlapsBox (theBoxMin, theBoxMax, myViewClipRange, thePickResult);
f751596e 346}
347
348//=======================================================================
03c9cc86 349// function : OverlapsBox
f751596e 350// purpose : Intersection test between defined volume and given point
351//=======================================================================
03c9cc86 352Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsBox (const SelectMgr_Vec3& theBoxMin,
353 const SelectMgr_Vec3& theBoxMax,
354 Standard_Boolean* theInside) const
f751596e 355{
e1eb39d2 356 if (myActiveSelectingVolume.IsNull())
357 {
f751596e 358 return Standard_False;
e1eb39d2 359 }
f751596e 360
03c9cc86 361 return myActiveSelectingVolume->OverlapsBox (theBoxMin, theBoxMax, theInside);
f751596e 362}
363
364//=======================================================================
03c9cc86 365// function : OverlapsPoint
f751596e 366// purpose : Intersection test between defined volume and given point
367//=======================================================================
03c9cc86 368Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt& thePnt,
369 SelectBasics_PickResult& thePickResult) const
f751596e 370{
e1eb39d2 371 if (myActiveSelectingVolume.IsNull())
372 {
f751596e 373 return Standard_False;
e1eb39d2 374 }
f751596e 375
03c9cc86 376 return myActiveSelectingVolume->OverlapsPoint (thePnt, myViewClipRange, thePickResult);
f751596e 377}
378
3bf9a45f 379//=======================================================================
03c9cc86 380// function : OverlapsPoint
3bf9a45f 381// purpose : Intersection test between defined volume and given point
382//=======================================================================
03c9cc86 383Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPoint (const gp_Pnt& thePnt) const
3bf9a45f 384{
e1eb39d2 385 if (myActiveSelectingVolume.IsNull())
386 {
3bf9a45f 387 return Standard_False;
e1eb39d2 388 }
3bf9a45f 389
03c9cc86 390 return myActiveSelectingVolume->OverlapsPoint (thePnt);
3bf9a45f 391}
392
f751596e 393//=======================================================================
03c9cc86 394// function : OverlapsPolygon
f751596e 395// purpose : SAT intersection test between defined volume and given
396// ordered set of points, representing line segments. The test
397// may be considered of interior part or boundary line defined
398// by segments depending on given sensitivity type
399//=======================================================================
03c9cc86 400Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPolygon (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
401 Standard_Integer theSensType,
402 SelectBasics_PickResult& thePickResult) const
f751596e 403{
e1eb39d2 404 if (myActiveSelectingVolume.IsNull())
405 {
f751596e 406 return Standard_False;
e1eb39d2 407 }
f751596e 408
03c9cc86 409 return myActiveSelectingVolume->OverlapsPolygon (theArrayOfPnts->Array1(), (Select3D_TypeOfSensitivity)theSensType,
410 myViewClipRange, thePickResult);
114b7bf1 411}
412
413//=======================================================================
03c9cc86 414// function : OverlapsPolygon
114b7bf1 415// purpose : SAT intersection test between defined volume and given
416// ordered set of points, representing line segments. The test
417// may be considered of interior part or boundary line defined
418// by segments depending on given sensitivity type
419//=======================================================================
03c9cc86 420Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
421 Standard_Integer theSensType,
422 SelectBasics_PickResult& thePickResult) const
114b7bf1 423{
e1eb39d2 424 if (myActiveSelectingVolume.IsNull())
425 {
114b7bf1 426 return Standard_False;
e1eb39d2 427 }
114b7bf1 428
03c9cc86 429 return myActiveSelectingVolume->OverlapsPolygon (theArrayOfPnts, (Select3D_TypeOfSensitivity)theSensType,
430 myViewClipRange, thePickResult);
f751596e 431}
432
433//=======================================================================
03c9cc86 434// function : OverlapsSegment
f751596e 435// purpose : Checks if line segment overlaps selecting volume
436//=======================================================================
03c9cc86 437Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsSegment (const gp_Pnt& thePt1,
438 const gp_Pnt& thePt2,
439 SelectBasics_PickResult& thePickResult) const
f751596e 440{
e1eb39d2 441 if (myActiveSelectingVolume.IsNull())
442 {
f751596e 443 return Standard_False;
e1eb39d2 444 }
f751596e 445
03c9cc86 446 return myActiveSelectingVolume->OverlapsSegment (thePt1, thePt2, myViewClipRange, thePickResult);
f751596e 447}
448
449//=======================================================================
03c9cc86 450// function : OverlapsTriangle
f751596e 451// purpose : SAT intersection test between defined volume and given
452// triangle. The test may be considered of interior part or
453// boundary line defined by triangle vertices depending on
454// given sensitivity type
455//=======================================================================
03c9cc86 456Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsTriangle (const gp_Pnt& thePt1,
457 const gp_Pnt& thePt2,
458 const gp_Pnt& thePt3,
459 Standard_Integer theSensType,
460 SelectBasics_PickResult& thePickResult) const
f751596e 461{
e1eb39d2 462 if (myActiveSelectingVolume.IsNull())
463 {
f751596e 464 return Standard_False;
e1eb39d2 465 }
f751596e 466
03c9cc86 467 return myActiveSelectingVolume->OverlapsTriangle (thePt1, thePt2, thePt3, (Select3D_TypeOfSensitivity)theSensType,
468 myViewClipRange, thePickResult);
f751596e 469}
470
471//=======================================================================
472// function : DistToGeometryCenter
473// purpose : Measures distance between 3d projection of user-picked
474// screen point and given point theCOG
475//=======================================================================
4a056d20 476Standard_Real SelectMgr_SelectingVolumeManager::DistToGeometryCenter (const gp_Pnt& theCOG) const
f751596e 477{
e1eb39d2 478 if (myActiveSelectingVolume.IsNull())
479 {
480 return RealLast();
481 }
482 return myActiveSelectingVolume->DistToGeometryCenter (theCOG);
f751596e 483}
484
485// =======================================================================
486// function : DetectedPoint
487// purpose : Calculates the point on a view ray that was detected during
488// the run of selection algo by given depth. Is valid for point
489// selection only
490// =======================================================================
3bf9a45f 491gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theDepth) const
f751596e 492{
e1eb39d2 493 Standard_ASSERT_RAISE(!myActiveSelectingVolume.IsNull(),
494 "SelectMgr_SelectingVolumeManager::DetectedPoint() should be called after initialization of selection volume");
495 return myActiveSelectingVolume->DetectedPoint (theDepth);
f751596e 496}
497
2157d6ac 498//=======================================================================
499// function : AllowOverlapDetection
500// purpose : If theIsToAllow is false, only fully included sensitives will
501// be detected, otherwise the algorithm will mark both included
502// and overlapped entities as matched
503//=======================================================================
504void SelectMgr_SelectingVolumeManager::AllowOverlapDetection (const Standard_Boolean theIsToAllow)
505{
506 myToAllowOverlap = theIsToAllow;
507}
508
509//=======================================================================
510// function : IsOverlapAllowed
511// purpose :
512//=======================================================================
513Standard_Boolean SelectMgr_SelectingVolumeManager::IsOverlapAllowed() const
514{
e1eb39d2 515 return myToAllowOverlap || GetActiveSelectionType() == SelectMgr_SelectionType_Point;
2157d6ac 516}
3bf9a45f 517
518//=======================================================================
519// function : GetVertices
520// purpose :
521//=======================================================================
522const gp_Pnt* SelectMgr_SelectingVolumeManager::GetVertices() const
523{
e1eb39d2 524 if (myActiveSelectingVolume.IsNull())
525 {
3bf9a45f 526 return NULL;
e1eb39d2 527 }
528 const SelectMgr_RectangularFrustum* aRectFrustum =
529 static_cast<const SelectMgr_RectangularFrustum*> (myActiveSelectingVolume.get());
530 if (aRectFrustum == NULL)
531 {
532 return NULL;
533 }
534 return aRectFrustum->GetVertices();
3bf9a45f 535}
536
537//=======================================================================
21a8e275 538// function : GetNearPickedPnt
3bf9a45f 539// purpose :
540//=======================================================================
21a8e275 541gp_Pnt SelectMgr_SelectingVolumeManager::GetNearPickedPnt() const
3bf9a45f 542{
e1eb39d2 543 if (myActiveSelectingVolume.IsNull())
544 {
3bf9a45f 545 return gp_Pnt();
e1eb39d2 546 }
547 return myActiveSelectingVolume->GetNearPnt();
3bf9a45f 548}
549
550//=======================================================================
21a8e275 551// function : GetFarPickedPnt
3bf9a45f 552// purpose :
553//=======================================================================
21a8e275 554gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
3bf9a45f 555{
e1eb39d2 556 if (myActiveSelectingVolume.IsNull())
557 {
558 return gp_Pnt(RealLast(), RealLast(), RealLast());
559 }
560 return myActiveSelectingVolume->GetFarPnt();
561}
562
563//=======================================================================
564// function : GetViewRayDirection
565// purpose :
566//=======================================================================
567gp_Dir SelectMgr_SelectingVolumeManager::GetViewRayDirection() const
568{
569 if (myActiveSelectingVolume.IsNull())
570 {
571 return gp_Dir();
572 }
573 return myActiveSelectingVolume->GetViewRayDirection();
574}
575
576//=======================================================================
577// function : IsScalableActiveVolume
578// purpose :
579//=======================================================================
580Standard_Boolean SelectMgr_SelectingVolumeManager::IsScalableActiveVolume() const
581{
582 if (myActiveSelectingVolume.IsNull())
583 {
584 return Standard_False;
585 }
586 return myActiveSelectingVolume->IsScalable();
587}
588
589//=======================================================================
590// function : GetMousePosition
591// purpose :
592//=======================================================================
593gp_Pnt2d SelectMgr_SelectingVolumeManager::GetMousePosition() const
594{
595 if (myActiveSelectingVolume.IsNull())
596 {
597 return gp_Pnt2d(RealLast(), RealLast());
598 }
599 return myActiveSelectingVolume->GetMousePosition();
600}
3bf9a45f 601
e1eb39d2 602//=======================================================================
603// function : GetPlanes
604// purpose :
605//=======================================================================
606void SelectMgr_SelectingVolumeManager::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
607{
608 if (myActiveSelectingVolume.IsNull())
609 {
610 thePlaneEquations.Clear();
611 return;
612 }
613 return myActiveSelectingVolume->GetPlanes (thePlaneEquations);
3bf9a45f 614}
e9312c0f 615
616//=======================================================================
617// function : SetViewClipping
618// purpose :
619//=======================================================================
fe525c6f 620void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
72e9e867 621 const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
622 const SelectMgr_SelectingVolumeManager* theWorldSelMgr)
e9312c0f 623{
fe525c6f 624 myViewClipPlanes = theViewPlanes;
625 myObjectClipPlanes = theObjPlanes;
e1eb39d2 626 if (GetActiveSelectionType() != SelectMgr_SelectionType_Point)
627 {
e9312c0f 628 return;
e1eb39d2 629 }
e9312c0f 630
72e9e867 631 const SelectMgr_SelectingVolumeManager* aWorldSelMgr = theWorldSelMgr != NULL ? theWorldSelMgr : this;
d7fa57a7 632 myViewClipRange.SetVoid();
633 if (!theViewPlanes.IsNull()
634 && !theViewPlanes->IsEmpty())
635 {
e1eb39d2 636 myViewClipRange.AddClippingPlanes (*theViewPlanes,
637 gp_Ax1(aWorldSelMgr->myActiveSelectingVolume->GetNearPnt(),
638 aWorldSelMgr->myActiveSelectingVolume->GetViewRayDirection()));
d7fa57a7 639 }
640 if (!theObjPlanes.IsNull()
641 && !theObjPlanes->IsEmpty())
642 {
e1eb39d2 643 myViewClipRange.AddClippingPlanes (*theObjPlanes,
644 gp_Ax1(aWorldSelMgr->myActiveSelectingVolume->GetNearPnt(),
645 aWorldSelMgr->myActiveSelectingVolume->GetViewRayDirection()));
d7fa57a7 646 }
3202bf1e 647}
208dc370 648
649//=======================================================================
650// function : SetViewClipping
651// purpose :
652//=======================================================================
653void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther)
654{
d7fa57a7 655 myViewClipPlanes = theOther.myViewClipPlanes;
656 myObjectClipPlanes = theOther.myObjectClipPlanes;
657 myViewClipRange = theOther.myViewClipRange;
208dc370 658}
bc73b006 659
660//=======================================================================
661//function : DumpJson
662//purpose :
663//=======================================================================
664void SelectMgr_SelectingVolumeManager::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
665{
666 OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_SelectingVolumeManager)
667
e1eb39d2 668 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myActiveSelectingVolume.get())
bc73b006 669 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myViewClipPlanes.get())
670 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myObjectClipPlanes.get())
671
672 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewClipRange)
673 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToAllowOverlap)
674}