-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraniteInterop.h
65 lines (48 loc) · 2.35 KB
/
GraniteInterop.h
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
/*=========================================================================
Program: Granite Plugin for Paraview
Module: GraniteInterop.h
Author: Toni Westbrook
Please see the included README file for full description,
build/installation instructions, and known issues.
=========================================================================*/
#ifndef __GraniteInterop_h
#define __GraniteInterop_h
#include <string>
#include <vector>
#include <jni.h>
#include "vtkDataSetAttributes.h"
#include "GraniteWrapper.h"
class GraniteInterop {
public:
GraniteInterop();
~GraniteInterop();
bool openDataSource(const char * passFileName, bool passActivate); // Open data source, return success
// Methods acting on current data source
void copyFloatData(int * passBounds, vtkDataSetAttributes * retData); // Copy float array from Granite to VTK for bounds specified
int getAttributeCount(); // Number of attributes
const char * getAttributeName(int passIdx); // Name of attribute
int * getBounds(); // Bounding array across 3 dimensions (xLow, xHigh, yLow...)
int getDimensions(); // Dimensionality of bounds
bool isMultiresolution(); // Is data source multiresolution
int getLevelCount(); // Number of multiresolution levels
int getLevel(); // Get current level
void setLevel(int passLevel); // Set current level
// JVM related
const char * getExceptionMessage();
const char * getClassName(jobject passObject); // Get the class name of a Java object
private:
void clearValues(); // Clear all bounds and attribute data
bool cacheValues(); // Cache Granite Java values into native objects
bool calculateBounds(); // Calculate all resolution levels of bounds for cacheValues
void convertBoundArrays(int * passBounds, jintArray * retLow, jintArray * retHigh); // Convert {xLow, xHigh, ...} to existing jintArrays
// Granite data source Java handle
jobject _jDataSource;
// Native data
static GraniteWrapper * _wrapper; // JNI doesn't allow JVM unloading, only initialize GraniteReaderWrapper once
bool _multiresolution; // Is data multiresolution
int _currentLevel; // Current number of resolution levels
std::vector< std::vector< int > > _boundsCache; // Data bounds per level
int _dimensionsCache; // Dimensionality of data
std::vector< std::string > _attributeNames; // Component attribute names
};
#endif // __GraniteInterop_h