Commit 952fbf03 authored by Ben Boeckel's avatar Ben Boeckel

cmake: update CMake macros for better API and behaviors

parent a77d61f1
/*=========================================================================
Program: ParaView
Module: @_add_visit_reader_plugin_name@.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "@_add_visit_reader_plugin_name@.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkMultiBlockDataSet.h"
#include "@_add_visit_reader_VISIT_INCLUDE_NAME@.h"
#include "avtDatabaseMetaData.h"
#include "avtMeshMetaData.h"
#include "avtVariableCache.h"
#include "VisItException.h"
#cmakedefine01 _add_visit_reader_VISIT_READER_USES_OPTIONS
#if _add_visit_reader_VISIT_READER_USES_OPTIONS
#include "@_add_visit_reader_visit_plugin_info_header@.h"
#endif
#if _add_visit_reader_uses_interface
#include "@_add_visit_reader_plugin_name@@_add_visit_reader_VISIT_INTERFACE_FILE@.h"
#endif
vtkStandardNewMacro(@_add_visit_reader_plugin_name@);
//-----------------------------------------------------------------------------
@_add_visit_reader_plugin_name@::@_add_visit_reader_plugin_name@()
{
this->FileName = 0;
}
//-----------------------------------------------------------------------------
@_add_visit_reader_plugin_name@::~@_add_visit_reader_plugin_name@()
{
this->SetFileName(0);
}
#if _add_visit_reader_uses_interface
//-----------------------------------------------------------------------------
int @_add_visit_reader_plugin_name@::CanReadFile(const char *fname)
{
int valid = 0;
try
{
valid = @_add_visit_reader_plugin_name@@_add_visit_reader_VISIT_INTERFACE_FILE@::@_add_visit_reader_VISIT_INTERFACE_CALL@;
}
catch(...){}
return valid;
}
#endif
//-----------------------------------------------------------------------------
bool @_add_visit_reader_plugin_name@::InitializeAVTReader( const int& timestep )
{
if (!this->MetaData)
{
this->MetaData = new avtDatabaseMetaData( );
}
if (!this->Cache)
{
this->Cache = new avtVariableCache( );
}
if (!this->AvtFile)
{
try
{
#if _add_visit_reader_VISIT_READER_USES_OPTIONS
@_add_visit_reader_visit_plugin_info_class@ *options =
new @_add_visit_reader_visit_plugin_info_class@();
this->AvtFile = new @_add_visit_reader_VISIT_READER_NAME@(
this->FileName, options->GetReadOptions() );
delete options;
#else
this->AvtFile = new @_add_visit_reader_VISIT_READER_NAME@(this->FileName);
#endif
}
catch(const VisItException& e)
{
vtkErrorMacro(<<e.Message());
this->AvtFile = NULL;
return false;
}
catch(const std::exception& e)
{
vtkErrorMacro(<<e.what());
this->AvtFile = NULL;
return false;
}
@_add_visit_reader_VISIT_READER_NAME@ *file = dynamic_cast<@_add_visit_reader_VISIT_READER_NAME@*>
(this->AvtFile);
if ( file )
{
//we have to make sure the visit reader populates its cache
//before activating a time step
try
{
file->SetCache( this->Cache );
file->ActivateTimestep(timestep);
//only fill database after choosing timestep to activate
file->SetDatabaseMetaData( this->MetaData, timestep );
}
catch(const VisItException& e)
{
vtkErrorMacro(<<e.Message());
return false;
}
catch(const std::exception& e)
{
vtkErrorMacro(<<e.what());
return false;
}
}
else
{
return false;
}
}
return true;
}
//-----------------------------------------------------------------------------
bool @_add_visit_reader_plugin_name@::ActivateTimestep( const int& timestep )
{
if(this->AvtFile)
{
@_add_visit_reader_VISIT_READER_NAME@ *file = dynamic_cast<@_add_visit_reader_VISIT_READER_NAME@*>
(this->AvtFile);
if ( file )
{
file->ActivateTimestep(timestep);
return true;
}
}
return false;
}
//-----------------------------------------------------------------------------
void @_add_visit_reader_plugin_name@::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: @_add_visit_reader_plugin_name@.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef @_add_visit_reader_plugin_name@_h
#define @_add_visit_reader_plugin_name@_h
#include "vtkIOVisItBridgeModule.h" //for export macro
#include "vtkAvt@_add_visit_reader_VISIT_READER_TYPE@FileFormatAlgorithm.h"
#cmakedefine01 _add_visit_reader_uses_interface
class VTKIOVISITBRIDGE_EXPORT @_add_visit_reader_plugin_name@ : public vtkAvt@_add_visit_reader_VISIT_READER_TYPE@FileFormatAlgorithm
{
public:
static @_add_visit_reader_plugin_name@ *New();
vtkTypeMacro(@_add_visit_reader_plugin_name@,vtkAvt@_add_visit_reader_VISIT_READER_TYPE@FileFormatAlgorithm );
void PrintSelf(ostream& os, vtkIndent indent) override;
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
#if _add_visit_reader_uses_interface
int CanReadFile(const char* fname);
#endif
protected:
@_add_visit_reader_plugin_name@();
~@_add_visit_reader_plugin_name@();
bool InitializeAVTReader( const int& timestep ) override;
bool ActivateTimestep( const int& timestep ) override;
char *FileName;
private:
@_add_visit_reader_plugin_name@(const @_add_visit_reader_plugin_name@&) = delete;
void operator = (const @_add_visit_reader_plugin_name@&) = delete;
};
#endif
<ServerManagerConfiguration>
<ProxyGroup name="sources">
<SourceProxy name="@_add_visit_reader_xml_name@"
class="@_add_visit_reader_plugin_name@"
file_name_method="SetFileName">
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1">
<FileListDomain name="files"/>
</StringVectorProperty>
<StringVectorProperty
name="MeshInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Mesh"/>
</StringVectorProperty>
<StringVectorProperty
name="MeshStatus"
label="Meshes"
command="SetMeshArrayStatus"
number_of_elements="2"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="MeshInfo">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="MeshInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
Select the meshes to be loaded from the dataset, if any.
</Documentation>
</StringVectorProperty>
<StringVectorProperty
name="MaterialInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Material"/>
</StringVectorProperty>
<StringVectorProperty
name="MaterialStatus"
label="Materials"
command="SetMaterialArrayStatus"
number_of_elements="2"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="MaterialInfo">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="MaterialInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
Select the Materiales to be loaded from the dataset, if any.
</Documentation>
</StringVectorProperty>
<StringVectorProperty
name="CellArrayInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Cell"/>
</StringVectorProperty>
<StringVectorProperty
name="CellArrayStatus"
command="SetCellArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="CellArrayInfo"
label="Cell Arrays">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="CellArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property lists which cell-centered arrays to read.
</Documentation>
</StringVectorProperty>
<StringVectorProperty
name="PointArrayInfo"
information_only="1">
<ArraySelectionInformationHelper attribute_name="Point"/>
</StringVectorProperty>
<StringVectorProperty
name="PointArrayStatus"
command="SetPointArrayStatus"
number_of_elements="0"
repeat_command="1"
number_of_elements_per_command="2"
element_types="2 0"
information_property="PointArrayInfo"
label="Point Arrays">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property name="PointArrayInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property lists which point-centered arrays to read.
</Documentation>
</StringVectorProperty>
<!-- The following two properties magically send time information -->
<!-- to the animation panel. -->
<DoubleVectorProperty
name="TimestepValues"
repeatable="1"
information_only="1">
<TimeStepsInformationHelper/>
</DoubleVectorProperty>
<DoubleVectorProperty name="TimeRange" information_only="1">
<TimeRangeInformationHelper/>
</DoubleVectorProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
set(_VisItReader_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
function (add_visit_reader NAME VERSION)
set(_add_visit_reader_plugin_name "vtk${NAME}")
cmake_parse_arguments(_add_visit_reader
""
"VISIT_READER_NAME;VISIT_INCLUDE_NAME;VISIT_READER_TYPE;VISIT_READER_USES_OPTIONS;VISIT_READER_OPTIONS_NAME"
"SERVER_SOURCES"
${ARGN})
if (_add_visit_reader_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"Unparsed arguments for add_visit_reader: "
"${_add_visit_reader_UNPARSED_ARGUMENTS}")
endif ()
if (NOT DEFINED _add_visit_reader_VISIT_READER_NAME)
message(FATAL_ERROR
"The `VISIT_READER_NAME` argument is required.")
endif ()
if (NOT DEFINED _add_visit_reader_VISIT_READER_USES_OPTIONS)
set(_add_visit_reader_VISIT_READER_USES_OPTIONS OFF)
endif ()
# If the user hasn't defined an include name, we presume the reader name is
# also the include name.
if (NOT DEFINED _add_visit_reader_VISIT_INCLUDE_NAME)
set(_add_visit_reader_VISIT_INCLUDE_NAME "${_add_visit_reader_VISIT_READER_NAME}")
endif ()
if (NOT _add_visit_reader_VISIT_READER_TYPE MATCHES "^[SM]T[SM]D$")
message(FATAL_ERROR
"Invalid Reader Type `${_add_visit_reader_VISIT_READER_TYPE}`. Valid "
"Types are STSD, STMD, MTSD, MTMD")
endif ()
if (_add_visit_reader_VISIT_READER_USES_OPTIONS)
# Determine the name of the plugin info class by removing the AVT from the
# start and the FileFormat from the back
if (_add_visit_reader_VISIT_READER_OPTIONS_NAME)
set(_add_visit_reader_name "${_add_visit_reader_VISIT_READER_OPTIONS_NAME}")
else ()
set(_add_visit_reader_name "${_add_visit_reader_VISIT_READER_NAME}")
endif ()
string(REGEX REPLACE "^avt|FileFormat$" "" _add_visit_reader_name_base "${_add_visit_reader_name}")
set(_add_visit_reader_visit_plugin_info_header
"${_add_visit_reader_name_base}PluginInfo")
set(_add_visit_reader_visit_plugin_info_class
"${_add_visit_reader_name_base}CommonPluginInfo")
endif ()
# Need to generate the VTK class wrapper.
string(SUBSTRING "${_add_visit_reader_VISIT_READER_TYPE}" 0 2 _add_visit_reader_wrapper_type)
set(_add_visit_reader_source
"${_VisItReader_output_dir}/${_add_visit_reader_plugin_name}.cxx")
set(_add_visit_reader_header
"${_VisItReader_output_dir}/${_add_visit_reader_plugin_name}.h")
configure_file(
"${_VisItReader_cmake_dir}/VisIt${_add_visit_reader_wrapper_type}.h.in"
"${_add_visit_reader_header}"
@ONLY)
configure_file(
"${_VisItReader_cmake_dir}/VisIt${_add_visit_reader_wrapper_type}.cxx.in"
"${_add_visit_reader_source}"
@ONLY)
# Fix up the arg_server_sources path for compilation
set(_add_visit_reader_server_sources)
foreach (_add_visit_reader_server_source IN LISTS _add_visit_reader_SERVER_SOURCES)
if (NOT IS_ABSOLUTE "${_add_visit_reader_server_source}")
string(PREPEND _add_visit_reader_server_source
"${CMAKE_CURRENT_SOURCE_DIR}/")
endif ()
list(APPEND _add_visit_reader_server_sources
"${_add_visit_reader_server_source}")
endforeach ()
set_property(GLOBAL APPEND
PROPERTY
_visit_server_sources "${_add_visit_reader_server_sources}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_sources "${_add_visit_reader_source}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_headers "${_add_visit_reader_header}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}")
endfunction ()
function(ADD_VISIT_INTERFACE_READER NAME VERSION)
set(INTERFACE_NAME "vtk${NAME}")
set(INTERFACE_VERSION "${VERSION}")
cmake_parse_arguments(_add_visit_reader
""
"VISIT_INTERFACE_CALL;VISIT_INTERFACE_FILE"
"VISIT_READERS;SERVER_SOURCES"
""
${ARGN})
if (_add_visit_reader_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
"Unparsed arguments for add_visit_interface_reader: "
"${_add_visit_reader_UNPARSED_ARGUMENTS}")
endif ()
if (NOT DEFINED _add_visit_reader_VISIT_INTERFACE_CALL)
message(FATAL_ERROR
"The `VISIT_INTERFACE_CALL` argument is required.")
endif ()
if (NOT DEFINED _add_visit_reader_VISIT_INTERFACE_FILE)
message(FATAL_ERROR
"The `VISIT_INTERFACE_FILE` argument is required.")
endif ()
set(_add_visit_reader_parse "")
set(_add_visit_reader_names)
set(_add_visit_reader_name)
set(_add_visit_reader_type)
set(_add_visit_reader_include)
foreach (_add_visit_reader_arg IN LISTS _add_visit_reader_VISIT_READERS)
if (_add_visit_reader_parse STREQUAL "")
set(_add_visit_reader_parse "${_add_visit_reader_arg}")
elseif (_add_visit_reader_parse STREQUAL "NAME")
set(_add_visit_reader_name "${_add_visit_reader_arg}")
list(APPEND _add_visit_reader_names "${_add_visit_reader_name}")
set(_add_visit_reader_parse "")
elseif (_add_visit_reader_parse STREQUAL "USES_INTERFACE")
if (NOT _add_visit_reader_name)
message(FATAL_ERROR
"Missing `NAME`")
endif ()
if (DEFINED "_add_visit_reader_${_add_visit_reader_name}_uses_interface")
message(FATAL_ERROR
"Duplicate `USES_INTERFACE` for `${_add_visit_reader_name}`")
endif ()
set("_add_visit_reader_${_add_visit_reader_name}_uses_interface"
"${_add_visit_reader_arg}")
set(_add_visit_reader_parse "")
elseif (_add_visit_reader_parse STREQUAL "TYPE")
if (NOT _add_visit_reader_name)
message(FATAL_ERROR
"Missing `NAME`")
endif ()
if (DEFINED "_add_visit_reader_${_add_visit_reader_name}_type")
message(FATAL_ERROR
"Duplicate `TYPE` for `${_add_visit_reader_name}`")
endif ()
set("_add_visit_reader_${_add_visit_reader_name}_type"
"${_add_visit_reader_arg}")
set(_add_visit_reader_parse "")
elseif (_add_visit_reader_parse STREQUAL "INCLUDE")
if (NOT _add_visit_reader_name)
message(FATAL_ERROR
"Missing `NAME`")
endif ()
if (DEFINED "_add_visit_reader_${_add_visit_reader_name}_include")
message(FATAL_ERROR
"Duplicate `INCLUDE` for `${_add_visit_reader_name}`")
endif ()
set("_add_visit_reader_${_add_visit_reader_name}_include"
"${_add_visit_reader_arg}")
set(_add_visit_reader_parse "")
else ()
message(FATAL_ERROR
"Unknown argument `${_add_visit_reader_parse}`")
endif ()
endforeach ()
if (_add_visit_reader_parse)
message(FATAL_ERROR
"Missing argument for `${_add_visit_reader_parse}`")
endif ()
if (NOT _add_visit_reader_names)
message(FATAL_ERROR
"No `NAME` arguments given")
endif ()
set(_add_visit_reader_sources)
set(_add_visit_reader_headers)
foreach (_add_visit_reader_name IN LISTS _add_visit_reader_names)
if (NOT DEFINED "_add_visit_reader_${_add_visit_reader_name}_type")
message(FATAL_ERROR
"Missing `TYPE` for `${_add_visit_reader_name}`")
endif ()
if (NOT DEFINED "_add_visit_reader_${_add_visit_reader_name}_uses_interface")
set("_add_visit_reader_${_add_visit_reader_name}_uses_interface" ON)
endif ()
if (NOT DEFINED "_add_visit_reader_${_add_visit_reader_name}_include")
set("_add_visit_reader_${_add_visit_reader_name}_include"
"${_add_visit_reader_name}")
endif ()
set(_add_visit_reader_VISIT_READER_NAME
"${_add_visit_reader_name}")
set(_add_visit_reader_type
"${_add_visit_reader_${_add_visit_reader_name}_type}")
set(_add_visit_reader_uses_interface
"${_add_visit_reader_${_add_visit_reader_name}_uses_interface}")
set(_add_visit_reader_VISIT_INCLUDE_NAME
"${_add_visit_reader_${_add_visit_reader_name}_include}")
string(REGEX REPLACE "^avt|FileFormat$" "" _add_visit_reader_name_base "${_add_visit_reader_name}")
set(_add_visit_reader_plugin_name "vtkVisIt${_add_visit_reader_name_base}Reader")
string(SUBSTRING "${_add_visit_reader_type}" 0 2 _add_visit_reader_wrapper_type)
set(_add_visit_reader_interface_header
"${_VisItReader_output_dir}/${_add_visit_reader_plugin_name}${_add_visit_reader_VISIT_INTERFACE_FILE}.h")
set(_add_visit_reader_source
"${_VisItReader_output_dir}/${_add_visit_reader_plugin_name}.cxx")
set(_add_visit_reader_header
"${_VisItReader_output_dir}/${_add_visit_reader_plugin_name}.h")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${_add_visit_reader_VISIT_INTERFACE_FILE}.h.in"
"${_add_visit_reader_interface_header}"
@ONLY)
configure_file(
"${_VisItReader_cmake_dir}/VisIt${_add_visit_reader_wrapper_type}.h.in"
"${_add_visit_reader_header}"
@ONLY)
configure_file(
"${_VisItReader_cmake_dir}/VisIt${_add_visit_reader_wrapper_type}.cxx.in"
"${_add_visit_reader_source}"
@ONLY)
list(APPEND _add_visit_reader_sources
"${_add_visit_reader_interface_header}"
"${_add_visit_reader_source}")
list(APPEND _add_visit_reader_headers
"${_add_visit_reader_header}")
endforeach ()
# Fix up the arg_server_sources path for compilation
set(_add_visit_reader_server_sources)
foreach (_add_visit_reader_server_source IN LISTS _add_visit_reader_SERVER_SOURCES)
if (NOT IS_ABSOLUTE "${_add_visit_reader_server_source}")
string(PREPEND _add_visit_reader_server_source
"${CMAKE_CURRENT_SOURCE_DIR}/")
endif ()
list(APPEND _add_visit_reader_server_sources
"${_add_visit_reader_server_source}")
endforeach ()
set_property(GLOBAL APPEND
PROPERTY
_visit_server_sources "${_add_visit_reader_server_sources}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_sources "${_add_visit_reader_sources}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_headers "${_add_visit_reader_headers}")
set_property(GLOBAL APPEND
PROPERTY
_visit_db_include_dirs "${CMAKE_CURRENT_SOURCE_DIR}")
endfunction ()
/*=========================================================================
Program: ParaView
Module: @_add_visit_reader_plugin_name@.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "@_add_visit_reader_plugin_name@.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkMultiBlockDataSet.h"
#include "@_add_visit_reader_VISIT_INCLUDE_NAME@.h"
#include "avtDatabaseMetaData.h"
#include "avtMeshMetaData.h"
#include "avtVariableCache.h"
#cmakedefine01 _add_visit_reader_VISIT_READER_USES_OPTIONS
#if _add_visit_reader_VISIT_READER_USES_OPTIONS
#include "@_add_visit_reader_visit_plugin_info_header@.h"
#endif
#if _add_visit_reader_uses_interface
#include "@_add_visit_reader_plugin_name@@_add_visit_reader_VISIT_INTERFACE_FILE@.h"
#endif
vtkStandardNewMacro(@_add_visit_reader_plugin_name@);
//-----------------------------------------------------------------------------
@_add_visit_reader_plugin_name@::@_add_visit_reader_plugin_name@()
{
this->FileName = 0;
}
//-----------------------------------------------------------------------------
@_add_visit_reader_plugin_name@::~@_add_visit_reader_plugin_name@()
{
this->SetFileName(0);
}
#if _add_visit_reader_uses_interface
//-----------------------------------------------------------------------------
int @_add_visit_reader_plugin_name@::CanReadFile(const char *fname)
{
int valid = 0;
try
{
valid = @_add_visit_reader_plugin_name@@_add_visit_reader_VISIT_INTERFACE_FILE@::@_add_visit_reader_VISIT_INTERFACE_CALL@;
}
catch(...){}
return valid;
}
#endif
//-----------------------------------------------------------------------------
bool @_add_visit_reader_plugin_name@::InitializeAVTReader( const int& )
{
if (!this->MetaData)
{
this->MetaData = new avtDatabaseMetaData( );
}
if (!this->Cache)
{
this->Cache = new avtVariableCache( );
}
if (!this->AvtFile)
{
try
{
#if _add_visit_reader_VISIT_READER_USES_OPTIONS
@_add_visit_reader_visit_plugin_info_class@ *options =
new @_add_visit_reader_visit_plugin_info_class@();
this->AvtFile = new @_add_visit_reader_VISIT_READER_NAME@(
this->FileName, options->GetReadOptions() );
delete options;
#else
this->AvtFile = new @_add_visit_reader_VISIT_READER_NAME@(this->FileName);
#endif
}
catch(const VisItException& e)
{
vtkErrorMacro(<<e.Message());
this->AvtFile = NULL;
return false;
}
catch(const std::exception& e)
{
vtkErrorMacro(<<e.what());
this->AvtFile = NULL;
return false;
}
@_add_visit_reader_VISIT_READER_NAME@ *file = dynamic_cast<@_add_visit_reader_VISIT_READER_NAME@*>
(this->AvtFile);
if ( file )
{
//we have to make sure the visit reader populates its cache
//before activating a time step
try