[vtk-developers] vtkCleanPolyData on textured surfaces

Michael Halle mhalle at bwh.harvard.edu
Thu Sep 30 08:15:04 EDT 2004


Hi Tim,

Looks like your code assumes the model has texture coordinates.
Furthermore, it does a direct C compare of the coordinates; because
of floating point error, you probably want some sort of error
allowed.

--Michael Halle
mhalle @ bwh.harvard.edu

On Sep 30, 2004, at 7:28 AM, Tim Hutton wrote:

> A couple of times the users list has mentioned that when you run 
> vtkCleanPolyData on textured surfaces, the texture sometimes gets 
> broken. This happens when two points are merged (because they are in 
> the same place), ignoring the fact that they have different tcoords.
>
> The result of this problem is shown here:
> http://www.eastman.ucl.ac.uk/~thutton/VTK/tcoords_merged_problem.jpg 
> (23k)
>
> The solution I'm using at the moment is to alter two bits of code in 
> vtkCleanPolyData, where the polygons and poly strips are merged (code 
> below).
>
> Perhaps a better alternative would be to have this functionality as an 
> option in vtkPointLocator, however what gets  passed to 
> InsertUniquePoint is just a double[3] and thus there is no easy way 
> for the locator to access the tcoords.
>
> So, I'm seeking advice on whether to:
>
> a) add the code as an option (IgnoreTextureCoordinates=1 by default to 
> keep current functionality) to vtkCleanPolyData.
> b) derive a new class from vtkCleanPolyData (means duplicating much of 
> the code of Execute())
> c) implement some way for the vtkPointLocator to check the tcoords if 
> desired
> d) implement nothing, but tell vtkusers about my workaround.
>
> The idea could be generalized to other point data, for example to not 
> merge two vertices if they had different scalars, however I suspect 
> that this wouldn't be of use to anyone.
>
> Thankyou for your time.
>
> Tim
>
> ------------------------------------
> OLD CODE: (at lines 337 and 423 in revision 1.74 of 
> vtkCleanPolyData.cxx)
>
> else if ( this->Locator->InsertUniquePoint(newx, ptId) )
>   {
>   outputPD->CopyData(inputPD,pts[i],ptId);
>   }
>
> ------------------------------------
> REPLACEMENT CODE:
>
> else
>   {
>     ptId = this->Locator->IsInsertedPoint(newx);
>     if(ptId!=-1)
>     {
>         // a point exists at this location - only insert our point if 
> tcoords differ
>         float *t1,*t2;
>         t1 = inputPD->GetTCoords()->GetTuple(pts[i]);
>         t2 = outputPD->GetTCoords()->GetTuple(ptId);
>         if(t1[0]!=t2[0] || t1[1]!=t2[1])
>         {
>           // insert the point, this vertex is duplicated
>           ptId = this->Locator->InsertNextPoint(newx); // note that 
> this is not InsertUniquePoint
>           outputPD->CopyData(inputPD,pts[i],ptId);
>         }
>     }
>     else
>     {
>       // this point hasn't been seen already, so add it
>       ptId = this->Locator->InsertNextPoint(newx);
>       outputPD->CopyData(inputPD,pts[i],ptId);
>     }
>   }
>
> ------------------------------------
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers




More information about the vtk-developers mailing list