Commit f4c61c39 authored by Thomas Otahal's avatar Thomas Otahal
Browse files

ENH: Added circle packing layout classes to VTK.

The vtkCirclePackLayout filter is similar to the area layout
filter in Infovis and produces a triple for each vertex in
an input vtkTree.  The triple represents the (X, Y, Radius)
of the circle for that vertex.  There is a concrete implementation
of the vtkCirclePackLayoutStrategy class for a "front chain"
based circle packing layout.  There is also a regression test
for the layout classes and a poly data mapper class for the
packed circle layout.
parent acfe2239
......@@ -32,6 +32,10 @@ vtkBivariateLinearTableThreshold.cxx
vtkBivariateStatisticsAlgorithm.cxx
vtkBoxLayoutStrategy.cxx
vtkChacoGraphReader.cxx
vtkCirclePackFrontChainLayoutStrategy.cxx
vtkCirclePackLayout.cxx
vtkCirclePackLayoutStrategy.cxx
vtkCirclePackToPolyData.cxx
vtkCircularLayoutStrategy.cxx
vtkClustering2DLayoutStrategy.cxx
vtkCollapseGraph.cxx
......@@ -251,6 +255,7 @@ ENDIF(VTK_HAS_UINT64_ARRAY)
SET_SOURCE_FILES_PROPERTIES(
vtkAreaLayoutStrategy.cxx
vtkBivariateStatisticsAlgorithm.cxx
vtkCirclePackLayoutStrategy.cxx
vtkEdgeLayoutStrategy.cxx
vtkGraphLayoutStrategy.cxx
vtkStatisticsAlgorithm.cxx
......
......@@ -9,6 +9,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
SET(MyTests
TestArcEdges
TestAssignCoordinates
TestCirclePackLayoutStrategy
TestCollapseVerticesByArray
TestContingencyStatistics
TestCorrelativeStatistics
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestTreeMapLayoutStrategy.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
#include "vtkActor.h"
#include "vtkCirclePackFrontChainLayoutStrategy.h"
#include "vtkIntArray.h"
#include "vtkMutableDirectedGraph.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTree.h"
#include "vtkTreeFieldAggregator.h"
#include "vtkCirclePackLayout.h"
#include "vtkCirclePackToPolyData.h"
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
void TestStrategy(vtkCirclePackLayoutStrategy* strategy, vtkTreeAlgorithm* input, double posX, double posY, vtkRenderer* ren)
{
VTK_CREATE(vtkCirclePackLayout, layout);
layout->SetLayoutStrategy(strategy);
layout->SetInputConnection(input->GetOutputPort());
layout->Update();
vtkDataArray* vda = layout->GetOutput()->GetVertexData()->GetArray("circle");
// Test GetBoundingCircle() and FindVertex()
float cinfo[3];
layout->GetBoundingCircle(vda->GetNumberOfTuples() - 1, cinfo);
float pnt[2];
pnt[0] = cinfo[0];
pnt[1] = cinfo[1];
if(((int) layout->FindVertex(pnt)) != (vda->GetNumberOfTuples() - 1))
{
cout << "GetBoundingCircle() and FindVertex() returned incorrect id" << endl;
exit(1);
}
VTK_CREATE(vtkCirclePackToPolyData, poly);
poly->SetInputConnection(layout->GetOutputPort());
VTK_CREATE(vtkPolyDataMapper, mapper);
mapper->SetInputConnection(poly->GetOutputPort());
mapper->SetScalarRange(0,600);
mapper->SetScalarModeToUseCellFieldData();
mapper->SelectColorArray("size");
VTK_CREATE(vtkActor, actor);
actor->SetMapper(mapper);
actor->SetPosition(posX, posY, 0);
ren->AddActor(actor);
}
int TestCirclePackLayoutStrategy(int argc, char* argv[])
{
VTK_CREATE(vtkRenderer, ren);
// Create input
VTK_CREATE(vtkMutableDirectedGraph, builder);
VTK_CREATE(vtkIntArray, sizeArr);
sizeArr->SetName("size");
builder->GetVertexData()->AddArray(sizeArr);
builder->AddVertex();
sizeArr->InsertNextValue(0);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(77);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(15);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(99);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(107);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(432);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(259);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(242);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(306);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(91);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(46);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(47);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(150);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(90);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(10);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(456);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(40);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(100);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(400);
builder->AddChild(0);
sizeArr->InsertNextValue(500);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);
sizeArr->InsertNextValue(1);
builder->AddChild(0);