Skip to content
Snippets Groups Projects
Commit 95c205ea authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Speeding up VectorDataGlComponent rendering

parent 1ad66808
No related branches found
No related tags found
No related merge requests found
......@@ -306,6 +306,8 @@ VectorDataExtractROI<TVectorData>
genericTransform->InstanciateTransform();
std::cout<<genericTransform<<std::endl;
typename VertexListType::Pointer regionCorners = VertexListType::New();
ProjPointType point1, point2 , point3, point4;
......
......@@ -72,10 +72,11 @@ public:
typedef typename VectorDataType::DataNodeType DataNodeType;
typedef typename DataNodeType::Pointer DataNodePointerType;
typedef typename VectorDataType::DataTreeType DataTreeType;
typedef itk::PreOrderTreeIterator<DataTreeType> TreeIteratorType;
typedef typename DataNodeType::LineType LineType;
typedef typename DataNodeType::PolygonType PolygonType;
typedef typename DataNodeType::PolygonListType PolygonListType;
typedef typename DataTreeType::TreeNodeType InternalTreeNodeType;
typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
/** Runtime information */
itkTypeMacro(VectorDataGlComponent,GlComponent);
......@@ -133,6 +134,9 @@ protected:
// Render a complex polygon (with holes)
void RenderPolygon(const PolygonType * extRing, const PolygonListType * intRings, const RegionType & extent, const AffineTransformType * transform);
// Recursive rendering method
void Render(InternalTreeNodeType * node, const RegionType & extent, const AffineTransformType * space2ScreenTransform);
/// Frame a given point using the frame width and color (point
/// should be in gl screen coordinates)
//void FramePoint(const PointType & p);
......
......@@ -22,6 +22,7 @@
// We need this include to get NodeType enum right.
#include "otbDataNode.h"
#include "itkTimeProbe.h"
namespace otb
{
......@@ -87,41 +88,15 @@ VectorDataGlComponent<TVectorData>
// Enabling line antialiasing
glEnable(GL_LINE_SMOOTH);
// Iterate on the data tree
TreeIteratorType it(m_VectorData->GetDataTree());
it.GoToBegin();
// Trigger recursive rendering
InternalTreeNodeType * inputRoot = const_cast<InternalTreeNodeType *>(m_VectorData->GetDataTree()->GetRoot());
itk::TimeProbe chrono;
chrono.Start();
this->Render(inputRoot,extent,space2ScreenTransform);
chrono.Stop();
std::cout<<"VectorData component rendered in "<<chrono.GetMeanTime()<<" s."<<std::endl;
while(!it.IsAtEnd())
{
DataNodePointerType node = it.Get();
switch(node->GetNodeType())
{
case FEATURE_POINT:
{
this->RenderPoint(node->GetPoint(),extent,space2ScreenTransform);
break;
}
case FEATURE_LINE:
{
this->RenderLine(node->GetLine(),extent,space2ScreenTransform);
break;
}
case FEATURE_POLYGON:
{
this->RenderPolygon(node->GetPolygonExteriorRing(),node->GetPolygonInteriorRings(),
extent,space2ScreenTransform);
break;
}
default:
{
// discard
break;
}
}
++it;
}
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
glLineWidth(previousWidth);
......@@ -276,6 +251,49 @@ VectorDataGlComponent<TVectorData>
delete [] (*it);
}
}
template <class TVectorData>
void
VectorDataGlComponent<TVectorData>
::Render(InternalTreeNodeType * node, const RegionType & extent, const AffineTransformType * space2ScreenTransform)
{
// Render the current node
switch(node->Get()->GetNodeType())
{
case FEATURE_POINT:
{
this->RenderPoint(node->Get()->GetPoint(),extent,space2ScreenTransform);
break;
}
case FEATURE_LINE:
{
this->RenderLine(node->Get()->GetLine(),extent,space2ScreenTransform);
break;
}
case FEATURE_POLYGON:
{
this->RenderPolygon(node->Get()->GetPolygonExteriorRing(),node->Get()->GetPolygonInteriorRings(),
extent,space2ScreenTransform);
break;
}
default:
{
// discard
break;
}
}
// Get the children list from the input node
ChildrenListType children = node->GetChildrenList();
// Render each child
for(typename ChildrenListType::iterator it = children.begin(); it!=children.end();++it)
{
this->Render(*it,extent,space2ScreenTransform);
}
}
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment