[vtkusers] Clipping Planes
John Biddiscombe
jbiddiscombe at skippingmouse.co.uk
Wed Aug 11 07:19:34 EDT 2004
After calling AddDisplacement(...) you are calling resetCameralippingRage() yes? If not. try it.
JB
----- Original Message -----
From: James Robinson
To: Vtk Users
Sent: Wednesday, August 11, 2004 11:24 AM
Subject: [vtkusers] Clipping Planes
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
------------------------------------------------------------------------------
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040811/8d8be511/attachment.htm>
More information about the vtkusers
mailing list