<div dir="ltr">James,<div>Great. I am glad you found the problem.</div><div><br></div><div>You set scalar data by<br></div><div>1. create and fill a vtkDataArray</div><div><div>2. dataset->GetPointData()->SetScalars(vtkDataArray*)</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 10:49 AM, James Furness <span dir="ltr"><<a href="mailto:pcxjf1@nottingham.ac.uk" target="_blank">pcxjf1@nottingham.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div>Thanks Dan,</div>
<div><br>
</div>
<div>I found the problem whilst cleaning up the code to send you a copy. Funny how that happens…</div>
<div><br>
</div>
<div>It turned out to be an old </div>
<div><br>
</div>
<div>int extent[6] = {0, 1, 0, 1, 0, 1}; </div>
<div>outInfo->Set<br>
(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), extent, 6);</div>
<div><br>
</div>
<div>call in RequestInformation( … ) that was wrongly setting the extent to [0,1,0,1,0,1].</div>
<div><br>
</div>
<div>Fixing that seemed to fix the problem of only 8 points showing up.</div>
<div><br>
</div>
<div>I’ve been looking now at using the vtkRectilinearGrid class, I’ve set the X, Y and Z coordinates using the respective SetXCoordinates (vtkDataArray *) methods. But I can’t work out from the documentation how to enter my scalar data into this grid
for use within paraview. </div>
<div><br>
</div>
<div>Can you offer any advice on this? Or better point me to an example to learn from?</div>
<div><br>
</div>
<div>Many thanks,</div>
<div>James</div><div><div class="h5">
<br>
<div>
<blockquote type="cite">
<div>On 25 Aug 2015, at 15:39, Dan Lipsa <<a href="mailto:dan.lipsa@kitware.com" target="_blank">dan.lipsa@kitware.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr">Hi James,
<div>I was used to the old style and it kind of made sense with the problem you are seeing, but you are right, setDimensions does not seem to be the problem.</div>
<div><br>
</div>
<div>Is it any way I can get the code and a sample data so that I can run it through a debugger. I cannot see anything else in the code.</div>
<div><br>
</div>
<div>Dan</div>
<div><br>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Aug 25, 2015 at 9:20 AM, James Furness <span dir="ltr">
<<a href="mailto:pcxjf1@nottingham.ac.uk" target="_blank">pcxjf1@nottingham.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Thanks for your advice, however it hasn’t quite solved my problem.
<div><br>
</div>
<div><span>
<blockquote type="cite">
<div dir="ltr">
<div>You are missing image->SetDimensions() - that may be a reason why your scalar does not have all values.</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div>The documentation marks vtkImageData::SetDimensions( ... ) as depreciated, and instead vtkImageData::SetExtent( ... ) should be used. It remarks that SetDimension is equivalent to SetExtent(0, i-1, 0, j-1, 0, k-1).</div>
<div><br>
</div>
<div>(( doc page - <a href="http://www.vtk.org/doc/nightly/html/classvtkImageData.html#a42bc5faee908c50407e9d9ec97f74238" target="_blank">http://www.vtk.org/doc/nightly/html/classvtkImageData.html#a42bc5faee908c50407e9d9ec97f74238</a> ))</div>
<div><br>
</div>
<div>Regardless, I tried using SetDimensions in this way, and resulted in some nasty set-fault crashes. Whilst now 64 elements were found correctly, all passed the first 8 were memory junk. When I use SetExtent( … ) the information print on the image
object happily reports dimensions of 4, 4, 4 as expected. So it seems this is set by SetExtent( … ).</div>
<span>
<div><br>
</div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div>vtkRectilinear grid is like an image data with variable extents and warped grid.</div>
</div>
</blockquote>
</div>
<div><br>
</div>
</span>
<div>I’ll look into this class. It’s possible that I am mangling this reader by trying to shoehorn my problem into an inappropriate class at the moment. Thanks for pointing this out.</div>
<div><br>
</div>
<div>Many thanks,</div>
<div>James</div>
<div>
<div><br>
<div>
<blockquote type="cite">
<div>On 24 Aug 2015, at 15:31, Dan Lipsa <<a href="mailto:dan.lipsa@kitware.com" target="_blank">dan.lipsa@kitware.com</a>>
wrote:</div>
<br>
<div>
<div dir="ltr">James,
<div>You are missing image->SetDimensions() - that may be a reason why your scalar does not have all values.</div>
<div><br>
</div>
<div>vtkRectilinear grid is like an image data with variable extents and warped grid.</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Aug 21, 2015 at 6:55 AM, James Furness <span dir="ltr">
<<a href="mailto:pcxjf1@nottingham.ac.uk" target="_blank">pcxjf1@nottingham.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I have a program that will produce an output either in csv, or a binary format (which I have written and can alter).<br>
<br>
The data points are constructed by taking 3 vectors, and stepping at set intervals along these vectors to construct a 3D set of data. Ultimately there shouldn’t be a restriction on the three vectors, so the data may not be in a rectilinear array. But I’m leaving
this for now and assuming the data is constructed from 3 orthogonal Axis aligned vectors to create a rectilinear structured grid. When I have a better grasp of preview readers I’ll update the reader to account for this. I guess it would require an unstructured
data type to handle non-orthogonal grids?<br>
<br>
Also, the user is free to select what data they save from the program. This could be many fields, both vector and scalar quantities. What has been selected is stored in a header to the file, and known on reading. For my toy example I save only one scalar quantity.<br>
<br>
I’ve been trying to write a reader for paraview to import the binary files output. The csv format works ok, but the files can become large and it is a pain to have to construct the vector quantities from 3 scalars in each case, I want to avoid the user having
to do this work. Another reason for writing a custom reader is to include additional information into the binary file for visualisation (e.g. the position of atoms, not a field quantity).<br>
<br>
With that background and reasoning I have managed to follow the documentation enough to read a basic test file, get the origin and point spacing, and read a single scalar quantity into a vtkDataArray owned by a vtkImageData object. Paraview picks this up seemingly
correctly, with one flaw:<br>
<br>
It only takes 2 elements from each dimension, 0 and 1 displaying 8 elements in total. I am confident it has read the other values correctly as the Information tab reports “X extent 0 to 3” “X range: -1 to 1” (as expected) and similar for the other dimensions.
If I view the data in spreadsheet layout the 8 values it has seem correct, but the others are missing.<br>
<br>
The code I am using in the reader’s RequestData( ) function is added below.<br>
<br>
Does anyone know why this may be happening and how to fix it? Also, any advice on how I should structure the reader to handle the non-orthogonal data?<br>
<br>
Thanks for your time, and thank you for such a stellar program. The results paraview produces for this data is brilliant, hence my want to make it convenient for our users!<br>
<br>
Regards,<br>
James Furness<br>
<br>
<br>
CODE for RequestData( ) Method:<br>
———————————————————————<br>
<br>
int LondonReader::RequestData(<br>
vtkInformation*,<br>
vtkInformationVector**,<br>
vtkInformationVector *outputVector)<br>
{<br>
vtkWarningMacro("Requesting the data!");<br>
<br>
<br>
ifstream finp;<br>
finp.open(this->FileName, ios::in | ios::binary);<br>
<br>
if (<a href="http://finp.is/" target="_blank">finp.is</a>_open()) {<br>
cerr << "File is open without problem!" << endl;<br>
} else {<br>
cerr << "File failed to open :(" << endl;<br>
return 0;<br>
}<br>
<br>
// size of real numbers may not be 8. Check for this from file header<br>
int realSize;<br>
finp.read((char*)&realSize, sizeof(int));<br>
if(realSize != 8) {<br>
cerr << "Not implimented yet!" << endl;<br>
return 0;<br>
}<br>
<br>
// number of data fields<br>
int nFields;<br>
finp.read((char*)&nFields, sizeof(int));<br>
<br>
vtkImageData* image = vtkImageData::GetData(outputVector);<br>
<br>
// Read the dimensions of the grid and set the extent accordingly<br>
int gridDim[3];<br>
finp.read((char*)&gridDim, 3*sizeof(int));<br>
int extent[6] = {0, gridDim[0]-1, 0, gridDim[1]-1, 0, gridDim[2]-1};<br>
image->SetExtent(extent);<br>
<br>
<br>
// Read the field names from the file<br>
std::vector<std::string> fields;<br>
std::string strBuf;<br>
for (int i = 0; i < nFields; i++) {<br>
std::getline( finp, strBuf, '\0');<br>
fields.push_back(strBuf);<br>
cerr << "Printing Fields (" << i << "): " << fields[i] << endl;<br>
}<br>
<br>
// setup image for only one field for test case<br>
image->AllocateScalars(VTK_FLOAT, 1);<br>
vtkDataArray* scalars = image->GetPointData()->GetScalars();<br>
<br>
// currently there is only one field 'rho'<br>
scalars->SetName(fields[3].c_str());<br>
<br>
double x, y, z, rho;<br>
double oX, oY, oZ; //origin coordinates<br>
double sX, sY, sZ; //spacing of points<br>
<br>
for (vtkIdType itx = 0; itx < gridDim[0]; itx++) {<br>
for (vtkIdType ity = 0; ity < gridDim[1]; ity++) {<br>
for (vtkIdType itz = 0; itz < gridDim[2]; itz++) {<br>
finp.read((char*)&x, realSize);<br>
finp.read((char*)&y, realSize);<br>
finp.read((char*)&z, realSize);<br>
finp.read((char*)&rho, realSize);<br>
<br>
// Find and set the origin and spacing<br>
if (itx == 0 && ity == 0 && itz == 0) {<br>
image->SetOrigin(x, y, z);<br>
oX = x; oY = y; oZ = z;<br>
} else if (itx == 1 && ity == 0 && itz == 0) {<br>
sX = x - oX;<br>
} else if (itx == 0 && ity == 1 && itz == 0) {<br>
sY = y - oY;<br>
} else if (itx == 0 && ity == 0 && itz == 1) {<br>
sZ = z - oZ;<br>
}<br>
//check correct read.<br>
cerr << x << "," << y << "," << z << "," << rho << ", at " << itx*(gridDim[1]*gridDim[2]) + ity*gridDim[2] + itz << endl;<br>
<br>
//add value<br>
scalars->SetTuple1(itx*gridDim[1]*gridDim[2] + ity*gridDim[2] + itz,<br>
rho);<br>
}<br>
}<br>
}<br>
<br>
image->SetSpacing(sX, sY, sZ);<br>
<br>
image->Print(cerr);<br>
<br>
return 1;<br>
}<br>
<br>
<br>
<br>
<br>
<br>
This message and any attachment are intended solely for the addressee<br>
and may contain confidential information. If you have received this<br>
message in error, please send it back to me, and immediately delete it.<br>
<br>
Please do not use, copy or disclose the information contained in this<br>
message or in any attachment. Any views or opinions expressed by the<br>
author of this email do not necessarily reflect the views of the<br>
University of Nottingham.<br>
<br>
This message has been checked for viruses but the contents of an<br>
attachment may still contain software viruses which could damage your<br>
computer system, you are advised to perform your own checks. Email<br>
communications with the University of Nottingham may be monitored as<br>
permitted by UK legislation.<br>
<br>
_______________________________________________<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/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">
http://paraview.org/Wiki/ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">
http://markmail.org/search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<div>
<div>
<pre>This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it.
Please do not use, copy or disclose the information contained in this
message or in any attachment. Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.
This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.
</pre>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<pre>
This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it.
Please do not use, copy or disclose the information contained in this
message or in any attachment. Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.
This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.
</pre></div></div></div>
<br>_______________________________________________<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/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>