mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 21:33:55 +00:00
Merge branch 'msvc-rendering' into 'master'
Fix several issues concerning using rendering library with Visual Studio Write a comment or drag your files here... See merge request !457
This commit is contained in:
commit
952929a7d0
5
CMake/FindPyexpander.cmake
Normal file → Executable file
5
CMake/FindPyexpander.cmake
Normal file → Executable file
@ -28,6 +28,11 @@
|
||||
# PYEXPANDER_FOUND - True if pyexpander is found
|
||||
# PYEXPANDER_COMMAND - The pyexpander executable
|
||||
#
|
||||
# Note that on some platforms (such as Windows), you cannot execute a python
|
||||
# script directly. Thus, it could be safer to execute the Python interpreter
|
||||
# with PYEXPANDER_COMMAND as an argument. See FindPythonInterp.cmake for help
|
||||
# in finding the Python interpreter.
|
||||
#
|
||||
|
||||
find_program(PYEXPANDER_COMMAND expander.py)
|
||||
|
||||
|
17
CMake/VTKmCheckPyexpander.cmake
Normal file → Executable file
17
CMake/VTKmCheckPyexpander.cmake
Normal file → Executable file
@ -23,9 +23,14 @@
|
||||
# version stored in the source code. If the versions are different, an
|
||||
# error message is printed with further instructions.
|
||||
#
|
||||
# To use this script, the CMake variables PYEXPANDER_COMMAND, SOURCE_FILE,
|
||||
# and GENERATED_FILE must be defined as the two files to compare. A ".in"
|
||||
# is appended to SOURCE_FILE to get the pyexpander input.
|
||||
# To use this script, the CMake variables PYTHON_EXECUTABLE PYEXPANDER_COMMAND,
|
||||
# SOURCE_FILE, and GENERATED_FILE must be defined as the two files to compare.
|
||||
# A ".in" is appended to SOURCE_FILE to get the pyexpander input.
|
||||
|
||||
if(NOT PYTHON_EXECUTABLE)
|
||||
message(SEND_ERROR "Variable PYTHON_EXECUTABLE must be set.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT PYEXPANDER_COMMAND)
|
||||
message(SEND_ERROR "Variable PYEXPANDER_COMMAND must be set.")
|
||||
@ -43,14 +48,14 @@ if(NOT GENERATED_FILE)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${PYEXPANDER_COMMAND} ${SOURCE_FILE}.in
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PYEXPANDER_COMMAND} ${SOURCE_FILE}.in
|
||||
RESULT_VARIABLE pyexpander_result
|
||||
OUTPUT_VARIABLE pyexpander_output
|
||||
)
|
||||
|
||||
if(${pyexpander_result})
|
||||
if(pyexpander_result)
|
||||
# If pyexpander returned non-zero, it failed.
|
||||
message(SEND_ERROR "Running pyexpander failed.")
|
||||
message(SEND_ERROR "Running pyexpander failed (${pyexpander_result}).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
3
CMake/VTKmMacros.cmake
Normal file → Executable file
3
CMake/VTKmMacros.cmake
Normal file → Executable file
@ -198,10 +198,11 @@ endfunction(vtkm_declare_worklets)
|
||||
|
||||
function(vtkm_pyexpander_generated_file generated_file_name)
|
||||
# If pyexpander is available, add targets to build and check
|
||||
if(PYEXPANDER_FOUND)
|
||||
if(PYEXPANDER_FOUND AND PYTHONINTERP_FOUND)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}.checked
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
-DPYEXPANDER_COMMAND=${PYEXPANDER_COMMAND}
|
||||
-DSOURCE_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${generated_file_name}
|
||||
-DGENERATED_FILE=${CMAKE_CURRENT_BINARY_DIR}/${generated_file_name}
|
||||
|
4
CMakeLists.txt
Normal file → Executable file
4
CMakeLists.txt
Normal file → Executable file
@ -208,6 +208,10 @@ if(UNIX AND VTKm_ENABLE_OPENGL_INTEROP)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Find the Python interpreter, which we will use during the build process
|
||||
find_package(PythonInterp)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Find Pyexpander in case somebody wants to update the auto generated
|
||||
# faux variadic template code
|
||||
|
2
examples/hello_world/CMakeLists.txt
Normal file → Executable file
2
examples/hello_world/CMakeLists.txt
Normal file → Executable file
@ -20,7 +20,7 @@
|
||||
##
|
||||
##=============================================================================
|
||||
|
||||
if(OPENGL_FOUND AND GLUT_FOUND)
|
||||
if(VTKm_ENABLE_OPENGL_INTEROP AND GLUT_FOUND)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(HelloWorld_SERIAL HelloWorld.cxx LoadShaders.h)
|
||||
set_source_files_properties(LoadShaders.h PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
2
examples/streamline/StreamLineUniformGrid.cxx
Normal file → Executable file
2
examples/streamline/StreamLineUniformGrid.cxx
Normal file → Executable file
@ -246,7 +246,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Read vector data at each point of the uniform grid and store
|
||||
vtkm::Id nElements = vdims[0] * vdims[1] * vdims[2] * 3;
|
||||
float* data = new float[nElements];
|
||||
float* data = new float[static_cast<std::size_t>(nElements)];
|
||||
fread(data, sizeof(float), static_cast<std::size_t>(nElements), pFile);
|
||||
|
||||
std::vector<vtkm::Vec<vtkm::Float32, 3> > field;
|
||||
|
2
vtkm/cont/StorageBasic.h
Normal file → Executable file
2
vtkm/cont/StorageBasic.h
Normal file → Executable file
@ -127,7 +127,7 @@ struct AlignedAllocator {
|
||||
return &r;
|
||||
}
|
||||
size_type max_size() const {
|
||||
return std::numeric_limits<size_type>::max() / sizeof(T);
|
||||
return (std::numeric_limits<size_type>::max)() / sizeof(T);
|
||||
}
|
||||
void construct(pointer p, const T &t){
|
||||
new(p) T(t);
|
||||
|
4
vtkm/cont/internal/ArrayPortalFromIterators.h
Normal file → Executable file
4
vtkm/cont/internal/ArrayPortalFromIterators.h
Normal file → Executable file
@ -63,7 +63,7 @@ public:
|
||||
std::distance(begin, end);
|
||||
VTKM_ASSERT(numberOfValues >= 0);
|
||||
#ifndef VTKM_USE_64BIT_IDS
|
||||
if (numberOfValues > std::numeric_limits<vtkm::Id>::max())
|
||||
if (numberOfValues > (std::numeric_limits<vtkm::Id>::max)())
|
||||
{
|
||||
throw vtkm::cont::ErrorControlBadAllocation(
|
||||
"Distance of iterators larger than maximum array size. "
|
||||
@ -147,7 +147,7 @@ public:
|
||||
std::distance(begin, end);
|
||||
VTKM_ASSERT(numberOfValues >= 0);
|
||||
#ifndef VTKM_USE_64BIT_IDS
|
||||
if (numberOfValues > std::numeric_limits<vtkm::Id>::max())
|
||||
if (numberOfValues > (std::numeric_limits<vtkm::Id>::max)())
|
||||
{
|
||||
throw vtkm::cont::ErrorControlBadAllocation(
|
||||
"Distance of iterators larger than maximum array size. "
|
||||
|
9
vtkm/rendering/AxisAnnotation2D.h
Normal file → Executable file
9
vtkm/rendering/AxisAnnotation2D.h
Normal file → Executable file
@ -29,6 +29,8 @@
|
||||
#include <vtkm/rendering/AxisAnnotation.h>
|
||||
#include <vtkm/rendering/TextAnnotation.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
|
||||
@ -175,6 +177,7 @@ public:
|
||||
0,0, 0));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
for (unsigned int i=0; i<nmajor; ++i)
|
||||
{
|
||||
vtkm::Float64 xc = x0 + (x1-x0) * maj_proportions[i];
|
||||
@ -192,10 +195,10 @@ public:
|
||||
xs -= (maj_tx<0?-1.:+1.) * fontscale * .1;
|
||||
}
|
||||
|
||||
char val[256];
|
||||
snprintf(val, 256, "%g", maj_positions[i]);
|
||||
numberToString.str("");
|
||||
numberToString << maj_positions[i];
|
||||
|
||||
labels[i]->SetText(val);
|
||||
labels[i]->SetText(numberToString.str());
|
||||
//if (fabs(maj_positions[i]) < 1e-10)
|
||||
// labels[i]->SetText("0");
|
||||
((ScreenTextAnnotation*)(labels[i]))->SetPosition(vtkm::Float32(xs),
|
||||
|
15
vtkm/rendering/AxisAnnotation3D.h
Normal file → Executable file
15
vtkm/rendering/AxisAnnotation3D.h
Normal file → Executable file
@ -28,6 +28,8 @@
|
||||
#include <vtkm/rendering/AxisAnnotation.h>
|
||||
#include <vtkm/rendering/TextAnnotation.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace vtkm {
|
||||
namespace rendering {
|
||||
|
||||
@ -75,9 +77,9 @@ public:
|
||||
}
|
||||
void SetTickInvert(bool x, bool y, bool z)
|
||||
{
|
||||
invertx = x ? +1 : -1;
|
||||
inverty = y ? +1 : -1;
|
||||
invertz = z ? +1 : -1;
|
||||
invertx = x ? +1.0f : -1.0f;
|
||||
inverty = y ? +1.0f : -1.0f;
|
||||
invertz = z ? +1.0f : -1.0f;
|
||||
}
|
||||
void SetMajorTickSize(vtkm::Float64 size, vtkm::Float64 offset)
|
||||
{
|
||||
@ -141,6 +143,7 @@ public:
|
||||
0));
|
||||
}
|
||||
|
||||
std::stringstream numberToString;
|
||||
for (unsigned int i=0; i<nmajor; ++i)
|
||||
{
|
||||
vtkm::Float64 xc = x0 + (x1-x0) * proportions[i];
|
||||
@ -182,9 +185,9 @@ public:
|
||||
ty *= inverty;
|
||||
tz *= invertz;
|
||||
|
||||
char val[256];
|
||||
snprintf(val, 256, "%g", positions[i]);
|
||||
labels[i]->SetText(val);
|
||||
numberToString.str("");
|
||||
numberToString << positions[i];
|
||||
labels[i]->SetText(numberToString.str());
|
||||
//if (fabs(positions[i]) < 1e-10)
|
||||
// labels[i]->SetText("0");
|
||||
labels[i]->SetPosition(vtkm::Float32(xc - tx),
|
||||
|
8
vtkm/rendering/Camera.h
Normal file → Executable file
8
vtkm/rendering/Camera.h
Normal file → Executable file
@ -125,8 +125,8 @@ class Camera
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
vtkm::Matrix<vtkm::Float32,4,4> CreateProjectionMatrix(vtkm::Float32 size,
|
||||
vtkm::Float32 near,
|
||||
vtkm::Float32 far,
|
||||
vtkm::Float32 znear,
|
||||
vtkm::Float32 zfar,
|
||||
vtkm::Float32 aspect) const
|
||||
{
|
||||
vtkm::Matrix<vtkm::Float32,4,4> matrix(0.f);
|
||||
@ -137,10 +137,10 @@ class Camera
|
||||
|
||||
matrix(0,0) = 2.f/(right-left);
|
||||
matrix(1,1) = 2.f/(top-bottom);
|
||||
matrix(2,2) = -2.f/(far-near);
|
||||
matrix(2,2) = -2.f/(zfar-znear);
|
||||
matrix(0,3) = -(right+left)/(right-left);
|
||||
matrix(1,3) = -(top+bottom)/(top-bottom);
|
||||
matrix(2,3) = -(far+near)/(far-near);
|
||||
matrix(2,3) = -(zfar+znear)/(zfar-znear);
|
||||
matrix(3,3) = 1.f;
|
||||
|
||||
vtkm::Matrix<vtkm::Float32,4,4> T, Z;
|
||||
|
8
vtkm/rendering/CanvasGL.h
Normal file → Executable file
8
vtkm/rendering/CanvasGL.h
Normal file → Executable file
@ -160,8 +160,8 @@ public:
|
||||
|
||||
glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
|
||||
GL_RGBA, GL_FLOAT,
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->GetColorBuffer().GetPortalControl()));
|
||||
&(*vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->GetColorBuffer().GetPortalControl())));
|
||||
}
|
||||
VTKM_CONT_EXPORT
|
||||
virtual void RefreshDepthBuffer()
|
||||
@ -173,8 +173,8 @@ public:
|
||||
|
||||
glReadPixels(viewport[0], viewport[1], viewport[2], viewport[3],
|
||||
GL_DEPTH_COMPONENT, GL_FLOAT,
|
||||
vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->GetDepthBuffer().GetPortalControl()));
|
||||
&(*vtkm::cont::ArrayPortalToIteratorBegin(
|
||||
this->GetDepthBuffer().GetPortalControl())));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
|
5
vtkm/rendering/internal/OpenGLHeaders.h
Normal file → Executable file
5
vtkm/rendering/internal/OpenGLHeaders.h
Normal file → Executable file
@ -21,6 +21,11 @@
|
||||
#ifndef vtk_m_rendering_internal_OpenGLHeaders_h
|
||||
#define vtk_m_rendering_internal_OpenGLHeaders_h
|
||||
|
||||
#ifdef _WIN32
|
||||
// Need to include windows.h before gl.h on windows.
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# include <OpenGL/gl.h>
|
||||
#else
|
||||
|
12
vtkm/rendering/raytracing/BoundingVolumeHierarchy.h
Normal file → Executable file
12
vtkm/rendering/raytracing/BoundingVolumeHierarchy.h
Normal file → Executable file
@ -783,12 +783,12 @@ public:
|
||||
*bvh.zmaxs,
|
||||
coordsHandle);
|
||||
// Find the extent of all bounding boxes to generate normalization for morton codes
|
||||
vtkm::Vec<vtkm::Float32,3> minExtent(std::numeric_limits<vtkm::Float32>::max(),
|
||||
std::numeric_limits<vtkm::Float32>::max(),
|
||||
std::numeric_limits<vtkm::Float32>::max());
|
||||
vtkm::Vec<vtkm::Float32,3> maxExtent(std::numeric_limits<vtkm::Float32>::min(),
|
||||
std::numeric_limits<vtkm::Float32>::min(),
|
||||
std::numeric_limits<vtkm::Float32>::min());
|
||||
vtkm::Vec<vtkm::Float32,3> minExtent(vtkm::Infinity32(),
|
||||
vtkm::Infinity32(),
|
||||
vtkm::Infinity32());
|
||||
vtkm::Vec<vtkm::Float32,3> maxExtent(vtkm::NegativeInfinity32(),
|
||||
vtkm::NegativeInfinity32(),
|
||||
vtkm::NegativeInfinity32());
|
||||
maxExtent[0] = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::Reduce(*bvh.xmaxs,
|
||||
maxExtent[0],
|
||||
MaxValue());
|
||||
|
12
vtkm/rendering/raytracing/Camera.h
Normal file → Executable file
12
vtkm/rendering/raytracing/Camera.h
Normal file → Executable file
@ -542,12 +542,12 @@ private:
|
||||
|
||||
//std::cout<<"Bounds ("<<x[0]<<","<<y[0]<<","<<z[0]<<")-("<<x[1]<<","<<y[1]<<","<<z[1]<<std::endl;
|
||||
vtkm::Float32 xmin, ymin, xmax, ymax, zmin, zmax;
|
||||
xmin = std::numeric_limits<vtkm::Float32>::max();
|
||||
ymin = std::numeric_limits<vtkm::Float32>::max();
|
||||
zmin = std::numeric_limits<vtkm::Float32>::max();
|
||||
xmax = std::numeric_limits<vtkm::Float32>::min();
|
||||
ymax = std::numeric_limits<vtkm::Float32>::min();
|
||||
zmax = std::numeric_limits<vtkm::Float32>::min();
|
||||
xmin = vtkm::Infinity32();
|
||||
ymin = vtkm::Infinity32();
|
||||
zmin = vtkm::Infinity32();
|
||||
xmax = vtkm::NegativeInfinity32();
|
||||
ymax = vtkm::NegativeInfinity32();
|
||||
zmax = vtkm::NegativeInfinity32();
|
||||
vtkm::Vec<vtkm::Float32,4> extentPoint;
|
||||
for (vtkm::Int32 i = 0; i < 2; ++i)
|
||||
for (vtkm::Int32 j = 0; j < 2; ++j)
|
||||
|
Loading…
Reference in New Issue
Block a user