Skip to main content

DipoleObject

Namespace: DISP3DLIB  ·  Library: 3D Display Library

#include <disp3D/dipoleobject.h>

class DISP3DLIB::DipoleObject

Renderable dipole object that builds instanced arrow geometry from an InvEcdSet and provides its CPU streams for instanced rendering.

Renderable dipole arrow set with instanced GPU rendering.

src/examples/ex_disp3d_scene/main.cpp
InvEcdSet dipoles;
InvEcd strong;
strong.rd = Vector3f(0.0f, 0.0f, 0.05f);
strong.Q = Vector3f(0.0f, 0.0f, 20e-9f);
InvEcd weak;
weak.rd = Vector3f(0.03f, 0.0f, 0.05f);
weak.Q = Vector3f(10e-9f, 0.0f, 0.0f);
dipoles.addEcd(strong);
dipoles.addEcd(weak);
DipoleObject dipoleGlyphs;
dipoleGlyphs.load(dipoles); // one cone per dipole, scaled by moment
float dipoleDistance = 0.0f;
const int pickedDipole = dipoleGlyphs.intersect(QVector3D(0.03f, 0.0f, 0.2f), QVector3D(0.0f, 0.0f, -1.0f), dipoleDistance);

Public Methods​

DipoleObject()​


~DipoleObject()​


load(ecdSet)​


applyTransform(trans)​


streams()​

Returns:

  • InstancedStreams — CPU streams of the arrow shape and of one instance per dipole.

renderKey()​

Returns:

  • const RenderKey & — Identity of this object in the renderer's GPU cache.

indexCount()​


instanceCount()​


isVisible()​


setVisible(visible)​


boundingBox(min, max)​

Axis-aligned bounds of the (transformed) dipole positions.

Parameters:

  • min : QVector3D & Minimum corner.

  • max : QVector3D & Maximum corner.

Returns:

  • bool — False if no dipoles are loaded.

setSelected(index, selected)​


intersect(rayOrigin, rayDir, dist)​

Test ray intersection with dipoles.

Parameters:

  • rayOrigin : const QVector3D & Ray origin in world space.

  • rayDir : const QVector3D & Ray direction (normalized).

  • dist : float & Distance to intersection.

Returns:

  • int — Index of intersected dipole, or -1 if none.

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 261
weak.Q = Vector3f(10e-9f, 0.0f, 0.0f);
dipoles.addEcd(strong);
dipoles.addEcd(weak);
DipoleObject dipoleGlyphs;
dipoleGlyphs.load(dipoles); // one cone per dipole, scaled by moment
float dipoleDistance = 0.0f;
const int pickedDipole = dipoleGlyphs.intersect(QVector3D(0.03f, 0.0f, 0.2f), QVector3D(0.0f, 0.0f, -1.0f), dipoleDistance);
ok &= expect(dipoleGlyphs.instanceCount() == 2 && pickedDipole == 1 && dipoleDistance > 0.13f && dipoleDistance < 0.15f,
QString("DipoleObject: a ray through the second dipole picks index %1 at %2 m").arg(pickedDipole).arg(dipoleDistance));

Authors of this file​