Commit 00a0d325 authored by Adam Borowski's avatar Adam Borowski

Import upstream 4.1.1

parent 962c841b
This diff is collapsed.
//LICENSE A
//
// The IFrIT logo has been created using:
// 1. Microsoft Agent software and Microsoft Agent character "Genie"; copyright (c) 1996-1998 Microsoft Corporation. All rights reserved.
// 2. ACS Viewer 1.1, build 12; copyright (c) 2005 Grigory Filatov.
//
#include "irunner.h"
#include <string.h>
#ifdef I_DEBUG
#include <stdlib.h>
#include "ihelpfactory.h"
#endif
namespace ifrit
{
void TestPerformance();
};
int main(int argc, const char **argv)
{
#ifdef I_DEBUG
//iHelpFactory::CreateUserGuide();
//exit(0);
#endif
//
// Skip program name
//
argc--;
argv++;
//
// Check if a test call
//
if(argc==1 && (strcmp(argv[0],"test")==0 || strcmp(argv[0],"-test")==0 || strcmp(argv[0],"--test")==0))
{
ifrit::TestPerformance();
return 0;
}
iRunner app; // that loads the factories
app.Run(argc,argv);
return 0;
}
#include "ivtk.h"
#include <stdio.h>
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCubeSource.h>
#include <vtkGlyph3D.h>
#include <vtkImageData.h>
#include <vtkLookupTable.h>
#include <vtkOutputWindow.h>
#include <vtkPointData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkTimerLog.h>
namespace ifrit
{
float TestRenderingPerformance(vtkRenderer *ren)
{
//
// Set up the timer
//
ren->GetActiveCamera()->SetPosition(0.0,0.0,1.0);
ren->ResetCamera();
ren->GetRenderWindow()->Render();
vtkTimerLog *timer = vtkTimerLog::New();
timer->StartTimer();
int i;
float r = 0;
do
{
for(i=0; i<35; i++)
{
ren->GetActiveCamera()->Azimuth(9);
ren->GetRenderWindow()->Render();
}
for(i=0; i<35; i++)
{
ren->GetActiveCamera()->Elevation(9);
ren->GetActiveCamera()->OrthogonalizeViewUp();
ren->GetRenderWindow()->Render();
}
for(i=0; i<40; i++)
{
ren->GetActiveCamera()->Roll(9);
ren->GetRenderWindow()->Render();
}
for(i=0; i<5; i++)
{
ren->GetActiveCamera()->Elevation(9);
ren->GetActiveCamera()->OrthogonalizeViewUp();
ren->GetRenderWindow()->Render();
}
for(i=0; i<5; i++)
{
ren->GetActiveCamera()->Azimuth(9);
ren->GetRenderWindow()->Render();
}
timer->StopTimer();
r += 1;
}
while(timer->GetElapsedTime() < 3.0);
r /= timer->GetElapsedTime();
timer->Delete();
return r;
}
void TestPerformance()
{
int i;
const float renRateScale[2] = { 7.5f, 7.5f };
vtkRenderer *ren = vtkRenderer::New();
vtkRenderWindow *win = vtkRenderWindow::New();
win->AddRenderer(ren);
ren->Delete();
vtkImageData *data = vtkImageData::New();
data->SetDimensions(17,17,17);
data->SetSpacing(0.125,0.125,0.125);
data->SetOrigin(-1.0,-1.0,-1.0);
#ifdef IVTK_5
data->SetScalarType(VTK_UNSIGNED_CHAR);
data->SetNumberOfScalarComponents(1);
data->AllocateScalars();
#else
data->AllocateScalars(VTK_UNSIGNED_CHAR,1);
#endif
unsigned char *ptr = (unsigned char *)data->GetScalarPointer();
for(i=0; i<data->GetNumberOfPoints(); i++)
{
ptr[i] = i % 256;
}
vtkCubeSource *cube = vtkCubeSource::New();
cube->Update();
vtkGlyph3D *glyph = vtkGlyph3D::New();
glyph->SetScaleModeToDataScalingOff();
glyph->SetColorModeToColorByScalar();
glyph->SetScaleFactor(0.08);
glyph->SetSourceConnection(cube->GetOutputPort());
glyph->SetInputData(data);
cube->Delete();
glyph->Update();
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
vtkActor *actor = vtkActor::New();
mapper->ScalarVisibilityOn();
mapper->SetColorModeToMapScalars();
vtkLookupTable *lut = vtkLookupTable::New();
lut->SetRange(0.0,255.0);
//lut->SetHueRange(0.0,255.0);
mapper->SetLookupTable(lut);
mapper->UseLookupTableScalarRangeOn();
lut->Delete();
actor->GetProperty()->SetColor(0.0,0.0,0.0);
actor->SetMapper(mapper);
mapper->Delete();
mapper->SetInputConnection(glyph->GetOutputPort());
glyph->Delete();
ren->AddActor(actor);
actor->Delete();
//
// set the scene
//
win->SetSize(512,512);
ren->SetBackground(1.0,1.0,1.0);
//
// draw the resulting scene
//
win->SetWindowName("IFrIT - Performance Test");
win->Render();
win->SetWindowName("IFrIT - Performance Test");
actor->GetProperty()->SetOpacity(1.0);
actor->GetProperty()->SetColor(0.0,0.0,1.0);
float rr1 = TestRenderingPerformance(ren)*renRateScale[0];
actor->GetProperty()->SetOpacity(0.03);
actor->GetProperty()->SetColor(1.0,0.0,0.0);
float rr2 = TestRenderingPerformance(ren)*renRateScale[1];
char str[1000];
sprintf(str,
"Rendering performance:\n\n"
"Opaque:\t\t %.1f\n"
"Transparent:\t %.1f\n\n"
"Representative rangers for values:\n"
"1-2\tLaptop with a chipset\n"
"5-20\tDesktop with a low-end video card\n"
"50-200\tWorkstation with a high-end video card\n\n"
"VTK Version: %s\n",rr1,rr2,VTK_VERSION);
vtkOutputWindow::GetInstance()->DisplayText(str);
data->Delete();
win->RemoveRenderer(ren);
win->Delete();
}
};
#include "iconfigure.h"
#if ISCRIPT_INCLUDED(ISCRIPT_PYTHON)
#include <Python.h>
namespace ipyPrivate
{
PyObject* Start(PyObject *module, PyObject *args);
void Free(void *ptr);
};
PyMethodDef ModuleMethods[] =
{
{"start", ipyPrivate::Start, METH_VARARGS, "Start IFrIT."},
{NULL, NULL, 0, NULL} /* Sentinel */
};
#if (PY_MAJOR_VERSION > 2)
PyModuleDef Module =
{
PyModuleDef_HEAD_INIT,
"ifrit",
"Module that provides access to IFrIT objects and their properties.",
0,
ModuleMethods, NULL, NULL, NULL, NULL
};
PyMODINIT_FUNC PyInit_ifrit(void)
{
//
// Create the module
//
Module.m_free = &ipyPrivate::Free;
PyObject* module = PyModule_Create(&Module);
return module;
}
#else
#if (PY_MINOR_VERSION < 7)
#error IFrIT needs Python 2.7 or Python 3
#endif
PyMODINIT_FUNC initifrit(void)
{
//
// Create the module
//
PyObject *Module = Py_InitModule("ifrit",ModuleMethods);
Py_InitModule4("ifrit",ModuleMethods,"Module that provides access to IFrIT objects and their properties.",Module,PYTHON_API_VERSION);
}
#endif
#endif
......@@ -42,10 +42,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Supported shells
//
#define ISHELL_CL 1
#define ISHELL_GG 0xFFFFFFFE
#define ISHELL_QT 2
//#define ISHELL_FX 4
#define ISHELL_OS 1
#define ISHELL_CL 2
#define ISHELL_GG 0xFFFFFFFC
#define ISHELL_QT 4
//
// Supported scripts
//
#define ISCRIPT_PYTHON 1
//
// Multiple extensions can be included, they are not exclusive
......@@ -57,6 +62,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#define ISHELL_INCLUDED(_Type_) ((ISHELL & _Type_) != 0)
//
// Multiple scripts can be included, they are not exclusive
//
#define ISCRIPT_INCLUDED(_Type_) ((ISCRIPT & _Type_) != 0)
//
// ******************************************************************************
//
......@@ -66,7 +76,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "iconfiguresettings.ext.h"
#else
#define IEXTENSION 0xFFFFFFFF
#define ISHELL 0xFFFFFFFF
#define ISHELL 0xFFFFFFFF
#define ISCRIPT 1
#endif
//
// ******************************************************************************
......@@ -77,9 +88,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
!TERMINATE!
#endif
#if !defined(ISHELL) || (ISHELL == 0)
#if !defined(ISHELL) || (ISHELL == 0)
#error Misconfiguration: shell (ISHELL) is not set.
!TERMINATE!
#endif
#if !defined(ISCRIPT)
#error Misconfiguration: script (ISCRIPT) is not set.
!TERMINATE!
#endif
#endif // ICONFIGURE_H
......@@ -25,6 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#define IEXTENSION @exten@
#define ISHELL @shell@
#define IEXTENSION @my_ext@
#define ISCRIPT @my_scr@
#define ISHELL @my_shl@
......@@ -35,31 +35,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "istring.h"
void iEdition::ApplySettings(iObject *obj, const iObjectType &type)
{
if(obj == 0) return;
iString ws = iEdition::GetObjectSettings(type);
if(!ws.IsEmpty())
{
obj->ReportMissingKeys(false);
obj->UnPackCompleteState(ws);
obj->ReportMissingKeys(true);
}
}
#ifndef I_EDITION
const iString iEdition::GetObjectSettings(const iObjectType &)
void iEdition::ApplySettings(iObject *obj)
{
return "";
}
const iString iEdition::GetEditionName()
const iString& iEdition::GetEditionName()
{
return "Standard Edition";
static const iString name("Standard Edition");
return name;
}
#endif
......
......@@ -34,7 +34,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class iObject;
class iObjectType;
class iString;
......@@ -43,12 +42,8 @@ class iEdition
public:
static void ApplySettings(iObject *obj, const iObjectType &type);
static const iString GetEditionName();
private:
static const iString GetObjectSettings(const iObjectType &type);
static void ApplySettings(iObject *obj);
static const iString& GetEditionName();
};
#endif // IEDITION_H
......@@ -27,14 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "iconfigure.h"
#include "iextensionfactory.h"
#include "irendertool.h"
//
// This file is documented only partially.
//
#include "ianimatorscript.h"
#include "irendertool.h"
#include "ierror.h"
#if IEXTENSION_INCLUDED(IEXTENSION_MV)
......@@ -42,12 +38,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
iRenderTool* iExtensionFactory::CreateRenderTool(iViewModule *vm)
//
// Factory method
//
iRenderTool* iRenderTool::New(iViewModule *vm)
{
IASSERT(vm);
#if IEXTENSION_INCLUDED(IEXTENSION_MV)
return new iMultiViewRenderTool(vm);
iRenderTool *tmp = new iMultiViewRenderTool(vm);
#else
return new iRenderTool(vm);
iRenderTool *tmp = new iRenderTool(vm);