#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/UniformCartesianArray.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <eagle/ColorSpace.hpp>
#include <fiber/fiberop/Range.hpp>
#include <fiber/baseop/ExpandBBox.hpp>
const string &FragmentName,
int PartialFactor
)
{
size_t PointsPerFragment = PartialFactor>0 ? FragmentDims.
size()/PartialFactor: FragmentDims.
size();
auto CellVector = Distribution->cell_diagonal();
for(auto I : FragmentDims)
{
if (PartialFactor<2)
idx = I.linear(FragmentDims);
point&P = Coordinates[ idx ];
P.x() = BBox.
min()[0] + I[0] * CellVector[0];
P.y() = BBox.
min()[1] + I[1] * CellVector[1];
P.z() = BBox.
min()[2] + I[2] * CellVector[2];
if (++idx >= PointsPerFragment)
break;
}
auto myFragmentCreator = Positions->createCreator(Coordinates, FragmentName);
(*myFragmentCreator) <<
"CellSize" <<
CellSize;
}
{
RefPtr<Field>&Positions = BP[0.0]["EquidistantPointCloud"].makeCartesianRepresentation(3)[ FIBER_POSITIONS ];
{
string FragmentName = "UniformSquarePartial-Coarse";
}
{
string FragmentName = "UniformSquarePartial-Fine";
}
{
string FragmentName = "UniformRectangular-Coarse";
}
{
string FragmentName = "UniformRectangular-Fine";
}
{
string FragmentName = "NotWorking:UniformCoarse";
}
{
string FragmentName = "NotWorking:UniformFine";
}
}
static double random_double(
double min,
double max)
{
return dist(rng);
}
void makeRandomPointCloudFragment(RefPtr<Field>&Positions,
const string &FragmentName)
{
size_t PointsPerFragment = FragmentDims.
size();
auto CellVector = Distribution->cell_diagonal();
for(auto I : FragmentDims)
{
index_t idx = I.linear(FragmentDims);
point&P = Coordinates[ idx ];
for(int i=0; i<3; i++)
P[i] = random_double(BBox.
min()[i], BBox.
max()[i] );
}
auto myFragmentCreator = Positions->createCreator(Coordinates, FragmentName);
(*myFragmentCreator) <<
"CellSize" <<
CellSize;
}
{
RefPtr<Field>&Positions = BP[0.0]["RandomPointCloud"].makeCartesianRepresentation(3)[ FIBER_POSITIONS ];
{
string FragmentName = "UniformSquarePartial-Coarse";
makeRandomPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformSquarePartial-Fine";
makeRandomPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformRectangular-Coarse";
makeRandomPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformRectangular-Fine";
makeRandomPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
}
void makeRegularPointCloudFragment(RefPtr<Field>&Positions,
const string &FragmentName)
{
size_t PointsPerFragment = FragmentDims.
size();
auto CellVector = Distribution->cell_diagonal();
for(auto I : FragmentDims)
{
index_t idx = I.linear(FragmentDims);
point&P = Coordinates[ idx ];
P.x() = BBox.
min()[0] + I[0] * CellVector[0];
P.y() = BBox.
min()[1] + I[1] * CellVector[1];
P.z() = BBox.
min()[2] + I[2] * CellVector[2];
}
auto myFragmentCreator = Positions->createCreator(Coordinates, FragmentName);
Eagle::metric33 CellTensor = {};
CellTensor(0,0) = 1./( CellVector[0]*CellVector[0] );
CellTensor(1,1) = 1./( CellVector[1]*CellVector[1] );
CellTensor(2,2) = 1./( CellVector[2]*CellVector[2] );
(*myFragmentCreator) << "CellTensor" << CellTensor;
}
{
RefPtr<Field>&Positions = BP[0.0]["RegularPointCloud"].makeCartesianRepresentation(3)[ FIBER_POSITIONS ];
{
string FragmentName = "UniformSquarePartial-Coarse";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformSquarePartial-Fine";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformRectangular-Coarse";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "UniformRectangular-Fine";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "NotWorking:UniformCoarse";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
{
string FragmentName = "NotWorking:UniformFine";
makeRegularPointCloudFragment(Positions, *BBox, FragmentDims, FragmentName);
}
}
{
Finit();
BP->bindToNew("PointCloud.f5");
Verbose(0) << "Bundle Binder: " << BP->getBinder();
CreateRandomPointCloud(BP);
CreateRegularPointCloud(BP);
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
void makeUniformPointCloudFragment(RefPtr< Field > &Positions, const Eagle::BoundingBox &BBox, const MultiIndex< 3 > FragmentDims, const string &FragmentName, int PartialFactor)
The CellTensor and its simpler version, the CellSize.
Definition 033-CellTensor.cpp:30
void CreateEquidistantPointCloud(BundlePtr &BP)
Create a coordinate field with equidistantly distributed points to demonstrate functionality of the C...
Definition 033-CellTensor.cpp:77
constexpr const _Tp & max(const _Tp &__a, const _Tp &__b)
constexpr const _Tp & min(const _Tp &__a, const _Tp &__b)
mersenne_twister_engine< uint_fast64_t, 64, 312, 156, 31, 0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL, 17, 0x71d67fffeda60000ULL, 37, 0xfff7eee000000000ULL, 43, 6364136223846793005ULL > mt19937_64
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
index_t size() const noexcept
Recursive function to compute the entire number of elements.
Definition MultiIndex.hpp:774
Eagle::DomainVector< VectorType, Domain, scalar_t > CellSize(const Eagle::DomainVector< VectorType, Domain, scalar_t > &V, const MultiIndex< VectorType::SIZE > &Dividend, const MultiIndex< VectorType::SIZE > &Stride=MultiIndex< VectorType::SIZE >(1))
Compute the size of a "cell" given a distance between a set of points.
Definition MultiIndex.hpp:1095
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
IndexTypeConfig< sizeof(void *)>::index_t index_t
Define the index type as according to the size of a pointer, i.e.
Definition Index.hpp:22
RefPtr< DataRange< Type > > setCreatorRange(CreativeArrayBase &CAB, const Type &Min, const Type &Max)
Set the range information on a data Creator with type information as provided implicitly by the type ...
Definition Range.hpp:1222