ctkVTKTransferFunctionRepresentationTest1.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. representation.computeCurve();
  42. representation.computeGradient();
  43. colorTransferFunction->Delete();
  44. /// Function discrete
  45. ctkVTKLookupTable defaultLuT;
  46. vtkLookupTable* lookupTable = vtkLookupTable::New();
  47. defaultLuT.setLookupTable(lookupTable);
  48. representation.setTransferFunction(&defaultLuT);
  49. representation.computeCurve();
  50. representation.computeGradient();
  51. lookupTable->Delete();
  52. return EXIT_SUCCESS;
  53. }