Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Functions
030-SimpleFileBinding.cpp File Reference

[← Previous Example] [Next Example → 031-RangedPointCloud.cpp ]. More...

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <fiber/bundle/Ownership.hpp>

Functions

int main ()
 File Binding, a way to do Structured Memory Mapping for out-of-core data.
 

Detailed Description

[← Previous Example] [Next Example → 031-RangedPointCloud.cpp ].

In FiberLib Tutorial

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <eagle/PhysicalSpace.hpp>
//
// Note that via Ownership functions we can retrieve the Bundle object that
// is associated with some sub-object. In general thus functionality should
// be avoided because a sub-object can be referenced via multiple containers,
// but the "primary" container is available for special cases. This example
// also serves as purpose to check the getPrimaryBundle() function.
//
#include <fiber/bundle/Ownership.hpp>
//
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
/**@brief File Binding, a way to do Structured Memory Mapping for out-of-core data
Demonstrating how to bind a Bundle to a file, then
adding data to it later on. In contrast, when saving
a Bundle to a file then data are added first and saved
in the end. The workflow with the binding feature is
just other way round - bind first, then add data.
The actual dataset is a set of points with a scalar field on them.
*/
int main()
{
// Initialize I/O layers (only required for standalone binaries)
Finit();
//
// Create a bundle object with a grid at T=1.0, named "DemoGrid", in
// a three-dimensional cartesian representation, using the default
// coordinate system.
//
BundlePtr BP = new Bundle();
unlink("outfile.f5");
Assert(!BP->isBound());
//
// Save the bundle to a file, even future data
// that are added to the bundle later. This feature
// is called "binding" a file to the Bundle.
//
BP->bindTo("outfile.f5");
Verbose(0) << "Bundle Binder: " << BP->getBinder();
Assert(BP->isBound());
Representation&myCartesianRepresentation = BP[1.0]["DemoGrid"].makeCartesianRepresentation(3);
Assert(BP->isBound());
Assert(getPrimaryBundle(BP[1.0]));
Assert(getPrimaryBundle(BP[1.0])->isBound());
Assert(getPrimaryBundle(BP[1.0]["DemoGrid"]));
Assert(getPrimaryBundle(BP[1.0]["DemoGrid"])->isBound());
Assert(getPrimaryBundle(*BP[1.0]["DemoGrid"].findVertices() ));
Assert(getPrimaryBundle(*BP[1.0]["DemoGrid"].findVertices())->isBound());
Assert(getPrimaryBundle(myCartesianRepresentation));
Assert(getPrimaryBundle(myCartesianRepresentation)->isBound());
//
// Define the size of the grid to be used hereforth
//
const MultiIndex<3> GridDims = MIndex(11,13,17);
//
// Create a coordinate field and fill it with values
//
RefPtr<Field>&Positions = myCartesianRepresentation[ FIBER_POSITIONS ];
Assert(Positions);
Assert(getPrimaryBundle(*Positions));
Assert(getPrimaryBundle(*Positions)->isBound());
Verbose(0) << "Positions field is bound to " << getPrimaryBundle(*Positions)->boundUrl();
{
//
// Creates a MemArray with a file-write creator, defining
// the type of the creator at this state.
//
for(auto I : GridDims)
{
P.x() = I[0]*0.83;
P.y() = I[1]*0.04*I[1];
P.z() = I[2]*0.01*I[2]*I[1];
}
puts("##################### CREATE CREATOR ######################");fflush(stdout);
CoordinateCreator = Positions->createCreator(Coordinates) )
{
}
}
#if 1 // optionally enable/disable adding a scalar field
//
// Define a scalar field called "values" and set numbers
// to it using some formula based on the indices, just to
// get something non-trivial here.
//
{
{
double& value = GridValues[ I ];
value = (I[0]*0.3)*(I[0]*0.3) +
(I[1]*0.2)*(I[0]*0.2) -
(I[2]*0.1)*(I[2]*0.1);
}
ValueCreator = Values->createCreator(GridValues) )
{
ValueCreator->touch();
}
}
#endif
return 0;
}
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
The main entity holding all information.
Definition Bundle.hpp:173
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2

Function Documentation

◆ main()

int main ( )

File Binding, a way to do Structured Memory Mapping for out-of-core data.

Demonstrating how to bind a Bundle to a file, then adding data to it later on. In contrast, when saving a Bundle to a file then data are added first and saved in the end. The workflow with the binding feature is just other way round - bind first, then add data.

The actual dataset is a set of points with a scalar field on them.