Draw a bounding box for a Grid object residing in the fiber bundle. Only draws a bounding box that is already available a interface to the Position field. No computation performed here.
#include <ocean/plankton/VModules.hpp> #include <ocean/plankton/VCreator.hpp> #include <ocean/GLvish/VGLRenderObject.hpp> #include <ocean/eagle/PhysicalSpace.hpp> #include <field/DirectProductArray.hpp> #include <fish/lakeview/eye/retina/VSkeletonRenderObject.hpp> #include <bone/GridObject.hpp> #include <bone/FishField.hpp> #include <baseop/ExpandBBox.hpp> #include <GLvish/BoundingBox.hpp> namespace { using namespace Wizt; using namespace Fiber; using namespace Eagle; class BoundingBoxSimple : public VSkeletonRenderObject { public: typedef DirectProductMemArray<Eagle::point3> ProcArray_t; typedef MemArray<3, Eagle::point3> CoordsArray_t; struct FieldState : State { RefPtr<Field> Coords; }; override RefPtr<State> newState() const { return new FieldState(); } Slot Thickness; BoundingBoxSimple(const string&name, int p, const RefPtr<VCreationPreferences>&VP) : VGLRenderObject(name, p, VP) , Fish<VObject>(this) , VSkeletonRenderObject(name, p, VP) { Thickness = addParam("thickness", 20, NullPtr(), 1); } override bool update(VRequest&R, double precision) { RefPtr<FieldState> S = getState(R); RefPtr<Grid> G = findMostRecentGrid( R ); if (!G) { printf("BoundingBox: update(): No grid!\n"); if (S) S -> Coords = NullPtr(); return true; } RefPtr<Field> Coords = G->CartesianPositions(); if (!Coords) { puts("No coord field!"); if (S) S -> Coords = NullPtr(); return true; } S = myState(R); assert(S); S -> Coords = Coords; return true; } override void render(VGLRenderContext&Context) const { RefPtr<FieldState> myState = getState(Context); if (!myState) return; if (!myState->Coords) return; RefPtr<BoundingBox> BBox = interface_cast<BoundingBox>( myState->Coords ); if (!BBox) return; int width = 20; Thickness << Context >> width; glDisable(GL_LIGHTING); glEnable( GL_DEPTH_TEST ); glLineWidth(width/10.0); glEnable(GL_LINE_SMOOTH); glColor3f( 0.6, 0.7, 0.9); glDraw( *BBox ); } static string createChildname(const string&parent_name) { return "iBBox[" + parent_name + "]"; } }; static Ref<VCreator<BoundingBoxSimple, AcceptList<Fiber::Grid> > > Crec("SimpleDisplay/ExistingBoundingBox", ObjectQuality::EXPERIMENTAL); }