---Purpose: returns both the elapsed time(seconds,minutes,hours)
-- and CPU time.
---Level: Public
-
+
Stop (me : in out) is redefined;
---Purpose: Stops the Timer.
---Level: Public
-- the Timer.
---Level: Public
+ ElapsedTime (me : in out) returns Real;
+ ---Purpose: Returns elapsed time in seconds.
+ ---Level: Public
+
fields
TimeStart : Real;
Show (cout);
}
+//=======================================================================
+//function : ElapsedTime
+//purpose :
+//=======================================================================
+
+Standard_Real OSD_Timer::ElapsedTime()
+{
+ if (!Stopped)
+ {
+ // update cumulative time
+ Stop();
+ Start();
+ }
+
+ return TimeCumul;
+}
//=======================================================================
//function : Show
aMap.UnBind2 (theName);
}
+ if (theAISObj.IsNull())
+ {
+ // object with specified name already unbound
+ return Standard_True;
+ }
+
// unbind AIS object if was bound with another name
aMap.UnBind1 (theAISObj);
Standard_Real aCenterY = (argc > 5) ? atof (argv[4]) : 0.0;
Standard_Real aCenterZ = (argc > 5) ? atof (argv[5]) : 0.0;
Standard_Real aRadius = (argc > 6) ? atof (argv[6]) : 100.0;
- Standard_Boolean isVBOEnabled = (argc > 7) ? atoi (argv[7]) : Standard_True;
- Standard_Integer aRedrawsNb = (argc > 8) ? atoi (argv[8]) : 1;
- Standard_Boolean toShowEdges = (argc > 9) ? atoi (argv[9]) : Standard_False;
-
- if (aRedrawsNb <= 0)
- {
- aRedrawsNb = 1;
- }
+ Standard_Boolean toShowEdges = (argc > 7) ? atoi (argv[7]) : Standard_False;
// remove AIS object with given name from map
- if (GetMapOfAIS().IsBound2 (aShapeName))
- {
- Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aShapeName);
- Handle(AIS_InteractiveObject) anInterObj = Handle(AIS_InteractiveObject)::DownCast (anObj);
- if (anInterObj.IsNull())
- {
- std::cout << "Shape name was used for non AIS viewer\n!";
- return 1;
- }
- aContextAIS->Remove (anInterObj, Standard_False);
- GetMapOfAIS().UnBind2 (aShapeName);
- }
-
- // enable/disable VBO
- Handle(Graphic3d_GraphicDriver) aDriver =
- Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
- if (!aDriver.IsNull())
- {
- aDriver->EnableVBO (isVBOEnabled);
- }
+ VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
std::cout << "Compute Triangulation...\n";
Handle(AIS_Triangulation) aShape
Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
- // register the object in map
- GetMapOfAIS().Bind (aShape, aShapeName);
-
// stupid initialization of Green color in RGBA space as integer
// probably wrong for big-endian CPUs
Standard_Integer aRed = 0;
aShAsp->SetAspect (anAspect);
aShape->Attributes()->SetShadingAspect (aShAsp);
- aContextAIS->Display (aShape, Standard_False);
-
- // Two viewer updates are needed in order to measure time spent on
- // loading triangulation to graphic card memory + redrawing (1st update) and
- // time spent on redrawing itself (2nd and all further updates)
- OSD_Chronometer aTimer;
- Standard_Real aUserSeconds, aSystemSeconds;
- aTimer.Start();
- const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
- for (Standard_Integer anInteration = 0; anInteration < aRedrawsNb; ++anInteration)
- {
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
- {
- if (anInteration == 0)
- {
- aViewer->ActiveView()->Update();
- }
- else
- {
- aViewer->ActiveView()->Redraw();
- }
- }
- }
- aTimer.Show (aUserSeconds, aSystemSeconds);
- aTimer.Stop();
- std::cout << "Number of scene redrawings: " << aRedrawsNb << "\n"
- << "CPU user time: "
- << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aUserSeconds
- << " msec\n"
- << "CPU system time: "
- << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * aSystemSeconds
- << " msec\n"
- << "CPU average time of scene redrawing: "
- << std::setiosflags(std::ios::fixed) << std::setprecision(16) << 1000.0 * (aUserSeconds / (Standard_Real )aRedrawsNb)
- << " msec\n";
+ VDisplayAISObject (aShapeName, aShape);
return 0;
}
__FILE__,VDrawText,group);
theCommands.Add("vdrawsphere",
- "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
+ "vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n",
__FILE__,VDrawSphere,group);
theCommands.Add("vclipplane",
#endif
#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_ExportFormat.hxx>
#include <ViewerTest.hxx>
#include <ViewerTest_EventManager.hxx>
#include <Draw_Appli.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Image_PixMap.hxx>
+#include <OSD_Timer.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Visual3d_LayerItem.hxx>
#include <V3d_LayerMgr.hxx>
Standard_Real minRange = 0. , maxRange = 100. ;
Standard_Integer numIntervals = 10 ;
- Standard_Real textHeight = 16. ;
+ Standard_Integer textHeight = 16;
Aspect_TypeOfColorScalePosition position = Aspect_TOCSP_RIGHT;
Standard_Real X = 0., Y = 0. ;
numIntervals = atoi( argv[3] );
}
if ( argc > 4 )
- textHeight = atof( argv[4] );
+ textHeight = atoi( argv[4] );
if ( argc > 5 )
position = (Aspect_TypeOfColorScalePosition)atoi( argv[5] );
if ( argc > 7 )
if (aTail == 5)
{
aRadiusStep = atof (theArgVec[anIter++]);
- aDivisionNumber = atof (theArgVec[anIter++]);
+ aDivisionNumber = atoi (theArgVec[anIter++]);
aRotAngle = atof (theArgVec[anIter++]);
}
return 0;
}
+//==============================================================================
+//function : VFps
+//purpose :
+//==============================================================================
+
+static int VFps (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ // get the active view
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
+ {
+ std::cerr << "No active view. Please call vinit.\n";
+ return 1;
+ }
+
+ Standard_Integer aFramesNb = (theArgNb > 1) ? atoi(theArgVec[1]) : 100;
+ if (aFramesNb <= 0)
+ {
+ std::cerr << "Incorrect arguments!\n";
+ return 1;
+ }
+
+ // the time is meaningless for first call
+ // due to async OpenGl rendering
+ aView->Redraw();
+
+ // redraw view in loop to estimate average values
+ OSD_Timer aTimer;
+ aTimer.Start();
+ for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter)
+ {
+ aView->Redraw();
+ }
+ aTimer.Stop();
+ Standard_Real aCpu;
+ const Standard_Real aTime = aTimer.ElapsedTime();
+ aTimer.OSD_Chronometer::Show (aCpu);
+
+ const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime;
+ const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb);
+
+ // return statistics
+ theDI << "FPS: " << aFpsAver << "\n"
+ << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
+
+ return 0;
+}
+
+
+//==============================================================================
+//function : VVbo
+//purpose :
+//==============================================================================
+
+static int VVbo (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ // get the context
+ Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+ if (aContextAIS.IsNull())
+ {
+ std::cerr << "No active view. Please call vinit.\n";
+ return 1;
+ }
+
+ Handle(Graphic3d_GraphicDriver) aDriver =
+ Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+ if (aDriver.IsNull())
+ {
+ std::cerr << "Graphic driver not available.\n";
+ return 1;
+ }
+
+ if (theArgNb < 2)
+ {
+ //theDI << "VBO: " << aDriver->ToUseVBO() << "\n";
+ //return 0;
+ std::cerr << "Wrong number of arguments.\n";
+ return 1;
+ }
+
+ aDriver->EnableVBO (atoi(theArgVec[1]) != 0);
+ return 0;
+}
+
//=======================================================================
//function : ViewerCommands
//purpose :
" : Mode - rectangular or circular"
" : Type - lines or points",
__FILE__, VGrid, group);
+ theCommands.Add ("vfps",
+ "vfps [framesNb=100] : estimate average frame rate for active view",
+ __FILE__, VFps, group);
+ theCommands.Add ("vvbo",
+ "vvbo {0|1} : turn VBO usage On/Off; affects only newly displayed objects",
+ __FILE__, VVbo, group);
}