0030058: Visualization, Select3D_SensitivePrimitiveArray - the selection is not fast...
[occt.git] / src / AIS / AIS_PointCloud.cxx
CommitLineData
d33222c1 1// Created on: 2014-08-13
2// Created by: Maxim GLIBIN
3// Copyright (c) 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 <AIS_PointCloud.hxx>
17
d33222c1 18#include <AIS_GraphicTool.hxx>
19#include <Graphic3d_AspectFillArea3d.hxx>
20#include <Graphic3d_AspectMarker3d.hxx>
21#include <Graphic3d_Group.hxx>
6262338c 22#include <Prs3d_Drawer.hxx>
d33222c1 23#include <Prs3d_PointAspect.hxx>
24#include <Prs3d_Presentation.hxx>
25#include <Prs3d_Root.hxx>
26#include <Prs3d_ShadingAspect.hxx>
27#include <PrsMgr_ModedPresentation.hxx>
28#include <PrsMgr_Presentations.hxx>
29#include <Select3D_SensitiveBox.hxx>
8b9a309b 30#include <Select3D_SensitivePrimitiveArray.hxx>
d33222c1 31#include <SelectMgr_EntityOwner.hxx>
32#include <SelectMgr_Selection.hxx>
5ad8c033 33#include <StdPrs_BndBox.hxx>
d33222c1 34
4a056d20 35IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloudOwner, SelectMgr_EntityOwner)
36IMPLEMENT_STANDARD_RTTIEXT(AIS_PointCloud, AIS_InteractiveObject)
d33222c1 37
4a056d20 38//=======================================================================
39//function : AIS_PointCloudOwner
40//purpose :
41//=======================================================================
42AIS_PointCloudOwner::AIS_PointCloudOwner (const Handle(AIS_PointCloud)& theOrigin)
43: SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theOrigin, 5),
44 myDetPoints (new TColStd_HPackedMapOfInteger()),
45 mySelPoints (new TColStd_HPackedMapOfInteger())
46{
47 //
48}
49
50//=======================================================================
51//function : ~AIS_PointCloudOwner
52//purpose :
53//=======================================================================
54AIS_PointCloudOwner::~AIS_PointCloudOwner()
55{
56 //
57}
58
59//=======================================================================
60//function : HilightWithColor
61//purpose :
62//=======================================================================
63Standard_Boolean AIS_PointCloudOwner::IsForcedHilight() const
64{
65 return true;
66}
67
68//=======================================================================
69//function : HilightWithColor
70//purpose :
71//=======================================================================
72void AIS_PointCloudOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
73 const Handle(Prs3d_Drawer)& theStyle,
74 const Standard_Integer )
75{
76 Handle(AIS_PointCloud) anObj = Handle(AIS_PointCloud)::DownCast (Selectable());
77 if (anObj.IsNull())
78 {
79 throw Standard_ProgramError ("Internal Error within AIS_PointCloud::PointsOwner!");
80 }
81
82 const Handle(TColStd_HPackedMapOfInteger)& aMap = thePrsMgr->IsImmediateModeOn()
83 ? myDetPoints
84 : mySelPoints;
85 Handle(Prs3d_Presentation) aPrs = thePrsMgr->IsImmediateModeOn()
86 ? anObj->GetHilightPresentation(thePrsMgr)
87 : anObj->GetSelectPresentation (thePrsMgr);
88 const Graphic3d_ZLayerId aZLayer = theStyle->ZLayer() != -1
89 ? theStyle->ZLayer()
90 : (thePrsMgr->IsImmediateModeOn() ? Graphic3d_ZLayerId_Top : anObj->ZLayer());
91 aMap->ChangeMap().Clear();
92 for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
93 {
94 const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
95 for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
96 {
97 const Handle(SelectMgr_SensitiveEntity)& aSelEnt = aSelEntIter.Value();
98 if (aSelEnt->BaseSensitive()->OwnerId() == this)
99 {
100 if (Handle(Select3D_SensitivePrimitiveArray) aSensitive = Handle(Select3D_SensitivePrimitiveArray)::DownCast (aSelEnt->BaseSensitive()))
101 {
102 aMap->ChangeMap() = aSensitive->LastDetectedElementMap()->Map();
103 if (aSensitive->LastDetectedElement() != -1)
104 {
105 aMap->ChangeMap().Add (aSensitive->LastDetectedElement());
106 }
107 break;
108 }
109 }
110 }
111 }
112
113 aPrs->Clear();
114 if (aPrs->GetZLayer() != aZLayer)
115 {
116 aPrs->SetZLayer (aZLayer);
117 }
118 if (aMap->Map().IsEmpty())
119 {
120 return;
121 }
122
123 const Handle(Graphic3d_ArrayOfPoints) anAllPoints = anObj->GetPoints();
124 if (anAllPoints.IsNull())
125 {
126 return;
127 }
128
129 Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (aMap->Map().Extent());
130 for (TColStd_PackedMapOfInteger::Iterator aPntIter (aMap->Map()); aPntIter.More(); aPntIter.Next())
131 {
132 const gp_Pnt aPnt = anAllPoints->Vertice (aPntIter.Key() + 1);
133 aPoints->AddVertex (aPnt);
134 }
135
136 Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
137 aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect());
138 aGroup->AddPrimitiveArray (aPoints);
139 if (thePrsMgr->IsImmediateModeOn())
140 {
141 thePrsMgr->AddToImmediateList (aPrs);
142 }
143 else
144 {
145 aPrs->Display();
146 }
147}
148
149//=======================================================================
150//function : Unhilight
151//purpose :
152//=======================================================================
153void AIS_PointCloudOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& , const Standard_Integer )
154{
155 if (Handle(Prs3d_Presentation) aPrs = Selectable()->GetSelectPresentation (Handle(PrsMgr_PresentationManager3d)()))
156 {
157 aPrs->Erase();
158 }
159}
160
161//=======================================================================
162//function : Clear
163//purpose :
164//=======================================================================
165void AIS_PointCloudOwner::Clear (const Handle(PrsMgr_PresentationManager)& thePrsMgr, const Standard_Integer theMode)
166{
167 SelectMgr_EntityOwner::Clear (thePrsMgr, theMode);
168}
92efcf78 169
d33222c1 170//==================================================
171// Function: AIS_PointCloud
172// Purpose : Constructor
173//==================================================
174AIS_PointCloud::AIS_PointCloud()
175{
2831708b 176 // override default point style to Aspect_TOM_POINT
177 myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_YELLOW, 1.0));
178
d33222c1 179 SetDisplayMode (AIS_PointCloud::DM_Points);
180 SetHilightMode (AIS_PointCloud::DM_BndBox);
4a056d20 181
182 myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));
d33222c1 183}
184
185//=======================================================================
186//function : GetPoints
187//purpose :
188//=======================================================================
189const Handle(Graphic3d_ArrayOfPoints) AIS_PointCloud::GetPoints() const
190{
191 return myPoints;
192}
193
194//=======================================================================
195//function : GetBoundingBox
196//purpose :
197//=======================================================================
198Bnd_Box AIS_PointCloud::GetBoundingBox() const
199{
200 return myBndBox;
201}
202
203//! Auxiliary method
204static inline Bnd_Box getBoundingBox (const Handle(Graphic3d_ArrayOfPoints)& thePoints)
205{
206 Bnd_Box aBndBox;
207 if (thePoints.IsNull())
208 {
209 return aBndBox;
210 }
211
212 const Standard_Integer aNbVertices = thePoints->VertexNumber();
213 for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter)
214 {
215 aBndBox.Add (thePoints->Vertice (aVertIter));
216 }
217 return aBndBox;
218}
219
220//=======================================================================
221//function : SetPoints
222//purpose :
223//=======================================================================
224void AIS_PointCloud::SetPoints (const Handle(Graphic3d_ArrayOfPoints)& thePoints)
225{
226 myPoints = thePoints;
227 myBndBox = getBoundingBox (thePoints);
228}
229
230//=======================================================================
231//function : SetPoints
232//purpose :
233//=======================================================================
234void AIS_PointCloud::SetPoints (const Handle(TColgp_HArray1OfPnt)& theCoords,
235 const Handle(Quantity_HArray1OfColor)& theColors,
236 const Handle(TColgp_HArray1OfDir)& theNormals)
237{
238 myPoints.Nullify();
239 myBndBox.SetVoid();
240 if (theCoords.IsNull())
241 {
242 return;
243 }
244
245 const Standard_Integer aNbPoints = theCoords->Length();
246 if ((!theNormals.IsNull() && theNormals->Length() != aNbPoints)
247 || (!theColors.IsNull() && theColors->Length() != aNbPoints))
248 {
249 // invalid input
250 return;
251 }
252
253 const Standard_Boolean hasColors = !theColors.IsNull() && theColors->Length() == aNbPoints;
254 const Standard_Boolean hasNormals = !theNormals.IsNull() && theNormals->Length() == aNbPoints;
255
256 const Standard_Integer aDiffColors = hasColors ? (theColors->Lower() - theCoords->Lower()) : 0;
257 const Standard_Integer aDiffNormals = hasNormals ? (theNormals->Lower() - theCoords->Lower()) : 0;
258
259 myPoints = new Graphic3d_ArrayOfPoints (aNbPoints, hasColors, hasNormals);
260 for (Standard_Integer aPntIter = theCoords->Lower(); aPntIter <= theCoords->Upper(); ++aPntIter)
261 {
262 myPoints->AddVertex (theCoords->Value (aPntIter));
263 if (hasColors)
264 {
265 myPoints->SetVertexColor (myPoints->VertexNumber(),
266 theColors->Value (aPntIter + aDiffColors));
267 }
268 if (hasNormals)
269 {
270 myPoints->SetVertexNormal (myPoints->VertexNumber(),
271 theNormals->Value (aPntIter + aDiffNormals));
272 }
273 }
274 myBndBox = getBoundingBox (myPoints);
275}
276
277//=======================================================================
278//function : SetColor
279//purpose :
280//=======================================================================
d33222c1 281void AIS_PointCloud::SetColor (const Quantity_Color& theColor)
282{
283 AIS_InteractiveObject::SetColor(theColor);
284
6262338c 285 if (!myDrawer->HasOwnPointAspect())
d33222c1 286 {
287 myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, theColor, 1.0));
6262338c 288 if (myDrawer->HasLink())
289 {
290 *myDrawer->PointAspect()->Aspect() = *myDrawer->Link()->PointAspect()->Aspect();
291 }
d33222c1 292 }
6262338c 293 if (!myDrawer->HasOwnShadingAspect())
d33222c1 294 {
295 myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 296 if (myDrawer->HasLink())
297 {
298 *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
299 }
d33222c1 300 }
301
302 // Override color
303 myDrawer->ShadingAspect()->SetColor (theColor);
304 myDrawer->PointAspect() ->SetColor (theColor);
305
306 const PrsMgr_Presentations& aPrsList = Presentations();
307 Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
308 Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
309 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
310 {
311 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
312 if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
313 {
314 continue;
315 }
316
317 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
d33222c1 318 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
319 {
320 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
321 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
322 {
323 aGroup->SetGroupPrimitivesAspect (aPointAspect);
324 }
325 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
326 {
327 aGroup->SetGroupPrimitivesAspect (anAreaAspect);
328 }
329 }
330 }
331}
332
333//=======================================================================
334//function : UnsetColor
335//purpose :
336//=======================================================================
337void AIS_PointCloud::UnsetColor()
338{
339 if (!HasColor())
340 {
341 return;
342 }
343
344 AIS_InteractiveObject::UnsetColor();
345
346 if (!HasWidth())
347 {
348 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
349 }
350 else
351 {
b6472664 352 myDrawer->PointAspect()->SetColor (myDrawer->HasLink()
353 ? myDrawer->Link()->PointAspect()->Aspect()->Color()
354 : Quantity_Color (Quantity_NOC_YELLOW));
d33222c1 355 }
356
357 if (HasMaterial()
358 || IsTransparent())
359 {
6262338c 360 Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
361 Graphic3d_MaterialAspect aMat = aDefaultMat;
362 if (HasMaterial() || myDrawer->HasLink())
363 {
364 aMat = AIS_GraphicTool::GetMaterial (HasMaterial() ? myDrawer : myDrawer->Link());
365 }
d33222c1 366 if (HasMaterial())
367 {
6262338c 368 Quantity_Color aColor = aDefaultMat.AmbientColor();
369 if (myDrawer->HasLink())
370 {
371 aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
372 }
d33222c1 373 aMat.SetColor (aColor);
374 }
375 if (IsTransparent())
376 {
377 Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
4e1bc39a 378 aMat.SetTransparency (Standard_ShortReal(aTransp));
d33222c1 379 }
380 myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel);
381 }
382 else
383 {
384 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
385 }
386 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
387
388 // modify shading presentation without re-computation
389 const PrsMgr_Presentations& aPrsList = Presentations();
390 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
391 Handle(Graphic3d_AspectMarker3d) aMarkerAsp = myDrawer->Link()->PointAspect()->Aspect();
392 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
393 {
394 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
395 if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
396 {
397 continue;
398 }
399
400 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
d33222c1 401 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
402 {
403 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
404
405 // Check if aspect of given type is set for the group,
406 // because setting aspect for group with no already set aspect
407 // can lead to loss of presentation data
408 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
409 {
410 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
411 }
412 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
413 {
414 aGroup->SetGroupPrimitivesAspect (aMarkerAsp);
415 }
416 }
417 }
418}
419
420//=======================================================================
421//function : SetMaterial
422//purpose :
423//=======================================================================
d33222c1 424void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
425{
6262338c 426 if (!myDrawer->HasOwnShadingAspect())
d33222c1 427 {
428 myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 429 if (myDrawer->HasLink())
430 {
431 *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
432 }
d33222c1 433 }
434 hasOwnMaterial = Standard_True;
435
436 myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
437 if (HasColor())
438 {
f838dac4 439 myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
d33222c1 440 }
f838dac4 441 myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
d33222c1 442
443 // modify shading presentation without re-computation
444 const PrsMgr_Presentations& aPrsList = Presentations();
445 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
446 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
447 {
448 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
449 if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
450 {
451 continue;
452 }
453
454 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
d33222c1 455 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
456 {
457 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
458 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
459 {
460 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
461 }
462 }
463 }
464}
465
466//=======================================================================
467//function : UnsetMaterial
468//purpose :
469//=======================================================================
470void AIS_PointCloud::UnsetMaterial()
471{
472 if (!HasMaterial())
473 {
474 return;
475 }
476
477 if (HasColor()
478 || IsTransparent())
479 {
6262338c 480 Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
481 myDrawer->ShadingAspect()->SetMaterial (myDrawer->HasLink() ?
482 myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel) :
483 aDefaultMat,
d33222c1 484 myCurrentFacingModel);
485 if (HasColor())
486 {
f838dac4 487 myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
488 myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
d33222c1 489 }
490 }
491 else
492 {
493 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
494 }
495 hasOwnMaterial = Standard_False;
496
497 // modify shading presentation without re-computation
498 const PrsMgr_Presentations& aPrsList = Presentations();
499 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
500 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
501 {
502 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
503 if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
504 {
505 continue;
506 }
507
508 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
d33222c1 509 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
510 {
511 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
512 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
513 {
514 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
515 }
516 }
517 }
518}
519
520//=======================================================================
521//function : Compute
522//purpose :
523//=======================================================================
524void AIS_PointCloud::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
525 const Handle(Prs3d_Presentation)& thePrs,
526 const Standard_Integer theMode)
527{
d33222c1 528 switch (theMode)
529 {
530 case AIS_PointCloud::DM_Points:
531 {
532 const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
533 if (aPoints.IsNull())
534 {
535 return;
536 }
537
d33222c1 538 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
2831708b 539 aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
540 aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
d33222c1 541 aGroup->AddPrimitiveArray (aPoints);
542 break;
543 }
544 case AIS_PointCloud::DM_BndBox:
545 {
546 Bnd_Box aBndBox = GetBoundingBox();
547 if (aBndBox.IsVoid())
548 {
549 return;
550 }
551
5ad8c033 552 StdPrs_BndBox::Add (thePrs, aBndBox, myDrawer);
d33222c1 553 break;
554 }
555 }
556}
557
558//=======================================================================
559//function : ComputeSelection
560//purpose :
561//=======================================================================
562void AIS_PointCloud::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
8b9a309b 563 const Standard_Integer theMode)
d33222c1 564{
8b9a309b 565 Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
566 switch (theMode)
567 {
568 case SM_Points:
4a056d20 569 case SM_SubsetOfPoints:
8b9a309b 570 {
571 const Handle(Graphic3d_ArrayOfPoints) aPoints = GetPoints();
572 if (!aPoints.IsNull()
573 && !aPoints->Attributes().IsNull())
574 {
4a056d20 575 if (theMode == SM_SubsetOfPoints)
576 {
577 anOwner = new AIS_PointCloudOwner (this);
578 }
579
a228288f 580 // split large point clouds into several groups
581 const Standard_Integer aNbGroups = aPoints->Attributes()->NbElements > 500000 ? 8 : 1;
8b9a309b 582 Handle(Select3D_SensitivePrimitiveArray) aSensitive = new Select3D_SensitivePrimitiveArray (anOwner);
4a056d20 583 aSensitive->SetDetectElements (true);
584 aSensitive->SetDetectElementMap (theMode == SM_SubsetOfPoints);
8b9a309b 585 aSensitive->SetSensitivityFactor (8);
a228288f 586 aSensitive->InitPoints (aPoints->Attributes(), aPoints->Indices(), TopLoc_Location(), true, aNbGroups);
8b9a309b 587 aSensitive->BVH();
588 theSelection->Add (aSensitive);
589 return;
590 }
591 break;
592 }
593 case SM_BndBox:
594 {
595 break;
596 }
597 default:
598 {
599 return;
600 }
601 }
602
d33222c1 603 Bnd_Box aBndBox = GetBoundingBox();
604 if (aBndBox.IsVoid())
605 {
606 return;
607 }
d33222c1 608 Handle(Select3D_SensitiveBox) aSensBox = new Select3D_SensitiveBox (anOwner, aBndBox);
609 theSelection->Add (aSensBox);
610}