@@ -486,12 +486,9 @@ void msvVTKWidgetClusters::vtkInternal::GetDisplayCoordinates(vtkPoints* from,
486486// ------------------------------------------------------------------------------
487487vtkStandardNewMacro (msvVTKWidgetClusters);
488488vtkInformationKeyMacro (msvVTKWidgetClusters, CLUSTER_IDX, IdType);
489- vtkInformationKeyRestrictedMacro (msvVTKWidgetClusters, CLUSTER_BUTTONS_RANGE,
489+ vtkInformationKeyMacro (msvVTKWidgetClusters, DATASET_BUTTONS_OFFSET, IdType);
490+ vtkInformationKeyRestrictedMacro (msvVTKWidgetClusters, CLUSTER_BUTTONS_OFFSET,
490491 IntegerVector, 2 );
491- vtkInformationKeyRestrictedMacro (msvVTKWidgetClusters, DATASET_BUTTONS_RANGE,
492- IntegerVector, 2 );
493- vtkInformationKeyRestrictedMacro (msvVTKWidgetClusters, DATA_DIMENSIONALITY,
494- DoubleVector, 6 );
495492
496493// ------------------------------------------------------------------------------
497494vtkCxxSetObjectMacro (msvVTKWidgetClusters,ColorLookUpTable,vtkLookupTable);
@@ -517,19 +514,9 @@ void msvVTKWidgetClusters::SetDataSet(size_t level, size_t idx,
517514 vtkInformation* info = levelDS->GetMetaData (idx);
518515 if (info)
519516 {
520- double *bounds = points->GetBounds ();
521- info->Set (DATA_DIMENSIONALITY (),
522- bounds[0 ], bounds[1 ], bounds[2 ],
523- bounds[3 ], bounds[4 ], bounds[5 ]);
524517 info->Set (CLUSTER_IDX (),clusterIdx);
525-
526- int range[2 ] = {0 };
527- range[0 ] = this ->Internal ->ButtonList .size ();
528- range[1 ] = this ->Internal ->ButtonList .size () +
529- points->GetNumberOfPoints ();
530-
531- info->Set (DATASET_BUTTONS_RANGE (), range, 2 );
532-
518+ vtkIdType offset = this ->Internal ->ButtonList .size ();
519+ info->Set (DATASET_BUTTONS_OFFSET (), offset);
533520 }
534521 this ->Internal ->SetButtons (points,this ->Internal ->ButtonList );
535522 }
@@ -616,11 +603,11 @@ void msvVTKWidgetClusters::SetRenderer(vtkRenderer* renderer)
616603// ------------------------------------------------------------------------------
617604void msvVTKWidgetClusters::UpdateWidgets ()
618605{
606+ this ->Clear ();
619607 if (!this ->ClusteringEnabled )
620608 {
621609 return ;
622610 }
623- this ->Clear ();
624611
625612 size_t numLevels = this ->GetNumberOfLevels ();
626613 for (size_t levelIdx = 0 ; levelIdx < numLevels; ++levelIdx)
@@ -636,24 +623,22 @@ void msvVTKWidgetClusters::UpdateWidgets()
636623 = vtkUnstructuredGrid::SafeDownCast (levelDS->GetPiece (dataSetIdx));
637624 // Recompute clusters for each dataset
638625 vtkPoints *points = ds->GetPoints ();
639- vtkIdType clusterIdx = this ->Internal ->ComputeClusters (points);
626+ size_t clusterIdx = this ->Internal ->ComputeClusters (points);
640627
641628 // Get the cluster structure and assign a button to each cluster
642- vtkInternal::IndexMapType& indexMap = this ->Internal ->IndexMaps . back () ;
629+ vtkInternal::IndexMapType& indexMap = this ->Internal ->IndexMaps [clusterIdx] ;
643630
644631 vtkNew<vtkPoints> clusterPositions;
645632 this ->Internal ->GetClustersPositions (points,indexMap,
646633 clusterPositions.GetPointer ());
647634 vtkInformation* info = levelDS->GetMetaData (dataSetIdx);
648635 if (info)
649636 {
650-
651637 int range[2 ] = {0 };
652638 range[0 ] = this ->Internal ->ClusterButtons .size ();
653- range[1 ] = this ->Internal ->ClusterButtons .size () +
654- clusterPositions->GetNumberOfPoints ();
639+ range[1 ] = clusterPositions->GetNumberOfPoints ();
655640 info->Set (CLUSTER_IDX (),clusterIdx);
656- info->Set (CLUSTER_BUTTONS_RANGE (),range,2 );
641+ info->Set (CLUSTER_BUTTONS_OFFSET (),range,2 );
657642 }
658643 this ->Internal ->SetButtons (
659644 clusterPositions.GetPointer (), this ->Internal ->ClusterButtons );
@@ -765,11 +750,11 @@ void msvVTKWidgetClusters::ShowClusterButtons(size_t level)
765750 vtkInformation* info = levelDS->GetMetaData (dataSetIdx);
766751 if (info)
767752 {
768- int buttonRange [2 ];
769- info->Get (CLUSTER_BUTTONS_RANGE (),buttonRange );
770- for (int i = buttonRange[ 0 ] ; i < buttonRange [1 ]; ++i)
753+ int offset [2 ];
754+ info->Get (CLUSTER_BUTTONS_OFFSET (),offset );
755+ for (int i = 0 ; i < offset [1 ]; ++i)
771756 {
772- this ->Internal ->ClusterButtons [i]->Show ();
757+ this ->Internal ->ClusterButtons [offset[ 0 ]+ i]->Show ();
773758 }
774759 }
775760 }
@@ -794,11 +779,11 @@ void msvVTKWidgetClusters::HideClusterButtons(size_t level)
794779 vtkInformation* info = levelDS->GetMetaData (dataSetIdx);
795780 if (info)
796781 {
797- int buttonRange [2 ];
798- info->Get (CLUSTER_BUTTONS_RANGE (),buttonRange );
799- for (int i = buttonRange[ 0 ] ; i < buttonRange [1 ]; ++i)
782+ int offset [2 ];
783+ info->Get (CLUSTER_BUTTONS_OFFSET (),offset );
784+ for (int i = 0 ; i < offset [1 ]; ++i)
800785 {
801- this ->Internal ->ClusterButtons [i]->Hide ();
786+ this ->Internal ->ClusterButtons [offset[ 0 ]+ i]->Hide ();
802787 }
803788 }
804789 }
@@ -820,12 +805,12 @@ void msvVTKWidgetClusters::ShowButtons(size_t level)
820805 size_t numDataSets = this ->GetNumberOfDataSets (level);
821806 for (size_t dataSetIdx = 0 ; dataSetIdx < numDataSets; ++dataSetIdx)
822807 {
808+ size_t numButtons = vtkUnstructuredGrid::SafeDownCast (levelDS->GetPiece (dataSetIdx))->GetPoints ()->GetNumberOfPoints ();
823809 vtkInformation* info = levelDS->GetMetaData (dataSetIdx);
824810 if (info)
825811 {
826- int buttonRange[2 ];
827- info->Get (DATASET_BUTTONS_RANGE (),buttonRange);
828- for (int i = buttonRange[0 ]; i < buttonRange[1 ]; ++i)
812+ vtkIdType offset = info->Get (DATASET_BUTTONS_OFFSET ());
813+ for (size_t i = offset, end = offset+numButtons; i < end; ++i)
829814 {
830815 this ->Internal ->ButtonList [i]->Show ();
831816 }
@@ -845,12 +830,12 @@ void msvVTKWidgetClusters::HideButtons(size_t level)
845830 size_t numDataSets = this ->GetNumberOfDataSets (level);
846831 for (size_t dataSetIdx = 0 ; dataSetIdx < numDataSets; ++dataSetIdx)
847832 {
833+ size_t numButtons = vtkUnstructuredGrid::SafeDownCast (levelDS->GetPiece (dataSetIdx))->GetPoints ()->GetNumberOfPoints ();
848834 vtkInformation* info = levelDS->GetMetaData (dataSetIdx);
849835 if (info)
850836 {
851- int buttonRange[2 ];
852- info->Get (DATASET_BUTTONS_RANGE (),buttonRange);
853- for (int i = buttonRange[0 ]; i < buttonRange[1 ]; ++i)
837+ vtkIdType offset = info->Get (DATASET_BUTTONS_OFFSET ());
838+ for (size_t i = offset, end = offset+numButtons; i < end; ++i)
854839 {
855840 this ->Internal ->ButtonList [i]->Hide ();
856841 }
0 commit comments