FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
Fiber::Representation Class Reference

A Representation is a set of Field objects, each of them accessed via some FieldID identifier. More...

#include <Representation.hpp>

Inheritance diagram for Fiber::Representation:
Fiber::FiberMap< RefPtr< FieldID > > MemCore::Intercube Fiber::FragmentIDCollectionProvider Fiber::BaseSpaceDependency MemCore::Ageable Fiber::Ownable< BaseSpaceDependency > Fiber::OwnerBase

Public Types

typedef FiberMap< RefPtr< FieldID > > Base_t
 
using const_iterator_t = std::function< bool(const FieldID &, const Field &)>
 
using iterator_t = std::function< bool(const FieldID &, Field &)>
 Note that an iterator_t can be implicitly cast into an const_iterator_t, thus functions taking an iterator_t must be named differently to avoid ambiguity.
 
typedef FieldIterator Iterator
 
using iterate_all_t = std::function< bool(const FieldID &d, Field &F, const RefPtr< CreativeArrayBase > &CAB, const RefPtr< FragmentID > &fid)>
 
- Public Types inherited from Fiber::OwnerBase
template<class ItemType >
using Item = MemCore::InterfaceData< ItemType >
 An optional convenience class that allows to easily add arbitrary types to Intercubes .
 

Public Member Functions

 Representation (const Representation &)=delete
 Prevent accidental copy construction.
 
void operator= (const Representation &)=delete
 Prevent accidental copy assignment.
 
void extremeUnction () override
 
RefPtr< FieldIDmakeFieldID (const string &name)
 Create a new FieldID from a given textual description if it does not exist yet.
 
RefPtr< FieldIDfindFieldID (const string &name) const
 Get a field ID, returning Null when none exists yet.
 
bool removeField (const string &name)
 
bool removeField (const RefPtr< FieldID > &FID)
 
RefPtr< FieldIDrenameField (const string &OldName, const string &NewName)
 
RefPtr< FieldIDinsertSharedFieldID (const Representation &R, const string &name)
 Retrieve an existing field ID if existent, otherwise insert a field ID that is shared with another Representation.
 
RefPtr< FieldIDcreateSharedFieldID (Representation &Carrier, const string &name)
 Use field identifier which resides on the given Carrier Representation.
 
RefPtr< Field > & getField (const RefPtr< FieldID > &f)
 Given a certain FieldID, retrieve the according field.
 
const RefPtr< Field > & findField (const RefPtr< FieldID > &f) const
 Search and find a Field from its ID.
 
const RefPtr< Field > & findField (const FieldID &f) const
 Search and find a Field from its ID.
 
bool checkIfFieldSizeIsIncompatible (const RefPtr< Field > &FieldPtr)
 Check if a given Field is incompatible with the index space of this representations, i.e.
 
FieldProxy makeField (const WeakPtr< FieldID > &rf, const RefPtr< FragmentIDCollection > &ExistingFragmentIDCollection=NullPtr(), const RefPtr< MemBase > &theFragmentTopology=MemCore::NullPtr())
 
FieldmakeField (const FieldID &f)
 
void own (Field &) const
 Set ownership information on the given Field.
 
Fieldoperator[] (const FieldID &f)
 Return a Field for the given ID.
 
FieldProxy operator[] (const RefPtr< FieldID > &f)
 Return reference to the internally stored Field pointer, which may be overwritten by the caller.
 
FieldProxy operator[] (const string &name)
 Make a field reference from a string, field ID is created if not yet existent.
 
const RefPtr< Field > & findField (const string &name) const
 Retrieve a field by its name; usually fields should be retrieved via their field identifier instead, using the () operator.
 
const RefPtr< Field > & findField (const char *name) const
 
template<class FieldNameContainer >
const RefPtr< Field > & findField (const FieldNameContainer &FieldNames) const
 
const RefPtr< Field > & operator() (const string &name) const
 Operator interface to the findField function.
 
const RefPtr< Field > & operator() (const char *name) const
 
const RefPtr< Field > & operator() (const FieldID &fid) const
 
const RefPtr< Field > & operator() (const RefPtr< FieldID > &f) const
 Look for a field, given its field identifier.
 
template<class FieldNameContainer >
const RefPtr< Field > & operator() (const FieldNameContainer &FieldNames) const
 
RefPtr< CreativeArrayBaseoperator() (const string &name, const RefPtr< FragmentID > &f)
 Shortcut function: Checks if a field exist, and if so, retrieves the data that are associated with a certain field fragment ID.
 
RefPtr< CreativeArrayBaseoperator() (const string &name, const string &FragmentName)
 
const RefPtr< Field > & Positions () const
 Get the positions component of this Representation object.
 
const RefPtr< Field > & getPositions () const
 Get the positions component of this Representation object.
 
RefPtr< SizeInterfacegetSize () const
 The size of this representation, which is the sum of all fragments of the Positions field.
 
RefPtr< SizeInterfacegetFragmentSize (const RefPtr< FragmentID > &Fid) const
 Shortcut function: Get the size of field's fragment, if possible.
 
bool setField (const string &Fieldname, const RefPtr< Field > &P)
 Add a field under the given name.
 
bool setPositions (const RefPtr< Field > &P)
 Set the positional component of this Representation object.
 
template<class Data , Dims_t Dims>
bool setPositions (const Data &D, const MultiIndex< Dims > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set unfragmented positions directly from some data set, e.g.
 
template<class T , Dims_t N>
bool setPositions (const MemCore::WeakPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set unfragmented positions directly from some MemArray.
 
bool setPositions (const MemCore::RefPtr< MemBase > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set unfragmented positions directly from some MemBase.
 
bool setPositions (const MemCore::RefPtr< CreativeArrayBase > &CrecRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set unfragmented positions directly from some CreativeArrayBase.
 
template<class Data , Dims_t Dims>
bool setField (const string &Fieldname, const Data &D, const MultiIndex< Dims > &Size, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set an unfragmented field direcly from some data that can be used for constucting a Field.
 
template<class T , Dims_t N>
bool setField (const string &Fieldname, const MemCore::WeakPtr< MemArray< N, T > > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set an unfragmented field direcly from a MemArray.
 
bool setField (const string &Fieldname, const MemCore::RefPtr< MemBase > &MemRefPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set an unfragmented field direcly from a MemBase.
 
bool setField (const string &Fieldname, const MemCore::RefPtr< CreativeArrayBase > &CrecPtr, const RefPtr< FragmentIDCollection > &theFragmentIDCollection=nullptr)
 Convenience function to set an unfragmented field direcly from a CreativeArrayBase.
 
int iterate (FieldIterator &FI) const
 Iterate over all fields in this Representation.
 
int iterate_fields (const iterator_t &F) const
 iterate over all fields contained in this Representation
 
int iterate_const_fields (const const_iterator_t &F) const
 Functor iterator with constant field.
 
int iterate (const iterator_t &F) const
 Functor iterator.
 
int iterate_m (const iterator_t &F) const
 Functor iterator with non-constant, modifyable field.
 
int iterate_all (const iterate_all_t &f) const
 
int iterate (const iterate_all_t &f) const
 
template<class Functor >
int Iterate_all (const Functor &F) const
 
Dims_t Dims () const
 Determine the dimensionality of the data that live here.
 
 DEPRECATED ("Use Dims() or getSize() instead", Dims_t rank() const)
 
RefPtr< FragmentIDCollectiongetFragmentIDCollection () const override
 
memsize_t getMemoryUsage (memsize_t &UsedMemory, memsize_t &WantedMemory) const
 Get memory usage.
 
void Speak (int indent=0, int maxindent=-1) const
 Informative debug message.
 
string xml () const
 Analyse this representation's content in XML format.
 
void createLinkedFields (const Representation &linked_from)
 Creates links to the fields of a different representation in the current representation.
 
- Public Member Functions inherited from Fiber::FiberMap< RefPtr< FieldID > >
RefPtr< FragmentIDCollectiongetFragmentIDCollection () const
 Return the associated fragment ID collection of the first field that has one.
 
 FiberMap ()
 Default constructor.
 
size_t getNumberOfFields () const
 Get the number of fields contained here.
 
Fieldoperator[] (const RefPtr< FieldID > &id)
 Access field by name, create one, in case.
 
void mkFieldID (const RefPtr< FieldID > &id)
 
void insertField (const RefPtr< FieldID > &id, const RefPtr< Field > &F)
 
const RefPtr< Field > & find (const RefPtr< FieldID > &id) const
 Find an entry.
 
RefPtr< CreativeArrayBasefind (const RefPtr< FieldID > &id, const RefPtr< FragmentID > &f) const
 
RefPtr< CreativeArrayBasefind (const RefPtr< FieldID > &id, const string &FragmentName) const
 
const RefPtr< Field > & operator() (const RefPtr< FieldID > &id) const
 Find an entry, operator interface to the find() member function for convenience.
 
void iterate (const std::function< bool(const RefPtr< FieldID > &, const RefPtr< Field > &)> &F) const
 
bool remove (const RefPtr< FieldID > &id)
 Remove an Field.
 
void getMinMaxAge (Ageable &Youngest, Ageable &Oldest) const
 Get the youngest/oldest age of all fields contained here, including the fiber space itself taking into account when fields have last been inserted or removed here.
 
RefPtr< FieldfindMostFragmentedField () const
 Find the Field with the most fragments.
 
int getMemoryUsage (memsize_t &UsedMemory, memsize_t &WantedMemory) const
 Memory usage.
 
int providesFieldType (const Fiber::TypeList_t &AcceptedFields) const
 Check how many fields exist here that conform to the given type.
 
string xml () const
 
void clear_fields ()
 
const RefPtr< Field > & getFirstField () const
 
- Public Member Functions inherited from Fiber::BaseSpaceDependency
 BaseSpaceDependency ()
 Constructor.
 
virtual ~BaseSpaceDependency ()
 Destructor.
 
- Public Member Functions inherited from Fiber::Ownable< BaseSpaceDependency >
void x_updateOwnershipAge (const MemCore::Ageable &theNewAge) override
 Forward some age to all Owners.
 
void insertOwner (const Container &theOwner)
 Add some owner.
 
bool insertOwner (const MemCore::WeakPtr< Container > &theOwner)
 Add some owner.
 
void addOwner (const Container &theOwner, const MemCore::Ageable &theNewAge)
 Add some owner and broadcast a new age to all Ownerrs.
 
void addOwner (const MemCore::WeakPtr< Container > &theOwner, const MemCore::Ageable &theNewAge)
 Add some owner and broadcast a new age to all Ownerrs.
 
 Ownable ()
 Default constructor, empty Ownership list.
 
 Ownable (const Ownable &)
 Copy constructor, does NOT copy any ownership information, the new Ownable will be unowned.
 
 Ownable (const MemCore::WeakPtr< Container > &theOwner, const MemCore::Ageable &theNewAge)
 Construct an Ownable with an initial owner.
 
 Ownable (const Container &theOwner, const MemCore::Ageable &theNewAge)
 Construct an Ownable with an initial owner.
 
Ownableoperator= (const Ownable &)
 Assignment, does NOT copy any ownership information, the assigned Ownable will retain all its ownership information.
 
MemCore::WeakPtr< Container > getPrimaryOwner () const
 Get the first valid owner.
 
size_t getNumberOfValidOwners () const
 Get the first valid owner.
 
bool processOwnership (MemCore::Intercube &Output, const MemCore::Intercube &Input) const override
 Process some ownership action.
 
- Public Member Functions inherited from Fiber::OwnerBase
bool processOwnership (MemCore::Intercube &OutputAndInput) const
 Process ownership where the input information is shared with the output information in the same Intercube.
 
- Public Member Functions inherited from MemCore::Ageable
constexpr Ageable (age_t t) noexcept
 
constexpr Ageable (const Ageable &A) noexcept
 
 Ageable (const volatile Ageable &A) noexcept
 
constexpr const AgeablegetAge () const
 
bool isNewerThan (const Ageable &a) const noexcept
 
bool isOlderThan (const Ageable &a) const noexcept
 
bool isYoungerThan (const Ageable &a) const noexcept
 
bool operator!= (const Ageable &a) const noexcept
 
bool operator< (const Ageable &a) const noexcept
 
bool operator<= (const Ageable &a) const noexcept
 
bool operator<= (const volatile Ageable &a) const volatile noexcept
 
bool operator== (const Ageable &a) const noexcept
 
bool operator> (const Ageable &a) const noexcept
 
bool operator> (const volatile Ageable &a) const volatile
 
bool operator>= (const Ageable &a) const noexcept
 
bool operator>= (const volatile Ageable &a) const volatile noexcept
 
constexpr void resetAge () noexcept
 
void setInfinitelyNew () noexcept
 
age_t time_value () const noexcept
 
age_t time_value () const volatile noexcept
 
Ageabletouch () noexcept
 
age_t update (age_t age) noexcept
 
age_t update (const Ageable &Other) noexcept
 
age_t update (const volatile Ageable &Other) volatile noexcept
 
- Public Member Functions inherited from MemCore::Intercube
void addInterface (const RefPtr< InterfaceBase > &I) const
 
void addInterfaceData (const Data &D)
 
void addInterfaceData (const Data &D)
 
void clearInterfaces ()
 
bool const_iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP) const
 
virtual RefPtr< InterfaceBasecreateInterface (const type_info &) const
 
RefPtr< InterfaceBasefindInterface (const type_info &t) const
 
RefPtr< InterfaceBasegetInterface (const type_info &t)
 
std::string getInterfaceNames (const char delim=';') const
 
bool gotNewInterfaceData (const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D)
 
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector &S)
 
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector *S)
 
bool hasChangedInterfaceData (const Data &D) const
 
bool hasChangedInterfaceData (const Data &D) const
 
bool hasChangedInterfaceData (const Data &D, const Selector &) const
 
bool hasChangedInterfaceData (const Data &D, const Selector *) const
 
bool hasInterface (const type_info &t) const
 
bool iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP)
 
void printInterfaces () const
 
void registerInterface (const type_info &t)
 
void removeInterface ()
 
void removeInterfaceBase (const type_info &InterfaceBaseID)
 

Public Attributes

unsigned long RenameOperations = 0
 
unsigned long RemovalOperations = 0
 
- Public Attributes inherited from Fiber::Ownable< BaseSpaceDependency >
std::unordered_set< MemCore::WeakPtr< Container > > Owners
 The (internal) list of owners.
 

Static Public Attributes

static constexpr unsigned long MaxOperations = -22U
 

Friends

struct FieldProxy
 

Additional Inherited Members

- Static Public Member Functions inherited from MemCore::Ageable
static const AgeableInfinitelyNew () noexcept
 
static constexpr const AgeableInfinitelyOld () noexcept
 
static age_t now () noexcept
 
- Protected Member Functions inherited from Fiber::FiberMap< RefPtr< FieldID > >
RefPtr< Field > & create_entry (const RefPtr< FieldID > &id)
 Get a modifyable field entry.
 
Fields_t copy_Fields_map () const
 

Detailed Description

A Representation is a set of Field objects, each of them accessed via some FieldID identifier.

The class describes the representation of a Skeleton in a coordinate system or relative to another Skeleton. Examples are the coordinate system representation (positions, fields) of a Grid object's geometrical representation, or the representation of the triangles of a triangular surface by its vertices or edges.

Use Representation::iterate(FieldIterator&) to find all fields.

The Representation is an Intercube and can carry arbitrary interfaces. There is no specific reason why the FiberMap should not be an Intercube either.

Examples
ModifyingPointCloudRange.cpp, Sphere.cpp, XF_LineSetFragmented.cpp, XF_LineSetHierarchical.cpp, XF_LineSetHierarchicalRegularized.cpp, trimesh.cpp, and uniform_scalar.cpp.

Member Function Documentation

◆ checkIfFieldSizeIsIncompatible()

bool Fiber::Representation::checkIfFieldSizeIsIncompatible ( const RefPtr< Field > &  FieldPtr)

Check if a given Field is incompatible with the index space of this representations, i.e.

whether the dimensions match. If for various reasons this cannot be determined, the function will return false, indicating that the field may be compatible, we just don't know yet.

References getPositions().

◆ createLinkedFields()

void Fiber::Representation::createLinkedFields ( const Representation linked_from)

Creates links to the fields of a different representation in the current representation.

The current representation will contain then all the data fields of the 'linked from' representation.

Author
: marcel

References apply().

◆ createSharedFieldID()

RefPtr< FieldID > Fiber::Representation::createSharedFieldID ( Representation Carrier,
const string &  name 
)

Use field identifier which resides on the given Carrier Representation.

If none exists there yet, create one. If a field identifier already existed for the current Representation, then this one is used, and the Carrier is not touched at all.

Parameters
CarrierThe Representation which hosts the field identifier, and field identifiers are shared with this one.
nameThe string that makes up a field identifier.

References findFieldID().

Referenced by Fiber::PartialDerivative().

◆ Dims()

Dims_t Fiber::Representation::Dims ( ) const

Determine the dimensionality of the data that live here.

Returns
If no fields are defined on this representation, a negative value is returned, i.e. the dimensionality is yet unspecified.

References getPositions().

◆ findFieldID()

RefPtr< FieldID > Fiber::Representation::findFieldID ( const string &  name) const

Get a field ID, returning Null when none exists yet.

The get function creates an entry in any case. Ensure the string is valid. Use the operator() to query if a certain field ID exists for a string.

Referenced by createSharedFieldID(), insertSharedFieldID(), and makeFieldID().

◆ getFragmentIDCollection()

RefPtr< FragmentIDCollection > Fiber::Representation::getFragmentIDCollection ( ) const
overridevirtual

◆ getSize()

RefPtr< SizeInterface > Fiber::Representation::getSize ( ) const

The size of this representation, which is the sum of all fragments of the Positions field.

Returns
A NullPtr() will be returned if the size cannot be determined, e.g. due to inconsistent rank of fragments, or no fragments existing here at all.
Todo:
Consider the case of unfragmented Positions with fragmented fields.

References getPositions().

◆ insertSharedFieldID()

RefPtr< FieldID > Fiber::Representation::insertSharedFieldID ( const Representation R,
const string &  name 
)

Retrieve an existing field ID if existent, otherwise insert a field ID that is shared with another Representation.

If that Representation doesn't contain an according field ID for the given name, no FieldID is created here either.

References findFieldID().

◆ iterate()

int Fiber::Representation::iterate ( FieldIterator FI) const

Iterate over all fields in this Representation.

{
bool apply(const FieldID&d, const Field&R) override
{
printf("Found field [%s]\n", d.Name().c_str() );
return true;
}
} MyFieldIteratorObject;
R.iterate( MyFieldIteratorObject );
_Expr< _ValFunClos< _ValArray, _Tp >, _Tp > apply(_Tp __func(_Tp)) const
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Identifier for Fields within a Grid.
Definition FieldID.hpp:53
const string & Name() const
Get the textual description.
Definition FieldID.hpp:86
Class for iterating over fields, in particular those contained in a Representation object.
Definition FieldID.hpp:134
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
int iterate(FieldIterator &FI) const
Iterate over all fields in this Representation.
Definition Representation.cpp:548

References Fiber::FieldIterator::apply().

Referenced by Fiber::ExecuteExpression(), and Fiber::operator<<=().

◆ iterate_all()

int Fiber::Representation::iterate_all ( const iterate_all_t &  f) const
inline
       Iterate over all fields and all fragments contained in this Representation.
R.iterate_all( [](const FieldID&d, Field&F, const RefPtr<CreativeArrayBase>&CAB, const RefPtr<FragmentID>&fid)
{
}
);
See also
iterate_fields()
Note
The Field argument is recommended to be const as in:
R.iterate_all( [](const FieldID&d, const Field&F, const RefPtr<CreativeArrayBase>&CAB, const RefPtr<FragmentID>&fid)
{
}
);
This function can be implicitly converted.

Referenced by Fiber::RepresentationMap::iterate_all().

◆ makeFieldID()

RefPtr< FieldID > Fiber::Representation::makeFieldID ( const string &  name)

Create a new FieldID from a given textual description if it does not exist yet.

Operating on FieldID's instead of just strings is beneficial to store additional information on fields, such as dependency relationships (e.g. one field is derived from another field).

Parameters
nameThe field name.

Empty strings are not supported, field names must be of at least one character length.

References findFieldID().

Referenced by setField().

◆ operator()()

const RefPtr< Field > & Fiber::Representation::operator() ( const string &  name) const
inline

Operator interface to the findField function.

Return a field from a textual description, if a field identifier with a compatible name exists on this Representation.

See also
FieldID, operator[](const string&name)
Parameters
nameThe name component of a field identifier.

◆ operator[]()

Field & Fiber::Representation::operator[] ( const FieldID f)
inline

Return a Field for the given ID.

If a new field shall be created for the given ID, then use the alternative [] operator function that takes a RefPtr<FieldID> as argument.

◆ setPositions() [1/2]

template<class Data , Dims_t Dims>
bool Fiber::Representation::setPositions ( const Data D,
const MultiIndex< Dims > &  Size,
const RefPtr< FragmentIDCollection > &  theFragmentIDCollection = nullptr 
)
inline

Convenience function to set unfragmented positions directly from some data set, e.g.

from a MemVector<Eagle::point3> .

◆ setPositions() [2/2]

bool Fiber::Representation::setPositions ( const RefPtr< Field > &  P)

Set the positional component of this Representation object.

An eventually existing component is overwritten. Semantically, this function is equivalent with creating a field named FIBER_POSITIONS:

R[ *R[FIBER_POSITIONS] ]
See also
RefPtr<Field>&operator[](const RefPtr<FieldID>&f), FieldID&operator[](const string&name)
Examples
XF_LineSetFragmented.cpp, XF_LineSetHierarchical.cpp, XF_LineSetHierarchicalRegularized.cpp, and trimesh.cpp.

References setField().