[vtkusers] Get vtkPolyData from vtkMapper in vtkActor using Java API
kent myers
dakota_63124 at yahoo.com
Sat May 9 16:05:27 EDT 2015
Hi Bill,
The results of the print are at the end of this message. It looks to me like the polydata is ok.
Below is what my code looks like now. Is it possible there is something wrong with the Write method as called from Java?
By the way, your code that iterates through the actors in the renderer made me wonder if there would be a way to export multiple actors to the same VTP file. The vtkXMLPolyDataWriter class doesn't have a Close() method, so it seems that the file will be closed immediately after the first write. If you can give many any feedback on this question that would be great.
For now the main issue is just to be able to call the write method without crashing.
Thanks,Kent
public void exportGraphicFile(String filename) { //Write the file vtkXMLPolyDataWriter writer = new vtkXMLPolyDataWriter(); writer.SetDataModeToAscii();;
writer.SetFileName(filename);
vtkActor testActor = elementFaceActor; vtkPolyDataMapper testMapper = (vtkPolyDataMapper) testActor.GetMapper(); vtkPolyData polyData = testMapper.GetInput(); String result = polyData.Print(); System.out.print(result);
writer.SetInputData(polyData);
// writer.Update();
writer.Write(); }
OUTPUT FROM PRINT:
vtkPolyData (00000000659D2ED0) Debug: Off Modified Time: 130 Reference Count: 7 Registered Events: (none) Information: 00000000659CBF10 Data Released: False Global Release Data: Off UpdateTime: 813 Field Data: Debug: Off Modified Time: 107 Reference Count: 1 Registered Events: (none) Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Number Of Points: 192 Number Of Cells: 540 Cell Data: Debug: Off Modified Time: 110 Reference Count: 1 Registered Events: (none) Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 ) Interpolate Flags: ( 1 1 1 1 1 0 0 1 ) Pass Through Flags: ( 1 1 1 1 1 1 1 1 ) Scalars: (none) Vectors: (none) Normals: (none) TCoords: (none) Tensors: (none) GlobalIds: (none) PedigreeIds: (none) EdgeFlag: (none) Point Data: Debug: Off Modified Time: 109 Reference Count: 1 Registered Events: (none) Number Of Arrays: 0 Number Of Components: 0 Number Of Tuples: 0 Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 ) Interpolate Flags: ( 1 1 1 1 1 0 0 1 ) Pass Through Flags: ( 1 1 1 1 1 1 1 1 ) Scalars: (none) Vectors: (none) Normals: (none) TCoords: (none) Tensors: (none) GlobalIds: (none) PedigreeIds: (none) EdgeFlag: (none) Bounds: Xmin,Xmax: (0, 1) Ymin,Ymax: (0, 1) Zmin,Zmax: (0, 2) Compute Time: 822 Number Of Points: 192 Point Coordinates: 00000000659D3800 Locator: 0000000000000000 Number Of Vertices: 0 Number Of Lines: 0 Number Of Polygons: 540 Number Of Triangle Strips: 0 Number Of Pieces: 1 Piece: 0 Ghost Level: 0
On Saturday, May 9, 2015 12:27 PM, Bill Lorensen [via VTK] <ml-node+s1045678n5731862h75 at n5.nabble.com> wrote:
SetInput(polydata) is not in vtk6.x. It should be SetInputData. Not
sure why you are crashing. Try printing the polydata. In C++:
polydata->Print(std::cout);
On Sat, May 9, 2015 at 3:21 PM, kent myers via vtkusers
<[hidden email]> wrote:
> Hi Bill,
>
> I edited my post shortly after I wrote it because I was able to get the
> vtkPolyData object from my actor.
>
> However I could not find the SetInput() method for the writer, so I tried
> SetInputData. This crashes the Java virtual machine.
>
> I will try to understand your C++ code sample, but Java is very different,
> and it seems that not all C++ methods are exposed to Java.
>
> Thanks for the help.
> Kent
>
>
>
> On Saturday, May 9, 2015 12:07 PM, Bill Lorensen [via VTK] <[hidden email]>
> wrote:
>
>
> Here is what I do in C++:
> vtkSmartPointer<vtkActorCollection> actors =
> vtkSmartPointer<vtkActorCollection>::New();
> actors = renderer->GetActors();
> actors->InitTraversal();
> for (vtkIdType a = 0; a < actors->GetNumberOfItems(); ++a)
> {
> vtkActor * actor = actors->GetNextActor();
> vtkPolyData *pd =
> vtkPolyData::SafeDownCast(actor->GetMapper()->GetInput());
> vtkSmartPointer<vtkCleanPolyData> clean =
> vtkSmartPointer<vtkCleanPolyData>::New();
> clean->SetInputData(pd);
> vtkSmartPointer<vtkPolyDataNormals> normals =
> vtkSmartPointer<vtkPolyDataNormals>::New();
> normals->SetInputConnection(clean->GetOutputPort());
> normals->Update();
> vtkPolyDataMapper *mapper =
> vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
> mapper->SetInputData(normals->GetOutput());
> }
>
>
> On Sat, May 9, 2015 at 2:48 PM, kent myers via vtkusers
> <[hidden email]> wrote:
>
>> I am trying to export a vtkPolyData object to a vtp file using
>> vtkXMLPolyDataWriter. The online VTK documentation says to use the
>> writer.SetInput() method that takes a vtkPolyData object.
>>
>> I am having some problems with this strategy:
>> 1. I can get the vtkMapper object from my vtkActor, but the vtkMapper
>> object
>> has no GetInput() method to retrieve a vtkPolyData object (or any other
>> method)
>> 2. vtkXMLPolyDataWriter has no SetInput() method (or any other method) to
>> pass the vtkPolyData object even if I could get the vtkPolyData object.
>>
>> Has anyone successfully exported vtkPolyData from a Java application? If
>> so,
>> how?
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://vtk.1045678.n5.nabble.com/Get-vtkPolyData-from-vtkMapper-in-vtkActor-using-Java-API-tp5731859.html
>> Sent from the VTK - Users mailing list archive at Nabble.com.
>> _______________________________________________
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://vtk.1045678.n5.nabble.com/Get-vtkPolyData-from-vtkMapper-in-vtkActor-using-Java-API-tp5731859p5731860.html
> To unsubscribe from Get vtkPolyData from vtkMapper in vtkActor using Java
> API, click here.
> NAML
>
>
>
> ________________________________
> View this message in context: Re: Get vtkPolyData from vtkMapper in vtkActor
> using Java API
>
> Sent from the VTK - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
--
Unpaid intern in BillsBasement at noware dot com
_______________________________________________
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
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
If you reply to this email, your message will be added to the discussion below: http://vtk.1045678.n5.nabble.com/Write-vtkPolyData-to-vtp-file-using-Java-API-tp5731859p5731862.html To unsubscribe from Write vtkPolyData to vtp file using Java API, click here.
NAML
--
View this message in context: http://vtk.1045678.n5.nabble.com/Write-vtkPolyData-to-vtp-file-using-Java-API-tp5731859p5731863.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150509/191f71fe/attachment.html>
More information about the vtkusers
mailing list