public void pruneViews ( int count ) { List < SceneStructureMetric . View > remainingS = new ArrayList <> ( ) ; List < SceneObservations . View > remainingO = new ArrayList <> ( ) ; for ( int viewId = 0 ; viewId < structure . views . length ; viewId ++ ) { SceneObservations . View view = observations . views [ viewId ] ; // See if has enough observations to not prune if ( view . size ( ) > count ) { remainingS . add ( structure . views [ viewId ] ) ; remainingO . add ( view ) ; continue ; } // Go through list of points and remove this view from them for ( int pointIdx = 0 ; pointIdx < view . point . size ; pointIdx ++ ) { int pointId = view . getPointId ( pointIdx ) ; int viewIdx = structure . points [ pointId ] . views . indexOf ( viewId ) ; if ( viewIdx < 0 ) throw new RuntimeException ( "Bug in structure. view has point but point doesn't have view" ) ; structure . points [ pointId ] . views . remove ( viewIdx ) ; } } // Create new arrays with the views that were not pruned structure . views = new SceneStructureMetric . View [ remainingS . size ( ) ] ; observations . views = new SceneObservations . View [ remainingO . size ( ) ] ; for ( int i = 0 ; i < structure . views . length ; i ++ ) { structure . views [ i ] = remainingS . get ( i ) ; observations . views [ i ] = remainingO . get ( i ) ; } }
Removes views with less than count features visible . Observations of features in removed views are also removed .