Advertisement
szilardszaloki

vtkDualGraph.cpp

Oct 8th, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. #include "vtkDualGraph.h"
  2.  
  3. #include "vtkBoostGraphAdapter.h"
  4. #include "vtkInformationVector.h"
  5. #include "vtkObjectFactory.h"
  6. //----------------------------------------------------------------------------
  7. #include <iostream>
  8. #include <vector>
  9.  
  10. #include <boost/tuple/tuple.hpp>
  11. #include <boost/graph/adjacency_list.hpp>
  12. #include <boost/graph/boyer_myrvold_planar_test.hpp>
  13. #include <boost/planar_dual.hpp>
  14. //----------------------------------------------------------------------------
  15. using namespace boost;
  16. vtkStandardNewMacro(vtkDualGraph);
  17. //----------------------------------------------------------------------------
  18. vtkDualGraph::vtkDualGraph(){}
  19. //----------------------------------------------------------------------------
  20. vtkDualGraph::~vtkDualGraph(){}
  21. //----------------------------------------------------------------------------
  22. void vtkDualGraph::PrintSelf(ostream& os, vtkIndent indent){
  23.     this->Superclass::PrintSelf(os, indent);
  24. }
  25. //----------------------------------------------------------------------------
  26. int vtkDualGraph::RequestData(vtkInformation* vtkNotUsed(request),
  27.                               vtkInformationVector** inputVector,
  28.                               vtkInformationVector* outputVector){
  29.     // get the info objects
  30.     vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  31.     vtkInformation *outInfo = outputVector->GetInformationObject(0);
  32.    
  33.     // get the input and output
  34.     vtkGraph *input = vtkGraph::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
  35.     vtkGraph *output = vtkGraph::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
  36.    
  37.     vtkUndirectedGraph* in = vtkUndirectedGraph::SafeDownCast(input);    
  38.     vtkMutableUndirectedGraph* dual = vtkMutableUndirectedGraph::SafeDownCast(output);
  39.    
  40.     // Compute the planar embedding - we know the input graph is planar,
  41.     // so we're ignoring the return value of the test
  42.     typedef std::vector<graph_traits<vtkUndirectedGraph*>::edge_descriptor> vec_t;
  43.     std::vector<vec_t> embedding(num_vertices(in));
  44.     boyer_myrvold_planarity_test(boyer_myrvold_params::graph = in, boyer_myrvold_params::embedding = &embedding[0]);
  45.    
  46.     create_dual_graph(in, dual, &embedding[0]);
  47.    
  48.     return 1;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement