Commit a42a11a0 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot

Merge topic '14244_fix_stereo_image_captures' into pv-master

edbb4ffe Merge topic '14244_fix_stereo_image_captures' into master
fa145803 Merge topic 'python-algorithm-old-python' into master
4b74588b vtkPythonAlgorithm: support older pythons
a4e10e46 Merge topic 'manual-VTKData-option' into master
56251ee5 Merge remote-tracking branch 'pvvtk/pv-master' into HEAD
7442036b Merge topic 'python-algorithm' into master
169f0154 BUG #14244: Fix stereo image captures.
6691160f FiltersPython: create a vtkPythonAlgorithm class
e8ba24a5 vtkAlgorithm: fix a typo
fec99e56 Add option to exclude VTKData target from default build
parents 02fae0a3 edbb4ffe
......@@ -72,3 +72,25 @@ set(ExternalData_LINK_CONTENT MD5)
# end in a (test) number that is not part of any series numbering.
set(ExternalData_SERIES_PARSE "()(\\.[^./]*)$")
set(ExternalData_SERIES_MATCH "(_[0-9]+)?")
if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
# Dashboard builds always need data.
set(VTK_DATA_EXCLUDE_FROM_ALL OFF)
endif()
if(NOT DEFINED VTK_DATA_EXCLUDE_FROM_ALL)
if(EXISTS "${VTK_SOURCE_DIR}/.ExternalData/config/exclude-from-all")
# Configuration left by developer setup script.
file(STRINGS "${VTK_SOURCE_DIR}/.ExternalData/config/exclude-from-all"
VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT LIMIT_COUNT 1 LIMIT_INPUT 1024)
elseif(DEFINED "ENV{VTK_DATA_EXCLUDE_FROM_ALL}")
set(VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT
"$ENV{VTK_DATA_EXCLUDE_FROM_ALL}")
else()
set(VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT OFF)
endif()
set(VTK_DATA_EXCLUDE_FROM_ALL "${VTK_DATA_EXCLUDE_FROM_ALL_DEFAULT}"
CACHE BOOL "Exclude test data download from default 'all' target."
)
mark_as_advanced(VTK_DATA_EXCLUDE_FROM_ALL)
endif()
......@@ -426,3 +426,11 @@ unset(_vtk_all_targets)
# Create target to download data from the VTKData group. This must come after
# all tests have been added that reference the group, so we put it last.
ExternalData_Add_Target(VTKData)
if(VTK_DATA_EXCLUDE_FROM_ALL)
set_property(TARGET VTKData PROPERTY EXCLUDE_FROM_ALL 1)
if(BUILD_TESTING AND NOT VTK_DATA_EXCLUDE_FROM_ALL_NO_WARNING)
message(WARNING "VTK_DATA_EXCLUDE_FROM_ALL is ON so test data "
"(needed because BUILD_TESTING is ON) may not be available "
"without manually building the 'VTKData' target.")
endif()
endif()
......@@ -235,7 +235,7 @@ void vtkAlgorithm::SetInputArrayToProcess(
{
if (!fieldAssociation)
{
vtkErrorMacro("Association is requied");
vtkErrorMacro("Association is required");
return;
}
if (!fieldAttributeTypeOrName)
......
set(Module_SRCS
vtkPythonAlgorithm.cxx
)
vtk_module_library(vtkFiltersPython ${Module_SRCS})
vtk_module(vtkFiltersPython
GROUPS
StandAlone
DEPENDS
vtkCommonExecutionModel
vtkPython
PRIVATE_DEPENDS
vtkWrappingPythonCore
)
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPythonAlgorithm.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.
=========================================================================*/
#include "vtkPythonAlgorithm.h"
#include "vtkObjectFactory.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkPythonUtil.h"
vtkStandardNewMacro(vtkPythonAlgorithm);
void vtkPythonAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
PyObject* str = NULL;
if (this->Object)
{
str = PyObject_Str(this->Object);
}
os << indent << "Object: " << Object << std::endl;
if (str)
{
os << indent << "Object (string): " << PyString_AsString(str) << std::endl;
Py_DECREF(str);
}
}
vtkPythonAlgorithm::vtkPythonAlgorithm()
{
this->Object = NULL;
}
vtkPythonAlgorithm::~vtkPythonAlgorithm()
{
Py_XDECREF(this->Object);
}
#define VTK_GET_METHOD(var, obj, method, failValue) \
if (!obj) \
{ \
return failValue; \
} \
PyObject* var = PyObject_GetAttrString(obj, method); \
if (!var) \
{ \
return failValue; \
} \
if (!PyCallable_Check(var)) \
{ \
Py_DECREF(var); \
return failValue; \
}
static PyObject* VTKToPython(vtkObjectBase* obj)
{
return vtkPythonUtil::GetObjectFromPointer(obj);
}
static std::string GetPythonErrorString()
{
PyObject* type;
PyObject* value;
PyObject* traceback;
// Increments refcounts for returns.
PyErr_Fetch(&type, &value, &traceback);
if (!type)
{
return "No error from Python?!";
}
PyObject* pyexc_string = PyObject_Str(value);
std::string exc_string;
if (pyexc_string)
{
exc_string = PyString_AsString(pyexc_string);
Py_DECREF(pyexc_string);
}
else
{
exc_string = "<Unable to convert Python error to string>";
}
Py_XDECREF(type);
Py_XDECREF(value);
Py_XDECREF(traceback);
PyErr_Clear();
return exc_string;
}
int vtkPythonAlgorithm::CheckResult(const char* method, PyObject* res)
{
if (!res)
{
std::string pymsg = GetPythonErrorString();
vtkErrorMacro("Failure when calling method: \""
<< method << "\": " << pymsg << ".");
return 0;
}
if (!PyInt_Check(res))
{
Py_DECREF(res);
return 0;
}
int code = PyInt_AsLong(res);
Py_DECREF(res);
return code;
}
void vtkPythonAlgorithm::SetPythonObject(PyObject* obj)
{
if (!obj)
{
return;
}
Py_XDECREF(this->Object);
this->Object = obj;
Py_INCREF(this->Object);
char mname[] = "Initialize";
VTK_GET_METHOD(method, this->Object, mname, /* no return */)
PyObject* args = PyTuple_New(1);
PyObject* vtkself = VTKToPython(this);
PyTuple_SET_ITEM(args, 0, vtkself);
PyObject* result = PyObject_Call(method, args, NULL);
Py_DECREF(args);
Py_DECREF(method);
CheckResult(mname, result);
}
void vtkPythonAlgorithm::SetNumberOfInputPorts(int n)
{
this->Superclass::SetNumberOfInputPorts(n);
}
void vtkPythonAlgorithm::SetNumberOfOutputPorts(int n)
{
this->Superclass::SetNumberOfOutputPorts(n);
}
int vtkPythonAlgorithm::ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo)
{
char mname[] = "ProcessRequest";
VTK_GET_METHOD(method, this->Object, mname, 0)
PyObject* args = PyTuple_New(4);
PyObject* vtkself = VTKToPython(this);
PyTuple_SET_ITEM(args, 0, vtkself);
PyObject* pyrequest = VTKToPython(request);
PyTuple_SET_ITEM(args, 1, pyrequest);
int nports = this->GetNumberOfInputPorts();
PyObject* pyininfos = PyTuple_New(nports);
for (int i = 0; i < nports; ++i)
{
PyObject* pyininfo = VTKToPython(inInfo[i]);
PyTuple_SET_ITEM(pyininfos, i, pyininfo);
}
PyTuple_SET_ITEM(args, 2, pyininfos);
PyObject* pyoutinfo = VTKToPython(outInfo);
PyTuple_SET_ITEM(args, 3, pyoutinfo);
PyObject* result = PyObject_Call(method, args, NULL);
Py_DECREF(method);
Py_DECREF(args);
return CheckResult(mname, result);
}
int vtkPythonAlgorithm::FillInputPortInformation(int port, vtkInformation* info)
{
char mname[] = "FillInputPortInformation";
VTK_GET_METHOD(method, this->Object, mname, 0)
PyObject* args = PyTuple_New(3);
PyObject* vtkself = VTKToPython(this);
PyTuple_SET_ITEM(args, 0, vtkself);
PyObject* pyport = PyInt_FromLong(port);
PyTuple_SET_ITEM(args, 1, pyport);
PyObject* pyinfo = VTKToPython(info);
PyTuple_SET_ITEM(args, 2, pyinfo);
PyObject* result = PyObject_Call(method, args, NULL);
Py_DECREF(method);
Py_DECREF(args);
return CheckResult(mname, result);
}
int vtkPythonAlgorithm::FillOutputPortInformation(int port, vtkInformation* info)
{
char mname[] = "FillOutputPortInformation";
VTK_GET_METHOD(method, this->Object, mname, 0)
PyObject* args = PyTuple_New(3);
PyObject* vtkself = VTKToPython(this);
PyTuple_SET_ITEM(args, 0, vtkself);
PyObject* pyport = PyInt_FromLong(port);
PyTuple_SET_ITEM(args, 1, pyport);
PyObject* pyinfo = VTKToPython(info);
PyTuple_SET_ITEM(args, 2, pyinfo);
PyObject* result = PyObject_Call(method, args, NULL);
Py_DECREF(method);
Py_DECREF(args);
return CheckResult(mname, result);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPythonAlgorithm.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 vtkPythonAlgorithm - a user-programmable filter
// .SECTION Description
// vtkPythonAlgorithm is a filter that calls a Python object to do the actual
// work.
// .SECTION See Also
// vtkProgrammableFilter
#ifndef __vtkPythonAlgorithm_h
#define __vtkPythonAlgorithm_h
#include "vtkPython.h" // Must be first
#include "vtkFiltersPythonModule.h" // For export macro
#include "vtkAlgorithm.h"
class VTKFILTERSPYTHON_EXPORT vtkPythonAlgorithm : public vtkAlgorithm
{
public:
static vtkPythonAlgorithm *New();
vtkTypeMacro(vtkPythonAlgorithm, vtkAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the Python object to use to operate on the data. A reference will
// be taken on the object.
void SetPythonObject(PyObject* obj);
// Description:
// Set the number of input ports used by the algorithm.
virtual void SetNumberOfInputPorts(int n);
// Description:
// Set the number of output ports provided by the algorithm.
virtual void SetNumberOfOutputPorts(int n);
protected:
vtkPythonAlgorithm();
~vtkPythonAlgorithm();
virtual int ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo);
virtual int FillInputPortInformation(int port, vtkInformation* info);
virtual int FillOutputPortInformation(int port, vtkInformation* info);
private:
vtkPythonAlgorithm(const vtkPythonAlgorithm&); // Not implemented.
void operator=(const vtkPythonAlgorithm&); // Not implemented.
int CheckResult(const char* method, PyObject* res);
PyObject* Object;
};
#endif
......@@ -292,25 +292,7 @@ void vtkWindowToImageFilter::RequestData(
viewAngles[i] = cams[i]->GetViewAngle();
parallelScale[i] = cams[i]->GetParallelScale();
cam = cams[i]->NewInstance();
cam->SetPosition(cams[i]->GetPosition());
cam->SetFocalPoint(cams[i]->GetFocalPoint());
cam->SetViewUp(cams[i]->GetViewUp());
cam->SetClippingRange(cams[i]->GetClippingRange());
cam->SetParallelProjection(cams[i]->GetParallelProjection());
cam->SetFocalDisk(cams[i]->GetFocalDisk());
cam->SetUserTransform(cams[i]->GetUserTransform());
cam->SetUseHorizontalViewAngle(cams[i]->GetUseHorizontalViewAngle());
cam->SetViewShear(cams[i]->GetViewShear());
cam->SetModelTransformMatrix(cams[i]->GetModelTransformMatrix());
cam->SetEyeTransformMatrix(cams[i]->GetEyeTransformMatrix());
cam->SetUseOffAxisProjection(cams[i]->GetUseOffAxisProjection());
cam->SetScreenBottomLeft(cams[i]->GetScreenBottomLeft());
cam->SetScreenBottomRight(cams[i]->GetScreenBottomRight());
cam->SetScreenTopRight(cams[i]->GetScreenTopRight());
cam->SetEyeSeparation(cams[i]->GetEyeSeparation());
double eyePos[3];
cams[i]->GetEyePosition(eyePos);
cam->SetEyePosition(eyePos);
cam->ShallowCopy(cams[i]);
aren->SetActiveCamera(cam);
}
......
......@@ -90,3 +90,57 @@ case "$ans" in
*) mkdir -p "${config_store%/*}" && echo "$ans" > "$config_store" ;;
esac &&
say_store
say_exclude() {
if test -f "$config_exclude"; then
echo 'A default for VTK_DATA_EXCLUDE_FROM_ALL is configured as:' &&
echo &&
sed 's/^/ /' < "$config_exclude" &&
echo
else
echo 'No default for VTK_DATA_EXCLUDE_FROM_ALL is configured.' &&
echo
fi
}
ask_exclude() {
ans='?'
while test "$ans" = '?'; do
read -ep 'From the options
<empty> = No change
d,delete = No default or delete current default
n,no,off = Include VTKData target in default build
y,yes,on = Exclude VTKData target from default build
select a default for VTK_DATA_EXCLUDE_FROM_ALL [d/n/y]: ' ans &&
case "$ans" in
d|D|delete) ans='D' ;;
n|N|no|off) ans='OFF' ;;
y|Y|yes|on) ans='ON' ;;
'') ans='' ;;
*) echo; echo "Invalid response '$ans'!"; echo; ans='?' ;;
esac
done
eval "$1='$ans'"
}
cd "${BASH_SOURCE%/*}/../.." &&
config_exclude='.ExternalData/config/exclude-from-all' &&
echo 'VTK defines a "VTKData" build target to download data
objects at build time to make them available for running tests.
VTK build trees have a VTK_DATA_EXCLUDE_FROM_ALL CMake
cache option to exclude the "VTKData" target from being built
as part of the default ("all") build. A default for this value to
be used in build trees created with this source tree may now be
chosen.
' &&
say_exclude &&
ask_exclude ans &&
case "$ans" in
'') ;;
D) rm -f "$config_exclude" ;;
*) mkdir -p "${config_exclude%/*}" && echo "$ans" > "$config_exclude" ;;
esac &&
say_exclude
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