FiberVISH  0.2
Fish-TheFiberBundleAPIfortheVishVisualizationShell
Public Types | Public Member Functions | 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::BaseSpaceDependency MemCore::Ageable Fiber::Ownable< BaseSpaceDependency > Fiber::OwnerBase

Public Types

typedef FiberMap< RefPtr
< FieldID > > 
Base_t
 
typedef FieldIterator Iterator
 

Public Member Functions

void extremeUnction () override
 
RefPtr< FieldIDmakeFieldID (const string &name)
 Create a new FieldID from a given textual description if it does not exist yet. More...
 
RefPtr< FieldIDfindFieldID (const string &name) const
 Get a field ID, returning Null when none exists yet. More...
 
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. More...
 
RefPtr< FieldIDcreateSharedFieldID (Representation &Carrier, const string &name)
 Use field identifier which resides on the given Carrier Representation. More...
 
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.
 
bool checkIfFieldSizeIsIncompatible (const RefPtr< Field > &FieldPtr)
 Check if a given Field is incompatible with the index space of this representations, i.e. More...
 
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. More...
 
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. More...
 
const RefPtr< Field > & operator() (const char *name) 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.
 
const RefPtr< Field > & getFirstField () const
 
RefPtr< SizeInterfacegetSize () const
 The size of this representation, which is the sum of all fragments of the Positions field. More...
 
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. More...
 
template<class Data , int 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. More...
 
template<class T , int 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 , int 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 , int 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. More...
 
int iterate (const std::function< bool(const FieldID &, const Field &)> &F) const
 
template<class Functor >
int iterate_fields (const Functor &F) const
 Iterate over all fields in this Representation. More...
 
template<class Functor >
int iterate_all (const Functor &F) const
 
int Dims () const
 Determine the dimensionality of the data that live here. More...
 
 DEPRECATED ("Use Dims() or getSize() instead", int rank() const)
 
RefPtr< FragmentIDCollectiongetFragmentIDCollection () const
 
int 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. More...
 
- 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. More...
 
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.
 
bool remove (const RefPtr< FieldID > &id)
 Remove an Field. More...
 
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. More...
 
string xml () const
 
- Public Member Functions inherited from Fiber::BaseSpaceDependency
 BaseSpaceDependency ()
 Constructor.
 
virtual ~BaseSpaceDependency ()
 Destructor.
 
- Public Member Functions inherited from Fiber::Ownable< BaseSpaceDependency >
void 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.
 

Friends

struct FieldProxy
 

Additional Inherited Members

- Public Attributes inherited from Fiber::Ownable< BaseSpaceDependency >
std::unordered_set
< MemCore::WeakPtr< Container > > 
Owners
 The (internal) list of owners. More...
 
- Protected Types inherited from Fiber::FiberMap< RefPtr< FieldID > >
typedef map< RefPtr< FieldID >
, RefPtr< Field > > 
Fields_t
 
- Protected Member Functions inherited from Fiber::FiberMap< RefPtr< FieldID > >
RefPtr< Field > & create_entry (const RefPtr< FieldID > &id)
 Get a modifyable field entry. More...
 
- Protected Attributes inherited from Fiber::FiberMap< RefPtr< FieldID > >
Fields_t Fields
 

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:
Sphere.cpp, trimesh.cpp, uniform_scalar.cpp, XF_LineSetFragmented.cpp, XF_LineSetHierarchical.cpp, XF_LineSetHierarchicalRegularized.cpp, and XF_SimpleFileBinding.cpp.

Member Function Documentation

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().

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 iterate().

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(), and makeFieldID().

Referenced by Fiber::EvalFieldOnRepresentation(), Wizt::BinaryFieldOperatorObject< TheBinaryOperator, NamingOperator, PrimaryValueType, SecondaryValueType, ResultValueType >::FieldOperation(), Wizt::UnaryFieldOperatorObject< TheUnaryOperator, ResultType >::FieldOperation(), Wizt::FieldFunctor< Operation, GridInspectorType >::FieldOperation(), and Fiber::PartialDerivative().

int 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.
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().

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().

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().

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

Iterate over all fields in this Representation.

Representation&R;
struct : FieldIterator
{
bool apply(const FieldID&d, const Field&R) override
{
printf("Found field [%s]\n", d.Name().c_str() );
return true;
}
} MyFieldIteratorObject;
R.iterate( MyFieldIteratorObject );

References Fiber::FieldIterator::apply().

Referenced by createLinkedFields(), and Fiber::ExecuteExpression().

template<class Functor >
int Fiber::Representation::iterate_all ( const Functor F) const
inline
R.iterate_all( [](const FieldID&d, const Field&F, const RefPtr<CreativeArrayBase>&CAB, const RefPtr<FragmentID>&fid)
{
}
);
See also
iterate_fields()

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

template<class Functor >
int Fiber::Representation::iterate_fields ( const Functor F) const
inline

Iterate over all fields in this Representation.

Representation&R;
struct : FieldIterator
{
bool apply(const FieldID&d, const Field&R) override
{
printf("Found field [%s]\n", d.Name().c_str() );
return true;
}
} MyFieldIteratorObject;
R.iterate( MyFieldIteratorObject );

Referenced by Fiber::operator<<=(), Fiber::pullFragments(), and Wizt::FieldObject::update().

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 createSharedFieldID(), Fiber::FieldSelector::makeFieldID(), and setField().

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.
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.

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:

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

References setField().

Referenced by Fiber::TriangularSurface::addVerticesAndConnectivity(), Fiber::FragmentedUniformGrid3DPoints::create(), Fiber::FragmentedUniformGrid3D::createInternal(), Fiber::LineSet::LineSet(), Fiber::LoadImageSequence(), GridLoader::LoadSkeletonTopology(), and Fiber::SplitMeshEdges().

template<class Data , int 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> .