Fish - FiberLib for VISH 0.3
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;
/**@example ComputeNormals.cpp
*/
/**
Antique object to compute normal vectors on a surface.
@author werner
*/
class VComputeNormals : public virtual VObject,
public virtual Fish<Fiber::Slice>,
public virtual Fish<Fiber::Grid>
{
public:
/// The output: normal vectors as field, optionally
VOutput<Fiber::Field> theNormalVectorField;
BundleSlot myBundle() const
{
/// hack
}
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 );
RefPtr<Grid> G = iG;
if (!G)
{
printf("ComputeNormals: update(): No grid!\n");
return true;
}
RefPtr<Field> NormalsField = (*G)( TriangularSurface::NormalVectorFieldName );
if (NormalsField)
{
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;
}
RefPtr<TriangularSurface::NormalVectorArray_t>
VertexNormals =
TriangularSurface::computeVertexNormals(
Coords->getData(),
CellsAsVertices->getPositions()->getData()
);
(*G)[ TriangularSurface::NormalVectorFieldName ] = new Field( VertexNormals );
FieldSelector FS( getGridSelector(Context), iG);
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" ),
}
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
Wizt::VCreatorProperty< Wizt::VCreatorProperties::URL > Url
Wizt::VCreatorProperty< Wizt::VCreatorProperties::APPLICATION > Application
Wizt::VCreatorProperty< Wizt::VCreatorProperties::DESCRIPTION > Description
Wizt::VCreatorProperty< Wizt::VCreatorProperties::SHORTHELP > Help
Wizt::VCreatorProperty< Wizt::VCreatorProperties::CATEGORY > Category
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
Definition Lytica.hpp:7
Definition fs/init.hpp:20
Generic template namespace class for results of find() functions throughout the Bundle.
Definition Info.hpp:17
static const char NormalVectorFieldName[]
A default name for the field that holds the normal vectors of a grid with a surface.
Definition TriangularSurface.hpp:146