<br>Hi David,<br><br>Thanks for your precious information. It will be grateful of you if you guide me in implementing this feature. How do I hook into the Renderer's StartEvent.?? Where my callback command should be implemented?? <br><br>Thanks<br><blockquote><br>---------- Original message ----------<br>From:David Gobbi< david.gobbi@gmail.com ><br>Date: 28 Jan 10 23:04:33<br>Subject: Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>To: Rakesh Patil <rakeshthp@in.com><br><br>Hi Rakesh,<br><br>I've had to deal with this same issue in my own software. A good<br>solution is to use observers.<br><br>Usually, I hook into the Renderer's StartEvent. Inside my<br>CommandCallback, I check the renderer to see how much I need to scale<br>the actor in order make it always be the same number of pixels across:<br><br>double vtkSurfaceCursor::ComputeScale(const double position[3],<br> vtkRenderer *renderer)<br>{<br> // Find
the cursor scale factor such that 1 data unit length<br> // equals 1 screen pixel at the cursor's distance from the camera.<br> // Start by computing the height of the window at the cursor position.<br> double worldHeight = 1.0;<br> vtkCamera *camera = renderer->GetActiveCamera();<br> if (camera->GetParallelProjection())<br> {<br> worldHeight = 2*camera->GetParallelScale();<br> }<br> else<br> {<br> double cameraPosition[3];<br> camera->GetPosition(cameraPosition);<br> worldHeight = 2*(sqrt(vtkMath::Distance2BetweenPoints(position,<br> cameraPosition))<br> * tan(0.5*camera->GetViewAngle()/57.296));<br> }<br><br> // Compare world height to window height.<br> int windowHeight = renderer->GetSize()[1];<br> double scale = 1.0;<br> if (windowHeight > 0)<br> {<br> scale = worldHeight/windowHeight;<br> }<br><br> return scale;<br>}<br><br>I hope
this is the sort of thing that you were looking for.<br><br> - David G<br><br><br>On Thu, Jan 28, 2010 at 9:53 AM, Rakesh Patil <rakeshthp@in.com> wrote:<br>><br>> i guess, the way i explained the problem was not correct.. here it goes,<br>><br>> for a large area, if i draw vecot of actual size, it will be visible as a<br>> small dot. So i need to scale and make it<br>> large enough that it is visible properly.. And as i zoom in, and go closer<br>> to them, they must slowly,<br>> shrink to their actual size...<br>><br>> As kaarthik said, i think i need to write my own actor . But how to do it,<br>> am not able to understand..<br>> can anyone guide me..??<br>><br>> Thanks<br>> Regards<br>><br>> ---------- Original message ----------<br>> From:David Doria< daviddoria+vtk@gmail.com ><br>> Date: 27 Jan 10 19:54:04<br>> Subject: Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>> To: rakeshth
p@in.com<br>><br>> On Wed, Jan 27, 2010 at 8:56 AM, Rakesh Patil wrote:<br>>> Hello,<br>>><br>>> I dont know mush about wrapping the code. It would be nice if anyone helps<br>>> me out. Here is my code to display vectors<br>>><br>>> unsigned int num_pts = x.size();<br>>><br>>> vtkPoints *pts = vtkPoints::New();<br>>> pts->SetNumberOfPoints(num_pts);<br>>><br>>> vtkDoubleArray *vecArr = vtkDoubleArray::New();<br>>> vecArr->SetNumberOfComponents(3);<br>>> vecArr->SetNumberOfTuples(num_pts);<br>>><br>>> for( unsigned int i=0; i < num_pts; i++)<br>>> {<br>>> pts->InsertPoint(i, x(i), y(i), 0);<br>>> vecArr->InsertTuple2(i, vel_u(i), vel_v(i));<br>>> }<br>>><br>>> unsigned int num_cells = elem.rows(); // elem is a matrix that contains<br>>> the<br>>> index of nodes of elements in the mesh<br>>><br>>> vtkCellA
rray *cellA = vtlCellArray::New();<br>>> cellA->SetNumberOfCells(num_cells);<br>>><br>>> for (unsigned int i=0; i < num_cells; i++)<br>>> {<br>>> cellA->InsertNextCell(3);<br>>> cellA->InsertCellPoint( elem(i, 0) );<br>>> cellA->InsertCellPoint( elem(i, 1) );<br>>> cellA->InsertCellPoint( elem(i, 2) );<br>>> }<br>>><br>>> vtkUnstructuredGrid *uGrid = vtkUnstructuredGrid::New();<br>>> uGrid->Allocate(num_cells, num_cells);<br>>> uGrid->SetCells( VTK_TRIANGLE, cellA);<br>>> uGrid->SetPoints(pts);<br>>> uGrid->GetPointData()->SetVector(vecArr);<br>>><br>>> vtkGlyph2D *glyph = vtkGlyph2D::New();<br>>> glyph->SetInput(uGrid);<br>>> glyph->SetColorModeToColorByVector();<br>>> glyph->OrientOn();<br>>> glyph->SetScaleFactor(1);<br>>><br>>> vtkGlyphSource2D *glyphSource = vtkGlyphSource2D::New();<br>>
> glyphSource->FilledOff();<br>>> glyphSource->SetGlyphTypeToArrow();<br>>><br>>> glyph->SetInputConnection(1, glyphSource->GetOutputPort());<br>>><br>>> vtkPolyDataMapper *gMapper = vtkPolyDataMapper::New();<br>>> gMapper->SetInput( glyph->GetOutput());<br>>> gMapper->ScalarVisibilityOn();<br>>> gMapper->SetScalarRange(uGrid->GetScalarRange());<br>>><br>>> vtkActor *gactor = vtkActor::New();< br>> gactor->SetMapper(gMapper);<br>>><br>>> pRenderer->AddActor(gactor);<br>>><br>>> pRenderer->Rese tCamera();<br>>><br>>> Do i need to derive a class from vtkActor and override<br>>> RenderOpaqueGeometry<br>>> code..?? If so, then how do i scale the glyphs..?? and which part will<br>>> this<br>>> code come into picture. Am not that much expert in C++ but can manage with<br>>> a<br>>> guidance.<br>>><
br>>> Thanks<br>>><br>>> Regards<br>>><br>>> ---------- Original message ----------<br>>> From:Karthik Krishnan< karthik.krishnan@kitware.com ><br>>> Date: 25 Jan 10 17:08:12<br>>> Subject: Re: [vtkusers] Vector arrows form a solid patch. How to rectify??<br>>> To: Rakesh Patil<br>>><br>>> You'll have to write your own actor wrapping around your existing code<br>>> and overriding RenderOpaqueGeometry. Its not hard. See several actors<br>>> in VTK/Rendering that scale their font size based on the size of the<br>>> viewport etc. Yo u may have to do something similar scaling your glyphs<br>>> based on the parallel scale / view angle.<br>>><br>>> On Sat, Jan 23, 2010 at 12:49 PM, Rakesh Patil wrote:<br>>>> hello,<br>>>><br>>>> When i display a vector plot using vtk, it is shown very small like a<br>>>> dot.<br>>>> And when i zoo
m into it, it gets more visible and big. But, i want it in<br>>>> such a way, that when i display it, at the initial stage itself, the<br>>>> vectors<br>>>> must be big enough that can be seen. And when we zoom into it, then the<br>>>> arrow size must proportionately become small. I Used setscalefactor for<br>>>> glyph object and got the arrow size increased.<br>>>><br>>>> But where the data is very dense, there a solid patch is formed due to<br>>>> which<br>>>> i cannot make out whats the length of the arrow. So as we zoom in, the<br>>>> arrow<br>>>> size must be reduced so that at the denser location, i ca n differentiate<br>>>> among two vectors. How can i do this..??<br>>>><br>>>> Thanks in advance<br>>>><br>>>> Regards<br>>>> Rakesh<br>>>><br>>>> Get Yourself a cool, short @in.com Email ID now!<br>>
>> _______________________________________ ________<br>>>> Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>>>><br>>>> Visit other Kitware open-source projects at<br>>>> <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>>>><br>>>> Please keep messages on-topic and check the VTK FAQ at:<br>>>> <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>>>><br>>>> Follow this link to subscribe/unsubscribe:<br>>>> <a target=\"_blank\" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>>><br>>> _________________________________<br>>> Karthik Krishnan<br>><br>> This is only a very partial a
nswer, but you can scale an arrow using<br>> the vtkTransformFilter like this:<br>><br>> <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK/Examples/TransformFilter" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/TransformFilter</a><br>><br>> Thanks,<br>><br>> David<br>> _______________________________________________<br>> Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>><br>> Visit other Kitware open-source projects at<br>> <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>><br>> Please keep messages on-topic and check the VTK FAQ at:<br>> <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>><br>> Follow this link to subscribe/unsubscribe:<br>> <a target=\"_blank\" href="http://www.vtk.org/mailman/
listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>> < /blockquote><br>><br>> Get Yourself a cool, short @in.com Email ID now!<br>><br>> _______________________________________________<br>> Powered by <a target=\"_blank\" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>><br>> Visit other Kitware open-source projects at<br>> <a target=\"_blank\" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>><br>> Please keep messages on-topic and check the VTK FAQ at:<br>> <a target=\"_blank\" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>><br>> Follow this link to subscribe/unsubscribe:<br>> <a target=\"_blank\" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>><br>><br></rakesht
hp@in.com></rakeshthp@in.com></blockquote>