Commit 97e3efb7 authored by Nghia Truong's avatar Nghia Truong

STYLE: Reformat files with new uncrustify config

parent c9afd8df
......@@ -31,7 +31,8 @@
using namespace imstk;
void playSound(const std::string& filename)
void
playSound(const std::string& filename)
{
#ifdef iMSTK_AUDIO_ENABLED
// Load a sound buffer from a .wav file
......@@ -77,7 +78,8 @@ void playSound(const std::string& filename)
#endif
}
void playMusic(const std::string& filename)
void
playMusic(const std::string& filename)
{
#ifdef iMSTK_AUDIO_ENABLED
// Load an ogg music file
......@@ -117,7 +119,8 @@ void playMusic(const std::string& filename)
/// \brief This example demonstrates the audio feature in imstk.
/// NOTE: Example modified from SFML/Examples
///
int main()
int
main()
{
// Initialize g3logger
auto logger = std::make_shared<LogUtility>();
......
......@@ -54,10 +54,11 @@ using namespace imstk;
/// \brief This example demonstrates bone drilling.
/// NOTE: Requires GeoMagic Touch device
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("BoneDrilling");
// Add virtual coupling object in the scene.
......@@ -103,7 +104,7 @@ int main()
// Create a collision graph
auto graph = scene->getCollisionGraph();
auto pair = graph->addInteractionPair(bone,
auto pair = graph->addInteractionPair(bone,
drill,
CollisionDetection::Type::PointSetToSphere,
CollisionHandling::Type::BoneDrilling,
......
......@@ -38,7 +38,8 @@ using namespace imstk;
/// \brief This example demonstrates controlling the camera
/// using external device. NOTE: Requires GeoMagic Touch device
///
int main()
int
main()
{
#ifndef iMSTK_USE_OPENHAPTICS
std::cout << "Audio not enabled at build time" << std::endl;
......@@ -46,7 +47,7 @@ int main()
#endif
// Create SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("CameraController");
#ifdef iMSTK_USE_OPENHAPTICS
......@@ -62,7 +63,7 @@ int main()
#endif
// Load Mesh
auto mesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj");
auto mesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj");
auto meshObject = std::make_shared<VisualObject>("meshObject");
meshObject->setVisualGeometry(mesh);
scene->addSceneObject(meshObject);
......
......@@ -40,10 +40,11 @@ using namespace imstk;
/// \brief This example demonstrates the soft body simulation
/// using Finite elements
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("DeformableBodyFEM");
scene->getCamera()->setPosition(0, 2.0, 15.0);
......@@ -56,7 +57,7 @@ int main()
}
// Extract the surface mesh
auto surfMesh = std::make_shared<SurfaceMesh>();
auto surfMesh = std::make_shared<SurfaceMesh>();
auto volTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(tetMesh);
if (!volTetMesh)
{
......@@ -66,7 +67,7 @@ int main()
volTetMesh->extractSurfaceMesh(surfMesh, true);
StopWatch wct;
CpuTimer cput;
CpuTimer cput;
wct.start();
cput.start();
......@@ -123,8 +124,8 @@ int main()
// create a linear solver
auto linSolver = std::make_shared<ConjugateGradient>();
if (linSolver->getType() == imstk::LinearSolver<imstk::SparseMatrixd>::Type::GaussSeidel &&
dynaModel->isFixedBCImplemented())
if (linSolver->getType() == imstk::LinearSolver<imstk::SparseMatrixd>::Type::GaussSeidel
&& dynaModel->isFixedBCImplemented())
{
LOG(WARNING) << "The GS solver may not be viable!";
}
......
......@@ -28,14 +28,15 @@ using namespace imstk;
/// \brief This example shows how to extract the triangular surface
/// mesh from a volumetric tetrahedral mesh
///
void extractSurfaceMesh()
void
extractSurfaceMesh()
{
auto sdk = std::make_shared<SimulationManager>();
// a. Construct a sample tetrahedral mesh
// a.1 add vertex positions
auto tetMesh = std::make_shared<TetrahedralMesh>();
auto tetMesh = std::make_shared<TetrahedralMesh>();
StdVectorOfVec3d vertList;
vertList.push_back(Vec3d(0, 0, 0));
vertList.push_back(Vec3d(1.0, 0, 0));
......@@ -47,8 +48,8 @@ void extractSurfaceMesh()
// a.2 add connectivity
std::vector<TetrahedralMesh::TetraArray> tetConnectivity;
TetrahedralMesh::TetraArray tet1 = { 0, 1, 2, 3 };
TetrahedralMesh::TetraArray tet2 = { 1, 2, 3, 4 };
TetrahedralMesh::TetraArray tet1 = { 0, 1, 2, 3 };
TetrahedralMesh::TetraArray tet2 = { 1, 2, 3, 4 };
tetConnectivity.push_back(tet1);
tetConnectivity.push_back(tet2);
tetMesh->setTetrahedraVertices(tetConnectivity);
......@@ -71,7 +72,8 @@ void extractSurfaceMesh()
getchar();
}
int main()
int
main()
{
extractSurfaceMesh();
......
......@@ -32,15 +32,16 @@ using namespace imstk;
/// \brief This example demonstrates the GUI feature.
/// NOTE: Requires enabling Vulkan rendering backend
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("GraphicalUserInterface");
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("GraphicalUserInterface");
auto canvas = sdk->getViewer()->getCanvas();
// Cube
auto cube = apiutils::createVisualAnalyticalSceneObject(Geometry::Type::Cube, scene, "cube", 0.5);
auto cube = apiutils::createVisualAnalyticalSceneObject(Geometry::Type::Cube, scene, "cube", 0.5);
auto sphere = std::make_shared<Sphere>();
cube->getVisualModel(0)->getGeometry()->translate(0, 0, 0);
cube->getVisualModel(0)->getGeometry()->rotate(UP_VECTOR, PI_4);
......@@ -49,16 +50,16 @@ int main()
auto plane = apiutils::createVisualAnalyticalSceneObject(Geometry::Type::Plane, scene, "plane", 10);
// Window logic
auto window = std::make_shared<GUIOverlay::Window>("Test Window", "Test Window", 200.0f, 100.0f, 200.0f, 0.0f);
auto window = std::make_shared<GUIOverlay::Window>("Test Window", "Test Window", 200.0f, 100.0f, 200.0f, 0.0f);
auto windowText = std::make_shared<GUIOverlay::Text>("Window Text", "Window Text", 0.0f, 0.0f);
window->addWidget(windowText);
auto circle = std::make_shared<GUIOverlay::Circle>("Circle", 100.0f, 100.0f, 25.0f, Color::Red, true);
auto circle = std::make_shared<GUIOverlay::Circle>("Circle", 100.0f, 100.0f, 25.0f, Color::Red, true);
auto circleOutline = std::make_shared<GUIOverlay::Circle>("CircleOutline", 100.0f, 100.0f, 25.0f, Color::Black, false);
// These two rectangles show that the ordering matters
auto underRectangle = std::make_shared<GUIOverlay::Rectangle>("UnderRectangle", 100.0f, 100.0f, 100.0f, 100.0f, Color(0.0f, 0.0f, 1.0f, 0.7f), true);
auto overRectangle = std::make_shared<GUIOverlay::Rectangle>("OverRectangle", 0.0f, 0.0f, 100.0f, 100.0f, Color(0.7f, 0.0f, 1.0f, 0.7f), true);
auto overRectangle = std::make_shared<GUIOverlay::Rectangle>("OverRectangle", 0.0f, 0.0f, 100.0f, 100.0f, Color(0.7f, 0.0f, 1.0f, 0.7f), true);
canvas->addWidget(underRectangle);
canvas->addWidget(circle);
......@@ -69,13 +70,13 @@ int main()
StopWatch watch;
watch.start();
auto startTime = watch.getTimeElapsed();
auto lastTime = startTime;
auto lastTime = startTime;
// Update function
auto GUIUpdateFunction =
[&](InteractorStyle* style) -> bool
{
auto time = watch.getTimeElapsed();
auto time = watch.getTimeElapsed();
float angle = time / 1000.0f;
circle->setPosition(std::sin(angle) * 50.0f + 100.0f, std::cos(angle) * 50.0f + 100.0f);
circle->setRadius(std::abs(std::sin(angle)) * 25.0f);
......@@ -92,7 +93,7 @@ int main()
};
sdk->getViewer()->setOnTimerFunction(GUIUpdateFunction);
bool canvasVisible = true;
bool canvasVisible = true;
auto hideShowCanvasFunction =
[&](InteractorStyle* style) -> bool
{
......
......@@ -31,10 +31,11 @@ using namespace imstk;
///
/// \brief This example demonstrates the geometry transforms in imstk
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("GeometryTransforms");
auto sceneObj = apiutils::createAndAddVisualSceneObject(scene, iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj", "Dragon");
......
......@@ -32,7 +32,8 @@ using namespace imstk;
/// Usage: Example-Graph.exe [method=greedy/welsh-powell]
/// (if no method was specified, WelshPowell method will be used)
///
int main(int argc, char** argv)
int
main(int argc, char** argv)
{
// Using WelshPowell method by default
Graph::ColoringMethod method = Graph::ColoringMethod::WelshPowell;
......@@ -40,8 +41,8 @@ int main(int argc, char** argv)
if (argc > 1)
{
auto param = std::string(argv[1]);
if (param.find("method") == 0 &&
param.find_first_of("=") != std::string::npos)
if (param.find("method") == 0
&& param.find_first_of("=") != std::string::npos)
{
if (param.substr(param.find_first_of("=") + 1) == "greedy")
{
......@@ -56,7 +57,7 @@ int main(int argc, char** argv)
std::cout << (method == Graph::ColoringMethod::Greedy ?
"Graph coloring method: Greedy" :
"Graph coloring method: WelshPowell" ) << std::endl << std::endl;
"Graph coloring method: WelshPowell") << std::endl << std::endl;
Graph g1(5);
g1.addEdge(0, 1);
......
......@@ -32,30 +32,31 @@ using namespace imstk;
///
/// \brief This example demonstrates line mesh rendering
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("LineMeshRenderingTest");
// Construct line mesh
auto lineMesh = std::make_shared<LineMesh>();
auto lineMesh = std::make_shared<LineMesh>();
auto lineMeshMaterial = std::make_shared<RenderMaterial>();
lineMeshMaterial->setLineWidth(3);
auto lineObject = std::make_shared<VisualObject>("lineMesh");
std::vector<LineMesh::LineArray> lines;
StdVectorOfVec3d points;
std::vector<Color> colors;
StdVectorOfVec3d points;
std::vector<Color> colors;
size_t resolution = 16;
size_t numVoxels = resolution * resolution * resolution;
size_t numVoxels = resolution * resolution * resolution;
points.resize(numVoxels * 8);
colors.resize(numVoxels * 8);
lines.resize(numVoxels * 12);
size_t index = 0;
size_t index = 0;
size_t lineIndex = 0;
for (int z = 0; z < resolution; z++)
......@@ -102,16 +103,16 @@ int main()
lines[lineIndex + 7][0] = index + 5;
lines[lineIndex + 7][1] = index + 7;
lines[lineIndex + 8][0] = index + 0;
lines[lineIndex + 8][1] = index + 4;
lines[lineIndex + 9][0] = index + 1;
lines[lineIndex + 9][1] = index + 5;
lines[lineIndex + 8][0] = index + 0;
lines[lineIndex + 8][1] = index + 4;
lines[lineIndex + 9][0] = index + 1;
lines[lineIndex + 9][1] = index + 5;
lines[lineIndex + 10][0] = index + 2;
lines[lineIndex + 10][1] = index + 6;
lines[lineIndex + 11][0] = index + 3;
lines[lineIndex + 11][1] = index + 7;
index += 8;
index += 8;
lineIndex += 12;
}
}
......
......@@ -28,10 +28,11 @@ using namespace imstk;
///
/// \brief This example demonstrates I/O of the mesh
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("ReadMesh");
// Read surface mesh
......
......@@ -28,15 +28,16 @@ using namespace imstk;
///
/// \brief This example shows how to read .msh and .veg files
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("MshAndVegaIO");
// Load a volumetric mesh (from .msh file)
std::string ifile = iMSTK_DATA_ROOT "/liver/liver.msh";
auto volMeshA = MeshIO::read(ifile);
std::string ifile = iMSTK_DATA_ROOT "/liver/liver.msh";
auto volMeshA = MeshIO::read(ifile);
if (!volMeshA)
{
LOG(WARNING) << "Failed to read msh file : " << ifile;
......@@ -55,8 +56,8 @@ int main()
objectA->setVisualGeometry(surfaceMeshA);
// Write a .veg file
std::string ofile = iMSTK_DATA_ROOT "/liver/liver.veg";
auto writeStatus = MeshIO::write(volMeshA, ofile);
std::string ofile = iMSTK_DATA_ROOT "/liver/liver.veg";
auto writeStatus = MeshIO::write(volMeshA, ofile);
std::cout << "------------------------------Summary----------------------------------------------------\n";
std::cout << "Following file conversion: " << ((writeStatus) ? "Success \n" : "Failure \n");
std::cout << "\n Input mesh file : \n" << ifile << std::endl;
......
......@@ -37,19 +37,20 @@ using namespace imstk;
/// \brief This example demonstrates the cloth simulation without any rendering
/// using Position based dynamics
///
int main()
int
main()
{
auto sdk = std::make_shared<SimulationManager>(SimulationManager::Mode::runInBackground);
auto sdk = std::make_shared<SimulationManager>(SimulationManager::Mode::runInBackground);
auto scene = sdk->createNewScene("NoRendering");
// Create surface mesh
auto surfMesh = std::make_shared<SurfaceMesh>();
auto surfMesh = std::make_shared<SurfaceMesh>();
StdVectorOfVec3d vertList;
const double width = 10.0;
const double height = 10.0;
static const int nRows = 5;
static const int nCols = 5;
const double epsilon = 1e-5;
const double width = 10.0;
const double height = 10.0;
static const int nRows = 5;
static const int nCols = 5;
const double epsilon = 1e-5;
vertList.resize(nRows * nCols);
const double dy = width / (double)(nCols - 1);
const double dx = height / (double)(nRows - 1);
......@@ -76,7 +77,7 @@ int main()
for (std::size_t j = 0; j < nCols - 1; j++)
{
SurfaceMesh::TriangleArray tri[2];
tri[0] = { { i*nCols + j, (i + 1) * nCols + j, i * nCols + j + 1 } };
tri[0] = { { i* nCols + j, (i + 1) * nCols + j, i * nCols + j + 1 } };
tri[1] = { { (i + 1) * nCols + j + 1, i * nCols + j + 1, (i + 1) * nCols + j } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
......@@ -87,7 +88,7 @@ int main()
// Create Object & Model
auto deformableObj = std::make_shared<PbdObject>("Cloth");
auto pbdModel = std::make_shared<PbdModel>();
auto pbdModel = std::make_shared<PbdModel>();
pbdModel->setModelGeometry(surfMesh);
// configure model
......@@ -96,13 +97,13 @@ int main()
// Constraints
pbdParams->enableConstraint(PbdConstraint::Type::Distance, 0.1);
pbdParams->enableConstraint(PbdConstraint::Type::Dihedral, 0.001);
pbdParams->m_fixedNodeIds = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
pbdParams->m_fixedNodeIds = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
// Other parameters
pbdParams->m_uniformMassValue = 1.0;
pbdParams->m_gravity = Vec3d(0, -9.8, 0);
pbdParams->m_dt = 0.03;
pbdParams->m_maxIter = 5;
pbdParams->m_gravity = Vec3d(0, -9.8, 0);
pbdParams->m_dt = 0.03;
pbdParams->m_maxIter = 5;
pbdModel->configure(pbdParams);
deformableObj->setDynamicalModel(pbdModel);
......@@ -129,7 +130,7 @@ int main()
apiutils::printUPS(sdk->getSceneManager(scene), ups);
// Method to call after the simulation is done running
static StdVectorOfVec3d lastPositions; // Vertex positions at the last iteration
static StdVectorOfVec3d lastPositions; // Vertex positions at the last iteration
lastPositions.resize(nRows * nCols);
static StdVectorOfVec3d beforeLastPositions; // Vertex positions at the (N-1) iteration
beforeLastPositions.resize(nRows * nCols);
......@@ -143,7 +144,7 @@ int main()
for (int j = 0; j < nCols; j++)
{
beforeLastPositions[i * nCols + j] = lastPositions[i * nCols + j];
lastPositions[i * nCols + j] = newPositions[i * nCols + j];
lastPositions[i * nCols + j] = newPositions[i * nCols + j];
}
}
};
......@@ -187,7 +188,7 @@ int main()
Vec3d(3.13296, -6.54906, 8.61026),
};
bool sameLastStateSuccess = true;
bool sameLastStateSuccess = true;
bool expectedLastStateSuccess = true;
for (int i = 0; i < nRows; ++i)
{
......
......@@ -34,11 +34,12 @@ using namespace imstk;
/// \brief This example demonstrates controlling the object
/// using external device. NOTE: Requires GeoMagic Touch device
///
int main()
int
main()
{
#ifdef iMSTK_USE_OPENHAPTICS
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("ObjectController");
// Device Client
......
......@@ -30,10 +30,11 @@ using namespace imstk;
/// \brief This example demonstrates controlling the object
/// using a simulated tracker: dummy client
///
int main()
int
main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("ObjectControllerDummyClient");
// Device Client
......
......@@ -31,18 +31,19 @@ using namespace imstk;
/// \brief This example demonstrates the cloth simulation
/// using Position based dynamics
///
int main()
int
main()
{
auto sdk = std::make_shared<SimulationManager>();
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDCloth");
// Create surface mesh
auto surfMesh = std::make_shared<SurfaceMesh>();
auto surfMesh = std::make_shared<SurfaceMesh>();
StdVectorOfVec3d vertList;
const double width = 10.0;
const double height = 10.0;
const int nRows = 11;
const int nCols = 11;
const double width = 10.0;
const double height = 10.0;
const int nRows = 11;
const int nCols = 11;
vertList.resize(nRows * nCols);
const double dy = width / (double)(nCols - 1);
const double dx = height / (double)(nRows - 1);
......@@ -63,7 +64,7 @@ int main()
for (std::size_t j = 0; j < nCols - 1; j++)
{
SurfaceMesh::TriangleArray tri[2];
tri[0] = { { i*nCols + j, (i + 1) * nCols + j, i * nCols + j + 1 } };
tri[0] = { { i* nCols + j, (i + 1) * nCols + j, i * nCols + j + 1 } };
tri[1] = { { (i + 1) * nCols + j + 1, i * nCols + j + 1, (i + 1) * nCols + j } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
......@@ -74,7 +75,7 @@ int main()
// Create Object & Model
auto deformableObj = std::make_shared<PbdObject>("Cloth");
auto pbdModel = std::make_shared<PbdModel>();
auto pbdModel = std::make_shared<PbdModel>();
pbdModel->setModelGeometry(surfMesh);
// configure model
......@@ -83,13 +84,13 @@ int main()
// Constraints
pbdParams->enableConstraint(PbdConstraint::Type::Distance, 0.1);