[vtkusers] Clipping Planes
James Robinson
j.robinson at kepler-systems.com
Wed Aug 11 06:24:22 EDT 2004
Dear All,
I am having trouble (again) with clipping planes. I am trying to create a
viewer to view results of an FE analysis. Part of the results are the
displacements at the nodes of the finite element mesh. I read in the FE mesh
into a vtkUnstructuredGrid with the displacements as a vector field. I then
create a displaced geometry by adding them to the vtkUnstructuredGrid
geometry as follows:
void CSampleDoc::AddDisplacement(float factor)
{ vtkFloatArray *pDisplacement =
(vtkFloatArray*)this->pUnstructuredGrid->GetPointData()->GetVectors() ;
vtkPoints* pNodalGeometry = this->pUnstructuredGrid->GetPoints()
;
if (pDisplacement==NULL)
{ AfxMessageBox("No displacement set") ;
return ;
}
float newcoords[3] ;
float* x ;
float* delta ;
for (int i = 0; i < pNodalGeometry->GetNumberOfPoints(); i++)
{
x = pNodalGeometry->GetPoint(i) ;
delta = pDisplacement->GetTuple(i) ;
for (int j = 0; j < 3; j++)
{ newcoords[j] = x[j] + factor*delta[j] ;
}
pNodalGeometry->SetPoint(i,newcoords) ;
}
this->pUnstructuredGrid->Update() ;
this->pGeometry->SetInput(pUnstructuredGrid) ;
this->pMeshMapper->SetInput(pGeometry->GetOutput());
this->pMeshMapper->Update() ;
this->pMeshActor->SetMapper(this->pMeshMapper) ;
}
This works (with some other quirky behaviour which I have circumvented). But
a problem that I am having difficulty with is that the clipping planes
remain as if the geometry hadn't been altered. Thus, as I rotate the object
(in trackball camera mode) the displaced object disappears. I have checked
the bounds of the viewable objects (using
Renderer->ComputeVisiblePropBounds(bounds) ;) and they are unaltered - thus
all the AutoClipping is thrown out of whack. It may very well be that (a) I
am doing things that are not meant to be catered for in vtk or (b) there is
a better (preferably simpler) way of achieving this effect.
All suggestions gratefully welcomed.
Jim
James C Robinson, PhD, Chartered Engineer,
* 42 Rivergrove,
Glanmire,
Co. Cork,
Eire
' +353 21 4822028
+353 87 2393010
6 +353 21 4822028
* j.robinson at kepler-systems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040811/bb8f4a72/attachment.htm>
More information about the vtkusers
mailing list