Class RawDatasetAdapter
Adapter for converting other formats to ABRDataFormat. For example, lists of points => ribbons, or lists of points => glyphs. See the examples below for usage of each of these methods.
Namespace: IVLab.ABREngine
Assembly: IVLab.ABREngine.Runtime.dll
Syntax
public static class RawDatasetAdapter
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Methods
| Improve this Doc View SourceGridPointsToSurface(List<Vector3>, Vector2Int, Bounds, Dictionary<string, List<float>>)
Convert a grid (2.5D) of points into an ABR surface data object.
Declaration
public static RawDataset GridPointsToSurface(List<Vector3> points, Vector2Int gridDimension, Bounds dataBounds, Dictionary<string, List<float>> scalarVars)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | points | Vertices of the desired mesh. Points are assumed to be in reverse column-major order, i.e. starting from -x, -z and ending at +x +z. |
Vector2Int | gridDimension | Dimensions of the mesh grid that the points make up (x vertex count and z vertex count). |
Bounds | dataBounds | The bounds of the actual vertices of the data. |
Dictionary<string, List<float>> | scalarVars | Mapping from name => float array for every scalar variable attached to the data. Float arrays are assumed to have the same ordering as |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a surface from a Cube GameObject primitive.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
// 3x3 2.5D grid of points. Note their arrangement in x-based "columns"
// -- this is a grid in the X-Z plane where only the y-coordinate is
// varying.
List<Vector3> gridVertices = new List<Vector3>
{
// column 1
new Vector3(0.0f, 0.5f, 0.0f),
new Vector3(0.0f, 0.6f, 0.1f),
new Vector3(0.0f, 0.4f, 0.2f),
// column 2
new Vector3(0.1f, 0.3f, 0.0f),
new Vector3(0.1f, 0.2f, 0.1f),
new Vector3(0.1f, 0.3f, 0.2f),
// column 3
new Vector3(0.2f, 0.0f, 0.0f),
new Vector3(0.2f, 0.3f, 0.1f),
new Vector3(0.2f, 0.1f, 0.2f),
};
// Dimenisions of the grid vertices (3x3)
Vector2Int dimensions = new Vector2Int(3, 3);
// Each data point corresponds with a vertex above
List<float> data = new List<float>
{
0.0f,
0.0f,
0.0f,
1.0f,
1.0f,
1.0f,
2.0f,
2.0f,
2.0f,
};
// Save the var so we can use it
Dictionary<string, List<float>> scalarVars = new Dictionary<string, List<float>> {{ "someData", data }};
// Provide a generous bounding box
Bounds b = new Bounds(Vector3.zero, Vector3.one);
RawDataset abrSurface = RawDatasetAdapter.GridPointsToSurface(gridVertices, dimensions, b, scalarVars);
// Or, if you don't have any variables:
RawDataset abrSurface2 = RawDatasetAdapter.GridPointsToSurface(gridVertices, dimensions, b, null);
}
}
|
Improve this Doc
View Source
MeshToSurface(Mesh, Dictionary<string, List<float>>)
Create a surfaces data object from a Unity mesh
Declaration
public static RawDataset MeshToSurface(Mesh mesh, Dictionary<string, List<float>> scalarVars)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The original mesh |
Dictionary<string, List<float>> | scalarVars |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we load a triangle GameObject from our existing Unity scene and associate some data with it.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
Mesh m = GameObject.Find("SomeTriangle").GetComponent<MeshFilter>().mesh;
// 3 vertices with scalar data values (assumed to have same number of vertices as the mesh, and the same order too)
List<float> someVariable = new List<float> { 0.0f, 1.0f, 0.5f };
Dictionary<string, List<float>> scalarVars = new Dictionary<string, List<float>> {{ "someVariable", someVariable }};
RawDataset meshSurface = RawDatasetAdapter.MeshToSurface(m, scalarVars);
}
}
|
Improve this Doc
View Source
ObjToSurface(string)
Load data from the data source.
Declaration
public static RawDataset ObjToSurface(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Data source file |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we load in a 3D model in OBJ format and convert it into ABR format.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
RawDataset objSurface = RawDatasetAdapter.ObjToSurface("C:/Users/me/Desktop/cube.obj");
}
}
|
Improve this Doc
View Source
PointsToLine(List<List<Vector3>>, Bounds, Dictionary<string, List<float>>)
Define a Line dataset from a bunch of points. Don't try to assume or calculate the full bounds for the imported data objects - explictly ask the user for them.
Declaration
public static RawDataset PointsToLine(List<List<Vector3>> lines, Bounds dataBounds, Dictionary<string, List<float>> scalarVars)
Parameters
Type | Name | Description |
---|---|---|
List<List<Vector3>> | lines | One, or several, lines. Each line consists of a series of points. |
Bounds | dataBounds | The center and extents of the data in the original coordinate space |
Dictionary<string, List<float>> | scalarVars | Mapping of variable name => array of floating point numbers for each scalar variable attached to the lines. Values will be applied at each point along each segment of each line. |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
PointsToLine(List<Vector3>, Bounds, Dictionary<string, List<float>>)
Define a Line dataset from a bunch of points. Don't try to assume or calculate the full bounds for the imported data objects - explictly ask the user for them. This method is a shortcut for a single connected line.
Declaration
public static RawDataset PointsToLine(List<Vector3> line, Bounds dataBounds, Dictionary<string, List<float>> scalarVars)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | line | |
Bounds | dataBounds | The center and extents of the data in the original coordinate space |
Dictionary<string, List<float>> | scalarVars | Mapping of variable name => array of floating point numbers for each scalar variable attached to the lines. Values will be applied at each point along each segment of each line. |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a single line from a series of vertices that have data values associated with them.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
List<Vector3> points = new List<Vector3>
{
new Vector3(0.0f, 0.0f, 0.0f),
new Vector3(0.1f, 0.1f, 0.0f),
new Vector3(0.2f, 0.2f, 0.0f),
new Vector3(0.3f, 0.3f, 0.0f),
new Vector3(0.4f, 0.4f, 0.0f),
new Vector3(0.5f, 0.5f, 0.0f)
};
// Each data point corresponds with a vertex above
List<float> data = new List<float>
{
0.0f,
1.0f,
2.0f,
3.0f,
4.0f,
5.0f
};
// Save the scalar var so we can use it
Dictionary<string, List<float>> scalarVars = new Dictionary<string, List<float>> {{ "someData", data }};
// Provide a generous bounding box
Bounds b = new Bounds(Vector3.zero, Vector3.one);
RawDataset abrLine = RawDatasetAdapter.PointsToLine(points, b, scalarVars);
// Or, if you don't have any variables:
RawDataset abrLine2 = RawDatasetAdapter.PointsToLine(points, b, null);
}
}
|
Improve this Doc
View Source
PointsToPoints(List<Vector3>, Bounds, Dictionary<string, List<float>>, Dictionary<string, List<Vector3>>)
Define a Point dataset from a bunch of points. Don't try to assume or calculate the full bounds for the imported data objects - explictly ask the user for them.
Declaration
public static RawDataset PointsToPoints(List<Vector3> points, Bounds dataBounds, Dictionary<string, List<float>> scalarVars, Dictionary<string, List<Vector3>> vectorVars)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | points | Source points in the original coordinate space |
Bounds | dataBounds | Center and extent of the data, in the original coordinate space |
Dictionary<string, List<float>> | scalarVars | Mapping of variable name => array of floating point numbers for each scalar variable attached to these points. Values will be applied at each point of the dataset. |
Dictionary<string, List<Vector3>> | vectorVars | Mapping of variable name => array of Vector3 for each vector variable attached to these points. Values will be applied at each point of the dataset. |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a points data object from a series of vertices.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
List<Vector3> points = new List<Vector3>
{
new Vector3(0.0f, 0.0f, 0.0f),
new Vector3(0.1f, 0.1f, 0.0f),
new Vector3(0.2f, 0.2f, 0.0f),
new Vector3(0.3f, 0.3f, 0.0f),
new Vector3(0.4f, 0.4f, 0.0f),
new Vector3(0.5f, 0.5f, 0.0f)
};
// Each data point corresponds with a vertex above
List<float> data = new List<float>
{
0.0f,
1.0f,
2.0f,
3.0f,
4.0f,
5.0f
};
// Some vector data corresponding with each vertex
List<Vector3> vectorData = new List<Vector3>
{
Vector3.up,
Vector3.up,
Vector3.up,
Vector3.down,
Vector3.down,
Vector3.down,
};
// Save the vars so we can use them
Dictionary<string, List<float>> scalarVars = new Dictionary<string, List<float>> {{ "someData", data }};
Dictionary<string, List<Vector3>> vectorVars = new Dictionary<string, List<Vector3>> {{ "someVectorData", vectorData }};
// Provide a generous bounding box
Bounds b = new Bounds(Vector3.zero, Vector3.one);
RawDataset abrPoints = RawDatasetAdapter.PointsToPoints(points, b, scalarVars, vectorVars);
// Or, if you don't have any variables:
RawDataset abrPoints2 = RawDatasetAdapter.PointsToPoints(points, b, null, null);
}
}
|
Improve this Doc
View Source
UnityPrimitiveToSurface(PrimitiveType)
Create a Surface data object from a Unity primitive. By default, includes XAxis, YAxis, and ZAxis scalar variables.
Declaration
public static RawDataset UnityPrimitiveToSurface(PrimitiveType primitive)
Parameters
Type | Name | Description |
---|---|---|
PrimitiveType | primitive |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a surface from a Cube GameObject primitive.
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
RawDataset cubeSurface = RawDatasetAdapter.UnityPrimitiveToSurface(PrimitiveType.Cube);
}
}
|
Improve this Doc
View Source
VoxelsToVolume(float[], string, Vector3Int, Bounds)
Convert a 1D array into an ABR volume data object. There is assumed to be a single scalar variable described by the array voxels
.
Declaration
public static RawDataset VoxelsToVolume(float[] voxels, string voxelsName, Vector3Int volumeDimensions, Bounds dataBounds)
Parameters
Type | Name | Description |
---|---|---|
float[] | voxels | Individual scalar values that make up the volume. All voxels are assumed to be the same size. |
string | voxelsName | Name of the variable the |
Vector3Int | volumeDimensions | Dimensions of the volume (number of steps in x, y, and z). |
Bounds | dataBounds | The bounds of volume in actual space. |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a volume from a series of voxels
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
// Define a 100x100x100 volume
int volX = 100;
int volY = 100;
int volZ = 100;
float[] voxels = new float[volX * volY * volZ];
// Populate voxels with "data" (x * y * z)
int v = 0;
for (int v = 0; v < voxels.Length; v++)
{
int z = v / (volX * volY);
int vAdjusted = v - (z * volX * volY);
int x = vAdjusted % volX;
int y = vAdjusted / volX;
voxels[v] = x * y * z;
}
Bounds b = new Bounds(Vector3.zero, Vector3.one);
RawDataset abrVolume = RawDatasetAdapter.VoxelsToVolume(voxels, "someData", new Vector3Int(volX, volY, volZ), b);
}
}
|
Improve this Doc
View Source
VoxelsToVolume(float[][][], string, Vector3Int, Bounds)
Convert a 3D grid into an ABR volume data object. There is assumed to be a single scalar variable described by the array voxels
.
Declaration
public static RawDataset VoxelsToVolume(float[][][] voxels, string voxelsName, Vector3Int volumeDimensions, Bounds dataBounds)
Parameters
Type | Name | Description |
---|---|---|
float[][][] | voxels | 3D voxels that make up the volume. All voxels are assumed to be the same size. |
string | voxelsName | Name of the variable the |
Vector3Int | volumeDimensions | Dimensions of the volume (number of steps in x, y, and z). |
Bounds | dataBounds | The bounds of volume in actual space. |
Returns
Type | Description |
---|---|
RawDataset |
Remarks
Note: None of these methods will actually import your data into ABR!
These are simply a convenience for converting data into ABR format.
After you call one of the RawDatasetAdapter methods, you MUST import it
using ABREngine.Instance.Data.ImportRawDataset(...)
to be able to use
it in ABR!
Examples
In this example, we create a volume from a series of voxels
public class RawDatasetAdapterExample : MonoBehaviour
{
void Start()
{
// Define a 100x100x100 volume
int volX = 100;
int volY = 100;
int volZ = 100;
float[][][] voxels = new float[volZ][][];
// Populate voxels with "data" (x * y * z)
for (int z = 0; z < volZ; z++)
{
float[][] stack = new float[volY][];
for (int y = 0; y < volY; y++)
{
float[] col = new float[volX];
for (int x = 0; x < volX; x++)
{
col[x] = x * y * z;
}
stack[y] = col;
}
voxels[z] = stack;
}
Bounds b = new Bounds(Vector3.zero, Vector3.one);
RawDataset abrVolume = RawDatasetAdapter.VoxelsToVolume(voxels, "someData", new Vector3Int(volX, volY, volZ), b);
}
}