ctkVTKTransferFunctionRepresentationTest1.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Qt includes
  2. #include <QCoreApplication>
  3. #include <QDebug>
  4. // CTK includes
  5. #include "ctkTransferFunctionRepresentation.h"
  6. // CTKVTK includes
  7. #include "ctkVTKColorTransferFunction.h"
  8. #include "ctkVTKLookupTable.h"
  9. // VTK includes
  10. #include <vtkColorTransferFunction.h>
  11. #include <vtkLookupTable.h>
  12. #include <vtkSmartPointer.h>
  13. // STD includes
  14. #include <cstdlib>
  15. #include <iostream>
  16. int ctkVTKTransferFunctionRepresentationTest1( int argc, char * argv [])
  17. {
  18. Q_UNUSED(argc);
  19. Q_UNUSED(argv);
  20. //--------------------------------------------
  21. //Test 1 : with default TransfertFunction
  22. //----------------------------------------------------------------------
  23. /// Function not discrete
  24. ctkVTKColorTransferFunction defaultCTF;
  25. vtkColorTransferFunction* colorTransferFunction = vtkColorTransferFunction::New();
  26. defaultCTF.setColorTransferFunction(colorTransferFunction);
  27. ctkTransferFunctionRepresentation representation;
  28. representation.setTransferFunction(&defaultCTF);
  29. qreal defaultMinRange = 0.;
  30. qreal defaultMaxRange = 1.;
  31. defaultCTF.range(defaultMinRange, defaultMaxRange);
  32. qreal firstPos = 10.;
  33. qreal secondPos = 20.;
  34. ctkControlPoint* defaultControlPoint;
  35. int firstIndex = defaultCTF.insertControlPoint(firstPos);
  36. int secondIndex = defaultCTF.insertControlPoint(secondPos);
  37. std::cout << "Index :" << firstIndex << " " << secondIndex << std::endl;
  38. defaultControlPoint = defaultCTF.controlPoint(0);
  39. defaultControlPoint = defaultCTF.controlPoint(firstIndex);
  40. defaultControlPoint = defaultCTF.controlPoint(secondIndex);
  41. Q_UNUSED(defaultControlPoint)
  42. representation.computeCurve();
  43. representation.computeGradient();
  44. colorTransferFunction->Delete();
  45. /// Function discrete
  46. ctkVTKLookupTable defaultLuT;
  47. vtkLookupTable* lookupTable = vtkLookupTable::New();
  48. defaultLuT.setLookupTable(lookupTable);
  49. representation.setTransferFunction(&defaultLuT);
  50. representation.computeCurve();
  51. representation.computeGradient();
  52. lookupTable->Delete();
  53. return EXIT_SUCCESS;
  54. }