Commit b41c6794 authored by Pierre Guilbert's avatar Pierre Guilbert
Browse files

Merge branch 'feature/GetFrameUsingTime' into 'kitware-master'

Feature/get frame using time

See merge request ComputerVision/VeloView!21
parents 1ee1a9e9 7005b403
......@@ -180,6 +180,44 @@ vtkSmartPointer<vtkPolyData> vtkLidarReader::GetFrame(int frameNumber)
return this->Interpreter->GetLastFrameAvailable();
}
//-----------------------------------------------------------------------------
vtkSmartPointer<vtkPolyData> vtkLidarReader::GetFrameForPacketTime(double packetTime)
{
return this->GetFrame(this->GetFrameIndexForPacketTime(packetTime));
}
//-----------------------------------------------------------------------------
vtkSmartPointer<vtkPolyData> vtkLidarReader::GetFrameForDataTime(double dataTime)
{
return this->GetFrame(this->GetFrameIndexForDataTime(dataTime));
}
//-----------------------------------------------------------------------------
int vtkLidarReader::GetFrameIndexForPacketTime(double packetTime)
{
// iterating over all timesteps until finding the first one with a greater time value
auto idx = std::lower_bound(this->FrameCatalog.begin(),
this->FrameCatalog.end(),
packetTime,
[](FrameInformation& fp, double d)
{ return fp.FirstPacketNetworkTime < d; });
auto frameRequested = std::distance(this->FrameCatalog.begin(), idx);
return static_cast<int>(frameRequested);
}
//-----------------------------------------------------------------------------
int vtkLidarReader::GetFrameIndexForDataTime(double dataTime)
{
// iterating over all timesteps until finding the first one with a greater time value
auto idx = std::lower_bound(this->FrameCatalog.begin(),
this->FrameCatalog.end(),
dataTime,
[](FrameInformation& fp, double d)
{ return fp.FirstPacketDataTime < d; });
auto frameRequested = std::distance(this->FrameCatalog.begin(), idx);
return static_cast<int>(frameRequested);
}
//-----------------------------------------------------------------------------
void vtkLidarReader::Open()
{
......
......@@ -43,6 +43,32 @@ public:
*/
virtual vtkSmartPointer<vtkPolyData> GetFrame(int frameNumber);
/**
* @brief GetFrameForPacketTime returns the requested frame
* @param packetTime udp packet time requested
*/
virtual vtkSmartPointer<vtkPolyData> GetFrameForPacketTime(double packetTime);
/**
* @brief GetFrameForDataTime returns the requested frame
* @param dataTime data time requested
*/
virtual vtkSmartPointer<vtkPolyData> GetFrameForDataTime(double dataTime);
/**
* @brief GetFrameIndexForPacketTime returns the frame index
* corresponding to the packet time asked
* @param packetTime udp packet time requested
*/
virtual int GetFrameIndexForPacketTime(double packetTime);
/**
* @brief GetFrameIndexForDataTime returns the frame index
* corresponding to the packet time asked
* @param packetTime udp packet time requested
*/
virtual int GetFrameIndexForDataTime(double dataTime);
/**
* @brief Open open the pcap file
* @todo a decition should be made if the opening/closing of the pcap should be handle by
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment