Commit cf68769c authored by Karthik Krishnan's avatar Karthik Krishnan
Browse files

ENH: Add method to build a contour from user supplied polydata. This

is useful when you compute a bunch of points, lets say based on image features
and you want to display a contour widget that runs through those points.
parent a83d7b74
......@@ -40,7 +40,7 @@
#include "vtkFocalPlanePointPlacer.h"
#include "vtkBezierContourLineInterpolator.h"
vtkCxxRevisionMacro(vtkOrientedGlyphContourRepresentation, "1.6");
vtkCxxRevisionMacro(vtkOrientedGlyphContourRepresentation, "1.7");
vtkStandardNewMacro(vtkOrientedGlyphContourRepresentation);
//----------------------------------------------------------------------
......@@ -607,6 +607,60 @@ void vtkOrientedGlyphContourRepresentation::BuildRepresentation()
}
//----------------------------------------------------------------------
void vtkOrientedGlyphContourRepresentation
::BuildRepresentationFromUserSuppliedPolydata( vtkPolyData * pd )
{
vtkPoints *points = pd->GetPoints();
vtkIdType nPoints = points->GetNumberOfPoints();
if (nPoints <= 0)
{
return; // Yeah right.. build from nothing !
}
// Clear all existing nodes.
for(unsigned int i=0;i<this->Internal->Nodes.size();i++)
{
for (unsigned int j=0;j<this->Internal->Nodes[i]->Points.size();j++)
{
delete this->Internal->Nodes[i]->Points[j];
}
this->Internal->Nodes[i]->Points.clear();
delete this->Internal->Nodes[i];
}
this->Internal->Nodes.clear();
vtkIdType index = 0;
vtkIdList *pointIds = pd->GetCell(0)->GetPointIds();
// Get the worldOrient from the point placer
double ref[3], displayPos[2], worldPos[3], worldOrient[9];
ref[0] = 0.0; ref[1] = 0.0; ref[2] = 0.0;
displayPos[0] = 0.0; displayPos[1] = 0.0;
this->PointPlacer->ComputeWorldPosition(this->Renderer,
displayPos, ref, worldPos, worldOrient );
// Add nodes
for ( vtkIdType i=0; i < nPoints; i++ )
{
double *p = points->GetPoint( i );
this->AddNodeAtWorldPosition( p, worldOrient );
}
if ( pointIds->GetNumberOfIds() > nPoints )
{
this->ClosedLoopOn();
}
// Update the contour representation from the nodes using the line interpolator
this->BuildRepresentation();
// Show the contour.
this->VisibilityOn();
}
//----------------------------------------------------------------------
void vtkOrientedGlyphContourRepresentation::GetActors(vtkPropCollection *pc)
{
......
......@@ -82,6 +82,13 @@ public:
virtual void WidgetInteraction(double eventPos[2]);
virtual int ComputeInteractionState(int X, int Y, int modified=0);
// Description:
// Build a contour representation from externally supplied PolyData. This
// is very useful when you use an external program to compute a set of
// contour nodes, let's say based on image features. Subsequently, you want
// to build and display a contour that runs through those points.
virtual void BuildRepresentationFromUserSuppliedPolydata( vtkPolyData * );
// Description:
// Methods to make this class behave as a vtkProp.
virtual void GetActors(vtkPropCollection *);
......
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