From: Fabian B. <f.b...@gm...> - 2005-10-20 17:00:07
|
Hi Dragan, thanks for the quick reply. * On 18 Oct 2005 * Dragan Tubic wrote: > You'll need know quite a bit about VTK to do this. Once you know which object > contains the data you want, you can proceed in the same way as you would from > C++ or Python. Unfortenatly, I'm too busy now to check this particular example > but if I find some free time later this week I'll let you know. Now, I got a 'little' bit deeper into VTK and figured out that I could use the probe filter. Below I want to describe what I did. I used like mentioned before the 'officeTube.m' as base. I changed the reader to an Ensight format: % This example demonstrates the use of a single streamline and the % tube filter to create a streamtube. vtk_init; VTK_DATA_ROOT = vtkGetDataRoot(); % We read a data file the is a CFD analysis of airflow in an office % (with ventilation and a burning cigarette). We force an update so % that we can query the output for its length, i.e., the length of the % diagonal of the bounding box. This is useful for normalizing the % data. %reader = vtkStructuredGridReader(); #reader = vtkEnSightGoldReader(); reader = vtkGenericEnSightReader(); %office.binary.vtk %reader.SetFileName(strcat(VTK_DATA_ROOT,"/Data/EnSight/office_ascii.case")); reader.SetCaseFileName(strcat(VTK_DATA_ROOT,"/Data/EnSight/office_ascii.case")); %reader.SetFileName(strcat(VTK_DATA_ROOT,"/Data/EnSight/office_ascii.case")); #reader.SetCaseFileName("/home/fab/HOME/Dissertation/CFD/Projects/Building_airflow/CFX/k-eps/smallerMesh_smooth/ascii_ensight/keps_small_smooth.case"); reader.Update(); length = reader.GetOutput().GetLength(); In order to use the probe filter, which can have a defined line as source, I need scalars. In fact in the choosen case-file is a scalar (density), but I want to acces the vector (velocity); so I need the 'calculator' to transform the existing vector to a scalar. I tried it this way: calc = vtkArrayCalculator(); calc.SetInput(reader.GetOutput()); calc.SetAttributeModeToUsePointData calc.AddScalarArrayName("vectors", 0) calc.SetResultArrayName("Velocity") calc.SetFunction("vectors_0") I wasn't sure about the names, but 'paraview's calculator declared them like above... Afterwards I create a line using two points for the 'LineSource' and display it in the graphic # Create three the line source to use for the probe lines. line = vtkLineSource() line.SetResolution(30) line.SetPoint1(1, 0 ,1.5) line.SetPoint2(1,2,1.5) mapline = vtkPolyDataMapper(); mapline.SetInput(line.GetOutput()); mapline.ScalarVisibilityOff(); lineactor = vtkActor(); lineactor.SetMapper(mapline); lineactor.GetProperty().SetColor(.8, .8, .6); I use this line as 'input' for the probe filter and the defined 'calculator' as 'source' for the probe. # Move the line into place and create the probe filter. For # vtkProbeFilter, the probe line is the input, and the underlying data # set is the source. probe = vtkProbeFilter() probe.SetInput(line.GetOutput()) probe.SetSource(calc.GetOutput()) The rest is the same as in the officeTube example; I just remove some 'Actors' and added the density1 and momentum1 variables: outline = vtkStructuredGridOutlineFilter(); outline.SetInput(reader.GetOutput()); mapOutline = vtkPolyDataMapper(); mapOutline.SetInput(outline.GetOutput()); outlineActor = vtkActor(); outlineActor.SetMapper(mapOutline); outlineActor.GetProperty().SetColor(0, 0, 0); % Now create the usual graphics stuff. ren = vtkRenderer(); renWin = vtkRenderWindow(); renWin.AddRenderer(ren); iren = vtkRenderWindowInteractor(); iren.SetRenderWindow(renWin); ren.AddActor(lineactor); ren.AddActor(outlineActor); #ren.AddActor(streamTubeActor); ren.SetBackground(0.4,0.4,0.4); % Here we specify a particular view. aCamera = vtkCamera(); aCamera.SetClippingRange(0.726079, 36.3039); aCamera.SetFocalPoint(2.43584, 2.15046, 1.11104); aCamera.SetPosition(-4.76183, -10.4426, 3.17203); aCamera.SetViewUp(0.0511273, 0.132773, 0.989827); aCamera.SetViewAngle(18.604); aCamera.Zoom(1.2); ren.SetActiveCamera(aCamera); renWin.SetSize(500, 300); % renWin.Render(); vtkInitializeInteractor(iren); density1 = reader.GetOutput().GetPointData().GetScalars().GetTuple1(1); momentum1= reader.GetOutput().GetPointData().GetVectors().GetTuple3(1); #density1probe = probe.GetOutput().GetPointData().GetScalars().GetTuple1(1) 'density1' and 'momentum1' work without any problem, but using 'density1probe', where I try to get access to the probe variables, octave crashes, because there are no 'values'. Actually I could use the working 'density1'/'momentum1' in combination with some other octave function to define a line in the domain, but I am not sure, that defining such a line and get the 'GetTuple1' to know the lines looks much harder than using the available 'probe'!? But maybe, it is just because of a big lack in octave and vtk knowledge. Would be nice, when anybody have a nice suggestion, how I should do it. I attached the adjusted 'officeTube' for better readability. Best Greetings! Fabian P.S. Until now, I forgot to say to the developers: Great Work! It seems that it will become my main visualization tool (with Paraview) :-) |