[vtkusers] Removing internal cells !
Sebastien Auclair
sxa at fluent.com
Fri Apr 18 11:36:58 EDT 2003
This is the code :
######################################################################
/*
THE CODE USUALLY PRESENT BEFORE THIS LINE IS NOT RELEVANT FOR THIS
MAILLED CODE SAMBLE
*/
int h, i, pointCount, oldPointCount, polylineCount;
vtkPolyData* aGrid = vtkPolyData::New();
polylineCount = m_AllPolylines.count();
QDictIterator<TK3DPointList> it( m_AllPolylines ); // See QDictIterator
it.toFirst () ;
aGrid->Allocate(polylineCount, polylineCount );
oldPointCount = 0;
vtkPoints* allPoints = vtkPoints::New();
allPoints = getAllPolylinesPoints();
// This will put in allPoints the following points describing a square:
/*
(0, 0.0 ,0.0, 0.0);
(1, 20.0 ,0.0, 0.0);
(2, 20.0 ,20.0, 0.0);
(3, 0.0 ,20.0, 0.0);
(4, 0.0 ,0.0, 0.0);
*/
vtkIdList* array = vtkIdList::New();
for (h = 0; h < polylineCount; h++){
pointCount = (it.current())->m_points->GetNumberOfPoints ();
array->SetNumberOfIds(pointCount);
for (i = 0; i < pointCount; i++){
array->SetId(i, i + oldPointCount);
}
aGrid->InsertNextCell (VTK_POLYGON, array);
array->Reset();
oldPointCount += pointCount;
++it ;
}
aGrid->SetPoints( allPoints);
aGrid->Update();
vtkGLUTesselatorTriangleFilter* tri =
vtkGLUTesselatorTriangleFilter::New();
tri->SetInput(aGrid);
tri->PassVertsOff ();
tri->PassLinesOff ();
tri->Update();
vtkReverseSense* reverser = vtkReverseSense::New();
reverser->SetInput(tri->GetOutput());
reverser->ReverseCellsOn ();
reverser->ReverseNormalsOff ();
reverser->Update();
vtkPolyDataNormals* normalA = vtkPolyDataNormals::New();
normalA->SetInput(reverser->GetOutput());
normalA->Update();
vtkLinearExtrusionFilter* extruder= vtkLinearExtrusionFilter::New();
extruder->SetInput(normalA->GetOutput());
extruder->SetExtrusionTypeToNormalExtrusion ();
extruder->CappingOn ();
extruder->SetScaleFactor (-m_thickness);
extruder->Update();
vtkPolyDataNormals* normal = vtkPolyDataNormals::New();
normal->SetInput(extruder->GetOutput());
normal->Update();
/*
THE CODE USUALLY HERE IS NOT RELEVANT FOR THIS MAILLED CODE SAMBLE
*/
aGrid->Delete();
array->Delete();
tri->Delete();
reverser->Delete();
normalA->Delete();
normal->Delete();
extruder->Delete();
allPoints->Delete();
##################################################################3
Thanks !
__________________________________
Seb
----- Original Message -----
From: "Berk Geveci" <berklist at nycap.rr.com>
To: "Sebastien Auclair" <sxa at fluent.com>
Sent: Thursday, April 17, 2003 4:11 PM
Subject: Re: [vtkusers] Removing internal cells !
> > Yes i'am using vtkLinearExtrusionFilter.
> > The polygons are complex and often non-convex so before being extruded,
they
> > are passed through vtkGLUTesselatorTriangleFilter.
> >
> > When displayed with transparency, we can see the internal facets !
>
> hmm. I wonder if this has something to do with the way
> tesselation is done (duplicate points, edges etc.). Can you
> reproduce this with one simple polygon (and if you can,
> can you write it to a file and send it to me) ?
>
> -Berk
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RESULT.jpg
Type: image/jpeg
Size: 65533 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030418/8e7e7a52/attachment.jpg>
More information about the vtkusers
mailing list