FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
ComputeNormals.cpp
#include <bone/FishSlice.hpp>
#include <bone/FishGrid.hpp>
#include <bone/FishField.hpp>
#include <grid/types/TriangularSurface.hpp>
namespace
{
using namespace Wizt;
using namespace Fiber;
using namespace Eagle;
class VComputeNormals : public virtual VObject,
public virtual Fish<Fiber::Slice>,
public virtual Fish<Fiber::Grid>
{
public:
VOutput<Fiber::Field> theNormalVectorField;
BundleSlot myBundle() const
{
}
VComputeNormals(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
: VObject(name, p, VP)
, theNormalVectorField( self(), "Normals")
{
theNormalVectorField.provides<PhysicalSpace::bivector>();
}
bool update(VRequest&R, double precision) override;
};
bool VComputeNormals::update(VRequest&Context, double precision)
{
Info<Grid> iG = findMostRecentGrid( Context );
if (!G)
{
printf("ComputeNormals: update(): No grid!\n");
return true;
}
RefPtr<Field> NormalsField = (*G)( TriangularSurface::NormalVectorFieldName );
{
puts("already have normals");
return true;
}
RefPtr<Field> Coords = G->CartesianPositions();
if (!Coords)
{
puts("No coord field!");
return true;
}
RefPtr<Representation> CellsAsVertices = G->CellsAsVertices(2);
if (!CellsAsVertices)
{
puts("VComputeNormals: No cells as vertices found");
return true;
}
VertexNormals =
TriangularSurface::computeVertexNormals(
Coords->getData(),
CellsAsVertices->getPositions()->getData()
);
(*G)[ TriangularSurface::NormalVectorFieldName ] = new Field( VertexNormals );
FieldSelector FS( getGridSelector(Context), iG);
FS.selectTypedField<PhysicalSpace::bivector>( TriangularSurface::NormalVectorFieldName );
theNormalVectorField << Context << FS;
return true;
}
}
namespace
{
using namespace Panthalassa;
MyCreator( Category( "Compute" ) + VIdentifier( "Normals" ) + Application( "General" ) +
Description( "Compute normal vectors of a triangular surface." ) +
Help( "todo" ) +
Url( "http://vish.fiberbundle.net/wiki" ),
ObjectQuality::EXPERIMENTAL );
}
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
Definition Lytica.hpp:7
Definition fs/init.hpp:20