Commit ffccb186 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

Revert "Merge branch 'NoRenderingOption' into 'master'"

This reverts merge request !286
parent 97a875d1
Pipeline #132861 passed with stage
......@@ -120,6 +120,5 @@ ExternalProject_Add( ${PROJECT_NAME}
-D${PROJECT_NAME}_USE_Vulkan:BOOL=${${PROJECT_NAME}_USE_Vulkan}
-D${PROJECT_NAME}_ENABLE_AUDIO:BOOL=${${PROJECT_NAME}_ENABLE_AUDIO}
-D${PROJECT_NAME}_ENABLE_VR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-D${PROJECT_NAME}_WITH_RENDERING:BOOL=${${PROJECT_NAME}_WITH_RENDERING}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
)
......@@ -9,12 +9,6 @@ endif(${${PROJECT_NAME}_ENABLE_VR})
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
if(${iMSTK_WITH_RENDERING})
set(rendering_backend "OpenGL2")
else()
set(rendering_backend "None")
endif()
include(imstkAddExternalProject)
imstk_add_external_project( VTK
GIT_REPOSITORY https://gitlab.kitware.com/vtk/vtk.git
......@@ -24,22 +18,19 @@ imstk_add_external_project( VTK
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DVTK_Group_StandAlone:BOOL=OFF
-DVTK_Group_Rendering:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingOpenGL2:BOOL=${iMSTK_WITH_RENDERING}
-DVTK_Group_Rendering:BOOL=OFF
-DModule_vtkRenderingOpenGL2:BOOL=ON
-DModule_vtkIOXML:BOOL=ON
-DModule_vtkIOLegacy:BOOL=ON
-DModule_vtkIOPLY:BOOL=ON
-DModule_vtkIOGeometry:BOOL=ON
-DModule_vtkInteractionStyle:BOOL=ON
-DModule_vtkRenderingAnnotation:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingAnnotation:BOOL=ON
-DModule_vtkRenderingOpenVR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-DModule_vtkInteractionWidgets:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkglew:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkRenderingContext2D:BOOL=${iMSTK_WITH_RENDERING}
-DModule_vtkFiltersCore:BOOL=ON
-DModule_vtkRenderingCore:BOOL=ON
-DModule_vtkImagingCore:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=${rendering_backend}
-DModule_vtkInteractionWidgets:BOOL=ON
-DModule_vtkglew:BOOL=ON
-DModule_vtkRenderingContext2D:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_WRAP_PYTHON:BOOL=OFF
-DVTK_OPENVR_OBJECT_FACTORY:BOOL=OFF
-DVTK_LEGACY_REMOVE:BOOL=ON
......
......@@ -18,8 +18,7 @@ set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utilities
${CMAKE_MODULE_PATH}
)
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
include(CMakeDependentOption)
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
......@@ -80,7 +79,6 @@ endif()
# Options
#-----------------------------------------------------------------------------
option(BUILD_EXAMPLES "Build iMSTK examples" ON)
option(${PROJECT_NAME}_WITH_RENDERING "Build ${PROJECT_NAME} with rendering." ON)
#-----------------------------------------------------------------------------
# SUPERBUILD
......@@ -103,15 +101,17 @@ if(${PROJECT_NAME}_SUPERBUILD)
imstk_define_dependency(Uncrustify)
endif()
option(${PROJECT_NAME}_USE_Vulkan "Use the custom Vulkan renderer." OFF)
imstk_define_dependency(glm)
cmake_dependent_option(${PROJECT_NAME}_ENABLE_VR "Allow the usage of VR rendering." OFF "${PROJECT_NAME}_WITH_RENDERING" OFF)
if(${PROJECT_NAME}_USE_Vulkan)
imstk_define_dependency(glfw)
imstk_define_dependency(gli)
endif()
cmake_dependent_option(${PROJECT_NAME}_USE_Vulkan "Use the custom Vulkan renderer." OFF "${PROJECT_NAME}_WITH_RENDERING" OFF)
option(${PROJECT_NAME}_ENABLE_VR "Allow the usage of VR rendering." OFF)
if(${PROJECT_NAME}_ENABLE_VR)
imstk_define_dependency(openvr)
endif()
......@@ -324,13 +324,6 @@ if(BUILD_TESTING)
include_directories(${GoogleMock_INCLUDE_DIRS})
endif()
# Rendering definition
if(${PROJECT_NAME}_WITH_RENDERING)
add_definitions( -DiMSTK_WITH_RENDERING )
else()
remove_definitions( -DiMSTK_WITH_RENDERING )
endif()
# External data
if(BUILD_TESTING OR BUILD_EXAMPLES)
include(imstkExternalData)
......
###########################################################################
#
# Copyright (c) Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
if(NOT iMSTK_WITH_RENDERING)
project(Example-NoRendering)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} noRenderingExample.cpp)
#-----------------------------------------------------------------------------
# Add shaders
#-----------------------------------------------------------------------------
include(imstkCopyAndCompileShaders)
CopyAndCompileShaders()
#-----------------------------------------------------------------------------
# Link libraries to executable
#-----------------------------------------------------------------------------
target_link_libraries(${PROJECT_NAME} SimulationManager)
endif()
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include "imstkSimulationManager.h"
#include "imstkPbdObject.h"
#include "imstkPbdSolver.h"
#include "imstkAPIUtilities.h"
#include "vtkMathUtilities.h"
#include <chrono>
#include <thread>
using namespace imstk;
///
/// \brief This example demonstrates the cloth simulation without any rendering
/// using Position based dynamics
///
int main()
{
#ifdef iMSTK_WITH_RENDERING
std::cerr << "This example should only be used when iMSTK is built with"
<< " iMSTK_WITH_RENDERING off." << std::endl;
return EXIT_SUCCESS;
#else
auto sdk = std::make_shared<SimulationManager>(false);
auto scene = sdk->createNewScene("NoRendering");
// Create surface mesh
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;
vertList.resize(nRows*nCols);
const double dy = width / (double)(nCols - 1);
const double dx = height / (double)(nRows - 1);
std::cout << " initialPositions = {" << std::endl;
for (int i = 0; i < nRows; ++i)
{
for (int j = 0; j < nCols; j++)
{
vertList[i*nCols + j] = Vec3d((double)dx*i, 1.0, (double)dy*j);
std::cout << vertList[i*nCols + j][0] << ", "
<< vertList[i*nCols + j][1] << ", "
<< vertList[i*nCols + j][2] << ", ";
}
std::cout << std::endl;
}
std::cout << "}" << std::endl;
surfMesh->setInitialVertexPositions(vertList);
surfMesh->setVertexPositions(vertList);
// Add connectivity data
std::vector<SurfaceMesh::TriangleArray> triangles;
for (std::size_t i = 0; i < nRows - 1; ++i)
{
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[1] = { { (i + 1)*nCols + j + 1, i*nCols + j + 1, (i + 1)*nCols + j } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
}
}
surfMesh->setTrianglesVertices(triangles);
// Create Object & Model
auto deformableObj = std::make_shared<PbdObject>("Cloth");
auto pbdModel = std::make_shared<PbdModel>();
pbdModel->setModelGeometry(surfMesh);
pbdModel->configure(/*Number of constraints*/ 2,
/*Constraint configuration*/ "Distance 0.1",
/*Constraint configuration*/ "Dihedral 0.001",
/*Mass*/ 1.0,
/*Gravity*/ "0 -9.8 0",
/*TimeStep*/ 0.03,
/*FixedPoint*/ "1 2 3 4 5 6 7 8 9 10 11",
/*NumberOfIterationInConstraintSolver*/ 5);
deformableObj->setDynamicalModel(pbdModel);
deformableObj->setPhysicsGeometry(surfMesh);
auto material = std::make_shared<RenderMaterial>();
material->setBackFaceCulling(false);
material->setColor(Color::LightGray);
material->setDisplayMode(RenderMaterial::DisplayMode::WIREFRAME_SURFACE);
auto surfMeshModel = std::make_shared<VisualModel>(surfMesh);
surfMeshModel->setRenderMaterial(material);
deformableObj->addVisualModel(surfMeshModel);
// Solver
auto pbdSolver = std::make_shared<PbdSolver>();
pbdSolver->setPbdObject(deformableObj);
scene->addNonlinearSolver(pbdSolver);
// Add in scene
scene->addSceneObject(deformableObj);
// print UPS
auto ups = std::make_shared<UPSCounter>();
apiutils::printUPS(sdk->getSceneManager(scene), ups);
// Method to call after the simulation is done running
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);
auto func =
[&surfMesh](Module* module)
{
auto newPositions = surfMesh->getVertexPositions();
for (int i = 0; i < nRows; ++i)
{
for (int j = 0; j < nCols; j++)
{
beforeLastPositions[i*nCols + j] = lastPositions[i*nCols + j];
lastPositions[i*nCols + j] = newPositions[i*nCols + j];
}
}
};
sdk->getSceneManager(scene)->setPostUpdateCallback(func);
// Start
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
// Sleep
std::this_thread::sleep_for(std::chrono::seconds(300));
// End
sdk->endSimulation();
const std::vector<Vec3d> expectedFinalPositions = {
Vec3d(0, 1, 0),
Vec3d(0, 1, 2.5),
Vec3d(0, 1, 5),
Vec3d(0, 1, 7.5),
Vec3d(0, 1, 10),
Vec3d(2.5, 1, 0),
Vec3d(2.5, 1, 2.5),
Vec3d(2.5, 1, 5),
Vec3d(2.5, 1, 7.5),
Vec3d(2.5, 1, 10),
Vec3d(5, 1, 0),
Vec3d(4.82032, 0.151579, 2.47237),
Vec3d(4.44397, -0.540266, 4.95431),
Vec3d(3.90422, -1.05503, 7.38393),
Vec3d(2.84115, -1.52265, 9.57745),
Vec3d(5.42292, -1.55528, -0.406832),
Vec3d(5.15428, -2.3468, 2.05675),
Vec3d(4.66615, -3.00741, 4.48803),
Vec3d(3.91197, -3.54776, 6.83235),
Vec3d(2.99625, -4.06199, 9.09933),
Vec3d(5.48704, -4.10154, -0.904475),
Vec3d(5.14791, -4.83293, 1.51491),
Vec3d(4.62851, -5.46666, 3.92927),
Vec3d(3.94636, -6.01879, 6.29803),
Vec3d(3.13296, -6.54906, 8.61026),
};
bool sameLastStateSuccess = true;
bool expectedLastStateSuccess = true;
for (int i = 0; i < nRows; ++i)
{
for (int j = 0; j < nCols; j++)
{
std::cout << lastPositions[i*nCols + j][0] << ", " << lastPositions[i*nCols + j][1] << ", " << lastPositions[i*nCols + j][2] << ", " << std::endl;
}
}
for (int i = 0; i < nRows; ++i)
{
for (int j = 0; j < nCols; j++)
{
for (int k = 0; k < 3; ++k)
{
sameLastStateSuccess &= vtkMathUtilities::FuzzyCompare(
beforeLastPositions[i*nCols + j][k], lastPositions[i*nCols + j][k], epsilon);
expectedLastStateSuccess &= vtkMathUtilities::FuzzyCompare(
lastPositions[i*nCols + j][k], expectedFinalPositions[i*nCols + j][k]);
if (!expectedLastStateSuccess)
{
std::cout << lastPositions[i*nCols + j][k] << " " << expectedFinalPositions[i*nCols + j][k]<< std::endl;
expectedLastStateSuccess = true;
}
}
}
}
if (!sameLastStateSuccess)
{
std::cerr << "Error: simulation did not converge" << std::endl;
return EXIT_FAILURE;
}
if (!expectedLastStateSuccess)
{
std::cerr << "Error: last state positions are wrong" << std::endl;
return EXIT_FAILURE;
}
return 0;
#endif
}
......@@ -83,7 +83,6 @@ int main()
cam1->setPosition(Vec3d(-5.5, 2.5, 32));
cam1->setFocalPoint(Vec3d(1, 1, 0));
#ifdef iMSTK_WITH_RENDERING
#ifndef iMSTK_USE_Vulkan
auto viewer = sdk->getViewer();
auto screenShotUtility
......@@ -96,7 +95,6 @@ int main()
screenShotUtility->saveScreenShot();
return false;
});
#endif
#endif
std::cout << "PRESS 'b' for taking screenshot" << std::endl;
......
......@@ -85,27 +85,26 @@ set(VULKAN_CPP_FILES
VulkanRenderer/PostProcessing/imstkVulkanPostProcess.cpp
VulkanRenderer/PostProcessing/imstkVulkanPostProcessingChain.cpp)
if(${iMSTK_WITH_RENDERING})
if( NOT iMSTK_USE_Vulkan )
set(RENDERING_H_FILES ${VTK_H_FILES})
set(RENDERING_CPP_FILES ${VTK_CPP_FILES})
set(RENDERING_SUBDIR
VTKRenderer
VTKRenderer/RenderDelegate)
set(RENDERING_DEPENDENCIES)
else()
set(RENDERING_H_FILES ${VULKAN_H_FILES})
set(RENDERING_CPP_FILES ${VULKAN_CPP_FILES})
set(RENDERING_SUBDIR
VulkanRenderer
VulkanRenderer/RenderDelegate
VulkanRenderer/PostProcessing)
set(RENDERING_DEPENDENCIES
${VulkanSDK_LIBRARIES}
glfw
gli
)
endif()
if( NOT iMSTK_USE_Vulkan )
set(RENDERING_H_FILES ${VTK_H_FILES})
set(RENDERING_CPP_FILES ${VTK_CPP_FILES})
set(RENDERING_SUBDIR
VTKRenderer
VTKRenderer/RenderDelegate)
set(RENDERING_DEPENDENCIES
GUIOverlay)
else()
set(RENDERING_H_FILES ${VULKAN_H_FILES})
set(RENDERING_CPP_FILES ${VULKAN_CPP_FILES})
set(RENDERING_SUBDIR
VulkanRenderer
VulkanRenderer/RenderDelegate
VulkanRenderer/PostProcessing)
set(RENDERING_DEPENDENCIES
${VulkanSDK_LIBRARIES}
glfw
gli
GUIOverlay)
endif()
include(imstkAddLibrary)
......@@ -126,7 +125,6 @@ imstk_add_library( Rendering
Scene
Animation
glm
GUIOverlay
#VERBOSE
)
......
......@@ -24,18 +24,16 @@ set(VULKAN_CPP_FILES
VulkanRenderer/imstkVulkanScreenCaptureUtility.cpp
VulkanRenderer/imstkVulkanViewer.cpp)
if(${iMSTK_WITH_RENDERING})
if( NOT iMSTK_USE_Vulkan )
set(SIMULATIONMANAGER_H_FILES ${VTK_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VTK_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VTKRenderer)
else()
set(SIMULATIONMANAGER_H_FILES ${VULKAN_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VULKAN_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VulkanRenderer)
endif()
if( NOT iMSTK_USE_Vulkan )
set(SIMULATIONMANAGER_H_FILES ${VTK_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VTK_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VTKRenderer)
else()
set(SIMULATIONMANAGER_H_FILES ${VULKAN_H_FILES})
set(SIMULATIONMANAGER_CPP_FILES ${VULKAN_CPP_FILES})
set(SIMULATIONMANAGER_SUBDIR
VulkanRenderer)
endif()
include(imstkAddLibrary)
......@@ -62,7 +60,6 @@ imstk_add_library( SimulationManager
Rendering
Devices
Collision
GUIOverlay
)
#-----------------------------------------------------------------------------
......
......@@ -34,7 +34,6 @@ SimulationManager::SimulationManager(const bool disableRendering, const bool ena
if (!disableRendering)
{
#ifdef iMSTK_WITH_RENDERING
#ifdef iMSTK_USE_Vulkan
m_viewer = std::make_shared<VulkanViewer>(this);
#else
......@@ -49,7 +48,6 @@ SimulationManager::SimulationManager(const bool disableRendering, const bool ena
}
m_viewer = std::make_shared<VTKViewer>(this, false);
#endif
#endif
#endif
}
}
......
......@@ -33,13 +33,11 @@
#include "imstkLogUtility.h"
#include "imstkViewer.h"
#ifdef iMSTK_WITH_RENDERING
#ifdef iMSTK_USE_Vulkan
#include "imstkVulkanViewer.h"
#else
#include "imstkVTKViewer.h"
#endif
#endif
namespace imstk
{
......
......@@ -9,7 +9,6 @@ set(iMSTK_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
list(INSERT CMAKE_MODULE_PATH 0 "${iMSTK_SOURCE_DIR}/CMake")
# iMSTK settings
set(iMSTK_WITH_RENDERING @iMSTK_WITH_RENDERING)
set(iMSTK_USE_OMNI @iMSTK_USE_OMNI@)
set(iMSTK_USE_Vulkan @iMSTK_USE_Vulkan@)
set(VegaFEM_DIR @VegaFEM_DIR@)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment