9 import java.nio.ByteBuffer;
10 import java.nio.ByteOrder;
11 import java.nio.FloatBuffer;
12 import java.nio.ShortBuffer;
13 import java.util.ArrayList;
14 import java.util.Arrays;
15 import java.util.List;
43 Log.d(
"VisualizationData",
"Allocating GL float buffer:" + size * 4 +
" bytes");
44 ByteBuffer fbb = ByteBuffer.allocateDirect(size * 4);
45 fbb.order(ByteOrder.nativeOrder()).position(0);
46 return fbb.asFloatBuffer();
63 Log.d(
"VisualizationData",
"Allocating GL short buffer:" + size * 2 +
" bytes");
64 ByteBuffer vbb = ByteBuffer.allocateDirect(size * 2);
65 vbb.order(ByteOrder.nativeOrder()).position(0);
66 return vbb.asShortBuffer();
81 private List<VisualFeature> visFeatures;
85 private FloatBuffer floatBuf;
86 private ShortBuffer shortBuf;
99 visFeatures =
new ArrayList<VisualFeature>(1);
110 return visFeatures.size();
118 return visFeatures.get(featureNr);
122 if (res.
getNumParts() != res.getTransforms().size()) {
123 throw new RuntimeException(
"Invalid simulation result, number of parts (" + res.
getNumParts()
124 +
") does not match transformation count (" + res.getTransforms().size()
125 +
"). Forgot to add default transformation?");
137 gData.addDisplacements((DisplacementField) f, res.
getNumParts());
171 * simres.getNumParts()), null));
173 for (
int fieldNr = 0; fieldNr < simres.getLogicFields().size(); fieldNr++) {
176 Log.d(
"VisData",
"Using default colors " + Arrays.toString(cg.getDefaultColor(1))
177 +
" for constant logical field '" + f.descriptor +
"'");
185 "Computing visual features for logical field '" + f.descriptor +
"' of size " + f.getSize());
196 "No solution fields given, using default color data " + Arrays.toString(cg.getDefaultColor(1))
197 +
" for " + gData.getNumVertices() +
" vertices");
abstract int getSize()
Returns the number of graphical elements (nodes/vertices or elements/faces) that this field contains ...
ShortBuffer getShortBuffer()
boolean hasDisplacements()
The displacement field is a logical solution field describing displacements of geometry nodes/vertice...
VisualFeature getVisualizationFeature(int featureNr)
Represents a logical solution field of a simulation.
void useResult(SimulationResult res)
VisualizationData(GeometryData fGeo)
static ShortBuffer createShortBuffer(int size)
Allocates short and float buffers for the rendering process and sets the position to zero...
Represents the results of a simulation.
static final int FLOAT_MAX
The default size for the float buffers.
abstract VisualFeature[] getVisualFeatures(ColorGenerator cg)
Abstract method that returns all available visual features for a logical solution field...
int getNumParts()
The number of parts in each LogicSolutionField.
FieldDescriptor descriptor
static FloatBuffer createFloatBuffer()
Creates the default float buffer of size FLOAT_MAX.
VisualizationData(GeometryData fGeo, FloatBuffer fBuf, ShortBuffer sBuf)
float[] getDefaultColor(int size)
Returns an array with "size" default colors (effectively 4*size RGBT values)
static ShortBuffer createShortBuffer()
Creates the default float buffer of size FLOAT_MAX.
Simple class for feature that can be visualized.
GeometryData getGeometryData()
A container class for all model visual data.
void computeVisualFeatures(ColorGenerator cg)
Checks if the logical solution field is constant or not.
Provides a Log class imitating the Android Log class when not used on android systems.
static FloatBuffer createFloatBuffer(int size)
Allocates short and float buffers for the rendering process and sets the position to zero...
This is a container class for all geometry-related data of a reduced model.
The color generator is used to produce RGBA (RGB+Alpha) values from a given array of floats...
abstract boolean isConstant()
Convenience method to determine if the solution field is constant in value.
List< LogicSolutionField > getLogicFields()
static final int SHORT_MAX
The default size for the short buffers.
FloatBuffer getFloatBuffer()
int getNumVertices()
The number of (original) vertices of the geometry.