#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>
{
Finit();
unlink("outfile.f5");
BP->bindTo("outfile.f5");
Verbose(0) << "Bundle Binder: " << BP->getBinder();
Representation&myCartesianRepresentation = BP[1.0][
"DemoGrid"].makeCartesianRepresentation(3);
RefPtr<Field>&Positions = myCartesianRepresentation[ FIBER_POSITIONS ];
{
for(auto I : GridDims)
{
point&P = Coordinates[ I ];
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) )
{
CoordinateCreator->touch();
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
}
}
{
RefPtr<Field>&Values = myCartesianRepresentation["values"];
{
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: "
RangeTimer.restart();
Console() <<
"Time to retrieve the range of " << GridDims <<
" double values is " << RangeTimer.
secs()*1000.0 <<
"ms.";
#endif
}
}
{
RefPtr<Field>&Values = myCartesianRepresentation["colors"];
{
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: "
;
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;
}
int main()
Demonstrates minimal usage of the FiberLib Create Bundle, insert a time slice, and safe it to a file.
Definition 010-SimpleSave.cpp:13
An array reference class, which is a convenience class for reference pointers to multidimensional mem...
Definition ArrayRef.hpp:28
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
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
double secs() const noexcept
StrongPtr< Object, ObjectBase > RefPtr
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
RefPtr< BoundingBox > ComputeBBox(const RefPtr< MemBase > &CoordBase)
Compute the bounding box from a given mem array of coordinates.
Definition ExpandBBox.cpp:27
Class for ranges of types, such as minimum/maximum.
Definition Range.hpp:379
static RefPtr< DataRange > retrieve(CreativeArrayBase &CAB, bool AsynchRequest=false, bool AvoidDataLoading=false, const RefPtr< MemBase > &PossibleData=nullptr)
Provide a data range on a given CreativeArrayBase from the attribute, if such exists and is older tha...
Definition Range.hpp:880