mululu
mululu

Reputation: 411

How can I write a vtkTextActor3D to a file?

I have a set of tubes representing boreholes in a vtp-file (written by vtkXMLPolyDataWriter). Now for clarity I would like to add text labels to identify the boreholes when displaying them in paraview.

My idea was to create labels with vtkTextActor3D, to convert these actors to polydata, and then output these labels, split into polygons, to a vtp-file with the polydatawriter.

How can I do this? In paraview I was able to create a 3D Text source and save it to a vtp-file. However, I can't figure out how to do this in python.

Thanks!

Upvotes: 0

Views: 398

Answers (2)

Abhijith
Abhijith

Reputation: 124

There is an easy work around to this. You need the borehole collar data as csv file with x, y and z coordinates and the label columns.

Here is the code of an XML plugin, provided by Sebastien Jourdain on ParaView Support in Discourse.

  1. Copy & paste the below code in notepad and save it as an XML file
  2. Load the file as a plugin in paraview from Tools > Manage Plugins> Load New
  3. Load your csv in paraview and add TableToPoints filter. Generate points by choosing the xyz columns.
  4. Once again add TableToPoints filter. This time choose the new option "Labels" under Display > Representation in the properties box. Choose "Labels" and then select the column from Point Field Data Array Name.
  5. Check the Point Label Visibility checkbox and your labels will be displayed at their respective locations. You can play with label properties for styling. Label Color can be changed by inputting RGB values from 0 to 1. Default is 1,1,0 for yellow. 1,1,1 will give you white and .5,.5,.5 grey - like that.
  6. For some reason, it was not displaying the labels in the first column of the csv file. I copied the first column to another column with a different header in the original csv and then it worked.

Please refer to this discussion on paraview support.

https://discourse.paraview.org/t/point-labels-available-with-pv-5-7/2478

The code :

<ServerManagerConfiguration>
  <ProxyGroup name="representations">
    <Extension name="GeometryRepresentation">
      <RepresentationType
        subproxy="DataLabelRepresentation"
        text="Labels"
      />

      <SubProxy>
        <Proxy
            name="DataLabelRepresentation"
            proxygroup="representations"
            proxyname="DataLabelRepresentation"
        />

        <ShareProperties subproxy="SurfaceRepresentation">
          <Exception name="Input" />
          <Exception name="Visibility" />
        </ShareProperties>

        <ExposedProperties>
            <Property name="PointFieldDataArrayName" />
            <Property name="PointLabelBold" />
            <Property name="PointLabelColor" />
            <Property name="PointLabelFontFamily" />
            <Property name="PointLabelFontSize" />
            <Property name="PointLabelFormat" />
            <Property name="PointLabelItalic" />
            <Property name="PointLabelJustification" />
            <Property name="PointLabelOpacity" />
            <Property name="PointLabelShadow" />
            <Property name="PointLabelVisibility" />
            <Property name="MaximumNumberOfLabels" />
        </ExposedProperties>
      </SubProxy>
    </Extension>
  </ProxyGroup>
</ServerManagerConfiguration>

Upvotes: 0

tomj
tomj

Reputation: 1109

I think to do it the way you described you should actually use vtkVectorText instead of vtkTextActor3D, because accroding to the documentation for vtkTextActor3D, it works like this: The input text is rendered into a buffer, which in turn is used as a texture applied onto a quad (a vtkImageActor is used under the hood). So you actually don't get any geometry for individual characters of your text, instead you would have to save the texture and display that in paraview. Meanwhile, vtkVectorText should (I've never used it personally...) produce an actual geometry for your characters so you can save them as any other polydata.

Upvotes: 1

Related Questions