Commit 5b971bda authored by cyrush's avatar cyrush

merged python filters branch to trunk

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@9964 18c085ea-50e0-402c-830e-de6fd14e8384
parent 81015560
......@@ -38,6 +38,9 @@
# Kathleen Bonnell, Thu Dec 10 17:53:36 MT 2009
# Use the same find routines whether on Windows or not.
#
# Cyrus Harrison, Fri Feb 19 15:41:04 PST 2010
# Added install of vtk python wrappers (if they exist).
#
#****************************************************************************/
INCLUDE(${VISIT_SOURCE_DIR}/CMake/ThirdPartyInstallLibrary.cmake)
......@@ -130,6 +133,35 @@ FOREACH(X ${VTK_INCLUDE_DIRS})
ENDIF(EXISTS ${X}/vtkActor.h)
ENDFOREACH(X)
# check for python wrappers
FILE(GLOB VTK_PY_WRAPPERS_DIR ${VTK_LIBRARY_DIRS}/python*/)
IF(EXISTS ${VTK_PY_WRAPPERS_DIR})
MESSAGE(STATUS ${VTK_PY_WRAPPERS_DIR})
FILE(GLOB VTK_PY_EGG ${VTK_PY_WRAPPERS_DIR}/site-packages/*.egg*)
FILE(GLOB VTK_PY_MODULE ${VTK_PY_WRAPPERS_DIR}/site-packages/vtk)
INSTALL(FILES ${VTK_PY_EGG}
DESTINATION ${VISIT_INSTALLED_VERSION_LIB}/site-packages/
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ
)
INSTALL(DIRECTORY ${VTK_PY_MODULE}
DESTINATION ${VISIT_INSTALLED_VERSION_LIB}/site-packages/
FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_WRITE GROUP_READ WORLD_READ
DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
SET(VTK_PYTHON_WRAPPERS_FOUND TRUE)
ELSE(EXISTS ${VTK_PY_WRAPPERS_DIR})
SET(VTK_PYTHON_WRAPPERS_FOUND FALSE)
ENDIF(EXISTS ${VTK_PY_WRAPPERS_DIR})
MARK_AS_ADVANCED(VTK_PYTHON_WRAPPERS_FOUND)
#INSTALL(DIRECTORY vtk
# DESTINATION ${VISIT_INSTALLED_VERSION_INCLUDE}/vtk/include
# #FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_WRITE GROUP_READ WORLD_READ
# DIRE
IF(NOT ${VTK_FOUND})
MESSAGE(FATAL_ERROR "VTK is required to build VisIt.")
ENDIF(NOT ${VTK_FOUND})
......@@ -78,6 +78,9 @@
# Removed conditional setting of VISIT_RENDERING_SIZE_LIMIT, in case
# initial configure pass was missing something. Install our zlib on windows.
#
# Cyrus Harrison, Sun Feb 21 19:12:33 PST 2010
# Added support for enable/disable of Python Engine Filters.
#
#****************************************************************************/
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.4 FATAL_ERROR)
......@@ -188,6 +191,19 @@ IF(VISIT_STATIC)
ADD_DEFINITIONS(-DVISIT_STATIC -DGLEW_STATIC)
ENDIF(VISIT_STATIC)
OPTION(VISIT_PYTHON_SCRIPTING "Build VisIt with Python scripting support." ON)
OPTION(VISIT_PYTHON_FILTERS "Build VisIt with Python Engine Filter support." OFF)
# VTK Python's wrappers avalaible with the static libs, so we cannot support
# python filters in a static build
IF(VISIT_STATIC AND VISIT_PYTHON_FILTERS)
SET(VISIT_PYTHON_FILTERS OFF)
MESSAGE(STATUS "Python Engine Filters are not supported for static build")
ENDIF(VISIT_STATIC AND VISIT_PYTHON_FILTERS)
IF(VISIT_PYTHON_FILTERS)
ADD_DEFINITIONS(-DVISIT_PYTHON_FILTERS)
ENDIF(VISIT_PYTHON_FILTERS)
OPTION(VISIT_BUILD_ALL_PLUGINS "Build all of VisIt's plugins." OFF)
OPTION(VISIT_BUILD_MINIMAL_PLUGINS "Build a minimal set of VisIt's plugins." OFF)
OPTION(VISIT_ZLIB "Use VisIt's internal libz" OFF)
......
......@@ -59,4 +59,7 @@ ELSE(VISIT_DBIO_ONLY)
ADD_SUBDIRECTORY(FileWriter)
ADD_SUBDIRECTORY(VisWindow)
ADD_SUBDIRECTORY(QtVisWindow)
IF(VISIT_PYTHON_FILTERS)
ADD_SUBDIRECTORY(PythonFilters)
ENDIF(VISIT_PYTHON_FILTERS)
ENDIF(VISIT_DBIO_ONLY)
......@@ -35,6 +35,8 @@
# DAMAGE.
#
# Modifications:
# Cyrus Harrison,Tue Feb 2 16:35:18 PST 2010
# Added the python filter expression.
#
#****************************************************************************/
......@@ -145,6 +147,10 @@ General/avtViscousStressExpression.C
General/avtZoneTypeExpression.C
)
IF(VISIT_PYTHON_FILTERS)
LIST(APPEND GENERAL_SOURCES General/avtPythonExpression.C)
ENDIF(VISIT_PYTHON_FILTERS)
SET(IMAGEPROCESSING_SOURCES
ImageProcessing/avtAbelInversionExpression.C
ImageProcessing/avtConservativeSmoothingExpression.C
......@@ -305,17 +311,36 @@ ${VISIT_SOURCE_DIR}/third_party_builtin/verdict
${VTK_INCLUDE_DIRS}
)
IF(VISIT_PYTHON_FILTERS)
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_DIRS}
${VISIT_SOURCE_DIR}/avt/PythonFilters
)
ENDIF(VISIT_PYTHON_FILTERS)
# Add link directories
LINK_DIRECTORIES(${LIBRARY_OUTPUT_DIRECTORY} ${VTK_LIBRARY_DIRS} ${MESA_LIBRARY_DIR} ${GLEW_LIBRARY_DIR})
IF(VISIT_PYTHON_FILTERS)
LINK_DIRECTORIES(${PYTHON_LIBRARY_DIRS})
ENDIF(VISIT_PYTHON_FILTERS)
#********************************* SERIAL ************************************
ADD_LIBRARY(avtexpressions_ser ${AVTEXPRESSIONS_SOURCES})
TARGET_LINK_LIBRARIES(avtexpressions_ser visitcommon avtdbatts avtdatabase_ser avtddf_ser avtplotter_ser avtfilters_ser avtpipeline_ser)
IF(VISIT_PYTHON_FILTERS)
TARGET_LINK_LIBRARIES(avtexpressions_ser avtpythonfilters_ser)
ENDIF(VISIT_PYTHON_FILTERS)
VISIT_INSTALL_TARGETS(avtexpressions_ser)
#********************************* PARALLEL **********************************
IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(avtexpressions_par ${AVTEXPRESSIONS_SOURCES})
TARGET_LINK_LIBRARIES(avtexpressions_par visitcommon avtdbatts avtdatabase_par avtddf_par avtplotter_par avtfilters_par avtpipeline_par)
IF(VISIT_PYTHON_FILTERS)
TARGET_LINK_LIBRARIES(avtexpressions_par avtpythonfilters_par)
ENDIF(VISIT_PYTHON_FILTERS)
VISIT_INSTALL_TARGETS(avtexpressions_par)
ENDIF(VISIT_PARALLEL)
This diff is collapsed.
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 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 LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY 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.
*
*****************************************************************************/
// ************************************************************************* //
// avtPythonExpression.h //
// ************************************************************************* //
#ifndef AVT_PYTHON_EXPRESSION_H
#define AVT_PYTHON_EXPRESSION_H
#include <avtExpressionFilter.h>
class avtPythonFilterEnvironment;
// ****************************************************************************
// Class: avtPythonExpression
//
// Purpose:
// TODO
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 2 13:45:21 PST 2010
//
// Modifications:
//
// ****************************************************************************
class EXPRESSION_API avtPythonExpression : public avtExpressionFilter
{
public:
avtPythonExpression();
virtual ~avtPythonExpression();
void CleanUp();
virtual const char *GetType(void);
virtual const char *GetDescription(void);
virtual int NumVariableArguments(void);
virtual int GetVariableDimension(void);
virtual bool IsPointVariable(void);
virtual void ProcessArguments(ArgsExpr*, ExprPipelineState *);
protected:
virtual void Execute(void);
virtual avtContract_p ModifyContract(avtContract_p);
private:
avtPythonFilterEnvironment *pyEnv;
std::string pyScript;
};
#endif
......@@ -90,6 +90,10 @@
#include <avtVectorComposeExpression.h>
#include <avtVectorDecomposeExpression.h>
#ifdef VISIT_PYTHON_FILTERS
#include <avtPythonExpression.h>
#endif
using std::string;
// ****************************************************************************
......@@ -451,6 +455,9 @@ avtVectorExpr::CreateFilters(ExprPipelineState *state)
// Cyrus Harrison, Tue Aug 11 10:34:08 PDT 2009
// Added the "map" expression.
//
// Cyrus Harrison, Tue Feb 2 14:54:25 PST 2010
// Added the "python" expression.
//
// ****************************************************************************
avtExpressionFilter *
......@@ -498,6 +505,14 @@ avtFunctionExpr::CreateFilters(string functionName)
return new avtCylindricalCoordinatesExpression();
if (functionName == "procid")
return new avtProcessorIdExpression();
if (functionName == "python" || functionName == "py")
#ifdef VISIT_PYTHON_FILTERS
return new avtPythonExpression();
#else
EXCEPTION1(VisItException,
"Cannot execute Python Filter Expression because "
"VisIt was build without Python Filter support.");
#endif
if (functionName == "mean_curvature")
{
avtCurvatureExpression *c = new avtCurvatureExpression;
......
......@@ -305,3 +305,21 @@ avtContract::DebugDump(avtWebpage *webpage)
}
// ****************************************************************************
// Method: avtContract::Print
//
// Purpose:
// Contract print function. Uses overloaed << operator.
//
// Programmer: Cyrus Harrison
// Creation: June 5, 2001
//
// ****************************************************************************
void
avtContract::Print(ostream &os)
{
os << this;
}
......@@ -97,6 +97,9 @@ typedef ref_ptr<avtContract> avtContract_p;
// Tom Fogal, Sun May 3 17:52:35 MDT 2009
// I overloaded operator<< to allow for easier debugging.
//
// Cyrus Harrison, Sat Feb 20 21:37:24 PST 2010
// Added Print() which calls 'operator<<' to get around visiblity issues.
//
// ****************************************************************************
class PIPELINE_API avtContract
......@@ -139,7 +142,7 @@ class PIPELINE_API avtContract
avtContract &operator=(const avtContract &);
void DebugDump(avtWebpage *);
void Print(ostream &);
protected:
avtDataRequest_p data;
int pipelineIndex;
......
#*****************************************************************************
#
# Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
# Produced at the Lawrence Livermore National Laboratory
# LLNL-CODE-400142
# All rights reserved.
#
# This file is part of VisIt. For details, see https://visit.llnl.gov/. The
# full copyright notice is contained in the file COPYRIGHT located at the root
# of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# 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 LAWRENCE LIVERMORE NATIONAL SECURITY,
# LLC, THE U.S. DEPARTMENT OF ENERGY 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.
#
# Modifications:
#
#****************************************************************************/
SET(AVTPYTHON_FILTERS_SOURCES
PythonInterpreter.C
PyContract.C
PyDataRequest.C
PyDataSelection.C
PySILRequest.C
${VISIT_SOURCE_DIR}/visitpy/common/PySILRestrictionBase.C
avtPythonFilterEnvironment.C
avtPythonFilter.C
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${VISIT_COMMON_INCLUDES}
${VISIT_SOURCE_DIR}/avt/Pipeline/Data/
${VISIT_SOURCE_DIR}/avt/Pipeline/Pipeline/
${VISIT_SOURCE_DIR}/avt/DBAtts/
${VISIT_SOURCE_DIR}/avt/DBAtts/MetaData/
${VISIT_SOURCE_DIR}/avt/DBAtts/SIL/
${VISIT_SOURCE_DIR}/visitpy/common/
${VTK_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
)
# Add link directories
LINK_DIRECTORIES(${LIBRARY_OUTPUT_DIRECTORY} ${VTK_LIBRARY_DIRS} ${PYTHON_DIRS})
#********************************* SERIAL ************************************
ADD_LIBRARY(avtpythonfilters_ser ${AVTPYTHON_FILTERS_SOURCES})
TARGET_LINK_LIBRARIES(avtpythonfilters_ser visitcommon avtdbatts avtpipeline_ser ${PYTHON_LIBRARIES} )
VISIT_INSTALL_TARGETS(avtpythonfilters_ser)
#********************************* PARALLEL **********************************
IF(VISIT_PARALLEL)
ADD_PARALLEL_LIBRARY(avtpythonfilters_par ${AVTPYTHON_FILTERS_SOURCES})
TARGET_LINK_LIBRARIES(avtpythonfilters_par visitcommon avtdbatts avtpipeline_par ${PYTHON_LIBRARIES})
VISIT_INSTALL_TARGETS(avtpythonfilters_par)
ENDIF(VISIT_PARALLEL)
/*****************************************************************************
*
* Copyright (c) 2000 - 2009, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* 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 LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY 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 <Python.h>
#include <PyContract.h>
#include <PyDataRequest.h>
// ****************************************************************************
// Modifications:
//
// ****************************************************************************
struct PyContractObject
{
PyObject_HEAD
avtContract_p *contract;
};
//
// Internal prototypes
//
//
// avtContract methods
//
// ****************************************************************************
// Function: Contract_ShouldUseStreaming
//
// Purpose:
// Wrap avtContract::ShouldUseStreaming.
//
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 9 08:58:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
static PyObject *
Contract_ShouldUseStreaming(PyObject *self, PyObject *args)
{
PyContractObject *obj = (PyContractObject *)self;
avtContract_p contract= *(obj->contract);
if(contract->ShouldUseStreaming())
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
// ****************************************************************************
// Function: Contract_NoStreaming
//
// Purpose:
// Wrap avtContract::NoStreaming.
//
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 9 08:58:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
static PyObject *
Contract_NoStreaming(PyObject *self, PyObject *args)
{
PyContractObject *obj = (PyContractObject *)self;
avtContract_p contract= *(obj->contract);
contract->NoStreaming();
Py_RETURN_NONE;
}
// ****************************************************************************
// Function: Contract_ShouldUseLoadBalancing
//
// Purpose:
// Wrap avtContract::ShouldUseLoadBalancing.
//
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 9 08:58:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
static PyObject *
Contract_ShouldUseLoadBalancing(PyObject *self, PyObject *args)
{
PyContractObject *obj = (PyContractObject *)self;
avtContract_p contract= *(obj->contract);
if(contract->ShouldUseLoadBalancing())
Py_RETURN_TRUE;
else
Py_RETURN_FALSE;
}
// ****************************************************************************
// Function: Contract_UseLoadBalancing
//
// Purpose:
// Wrap avtContract::UseLoadBalancing.
//
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 9 08:58:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
static PyObject *
Contract_UseLoadBalancing(PyObject *self, PyObject *args)
{
PyContractObject *obj = (PyContractObject *)self;
avtContract_p contract= *(obj->contract);
// parse bool from args
PyObject *py_val;
if(!PyArg_ParseTuple(args, "o", &py_val))
return NULL;
if(PyBool_Check(py_val) == 0)
return NULL;
bool val;
if(py_val == Py_True)
val = true;
else if(py_val == Py_False)
val = false;
contract->UseLoadBalancing(val);
Py_RETURN_NONE;
}
// ****************************************************************************
// Function: Contract_SetHaveRectilinearMeshOptimizations
//
// Purpose:
// Wrap avtContract::SetHaveRectilinearMeshOptimizations.
//
//
// Programmer: Cyrus Harrison
// Creation: Tue Feb 9 08:58:23 PST 2010
//
// Modifications:
//
// ****************************************************************************
static PyObject *
Contract_SetHaveRectilinearMeshOptimizations(PyObject *self, PyObject *args)
{
PyContractObject *obj = (PyContractObject *)self;
avtContract_p contract= *(obj->contract);
// parse bool from args
PyObject *py_val;
if(!PyArg_ParseTuple(args, "o", &py_val))
return NULL;
if(PyBool_Check(py_val) == 0)
return NULL;
bool val;
if(py_val == Py_True)
val = true;
else if(py_val == Py_False)
val = false;
contract->SetHaveRectilinearMeshOptimizations(val);