Commit b1be10fb authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

ENH: Added Sandia Painter and Shader support. Painters are fully incorporated,...

ENH: Added Sandia Painter and Shader support. Painters are fully incorporated, shader support is in-progress.
parent 5bf30d59
#
# Try to find nVidia's Cg compiler, runtime libraries, and include path.
#
# CG_INCLUDE_PATH = directory where cg.h resides
# CG_LIBRARY = full path to libCg.so (Cg.DLL on win32)
# CG_GL_LIBRARY = full path to libCgGL.so (CgGL.dll on win32)
# CG_COMPILER = full path to cgc (cgc.exe on win32)
#
IF (WIN32)
FIND_PROGRAM( CG_COMPILER cgc
"C:/Program Files/NVIDIA Corporation/Cg/bin"
"C:/Program Files/Cg"
${PROJECT_SOURCE_DIR}/../Cg
DOC "The Cg Compiler"
)
IF (CG_COMPILER)
GET_FILENAME_COMPONENT(CG_COMPILER_DIR ${CG_COMPILER} PATH)
GET_FILENAME_COMPONENT(CG_COMPILER_SUPER_DIR ${CG_COMPILER_DIR} PATH)
ELSE (CG_COMPILER)
SET (CG_COMPILER_DIR .)
SET (CG_COMPILER_SUPER_DIR ..)
ENDIF (CG_COMPILER)
FIND_PATH( CG_INCLUDE_PATH Cg/cg.h
"C:/Program Files/NVIDIA Corporation/Cg/include"
"C:/Program Files/Cg"
${PROJECT_SOURCE_DIR}/../Cg
${CG_COMPILER_SUPER_DIR}/include
${CG_COMPILER_DIR}
DOC "The directory where Cg/cg.h resides"
)
FIND_LIBRARY( CG_LIBRARY
NAMES Cg
PATHS
"C:/Program Files/NVIDIA Corporation/Cg/lib"
"C:/Program Files/Cg"
${PROJECT_SOURCE_DIR}/../Cg
${CG_COMPILER_SUPER_DIR}/lib
${CG_COMPILER_DIR}
DOC "The Cg runtime library"
)
FIND_LIBRARY( CG_GL_LIBRARY
NAMES CgGL
PATHS
"C:/Program Files/NVIDIA Corporation/Cg/lib"
"C:/Program Files/Cg"
${PROJECT_SOURCE_DIR}/../Cg
${CG_COMPILER_SUPER_DIR}/lib
${CG_COMPILER_DIR}
DOC "The Cg runtime library"
)
ELSE (WIN32)
FIND_PROGRAM( CG_COMPILER cgc
/usr/bin
/usr/local/bin
DOC "The Cg Compiler"
)
GET_FILENAME_COMPONENT(CG_COMPILER_DIR "${CG_COMPILER}" PATH)
GET_FILENAME_COMPONENT(CG_COMPILER_SUPER_DIR "${CG_COMPILER_DIR}" PATH)
FIND_PATH( CG_INCLUDE_PATH Cg/cg.h
/usr/include
/usr/local/include
${CG_COMPILER_SUPER_DIR}/include
DOC "The directory where Cg/cg.h resides"
)
FIND_LIBRARY( CG_LIBRARY Cg
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
${CG_COMPILER_SUPER_DIR}/lib64
${CG_COMPILER_SUPER_DIR}/lib
DOC "The Cg runtime library"
)
FIND_LIBRARY( CG_GL_LIBRARY CgGL
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
${CG_COMPILER_SUPER_DIR}/lib64
${CG_COMPILER_SUPER_DIR}/lib
DOC "The Cg runtime library"
)
ENDIF (WIN32)
IF (CG_INCLUDE_PATH)
SET( FOUND_CG 1 CACHE STRING "Set to 1 if CG is found, 0 otherwise")
ELSE (CG_INCLUDE_PATH)
SET( FOUND_CG 0 CACHE STRING "Set to 1 if CG is found, 0 otherwise")
ENDIF (CG_INCLUDE_PATH)
MARK_AS_ADVANCED( FOUND_CG )
...@@ -152,6 +152,21 @@ OPTION(VTK_USE_RENDERING "Build the vtkRendering kit. Needed for displaying dat ...@@ -152,6 +152,21 @@ OPTION(VTK_USE_RENDERING "Build the vtkRendering kit. Needed for displaying dat
VTK_DEPENDENT_OPTION(VTK_USE_PARALLEL "Build the vtkParallel kit." OFF VTK_DEPENDENT_OPTION(VTK_USE_PARALLEL "Build the vtkParallel kit." OFF
"VTK_USE_RENDERING" OFF) "VTK_USE_RENDERING" OFF)
# Determine Shading Support
VTK_DEPENDENT_OPTION(VTK_USE_CG_SHADERS "Build pixel and vertex shader support for Cg." OFF
"VTK_USE_RENDERING" OFF)
VTK_DEPENDENT_OPTION(VTK_USE_GLSL_SHADERS "Build pixel and vertex shader support for GLSL." OFF
"VTK_USE_RENDERING" OFF)
IF(VTK_USE_CG_SHADERS OR VTK_USE_GLSL_SHADERS)
SET(VTK_SHADERS_DIRS
"${VTK_BINARY_DIR}/Materials"
CACHE STRING
"; separated directories to search for materials/shaders")
MARK_AS_ADVANCED(VTK_SHADERS_DIRS)
ENDIF(VTK_USE_CG_SHADERS OR VTK_USE_GLSL_SHADERS)
# Determine GUI Support. # Determine GUI Support.
VTK_DEPENDENT_OPTION(VTK_USE_GUISUPPORT "Build VTK with GUI Support" OFF VTK_DEPENDENT_OPTION(VTK_USE_GUISUPPORT "Build VTK with GUI Support" OFF
"VTK_USE_RENDERING" OFF) "VTK_USE_RENDERING" OFF)
...@@ -908,6 +923,17 @@ IF(VTK_OPENGL_HAS_OSMESA AND VTK_USE_MANGLED_MESA) ...@@ -908,6 +923,17 @@ IF(VTK_OPENGL_HAS_OSMESA AND VTK_USE_MANGLED_MESA)
"VTK_OPENGL_HAS_OSMESA or VTK_USE_MANGLED_MESA.") "VTK_OPENGL_HAS_OSMESA or VTK_USE_MANGLED_MESA.")
ENDIF(VTK_OPENGL_HAS_OSMESA AND VTK_USE_MANGLED_MESA) ENDIF(VTK_OPENGL_HAS_OSMESA AND VTK_USE_MANGLED_MESA)
#-----------------------------------------------------------------------------
# Configure CG-Shading support.
IF(VTK_USE_CG_SHADERS)
INCLUDE(${VTK_SOURCE_DIR}/CMake/FindCg.cmake)
MARK_AS_ADVANCED(CG_COMPILER CG_INCLUDE_PATH CG_LIBRARY CG_GL_LIBRARY)
ENDIF(VTK_USE_CG_SHADERS)
#-----------------------------------------------------------------------------
# Configure GLSL-Shading support.
# TODO: Should verify that GL2.0 is supported.
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Configure Matrox Imaging support. # Configure Matrox Imaging support.
IF(VTK_USE_MATROX_IMAGING) IF(VTK_USE_MATROX_IMAGING)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "vtkPointData.h" #include "vtkPointData.h"
#include "vtkTimerLog.h" #include "vtkTimerLog.h"
vtkCxxRevisionMacro(vtkAbstractMapper, "1.4"); vtkCxxRevisionMacro(vtkAbstractMapper, "1.4.2.1");
vtkCxxSetObjectMacro(vtkAbstractMapper,ClippingPlanes,vtkPlaneCollection); vtkCxxSetObjectMacro(vtkAbstractMapper,ClippingPlanes,vtkPlaneCollection);
...@@ -188,7 +188,7 @@ vtkDataArray *vtkAbstractMapper::GetScalars(vtkDataSet *input, ...@@ -188,7 +188,7 @@ vtkDataArray *vtkAbstractMapper::GetScalars(vtkDataSet *input,
{ {
scalars = fd->GetArray(arrayName); scalars = fd->GetArray(arrayName);
} }
cellFlag = 1; cellFlag = 2;
} }
return scalars; return scalars;
......
...@@ -5,7 +5,8 @@ SET(KIT_PYTHON_LIBS vtkFilteringPythonD) ...@@ -5,7 +5,8 @@ SET(KIT_PYTHON_LIBS vtkFilteringPythonD)
SET(KIT_JAVA_LIBS vtkFilteringJava) SET(KIT_JAVA_LIBS vtkFilteringJava)
SET(KIT_LIBS vtkFiltering vtkDICOMParser SET(KIT_LIBS vtkFiltering vtkDICOMParser
${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_JPEG_LIBRARIES} ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_JPEG_LIBRARIES}
${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES}) ${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES}
${KWSYS_NAMESPACE})
SET( Kit_SRCS SET( Kit_SRCS
...@@ -96,6 +97,9 @@ vtkXMLDataSetWriter.cxx ...@@ -96,6 +97,9 @@ vtkXMLDataSetWriter.cxx
vtkXMLFileReadTester.cxx vtkXMLFileReadTester.cxx
vtkXMLImageDataReader.cxx vtkXMLImageDataReader.cxx
vtkXMLImageDataWriter.cxx vtkXMLImageDataWriter.cxx
vtkXMLMaterial.cxx
vtkXMLMaterialParser.cxx
vtkXMLMaterialReader.cxx
vtkXMLPDataReader.cxx vtkXMLPDataReader.cxx
vtkXMLPDataSetWriter.cxx vtkXMLPDataSetWriter.cxx
vtkXMLPDataWriter.cxx vtkXMLPDataWriter.cxx
...@@ -119,6 +123,7 @@ vtkXMLPolyDataWriter.cxx ...@@ -119,6 +123,7 @@ vtkXMLPolyDataWriter.cxx
vtkXMLReader.cxx vtkXMLReader.cxx
vtkXMLRectilinearGridReader.cxx vtkXMLRectilinearGridReader.cxx
vtkXMLRectilinearGridWriter.cxx vtkXMLRectilinearGridWriter.cxx
vtkXMLShader.cxx
vtkXMLStructuredDataReader.cxx vtkXMLStructuredDataReader.cxx
vtkXMLStructuredDataWriter.cxx vtkXMLStructuredDataWriter.cxx
vtkXMLStructuredGridReader.cxx vtkXMLStructuredGridReader.cxx
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <ctype.h> #include <ctype.h>
vtkCxxRevisionMacro(vtkXMLDataElement, "1.24"); vtkCxxRevisionMacro(vtkXMLDataElement, "1.24.4.1");
vtkStandardNewMacro(vtkXMLDataElement); vtkStandardNewMacro(vtkXMLDataElement);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -43,6 +43,7 @@ vtkXMLDataElement::vtkXMLDataElement() ...@@ -43,6 +43,7 @@ vtkXMLDataElement::vtkXMLDataElement()
this->XMLByteIndex = 0; this->XMLByteIndex = 0;
this->AttributeEncoding = VTK_ENCODING_UTF_8; this->AttributeEncoding = VTK_ENCODING_UTF_8;
this->CharacterData = 0;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -57,6 +58,7 @@ vtkXMLDataElement::~vtkXMLDataElement() ...@@ -57,6 +58,7 @@ vtkXMLDataElement::~vtkXMLDataElement()
this->RemoveAllNestedElements(); this->RemoveAllNestedElements();
delete [] this->NestedElements; delete [] this->NestedElements;
this->SetCharacterData(0, 0);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -116,6 +118,52 @@ void vtkXMLDataElement::ReadXMLAttributes(const char** atts, int encoding) ...@@ -116,6 +118,52 @@ void vtkXMLDataElement::ReadXMLAttributes(const char** atts, int encoding)
} }
} }
//----------------------------------------------------------------------------
void vtkXMLDataElement::SetCharacterData(const char* c, int length)
{
if (this->CharacterData)
{
delete [] this->CharacterData;
this->CharacterData = 0;
}
if (c && length > 0)
{
this->CharacterData = new char[length + 1];
strncpy(this->CharacterData, c, length);
this->CharacterData[length] = 0;
}
this->Modified();
}
//----------------------------------------------------------------------------
void vtkXMLDataElement::AddCharacterData(const char* c, int length)
{
if (!c || length <= 0)
{
return;
}
char* old_data = this->CharacterData;
int old_length = (old_data)? strlen(old_data): 0;
int total_length = old_length + length;
this->CharacterData = new char[total_length + 1];
this->CharacterData[0] = 0;
if (old_length > 0)
{
strncpy(this->CharacterData, old_data, old_length);
this->CharacterData[old_length] = 0;
}
strncat(this->CharacterData, c, length);
this->CharacterData[total_length] = 0;
if (old_data)
{
delete [] old_data;
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void vtkXMLDataElement::SetAttribute(const char *name, const char *value) void vtkXMLDataElement::SetAttribute(const char *name, const char *value)
{ {
......
...@@ -55,7 +55,13 @@ public: ...@@ -55,7 +55,13 @@ public:
// Set the attribute with the given name and value. If it doesn't exist, // Set the attribute with the given name and value. If it doesn't exist,
// adds it. // adds it.
void SetAttribute(const char* name, const char* value); void SetAttribute(const char* name, const char* value);
// Description:
// Set/Get the character data between XML start/end tags.
void SetCharacterData(const char* c, int length);
void AddCharacterData(const char* c, int length);
vtkGetStringMacro(CharacterData);
// Description: // Description:
// Get the attribute with the given name and converted to a scalar // Get the attribute with the given name and converted to a scalar
// value. Returns whether value was extracted. // value. Returns whether value was extracted.
...@@ -202,6 +208,9 @@ protected: ...@@ -202,6 +208,9 @@ protected:
// The value of the "id" attribute, if any was given. // The value of the "id" attribute, if any was given.
char* Id; char* Id;
// The character data between the start and end tags of this element.
char* CharacterData;
// The offset into the XML stream where the element begins. // The offset into the XML stream where the element begins.
unsigned long XMLByteIndex; unsigned long XMLByteIndex;
...@@ -236,6 +245,7 @@ protected: ...@@ -236,6 +245,7 @@ protected:
//BTX //BTX
friend class vtkXMLDataParser; friend class vtkXMLDataParser;
friend class vtkXMLMaterialParser;
//ETX //ETX
private: private:
......
...@@ -128,8 +128,9 @@ protected: ...@@ -128,8 +128,9 @@ protected:
virtual int Parse(const char*, unsigned int); virtual int Parse(const char*, unsigned int);
// Implement parsing methods. // Implement parsing methods.
void StartElement(const char* name, const char** atts); virtual void StartElement(const char* name, const char** atts);
void EndElement(const char*); virtual void EndElement(const char*);
int ParsingComplete(); int ParsingComplete();
int CheckPrimaryAttributes(); int CheckPrimaryAttributes();
void FindAppendedDataPosition(); void FindAppendedDataPosition();
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkXMLMaterial.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkXMLMaterial.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
#include "vtkXMLDataElement.h"
#include "vtkXMLShader.h"
#include <vtkstd/vector>
class vtkXMLMaterialInternals
{
public:
typedef vtkstd::vector<vtkXMLDataElement*> VectorOfElements;
typedef vtkstd::vector<vtkSmartPointer<vtkXMLShader> > VectorOfShaders;
VectorOfElements Properties;
VectorOfShaders VertexShaders;
VectorOfShaders FragmentShaders;
void Initialize()
{
this->Properties.clear();
this->VertexShaders.clear();
this->FragmentShaders.clear();
}
};
vtkStandardNewMacro(vtkXMLMaterial);
vtkCxxRevisionMacro(vtkXMLMaterial, "1.1.2.1");
//-----------------------------------------------------------------------------
vtkXMLMaterial::vtkXMLMaterial()
{
this->RootElement = 0;
this->Internals = new vtkXMLMaterialInternals;
}
//-----------------------------------------------------------------------------
vtkXMLMaterial::~vtkXMLMaterial()
{
this->SetRootElement(0);
delete this->Internals;
}
//-----------------------------------------------------------------------------
void vtkXMLMaterial::SetRootElement(vtkXMLDataElement* root)
{
this->Internals->Initialize();
vtkSetObjectBodyMacro(RootElement, vtkXMLDataElement, root);
if (this->RootElement)
{
// Update the internal data structure to
// avoid repeated searches.
int numElems = this->RootElement->GetNumberOfNestedElements();
for (int i=0; i<numElems; i++)
{
vtkXMLDataElement* elem = this->RootElement->GetNestedElement(i);
const char* name = elem->GetName();
if (!name)
{
continue;
}
if (strcmp(name, "Property") == 0)
{
this->Internals->Properties.push_back(elem);
}
else if (strcmp(name, "Shader") == 0)
{
vtkXMLShader* shader = vtkXMLShader::New();
shader->SetRootElement(elem);
switch (shader->GetScope())
{
case vtkXMLShader::SCOPE_VERTEX:
this->Internals->VertexShaders.push_back(shader);
break;
case vtkXMLShader::SCOPE_FRAGMENT:
this->Internals->FragmentShaders.push_back(shader);
break;
default:
vtkErrorMacro("Invalid scope for shader: " << shader->GetName());
}
shader->Delete();
}
}
}
}
//-----------------------------------------------------------------------------
int vtkXMLMaterial::GetNumberOfProperties()
{
return this->Internals->Properties.size();
}
//-----------------------------------------------------------------------------
int vtkXMLMaterial::GetNumberOfVertexShaders()
{
return this->Internals->VertexShaders.size();
}
//-----------------------------------------------------------------------------
int vtkXMLMaterial::GetNumberOfFragmentShaders()
{
return this->Internals->FragmentShaders.size();
}
//-----------------------------------------------------------------------------
vtkXMLDataElement* vtkXMLMaterial::GetProperty(int id)
{
if (id < this->GetNumberOfProperties())
{
return this->Internals->Properties[id];
}
return NULL;
}
//-----------------------------------------------------------------------------
vtkXMLShader* vtkXMLMaterial::GetVertexShader(int id)
{
if (id < this->GetNumberOfVertexShaders())
{
return this->Internals->VertexShaders[id].GetPointer();
}
return NULL;
}
//-----------------------------------------------------------------------------
vtkXMLShader* vtkXMLMaterial::GetFragmentShader(int id)
{
if (id < this->GetNumberOfFragmentShaders())
{
return this->Internals->FragmentShaders[id].GetPointer();
}
return NULL;
}
//-----------------------------------------------------------------------------
int vtkXMLMaterial::GetShaderLanguage()
{
if( this->GetVertexShader() && this->GetFragmentShader() )
{
int vLang = this->GetVertexShader()->GetLanguage();
int fLang = this->GetFragmentShader()->GetLanguage();
if( vLang == fLang )
{
return this->GetVertexShader()->GetLanguage();
}
else if( vLang != vtkXMLShader::LANGUAGE_NONE &&
fLang == vtkXMLShader::LANGUAGE_NONE )
{
return this->GetVertexShader()->GetLanguage();
}
else if( vLang == vtkXMLShader::LANGUAGE_NONE &&
fLang != vtkXMLShader::LANGUAGE_NONE )
{
return this->GetFragmentShader()->GetLanguage();
}
else
{
return vtkXMLShader::LANGUAGE_MIXED;
}
}
else if( this->GetVertexShader() )
{
return this->GetVertexShader()->GetLanguage();
}
else if( this->GetFragmentShader() )
{
return this->GetFragmentShader()->GetLanguage();
}
return vtkXMLShader::LANGUAGE_NONE;
}
//-----------------------------------------------------------------------------
void vtkXMLMaterial::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkXMLMaterial.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkXMLMaterial - encapsulates a VTK Material description.
// .SECTION Description
// vtkXMLMaterial encapsulates VTK Material description. It keeps a pointer
// to vtkXMLDataElement that defines the material and provides
// access to Shaders/Properties defined in it.
#ifndef __vtkXMLMaterial_h
#define __vtkXMLMaterial_h
#include "vtkObject.h"
class vtkXMLDataElement;
class vtkXMLMaterialInternals;
class vtkXMLShader;
class VTK_IO_EXPORT vtkXMLMaterial : public vtkObject
{
public:
static vtkXMLMaterial* New();
vtkTypeRevisionMacro(vtkXMLMaterial, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get number of elements of type vtkProperty.
int GetNumberOfProperties();
// Description: