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

[← Previous Example] [Next Example → 300-Interpolator.cpp ]. More...

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <memcore/Console.hpp>
#include <fish/fiber/baseop/ExpandBBox.hpp>
#include <string>

Classes

struct  MyProgress
struct  FragIt
class  SliceIterator

Functions

int main (int argc, char **argv)

Detailed Description

[← Previous Example] [Next Example → 300-Interpolator.cpp ].

In FiberLib Tutorial

/**
* small infrastructure to implement spatial sorting
* @author: Doeby & Werner
* @date: 2015/10/19
*/
#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <memcore/Console.hpp>
#include <fish/fiber/baseop/ExpandBBox.hpp>
#include <string>
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
using namespace std;
{
string GridName ;
bool CreateGrid(const RefPtr<GridID>&gname, Grid&G, double t) override
{
GridName = gname->Name();
return true;
}
bool CreateField(const RefPtr<GridID>&gname, Grid&G, double t,
const string&fieldname) override
{
return true;
}
};
// ----------- FRAG ------------
struct FragIt : Field::Iterator
{
RefPtr<Field>&OutputField;
FragIt(RefPtr<Field>&OutputFieldP)
: OutputField(OutputFieldP)
{}
bool apply(const RefPtr<FragmentID>&fid,
{
RefPtr<MemArray<1,point> > MemIn = CAB->create();
MultiArray<1,point>&MulIn = *MemIn;
RefPtr<MemArray<1,point> > MemOut = new MemArray<1,point>( MemIn->nElements() );
MultiArray<1,point>&MulOut = *MemOut;
//implementing spatial sorting......
for (auto I : MulIn.Size() )
MulOut[I] = MulIn[I];
RefPtr<FragmentID> NewFragID = OutputField->makeFragmentID( fid->Name() );
Console() << "Save Fragment: " << fid->Name() << " with " << MemIn->nElements() ;
OutputField->setPersistentData(MemOut,NewFragID);
return true;
}
};
// ----------- SLICE ------------
class SliceIterator : public EvolutionIterator<Slice>
{
public:
string&GridName;
BundlePtr&BPNew;
SliceIterator(string&GridNameP,BundlePtr&BPNewP)
: GridName(GridNameP)
, BPNew(BPNewP)
{}
bool apply(ParameterSet&P, Slice&S)
{
RefPtr<Grid> InGrid = S(GridName);
if (!InGrid)
return true;
RefPtr<Field> myPositions = InGrid->getCartesianPositions();
if (!myPositions)
return false;
Representation&myCartesianRepresentation = BPNew[0.0]["myGrid"].makeCartesianRepresentation(3);
RefPtr<Field>&OutputField = myCartesianRepresentation[ FIBER_POSITIONS ];
OutputField = new Field();
if (!OutputField)
return false;
FragIt myfragit(OutputField);
if ( !myPositions->iterate(myfragit) )
return false;
return true;
}
};
// ----------- MAIN ------------
int main(int argc, char** argv)
{
// initialize
Finit();
string FileName = argv[1];
Console() << "Input File: " << FileName;
// load bundle
bool success;
RefPtr<MyProgress> Ptr = new MyProgress();
BP = Bundle::load( success, FileName , BP, Ptr);
if (!success)
{
Console() << "Could not read file: " ;
return true;
}
// new Bundle
BundlePtr BPNew = new Bundle();
BPNew->bindToNew("200_SpacialSorting.f5");
SliceIterator mySliceIterator(Ptr->GridName,BPNew);
if ( !BP->iterate(ParameterList(), mySliceIterator) )
{
Console() << "Error";
return 1;
}
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
Loading progress callback functor.
Definition Bundle.hpp:132
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
static RefPtr< Bundle > load(bool &success, const RefPtr< LoaderParameters > &ld, const RefPtr< Bundle > &B=nullptr)
Load a Bundle object or append new data to an existing Bundle.
Definition Bundle.cpp:139
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
Definition ParameterSpace.hpp:83
Definition 200-SpatialSorting.cpp:69
StrongPtr< Object, ObjectBase > RefPtr
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
STL namespace.
Definition 200-SpatialSorting.cpp:36
bool apply(const RefPtr< FragmentID > &fid, const RefPtr< CreativeArrayBase > &CAB)
Iteration callback function.
Definition 200-SpatialSorting.cpp:43
Definition 200-SpatialSorting.cpp:18
bool CreateGrid(const RefPtr< GridID > &gname, Grid &G, double t) override
Callback when a new Grid object is created; if return value is false, the load process is terminated.
Definition 200-SpatialSorting.cpp:21