When things in the rendering library need to execute things in parallel
(outside of another rendering library like OpenGL) it should run it on
available parallel devices. This means using TryExecute to attempt on
whatever devices may be available. It also means that some of the
sources must be compiled with CUDA's nvcc. To enable this, made a code
wrapping mechanism to compile within a .cu file.
I have noticed at least on my windows machine that source code that uses
the rendering package is taking a long time to compile. The rendering
library does not rely much on templates and more on virtual methods.
Thus, it is a good candidate for moving to a library so that it need be
compiled only once.
This sets up the configure scripts to create the library. There is also
a simple port of one class to the library. More will follow.
Fix precision warnings when FloatDefault is 64 bit
When VTKm_USE_DOUBLE_PRECISION is on (not the default), then
vtkm::FloatDefault is set to 64 bit values. There was some code that was
coded for 32 bit and never checked for 64 bit (on all compilers).
See merge request !526
call and then never upload again.
RenderTest: overload the Render function to pass in a Mapper.
UnitTestMapperGLFW: global variable for the MapperGL to pass into RenderTest::Render
MapperGL: Creating the VBO/VAO is now wrapped in check to see if the data's
already been loaded.
Moved some variables to class scope.
When VTKm_USE_DOUBLE_PRECISION is on (not the default), then
vtkm::FloatDefault is set to 64 bit values. There was some code that was
coded for 32 bit and never checked for 64 bit (on all compilers).
The UnitTestMapperGLFW test was coded to run in an interactive mode,
which was problematic when simply running the test. If no one was there
to exit the interactive window, the test would time out. This change
adds a "batch" mode that is on when run by ctest. The batch mode runs
through all configurations and exits.
The VTKmConfigureComponents.cmake file has lots of careful configuration
of many of VTK-m components and dependent libraries (like OpenGL,
OSMesa, etc.) that takes care of several corner cases. The configuration
is consolidated here so that it can be consistent across the many
directories in VTK-m as well as other projects that use VTK-m.
Recent changes to the configuration in rendering circumvented these and
directly tried to configure dependent rendering libraries. This is wrong
(and more importantly broke my OSX build).
The testing subdirectories were including the tests from the parent
directory. I believe this was a copy-paste error from the tests
originally all being in one file (where the unit_tests variable had all
tests appended) and then moved to subdirectories where they should not
be appended.
The intension was that if Camera::Zoom was called with a Float64, it
would call the Float32 version. However, I made a type where it called
itself. The latest version of XCode called me out on this infinite
recursion.
I think this is the equivalent of the compiler calling me a dumb-ass.
Have VTK-m eat its own dog food when it comes to its configuration. Load
the same configuration for building VTK-m as would be loaded (more or
less) when using find_package(VTKm) in an external project.
This includes adding lots more components to the packages so that all the
setup (e.g. OpenGL, TBB, etc.) can be set up correctly. It is also a
significant change to how these components are declared. The component
configuration is simplified a bit and unified in a single file.
In some cases on windows pointers used as iterators are wrapped in
checked iterators. This is fine for most uses, but you cannot pass them
to a C function as a pointer (as we were doing for OpenGL). This change
converts the checked iterator back to a raw pointer in this case.
There were a few places in the source code where
std::numeric_limits::min and max were used. There is an issue with these
methods on windows because the standard libraries there define macros
with the same name. Get around this problem by either places parentheses
so that they do not look like macros or use the vtkm::Infinity methods
instead.
Microsoft visual studio treats these as keywords. These keywords were
used for pointers on 16-bit architectures. That makes them pretty much
obsolete for any software written in the last 20 years, but happily they
stick around to give us confusing compile errors.
It is more common to use degrees when specifying a transform (thanks to
the classic OpenGL interface). Also, camera specifies the field of view in
degrees, which made rotations inconsistent. This change unifies all that.
All of the Camera math (currently) uses 32-bit floats. However, to make
it easier to use the Camera class, I've duplicated the accessor methods
to also accept 64-bit floats.
Merge request !445 (Camera enhancements) and merge request !448
(Consolidate background color) had conflicting changes in View.h.
Although git did not pick up on the conflict because each merge modified a
different portion of View.h, the final merge with both of these resulted
in a compile error.
Basically what happened was `Consolidate background color` changed all
the View constructors to reflect changes. `Camera enhancements` added a
new constructor to View using the old construction method. The new
constructor with the old construction method caused an error.
Consolidate background color in rendering classes
Before this commit, there were three separate classes (Mapper, Canvas,
and View) that were all managing their own version of the background
color. As you can imagine, this could easily become out of sync, and in
fact if the user code did not specify the same background at least
twice, it would not work.
Fix this by consolidating the background color management to the Canvas.
This is the class most responsible for maintaining the background. All
other classes get or set the background from the Canvas.
That said, I also removed setting the background color from the
constructor in the Canvas. This background color is overridden by the
View anyway, so having it there was only confusing.
See merge request !448
In the previous commit, I removed the background color arguments from
all the constructors from the Canvas class. I had missed the fact that
this was used in UnitTestMapperOSMesa.
Before this commit, there were three separate classes (Mapper, Canvas,
and View) that were all managing their own version of the background
color. As you can imagine, this could easily become out of sync, and in
fact if the user code did not specify the same background at least
twice, it would not work.
Fix this by consolidating the background color management to the Canvas.
This is the class most responsible for maintaining the background. All
other classes get or set the background from the Canvas.
That said, I also removed setting the background color from the
constructor in the Canvas. This background color is overridden by the
View anyway, so having it there was only confusing.
It is now optional to give a Camera object when constructing a View. If
a Camera is not specified, one is automatically set up by calling
ResetToBounds on the spatial bounds of the scene.
This makes it even easier to set up a view.
Also implement pan and zoom for 2D cameras.
Update the rendering tests to do these camera rotations. This matches
better the viewpoint used before the previous camera changes.
Affine transformations of homogeneous coordinates using 4x4 matrices are
quite common in visualization. Create a new math header file in the base
vtkm namespace that has common functions for such coordinates.
Much of this implementation was taken from the rendering matrix helpers.
I do not have OSMesa on my main development platform, so I missed updating
some of the code when I changed the interface.
Also removed some inline statements on pure virtual functions that GCC
was complaining about.
Most of the time, you just match the WorldAnnotator with the canvas of
the same type. Rather than make the user specify it every time, add a
method to the canvas that creates a "good" WorldAnnotator to use with
it. Then, if a WorldAnnotator is not given to the View constructor, one
is automatically created from the Canvas.
The template parameters on vtkm::rendering::View are unnecessary. All
three of the templated classes are polymorphic (with virtual functions).
Thus, you just have to specify them at the constructor. Removing the
template parameters makes the syntax a bit cleaner and removes some
unnecessary duplication in the executable.
Removing the template does mean we cannot optimize in the future.
However, I expect us to start using more virtual methods rather than
less, so I think this is a move in the right direction.
With only a few exceptions for simple structures, we do not expose the
members of classes. Instead, we provide accessor methods. Do this for
Camera as well as add some helper methods.
The width and height are maintained out of necessity by the canvas. A
second copy was maintained by the camera, which was only used for
computing the aspect ratio and similar metrics for projections.
Having to maintain the width/height in two places is a bit of a hassle
and provides the opportunity for bugs if they get out of sync. Instead,
have the width/height managed in one place (the canvas) and pass them as
parameters as necessary.
Move some of the management of the width, height, and buffers to the base
Canvas class. Also, when it makes sense, get the width and height from
the rendering system.
Also changed the color buffer to be a Vec so that you don't have to
manage array offsets by hand.
All of these changes snowballed from the observation that the glut
example did not properly enable the depth buffer.
Generally we try not to expose the implementation details of how things
are stored in objects.
Also changed some arguments that should have been declared const to
actually be const.
The SamplerRect worklet had an error where it was possible that the
invSpacing stack-local values could be used uninitialized. On the first
iteration of the loop in the SamplerRect operation, it calls LocateCell,
which is supposed to set invSpacing. Under most conditions it does, but
if one of the ray directions is 0 (which can happen with axis-aligned
views), one of the invSpacing dimensions was skipped, leaving the value
to whatever garbage happened to be on the stack. Later, the invSpacing
value was used to interpolate a scalar, which under some circumstances
could cause an array index error when looking up a color in the color
map.
This fix changes the condition for when the ray direction is 0 to still
initialize invSpacing.
There was an error in the CMakeLists.txt in the rendering tests where
the include directory was linked in instead of the OSMesa library.
It was a simple mistake of typing the wrong CMake variable.
The word surface is more often used for something like a polygonal mesh,
so this name is quite confusing. Canvas is consistent with a
conventional name in GUI widget APIs.
The rendering classes do not actually manage windows, and window was not
descriptive of what this class was doing. We decided that the class was
mostly analogous to what we call a "view" in ParaView.
Not all systems put their OpenGL headers in a directory named GL. (In
particular, OSX decides to be different.) The vtkm/rendering/internal/
OpenGLHeaders.h header takes care of including the OpenGL header on all
platforms.
This is required for installing the files. It is also useful for
developers because it adds the files to IDEs and creates test builds for
the header files. Those test builds highlighted some missing includes.
Specifically, I am trying to compile the code on OSX. OSX uses OpenGL
libraries in a different directory than most other installs (including
X11) and does not generally support GLX. These changes remove the files
that support GLX in systems that do not support it.
I also added several header files to the CMake lists that were not there
but should have been.
Made several changes to Window.h that fix the following:
* Fix warning about the member functions being initialized out of order
* Conform indentation to be 2 spaces
* Conform member functions to be capitolized
* Conform the use of "this->" when referencing class members
* Conform using full namespace when using classes
* Be more descriptive in some variable names
* Alphabetize includes
There are a lot of VTK-m coding style issues I would also like to clean
up (such as variable names and using "this->" before member variables),
but it is late and I want to go home.
C++ standard states that all class member variables are initialized in
the order they are declared in the class. Thus, it is considered good
C++ style to have their initialization listing in the constructor to
match the actual order they are initialized. The compiler could give a
warning otherwise.
While I am at it, rename the member variables to be more aligned with
VTK-m coding style (i.e. start with capital letter and be descriptive).
Several of the methods in View.h were giving me warnings about shadowed
variables because the name of the arguments were the same as some class
member variables. I fixed this by changing the variable names to match
the VTK-m coding convention of using capitalized words for class member
variables and starting lower case letter for method arguments and local
variables.
Since this ended up changing over half of the lines of View.h and
Camera.h anyway, I also made some other modifications to the style to put
it in alignment with VTK-m coding conventions including 2-space
indentation and more descriptive variable names.