Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Typedefs | Functions
031-RangedPointCloud.cpp File Reference

[← Previous Example] [Next Example → 033-CellTensor.cpp ]. More...

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <eagle/ColorSpace.hpp>
#include <fiber/fiberop/Range.hpp>
#include <fiber/baseop/ExpandBBox.hpp>
#include <memcore/Timer.hpp>
#include <memcore/Console.hpp>

Typedefs

using rgb16 = Eagle::rgb16_t
 

Functions

int main ()
 Bind a bundle to a file and add data to it later.
 

Detailed Description

[← Previous Example] [Next Example → 033-CellTensor.cpp ].

In FiberLib Tutorial

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <eagle/ColorSpace.hpp>
#include <fiber/fiberop/Range.hpp>
#include <fiber/baseop/ExpandBBox.hpp>
#include <memcore/Timer.hpp>
#include <memcore/Console.hpp>
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
/**@brief Bind a bundle to a file and add data to it later.
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);
//
// Define the size of the grid to be used hereforth
//
const MultiIndex<3> GridDims = MIndex(210,130,170);
//
// Create a coordinate field and fill it with values
//
RefPtr<Field>&Positions = myCartesianRepresentation[ FIBER_POSITIONS ];
{
//
// 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];
}
if (auto CoordinateCreator = Positions->createCreator(Coordinates) )
{
Console() << "Time to compute the bounding box of " << GridDims << " coordinates is " << CoordRangeTimer.secs()*1000.0 << "ms: " << *Range;
#if FIBEROPERATIONS_RANGE_HPP >= 20241206
CoordRangeTimer.restart();
Console() << "Time to compute the range of " << GridDims << " coordinates is " << CoordRangeTimer.secs()*1000.0 << "ms: " << *Range2;
CoordRangeTimer.restart();
Console() << "Time to retrieve the range of " << GridDims << " coordinates is " << CoordRangeTimer.secs()*1000.0 << "ms.";
#endif
}
}
//
// 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);
}
if (auto
ValueCreator = Values->createCreator(GridValues) )
{
ValueCreator->touch();
#if FIBEROPERATIONS_RANGE_HPP < 20241206
Console() << "Time to compute the range of " << GridDims << " double values is " << RangeTimer.secs()*1000.0 << "ms.";
#else
Console() << "Time to compute the range of " << GridDims << " double values is " << RangeTimer.secs()*1000.0 << "ms: "
<< *Range;
RangeTimer.restart();
Console() << "Time to retrieve the range of " << GridDims << " double values is " << RangeTimer.secs()*1000.0 << "ms.";
#endif
}
}
{
{
auto& value = GridValues[ I ];
value.r() = I[0]*0x10000 / GridDims[0];
value.g() = I[1]*0x10000 / GridDims[1];
value.b() = I[2]*0x10000 / GridDims[2];
}
if (auto
ValueCreator = Values->createCreator(GridValues) )
{
ValueCreator->touch();
#if FIBEROPERATIONS_RANGE_HPP >= 20241206
Console() << "Time to compute the range of " << GridDims << " rgb values is " << RangeTimer.secs()*1000.0 << "ms: "
<< *Range
;
RangeTimer.restart();
Console() << "Time to retrieve the range of " << GridDims << " rgb values is " << RangeTimer.secs()*1000.0 << "ms.";
Assert( ValueCreator->getAttribute("Range" ) );
#endif
}
#if FIBEROPERATIONS_RANGE_HPP >= 20241206
auto Range = Values->getAttribute("Range");
#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
DomainVector< Vector< color16_t, 3 >, RGB > rgb16_t
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Class for ranges of types, such as minimum/maximum.
Definition Range.hpp:379

Function Documentation

◆ main()

int main ( )

Bind a bundle to a file and add data to it later.

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.

References Fiber::ComputeBBox(), and Fiber::DataRange< Type >::retrieve().