<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello,<br>I am trying to combine VTK6.2 with OpenFOAM (<a href="http://www.openfoam.com">www.openfoam.com</a>).<br></div>Unfortunately, the simplest VTK examples crash when I am calling OpenFOAM functions before. I know, it is difficult for you to judge what happens in these functions, but maybe you have some hints what to search for, or maybe some of you are familiar with OpenFOAM. The gdb stacktrace doesn't show useful information although VTK6.2 and OpenFOAM are compiled with debug flags. I didn't have such problems with VTK5.8.<br><br></div>I attach below the code of Examples/Tutorial/Step5/Cxx, which is only modified in 2 lines, and the CMakeLists.txt which includes the additional settings for OpenFOAM 2.3.1.<br><br>The output from running the modified example is:<br>$ ./Cone5 <br>/*---------------------------------------------------------------------------*\<br>| =========                 |                                                 |<br>| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |<br>|  \\    /   O peration     | Version:  2.3.1                                 |<br>|   \\  /    A nd           | Web:      <a href="http://www.OpenFOAM.org">www.OpenFOAM.org</a>                      |<br>|    \\/     M anipulation  |                                                 |<br>\*---------------------------------------------------------------------------*/<br>Build  : 2.3.1-bcfaaa7b8660<br>Exec   : ./Cone5<br>Date   : Apr 28 2015<br>Time   : 14:24:08<br>Host   : "ip-10-230-129-53"<br>PID    : 13462<br>Case   : /home/ubuntu/Tutorial/Step5/Cxx<br>nProcs : 1<br>sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).<br>fileModificationChecking : Monitoring run-time modified files using timeStampMaster<br>allowSystemOperations : Allowing user-supplied system call operations<br><br>// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //<br>Floating point exception (core dumped)<br></div>--- End of output ---<br><br></div>--- CMakeLists.txt ---<br>cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)<br>if(POLICY CMP0025)<br>  cmake_policy(SET CMP0025 NEW) # CMake 3.0<br>endif()<br>if(POLICY CMP0053)<br>  cmake_policy(SET CMP0053 NEW) # CMake 3.1<br>endif()<br><br>PROJECT (Step5)<br><br>find_package(VTK COMPONENTS<br>  vtkCommonCore<br>  vtkFiltersSources<br>  vtkInteractionStyle<br>  vtkRenderingOpenGL<br>)<br>include(${VTK_USE_FILE})<br>set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -m64 -Dlinux64 -DWM_DP -DNoRepository -Xlinker --add-needed")<br><br>include_directories($ENV{FOAM_SRC}/finiteVolume/lnInclude $ENV{FOAM_SRC}/OpenFOAM/lnInclude $ENV{FOAM_SRC}/OSspecific/POSIX/lnInclude)<br><br>add_executable(Cone5 MACOSX_BUNDLE Cone5.cxx)<br>target_link_libraries(Cone5 ${VTK_LIBRARIES} $ENV{FOAM_LIBBIN}/libfiniteVolume.so $ENV{FOAM_LIBBIN}/libOpenFOAM.so $ENV{FOAM_LIBBIN}/libmeshTools.so)<br></div>--- End of CMakeLists.txt ---<br><br></div>--- modified Cone5.cxx: ---<br>#include <fvCFD.H> //added for OpenFOAM<br>// First include the required header files for the VTK classes we are using.<br>#include "vtkConeSource.h"<br>#include "vtkPolyDataMapper.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkCamera.h"<br>#include "vtkActor.h"<br>#include "vtkRenderer.h"<br>#include "vtkInteractorStyleTrackballCamera.h"<br><br>int main(int argc, char **argv)<br>{<br>  Foam::argList args(argc, argv); //initializes OpenFOAM<br>    <br>  vtkConeSource *cone = vtkConeSource::New();<br>  cone->SetHeight( 3.0 );<br>  cone->SetRadius( 1.0 );<br>  cone->SetResolution( 10 );<br>  vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();<br>  coneMapper->SetInputConnection( cone->GetOutputPort() );<br>  vtkActor *coneActor = vtkActor::New();<br>  coneActor->SetMapper( coneMapper );<br>  vtkRenderer *ren1= vtkRenderer::New();<br>  ren1->AddActor( coneActor );<br>  ren1->SetBackground( 0.1, 0.2, 0.4 );<br>  vtkRenderWindow *renWin = vtkRenderWindow::New();<br>  renWin->AddRenderer( ren1 );<br>  renWin->SetSize( 300, 300 );<br>  <br>  //renWin->Render(); //Using this call instead of the remaining code<br>  //causes a crash, too.<br>  <br>  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>  iren->SetRenderWindow(renWin);<br>  vtkInteractorStyleTrackballCamera *style =<br>    vtkInteractorStyleTrackballCamera::New();<br>  iren->SetInteractorStyle(style);<br>  iren->Initialize();<br>  iren->Start();<br>  cone->Delete();<br>  coneMapper->Delete();<br>  coneActor->Delete();<br>  ren1->Delete();<br>  renWin->Delete();<br>  iren->Delete();<br>  style->Delete();<br>  return 0;<br>}<br></div>--- End of Cone5.cxx ---<br><br></div>Every input is welcome!<br></div>Mirko<br></div>