[vtkusers] Clipping Planes

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Wed Aug 11 07:49:35 EDT 2004


I see Something...

loop
       pNodalGeometry->SetPoint(i,newcoords) ;

end loop



now try

pNodalGeometry->Modified()

 

that might force the bounds change to be picked up. But between you and me you ought to be careful, if the pNodalGeometry data is being output from another filter, then it may get overwritten later. Maybe a deepcopy or a new dataset is in order.

 

JB

 

  ----- Original Message ----- 
  From: James Robinson 
  To: 'John Biddiscombe' 
  Cc: Vtk Users 
  Sent: Wednesday, August 11, 2004 12:40 PM
  Subject: RE: [vtkusers] Clipping Planes


  John,

   

  Many thanks for replying. I have tried EVERYTHING. I have even tried reloading all the props into the renderer. I have checked the altered bounds on everything from the vtkUnstructuredGrid to the vtkPoints* pNodalGeometry. None of the bounds are altered after the change (which, I would imagine, is why the resetting of the clip planes has no effect). My workaround is:

   

  void CSampleView::ResetCameraClippingRange(BOOL ShowDisplacement)

  {   

  //          float    bounds[6]  ;

  //  Renderer->ComputeVisiblePropBounds(bounds) ;

  //          Renderer->ResetCameraClippingRange() ;

   

    // TODO: add construction code here

      vtkInteractorStyleSwitch* pStyle = (vtkInteractorStyleSwitch*)Interactor->GetInteractorStyle() ;

      if (ShowDisplacement)

              { 

                          pStyle->AutoAdjustCameraClippingRangeOff() ;

                          vtkCamera* pCamera = Renderer->GetActiveCamera() ;

                          pCamera->SetClippingRange(0.001, 1000.) ; // Arbitrary - this could be automated

              } else

              {

                          pStyle->AutoAdjustCameraClippingRangeOn() ;

              }

              

  }

   

  which I call every time the displacement view option is chosen. Note that it was at this level that I tried to ResetCameraClippingRange (both with bounds computed and not), but to no avail.

   

  Any other suggestions welcomed.

   

  Regards,

   

  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 


------------------------------------------------------------------------------

  From: John Biddiscombe [mailto:jbiddiscombe at skippingmouse.co.uk] 
  Sent: 11 August 2004 12:20
  To: j.robinson at kepler-systems.com; Vtk Users
  Subject: Re: [vtkusers] Clipping Planes

   

  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/13c33e86/attachment.htm>


More information about the vtkusers mailing list