Commit 7d10609b authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Add progress

parent 2f69dfa9
......@@ -21,7 +21,7 @@
#include "vtkPointData.h"
#include "vtkPolyData.h"
vtkCxxRevisionMacro(vtkLinearSubdivisionFilter, "1.16");
vtkCxxRevisionMacro(vtkLinearSubdivisionFilter, "1.17");
vtkStandardNewMacro(vtkLinearSubdivisionFilter);
void vtkLinearSubdivisionFilter::GenerateSubdivisionPoints (vtkPolyData *inputDS, vtkIntArray *edgeData, vtkPoints *outputPts, vtkPointData *outputPD)
......@@ -44,6 +44,9 @@ void vtkLinearSubdivisionFilter::GenerateSubdivisionPoints (vtkPolyData *inputDS
pointIds->SetNumberOfIds(2);
double total = inputPolys->GetNumberOfCells();
double curr = 0;
// Generate new points for subdivisions surface
for (cellId=0, inputPolys->InitTraversal();
inputPolys->GetNextCell(npts, pts); cellId++)
......@@ -83,6 +86,8 @@ void vtkLinearSubdivisionFilter::GenerateSubdivisionPoints (vtkPolyData *inputDS
p2 = pts[edgeId + 1];
}
} // each edge
this->UpdateProgress(curr / total);
curr += 1;
} // each cell
edgeTable->Delete();
......
......@@ -24,7 +24,7 @@
#include "vtkTimerLog.h"
#include "vtkTriangle.h"
vtkCxxRevisionMacro(vtkQuadricClustering, "1.65");
vtkCxxRevisionMacro(vtkQuadricClustering, "1.66");
vtkStandardNewMacro(vtkQuadricClustering);
//----------------------------------------------------------------------------
......@@ -141,7 +141,10 @@ void vtkQuadricClustering::Execute()
this->NumberOfDivisions[2] = this->NumberOfZDivisions;
}
this->UpdateProgress(.01);
this->StartAppend(input->GetBounds());
this->UpdateProgress(.2);
this->SliceSize = this->NumberOfDivisions[0]*this->NumberOfDivisions[1];
this->Append(input);
......@@ -280,18 +283,21 @@ void vtkQuadricClustering::Append(vtkPolyData *pd)
{
this->AddVertices(inputVerts, inputPoints, 1);
}
this->UpdateProgress(.40);
inputLines = pd->GetLines();
if (inputLines)
{
this->AddEdges(inputLines, inputPoints, 1);
}
this->UpdateProgress(.60);
inputPolys = pd->GetPolys();
if (inputPolys)
{
this->AddPolygons(inputPolys, inputPoints, 1);
}
this->UpdateProgress(.80);
inputStrips = pd->GetStrips();
if (inputStrips)
......@@ -310,6 +316,11 @@ void vtkQuadricClustering::AddPolygons(vtkCellArray *polys, vtkPoints *points,
double pts0[3], pts1[3], pts2[3];
vtkIdType binIds[3];
double total = polys->GetNumberOfCells();
double curr = 0;
double step = total / 100;
double cstep = 0;
for ( polys->InitTraversal(); polys->GetNextCell(numPts, ptIds); )
{
points->GetPoint(ptIds[0],pts0);
......@@ -323,6 +334,12 @@ void vtkQuadricClustering::AddPolygons(vtkCellArray *polys, vtkPoints *points,
this->AddTriangle(binIds, pts0, pts1, pts2, geometryFlag);
}
++this->InCellCount;
if ( curr > cstep )
{
this->UpdateProgress(.6 + .2 * curr / total);
cstep += step;
}
curr += 1;
}//for all polygons
}
......@@ -621,6 +638,7 @@ void vtkQuadricClustering::AddVertices(vtkCellArray *verts, vtkPoints *points,
this->AddVertex(binId, pt, geometryFlag);
}
++this->InCellCount;
this->UpdateProgress(.2 + .2 * i / static_cast<double>(numCells));
}
}
//----------------------------------------------------------------------------
......
......@@ -24,7 +24,7 @@
#include <math.h>
vtkCxxRevisionMacro(vtkSphereSource, "1.64");
vtkCxxRevisionMacro(vtkSphereSource, "1.65");
vtkStandardNewMacro(vtkSphereSource);
//----------------------------------------------------------------------------
......@@ -166,6 +166,8 @@ void vtkSphereSource::Execute()
jEnd = (this->EndPhi >= 180.0 ? this->PhiResolution - 1
: this->PhiResolution);
this->UpdateProgress(0.1);
// Create intermediate points
for (i=0; i < localThetaResolution; i++)
{
......@@ -190,6 +192,7 @@ void vtkSphereSource::Execute()
n[0] /= norm; n[1] /= norm; n[2] /= norm;
newNormals->InsertNextTuple(n);
}
this->UpdateProgress (0.10 + 0.50*i/static_cast<float>(localThetaResolution));
}
// Generate mesh connectivity
......@@ -223,6 +226,7 @@ void vtkSphereSource::Execute()
newPolys->InsertNextCell(3, pts);
}
}
this->UpdateProgress (0.70);
// bands in-between poles
for (i=0; i < localThetaResolution; i++)
......@@ -245,6 +249,7 @@ void vtkSphereSource::Execute()
newPolys->InsertNextCell(4, pts);
}
}
this->UpdateProgress (0.70 + 0.30*i/static_cast<double>(localThetaResolution));
}
// Update ourselves and release memeory
......
Supports Markdown
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