Commit 47118393 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'forward-vtk-to-master' into pv-master

e6bab494 Merge topic 'fix_dashboard_issues' into master
70ead432 Merge topic 'data-array-asserts' into master
14c8487e Safer fake coordinates for structured from unstructured CF grids
4b20f9b1 Increasing timeout for test.
46a51e1c Merge topic 'opengl-error-hunt' into master
6455c581 OpenGL error hunt -- dashboard cleanup
7e49ccd4 Merge topic 'opengl-error-hunt' into master
0994d6ca OpenGL error hunt -- dashboard cleanup
bc424e27 Add asserts to vtkDataArrayTemplate Set/GetValue()
e07e9824 Merge topic 'opengl-error-hunt' into master
62311d5e OpenGL error hunt -- dashboard cleanup
8be9b7a5 Merge topic 'opengl-error-hunt' into master
5e3e2043 Merge topic 'Fix_OctreePointLocator_Descr' into master
3545b515 Merge topic 'netcdf_units' into master
7cbcd88c fix windows compilation
5de3f32a Merge topic 'geojson_writer' into master
...
parents 90b9cca7 e6bab494
......@@ -27,6 +27,7 @@
#include "vtkPistonScalarsColors.h"
#include "vtkScalarsToColors.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkOpenGLError.h"
#include <limits>
......@@ -52,12 +53,14 @@ namespace vtkpiston {
{
PistonGLRAII(GLbitfield mask)
{
vtkOpenGLClearErrorMacro();
glPushAttrib(mask);
}
~PistonGLRAII()
{
glPopAttrib();
vtkOpenGLStaticCheckErrorMacro("failed after ~PistonGLRAII");
}
};
}
......@@ -136,6 +139,8 @@ vtkPistonMapper::~vtkPistonMapper()
//-----------------------------------------------------------------------------
void vtkPistonMapper::PrepareDirectRenderBuffers(int nPoints)
{
vtkOpenGLClearErrorMacro();
if (nPoints==this->Internal->BufferSize)
{
return;
......@@ -144,6 +149,7 @@ void vtkPistonMapper::PrepareDirectRenderBuffers(int nPoints)
{
// Release old buffer
vtkgl::DeleteBuffers(3, this->Internal->vboBuffers);
vtkOpenGLCheckErrorMacro("failed at glDeleteBuffers");
}
this->Internal->BufferSize = nPoints;
......@@ -170,6 +176,8 @@ void vtkPistonMapper::PrepareDirectRenderBuffers(int nPoints)
this->Internal->BufferSize*3*sizeof(float), 0,
vtkgl::DYNAMIC_DRAW);
vtkOpenGLCheckErrorMacro("failed after allocate shared memory");
vtkpiston::CudaRegisterBuffer(&this->Internal->vboResources[0],
this->Internal->vboBuffers[0]);
vtkpiston::CudaRegisterBuffer(&this->Internal->vboResources[1],
......@@ -214,6 +222,8 @@ int vtkPistonMapper::FillInputPortInformation(
//-----------------------------------------------------------------------------
void vtkPistonMapper::RenderOnCPU()
{
vtkOpenGLClearErrorMacro();
vtkpiston::PistonGLRAII(GL_LIGHTING_BIT);
vtkScalarsToColors *lut = this->GetLookupTable();
......@@ -389,11 +399,15 @@ void vtkPistonMapper::RenderOnCPU()
glEnd();
}
od->Delete();
vtkOpenGLCheckErrorMacro("failed after RenderOnCPU");
}
//-----------------------------------------------------------------------------
void vtkPistonMapper::RenderOnGPU()
{
vtkOpenGLClearErrorMacro();
vtkPistonDataObject *id = this->GetPistonDataObjectInput(0);
int nPoints = vtkpiston::QueryNumVerts(id);
......@@ -443,11 +457,15 @@ void vtkPistonMapper::RenderOnGPU()
glDisableClientState(GL_VERTEX_ARRAY);
if (hasNormals) glDisableClientState(GL_NORMAL_ARRAY);
if (hasColors) glDisableClientState(GL_COLOR_ARRAY);
vtkOpenGLCheckErrorMacro("failed after RenderOnGPU");
}
//-----------------------------------------------------------------------------
void vtkPistonMapper::RenderImageDataOutline()
{
vtkOpenGLClearErrorMacro();
vtkpiston::PistonGLRAII(GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
......@@ -508,6 +526,8 @@ void vtkPistonMapper::RenderImageDataOutline()
glVertex3dv(nextpt[3]);
glVertex3dv(nextpt[7]);
glEnd();
vtkOpenGLCheckErrorMacro("failed after RenderImageDataOutline");
}
//----------------------------------------------------------------------------
......
......@@ -172,7 +172,9 @@ include(vtkDetermineCompilerFlags)
add_definitions(-DVTK_IN_VTK)
#-----------------------------------------------------------------------------
include(vtkLegacyData)
if(BUILD_TESTING)
include(vtkLegacyData)
endif()
# Provide an option for tests requiring "large" input data
option(VTK_USE_LARGE_DATA "Enable tests requiring \"large\" data" OFF)
......
......@@ -47,7 +47,7 @@ bool vtkPlotLine3D::Paint(vtkContext2D *painter)
// Get the 3D context.
vtkContext3D *context = painter->GetContext3D();
if(context == false)
if(context == NULL)
{
return false;
}
......
......@@ -23,6 +23,7 @@
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkDataArray.h"
#include <cassert> // for assert()
template <class T>
class vtkDataArrayTemplateLookup;
......@@ -131,13 +132,14 @@ public:
// Description:
// Get the data at a particular index.
T GetValue(vtkIdType id) { return this->Array[id]; }
T GetValue(vtkIdType id)
{ assert(id >= 0 && id < this->Size); return this->Array[id]; }
// Description:
// Set the data at a particular index. Does not do range checking. Make sure
// you use the method SetNumberOfValues() before inserting data.
void SetValue(vtkIdType id, T value)
{ this->Array[id] = value;};
{ assert(id >= 0 && id < this->Size); this->Array[id] = value;};
// Description:
// Specify the number of values for this object to hold. Does an
......
......@@ -758,7 +758,11 @@ virtual double *Get##name() \
// place to avoid stray semicolons because this is an error for some
// compilers. Using a class forward declaration allows any number
// of repeats in any context without generating unique names.
# define VTK_LEGACY(method) class vtkLegacyMethodRemoved
# define VTK_LEGACY(method) VTK_LEGACY__0(method,__LINE__)
# define VTK_LEGACY__0(method,line) VTK_LEGACY__1(method,line)
# define VTK_LEGACY__1(method,line) class vtkLegacyMethodRemoved##line
#elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
// Provide legacy methods with no warnings.
# define VTK_LEGACY(method) method
......
......@@ -243,8 +243,12 @@ void vtkImplicitBoolean::PrintSelf(ostream& os, vtkIndent indent)
{
os << "VTK_UNION\n";
}
else if ( this->OperationType == VTK_UNION_OF_MAGNITUDES )
{
os << "VTK_UNION_OF_MAGNITUDES\n";
}
else
{
os << "VTK_INTERSECTION\n";
os << "VTK_DIFFERENCE\n";
}
}
......@@ -17,19 +17,19 @@
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
----------------------------------------------------------------------------*/
// .NAME vtkOctreePointLocator - a octree spatial decomposition of a set of points
// .NAME vtkOctreePointLocator - an octree spatial decomposition of a set of points
//
// .SECTION Description
// Given a vtkDataSetxs, create an octree that is locally refined
// such that all leaf octants contain less than a certain
// amount of points. Note that there is no size constraint that
// a leaf octant in relation to any of its neighbors.
// Given a vtkDataSet, create an octree that is locally refined
// such that all leaf octants contain less than a certain
// amount of points. Note that there is no size constraint that
// a leaf octant in relation to any of its neighbors.
//
// This class can also generate a PolyData representation of
// the boundaries of the spatial regions in the decomposition.
// This class can also generate a PolyData representation of
// the boundaries of the spatial regions in the decomposition.
//
// .SECTION See Also
// vtkPointLocator vtkOctreePointLocatorNode
// vtkLocator vtkPointLocator vtkOctreePointLocatorNode
#ifndef __vtkOctreePointLocator_h
#define __vtkOctreePointLocator_h
......
......@@ -29,7 +29,7 @@
// octant is Min < x <= Max.
//
// .SECTION See Also
// vtkOctreePointLocator
// vtkOctreePointLocator
#ifndef __vtkOctreePointLocatorNode_h
#define __vtkOctreePointLocatorNode_h
......
......@@ -83,10 +83,6 @@ public:
virtual void SetRepelVertices(vtkPoints*);
vtkGetObjectMacro(RepelVertices, vtkPoints);
// Description:
// TODO: Get the total geodesic length.
virtual double GetGeodesicLength() { return 0.0; }
//Description:
//Fill the array with the cumulative weights.
virtual void GetCumulativeWeights(vtkDoubleArray *weights);
......
......@@ -34,8 +34,6 @@ public:
vtkTypeMacro(vtkGeodesicPath,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
virtual double GetGeodesicLength() = 0;
protected:
vtkGeodesicPath();
~vtkGeodesicPath();
......
......@@ -28,6 +28,7 @@
#include "vtkGenericOpenGLRenderWindow.h"
#include "vtkEventQtSlotConnect.h"
#include "vtkgl.h"
#include "vtkOpenGLError.h"
QVTKGraphicsItem::QVTKGraphicsItem(QGLContext* ctx, QGraphicsItem* p)
: QGraphicsWidget(p), mContext(ctx)
......@@ -183,6 +184,8 @@ void QVTKGraphicsItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget
if(!mWin)
return;
vtkOpenGLClearErrorMacro();
#if QT_VERSION >= 0x040600
// tell Qt we're doing our own GL calls
// if necessary, it'll put us in an OpenGL 1.x compatible state.
......@@ -239,6 +242,8 @@ void QVTKGraphicsItem::paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget
#if QT_VERSION >= 0x040600
painter->endNativePainting();
#endif
vtkOpenGLStaticCheckErrorMacro("failed after paint");
}
void QVTKGraphicsItem::keyPressEvent(QKeyEvent* e)
......
......@@ -35,11 +35,11 @@
#include "vtkMatrix4x4.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkPath.h"
#include "vtkPointData.h"
#include "vtkProp.h"
#include "vtkProp3DCollection.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRendererCollection.h"
......@@ -56,6 +56,7 @@
#include "vtkVolumeCollection.h"
#include "vtkWindowToImageFilter.h"
#include "vtk_gl2ps.h"
#include "vtkOpenGLError.h"
#include <vector>
......@@ -626,6 +627,8 @@ void vtkGL2PSExporter::SetPropVisibilities(vtkPropCollection *col, int vis)
void vtkGL2PSExporter::DrawSpecialProps(vtkCollection *specialPropCol,
vtkRendererCollection *renCol)
{
vtkOpenGLClearErrorMacro();
// Iterate through the renderers and the prop collections together:
assert("renderers and special prop collections match" &&
renCol->GetNumberOfItems() == specialPropCol->GetNumberOfItems());
......@@ -654,6 +657,8 @@ void vtkGL2PSExporter::DrawSpecialProps(vtkCollection *specialPropCol,
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
vtkOpenGLCheckErrorMacro("failed after DrawSpecialProps");
}
void vtkGL2PSExporter::HandleSpecialProp(vtkProp *prop, vtkRenderer *ren)
......@@ -790,6 +795,8 @@ void vtkGL2PSExporter::DrawViewportTextOverlay(const char *string,
vtkCoordinate *coord,
vtkRenderer *ren)
{
vtkOpenGLClearErrorMacro();
// Figure out the viewport information
int *winsize = this->RenderWindow->GetSize();
double *viewport = ren->GetViewport();
......@@ -825,6 +832,8 @@ void vtkGL2PSExporter::DrawViewportTextOverlay(const char *string,
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
vtkOpenGLCheckErrorMacro("failed after DrawViewportTextOverlay");
}
......@@ -835,6 +844,9 @@ void vtkGL2PSExporter::CopyPixels(int copyRect[4], vtkRenderer *ren)
vtkErrorMacro(<<"Raster image is not correctly formatted.")
return;
}
vtkOpenGLClearErrorMacro();
// Figure out the viewport information
int *winsize = this->RenderWindow->GetSize();
double *viewport = ren->GetViewport();
......@@ -893,6 +905,8 @@ void vtkGL2PSExporter::CopyPixels(int copyRect[4], vtkRenderer *ren)
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
vtkOpenGLCheckErrorMacro("failed after CopyPixels");
}
void vtkGL2PSExporter::DrawContextActors(vtkPropCollection *contextActs,
......
set(Module_SRCS
vtkGeoJSONWriter.cxx
)
vtk_module_library(vtkIOGeoJSON ${Module_SRCS})
vtk_add_test_python(TestGeoJSONWriter.py NO_VALID)
import vtk, os, sys
from vtk.test import Testing
ss = vtk.vtkSphereSource() #make mesh to test with
af = vtk.vtkElevationFilter() #add some attributes
af.SetInputConnection(ss.GetOutputPort())
ef = vtk.vtkExtractEdges() #make lines to test
ef.SetInputConnection(af.GetOutputPort())
gf = vtk.vtkGlyph3D() #make verts to test
pts = vtk.vtkPoints()
pts.InsertNextPoint(0,0,0)
verts = vtk.vtkCellArray()
avert = vtk.vtkVertex()
avert.GetPointIds().SetId(0, 0)
verts.InsertNextCell(avert)
onevertglyph = vtk.vtkPolyData()
onevertglyph.SetPoints(pts)
onevertglyph.SetVerts(verts)
gf.SetSourceData(onevertglyph)
gf.SetInputConnection(af.GetOutputPort())
testwrites = ["points","lines","mesh"]
failed = False
for datasetString in testwrites:
if datasetString == "points":
toshow=gf
elif datasetString == "lines":
toshow = ef
else:
toshow = af
gw = vtk.vtkGeoJSONWriter()
fname = "sphere_"+datasetString+".json"
gw.SetInputConnection(toshow.GetOutputPort())
gw.SetFileName(fname)
gw.Write()
if (os.path.exists(fname) and
os.path.isfile(fname)):
os.remove(fname)
else:
print "Failed to write " + fname + " to file"
failed = True
gw.WriteToOutputStringOn()
gw.Write()
gj = "['"+str(gw.RegisterAndGetOutputString()).replace('\n','')+"']"
if len(gj) <= 1000:
print "Failed to write " + fname + " to buffer"
failed = True
if failed:
sys.exit(1)
sys.exit(0)
vtk_module(vtkIOGeoJSON
DEPENDS
vtkCommonDataModel
vtkIOCore
TEST_DEPENDS
vtkTestingCore
)
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGeoJSONWriter.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 "vtkGeoJSONWriter.h"
#include "vtkCellArray.h"
#include "vtkInformation.h"
#include "vtkLookupTable.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include <vtksys/ios/sstream>
vtkStandardNewMacro(vtkGeoJSONWriter);
#define VTK_GJWRITER_MAXPOINTS 32000
//------------------------------------------------------------------------------
vtkGeoJSONWriter::vtkGeoJSONWriter()
{
this->FileName = NULL;
this->OutputString = NULL;
this->SetNumberOfOutputPorts(0);
this->WriteToOutputString = false;
this->ScalarFormat = 2;
this->LookupTable = NULL;
}
//------------------------------------------------------------------------------
vtkGeoJSONWriter::~vtkGeoJSONWriter()
{
this->SetFileName(NULL);
delete[] this->OutputString;
this->SetLookupTable(NULL);
}
//------------------------------------------------------------------------------
void vtkGeoJSONWriter::PrintSelf(ostream & os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "FileName: "
<< (this->FileName?this->FileName:"NONE") << endl;
os << indent << "WriteToOutputString: "
<< (this->WriteToOutputString?"True":"False") << endl;
os << indent << "ScalarFormat: " << this->ScalarFormat << endl;
}
//------------------------------------------------------------------------------
int vtkGeoJSONWriter::FillInputPortInformation(int port, vtkInformation *info)
{
if (port == 0)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
}
return 1;
}
//------------------------------------------------------------------------------
ostream *vtkGeoJSONWriter::OpenFile()
{
vtkDebugMacro(<<"Opening file\n");
ostream *fptr;
if (!this->WriteToOutputString)
{
if (!this->FileName)
{
vtkErrorMacro(<< "No FileName specified! Can't write!");
return NULL;
}
fptr = new ofstream(this->FileName, ios::out);
}
else
{
// Get rid of any old output string.
if (this->OutputString)
{
delete [] this->OutputString;
this->OutputString = NULL;
this->OutputStringLength = 0;
}
fptr = new vtksys_ios::ostringstream;
}
if (fptr->fail())
{
vtkErrorMacro(<< "Unable to open file: "<< this->FileName);
delete fptr;
return NULL;
}
return fptr;
}
//------------------------------------------------------------------------------
void vtkGeoJSONWriter::CloseFile(ostream *fp)
{
vtkDebugMacro(<<"Closing file\n");
if ( fp != NULL )
{
if (this->WriteToOutputString)
{
vtksys_ios::ostringstream *ostr =
static_cast<vtksys_ios::ostringstream*>(fp);
delete [] this->OutputString;
this->OutputStringLength = static_cast<int>(ostr->str().size());
//+1's account for null terminator
this->OutputString = new char[ostr->str().size()+1];
memcpy(this->OutputString, ostr->str().c_str(),
this->OutputStringLength+1);
}
delete fp;
}
}
//------------------------------------------------------------------------------
void vtkGeoJSONWriter::ConditionalComma(ostream *fp,
vtkIdType cnt, vtkIdType limit)
{
if (cnt+1 != limit)
{
*fp << ",";
}
}
//------------------------------------------------------------------------------
void vtkGeoJSONWriter::WriteScalar(ostream *fp,
vtkDataArray *da, vtkIdType ptId)
{
if (this->ScalarFormat == 0)
{
return;
}
if (da)
{
double b = da->GetTuple1(ptId);
if (this->ScalarFormat == 1)
{
vtkLookupTable *lut = this->GetLookupTable();
if (!lut)
{
lut = vtkLookupTable::New();
lut->SetNumberOfColors(256);
lut->SetHueRange(0.0,0.667);
lut->SetRange(da->GetRange());
lut->Build();
this->SetLookupTable(lut);
lut->Delete();
}
unsigned char *color = lut->MapValue(b);
*fp << ","
<< (double)color[0]/255.0 << ","
<< (double)color[1]/255.0 << ","
<< (double)color[2]/255;
}
else
{
if (vtkMath::IsNan(b))
{
*fp << "," << "null";
}
else
{
*fp << "," << b;
}
}
}
}
//------------------------------------------------------------------------------
void vtkGeoJSONWriter::WriteData()
{
ostream *fp;
vtkPolyData *input = vtkPolyData::SafeDownCast(this->GetInput());
vtkDebugMacro(<<"Writing vtk polygonal data to geojson file...");
fp=this->OpenFile();
if ( !fp )
{
return;
}
*fp << "{\n";
*fp << "\"type\": \"Feature\",\n";
vtkDataArray *da = input->GetPointData()->GetScalars();
if (!da)
{
da = input->GetPointData()->GetArray(0);
}
if (da)
{
switch (this->ScalarFormat) {
case 0:
*fp << "\"properties\": {\"ScalarFormat\": \"none\"},\n";