<div dir="ltr"><div><div><div>Thanks for your answer.<br><br></div>Unfortunately, I'm not trying to compute normals but some other vector field resulting from previous calculation.<br><br>Here is the code I'm working on. But for moment it doesn't provides the expected results...<br></div><div><some calculation stuff...><br></div><div><br> vtkPoints points = new vtkPoints();<br> vtkUnsignedCharArray colors = new vtkUnsignedCharArray();<br> colors.SetNumberOfComponents(<wbr>3);<br> colors.SetName("Colors");<br><br><br></div> // Weaves, Chunks and SurfacePoints are my own objects from which I get the geometrical informations I need<br></div> // SurfacePoint holds both 3D and parametric informations of each point. ie (x,y,z) and (u, v)<br><div> for (Weave w : part.getFirstPly().getWeaves()<wbr>) {<br> for (int i = 0; i < w.getNbPoints() - 1; i++) {<br> WeaveChunk chunk = w.getChunkAtIndex(i);<br> SurfacePoint p = chunk.getStart();<br> points.InsertNextPoint(p.u, p.v, 0.0);<br> Vector3d vec = chunk.getDirectionVector();<br> vec.normalize();<br> double[] dcolor = new double[]{vec.x, vec.y, vec.z};<br> byte[] color = new byte[3];<br> for(int j = 0; j < 3; j++)<br> color[j] = (byte)( 255 * dcolor[j]);<br> colors.InsertNextTuple3(color[<wbr>0], color[1], color[2]);<br> }<br> }<br><br> vtkPolyData inputPolyData = new vtkPolyData();<br> inputPolyData.SetPoints(<wbr>points);<br> <br> vtkDelaunay2D delaunay = new vtkDelaunay2D();<br> delaunay.SetInputData(<wbr>inputPolyData);<br> delaunay.Update();<br><br> vtkPolyData outputPolyData = new vtkPolyData();<br> outputPolyData.ShallowCopy(<wbr>delaunay.GetOutput());<br> outputPolyData.GetPointData().<wbr>SetScalars(colors);<br><br></div><div><rendering stuff...><br></div><div><br></div><div>I can figure out what I missed.<br><br></div><div>Any hint would be very appreciated.<br><br></div>jMax</div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-15 12:38 GMT+01:00 Jean-Max Redonnet <span dir="ltr"><<a href="mailto:jmax.red@gmail.com" target="_blank">jmax.red@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Thanks for your answer.<br><br></div>Unfortunately, I'm not trying to compute normals but some other vector field resulting from previous calculation.<br><br>Here is the code I'm working on. But for moment it doesn't provides the expected results...<br></div><div><some calculation stuff...><br></div><div><br> vtkPoints points = new vtkPoints();<br> vtkUnsignedCharArray colors = new vtkUnsignedCharArray();<br> colors.SetNumberOfComponents(<wbr>3);<br> colors.SetName("Colors");<br><br><br></div> // Weaves, Chunks and SurfacePoints are my own objects from which I get the geometrical informations I need<br></div> // SurfacePoint holds both 3D and parametric informations of each point. ie (x,y,z) and (u, v)<br><div><div> for (Weave w : part.getFirstPly().getWeaves()<wbr>) {<br> for (int i = 0; i < w.getNbPoints() - 1; i++) {<br> WeaveChunk chunk = w.getChunkAtIndex(i);<br> SurfacePoint p = chunk.getStart();<br> points.InsertNextPoint(p.u, p.v, 0.0);<br> Vector3d vec = chunk.getDirectionVector();<br> vec.normalize();<br> double[] dcolor = new double[]{vec.x, vec.y, vec.z};<br> byte[] color = new byte[3];<br> for(int j = 0; j < 3; j++)<br> color[j] = (byte)( 255 * dcolor[j]);<br> colors.InsertNextTuple3(color[<wbr>0], color[1], color[2]);<br> }<br> }<br><br> vtkPolyData inputPolyData = new vtkPolyData();<br> inputPolyData.SetPoints(<wbr>points);<br> <br> vtkDelaunay2D delaunay = new vtkDelaunay2D();<br> delaunay.SetInputData(<wbr>inputPolyData);<br> delaunay.Update();<br><br> vtkPolyData outputPolyData = new vtkPolyData();<br> outputPolyData.ShallowCopy(<wbr>delaunay.GetOutput());<br> outputPolyData.GetPointData().<wbr>SetScalars(colors);<br><br></div><div><rendering stuff...><br></div><div><br></div><div>I can figure out what I missed.<br><br></div><div>Any hint would be very appreciated.<br><br></div><div>jMax<br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-12-13 17:37 GMT+01:00 Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>That seems like a reasonable approach to doing what you are describing. If you need only to compute normals between points on a Delaunay2D surface and display them immediately, then the rendering is already doing that for you on the GPU, so it is very fast. If you need to save out the texture, then doing it the way you describe also sounds reasonable.<br><br></div>HTH,<br></div>Cory<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-6668809826636876065h5">On Mon, Dec 11, 2017 at 8:32 AM, Jean-Max Redonnet <span dir="ltr"><<a href="mailto:jmax.red@gmail.com" target="_blank">jmax.red@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-6668809826636876065h5"><div dir="ltr"><div>Hi, I'm still quite new to vtk, and I would like a pro advice.<br><br>I
have a set of pixels, each one given with its full rgb color
information. I would like to build a full image by interpolating color
of pixels between the given points. First, I would like to know if there
is a magic wand to do that. I searched it for days but maybe I missed
something.<br><br>If the job need to be done by hand, I plan to do this:<br>- first I split my image using a Delaunay algorithm.<br>-
then, each pixels (except the given ones) belongs to a single triangle.
Thus I can calculate the scalar factors using a barycenter formula.<br><br>For
example, let be a triangle defined by three pixels A, B and C. Let be P
a pixel inside this triangle. The following vectorial relations can be
written: PA = a.u, PB = b.v and PC = c.w, where u,v and w are unit
vector along (PA), (PB) and (PC) respectively. In this context I plan to
use scalar factors a, b and c to interpolate A,B and C pixels colors
values. The color of pixel P being then set to these interpolated
values.<br><br>Is it the right way to do ? Do you know a better way to do this ?<br><br>Giving
you a larger sight may help you to help me. Actually I want to
interpolate a vector field from a given set of vectors. The idea is to
do something like normal maps used in computer graphics. Mapping the 3D
vectors position to a 2D space is not a problem since their starting
point belongs to a parametric surface, therefore the 2D parametric space
of the surface can be used. Then the (u,v) space can easily be mapped
to an image pixels space while the coordinates of my vectors can
meanwhile be mapped to a rgb color space.<br><br>Using an image to build
and store my vector field interpolation is convenient but I would like
to set up all this in the most efficient manner.<br><br>According to you, what is the better way to do this ?<br><br>Thanks for any help.<br></div><div><br>jMax<br><br></div></div>
<br></div></div>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
<br></blockquote></div><span class="m_-6668809826636876065HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_-6668809826636876065m_7072386847543823528gmail_signature" data-smartmail="gmail_signature">Cory Quammen<br>Staff R&D Engineer<br>Kitware, Inc.</div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>