ENH: avoid deprecated resource xml when building paraview plugins (fixes #181)

- remove old VTK_CONVEX_POINT_SET code, since VTK_POLYHEDRON exists
  since several years

ENH: improve robustness of paraFoam script

- only check the relevant plugin types,
  fallback to native reader if needed/possible.
This commit is contained in:
Mark Olesen 2016-07-12 11:17:57 +02:00
parent a9fed233db
commit ecfbdce3da
7 changed files with 65 additions and 82 deletions

View File

@ -47,11 +47,14 @@ QT4_WRAP_CPP(MOC_SRCS pqPVFoamReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVFoamReaderPanel
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_NAME PVFoamReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -61,7 +64,7 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVFoamReader.xml
)
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ELSE()
ADD_PARAVIEW_PLUGIN(
PVFoamReader_SM "1.0"
SERVER_MANAGER_XML PVFoamReader_SM.xml
@ -70,7 +73,7 @@ ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
GUI_SOURCES pqPVFoamReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
)
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ENDIF()
TARGET_LINK_LIBRARIES(
PVFoamReader_SM

View File

@ -1,4 +1,5 @@
<ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVFoamReader"
extensions="OpenFOAM"
file_description="OpenFOAM Reader">

View File

@ -1,18 +1,12 @@
/* Note: enable vtkPolyhedron when available */
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I../../vtkPVReaders/lnInclude \
-I../PVFoamReader \
-I$(ParaView_INCLUDE_DIR) \
-I$(ParaView_INCLUDE_DIR)/vtkkwiml \
$(shell \
test -f $(ParaView_INCLUDE_DIR)/vtkPolyhedron.h && \
echo "-DHAS_VTK_POLYHEDRON" || echo "-UHAS_VTK_POLYHEDRON" \
)
-I../../vtkPVReaders/lnInclude \
-I../PVFoamReader
LIB_LIBS = \
-lmeshTools \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -275,7 +275,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
// Polyhedral cell - use VTK_POLYHEDRON
const labelList& cFaces = mesh.cells()[cellI];
#ifdef HAS_VTK_POLYHEDRON
vtkIdType nFaces = cFaces.size();
vtkIdType nLabels = nFaces;
@ -320,33 +319,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
}
vtkmesh->InsertNextCell(VTK_POLYHEDRON, nFaces, faceStream.data());
#else
// this is a horrible substitute
// but avoids crashes when there is no vtkPolyhedron support
// establish unique node ids used
HashSet<vtkIdType, Hash<label>> hashUniqId(2*256);
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
forAll(f, fp)
{
hashUniqId.insert(f[fp]);
}
}
// use face stream to store unique node ids:
faceStream = hashUniqId.sortedToc();
vtkmesh->InsertNextCell
(
VTK_CONVEX_POINT_SET,
vtkIdType(faceStream.size()),
faceStream.data()
);
#endif
}
else
{

View File

@ -46,13 +46,16 @@ QT4_WRAP_CPP(MOC_SRCS pqPVblockMeshReaderPanel.h)
ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS
CLASS_NAME pqPVblockMeshReaderPanel
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_NAME PVblockMeshReader # name of SourceProxy in *SM.xml
XML_GROUP sources
)
IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
# Separate GUI_RESOURCE_FILES deprecated with paraview 4.3
# so check if version < 4.4
IF(("${PARAVIEW_VERSION_MAJOR}" LESS 5) AND ("${PARAVIEW_VERSION_MINOR}" LESS 4))
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
@ -60,16 +63,16 @@ IF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
GUI_RESOURCE_FILES PVblockMeshReader.xml
)
ELSE("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
ELSE()
ADD_PARAVIEW_PLUGIN(
PVblockMeshReader_SM "1.0"
SERVER_MANAGER_XML PVblockMeshReader_SM.xml
SERVER_MANAGER_SOURCES vtkPVblockMeshReader.cxx
GUI_INTERFACES ${IFACES}
GUI_SOURCES pqPVblockMeshReaderPanel.cxx
${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS}
)
ENDIF("${PARAVIEW_VERSION_MINOR}" EQUAL 0)
ENDIF()
# Build the client-side plugin

View File

@ -1,4 +1,5 @@
<ParaViewReaders>
<!-- deprecated with paraview-4.3, use hints in *SM.xml -->
<Reader name="PVblockMeshReader"
extensions="blockMesh"
file_description="OpenFOAM blockMesh reader">

View File

@ -4,7 +4,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation |
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
#-------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -40,17 +40,18 @@ usage() {
Usage: ${0##*/} [OPTION] [PARAVIEW_OPTION]
options:
-block use blockMesh reader (uses .blockMesh extension)
-builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-case <dir> specify alternative case directory, default is the cwd
-region <name> specify alternative mesh region
-touch only create the file (eg, .blockMesh, .OpenFOAM, etc)
-touchAll create .blockMesh, .OpenFOAM files (and for all regions)
-vtk | -builtin use VTK builtin OpenFOAM reader (uses .foam extension)
-help print the usage
Paraview options start with a double dashes.
paraview options start with a double dashes
* start paraview with the OpenFOAM libraries
* start paraview $ParaView_VERSION with the OpenFOAM libraries
paraview=$(command -v paraview)
USAGE
exit 1
@ -67,10 +68,9 @@ unset regionName optTouch
# already 2010-07)
export LC_ALL=C
# Reader extension
# Reader extension and plugin
extension=OpenFOAM
requirePV=1
plugin=PVFoamReader
# Parse options
while [ "$#" -gt 0 ]
@ -81,11 +81,12 @@ do
;;
-block | -blockMesh)
extension=blockMesh
plugin=PVblockMeshReader
shift
;;
-builtin)
-builtin | -vtk)
extension=foam
requirePV=0
unset plugin
shift
;;
-case)
@ -100,12 +101,12 @@ do
;;
-touch)
optTouch=true
requirePV=0
unset plugin
shift
;;
-touchAll)
optTouch=all
requirePV=0
unset plugin
shift
;;
--)
@ -116,26 +117,34 @@ do
break # Stop here, treat this and balance as paraview options
;;
*)
usage "unknown option/argument: '$*'"
usage "unknown option/argument: '$1'"
;;
esac
done
# Check that reader module has been built
if [ $requirePV -eq 1 -a ! -f $PV_PLUGIN_PATH/libPVFoamReader_SM.so ]
then
cat<< BUILDREADER
FATAL ERROR: ParaView reader module libraries do not exist
# If a reader module is needed, check that it exists
[ -z "$plugin" -o -f $PV_PLUGIN_PATH/lib${plugin}_SM.so ] || {
cat<< BUILDREADER 1>&2
ERROR: ParaView reader module library ($plugin) does not exist
Please build the reader module before continuing:
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwclean
./Allwmake
cd \$FOAM_UTILITIES/postProcessing/graphics/PVReaders
./Allwclean
./Allwmake
BUILDREADER
exit 1
fi
# Fallback to native reader, if possible
if [ "$extension" = OpenFOAM ]
then
extension=foam
echo "Using the native VTK/OpenFOAM reader instead" 1>&2
else
exit 1
fi
}
# Check for --data=... argument
hasDataArg()
@ -165,7 +174,7 @@ if [ -n "$regionName" ]
then
if [ ! -d constant/$regionName ]
then
echo "FATAL ERROR: Region $regionName does not exist"
echo "FATAL ERROR: Region $regionName does not exist" 1>&2
exit 1
else
caseFile="$caseName{$regionName}.$extension"
@ -179,10 +188,10 @@ all)
if [ -f system/blockMeshDict -o -f constant/polyMesh/blockMeshDict ]
then
touch "$caseName.blockMesh"
echo "Created '$caseName.blockMesh'"
echo "Created '$caseName.blockMesh'" 1>&2
fi
touch "$caseName.$extension"
echo "Created '$caseName.$extension'"
echo "Created '$caseName.$extension'" 1>&2
# Discover probable regions
for region in constant/*
do
@ -190,14 +199,14 @@ all)
then
regionName=${region##*/}
touch "$caseName{$regionName}.$extension"
echo "Created '$caseName{$regionName}.$extension'"
echo "Created '$caseName{$regionName}.$extension'" 1>&2
fi
done
exit 0
;;
true)
touch "$caseFile"
echo "Created '$caseFile'"
echo "Created '$caseFile'" 1>&2
exit 0
;;
esac
@ -222,14 +231,14 @@ else
warn="WARN file does not exist:"
case $extension in
blockMesh)
blockMeshDictDir=system/blockMeshDict
blockMeshDict=system/blockMeshDict
if [ -f constant/polyMesh/blockMeshDict ]
then
blockMeshDictDir=constant/polyMesh/blockMeshDict
blockMeshDict=constant/polyMesh/blockMeshDict
fi
for check in \
system/controlDict \
$blockMeshDictDir \
$blockMeshDict \
;
do
[ -s "$parentDir/$check" ] || {
@ -240,7 +249,7 @@ else
done
;;
builtin | OpenFOAM)
OpenFOAM)
for check in \
system/controlDict \
$fvControls/fvSchemes \
@ -268,7 +277,7 @@ else
[ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile"
echo "Created temporary '$caseFile'"
echo "Created temporary '$caseFile'" 1>&2
}
# For now filter out any ld.so errors. Caused by non-system compiler?