[vtkusers] Track all downstream filters MTime
Dmitry Gurulev
patalog at electropulse.tomsk.ru
Tue Mar 25 05:24:31 EDT 2008
Hi All!
I'm writing custom filter and part of it executed at working thread.
Since, I require track all downstream filters to be up-to-date before
modify internal data to avoid:
1. frequent filter execution (can be heavy).
2. data sets inconsistency (filter produce 3 data set)
Eg. -
filter + 2 mappers.
1. 1st mapper request execution -> filter up-to-date
2. 2nd mapper request execution -> filter execution again, since working
thread call Modified()!
Now I've solved this problem such way-
-------------part of filter executed at working thread-------------
bool my_filter::cache(void const* buffer, size_t size)
{
boost::try_mutex::scoped_try_lock l(guard_);
if (!l.locked())
return false;
unsigned long time = unsigned long(-1);
unsigned long const m_time = GetMTime();
vtkInformationVector* ov = GetExecutive()->GetOutputInformation();
int const n_obj = ov->GetNumberOfInformationObjects();
for (int i = 0; i < n_obj ; ++i)
{
vtkInformation* info = ov->GetInformationObject(i);
int const length = info->Length(vtkExecutive::CONSUMERS());
if (!length)
break;
vtkExecutive** consumers =
info->GetExecutives(vtkExecutive::CONSUMERS());
for (int j = 0; j < length; ++j)
{
vtkDemandDrivenPipeline* pipe =
vtkDemandDrivenPipeline::SafeDownCast(consumers[j]);
unsigned long const ctime = pipe ? pipe->GetPipelineMTime() : 0;
if (ctime < time)
time = ctime;
AtlTrace(_T("\n%X - %d"), pipe, ctime);
}
}
AtlTrace(_T("\nMin - %d, Modified - %d"), time, m_time);
if (m_time != 0 && time < m_time)
{
//some consuners have pipeline time less then MTime - //i.e. not
updated yet
//skip internal data modification
AtlTrace(_T(" --- Skipped"));
return false;
}
//modify internal data
Modified(); //say we are modify data
-------------
Is there more direct way to solve my problem?
Is there way to solve it on old pipeline (v 4.4)?
PS Use pretty old CVS revision of VTK 5 version (since ~ 2007
September), WinXP SP 2, VS 2003 (7.1)
More information about the vtkusers
mailing list