Changeset 496


Ignore:
Timestamp:
07/20/10 15:05:38 (19 months ago)
Author:
ddangelo
Message:

Function to print the number of actual FieldContainers? sorted by their Name and occurrence.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/avango-utils/python/_utils.cpp

    r450 r496  
    2323 
    2424#include <boost/python.hpp> 
     25 
    2526#include <avango/Link.h> 
     27#include <avango/ContainerPool.h> 
    2628 
    2729#include <osg/Matrix> 
     
    3335#include "../include/avango/utils/Bool3And.h" 
    3436#include "../include/avango/utils/Trackball.h" 
     37 
     38#include <iostream> 
     39#include <map> 
    3540 
    3641using namespace boost::python; 
     
    4651    }; 
    4752  } 
     53} 
     54 
     55template < typename T, typename U > 
     56std::map< U, T > converseMap( const std::map< T, U >& o ) 
     57{ 
     58  std::map< U, T > result; 
     59  for ( typename std::map< T, U >::const_iterator begin( o.begin() ); begin != o.end(); ++begin ) 
     60    result.insert( make_pair( begin->second, begin->first ) ); 
     61  return result; 
    4862} 
    4963 
     
    7488} 
    7589 
     90void print_actual_registered_field_containers() 
     91{ 
     92  const std::map< av::FieldContainer::IDType, av::FieldContainer* > & containers = av::ContainerPool::getContainerPool(); 
     93  std::map< av::FieldContainer::IDType, av::FieldContainer* >::const_iterator iter; 
     94  std::map< std::string,int> m; 
     95  for(iter=containers.begin();iter!=containers.end();++iter) 
     96  { 
     97    std::string type = ::av::ContainerPool::getNameByInstance(iter->second); 
     98    std::map< std::string,int >::const_iterator find_iter = m.find(type); 
     99    if(find_iter==m.end()) 
     100    { 
     101      m[type] = 1; 
     102    } 
     103    else 
     104    { 
     105      m[type]++; 
     106    } 
     107  } 
     108  std::cout << "###########################################" << std::endl; 
     109  std::cout <<"<FieldContainer Name> | Number of containers"<< std::endl; 
     110  std::map< int, std::string > conversedMap = converseMap( m ); 
     111  std::map< int, std::string >::reverse_iterator i; 
     112  for(i=conversedMap.rbegin();i!=conversedMap.rend();++i) 
     113  { 
     114    std::cout <<"<"<< i->second << "> | " << i->first << std::endl; 
     115  } 
     116  std::cout << "Total number of containers: " << av::ContainerPool::getNumberOfContainers() << std::endl; 
     117} 
     118 
    76119BOOST_PYTHON_MODULE(_utils) 
    77120{ 
     
    86129 
    87130  def("calc_hpr", CalcHpr); 
     131 
     132  def("print_registered_field_containers",print_actual_registered_field_containers); 
    88133} 
Note: See TracChangeset for help on using the changeset viewer.