How to write scalar filed with VTK in C++?How do you set, clear, and toggle a single bit?What are the differences between a pointer variable and a reference variable in C++?How do I iterate over the words of a string?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the effect of extern “C” in C++?What is the “-->” operator in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why is reading lines from stdin much slower in C++ than Python?Writing and modifying VTK polydata files using Python
Why do OOK transmissions have bandwidth?
How does Ctrl+c and Ctrl+v work?
Could there be something like aerobatic smoke trails in the vacuum of space?
What is the effect of the Feeblemind spell on Ability Score Improvements?
Polynomial division: Is this trick obvious?
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
tikzcd diagram within an array
How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview
Should I communicate in my applications that I'm unemployed out of choice rather than because nobody will have me?
Break long word (not long text!) in longtable cell
Why are lawsuits between the President and Congress not automatically sent to the Supreme Court
What color to choose as "danger" if the main color of my app is red
It is as easy as A B C, Figure out U V C from the given relationship
I recently started my machine learning PhD and I have absolutely no idea what I'm doing
Understanding Deutch's Algorithm
What do the "optional" resistor and capacitor do in this circuit?
Why did Varys remove his rings?
Does the wearer know what items are in which patch in the Robe of Useful items?
Wireless headphones interfere with Wi-Fi signal on laptop
Why were the bells ignored in S8E5?
Will the volt, ampere, ohm or other electrical units change on May 20th, 2019?
UUID type for NEWID()
Meaning of "legitimate" in Carl Jung's quote "Neurosis is always a substitute for legitimate suffering."
Why are goodwill impairments on the statement of cash-flows of GE?
How to write scalar filed with VTK in C++?
How do you set, clear, and toggle a single bit?What are the differences between a pointer variable and a reference variable in C++?How do I iterate over the words of a string?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the effect of extern “C” in C++?What is the “-->” operator in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why is reading lines from stdin much slower in C++ than Python?Writing and modifying VTK polydata files using Python
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am starting to learn about VTK. I would like to write an scalar field in a .vts file.
The structured grid is being generated with the code included below.
I tried finding information on the user guide and tutorials but I was not able to do it.
// Create a grid
vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
unsigned int numi = 20;
unsigned int numj = 30;
unsigned int numk = 1;
for (unsigned int k = 0; k < numk; k++)
for (unsigned int j = 0; j < numj; j++)
for (unsigned int i = 0; i < numi; i++)
points->InsertNextPoint(i, j, k);
// Specify the dimensions of the grid
structuredGrid->SetDimensions(numi, numj, numk);
structuredGrid->SetPoints(points);
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
c++ vtk
add a comment |
I am starting to learn about VTK. I would like to write an scalar field in a .vts file.
The structured grid is being generated with the code included below.
I tried finding information on the user guide and tutorials but I was not able to do it.
// Create a grid
vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
unsigned int numi = 20;
unsigned int numj = 30;
unsigned int numk = 1;
for (unsigned int k = 0; k < numk; k++)
for (unsigned int j = 0; j < numj; j++)
for (unsigned int i = 0; i < numi; i++)
points->InsertNextPoint(i, j, k);
// Specify the dimensions of the grid
structuredGrid->SetDimensions(numi, numj, numk);
structuredGrid->SetPoints(points);
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
c++ vtk
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06
add a comment |
I am starting to learn about VTK. I would like to write an scalar field in a .vts file.
The structured grid is being generated with the code included below.
I tried finding information on the user guide and tutorials but I was not able to do it.
// Create a grid
vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
unsigned int numi = 20;
unsigned int numj = 30;
unsigned int numk = 1;
for (unsigned int k = 0; k < numk; k++)
for (unsigned int j = 0; j < numj; j++)
for (unsigned int i = 0; i < numi; i++)
points->InsertNextPoint(i, j, k);
// Specify the dimensions of the grid
structuredGrid->SetDimensions(numi, numj, numk);
structuredGrid->SetPoints(points);
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
c++ vtk
I am starting to learn about VTK. I would like to write an scalar field in a .vts file.
The structured grid is being generated with the code included below.
I tried finding information on the user guide and tutorials but I was not able to do it.
// Create a grid
vtkSmartPointer<vtkStructuredGrid> structuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
unsigned int numi = 20;
unsigned int numj = 30;
unsigned int numk = 1;
for (unsigned int k = 0; k < numk; k++)
for (unsigned int j = 0; j < numj; j++)
for (unsigned int i = 0; i < numi; i++)
points->InsertNextPoint(i, j, k);
// Specify the dimensions of the grid
structuredGrid->SetDimensions(numi, numj, numk);
structuredGrid->SetPoints(points);
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
c++ vtk
c++ vtk
edited Mar 23 at 15:46
Mario Lino Valencia
asked Mar 23 at 15:35
Mario Lino ValenciaMario Lino Valencia
133
133
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06
add a comment |
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06
add a comment |
1 Answer
1
active
oldest
votes
Scalar can be set for attribute PointData of vtkStructuredGrid object.
Then vtkXMLStructuredGridWriter object writes structuredGrid in vts file just as this:
vtkFloatArray *scalars = vtkFloatArray::New();
for (int i=0; i< numi*numj*numk; i++) scalars->InsertTuple1(i, 1.0 * i /(numi*numj*numk));
structuredGrid->GetPointData()->SetScalars( scalars );
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315403%2fhow-to-write-scalar-filed-with-vtk-in-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Scalar can be set for attribute PointData of vtkStructuredGrid object.
Then vtkXMLStructuredGridWriter object writes structuredGrid in vts file just as this:
vtkFloatArray *scalars = vtkFloatArray::New();
for (int i=0; i< numi*numj*numk; i++) scalars->InsertTuple1(i, 1.0 * i /(numi*numj*numk));
structuredGrid->GetPointData()->SetScalars( scalars );
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
add a comment |
Scalar can be set for attribute PointData of vtkStructuredGrid object.
Then vtkXMLStructuredGridWriter object writes structuredGrid in vts file just as this:
vtkFloatArray *scalars = vtkFloatArray::New();
for (int i=0; i< numi*numj*numk; i++) scalars->InsertTuple1(i, 1.0 * i /(numi*numj*numk));
structuredGrid->GetPointData()->SetScalars( scalars );
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
add a comment |
Scalar can be set for attribute PointData of vtkStructuredGrid object.
Then vtkXMLStructuredGridWriter object writes structuredGrid in vts file just as this:
vtkFloatArray *scalars = vtkFloatArray::New();
for (int i=0; i< numi*numj*numk; i++) scalars->InsertTuple1(i, 1.0 * i /(numi*numj*numk));
structuredGrid->GetPointData()->SetScalars( scalars );
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
Scalar can be set for attribute PointData of vtkStructuredGrid object.
Then vtkXMLStructuredGridWriter object writes structuredGrid in vts file just as this:
vtkFloatArray *scalars = vtkFloatArray::New();
for (int i=0; i< numi*numj*numk; i++) scalars->InsertTuple1(i, 1.0 * i /(numi*numj*numk));
structuredGrid->GetPointData()->SetScalars( scalars );
// Write file
vtkSmartPointer<vtkXMLStructuredGridWriter> writer = vtkSmartPointer<vtkXMLStructuredGridWriter>::New();
writer->SetFileName("output.vts");
writer->SetInputData(structuredGrid);
writer->Write();
answered Mar 24 at 14:13
theArcticOceantheArcticOcean
562
562
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315403%2fhow-to-write-scalar-filed-with-vtk-in-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"I would like to write an scalar field in a .vts file." Isn't a valid question.
– πάντα ῥεῖ
Mar 23 at 15:36
your example code does not include any tries of writing a scalar. Juste create the array and add it with SetScalars.
– Mathieu Westphal
Mar 25 at 9:06