1 // Created on: 2003-09-09
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <AIS_InteractiveContext.hxx>
18 #include <Aspect_InteriorStyle.hxx>
19 #include <Bnd_Box.hxx>
21 #include <Graphic3d_AspectFillArea3d.hxx>
22 #include <Graphic3d_MaterialAspect.hxx>
23 #include <Graphic3d_NameOfMaterial.hxx>
24 #include <MeshVS_Buffer.hxx>
25 #include <MeshVS_CommonSensitiveEntity.hxx>
26 #include <MeshVS_DataMapIteratorOfDataMapOfIntegerOwner.hxx>
27 #include <MeshVS_DataSource.hxx>
28 #include <MeshVS_Drawer.hxx>
29 #include <MeshVS_DrawerAttribute.hxx>
30 #include <MeshVS_DummySensitiveEntity.hxx>
31 #include <MeshVS_Mesh.hxx>
32 #include <MeshVS_MeshEntityOwner.hxx>
33 #include <MeshVS_MeshOwner.hxx>
34 #include <MeshVS_PrsBuilder.hxx>
35 #include <MeshVS_SelectionModeFlags.hxx>
36 #include <MeshVS_SensitiveFace.hxx>
37 #include <MeshVS_SensitiveMesh.hxx>
38 #include <MeshVS_SensitivePolyhedron.hxx>
39 #include <MeshVS_SensitiveSegment.hxx>
40 #include <MeshVS_SensitiveQuad.hxx>
41 #include <OSD_Timer.hxx>
42 #include <Prs3d_LineAspect.hxx>
43 #include <Prs3d_PointAspect.hxx>
44 #include <Prs3d_Presentation.hxx>
45 #include <Prs3d_Root.hxx>
46 #include <Prs3d_ShadingAspect.hxx>
47 #include <PrsMgr_ModedPresentation.hxx>
48 #include <PrsMgr_PresentationManager3d.hxx>
49 #include <Select3D_SensitiveBox.hxx>
50 #include <Select3D_SensitiveGroup.hxx>
51 #include <Select3D_SensitivePoint.hxx>
52 #include <Select3D_SensitiveTriangle.hxx>
53 #include <SelectBasics_SensitiveEntity.hxx>
54 #include <SelectMgr_EntityOwner.hxx>
55 #include <SelectMgr_Selection.hxx>
56 #include <SelectMgr_SequenceOfOwner.hxx>
57 #include <Standard_Type.hxx>
58 #include <StdSelect_BRepSelectionTool.hxx>
59 #include <TColgp_Array1OfPnt.hxx>
60 #include <TColStd_Array1OfInteger.hxx>
61 #include <TColStd_Array1OfReal.hxx>
62 #include <TColStd_HPackedMapOfInteger.hxx>
63 #include <TColStd_ListIteratorOfListOfInteger.hxx>
64 #include <TColStd_ListIteratorOfListOfReal.hxx>
65 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
66 #include <TColStd_SequenceOfInteger.hxx>
68 IMPLEMENT_STANDARD_RTTIEXT(MeshVS_Mesh,AIS_InteractiveObject)
70 //================================================================
71 // Function : Constructor MeshVS_Mesh
73 //================================================================
74 MeshVS_Mesh::MeshVS_Mesh (const Standard_Boolean theIsAllowOverlapped )
76 myDataSource.Nullify();
77 myHilighter.Nullify();
78 myWholeMeshOwner.Nullify();
79 mySelectionMethod = MeshVS_MSM_NODES;
81 SetAutoHilight ( Standard_False );
83 SetDisplayMode( MeshVS_DMF_WireFrame ); // Mode as defaut
84 SetHilightMode( MeshVS_DMF_WireFrame ); // Wireframe as default hilight mode
86 SetColor ( Quantity_NOC_WHITE );
87 SetMaterial ( Graphic3d_NOM_PLASTIC );
89 myCurrentDrawer = new MeshVS_Drawer();
90 myCurrentDrawer->SetColor ( MeshVS_DA_InteriorColor, Quantity_NOC_BLUE4 );
91 myCurrentDrawer->SetInteger ( MeshVS_DA_InteriorStyle, Aspect_IS_SOLID );
92 myCurrentDrawer->SetInteger ( MeshVS_DA_MaxFaceNodes, 10 );
93 myCurrentDrawer->SetBoolean ( MeshVS_DA_IsAllowOverlapped, theIsAllowOverlapped );
94 myCurrentDrawer->SetBoolean ( MeshVS_DA_Reflection, Standard_True );
95 myCurrentDrawer->SetDouble ( MeshVS_DA_ShrinkCoeff, 0.8 );
96 myCurrentDrawer->SetBoolean ( MeshVS_DA_ComputeTime, Standard_False );
97 myCurrentDrawer->SetBoolean ( MeshVS_DA_ComputeSelectionTime, Standard_False );
98 myCurrentDrawer->SetBoolean ( MeshVS_DA_DisplayNodes, Standard_True );
99 myCurrentDrawer->SetDouble ( MeshVS_DA_EdgeWidth, 1.0 );
100 myCurrentDrawer->SetInteger ( MeshVS_DA_EdgeType, Aspect_TOL_SOLID );
101 myCurrentDrawer->SetInteger ( MeshVS_DA_MarkerType, Aspect_TOM_O );
102 myCurrentDrawer->SetColor ( MeshVS_DA_MarkerColor, Quantity_NOC_WHITE );
103 myCurrentDrawer->SetDouble ( MeshVS_DA_MarkerScale, 1.0 );
104 myCurrentDrawer->SetInteger ( MeshVS_DA_BeamType, Aspect_TOL_SOLID );
105 myCurrentDrawer->SetDouble ( MeshVS_DA_BeamWidth, 1.0 );
106 myCurrentDrawer->SetBoolean ( MeshVS_DA_SmoothShading, Standard_False );
107 myCurrentDrawer->SetBoolean ( MeshVS_DA_SupressBackFaces, Standard_False );
109 mySelectionDrawer = new MeshVS_Drawer();
110 mySelectionDrawer->Assign ( myCurrentDrawer );
111 mySelectionDrawer->SetInteger ( MeshVS_DA_MarkerType, Aspect_TOM_STAR );
112 mySelectionDrawer->SetColor ( MeshVS_DA_MarkerColor, Quantity_NOC_GRAY80 );
113 mySelectionDrawer->SetDouble ( MeshVS_DA_MarkerScale, 2.0 );
115 mySelectionDrawer->SetColor ( MeshVS_DA_BeamColor, Quantity_NOC_GRAY80 );
116 mySelectionDrawer->SetInteger ( MeshVS_DA_BeamType, Aspect_TOL_SOLID );
117 mySelectionDrawer->SetDouble ( MeshVS_DA_BeamWidth, 3.0 );
119 myHilightDrawer = new MeshVS_Drawer ();
120 myHilightDrawer->Assign ( myCurrentDrawer );
121 myHilightDrawer->SetDouble ( MeshVS_DA_ShrinkCoeff, 0.7 );
122 myHilightDrawer->SetInteger ( MeshVS_DA_InteriorStyle, Aspect_IS_SOLID );
123 myHilightDrawer->SetColor ( MeshVS_DA_InteriorColor, Quantity_NOC_YELLOW );
124 myHilightDrawer->SetColor ( MeshVS_DA_BackInteriorColor, Quantity_NOC_YELLOW );
125 myHilightDrawer->SetColor ( MeshVS_DA_EdgeColor, Quantity_NOC_GREEN );
126 myHilightDrawer->SetInteger ( MeshVS_DA_EdgeType, Aspect_TOL_SOLID );
127 myHilightDrawer->SetDouble ( MeshVS_DA_EdgeWidth, 1.0 );
128 myHilightDrawer->SetMaterial ( MeshVS_DA_FrontMaterial, Graphic3d_NOM_PLASTIC );
129 myHilightDrawer->SetMaterial ( MeshVS_DA_BackMaterial, Graphic3d_NOM_PLASTIC );
131 myHilightDrawer->SetColor ( MeshVS_DA_BeamColor, Quantity_NOC_GRAY80 );
132 myHilightDrawer->SetInteger ( MeshVS_DA_BeamType, Aspect_TOL_SOLID );
133 myHilightDrawer->SetDouble ( MeshVS_DA_BeamWidth, 3.0 );
135 myHilightDrawer->SetInteger ( MeshVS_DA_MarkerType, Aspect_TOM_STAR );
136 myHilightDrawer->SetColor ( MeshVS_DA_MarkerColor, Quantity_NOC_GRAY80 );
137 myHilightDrawer->SetDouble ( MeshVS_DA_MarkerScale, 2.0 );
140 //================================================================
141 // Function : Compute
143 //================================================================
144 void MeshVS_Mesh::Compute ( const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
145 const Handle(Prs3d_Presentation)& thePresentation,
146 const Standard_Integer theMode )
150 Standard_Boolean ShowComputeTime = Standard_True;
151 myCurrentDrawer->GetBoolean( MeshVS_DA_ComputeTime, ShowComputeTime );
153 if ( ShowComputeTime )
159 // Repair Ids in map if necessary
160 Handle( MeshVS_DataSource ) aDS = GetDataSource();
164 const TColStd_PackedMapOfInteger& aNodes = aDS->GetAllNodes();
165 const TColStd_PackedMapOfInteger& aElems = aDS->GetAllElements();
166 Standard_Boolean HasNodes = !aNodes.IsEmpty(),
167 HasElements = !aElems.IsEmpty();
169 TColStd_PackedMapOfInteger aNodesToExclude, aElemsToExclude;
171 thePresentation->Clear();
172 Standard_Integer len = myBuilders.Length();
174 for ( Standard_Integer i=1; i<=len; i++ )
176 Handle (MeshVS_PrsBuilder) aCurrent = myBuilders.Value ( i );
177 if ( !aCurrent.IsNull() && aCurrent->TestFlags ( theMode ) )
179 aCurrent->SetPresentationManager( thePrsMgr );
181 aCurrent->Build ( thePresentation, aNodes, aNodesToExclude, Standard_False, theMode );
183 aCurrent->Build ( thePresentation, aElems, aElemsToExclude, Standard_True, theMode );
188 if ( ShowComputeTime )
190 Standard_Real sec, cpu;
191 Standard_Integer min, hour;
193 gTimer.Show ( sec, min, hour, cpu );
194 cout << "DisplayMode : " << theMode << endl;
195 cout << "Compute : " << sec << " sec" << endl;
196 cout << "Compute CPU : " << cpu << " sec" << endl << endl;
201 //================================================================
202 // Function : scanFacesForSharedNodes
204 //================================================================
205 void MeshVS_Mesh::scanFacesForSharedNodes (const TColStd_PackedMapOfInteger& theAllElements,
206 const Standard_Integer theNbMaxFaceNodes,
207 TColStd_PackedMapOfInteger& theSharedNodes) const
209 theSharedNodes.Clear();
210 MeshVS_EntityType aType;
211 Standard_Integer aNbNodes;
212 MeshVS_Buffer aCoordsBuf (3 * theNbMaxFaceNodes * sizeof (Standard_Real));
213 TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3 * theNbMaxFaceNodes);
214 for (TColStd_MapIteratorOfPackedMapOfInteger aFaceIter (theAllElements); aFaceIter.More(); aFaceIter.Next())
216 const Standard_Integer aFaceIdx = aFaceIter.Key();
218 if (IsSelectableElem (aFaceIdx) &&
219 myDataSource->GetGeomType (aFaceIdx, Standard_True, aType) &&
220 aType == MeshVS_ET_Face)
222 myDataSource->GetGeom (aFaceIdx, Standard_True, aCoords, aNbNodes, aType );
226 MeshVS_Buffer aNodesBuf (aNbNodes * sizeof (Standard_Integer));
227 TColStd_Array1OfInteger aElemNodes (aNodesBuf, 1, aNbNodes);
228 if (!myDataSource->GetNodesByElement (aFaceIdx, aElemNodes, aNbNodes))
231 MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
232 TColgp_Array1OfPnt aFacePnts (aFacePntsBuf, 1, aNbNodes);
233 for (Standard_Integer aNodeIdx = 1; aNodeIdx <= aNbNodes; ++aNodeIdx)
235 theSharedNodes.Add (aElemNodes (aNodeIdx));
241 //================================================================
242 // Function : ComputeSelection
244 //================================================================
245 void MeshVS_Mesh::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
246 const Standard_Integer theMode)
249 Standard_Boolean toShowComputeSelectionTime = Standard_True;
250 myCurrentDrawer->GetBoolean( MeshVS_DA_ComputeSelectionTime, toShowComputeSelectionTime);
251 if (toShowComputeSelectionTime)
257 Standard_Integer aMaxFaceNodes = 0;
258 Handle(MeshVS_DataSource) aSource = GetDataSource();
260 || myCurrentDrawer.IsNull()
261 || !myCurrentDrawer->GetInteger (MeshVS_DA_MaxFaceNodes, aMaxFaceNodes)
262 || aMaxFaceNodes <= 0)
267 const Standard_Integer aMode = HasDisplayMode() ? DisplayMode() : DefaultDisplayMode();
268 if (myHilighter.IsNull()
269 || (aMode & MeshVS_DMF_OCCMask) == 0)
274 // Make two array aliases pointing to the same memory:
275 // - TColStd_Array1OfReal for getting values from MeshVS_DataSource interface
276 // - array of gp_Pnt for convenient work with array of points
277 MeshVS_Buffer aCoordsBuf (3 * aMaxFaceNodes * sizeof(Standard_Real));
278 NCollection_Array1<gp_Pnt> aPntArray (aCoordsBuf, 1, aMaxFaceNodes);
279 TColStd_Array1OfReal aPntArrayAsCoordArray (aCoordsBuf, 1, 3 * aMaxFaceNodes);
281 const TColStd_PackedMapOfInteger& anAllNodesMap = aSource->GetAllNodes();
282 const TColStd_PackedMapOfInteger& anAllElementsMap = aSource->GetAllElements();
283 if (aSource->IsAdvancedSelectionEnabled())
285 Handle(MeshVS_MeshOwner) anOwner;
286 for (MeshVS_DataMapIteratorOfDataMapOfIntegerOwner anIt (GetOwnerMaps (Standard_False)); anIt.More(); anIt.Next())
288 anOwner = Handle(MeshVS_MeshOwner)::DownCast (anIt.Value());
289 if (!anOwner.IsNull())
291 // get the owner if it is already created
295 if (anOwner.IsNull())
297 // create one owner for the whole mesh and for all selection modes
298 anOwner = new MeshVS_MeshOwner (this, aSource, 5);
301 // Save the owner. It will be available via GetOwnerMaps method
302 if (!myMeshOwners.IsBound (1))
304 myMeshOwners.Bind (1, anOwner);
306 // Create one sensitive entity. It should detect mesh entities correspondingly to selection mode
307 Handle(MeshVS_SensitiveMesh) aSensMesh = new MeshVS_SensitiveMesh (anOwner, theMode);
308 theSelection->Add (aSensMesh);
314 case MeshVS_SMF_Node:
316 myNodeOwners.Clear();
317 for (TColStd_MapIteratorOfPackedMapOfInteger anIter (anAllNodesMap); anIter.More(); anIter.Next())
319 const Standard_Integer aKey = anIter.Key();
320 Standard_Integer aNbNodes = 0;
321 MeshVS_EntityType aType = MeshVS_ET_NONE;
322 if (!myDataSource->GetGeom (aKey, Standard_False, aPntArrayAsCoordArray, aNbNodes, aType))
327 Standard_Address anAddr = myDataSource->GetAddr (aKey, Standard_False);
328 Handle(MeshVS_MeshEntityOwner) anOwner = new MeshVS_MeshEntityOwner (this, aKey, anAddr, aType, 5);
329 myNodeOwners.Bind (aKey, anOwner);
330 if (IsSelectableNode (aKey))
332 Handle(Select3D_SensitivePoint) aPoint = new Select3D_SensitivePoint (anOwner, aPntArray.First());
333 theSelection->Add (aPoint);
337 theSelection->Add (new MeshVS_DummySensitiveEntity (anOwner));
342 case MeshVS_SMF_Mesh:
344 if (myWholeMeshOwner.IsNull())
346 myWholeMeshOwner = new SelectMgr_EntityOwner (this);
349 switch (mySelectionMethod)
354 BoundingBox (aBndBox);
355 if (!aBndBox.IsVoid())
357 theSelection->Add (new Select3D_SensitiveBox (myWholeMeshOwner, aBndBox));
361 case MeshVS_MSM_NODES:
363 theSelection->Add (new MeshVS_CommonSensitiveEntity (myWholeMeshOwner, this, MeshVS_MSM_NODES));
366 case MeshVS_MSM_PRECISE:
368 theSelection->Add (new MeshVS_CommonSensitiveEntity (myWholeMeshOwner, this, MeshVS_MSM_PRECISE));
370 // since MeshVS_Mesh objects can contain free edges and vertices, it is necessary to create
371 // separate sensitive entity for each of them
372 TColStd_PackedMapOfInteger aSharedNodes;
373 scanFacesForSharedNodes (anAllElementsMap, aMaxFaceNodes, aSharedNodes);
375 // create sensitive entities for free edges, if there are any
376 Standard_Integer aNbNodes = 0;
377 MeshVS_EntityType aType = MeshVS_ET_NONE;
378 for (TColStd_MapIteratorOfPackedMapOfInteger anElemIter (anAllElementsMap); anElemIter.More(); anElemIter.Next())
380 const Standard_Integer anElemIdx = anElemIter.Key();
381 if (IsSelectableElem (anElemIdx)
382 && myDataSource->GetGeomType (anElemIdx, Standard_True, aType)
383 && aType == MeshVS_ET_Link)
385 myDataSource->GetGeom (anElemIdx, Standard_True, aPntArrayAsCoordArray, aNbNodes, aType);
391 MeshVS_Buffer aNodesBuf (aNbNodes * sizeof(Standard_Integer));
392 TColStd_Array1OfInteger aElemNodes (aNodesBuf, 1, aNbNodes);
393 if (!myDataSource->GetNodesByElement (anElemIdx, aElemNodes, aNbNodes))
398 MeshVS_Buffer aPntsBuf (aNbNodes * 3 * sizeof(Standard_Real));
399 TColgp_Array1OfPnt aLinkPnts (aPntsBuf, 1, aNbNodes);
400 Standard_Boolean isVertsShared = Standard_True;
401 for (Standard_Integer aPntIdx = 1; aPntIdx <= aNbNodes; ++aPntIdx)
403 aLinkPnts (aPntIdx) = aPntArray.Value (aPntIdx);
404 isVertsShared = isVertsShared && aSharedNodes.Contains (aElemNodes (aPntIdx));
405 aSharedNodes.Add (aElemNodes (aPntIdx));
410 Handle(Select3D_SensitiveEntity) aLinkEnt = new Select3D_SensitiveSegment (myWholeMeshOwner, aLinkPnts.Value (1), aLinkPnts.Value (2));
411 theSelection->Add (aLinkEnt);
416 // create sensitive entities for free nodes, if there are any
417 for (TColStd_MapIteratorOfPackedMapOfInteger aNodesIter (anAllNodesMap); aNodesIter.More(); aNodesIter.Next())
419 const Standard_Integer aNodeIdx = aNodesIter.Key();
420 if (IsSelectableNode (aNodeIdx)
421 && myDataSource->GetGeom (aNodeIdx, Standard_False, aPntArrayAsCoordArray, aNbNodes, aType)
422 && !aSharedNodes.Contains (aNodeIdx))
424 Handle(Select3D_SensitiveEntity) aNodeEnt = new Select3D_SensitivePoint (myWholeMeshOwner, aPntArray.First());
425 theSelection->Add (aNodeEnt);
433 case MeshVS_SMF_Group:
435 myGroupOwners.Clear();
437 TColStd_PackedMapOfInteger anAllGroupsMap;
438 aSource->GetAllGroups (anAllGroupsMap);
440 Handle(MeshVS_HArray1OfSequenceOfInteger) aTopo;
441 for (TColStd_MapIteratorOfPackedMapOfInteger anIter (anAllGroupsMap); anIter.More(); anIter.Next())
443 const Standard_Integer aKeyGroup = anIter.Key();
444 MeshVS_EntityType aGroupType = MeshVS_ET_NONE;
445 TColStd_PackedMapOfInteger aGroupMap;
446 if (!myDataSource->GetGroup (aKeyGroup, aGroupType, aGroupMap))
451 Standard_Address anAddr = myDataSource->GetGroupAddr (aKeyGroup);
452 Standard_Integer aPrior = 0;
455 case MeshVS_ET_Volume: aPrior = 1; break;
456 case MeshVS_ET_Face: aPrior = 2; break;
457 case MeshVS_ET_Link: aPrior = 3; break;
458 case MeshVS_ET_0D: aPrior = 4; break;
459 case MeshVS_ET_Node: aPrior = 5; break;
463 Handle(MeshVS_MeshEntityOwner) anOwner = new MeshVS_MeshEntityOwner (this, aKeyGroup, anAddr, aGroupType, aPrior, Standard_True);
464 myGroupOwners.Bind (aKeyGroup, anOwner);
466 Standard_Boolean added = Standard_False;
467 Standard_Integer aNbNodes = 0;
468 MeshVS_EntityType aType = MeshVS_ET_NONE;
469 for (TColStd_MapIteratorOfPackedMapOfInteger anIterMG (aGroupMap); anIterMG.More(); anIterMG.Next())
471 Standard_Integer aKey = anIterMG.Key();
472 if (aGroupType == MeshVS_ET_Node)
474 if (myDataSource->GetGeom (aKey, Standard_False, aPntArrayAsCoordArray, aNbNodes, aType)
475 && IsSelectableNode/*!IsHiddenNode*/(aKey))
477 theSelection->Add (new Select3D_SensitivePoint (anOwner, aPntArray.First ()));
478 added = Standard_True;
481 else if (myDataSource->GetGeomType (aKey, Standard_True, aType)
482 && IsSelectableElem/*!IsHiddenElem*/(aKey))
484 myDataSource->GetGeom (aKey, Standard_True, aPntArrayAsCoordArray, aNbNodes, aType);
485 if (aType == MeshVS_ET_Face && aNbNodes > 0) // Faces: 2D-elements
487 Handle(Select3D_SensitiveEntity) aSensFace;
490 aSensFace = new Select3D_SensitiveTriangle (anOwner,
491 aPntArray.Value (1), aPntArray.Value (2), aPntArray.Value (3),
492 Select3D_TOS_INTERIOR);
494 else if (aNbNodes == 4)
496 aSensFace = new MeshVS_SensitiveQuad (anOwner, aPntArray);
500 aSensFace = new MeshVS_SensitiveFace (anOwner, aPntArray);
502 theSelection->Add (aSensFace);
503 added = Standard_True;
505 else if (aType == MeshVS_ET_Link && aNbNodes > 0) // Links: 1D-elements
507 Handle (MeshVS_SensitiveSegment) aSeg = new MeshVS_SensitiveSegment (anOwner, aPntArray (1), aPntArray (2));
508 theSelection->Add (aSeg);
509 added = Standard_True;
511 else if (aType == MeshVS_ET_Volume
512 && aSource->Get3DGeom (aKey, aNbNodes, aTopo))
514 Handle(MeshVS_SensitivePolyhedron) aPolyhedron = new MeshVS_SensitivePolyhedron (anOwner, aPntArray, aTopo);
515 theSelection->Add (aPolyhedron);
516 added = Standard_True;
518 else //if ( aType == MeshVS_ET_0D ) // Custom : not only 0D-elements !!!
520 Handle(SelectBasics_SensitiveEntity) anEnt = myHilighter->CustomSensitiveEntity (anOwner, aKey);
523 theSelection->Add (anEnt);
524 added = Standard_True;
531 theSelection->Add (new MeshVS_DummySensitiveEntity (anOwner));
536 default: // all residuary modes
538 Handle(MeshVS_HArray1OfSequenceOfInteger) aTopo;
539 myElementOwners.Clear();
541 MeshVS_DataMapOfIntegerOwner* aCurMap = &my0DOwners;
542 if (theMode == MeshVS_ET_Link)
544 aCurMap = &myLinkOwners;
546 else if (theMode == MeshVS_ET_Face)
548 aCurMap = &myFaceOwners;
550 else if (theMode == MeshVS_ET_Volume)
552 aCurMap = &myVolumeOwners;
556 Standard_Integer aNbNodes = 0;
557 MeshVS_EntityType aType = MeshVS_ET_NONE;
558 for (TColStd_MapIteratorOfPackedMapOfInteger anIterMV (anAllElementsMap); anIterMV.More(); anIterMV.Next())
560 Standard_Integer aKey = anIterMV.Key();
561 if (myDataSource->GetGeomType (aKey, Standard_True, aType)
564 myDataSource->GetGeom (aKey, Standard_True, aPntArrayAsCoordArray, aNbNodes, aType);
565 Standard_Address anAddr = myDataSource->GetAddr (aKey, Standard_True);
567 Standard_Integer aPrior = 0;
570 case MeshVS_ET_Volume: aPrior = 1; break;
571 case MeshVS_ET_Face: aPrior = 2; break;
572 case MeshVS_ET_Link: aPrior = 3; break;
573 case MeshVS_ET_0D: aPrior = 4; break;
577 Handle(MeshVS_MeshEntityOwner) anOwner = new MeshVS_MeshEntityOwner (this, aKey, anAddr, aType, aPrior);
578 aCurMap->Bind (aKey, anOwner);
579 if (IsSelectableElem (aKey)) // The element is selectable
581 if (aType == MeshVS_ET_Face && aNbNodes > 0) // Faces: 2D-elements
583 Handle(Select3D_SensitiveEntity) aSensFace;
586 aSensFace = new Select3D_SensitiveTriangle (anOwner,
587 aPntArray.Value (1), aPntArray.Value (2), aPntArray.Value (3),
588 Select3D_TOS_INTERIOR);
590 else if (aNbNodes == 4)
592 aSensFace = new MeshVS_SensitiveQuad (anOwner, aPntArray);
596 aSensFace = new MeshVS_SensitiveFace (anOwner, aPntArray);
598 theSelection->Add (aSensFace);
600 else if (aType == MeshVS_ET_Link && aNbNodes > 0) // Links: 1D-elements
602 Handle(MeshVS_SensitiveSegment) aSeg = new MeshVS_SensitiveSegment (anOwner, aPntArray (1), aPntArray (2));
603 theSelection->Add (aSeg);
605 else if (aType == MeshVS_ET_Volume
606 && aSource->Get3DGeom (aKey, aNbNodes, aTopo))
608 Handle(MeshVS_SensitivePolyhedron) aPolyhedron = new MeshVS_SensitivePolyhedron (anOwner, aPntArray, aTopo);
609 theSelection->Add (aPolyhedron);
611 else //if ( aType == MeshVS_ET_0D ) // Custom : not only 0D-elements !!!
613 Handle(SelectBasics_SensitiveEntity) anEnt = myHilighter->CustomSensitiveEntity (anOwner, aKey);
616 theSelection->Add (anEnt);
622 theSelection->Add (new MeshVS_DummySensitiveEntity (anOwner));
631 StdSelect_BRepSelectionTool::PreBuildBVH (theSelection);
633 if (toShowComputeSelectionTime)
635 Standard_Real sec, cpu;
636 Standard_Integer min, hour;
637 gTimer.Show (sec, min, hour, cpu);
638 std::cout << "SelectionMode : " << theMode << "\n";
639 std::cout << "Compute selection: " << sec << " sec\n";
640 std::cout << "Compute selection CPU : " << cpu << " sec\n\n";
645 //================================================================
646 // Function : GetBuildersCount
648 //================================================================
649 Standard_Integer MeshVS_Mesh::GetBuildersCount () const
651 return myBuilders.Length();
654 //================================================================
655 // Function : GetFreeId
657 //================================================================
658 Standard_Integer MeshVS_Mesh::GetFreeId () const
660 TColStd_PackedMapOfInteger Ids;
661 Standard_Integer i, len = myBuilders.Length(), curId;
663 for ( i=1; i<=len; i++ )
664 Ids.Add( myBuilders.Value(i)->GetId () );
667 while ( Ids.Contains( curId ) )
673 //================================================================
674 // Function : GetBuilder
676 //================================================================
677 Handle (MeshVS_PrsBuilder) MeshVS_Mesh::GetBuilder ( const Standard_Integer Index ) const
679 if ( Index>=1 && Index<=myBuilders.Length() )
680 return myBuilders.Value( Index );
685 //================================================================
686 // Function : GetBuilderById
688 //================================================================
689 Handle (MeshVS_PrsBuilder) MeshVS_Mesh::GetBuilderById ( const Standard_Integer Id ) const
691 Handle (MeshVS_PrsBuilder) Result;
693 Standard_Integer i, len = myBuilders.Length();
694 for ( i=1; i<=len; i++ )
695 if ( myBuilders.Value(i)->GetId () == Id )
697 Result = myBuilders.Value(i);
703 //================================================================
704 // Function : AddBuilder
706 //================================================================
707 void MeshVS_Mesh::AddBuilder ( const Handle (MeshVS_PrsBuilder)& theBuilder,
708 const Standard_Boolean TreatAsHilighter )
710 if ( theBuilder.IsNull() )
713 Standard_Integer i, n = myBuilders.Length();
714 for ( i = 1; i<=n; i++ )
715 if ( myBuilders(i)->GetPriority() < theBuilder->GetPriority() )
719 myBuilders.Append ( theBuilder );
721 myBuilders.InsertBefore ( i, theBuilder );
723 if( TreatAsHilighter )
724 myHilighter = theBuilder;
727 //================================================================
728 // Function : RemoveBuilder
730 //================================================================
731 void MeshVS_Mesh::RemoveBuilder ( const Standard_Integer theIndex )
733 Handle( MeshVS_PrsBuilder ) aBuild = GetBuilder( theIndex );
734 if ( !aBuild.IsNull() )
736 if ( aBuild == myHilighter )
737 myHilighter.Nullify();
738 myBuilders.Remove ( theIndex );
742 //================================================================
743 // Function : RemoveBuilderById
745 //================================================================
746 void MeshVS_Mesh::RemoveBuilderById ( const Standard_Integer Id )
748 Standard_Integer i, n = myBuilders.Length();
749 for ( i=1; i<=n; i++ )
751 Handle( MeshVS_PrsBuilder ) aCur = myBuilders(i);
752 if ( !aCur.IsNull() && aCur->GetId()==Id )
757 if ( GetBuilder( i )==myHilighter )
758 myHilighter.Nullify();
763 //================================================================
764 // Function : SetHiddenElems
766 //================================================================
767 void MeshVS_Mesh::SetHiddenElems ( const Handle(TColStd_HPackedMapOfInteger)& theMap )
769 myHiddenElements = theMap;
771 // Note: update of list of selectable nodes -- this is not optimal!
772 Standard_Boolean AutoSelUpdate = Standard_False;
773 if ( !GetDrawer().IsNull() && GetDrawer()->GetBoolean( MeshVS_DA_SelectableAuto, AutoSelUpdate ) &&
775 UpdateSelectableNodes();
778 //================================================================
779 // Function : SetHiddenNodes
781 //================================================================
782 void MeshVS_Mesh::SetHiddenNodes ( const Handle(TColStd_HPackedMapOfInteger)& theMap )
784 myHiddenNodes = theMap;
786 // Note: update of list of selectable nodes -- this is not optimal!
787 Standard_Boolean AutoSelUpdate = Standard_False;
788 if ( !GetDrawer().IsNull() && GetDrawer()->GetBoolean( MeshVS_DA_SelectableAuto, AutoSelUpdate ) &&
790 UpdateSelectableNodes();
793 //================================================================
794 // Function : GetHiddenElems
796 //================================================================
797 const Handle(TColStd_HPackedMapOfInteger)& MeshVS_Mesh::GetHiddenElems () const
799 return myHiddenElements;
802 //================================================================
803 // Function : GetHiddenNodes
805 //================================================================
806 const Handle(TColStd_HPackedMapOfInteger)& MeshVS_Mesh::GetHiddenNodes () const
808 return myHiddenNodes;
811 //================================================================
812 // Function : AddToMap
814 //================================================================
815 void AddToMap ( MeshVS_DataMapOfIntegerOwner& Result, const MeshVS_DataMapOfIntegerOwner& Addition )
817 MeshVS_DataMapIteratorOfDataMapOfIntegerOwner anIt ( Addition );
818 for ( ; anIt.More(); anIt.Next() )
819 if ( Result.IsBound ( anIt.Key() ) )
820 Result.ChangeFind ( anIt.Key() ) = anIt.Value();
822 Result.Bind( anIt.Key(), anIt.Value() );
825 //================================================================
826 // Function : GetOwnerMaps
828 //================================================================
829 const MeshVS_DataMapOfIntegerOwner& MeshVS_Mesh::GetOwnerMaps ( const Standard_Boolean IsElements )
831 Handle(MeshVS_DataSource) aDS = GetDataSource();
832 if( !aDS.IsNull() && aDS->IsAdvancedSelectionEnabled() )
836 if ( myElementOwners.IsEmpty() )
838 AddToMap ( myElementOwners, my0DOwners );
839 AddToMap ( myElementOwners, myLinkOwners );
840 AddToMap ( myElementOwners, myFaceOwners );
841 AddToMap ( myElementOwners, myVolumeOwners );
843 return myElementOwners;
849 //================================================================
850 // Function : IsHiddenElem
852 //================================================================
853 Standard_Boolean MeshVS_Mesh::IsHiddenElem ( const Standard_Integer theID ) const
855 return ! myHiddenElements.IsNull() && myHiddenElements->Map().Contains( theID );
858 //================================================================
859 // Function : IsHiddenNode
861 //================================================================
862 Standard_Boolean MeshVS_Mesh::IsHiddenNode ( const Standard_Integer theID ) const
864 // note that by default all nodes are hidden
865 return myHiddenNodes.IsNull() || myHiddenNodes->Map().Contains( theID );
868 //================================================================
869 // Function : GetDrawer
871 //================================================================
872 Handle( MeshVS_Drawer ) MeshVS_Mesh::GetDrawer() const
874 return myCurrentDrawer;
877 //================================================================
878 // Function : SetDrawer
880 //================================================================
881 void MeshVS_Mesh::SetDrawer(const Handle(MeshVS_Drawer)& aDrawer)
883 myCurrentDrawer = aDrawer;
886 //================================================================
887 // Function : GetDataSource
889 //================================================================
890 Handle(MeshVS_DataSource) MeshVS_Mesh::GetDataSource() const
895 //================================================================
896 // Function : SetDataSource
898 //================================================================
899 void MeshVS_Mesh::SetDataSource( const Handle(MeshVS_DataSource)& theDataSource )
901 myDataSource = theDataSource;
904 //================================================================
905 // Function : HilightSelected
907 //================================================================
908 void MeshVS_Mesh::HilightSelected ( const Handle(PrsMgr_PresentationManager3d)& thePM,
909 const SelectMgr_SequenceOfOwner& theOwners )
911 if ( myHilighter.IsNull() )
914 // if ( mySelectionPrs.IsNull() )
915 // mySelectionPrs = new Prs3d_Presentation ( thePM->StructureManager() );
919 Handle( Prs3d_Presentation ) aSelectionPrs;
921 aSelectionPrs = GetSelectPresentation( thePM );
923 if( HasPresentation() )
924 aSelectionPrs->SetTransformPersistence (Presentation()->TransformPersistence());
927 // It is very important to call this parent method, because it check whether
928 // mySelectionPrs is created and if not, create it.
936 Standard_Integer len = theOwners.Length(), i;
938 Handle (MeshVS_MeshEntityOwner) anOwner;
939 TColStd_PackedMapOfInteger aSelNodes, aSelElements;
941 for( i=1; i<=len; i++ )
943 if (theOwners.Value (i) == GlobalSelOwner())
945 const Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0;
946 const Handle(Prs3d_Drawer)& aSelStyle = !HilightAttributes().IsNull() ? HilightAttributes() : GetContext()->SelectionStyle();
947 thePM->Color (this, aSelStyle, aHiMode);
950 anOwner = Handle (MeshVS_MeshEntityOwner)::DownCast ( theOwners.Value ( i ) );
951 if ( !anOwner.IsNull() )
953 // nkv: add support of mesh groups
954 if ( anOwner->IsGroup() ) {
955 MeshVS_EntityType aGroupType;
956 TColStd_PackedMapOfInteger aGroupMap;
957 if ( GetDataSource()->GetGroup( anOwner->ID(), aGroupType, aGroupMap ) ) {
958 if ( aGroupType == MeshVS_ET_Node ) {
959 for( TColStd_MapIteratorOfPackedMapOfInteger anIt(aGroupMap); anIt.More(); anIt.Next() )
960 if( IsSelectableNode/*!IsHiddenNode*/( anIt.Key() ) )
961 aSelNodes.Add( anIt.Key() );
964 for( TColStd_MapIteratorOfPackedMapOfInteger anIt(aGroupMap); anIt.More(); anIt.Next() )
965 if( IsSelectableElem/*!IsHiddenElem*/( anIt.Key() ) )
966 aSelElements.Add( anIt.Key() );
971 if( anOwner->Type() == MeshVS_ET_Node )
972 aSelNodes.Add( anOwner->ID() );
974 aSelElements.Add( anOwner->ID() );
977 else if( GetDataSource()->IsAdvancedSelectionEnabled() )
979 Handle(MeshVS_MeshOwner) aMeshOwner = Handle(MeshVS_MeshOwner)::DownCast ( theOwners.Value ( i ) );
980 if( !aMeshOwner.IsNull() )
982 Handle(TColStd_HPackedMapOfInteger) aNodes = aMeshOwner->GetSelectedNodes();
983 Handle(TColStd_HPackedMapOfInteger) aElems = aMeshOwner->GetSelectedElements();
984 if( !aNodes.IsNull() )
985 aSelNodes.Assign( aNodes->Map() );
986 if( !aElems.IsNull() )
987 aSelElements.Assign( aElems->Map() );
990 //agv else if( theOwners.Value ( i )==myWholeMeshOwner )
991 else if (IsWholeMeshOwner (theOwners.Value ( i )))
993 TColStd_MapIteratorOfPackedMapOfInteger anIt(GetDataSource()->GetAllNodes());
994 for( ; anIt.More(); anIt.Next() )
995 if( !IsHiddenNode( anIt.Key() ) )
996 aSelNodes.Add( anIt.Key() );
998 anIt = TColStd_MapIteratorOfPackedMapOfInteger( GetDataSource()->GetAllElements() );
999 for( ; anIt.More(); anIt.Next() )
1000 if( !IsHiddenElem( anIt.Key() ) )
1001 aSelElements.Add( anIt.Key() );
1007 Standard_Boolean IsNeedToRedisplay = Standard_False;
1009 aSelectionPrs->Clear();
1011 myHilighter->SetDrawer ( mySelectionDrawer );
1013 if( aSelNodes.Extent()>0 )
1015 TColStd_PackedMapOfInteger tmp;
1016 myHilighter->Build ( aSelectionPrs, aSelNodes, tmp, Standard_False, MeshVS_DMF_SelectionPrs );
1018 if( aSelElements.Extent()>0 )
1020 TColStd_PackedMapOfInteger tmp;
1021 myHilighter->Build( aSelectionPrs, aSelElements, tmp, Standard_True, MeshVS_DMF_SelectionPrs );
1024 myHilighter->SetDrawer ( 0 );
1026 IsNeedToRedisplay = Standard_True;
1028 aSelectionPrs->SetZLayer (Graphic3d_ZLayerId_Top);
1030 if ( IsNeedToRedisplay )
1032 aSelectionPrs->SetDisplayPriority(9);
1033 aSelectionPrs->Display();
1037 Standard_Real sec, cpu;
1038 Standard_Integer min, hour;
1040 gTimer.Show ( sec, min, hour, cpu );
1041 cout << "HilightSelected : " << endl;
1042 cout << aSelNodes.Extent() << " nodes " << endl;
1043 cout << aSelElements.Extent() << " elements " << endl;
1044 cout << "Time : " << sec << " sec" << endl;
1045 cout << "CPU time : " << cpu << " sec" << endl << endl;
1050 //================================================================
1051 // Function : HilightOwnerWithColor
1053 //================================================================
1054 void MeshVS_Mesh::HilightOwnerWithColor ( const Handle(PrsMgr_PresentationManager3d)& thePM,
1055 const Handle(Prs3d_Drawer)& theStyle,
1056 const Handle(SelectMgr_EntityOwner)& theOwner)
1058 if (theOwner.IsNull())
1061 const Quantity_Color& aColor = theStyle->Color();
1062 if (theOwner == GlobalSelOwner())
1064 Standard_Integer aHiMode = HasHilightMode() ? HilightMode() : 0;
1065 thePM->Color (this, theStyle, aHiMode, NULL, Graphic3d_ZLayerId_Top);
1069 if ( myHilighter.IsNull() )
1072 Handle( Prs3d_Presentation ) aHilightPrs;
1073 aHilightPrs = GetHilightPresentation( thePM );
1075 aHilightPrs->Clear();
1078 if( HasPresentation() )
1079 aHilightPrs->SetTransformPersistence (Presentation()->TransformPersistence());
1082 const Standard_Boolean isMeshEntityOwner = theOwner->IsKind ( STANDARD_TYPE ( MeshVS_MeshEntityOwner ) );
1083 const Standard_Boolean isWholeMeshOwner =
1084 //agv !Owner.IsNull() && Owner==myWholeMeshOwner;
1085 IsWholeMeshOwner (theOwner);
1087 Standard_Integer aDispMode = MeshVS_DMF_Shading;
1088 if ( HasDisplayMode() && ( DisplayMode() & MeshVS_DMF_OCCMask ) > MeshVS_DMF_WireFrame )
1089 aDispMode = ( DisplayMode() & MeshVS_DMF_OCCMask );
1090 //It because we draw hilighted owners only in shading or shrink (not in wireframe)
1092 myHilightDrawer->SetColor( MeshVS_DA_InteriorColor, aColor );
1093 myHilightDrawer->SetColor( MeshVS_DA_BackInteriorColor, aColor );
1094 myHilightDrawer->SetColor( MeshVS_DA_EdgeColor, aColor );
1095 myHilightDrawer->SetColor( MeshVS_DA_BeamColor, aColor );
1096 myHilightDrawer->SetColor( MeshVS_DA_MarkerColor, aColor );
1097 myHilighter->SetDrawer( myHilightDrawer );
1099 if( isMeshEntityOwner )
1101 Handle ( MeshVS_MeshEntityOwner ) theAISOwner = Handle ( MeshVS_MeshEntityOwner )::DownCast ( theOwner );
1102 MeshVS_EntityType aType = theAISOwner->Type();
1103 Standard_Integer anID = theAISOwner->ID();
1105 if ( theAISOwner->IsGroup() ) {
1106 MeshVS_EntityType aGroupType;
1107 TColStd_PackedMapOfInteger aGroupMap;
1108 if ( myDataSource->GetGroup( anID, aGroupType, aGroupMap ) ) {
1109 TColStd_PackedMapOfInteger tmp;
1110 myHilighter->Build( aHilightPrs, aGroupMap, tmp, aType!=MeshVS_ET_Node,
1111 aDispMode | MeshVS_DMF_HilightPrs );
1115 TColStd_PackedMapOfInteger anOne, tmp;
1117 myHilighter->Build( aHilightPrs, anOne, tmp, aType!=MeshVS_ET_Node,
1118 aDispMode | MeshVS_DMF_HilightPrs );
1121 else if( isWholeMeshOwner )
1123 if( ! GetDataSource().IsNull() )
1125 TColStd_PackedMapOfInteger tmp;
1126 myHilighter->Build( aHilightPrs, GetDataSource()->GetAllElements(), tmp,
1127 Standard_True, MeshVS_DMF_WireFrame );
1132 Handle(MeshVS_MeshOwner) aMeshOwner = Handle(MeshVS_MeshOwner)::DownCast ( theOwner );
1133 if( !aMeshOwner.IsNull() )
1135 Handle(TColStd_HPackedMapOfInteger) aNodes = aMeshOwner->GetDetectedNodes();
1136 Handle(TColStd_HPackedMapOfInteger) aElems = aMeshOwner->GetDetectedElements();
1137 // hilight detected entities
1138 if( !aNodes.IsNull() )
1140 TColStd_PackedMapOfInteger tmp;
1141 myHilighter->Build( aHilightPrs, aNodes->Map(), tmp, Standard_False,
1142 aDispMode | MeshVS_DMF_HilightPrs );
1144 if( !aElems.IsNull() )
1146 TColStd_PackedMapOfInteger tmp;
1147 myHilighter->Build( aHilightPrs, aElems->Map(), tmp, Standard_True,
1148 aDispMode | MeshVS_DMF_HilightPrs );
1153 aHilightPrs->SetZLayer (Graphic3d_ZLayerId_Topmost);
1155 if (thePM->IsImmediateModeOn())
1157 thePM->AddToImmediateList (aHilightPrs);
1159 myHilighter->SetDrawer ( 0 );
1162 //=======================================================================
1163 //function : ClearSelected
1165 //=======================================================================
1166 void MeshVS_Mesh::ClearSelected ()
1168 Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );
1169 if( !aSelectionPrs.IsNull() )
1170 aSelectionPrs->Clear();
1173 //=======================================================================
1174 //function : FindBuilder
1176 //=======================================================================
1177 Handle (MeshVS_PrsBuilder) MeshVS_Mesh::FindBuilder ( const Standard_CString theTypeName ) const
1179 Standard_Integer len = myBuilders.Length();
1180 Handle(MeshVS_PrsBuilder) aBuilder;
1181 Standard_Boolean IsExist = Standard_False;
1183 for ( Standard_Integer i=1; i<=len && !IsExist; i++)
1184 if ( myBuilders.Value (i)->IsKind ( theTypeName ) )
1186 aBuilder = myBuilders.Value (i);
1187 IsExist = Standard_True;
1193 //=======================================================================
1194 //function : SetHilighter
1196 //=======================================================================
1197 void MeshVS_Mesh::SetHilighter ( const Handle( MeshVS_PrsBuilder )& Builder )
1199 myHilighter = Builder;
1202 //=======================================================================
1203 //function : SetHilighter
1205 //=======================================================================
1206 Standard_Boolean MeshVS_Mesh::SetHilighter ( const Standard_Integer Index )
1208 Handle( MeshVS_PrsBuilder ) aBuild = GetBuilder( Index );
1209 Standard_Boolean aRes = ( !aBuild.IsNull() );
1211 myHilighter = aBuild;
1215 //=======================================================================
1216 //function : SetHilighter
1218 //=======================================================================
1219 Standard_Boolean MeshVS_Mesh::SetHilighterById ( const Standard_Integer Id )
1221 Handle( MeshVS_PrsBuilder ) aBuild = GetBuilderById( Id );
1222 Standard_Boolean aRes = ( !aBuild.IsNull() );
1224 myHilighter = aBuild;
1228 //=======================================================================
1229 //function : GetHilighter
1231 //=======================================================================
1232 Handle( MeshVS_PrsBuilder ) MeshVS_Mesh::GetHilighter () const
1237 //=======================================================================
1238 //function : IsSelectableElem
1240 //=======================================================================
1241 Standard_Boolean MeshVS_Mesh::IsSelectableElem ( const Standard_Integer ID ) const
1243 return ! IsHiddenElem ( ID );
1246 //=======================================================================
1247 //function : IsSelectableNode
1249 //=======================================================================
1250 Standard_Boolean MeshVS_Mesh::IsSelectableNode ( const Standard_Integer ID ) const
1252 return mySelectableNodes.IsNull() ? ! IsHiddenNode ( ID ) :
1253 mySelectableNodes->Map().Contains( ID );
1256 //=======================================================================
1257 //function : GetSelectableNodes
1259 //=======================================================================
1260 const Handle(TColStd_HPackedMapOfInteger)& MeshVS_Mesh::GetSelectableNodes () const
1262 return mySelectableNodes;
1265 //=======================================================================
1266 //function : SetSelectableNodes
1268 //=======================================================================
1269 void MeshVS_Mesh::SetSelectableNodes ( const Handle(TColStd_HPackedMapOfInteger)& Ids )
1271 mySelectableNodes = Ids;
1274 //=======================================================================
1275 //function : UpdateSelectableNodes
1277 //=======================================================================
1278 void MeshVS_Mesh::UpdateSelectableNodes()
1280 mySelectableNodes = new TColStd_HPackedMapOfInteger;
1282 Standard_Integer aMaxFaceNodes;
1283 Handle( MeshVS_DataSource ) aSource = GetDataSource();
1284 if ( aSource.IsNull() || myCurrentDrawer.IsNull() || !myCurrentDrawer->GetInteger
1285 ( MeshVS_DA_MaxFaceNodes, aMaxFaceNodes ) || aMaxFaceNodes<=0 )
1288 // all non-hidden nodes are selectable;
1289 // by default (i.e. if myHiddenNodes.IsNull()) all nodes are hidden
1290 if ( ! myHiddenNodes.IsNull() )
1292 mySelectableNodes->ChangeMap().Subtraction (aSource->GetAllNodes(),
1293 myHiddenNodes->Map());
1296 // add all nodes belonging to non-hidden elements
1297 TColStd_MapIteratorOfPackedMapOfInteger anIter( aSource->GetAllElements() );
1298 for ( ; anIter.More(); anIter.Next() )
1300 Standard_Integer aKey = anIter.Key();
1301 if ( IsHiddenElem (aKey) )
1304 MeshVS_Buffer aNodesBuf (aMaxFaceNodes*sizeof(Standard_Integer));
1305 TColStd_Array1OfInteger aNodes (aNodesBuf, 1, aMaxFaceNodes);
1306 Standard_Integer NbNodes;
1307 if ( !aSource->GetNodesByElement ( aKey, aNodes, NbNodes ) )
1309 for ( Standard_Integer i=1; i<=NbNodes; i++ )
1310 mySelectableNodes->ChangeMap().Add ( aNodes(i) );
1314 //=======================================================================
1315 //function : GetMeshSelMethod
1317 //=======================================================================
1318 MeshVS_MeshSelectionMethod MeshVS_Mesh::GetMeshSelMethod() const
1320 return mySelectionMethod;
1323 //=======================================================================
1324 //function : SetMeshSelMethod
1326 //=======================================================================
1327 void MeshVS_Mesh::SetMeshSelMethod( const MeshVS_MeshSelectionMethod M )
1329 mySelectionMethod = M;
1332 //=======================================================================
1333 //function : IsWholeMeshOwner
1335 //=======================================================================
1337 Standard_Boolean MeshVS_Mesh::IsWholeMeshOwner
1338 (const Handle(SelectMgr_EntityOwner)& theOwn) const
1340 return theOwn.IsNull() ? Standard_False : (theOwn == myWholeMeshOwner);