return 0;
}
-static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull()) {
- di << "use 'vinit' command before " << argv[0] << "\n";
- return 1;
- }
- if(argc < 5) {
- di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window\n";
- return 1;
- }
-
- Standard_Integer xmin = Draw::Atoi(argv[1]);
- Standard_Integer ymin = Draw::Atoi(argv[2]);
- Standard_Integer xmax = Draw::Atoi(argv[3]);
- Standard_Integer ymax = Draw::Atoi(argv[4]);
-
- Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-
- Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
- EM->Select(xmin,ymin,xmax,ymax);
-
- return 0;
-}
-
-static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
-{
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if(aContext.IsNull()) {
- di << "use 'vinit' command before " << argv[0] << "\n";
- return 1;
- }
- if(argc < 7) {
- di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
- return 1;
- }
- if (((argc - 1) % 2) != 0) {
- di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
- return 1;
- }
-
- Standard_Integer i, j, np = (argc-1) / 2;
- TColgp_Array1OfPnt2d Polyline(1,np);
- j = 1;
- for (i = 1; i <= np; i++) {
- Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
- j += 2;
- }
-
- Handle(V3d_View) V3dView = ViewerTest::CurrentView();
-
- aContext->Select (Polyline, V3dView, Standard_False);
- aContext->UpdateCurrentViewer();
-
- return 0;
-}
-
static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
{
if(argc != 2) {
theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
- theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
- theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);
//! Returns the entity with index theIndex in the set
Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const;
+ //! Returns map of entities.
+ const SelectMgr_IndexedMapOfHSensitive& Sensitives() const { return mySensitives; }
+
private:
SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
Standard_Real Tolerance; //!< tolerance used for selecting candidates
Standard_Integer Priority; //!< selection priority
Standard_Integer ZLayerPosition; //!< ZLayer rendering order index, stronger than a depth
+ Standard_Integer NbOwnerMatches; //!< overall number of entities collected for the same owner
Standard_Boolean ToPreferClosest; //!< whether closest object is preferred even if has less priority
public:
Tolerance(0.0),
Priority (0),
ZLayerPosition (0),
+ NbOwnerMatches (0),
ToPreferClosest (Standard_True) {}
//! Comparison operator.
aCriterion.Tolerance = theEntity->SensitivityFactor() / 33.0;
aCriterion.ToPreferClosest = preferclosest;
- const Standard_Integer aPrevStoredIndex = mystored.FindIndex (anOwner);
- if (aPrevStoredIndex != 0)
+ if (SelectMgr_SortCriterion* aPrevCriterion = mystored.ChangeSeek (anOwner))
{
+ ++aPrevCriterion->NbOwnerMatches;
+ aCriterion.NbOwnerMatches = aPrevCriterion->NbOwnerMatches;
if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box)
{
- SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromIndex (aPrevStoredIndex);
- if (aCriterion > aPrevCriterion)
+ if (aCriterion > *aPrevCriterion)
{
updatePoint3d (aCriterion, theInversedTrsf, theMgr);
- aPrevCriterion = aCriterion;
+ *aPrevCriterion = aCriterion;
}
}
}
else
{
+ aCriterion.NbOwnerMatches = 1;
updatePoint3d (aCriterion, theInversedTrsf, theMgr);
mystored.Add (anOwner, aCriterion);
}
{
return;
}
+
+ const Standard_Integer aFirstStored = mystored.Extent() + 1;
+
Standard_Integer aStack[BVH_Constants_MaxTreeDepth];
Standard_Integer aHead = -1;
for (;;)
Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode);
for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
{
- const Handle(SelectMgr_SensitiveEntity)& aSensitive =
- anEntitySet->GetSensitiveById (anIdx);
+ const Handle(SelectMgr_SensitiveEntity)& aSensitive = anEntitySet->GetSensitiveById (anIdx);
if (aSensitive->IsActiveForSelection())
{
const Handle(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
--aHead;
}
}
+
+ // in case of Box/Polyline selection - keep only Owners having all Entities detected
+ if (mySelectingVolumeMgr.IsOverlapAllowed()
+ || (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Box
+ && theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Polyline))
+ {
+ return;
+ }
+
+ for (Standard_Integer aStoredIter = mystored.Extent(); aStoredIter >= aFirstStored; --aStoredIter)
+ {
+ const SelectMgr_SortCriterion& aCriterion = mystored.FindFromIndex (aStoredIter);
+ const Handle(SelectBasics_EntityOwner)& anOwner = aCriterion.Entity->OwnerId();
+ Standard_Integer aNbOwnerEntities = 0;
+ for (SelectMgr_IndexedMapOfHSensitive::Iterator aSensIter (anEntitySet->Sensitives()); aSensIter.More(); aSensIter.Next())
+ {
+ if (aSensIter.Value()->BaseSensitive()->OwnerId() == anOwner)
+ {
+ if (++aNbOwnerEntities > aCriterion.NbOwnerMatches)
+ {
+ // Remove from index map.
+ // Considering NCollection_IndexedDataMap implementation, the values for lower indexes will not be modified.
+ // Hence, just keep iterating in backward direction.
+ mystored.RemoveFromIndex (aStoredIter);
+ break;
+ }
+ }
+ }
+ }
}
//=======================================================================
puts "============"
-puts "OCC25723"
-puts "Calculate the center of rotation taking into account structure visibility"
+puts "OCC25723 Calculate the center of rotation taking into account structure visibility"
puts "============"
puts ""
-set x_start_sel_coord 100
-set y_start_sel_coord 104
-
-set x_end_sel_coord 400
-set y_end_sel_coord 400
-
-set x_mouse_start_coord 100
-set y_mouse_start_coord 100
-
-set x_mouse_move_coord 300
-set y_mouse_move_coord 300
-
-set x_check_coord 220
-set y_check_coord 50
-
box b1 0 0 0 10 10 10
box b2 0 0 20 10 10 10
box b3 0 0 -20 10 10 10
box b4 0 0 40 10 10 10
-vinit View1
vclear
+vinit View1
vaxo
vsetdispmode 1
vdisplay b1 b2 b3 b4
vfit
-# select solid
-vselect ${x_start_sel_coord} ${y_start_sel_coord} ${x_end_sel_coord} ${y_end_sel_coord}
-
-# hide selected solids
+# select and hide boxes b2 b3 b4
+vselect 100 100 400 410
verase
# rotation
-vrotate -mouseStart ${x_mouse_start_coord} ${y_mouse_start_coord} -mouseMove ${x_mouse_move_coord} ${y_mouse_move_coord}
-
-if {"[vreadpixel ${x_check_coord} ${y_check_coord} rgb name]" != "GOLDENROD2"} {
- puts "Error: Rotation is not correct"
-}
+vrotate -mouseStart 100 100 -mouseMove 300 300
+if {"[vreadpixel 220 50 rgb name]" != "GOLDENROD2"} { puts "Error: Rotation is not correct" }
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+vdump ${imagedir}/${casename}.png
puts "============"
-puts "CR26344"
+puts "0026344: Visualization - provide a support of zoom persistent selection"
puts "============"
puts ""
-##########################################################################################
-puts "Visualization - provide a support of zoom persistent selection"
-##########################################################################################
-
vclear
vclose ALL
vinit View1 w=409 h=409
if { [vreadpixel 387 77 rgb name] != "GRAY66" } { puts "Error picking zoom persistence object(s)" }
vselect 0 0
-vselect 330 120 400 50
+vselect 330 120 410 50
if { [vreadpixel 387 77 rgb name] != "GRAY66" || [vreadpixel 352 96 rgb name] != "GRAY66" } { puts "Error selecting zoom persistence object(s)" }
# 2) Rotate persistence
vselect 50 223 235 395
if { [vreadpixel 132 300 rgb name] != "GRAY66" } { puts "Error selecting trihedron persistence object" }
-vselect 50 380 400 50
+vselect 50 410 410 50
vstate -entities
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+++ /dev/null
-puts "========"
-puts "OCC60"
-puts "SAM723"
-puts "BUC60916"
-puts "========"
-
-vinit
-box b 10 10 10
-vdisplay b
-vfit
-vaspects -setwidth 5
-
-set x_coord 83
-set y_coord 337
-
-if { [vreadpixel ${x_coord} ${y_coord} rgb name] != "YELLOW" } {
- puts "Error : color is not yellow"
-}
-
-set xmin 1
-set ymin 1
-set xmax 409
-set ymax 300
-
-# Select part of box
-OCC60 ${xmin} ${ymin} ${xmax} ${ymax}
-OCC60 ${xmin} ${ymin} ${xmax} ${ymax}
-
-set Selection_R 0.8
-set Selection_G 0.8
-set Selection_B 0.8
-
-if { [vreadpixel ${x_coord} ${y_coord} rgb name] != "GRAY80" } {
- puts "Error : color is not gray"
-}
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+++ /dev/null
-puts "========"
-puts "OCC61"
-puts "SAM723"
-puts "BUC60919"
-puts "========"
-
-vinit
-vtrihedron trihedron
-
-set x_coord 205
-set y_coord 205
-
-checkcolor $x_coord $y_coord 0.43 0.48 0.54
-
-set xmin 1
-set ymin 1
-set xmax 409
-set ymax 205
-
-# Select part of trihedron
-OCC60 ${xmin} ${ymin} ${xmax} ${ymax}
-OCC60 ${xmin} ${ymin} ${xmax} ${ymax}
-
-checkcolor $x_coord $y_coord 0.8 0.8 0.8
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png