|
|
(14 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | This example produces a vtkGraph as output. Current it does not work - producing errors such as
| + | = '''See [https://lorensen.github.io/VTKExamples/site/Cxx/Developers/GraphAlgorithmSource GraphAlgorithmSource] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' = |
− | | |
− | You are trying to instantiate DataObjectType "vtkGraph" which does not exist.
| |
− | | |
− | and
| |
− | | |
− | Algorithm vtkTestSource(0x9fee918) did not create output for port 0 when asked by REQUEST_DATA_OBJECT and does not specify a concrete DATA_TYPE_NAME.
| |
− | | |
− | ==SourceExample.cxx==
| |
− | <source lang="cpp">
| |
− | #include <vtkSmartPointer.h>
| |
− | #include <vtkGraph.h>
| |
− | #include <vtkMutableUndirectedGraph.h>
| |
− | | |
− | #include "vtkTestSource.h"
| |
− | | |
− | int main (int argc, char *argv[])
| |
− | {
| |
− | vtkSmartPointer<vtkTestSource> source = vtkSmartPointer<vtkTestSource>::New();
| |
− | source->Update();
| |
− |
| |
− | vtkGraph* outputGraph = source->GetOutput();
| |
− | vtkstd::cout << "Output number of vertices: " << outputGraph->GetNumberOfVertices() << vtkstd::endl;
| |
− |
| |
− | return 0;
| |
− | }
| |
− | | |
− | </source>
| |
− | | |
− | ==vtkTestSource.h==
| |
− | <source lang="cpp">
| |
− | | |
− | #ifndef __vtkTestSource_h
| |
− | #define __vtkTestSource_h
| |
− | | |
− | #include "vtkGraphAlgorithm.h"
| |
− | | |
− | class vtkTestSource : public vtkGraphAlgorithm
| |
− | {
| |
− | public:
| |
− | vtkTypeRevisionMacro(vtkTestSource,vtkGraphAlgorithm);
| |
− | void PrintSelf(ostream& os, vtkIndent indent);
| |
− | | |
− | static vtkTestSource *New();
| |
− |
| |
− | protected:
| |
− | vtkTestSource();
| |
− | ~vtkTestSource();
| |
− |
| |
− | //int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
| |
− | int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
| |
− | | |
− | private:
| |
− | vtkTestSource(const vtkTestSource&); // Not implemented.
| |
− | void operator=(const vtkTestSource&); // Not implemented.
| |
− | | |
− | };
| |
− | | |
− | #endif
| |
− | | |
− | </source>
| |
− | | |
− | ==vtkTestSource.cxx==
| |
− | <source lang="cpp">
| |
− | #include "vtkTestSource.h"
| |
− | | |
− | #include "vtkObjectFactory.h"
| |
− | #include "vtkStreamingDemandDrivenPipeline.h"
| |
− | #include "vtkInformationVector.h"
| |
− | #include "vtkInformation.h"
| |
− | #include "vtkDataObject.h"
| |
− | #include "vtkSmartPointer.h"
| |
− | #include "vtkMutableUndirectedGraph.h"
| |
− | | |
− | vtkCxxRevisionMacro(vtkTestSource, "$Revision: 1.70 $");
| |
− | vtkStandardNewMacro(vtkTestSource);
| |
− | | |
− | vtkTestSource::vtkTestSource()
| |
− | {
| |
− | this->SetNumberOfInputPorts(0);
| |
− | this->SetNumberOfOutputPorts(1);
| |
− | }
| |
− | | |
− | vtkTestSource::~vtkTestSource()
| |
− | {
| |
− | | |
− | }
| |
− | | |
− | //int vtkTestSource::RequestData(vtkInformation *vtkNotUsed(request),
| |
− | int vtkTestSource::RequestDataObject(vtkInformation *vtkNotUsed(request),
| |
− | vtkInformationVector **inputVector,
| |
− | vtkInformationVector *outputVector)
| |
− | {
| |
− |
| |
− | vtkInformation *outInfo = outputVector->GetInformationObject(0);
| |
− |
| |
− | vtkMutableUndirectedGraph *output = vtkMutableUndirectedGraph::SafeDownCast(
| |
− | outInfo->Get(vtkDataObject::DATA_OBJECT()));
| |
− |
| |
− | output = vtkMutableUndirectedGraph::New();
| |
− |
| |
− | //add 3 vertices
| |
− | output->AddVertex();
| |
− | output->AddVertex();
| |
− | output->AddVertex();
| |
− |
| |
− | return 1;
| |
− | }
| |
− | | |
− | | |
− | //---------------------------------------------------------------------------- | |
− | void vtkTestSource::PrintSelf(ostream& os, vtkIndent indent)
| |
− | {
| |
− | this->Superclass::PrintSelf(os,indent);
| |
− | }
| |
− | </source>
| |
− | | |
− | ==CMakeLists.txt==
| |
− | <source lang="text">
| |
− | cmake_minimum_required(VERSION 2.6)
| |
− | PROJECT(vtkGraphAlgorithmSource)
| |
− | | |
− | FIND_PACKAGE(VTK REQUIRED)
| |
− | INCLUDE(${VTK_USE_FILE})
| |
− | | |
− | ADD_EXECUTABLE(SourceExample SourceExample.cxx vtkTestSource.cxx)
| |
− | TARGET_LINK_LIBRARIES(SourceExample vtkHybrid)
| |
− | | |
− | </source>
| |