Implement an alternative way of structuring nodes.
This commit is contained in:
@@ -20,7 +20,8 @@ static inline void computeColor(float intensity, float limit, float* destination
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatLayerVisualisation::FlatLayerVisualisation(const fmri::LayerData &layer) :
|
FlatLayerVisualisation::FlatLayerVisualisation(const LayerData &layer, Ordering ordering) :
|
||||||
|
ordering(ordering),
|
||||||
faceCount(layer.numEntries() * 4),
|
faceCount(layer.numEntries() * 4),
|
||||||
vertexBuffer(new float[faceCount * 3]),
|
vertexBuffer(new float[faceCount * 3]),
|
||||||
colorBuffer(new float[faceCount * 3]),
|
colorBuffer(new float[faceCount * 3]),
|
||||||
@@ -80,18 +81,36 @@ void FlatLayerVisualisation::render()
|
|||||||
void FlatLayerVisualisation::setVertexPositions(int vertexNo, float *destination)
|
void FlatLayerVisualisation::setVertexPositions(int vertexNo, float *destination)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
const float zOffset = -2 * vertexNo;
|
float zOffset;
|
||||||
|
float yOffset;
|
||||||
|
|
||||||
|
switch (ordering) {
|
||||||
|
case Ordering::LINE:
|
||||||
|
zOffset = -2 * vertexNo;
|
||||||
|
yOffset = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ordering ::SQUARE:
|
||||||
|
const auto nodes = faceCount / 4;
|
||||||
|
auto columns = static_cast<int>(ceil(sqrt(nodes)));
|
||||||
|
while (nodes % columns) ++columns;
|
||||||
|
|
||||||
|
zOffset = -2 * (vertexNo % columns);
|
||||||
|
yOffset = 2 * (vertexNo / columns);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the 4 vertices for the pyramid
|
// Create the 4 vertices for the pyramid
|
||||||
destination[j++] = -0.5f;
|
destination[j++] = -0.5f;
|
||||||
destination[j++] = 0;
|
destination[j++] = 0 + yOffset;
|
||||||
destination[j++] = 0.5f + zOffset;
|
destination[j++] = 0.5f + zOffset;
|
||||||
destination[j++] = 0;
|
destination[j++] = 0;
|
||||||
destination[j++] = 0;
|
destination[j++] = 0 + yOffset;
|
||||||
destination[j++] = -0.5f + zOffset;
|
destination[j++] = -0.5f + zOffset;
|
||||||
destination[j++] = 0;
|
destination[j++] = 0;
|
||||||
destination[j++] = 1;
|
destination[j++] = 1 + yOffset;
|
||||||
destination[j++] = 0 + zOffset;
|
destination[j++] = 0 + zOffset;
|
||||||
destination[j++] = 0.5;
|
destination[j++] = 0.5;
|
||||||
destination[j++] = 0;
|
destination[j++] = 0 + yOffset;
|
||||||
destination[j++] = 0.5 + zOffset;
|
destination[j++] = 0.5 + zOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,17 @@ namespace fmri
|
|||||||
class FlatLayerVisualisation : public LayerVisualisation
|
class FlatLayerVisualisation : public LayerVisualisation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FlatLayerVisualisation(const LayerData& layer);
|
enum class Ordering {
|
||||||
|
LINE,
|
||||||
|
SQUARE,
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit FlatLayerVisualisation(const LayerData &layer, Ordering ordering);
|
||||||
|
|
||||||
void render() override;
|
void render() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Ordering ordering;
|
||||||
std::size_t faceCount;
|
std::size_t faceCount;
|
||||||
std::unique_ptr<float[]> vertexBuffer;
|
std::unique_ptr<float[]> vertexBuffer;
|
||||||
std::unique_ptr<float[]> colorBuffer;
|
std::unique_ptr<float[]> colorBuffer;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ static void updateVisualisers()
|
|||||||
LayerVisualisation* visualisation = nullptr;
|
LayerVisualisation* visualisation = nullptr;
|
||||||
switch (layer.shape().size()) {
|
switch (layer.shape().size()) {
|
||||||
case 2:
|
case 2:
|
||||||
visualisation = new FlatLayerVisualisation(layer);
|
visualisation = new FlatLayerVisualisation(layer, FlatLayerVisualisation::Ordering::SQUARE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
|
|||||||
Reference in New Issue
Block a user