Back to index

salome-paravis  6.5.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
vtkMedComputeStepMap< T > Class Template Reference

#include <vtkMedUtilities.h>

Inheritance diagram for vtkMedComputeStepMap< T >:
Inheritance graph
[legend]
Collaboration diagram for vtkMedComputeStepMap< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void AddObject (const vtkMedComputeStep &cs, T *obj)
T * GetObject (const vtkMedComputeStep &cs)
med_int GetNumberOfObject ()
T * GetObject (med_int id)
T * FindObject (const vtkMedComputeStep &cs, int strategy)
void GatherTimes (std::set< med_float > &times)
void GatherIterations (med_float time, std::set< med_int > &iterations)

Public Attributes

keys
 STL member.
elements
 STL member.

Protected Member Functions

med_int FindTimeIterator (med_float time, med_int defaultit)

Protected Attributes

std::map< med_float, med_int > TimeIt

Detailed Description

template<class T>
class vtkMedComputeStepMap< T >

Definition at line 226 of file vtkMedUtilities.h.


Member Function Documentation

template<class T>
void vtkMedComputeStepMap< T >::AddObject ( const vtkMedComputeStep cs,
T *  obj 
) [inline]

Definition at line 230 of file vtkMedUtilities.h.

    {
    (*this)[cs.TimeIt][cs.IterationIt] = obj;
    this->TimeIt[cs.TimeOrFrequency] = cs.TimeIt;
    }
template<class T>
T* vtkMedComputeStepMap< T >::FindObject ( const vtkMedComputeStep cs,
int  strategy 
) [inline]

Definition at line 285 of file vtkMedUtilities.h.

    {
    // first test if the given compute step is present
    T* obj = this->GetObject(cs);
    if(obj != NULL)
      return obj;

    if(this->size() == 0)
      return NULL;

    // let us first find the iterator that corresponds to the given time
    med_int timeit = this->FindTimeIterator(cs.TimeOrFrequency, cs.TimeIt);

    std::map<med_int, vtkSmartPointer<T> >& itmap =
        (*this)[timeit];

    if(itmap.size() == 0)
      return NULL;

    if(strategy == vtkMedReader::PhysicalTime
       || strategy == vtkMedReader::Modes)
      {
      // in this strategies, we return the last iteration for each time.
      return itmap.rbegin()->second;
      }
    else if(strategy == vtkMedReader::Iteration)
      {
      // in this case, we look for the real iteration
      typename std::map<med_int, vtkSmartPointer<T> >::iterator iterationit
          = itmap.lower_bound(cs.IterationIt);

      // if this is not exactly the same step and if this is not the first
      // step, rool back one step to choose the one just before the asked time.
      if(iterationit->first != cs.IterationIt && iterationit != itmap.begin())
        iterationit--;

      // the time iterator asked for is higher than all times,
      // let us pick the last one.
      if(iterationit == itmap.end())
        iterationit--;

      return iterationit->second;
      }
    }
template<class T>
med_int vtkMedComputeStepMap< T >::FindTimeIterator ( med_float  time,
med_int  defaultit 
) [inline, protected]

Definition at line 362 of file vtkMedUtilities.h.

    {
    if(this->TimeIt.size() == 0)
      return defaultit;

    typename std::map<med_float, med_int>::iterator it
        = this->TimeIt.lower_bound(time);

    // if this is not exactly the same step and if this is not the first step,
    // rool back one step to choose the one just before the asked time.
    if(it->first != time && it != this->TimeIt.begin())
      it--;

    // if the time iterator asked for is higher than all times,
    // let us pick the last one.
    if(it == this->TimeIt.end())
      it--;

    return it->second;
    }

Here is the caller graph for this function:

template<class T>
void vtkMedComputeStepMap< T >::GatherIterations ( med_float  time,
std::set< med_int > &  iterations 
) [inline]

Definition at line 341 of file vtkMedUtilities.h.

    {
    med_int timeit = this->FindTimeIterator(time, -1);
    if(timeit == -1)
      return;

    std::map<med_int, vtkSmartPointer<T> >& itmap =
        (*this)[timeit];

    typename std::map<med_int, vtkSmartPointer<T> >::iterator it =
        itmap.begin();

    while(it != itmap.end())
      {
      iterations.insert(it->first);
      it++;
      }
    }
template<class T>
void vtkMedComputeStepMap< T >::GatherTimes ( std::set< med_float > &  times) [inline]

Definition at line 330 of file vtkMedUtilities.h.

    {
    typename std::map<med_float, med_int>::iterator it
        = this->TimeIt.begin();
    while(it != this->TimeIt.end())
      {
      times.insert(it->first);
      it++;
      }
    }
template<class T>
med_int vtkMedComputeStepMap< T >::GetNumberOfObject ( ) [inline]

Definition at line 249 of file vtkMedUtilities.h.

    {
    med_int nb = 0;
    typename vtkMedComputeStepMap<T>::iterator it = this->begin();
    while(it != this->end())
      {
      nb += it->second.size();
      it++;
      }
    return nb;
    }
template<class T>
T* vtkMedComputeStepMap< T >::GetObject ( const vtkMedComputeStep cs) [inline]

Definition at line 236 of file vtkMedUtilities.h.

    {
    if(this->find(cs.TimeIt) == this->end())
      return NULL;

    std::map<med_int, vtkSmartPointer<T> >& itmap = (*this)[cs.TimeIt];

    if(itmap.find(cs.IterationIt) == itmap.end())
      return NULL;

    return itmap[cs.IterationIt];
    }

Here is the caller graph for this function:

template<class T>
T* vtkMedComputeStepMap< T >::GetObject ( med_int  id) [inline]

Definition at line 261 of file vtkMedUtilities.h.

    {
    med_int nb = 0;
    if(id < 0)
      return NULL;

    typename vtkMedComputeStepMap<T>::iterator it = this->begin();
    while(it != this->end())
      {
      std::map<med_int, vtkSmartPointer<T> >& itmap = it->second;
      nb += itmap.size();
      if(id < nb)
        {
        typename std::map<med_int, vtkSmartPointer<T> >::iterator iterationit =
            itmap.begin();
        for(int ii=0; ii<nb-id-1; ii++)
          iterationit++;
        return iterationit->second;
        }
      it++;
      }
    return NULL;
    }

Member Data Documentation

template<typename K, typename T>
T std::map< K, T >::elements [inherited]

STL member.

template<typename K, typename T>
K std::map< K, T >::keys [inherited]

STL member.

template<class T>
std::map<med_float, med_int> vtkMedComputeStepMap< T >::TimeIt [protected]

Definition at line 383 of file vtkMedUtilities.h.


The documentation for this class was generated from the following file: