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;








1















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();









share|improve this question
























  • "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

















1















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();









share|improve this question
























  • "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













1












1








1








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();









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • "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












1 Answer
1






active

oldest

votes


















0














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();





share|improve this answer























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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();





    share|improve this answer



























      0














      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();





      share|improve this answer

























        0












        0








        0







        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();





        share|improve this answer













        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();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 14:13









        theArcticOceantheArcticOcean

        562




        562





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현