Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Classes | Functions
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 ------------
{
RefPtr<Field>&OutputField;
: OutputField(OutputFieldP)
{}
bool apply(const RefPtr<FragmentID>&fid,
{
RefPtr<MemArray<1,point> > MemIn = CAB->create();
//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;
: 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;
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");
if ( !BP->iterate(ParameterList(), mySliceIterator) )
{
Console() << "Error";
return 1;
}
return 0;
}
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
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
Base class for iterators over the fragments of a field.
Definition FragmentID.hpp:249
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 ParameterSpace.hpp:49
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
Definition 200-SpatialSorting.cpp:69
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
Definition 200-SpatialSorting.cpp:18