ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itk::TrxGroup Class Reference

#include <itkTrxGroup.h>

Detailed Description

Represents a named group of streamlines within a TRX file.

Note
Construction and initialization are performed exclusively by TrxStreamlineData::GetGroup(). Do not construct TrxGroup objects directly.

A TRX file can contain named groups (e.g., "CST_left", "AF_right"), each of which is a subset of the total streamline set. TrxGroup stores the group's name, its streamline indices, any per-group scalar fields (DPG), and GUI display properties (color and visibility).

Typical usage

Groups are obtained through TrxStreamlineData, not constructed directly:

#include "itkTrxStreamlineData.h" // also brings in itkTrxGroup.h
auto reader = itk::TrxFileReader::New();
reader->SetFileName("bundle.trx");
reader->Update();
auto data = reader->GetOutput();
// Enumerate groups
for (const auto & name : data->GetGroupNames())
{
auto group = data->GetGroup(name);
std::cout << name << ": " << group->GetStreamlineIndices().size()
<< " streamlines\n";
}
// Get the streamlines belonging to one group (lazy subset, no copy)
auto group = data->GetGroup("CST_left");
auto subset = group->GetStreamlines(data); // TrxStreamlineData::Pointer
// GUI: toggle visibility (fires Modified(), observers notified)
group->SetVisible(false);
// GUI: change color
itk::TrxGroup::ColorType red = {{ 1.0f, 0.0f, 0.0f }};
group->SetColor(red);
static Pointer New()
FixedArray< float, 3 > ColorType

Color assignment

If the TRX file contains a DPG (data-per-group) field named "color" with at least 3 float values for this group, those values are used as the initial RGB color in [0, 1]. Otherwise a color is auto-assigned from a 10-entry perceptually distinct palette, cycling by group index.

Observer pattern

TrxGroup inherits from itk::Object, so ITK's observer mechanism works:

group->AddObserver(itk::ModifiedEvent(), myCallback);
group->SetVisible(false); // myCallback is invoked

Definition at line 99 of file itkTrxGroup.h.

+ Inheritance diagram for itk::TrxGroup:
+ Collaboration diagram for itk::TrxGroup:

Public Types

using ColorType = FixedArray<float, 3>
 
using ConstPointer = SmartPointer<const Self>
 
using Pointer = SmartPointer<Self>
 
using Self = TrxGroup
 
using Superclass = Object
 
- Public Types inherited from itk::Object
using ConstPointer = SmartPointer<const Self>
 
using Pointer = SmartPointer<Self>
 
using Self = Object
 
using Superclass = LightObject
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer<const Self>
 
using Pointer = SmartPointer<Self>
 
using Self = LightObject
 

Public Member Functions

virtual::itk::LightObject::Pointer CreateAnother () const
 
virtual ColorType GetColor () const
 
std::vector< float > GetDpgField (const std::string &name) const
 
std::vector< std::string > GetDpgFieldNames () const
 
virtual const std::string & GetName () const
 
virtual const char * GetNameOfClass () const
 
virtual const std::vector< uint32_t > & GetStreamlineIndices () const
 
SmartPointer< TrxStreamlineData > GetStreamlines (SmartPointer< const TrxStreamlineData > parent) const
 
virtual bool GetVisible () const
 
bool HasDpgField (const std::string &name) const
 
virtual void SetColor (ColorType _arg)
 
virtual void SetVisible (bool _arg)
 
virtual void VisibleOff ()
 
virtual void VisibleOn ()
 
- Public Member Functions inherited from itk::Object
unsigned long AddObserver (const EventObject &event, Command *cmd) const
 
unsigned long AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const
 
virtual void DebugOff () const
 
virtual void DebugOn () const
 
Command * GetCommand (unsigned long tag)
 
bool GetDebug () const
 
MetaDataDictionary & GetMetaDataDictionary ()
 
const MetaDataDictionary & GetMetaDataDictionary () const
 
virtual ModifiedTimeType GetMTime () const
 
virtual const TimeStamp & GetTimeStamp () const
 
bool HasObserver (const EventObject &event) const
 
void InvokeEvent (const EventObject &)
 
void InvokeEvent (const EventObject &) const
 
virtual void Modified () const
 
void Register () const override
 
void RemoveAllObservers ()
 
void RemoveObserver (unsigned long tag) const
 
void SetDebug (bool debugFlag) const
 
void SetReferenceCount (int) override
 
void UnRegister () const noexcept override
 
void SetMetaDataDictionary (const MetaDataDictionary &rhs)
 
void SetMetaDataDictionary (MetaDataDictionary &&rrhs)
 
virtual void SetObjectName (std::string _arg)
 
virtual const std::string & GetObjectName () const
 
- Public Member Functions inherited from itk::LightObject
Pointer Clone () const
 
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
void Print (std::ostream &os, Indent indent=0) const
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::Object
static bool GetGlobalWarningDisplay ()
 
static void GlobalWarningDisplayOff ()
 
static void GlobalWarningDisplayOn ()
 
static Pointer New ()
 
static void SetGlobalWarningDisplay (bool val)
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

void PrintSelf (std::ostream &os, Indent indent) const override
 
 TrxGroup ()=default
 
 ~TrxGroup () override=default
 
- Protected Member Functions inherited from itk::Object
 Object ()
 
bool PrintObservers (std::ostream &os, Indent indent) const
 
virtual void SetTimeStamp (const TimeStamp &timeStamp)
 
 ~Object () override
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Member Functions

void SetDpgFields (std::map< std::string, std::vector< float > > dpgFields)
 
void SetName (const std::string &name)
 
void SetStreamlineIndices (std::vector< uint32_t > indices)
 

Private Attributes

ColorType m_Color { { 1.0f, 1.0f, 1.0f } }
 
std::map< std::string, std::vector< float > > m_DpgFields
 
std::string m_Name
 
std::vector< uint32_t > m_StreamlineIndices
 
bool m_Visible { true }
 

Friends

class TrxStreamlineData
 

Additional Inherited Members

- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount {}
 

Member Typedef Documentation

◆ ColorType

RGB color in [0, 1].

Definition at line 110 of file itkTrxGroup.h.

◆ ConstPointer

Definition at line 107 of file itkTrxGroup.h.

◆ Pointer

Definition at line 106 of file itkTrxGroup.h.

◆ Self

Definition at line 104 of file itkTrxGroup.h.

◆ Superclass

Definition at line 105 of file itkTrxGroup.h.

Constructor & Destructor Documentation

◆ TrxGroup()

itk::TrxGroup::TrxGroup ( )
protecteddefault

Referenced by GetNameOfClass().

◆ ~TrxGroup()

itk::TrxGroup::~TrxGroup ( )
overrideprotecteddefault

Member Function Documentation

◆ CreateAnother()

virtual::itk::LightObject::Pointer itk::TrxGroup::CreateAnother ( ) const
virtual

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::Object.

◆ GetColor()

virtual ColorType itk::TrxGroup::GetColor ( ) const
virtual

◆ GetDpgField()

std::vector< float > itk::TrxGroup::GetDpgField ( const std::string & name) const

Values of a DPG field, widened to float regardless of on-disk dtype. For a scalar field this is a single-element vector. For a matrix field the values are returned flat in row-major order. Returns empty if the field does not exist.

◆ GetDpgFieldNames()

std::vector< std::string > itk::TrxGroup::GetDpgFieldNames ( ) const

Names of all data-per-group (DPG) fields stored for this group.

◆ GetName()

virtual const std::string & itk::TrxGroup::GetName ( ) const
virtual

Name of this group as stored in the TRX file.

◆ GetNameOfClass()

virtual const char * itk::TrxGroup::GetNameOfClass ( ) const
virtual
See also
LightObject::GetNameOfClass()

Reimplemented from itk::Object.

References TrxGroup().

◆ GetStreamlineIndices()

virtual const std::vector< uint32_t > & itk::TrxGroup::GetStreamlineIndices ( ) const
virtual

Indices into the parent TrxStreamlineData identifying which streamlines belong to this group. Indices are in the range [0, N) where N is the total number of streamlines in the parent object.

◆ GetStreamlines()

SmartPointer< TrxStreamlineData > itk::TrxGroup::GetStreamlines ( SmartPointer< const TrxStreamlineData > parent) const

Return a TrxStreamlineData containing only the streamlines in this group. The subset is created lazily (no position data is copied; the backing TRX handle is remapped). Pass the parent TrxStreamlineData that this group was obtained from.

Callers must #include "itkTrxStreamlineData.h" to use this method.

◆ GetVisible()

virtual bool itk::TrxGroup::GetVisible ( ) const
virtual

◆ HasDpgField()

bool itk::TrxGroup::HasDpgField ( const std::string & name) const

True if a DPG field with the given name exists.

◆ New()

static Pointer itk::TrxGroup::New ( )
static

◆ PrintSelf()

void itk::TrxGroup::PrintSelf ( std::ostream & os,
Indent indent ) const
overrideprotectedvirtual

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from itk::Object.

◆ SetColor()

virtual void itk::TrxGroup::SetColor ( ColorType _arg)
virtual

RGB color in [0, 1] for rendering this group. Initialized from the DPG "color" field if present, otherwise auto-assigned from a palette. Changing fires Modified().

◆ SetDpgFields()

void itk::TrxGroup::SetDpgFields ( std::map< std::string, std::vector< float > > dpgFields)
private

Set DPG field map — called once at construction by TrxStreamlineData.

◆ SetName()

void itk::TrxGroup::SetName ( const std::string & name)
private

Set group name — called once at construction by TrxStreamlineData.

◆ SetStreamlineIndices()

void itk::TrxGroup::SetStreamlineIndices ( std::vector< uint32_t > indices)
private

Set streamline index list — called once at construction by TrxStreamlineData.

◆ SetVisible()

virtual void itk::TrxGroup::SetVisible ( bool _arg)
virtual

Whether this group should be rendered. Changing fires Modified().

◆ VisibleOff()

virtual void itk::TrxGroup::VisibleOff ( )
virtual

◆ VisibleOn()

virtual void itk::TrxGroup::VisibleOn ( )
virtual

Friends And Related Symbol Documentation

◆ TrxStreamlineData

friend class TrxStreamlineData
friend

Definition at line 190 of file itkTrxGroup.h.

References TrxStreamlineData.

Referenced by TrxStreamlineData.

Member Data Documentation

◆ m_Color

ColorType itk::TrxGroup::m_Color { { 1.0f, 1.0f, 1.0f } }
private

Definition at line 207 of file itkTrxGroup.h.

◆ m_DpgFields

std::map<std::string, std::vector<float> > itk::TrxGroup::m_DpgFields
private

Definition at line 206 of file itkTrxGroup.h.

◆ m_Name

std::string itk::TrxGroup::m_Name
private

Definition at line 204 of file itkTrxGroup.h.

◆ m_StreamlineIndices

std::vector<uint32_t> itk::TrxGroup::m_StreamlineIndices
private

Definition at line 205 of file itkTrxGroup.h.

◆ m_Visible

bool itk::TrxGroup::m_Visible { true }
private

Definition at line 208 of file itkTrxGroup.h.


The documentation for this class was generated from the following file: