Commit 452d8812 authored by Berk Geveci's avatar Berk Geveci

Added a new reader to better handle PLOT3D files.

- Added a new reader (vtkPlot3DMetaReader) designed to make it easier
to deal with Plot3D files. This is a meta-file in which the user
can specify various settings (such as endianness, multi-grid etc.)
rather than having to do it through the reader API. The reader also
supports time series of xyz and q files.
- Added JSON CPP support which is used by the meta-reader.

Change-Id: I991e6487869966c3e1769835a72fd2f8b7f81770
parent 50e677ac
......@@ -18,6 +18,7 @@ SET(Module_SRCS
vtkOpenFOAMReader.cxx
vtkParticleReader.cxx
vtkPDBReader.cxx
vtkPlot3DMetaReader.cxx
vtkProStarReader.cxx
vtkSESAMEReader.cxx
vtkSTLReader.cxx
......
......@@ -11,3 +11,4 @@ add_test_python(motor.py Graphics)
add_test_python(testHexaPenta.py Graphics)
add_test_python(TestChacoReader.py IO)
add_test_python(TestSimplePointsReader.py IO)
add_test_python(TestPlot3DMeta.py IO)
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
renWin = vtk.vtkRenderWindow()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
r = vtk.vtkPlot3DMetaReader()
r.SetFileName("%s/Data/test.p3d" % VTK_DATA_ROOT)
r.UpdateInformation()
outInfo = r.GetOutputInformation(0)
l = outInfo.Length(vtk.vtkStreamingDemandDrivenPipeline.TIME_STEPS())
if l != 2:
raise "Error: wrong number of time steps: %d. Should be 2" % l
outInfo.Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP(), 3.5)
r.Update()
outInfo.Set(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_TIME_STEP(), 4.5)
r.Update()
output = r.GetOutput().GetBlock(0)
plane = vtk.vtkStructuredGridGeometryFilter()
plane.SetInputData(output)
plane.SetExtent(25,25,0,100,0,100)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(plane.GetOutputPort())
mapper.SetScalarRange(output.GetPointData().GetScalars().GetRange())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
ren = vtk.vtkRenderer()
camera = vtk.vtkCamera()
ren.SetActiveCamera(camera)
renWin.AddRenderer(ren)
ren.AddActor(actor)
camera.SetViewUp(0,1,0)
camera.SetFocalPoint(0,0,0)
camera.SetPosition(1,0,0)
ren.ResetCamera()
camera.Dolly(1.25)
ren.ResetCameraClippingRange()
renWin.SetSize(400,300)
renWin.Render()
iren.Initialize()
......@@ -7,6 +7,7 @@ vtk_module(vtkIOGeometry
vtkCommonMisc
vtkIOCore
vtkzlib
vtkjsoncpp
TEST_DEPENDS
vtkIOAMR
vtkIOLegacy
......
This diff is collapsed.
/*=========================================================================
Program: ParaView
Module: $RCSfile: vtkPlot3DMetaReader.h,v $
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 vtkPlot3DMetaReader - reads meta-files points to PLOT3D files
// .SECTION Description:
// The main goal of this reader is to make it easy to read PLOT3D files,
// specifically time series of PLOT3D files. PLOT3D files can take many
// different forms based on their content. Unfortunately, it is not a
// self-describing format therefore the user needs to pass information
// about the contents of the file to the reader. Normally, this is done
// by setting a number of member variables. The goal of this reader is
// to provide a simple format that enable the writer of the PLOT3D file
// to describe its settings as well as group a number of files as a time
// series. Note that for binary files, the auto-detect-format option,
// which is on by default negates the need to specify most other option.
// However, this reader is still very useful when trying to read file
// series even for binary files. The format for this meta-file is very simple
// and is based on JSON (there is no need to know anything about JSON to
// understand this format). Below is an example with comments (followed by //)
// that describe the format. Note that the PLOT3D file names are relative
// to the location of the meta-file unless they start with a leading /.
//
// \verbatim
// {
// "auto-detect-format" : true // Tells the reader to try to figure out the format automatically. Only works
// // with binary file. This is on by default, negating the need for most other
// // options for binary files (format, byte-order, precision, multi-grid,
// // blanking, 2D).
// "format" : "binary", // Is this a binary or ascii file, values : binary, ascii
// "byte-order" : "big", // Byte order for binary files, values : little, big (denoting little or big endian)
// "precision" : 32, // Precision of floating point values, can be 32 or 64 (bits)
// "multi-grid" : false, // Is this a multi-grid file, values: true, false
// "language" : "C", // Which language was this file written in, values : C, fortran. This is
// // used to determine if an binary PLOT3D file contains byte counts, used by
// // Fortran IO routines.
// "blanking" : false, // Does this file have blanking information (iblanks), values : true, false
// "2D" : false, // Is this a 2D dataset, values : true, false
// "R" : 8.314, // The value of the gas constant, default is 1.0. Set this according to the dimensions you use
// "gamma" : 1.4, // Ratio of specific heats. Default is 1.4.
// "functions": [ 110, 200, 201 ], // Additional derived values to calculate. This is an array of integers formatted
// // as [ value, value, value, ...]
// "filenames" : [ // List of xyz (geometry) and q (value) file names along with the time values.
// // This is an array which contains items in the format:
// // { "time" : values, "xyz" : "xyz file name", "q" : "q file name" }
// // Note that q is optional. Also, you can repeat the same file name for xyz or q
// // if they don't change over time. The reader will not read files unnecessarily.
// { "time" : 3.5, "xyz" : "combxyz.bin", "q" : "combq.1.bin"},
// { "time" : 4.5, "xyz" : "combxyz.bin", "q" : "combq.2.bin"}
// ]
// }
// \endverbatim
//
// This reader leverages vtkMultiBlockPLOT3DReader to do the actual
// reading so you may want to refer to the documenation of
// vtkMultiBlockPLOT3DReader about the details of some of these
// parameters including the function numbers for derived value
// calculation.
//
// .SECTION See Also
// vtkMultiBlockPLOT3DReader
#ifndef __vtkPlot3DMetaReader_h
#define __vtkPlot3DMetaReader_h
#include "vtkIOGeometryModule.h" // For export macro
#include "vtkMultiBlockDataSetAlgorithm.h"
//BTX
struct vtkPlot3DMetaReaderInternals;
//ETX
class vtkMultiBlockPLOT3DReader;
namespace Json
{
class Value;
}
class VTKIOGEOMETRY_EXPORT vtkPlot3DMetaReader : public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkPlot3DMetaReader* New();
vtkTypeMacro(vtkPlot3DMetaReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get the meta PLOT3D filename. See the class documentation for
// format details.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
protected:
vtkPlot3DMetaReader();
~vtkPlot3DMetaReader();
virtual int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int RequestData(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
char* FileName;
void SetAutoDetectFormat(Json::Value* value);
void SetByteOrder(Json::Value* value);
void SetPrecision(Json::Value* val);
void SetMultiGrid(Json::Value* val);
void SetFormat(Json::Value* val);
void SetBlanking(Json::Value* val);
void Set2D(Json::Value* val);
void SetR(Json::Value* val);
void SetGamma(Json::Value* val);
void SetFileNames(Json::Value* val);
void SetLanguage(Json::Value* val);
void AddFunctions(Json::Value* val);
private:
vtkPlot3DMetaReader(const vtkPlot3DMetaReader&); // Not implemented.
void operator=(const vtkPlot3DMetaReader&); // Not implemented.
vtkMultiBlockPLOT3DReader* Reader;
vtkPlot3DMetaReaderInternals* Internal;
};
#endif
project(JSONCPP)
set(vtkjsoncpp_THIRD_PARTY 1)
set(vtkjsoncpp_LIBRARIES vtkjsoncpp)
vtk_module_export_info()
set(JSONCPP_SOURCES
jsoncpp.cpp
)
include_directories(${JSONCPP_SOURCE_DIR} ${JSONCPP_BINARY_DIR})
if (BUILD_SHARED_LIBS AND WIN32)
add_definitions(-DJSON_DLL_BUILD)
endif()
vtk_add_library(vtkjsoncpp ${JSONCPP_SOURCES})
if(NOT VTK_INSTALL_NO_DEVELOPMENT)
install(DIRECTORY
${JSONCPP_SOURCE_DIR}/json
DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}/JSONCPP
COMPONENT Development)
endif()
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
/// It is intented to be used with #include <json/json-forwards.h>
/// This header provides forward declaration for all JsonCpp types.
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
/*
The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
conditions of the MIT License (see below), or 3) under the terms of dual
Public Domain/MIT License conditions described here, as they choose.
The MIT License is about as close to Public Domain as a license can get, and is
described in clear, concise terms at:
http://en.wikipedia.org/wiki/MIT_License
The full text of the MIT License follows:
========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
(END LICENSE TEXT)
The MIT license is compatible with both the GPL and commercial
software, affording one all of the rights of Public Domain with the
minor nuisance of being required to keep the above copyright notice
and license text in the source code. Note also that by accepting the
Public Domain "license" you can re-license your copy using whatever
license you like.
*/
// //////////////////////////////////////////////////////////////////////
// End of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
# define JSON_FORWARD_AMALGATED_H_INCLUDED
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
#define JSON_IS_AMALGAMATION
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
# define JSON_CONFIG_H_INCLUDED
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
/// If defined, indicates that Json specific container should be used
/// (hash table & simple deque container with customizable allocator).
/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332
//# define JSON_VALUE_USE_INTERNAL_MAP 1
/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
/// as if it was a POD) that may cause some validation tool to report errors.
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
/// If defined, indicates that Json use exception to report invalid type manipulation
/// instead of C assert macro.
# define JSON_USE_EXCEPTION 1
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGAMATION
# ifdef JSON_IN_CPPTL
# include <cpptl/config.h>
# ifndef JSON_USE_CPPTL
# define JSON_USE_CPPTL 1
# endif
# endif
# ifdef JSON_IN_CPPTL
# define JSON_API CPPTL_API
# elif defined(JSON_DLL_BUILD)
# define JSON_API __declspec(dllexport)
# elif defined(JSON_DLL)
# define JSON_API __declspec(dllimport)
# else
# define JSON_API
# endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
// Microsoft Visual Studio 6 only support conversion from __int64 to double
// (no conversion from unsigned __int64).
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
#endif
#if !defined(JSONCPP_DEPRECATED)
# define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
# if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
# undef JSON_HAS_INT64
# else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
# if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
# else // if defined(_MSC_VER) // Other platforms, use long long
typedef long long int Int64;
typedef unsigned long long int UInt64;
# endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
# define JSON_HAS_INT64
# endif // if defined(JSON_NO_INT64)
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
# define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
# include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
#ifdef JSON_VALUE_USE_INTERNAL_MAP
class ValueMapAllocator;
class ValueInternalLink;
class ValueInternalArray;
class ValueInternalMap;
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
This diff is collapsed.
This diff is collapsed.
vtk_module(vtkjsoncpp
EXCLUDE_FROM_WRAPPING
)
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