Skip to main content

VertexData

Namespace: DISP3DLIB  ·  Library: 3D Display Library

#include <disp3D/brainsurface.h>

struct DISP3DLIB::VertexData

Geometry of one brain surface vertex: position and normal.

src/examples/ex_disp3d_scene/main.cpp
// A 2 x 2 cm flat patch at z = 0 (metres), picked by a ray cast straight down
MatrixX3f patchVertices(4, 3);
patchVertices << 0.0f, 0.0f, 0.0f, 0.02f, 0.0f, 0.0f, 0.02f, 0.02f, 0.0f, 0.0f, 0.02f, 0.0f;
MatrixX3i patchTriangles(2, 3);
patchTriangles << 0, 1, 2, 0, 2, 3;
BrainSurface patch;
patch.createFromData(patchVertices, patchTriangles, Qt::gray);
patch.setHemi(0);
float hitDistance = 0.0f;
int hitVertex = -1;
const bool picked = patch.intersects(QVector3D(0.019f, 0.019f, 0.05f), QVector3D(0.0f, 0.0f, -1.0f), hitDistance, hitVertex);
const VertexData& corner = patch.vertexDataRef().at(2); // interleaved position, normal and packed ABGR colour

Example​

Used in examples​

ex_disp3d_scene​

Disp3D scene data: sensor-to-surface interpolation, electrodes, MRI slices, video overlay and layers.

src/examples/ex_disp3d_scene/main.cpp, line 231
float hitDistance = 0.0f;
int hitVertex = -1;
const bool picked = patch.intersects(QVector3D(0.019f, 0.019f, 0.05f), QVector3D(0.0f, 0.0f, -1.0f), hitDistance, hitVertex);
const VertexData& corner = patch.vertexDataRef().at(2); // interleaved position, normal and packed ABGR colour
ok &= expect(picked && std::abs(hitDistance - 0.05f) < 1e-6f && hitVertex == 2 && corner.pos == QVector3D(0.02f, 0.02f, 0.0f) && std::abs(std::abs(corner.norm.z()) - 1.0f) < 1e-6f,
"BrainSurface: a downward ray hits the patch 5 cm below, nearest vertex 2");

Authors of this file​