Commit 07b9d98b authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

STYLE: Enforce code style

parent cfe79a76
......@@ -30,10 +30,10 @@
class CapsuleRenderTest : public RenderTest
{
void createGeometry() override
{
void createGeometry() override
{
geom = std::make_shared<Capsule>();
}
}
};
TEST_F(CapsuleRenderTest, createCapsule)
{
......@@ -42,10 +42,10 @@ TEST_F(CapsuleRenderTest, createCapsule)
class CylinderRenderTest : public RenderTest
{
void createGeometry() override
{
void createGeometry() override
{
geom = std::make_shared<Cylinder>();
}
}
};
TEST_F(CylinderRenderTest, createCylinder)
{
......@@ -54,10 +54,10 @@ TEST_F(CylinderRenderTest, createCylinder)
class OrientedBoxRenderTest : public RenderTest
{
void createGeometry() override
{
void createGeometry() override
{
geom = std::make_shared<OrientedBox>();
}
}
};
TEST_F(OrientedBoxRenderTest, createOrientedBox)
{
......@@ -66,10 +66,10 @@ TEST_F(OrientedBoxRenderTest, createOrientedBox)
class PlaneRenderTest : public RenderTest
{
void createGeometry() override
{
void createGeometry() override
{
geom = std::make_shared<Plane>();
}
}
};
TEST_F(PlaneRenderTest, createPlane)
{
......@@ -78,10 +78,10 @@ TEST_F(PlaneRenderTest, createPlane)
class SphereRenderTest : public RenderTest
{
void createGeometry() override
{
void createGeometry() override
{
geom = std::make_shared<Sphere>();
}
}
};
TEST_F(SphereRenderTest, createSphere)
{
......
......@@ -31,11 +31,11 @@ class MeshFileRenderTest : public RenderTest
{
public:
void createGeometry() override
{
geom = MeshIO::read(iMSTK_DATA_ROOT "/textured_organs/heart.obj");
geom->scale(0.15, Geometry::TransformType::ConcatenateToTransform);
}
void createGeometry() override
{
geom = MeshIO::read(iMSTK_DATA_ROOT "/textured_organs/heart.obj");
geom->scale(0.15, Geometry::TransformType::ConcatenateToTransform);
}
};
TEST_F(MeshFileRenderTest, meshFile)
{
......@@ -46,124 +46,123 @@ class MeshColorFunctionVerticesRenderTest : public RenderTest
{
public:
float val = 0.0;
void createGeometry() override
{
imstk::VecDataArray<double, 3> points;
auto scalars = std::make_shared<imstk::DataArray<float>>();
for (int i = 0; i < 6; ++i)
float val = 0.0;
void createGeometry() override
{
points.push_back({ 0, 0, static_cast<double>(i) });
scalars->push_back(i);
points.push_back({ 1, 0, static_cast<double>(i) });
scalars->push_back(i);
}
imstk::VecDataArray<double, 3> points;
auto scalars = std::make_shared<imstk::DataArray<float>>();
auto mesh = std::make_shared<imstk::SurfaceMesh>();
geom = mesh;
imstk::VecDataArray<int, 3> tris;
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris.push_back({ j + 2, j + 1, j });
tris.push_back({ j + 3, j + 1, j + 2 });
}
for (int i = 0; i < 6; ++i)
{
points.push_back({ 0, 0, static_cast<double>(i) });
scalars->push_back(i);
points.push_back({ 1, 0, static_cast<double>(i) });
scalars->push_back(i);
}
mesh->initialize(std::make_shared<VecDataArray<double, 3>>(points), std::make_shared<VecDataArray<int, 3>>(tris));
mesh->setVertexAttribute("scalars", scalars);
mesh->setVertexScalars("scalars");
auto mesh = std::make_shared<imstk::SurfaceMesh>();
geom = mesh;
std::shared_ptr<imstk::AbstractDataArray> abstracScalars = scalars;
imstk::VecDataArray<int, 3> tris;
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris.push_back({ j + 2, j + 1, j });
tris.push_back({ j + 3, j + 1, j + 2 });
}
auto onPreUpdate = [this, scalars, abstracScalars](Event*)
{
if (val < 6.0)
{
val += 0.05;
}
else
{
val = 0.0;
}
(*scalars)[0] = val;
(*scalars)[1] = val;
(*scalars)[2] = val;
(*scalars)[3] = val;
abstracScalars->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, onPreUpdate);
onPreUpdate(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
mesh->initialize(std::make_shared<VecDataArray<double, 3>>(points), std::make_shared<VecDataArray<int, 3>>(tris));
mesh->setVertexAttribute("scalars", scalars);
mesh->setVertexScalars("scalars");
std::shared_ptr<imstk::AbstractDataArray> abstracScalars = scalars;
auto onPreUpdate = [this, scalars, abstracScalars](Event*)
{
if (val < 6.0)
{
val += 0.05;
}
else
{
val = 0.0;
}
(*scalars)[0] = val;
(*scalars)[1] = val;
(*scalars)[2] = val;
(*scalars)[3] = val;
abstracScalars->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, onPreUpdate);
onPreUpdate(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
};
TEST_F(MeshColorFunctionVerticesRenderTest, meshColorFunctionVertices)
{
runFor(2);
}
class MeshColorFunctionCellsRenderTest : public RenderTest
{
public:
float val = 0.0;
void createGeometry() override
{
imstk::VecDataArray<double, 3> points;
auto scalars = std::make_shared<imstk::DataArray<float>>();
for (int i = 0; i < 6; ++i)
float val = 0.0;
void createGeometry() override
{
points.push_back({ 0, 0, static_cast<double>(i) });
points.push_back({ 1, 0, static_cast<double>(i) });
}
imstk::VecDataArray<double, 3> points;
auto scalars = std::make_shared<imstk::DataArray<float>>();
imstk::VecDataArray<int, 3> tris;
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris.push_back({ j + 2, j + 1, j });
scalars->push_back(i);
tris.push_back({ j + 3, j + 1, j + 2 });
scalars->push_back(i);
}
for (int i = 0; i < 6; ++i)
{
points.push_back({ 0, 0, static_cast<double>(i) });
points.push_back({ 1, 0, static_cast<double>(i) });
}
auto mesh = std::make_shared<imstk::SurfaceMesh>();
mesh->initialize(std::make_shared<VecDataArray<double, 3>>(points), std::make_shared<VecDataArray<int, 3>>(tris));
mesh->setCellAttribute("scalars", scalars);
mesh->setCellScalars("scalars");
geom = mesh;
imstk::VecDataArray<int, 3> tris;
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris.push_back({ j + 2, j + 1, j });
scalars->push_back(i);
tris.push_back({ j + 3, j + 1, j + 2 });
scalars->push_back(i);
}
auto onPreUpdate = [this, scalars](Event*)
{
if (val < 6.0)
{
val += 0.05;
}
else
{
val = 0.0;
}
(*scalars)[0] = val;
(*scalars)[1] = val;
(*scalars)[2] = val;
(*scalars)[3] = val;
scalars->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, onPreUpdate);
onPreUpdate(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
auto mesh = std::make_shared<imstk::SurfaceMesh>();
mesh->initialize(std::make_shared<VecDataArray<double, 3>>(points), std::make_shared<VecDataArray<int, 3>>(tris));
mesh->setCellAttribute("scalars", scalars);
mesh->setCellScalars("scalars");
geom = mesh;
auto onPreUpdate = [this, scalars](Event*)
{
if (val < 6.0)
{
val += 0.05;
}
else
{
val = 0.0;
}
(*scalars)[0] = val;
(*scalars)[1] = val;
(*scalars)[2] = val;
(*scalars)[3] = val;
scalars->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, onPreUpdate);
onPreUpdate(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
};
TEST_F(MeshColorFunctionCellsRenderTest, meshColorFunctionCells)
{
......@@ -174,52 +173,52 @@ class MeshColorFunctionDynamicVerticesRenderTest : public RenderTest
{
public:
double scale = 1.0;
void createGeometry() override
{
auto mesh = std::make_shared<imstk::SurfaceMesh>();
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->initialize(points, tris);
geom = mesh;
auto updateMesh = [this, mesh](Event*)
double scale = 1.0;
void createGeometry() override
{
scale += 0.01;
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->clear();
for (int i = 0; i < 6; ++i)
{
points->push_back({ 0, 0, static_cast<double>(i) });
scalars->push_back(i);
points->push_back({ 1 * scale, 0, static_cast<double>(i) });
scalars->push_back(i);
}
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris->push_back({ j + 2, j + 1, j });
tris->push_back({ j + 3, j + 1, j + 2 });
}
mesh->initialize(points, tris);
mesh->setVertexAttribute("scalars", scalars);
mesh->setVertexScalars("scalars");
mesh->computeVertexNormals();
mesh->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, updateMesh);
updateMesh(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
auto mesh = std::make_shared<imstk::SurfaceMesh>();
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->initialize(points, tris);
geom = mesh;
auto updateMesh = [this, mesh](Event*)
{
scale += 0.01;
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->clear();
for (int i = 0; i < 6; ++i)
{
points->push_back({ 0, 0, static_cast<double>(i) });
scalars->push_back(i);
points->push_back({ 1 * scale, 0, static_cast<double>(i) });
scalars->push_back(i);
}
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris->push_back({ j + 2, j + 1, j });
tris->push_back({ j + 3, j + 1, j + 2 });
}
mesh->initialize(points, tris);
mesh->setVertexAttribute("scalars", scalars);
mesh->setVertexScalars("scalars");
mesh->computeVertexNormals();
mesh->postModified();
};
connect<Event>(viewer, VTKViewer::preUpdate, updateMesh);
updateMesh(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
};
TEST_F(MeshColorFunctionDynamicVerticesRenderTest, meshColorFunctionDynamicVertices)
{
......@@ -230,52 +229,52 @@ class MeshColorFunctionDynamicCellsRenderTest : public RenderTest
{
public:
double scale = 1.0;
void createGeometry() override
{
auto mesh = std::make_shared<imstk::SurfaceMesh>();
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->initialize(points, tris);
geom = mesh;
auto updateMesh = [this, mesh](Event*)
double scale = 1.0;
void createGeometry() override
{
scale += 0.01;
auto mesh = std::make_shared<imstk::SurfaceMesh>();
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->clear();
for (int i = 0; i < 6; ++i)
{
points->push_back({ 0, 0, static_cast<double>(i) });
points->push_back({ 1*scale, 0, static_cast<double>(i) });
}
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris->push_back({ j + 2, j + 1, j });
scalars->push_back(i);
tris->push_back({ j + 3, j + 1, j + 2 });
scalars->push_back(i);
}
mesh->initialize(points, tris);
mesh->setCellAttribute("scalars", scalars);
mesh->setCellScalars("scalars");
mesh->computeVertexNormals();
mesh->postModified();
};
connect<Event>(viewer, viewer->preUpdate, updateMesh);
updateMesh(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
geom = mesh;
auto updateMesh = [this, mesh](Event*)
{
scale += 0.01;
auto points = std::make_shared<imstk::VecDataArray<double, 3>>();
auto tris = std::make_shared<imstk::VecDataArray<int, 3>>();
auto scalars = std::make_shared<imstk::DataArray<float>>();
mesh->clear();
for (int i = 0; i < 6; ++i)
{
points->push_back({ 0, 0, static_cast<double>(i) });
points->push_back({ 1 * scale, 0, static_cast<double>(i) });
}
for (int i = 0; i < 5; ++i)
{
int j = i * 2;
tris->push_back({ j + 2, j + 1, j });
scalars->push_back(i);
tris->push_back({ j + 3, j + 1, j + 2 });
scalars->push_back(i);
}
mesh->initialize(points, tris);
mesh->setCellAttribute("scalars", scalars);
mesh->setCellScalars("scalars");
mesh->computeVertexNormals();
mesh->postModified();
};
connect<Event>(viewer, viewer->preUpdate, updateMesh);
updateMesh(nullptr);
applyColorFunction();
scene->getActiveCamera()->setPosition(Vec3d(0, 12, 3));
scene->getActiveCamera()->setFocalPoint(Vec3d(0, 0, 3.01));
}
};
TEST_F(MeshColorFunctionDynamicCellsRenderTest, meshColorFunctionDynamicCells)
{
......
......@@ -23,213 +23,221 @@
#include "imstkColorFunction.h"
void RenderTest::SetUp()
void
RenderTest::SetUp()
{
scene = std::make_shared<Scene>("Render Test Scene");
scene->getActiveCamera()->setPosition(Vec3d(0.0, 1.0, -3.0));
scene = std::make_shared<Scene>("Render Test Scene");
scene->getActiveCamera()->setPosition(Vec3d(0.0, 1.0, -3.0));
viewer = std::make_shared<VTKViewer>("Viewer");
viewer->setActiveScene(scene);
viewer = std::make_shared<VTKViewer>("Viewer");
viewer->setActiveScene(scene);
// Setup a scene manager to advance the scene in its own thread
sceneManager = std::make_shared<SceneManager>("Scene Manager");
sceneManager->setExecutionType(Module::ExecutionType::ADAPTIVE);
sceneManager->setActiveScene(scene);
// Setup a scene manager to advance the scene in its own thread
sceneManager = std::make_shared<SceneManager>("Scene Manager");
sceneManager->setExecutionType(Module::ExecutionType::ADAPTIVE);
sceneManager->setActiveScene(scene);
driver = std::make_shared<SimulationManager>();
driver->addModule(viewer);
driver->addModule(sceneManager);
driver = std::make_shared<SimulationManager>();
driver->addModule(viewer);
driver->addModule(sceneManager);
mouseControl = std::make_shared<MouseSceneControl>(viewer->getMouseDevice());
mouseControl->setSceneManager(sceneManager);
viewer->addControl(mouseControl);
mouseControl = std::make_shared<MouseSceneControl>(viewer->getMouseDevice());
mouseControl->setSceneManager(sceneManager);
viewer->addControl(mouseControl);
keyControl = std::make_shared<KeyboardSceneControl>(viewer->getKeyboardDevice());
keyControl->setSceneManager(sceneManager);
keyControl->setModuleDriver(driver);
viewer->addControl(keyControl);
keyControl = std::make_shared<KeyboardSceneControl>(viewer->getKeyboardDevice());
keyControl->setSceneManager(sceneManager);
keyControl->setModuleDriver(driver);
viewer->addControl(keyControl);
renderMaterial = std::make_shared<RenderMaterial>();
renderMaterial = std::make_shared<RenderMaterial>();
createGeometry();
createGeometry();
ASSERT_TRUE(geom != nullptr) << "ERROR: No geometry";
ASSERT_TRUE(geom != nullptr) << "ERROR: No geometry";
visualModel = std::make_shared<VisualModel>(geom);
visualModel->setRenderMaterial(renderMaterial);
visualModel = std::make_shared<VisualModel>(geom);
visualModel->setRenderMaterial(renderMaterial);
sceneObj = std::make_shared<SceneObject>("SceneObject");
sceneObj->addVisualModel(visualModel);
scene->addSceneObject(sceneObj);
sceneObj = std::make_shared<SceneObject>("SceneObject");
sceneObj->addVisualModel(visualModel);
scene->addSceneObject(sceneObj);
driver->requestStatus(ModuleDriverRunning);
driver->requestStatus(ModuleDriverRunning);
}
void RenderTest::runFor(int seconds)
void
RenderTest::runFor(int seconds)
{
std::thread t(&SimulationManager::start, driver);
std::this_thread::sleep_for(std::chrono::seconds(seconds));