File: TestDataEncoder.cxx

package info (click to toggle)
paraview 5.1.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 221,108 kB
  • ctags: 236,092
  • sloc: cpp: 2,416,026; ansic: 190,891; python: 99,856; xml: 81,001; tcl: 46,915; yacc: 5,039; java: 4,413; perl: 3,108; sh: 1,974; lex: 1,926; f90: 748; asm: 471; pascal: 228; makefile: 198; objc: 83; fortran: 31
file content (65 lines) | stat: -rw-r--r-- 1,718 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "vtkNew.h"
#include "vtkPNGReader.h"
#include "vtkPVDataEncoder.h"
#include "vtkTestUtilities.h"
#include "vtkSmartPointer.h"
#include "vtkImageData.h"

#include <vtksys/SystemTools.hxx>

#include <string>
#include <vector>

// returns 0 on success.
int TestDataEncoder(int argc, char* argv[])
{
  char* dataroot = vtkTestUtilities::GetDataRoot(argc, argv);
  if (!dataroot)
    {
    vtkGenericWarningMacro("Missing Data Root!");
    return 1;
    }

  // Open image files from the PARAVIEW_DATA_ROOT/Baseline and try to
  // encode/compress them and then verify that they are indeed the same.
  const char* filenames[] = {
    "/Baseline/Clip.png",
    "/Baseline/Contour.png",
    "/Baseline/ContourRange.png",
    "/Baseline/EnSight.png",
    "/Baseline/ExtractBlock.png",
    "/Baseline/ExtractGrid.png",
    NULL
  };

  std::vector<vtkSmartPointer<vtkImageData> > images;
  for (int cc=0; filenames[cc] != NULL; cc++)
    {
    vtkNew<vtkPNGReader> reader;
    std::string filename(dataroot);
    filename += filenames[cc];
    reader->SetFileName(filename.c_str());
    reader->Update();
    images.push_back(reader->GetOutput());
    }

  int errors = 0;
  vtkNew<vtkPVDataEncoder> encoder;
  for (size_t cc=0; cc < images.size(); cc++)
    {
    vtkImageData* img = images[cc].GetPointer();
    img->Register(NULL);
    images[cc] = NULL;
    encoder->PushAndTakeReference(cc % 3, img, 100);
    vtksys::SystemTools::Delay(10); // 0.2s
    }

  vtkSmartPointer<vtkUnsignedCharArray> data;
  encoder->GetLatestOutput(0, data);
  encoder->GetLatestOutput(1, data);
  encoder->GetLatestOutput(2, data);
  encoder->GetLatestOutput(3, data);
  encoder->Flush(0);
  delete [] dataroot;
  return errors;
}