Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
GridBoundingBox.cpp

Draw a bounding box for a Grid object residing in the fiber bundle.

Draw a bounding box for a Grid object residing in the fiber bundle.Refinement representations and field fragments are supported (which constitutes AMR).

For each coordinate field, the bounding box is stored with the field and thus re-used if possible. Also, there might be an field in the same data represention be specified. The bounding box information of this field is then shown in addition. This field may consist of various fragments, such that multiple bounding boxes are shown. The bounding box information is cached at each field fragment.

If values in field coordinates are changed, this is not recognized. Code doing so would have to clear the field's BoundingBox interface.

#include <bone/GridOperatorObject.hpp>
#include <ocean/shrimp/VObjectStatus.hpp>
#include <ocean/shrimp/ColorTypes.hpp>
#include <baseop/ExpandBBox.hpp>
#include <ocean/Anemonia/Programmable.hpp>
#include <ocean/Anemonia/VRenderObject.hpp>
#include <ocean/Anemonia/FloatOrigin.hpp>
#include <grid/CartesianChart.hpp>
using namespace Wizt;
using namespace Fiber;
using namespace Eagle;
/**@example GridBoundingBox.cpp
@brief Draw a bounding box for a Grid object residing in the fiber bundle.
Refinement representations and field fragments are supported (which
constitutes AMR).
For each coordinate field, the bounding box is stored with the field
and thus re-used if possible. Also, there might be an field in the
same data represention be specified. The bounding box information of
this field is then shown in addition. This field may consist of
various fragments, such that multiple bounding boxes are shown.
The bounding box information is cached at each field fragment.
If values in field coordinates are changed, this is not recognized.
Code doing so would have to clear the field's BoundingBox interface.
*/
namespace
{
/** @ingroup GridViz
Display a bounding box over some fiber bundle's field.
@author werner
*/
class GridBoundingBox : public GridOperatorObject<VRenderObject>
, public Programmable
, public FloatOrigin
{
public:
using Fish<Fiber::Slice>::getTime;
TypedSlot<double> Thickness;
GridBoundingBox(const string&name, int, const RefPtr<VCreationPreferences>&VP)
, Color(this,"color", rgba_float_t(0.6, 0.7, 0.9, 1.0), 0)
, Thickness(this, "thickness", 2.0, 0)
{
Thickness.setProperty("max", 10.0);
}
{
return G->findChart( typeid(Fiber::CartesianChart3D), theChart.Chartname() );
}
bool update(VRequest&R, double precision) override;
bool environment_render(VRenderContext&Context) const override;
static string createChildname(const string&obj)
{
return "BoundingBoxOf" + obj;
}
string vertex_shader(VRenderContext&Context) const override
{
return default_vertex_shader;
}
string fragment_shader(VRenderContext&Context) const override
{
return
"uniform vec4 Color;\n"
"void main (void)\n"
"{\n"
" gl_FragColor = Color;\n"
"}\n"
;
}
};
/*
Update function: evaluates the current parameter settings
and determines the bounding box information for the entire
representation, plus the field fragments if a field is
specified.
*/
bool GridBoundingBox::update(VRequest&Context, double precision)
{
int nLevel = getMaxRefinementLevel(Context);
Info<Skeleton> Level = getRefinementLevel(nLevel, Context);
if (!Level.getSkeleton() )
{
if (nLevel>0)
return setStatusError(Context, "No Vertices found on this grid's level.", false);
else
return setStatusError(Context, "No Vertices found on this grid.", false);
}
RefPtr<Grid> G = Level.getGrid();
if (!G)
return setStatusError(Context, "No Grid found");
RefPtr<Fiber::Chart> myChart = getChart(G, Context);
if (!myChart)
{
return setStatusError(Context, "No Cartesian Coordinates Available.", false);
}
RefPtr<Field> Coords = Level.getSkeleton()->getField(myChart, FIBER_POSITIONS);
if (!Coords)
return setStatusError(Context, "No Coordinates");
if (RefPtr<BoundingBox> BBox = getBoundingBox( Coords ) )
{
setBoundingBall(Context, BBox);
VBoundingBox B(BBox);
return setStatusInfo(Context, "Bounding box" + String( B ) );
}
else
return setStatusError(Context, "No Bounding box");
}
/*
The render routine.
Retrieves the field state information, draws the
global bounding box of the coordinate field,
plus local bounding boxes for all fragments of the
specified fields.
*/
bool GridBoundingBox::environment_render(VRenderContext&Context) const
{
RefPtr<BoundingBox> MyBBox = getBoundingBall( Context );
if (!MyBBox or MyBBox->empty() )
return true;
Eagle::tvector3 TranslationVector;
VRenderContext::ModelViewState
MVS = getCoordinateTranslation(Context, TranslationVector) ;
using namespace Eagle::PhysicalSpace;
point P0 = MyBBox->mincoord() - TranslationVector,
P1 = MyBBox->maxcoord() - TranslationVector;
P000 ( P0.x(), P0.y(), P0.z() ),
P001 ( P0.x(), P0.y(), P1.z() ),
P010 ( P0.x(), P1.y(), P0.z() ),
P011 ( P0.x(), P1.y(), P1.z() ),
P100 ( P1.x(), P0.y(), P0.z() ),
P101 ( P1.x(), P0.y(), P1.z() ),
P110 ( P1.x(), P1.y(), P0.z() ),
P111 ( P1.x(), P1.y(), P1.z() );
size_t i = 0;
Edges[i++] = P000; Edges[i++] = P010;
Edges[i++] = P010; Edges[i++] = P011;
Edges[i++] = P011; Edges[i++] = P001;
Edges[i++] = P001; Edges[i++] = P000;
Edges[i++] = P100; Edges[i++] = P110;
Edges[i++] = P110; Edges[i++] = P111;
Edges[i++] = P111; Edges[i++] = P101;
Edges[i++] = P101; Edges[i++] = P100;
Edges[i++] = P000; Edges[i++] = P100;
Edges[i++] = P010; Edges[i++] = P110;
Edges[i++] = P011; Edges[i++] = P111;
Edges[i++] = P001; Edges[i++] = P101;
ShaderProgram = CompileShader(Context, "GridBoundingBox" );
if (!ShaderProgram)
return true;
Ref<Anemone> RenderAnemone;
Context.createCoordinates( Edges ) )
{
RenderAnemone->insert( BoxVertices );
RenderAnemone->insert( ShaderProgram );
RenderAnemone->insert( Context.drawPrimitives(RenderBasin::LINES) );
rgba_float_t color(0.6, 0.7, 0.9, 1.0);
RenderAnemone->insert( Context.createRenderParameter("Color", color) );
double width = 2.0;
RenderAnemone->insert( Context.createRenderParameter("glLineWidth", width ) );
// This call replaces glEnable(GL_LINE_SMOOTH);
RenderAnemone->insert( Context.Enable("GL_LINE_SMOOTH") );
RenderAnemone->insert( Context.Enable("GL_DEPTH_TEST") );
RenderAnemone->insert( Context.Disable("GL_LIGHTING") );
RenderAnemone->wave();
return true;
}
else
{
puts("void GridBoundingBox: CANNOT Create a vertex attribute?");
return true;
}
}
using namespace Panthalassa;
myCreator(
Category("Display")
+ VIdentifier("BoundingBox")
+ Help("Display the bounding volume of the grid object.")
+ Description("Display the boundaries of the data volume occupied "
"by the specific Grid object for the most recent time step. "
"Multiple refinement levels are supported, taking the most recent "
"refinement level for a given time. "
)
,
ObjectQuality::BETA);
} // namespace
Chart object for cartesian coordinates.
Definition CartesianChart.hpp:15
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Identify the edges on a skeleton within a Grid.
Definition Edges.hpp:35
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
bool setProperty(const string &theName, const Type &theValue) const
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 ...
DEFAULT_OBJECT
Definition Lytica.hpp:7
Definition GridInspector.hpp:13
The Fish Template provide an interface between the fiber bundle data model and the VISH objects and p...
Definition Fish.hpp:30
Convenience class for objects operating on Grid objects.
Definition GridOperatorObject.hpp:23