Commit a4f9143a authored by Jeff Baumes's avatar Jeff Baumes

ENH: Adding simple geo random graph source.

parent b35cd253
......@@ -14,7 +14,7 @@ SET( Kit_SRCS
vtkGeoArcs.cxx
vtkGeoAssignCoordinates.cxx
vtkGeoCamera.cxx
vtkGeoComputeTextureCoordinates.cxx
vtkGeoComputeTextureCoordinates.cxx
vtkGeoEdgeStrategy.cxx
vtkGeoGraphRepresentation.cxx
vtkGeoImageNode.cxx
......@@ -22,7 +22,8 @@ SET( Kit_SRCS
vtkGeoLineRepresentation.cxx
vtkGeoMath.cxx
vtkGeoPatch.cxx
vtkGeoSampleArcs.cxx
vtkGeoRandomGraphSource.cxx
vtkGeoSampleArcs.cxx
vtkGeoTreeNode.cxx
vtkGeoTerrain.cxx
vtkGeoTerrainGlobeSource.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGeoRandomGraphSource.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 "vtkGeoRandomGraphSource.h"
#include "vtkDataSetAttributes.h"
#include "vtkDoubleArray.h"
#include "vtkGraph.h"
#include "vtkInformation.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
vtkCxxRevisionMacro(vtkGeoRandomGraphSource, "1.1");
vtkStandardNewMacro(vtkGeoRandomGraphSource);
// ----------------------------------------------------------------------
vtkGeoRandomGraphSource::vtkGeoRandomGraphSource()
{
}
// ----------------------------------------------------------------------
vtkGeoRandomGraphSource::~vtkGeoRandomGraphSource()
{
}
// ----------------------------------------------------------------------
void vtkGeoRandomGraphSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
// ----------------------------------------------------------------------
int vtkGeoRandomGraphSource::RequestData(
vtkInformation* info,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
vtkRandomGraphSource::RequestData(info, inputVector, outputVector);
// Set random lat/long points into the output
vtkGraph* output = vtkGraph::GetData(outputVector);
vtkDoubleArray* latArr = vtkDoubleArray::New();
vtkDoubleArray* lonArr = vtkDoubleArray::New();
latArr->SetNumberOfTuples(output->GetNumberOfVertices());
lonArr->SetNumberOfTuples(output->GetNumberOfVertices());
latArr->SetName("latitude");
lonArr->SetName("longitude");
for (vtkIdType v = 0; v < output->GetNumberOfVertices(); ++v)
{
double lat = vtkMath::Random()*180.0 - 90.0;
double lon = vtkMath::Random()*360.0 - 180.0;
latArr->SetValue(v, lat);
lonArr->SetValue(v, lon);
}
output->GetVertexData()->AddArray(latArr);
output->GetVertexData()->AddArray(lonArr);
latArr->Delete();
lonArr->Delete();
return 1;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGeoRandomGraphSource.h
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.
-------------------------------------------------------------------------*/
// .NAME vtkGeoRandomGraphSource - a geospatial graph with random edges
//
// .SECTION Description
// Generates a graph with a specified number of vertices, with the density of
// edges specified by either an exact number of edges or the probability of
// an edge. You may additionally specify whether to begin with a random
// tree (which enforces graph connectivity).
//
// The filter also adds random vertex attributes called latitude and longitude.
// The latitude is distributed uniformly from -90 to 90, while longitude is
// distributed uniformly from -180 to 180.
//
// .SECTION See Also
// vtkRandomGraphSource
#ifndef __vtkGeoRandomGraphSource_h
#define __vtkGeoRandomGraphSource_h
#include "vtkRandomGraphSource.h"
class vtkGraph;
class VTK_GEOVIS_EXPORT vtkGeoRandomGraphSource : public vtkRandomGraphSource
{
public:
static vtkGeoRandomGraphSource* New();
vtkTypeRevisionMacro(vtkGeoRandomGraphSource,vtkRandomGraphSource);
void PrintSelf(ostream& os, vtkIndent indent);
protected:
vtkGeoRandomGraphSource();
~vtkGeoRandomGraphSource();
virtual int RequestData(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
private:
vtkGeoRandomGraphSource(const vtkRandomGraphSource&); // Not implemented
void operator=(const vtkGeoRandomGraphSource&); // Not implemented
};
#endif
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