[Paraview] Use existing texture map for 3D surface

Eric E. Monson emonson at cs.duke.edu
Tue Mar 16 12:13:27 EDT 2010


Hey Christian,

Something like this should work:

# =============
pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()

numPts = pdi.GetPoints().GetNumberOfPoints()
Uarray = pdi.GetPointData().GetArray('U')
Varray = pdi.GetPointData().GetArray('V')

tc = vtk.vtkDoubleArray()
tc.SetNumberOfComponents(2)
tc.SetNumberOfTuples(numPts)
tc.SetName('TCoords')

for ii in range(numPts):
  Uval = Uarray.GetTuple1(ii)
  Vval = Varray.GetTuple1(ii)
  tc.SetTuple2(ii,Uval,Vval)

pdo.ShallowCopy(pdi)
pdo.GetPointData().AddArray(tc)
pdo.GetPointData().SetActiveTCoords('TCoords')
# =============

-Eric


On Mar 16, 2010, at 9:37 AM, Utkarsh Ayachit wrote:

> Christian,
> 
> Sorry I've been meaning to write up a quick  script for you. For
> starters take a look at:
> 
> http://www.paraview.org/Wiki/Python_Programmable_Filter
> http://www.paraview.org/Wiki/Python_recipes
> 
> Here's the algorithm:
> * Create a new vtkDoubleArray (or another vtkDataArray subclass) with
> 2 components and number of tuples = number of points.
> * Get access the to two input arrays you want to use an texture coordinates.
> * Iterate over each value in the two array and insert them as the two
> components in the new array
> * Set the new array as the TCoords in the output's point data.
> 
> Utkarsh
> 
> On Tue, Mar 16, 2010 at 6:38 AM, Dressler, Christian
> <Christian.Dressler at medizin.uni-leipzig.de> wrote:
>> Hi Utkarsh,
>> 
>> could you give me some hints or catchwords how to realize that filter? Perhaps a link to tutorial you recommend?
>> 
>> 
>> Best,
>> 
>> Christian
>> 
>> -----Ursprüngliche Nachricht-----
>> Von: Utkarsh Ayachit [mailto:utkarsh.ayachit at kitware.com]
>> Gesendet: Freitag, 12. März 2010 16:13
>> An: Dressler, Christian
>> Cc: paraview at paraview.org
>> Betreff: Re: [Paraview] Use existing texture map for 3D surface
>> 
>> The problem is that the uv array needs to be marked as "Texture"
>> attribute for the PointData. You can write a PythonProgrammableFilter
>> which generate an output with the Texture coords setup correctly. Let
>> me know if you need help with that. Also remember this filter will
>> have to combine the two "u" and "v" arrays produced by
>> vtkTableToPoints into a single array with 2 components.
>> 
>> Utkarsh
>> 
>> On Fri, Mar 12, 2010 at 10:05 AM, Dressler, Christian
>> <Christian.Dressler at medizin.uni-leipzig.de> wrote:
>>> Hi Eric,
>>> 
>>> Unfortunately this does not work. Neither for the point cloud, nor for the surface. It does only work after generating a map by paraview, but this is the wrong map.
>>> 
>>> I also tried to rename the columns header the way paraview does, but it did not work. I am looking for an option similar to the "table to points filter", where I am asked which column has which meaning.
>>> 
>>> Thanks,
>>> 
>>> Christian
>>> 
>>> 
>>> -----Ursprüngliche Nachricht-----
>>> Von: Eric E. Monson [mailto:emonson at cs.duke.edu]
>>> Gesendet: Freitag, 12. März 2010 15:54
>>> An: Dressler, Christian
>>> Cc: paraview at paraview.org
>>> Betreff: Re: [Paraview] Use existing texture map for 3D surface
>>> 
>>> Hey Christian,
>>> 
>>> If your data already has valid texture coordinates, highlight your surface in the Pipeline Browser. You should be able to go to the Display tab of the Object Inspector and in the Color section there is an Apply Texture combo box that should not be grayed-out if everything is ready for texturing. If you pull down to Load... it will let you load your texture image and you should see it on your surface.
>>> 
>>> Let us know if you have problems,
>>> -Eric
>>> 
>>> ------------------------------------------------------
>>> Eric E Monson
>>> Duke Visualization Technology Group
>>> 
>>> 
>>> On Mar 12, 2010, at 7:51 AM, Dressler, Christian wrote:
>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> I am trying to reconstruct data generated by a surface scanner with paraview. The data is structured as xyzuv arrays. I managed to calculate the surface by using the filters "Table to points" and "Delaunay 2D".
>>>> 
>>>> But I could not figure out, how to apply the texture to the surface. The uv-coordinates have the same format as the maps generated by the paraview texture filters (normalized position of bitmap).
>>>> 
>>>> How can I make paraview using my own texture map?
>>>> 
>>>> 
>>>> Best,
>>>> 
>>>> Christian
>>>> ____________________________________________
>>>> Dipl.-Ing. Christian Dressler
>>>> Research Associate  | Working Group - S-DICOM Solutions
>>>> 
>>>> Universität Leipzig | Faculty of Medicine
>>>> Innovation Center Computer Assisted Surgery (ICCAS)
>>>> Semmelweisstr. 14
>>>> D - 04103 Leipzig
>>>> Germany
>>>> 
>>>> phone  +49 (0) 341 97 - 12018
>>>> fax    +49 (0) 341 97 - 12009
>>>> christian.dressler at medizin.uni-leipzig.de
>>>> http://www.iccas.de/?id=430
>>>> ____________________________________________
>>>> 
>>>> _______________________________________________
>>>> 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 ParaView Wiki at: http://paraview.org/Wiki/ParaView
>>>> 
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.paraview.org/mailman/listinfo/paraview
>>> 
>>> _______________________________________________
>>> 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 ParaView Wiki at: http://paraview.org/Wiki/ParaView
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.paraview.org/mailman/listinfo/paraview
>>> 
>> 
> _______________________________________________
> 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 ParaView Wiki at: http://paraview.org/Wiki/ParaView
> 
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview



More information about the ParaView mailing list