[vtkusers] Save a plane in a vtp file?

David Doria daviddoria at gmail.com
Sat Mar 14 08:08:09 EDT 2009


Excellent, thank you Amy. I also found
vtkAppendPolyData.h<http://www.vtk.org/doc/nightly/html/vtkAppendPolyData_8h-source.html>
to attach them together.  For anyone else interested:

void TwoCubes(const string &OutputFilename)
{
    vtkSmartPointer<vtkCubeSource> Cube1 =
vtkSmartPointer<vtkCubeSource>::New();
    Cube1->SetCenter(0.0, 0.0, 0.0);
    Cube1->SetXLength(.5);
    Cube1->SetYLength(.5);
    Cube1->SetZLength(.5);

    vtkSmartPointer<vtkCubeSource> Cube2 =
vtkSmartPointer<vtkCubeSource>::New();
    Cube2->SetCenter(5.0, 0.0, 0.0);
    Cube2->SetXLength(.5);
    Cube2->SetYLength(.5);
    Cube2->SetZLength(.5);

    vtkSmartPointer<vtkPolyData> polydata1 = Cube1->GetOutput();
    vtkSmartPointer<vtkPolyData> polydata2 = Cube2->GetOutput();

    vtkSmartPointer<vtkAppendPolyData> CombinedData =
vtkSmartPointer<vtkAppendPolyData>::New();;
    CombinedData->AddInput(polydata1);
    CombinedData->AddInput(polydata2);

    //write the file
    vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
    writer->SetInput(CombinedData->GetOutput());

    writer->SetFileName(OutputFilename.c_str());
    writer->Write();

}

Thanks,

David


On Fri, Mar 13, 2009 at 10:08 PM, Amy Squillacote <amylists at gmail.com>wrote:

> Hi David,
>
> .vtp files are for storing polygonal data sets. For your plane, you could
> store the output of vtkPlaneSource in a .vtp file. Similarly, for a sphere,
> you can store the output of a vtkSphereSource in a .vtp file.
>
> - Amy
>
> On Fri, Mar 13, 2009 at 5:35 PM, David Doria <daviddoria at gmail.com> wrote:
>
>> Is there a way to store a sphere in a vtp file?
>>
>> Thanks,
>>
>> David
>>
>>
>>
>> On Fri, Mar 6, 2009 at 8:26 PM, David Doria <daviddoria at gmail.com> wrote:
>>
>>> Is there a way to store a plane in a vtp file? I have a point and a
>>> normal, and I want to see what that plane looks like. I could clearly get
>>> two random vectors on the plane that go through the point and make a giant
>>> triangle, but that seems very hacky.
>>>
>>> Thanks,
>>>
>>> David
>>>
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090314/2879acdf/attachment.htm>


More information about the vtkusers mailing list