Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
020-CreateBundleAndSave.cpp File Reference

[← Previous Example] [Next Example → 021_CreateMultiBundlesAndSave.cpp ]. More...

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

Functions

int main ()

Detailed Description

[← Previous Example] [Next Example → 021_CreateMultiBundlesAndSave.cpp ].

In FiberLib Tutorial

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <eagle/PhysicalSpace.hpp>
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
int main()
{
// Initialize I/O layers
Finit();
//
// Create a bundle object with a grid at T=1.0, named "myGrid", in
// a three-dimensional cartesian representation, using the default
// coordinate system.
//
Representation&myCartesianRepresentation = BP[1.0]["myGrid"].makeCartesianRepresentation(3);
//
// 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 ];
Positions = new Field();
{
Coordinates(GridDims);
for(MultiIndex<3> I : GridDims)
{
point&P = Coordinates[ I ];
P.x() = I[0]*0.3;
P.y() = I[1]*0.2;
P.z() = I[2]*0.1;
}
Positions->setPersistentData(Coordinates);
}
Assert( Positions->isUnfragmented() );
//
// 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.
//
RefPtr<Field>&Values = myCartesianRepresentation["values"];
Values = new Field();
{
GridValues(GridDims);
for(MultiIndex<3> I : GridDims)
{
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);
}
Values->setPersistentData( GridValues );
}
Assert( Values->isUnfragmented() );
//
// Save the bundle to a file.
//
BP.save("020_CreateBundleAndSave.f5");
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
int save(const string &url, const RefPtr< LoaderProgress > &SaveProgress=nullptr, const RefPtrStorageTransformations &ST=nullptr)
Definition Bundle.cpp:1142
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
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
StrongPtr< Object, ObjectBase > RefPtr
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2