我的菜地

gmsh,vtk,opensees,tcl/tk,FEM

博客园 首页 新随笔 联系 订阅 管理

借鉴了vtk里WidgetsCxxTests的例子

vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter =
    vtkSmartPointer<vtkTransformPolyDataFilter>::New();
  vtkSmartPointer<vtkTransform> transform =
    vtkSmartPointer<vtkTransform>::New();
  transformFilter->SetTransform( transform );

 
  CRect rect;
  HWND hWnd = this->GetSafeHwnd();
  pvtkMFCWindow->GetClientRect(&rect);
  int cx,cy;
  cx=rect.Width();
  cy=rect.Height();


   pvtkMFCWindow->GetRenderWindow()->SetSize( cx, cy );

  vtkSmartPointer<vtkRenderWindowInteractor> iren =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  iren->SetRenderWindow( pvtkMFCWindow->GetRenderWindow() );


  // set up an interesting view
  //
  vtkCamera* camera = this->pvtkRenderer->GetActiveCamera();
  camera->SetViewUp( 0, 0, 1 );
  camera->SetFocalPoint( 0, 0, 0 );
  camera->SetPosition( 4.5, 4.5, 2.5 );
  this->pvtkRenderer->ResetCameraClippingRange();

 
  // this static function improves the appearance of the text edges
  // since they are overlaid on a surface rendering of the cube's faces
  //
  vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();

 

  vtkSmartPointer<vtkAxesActor> axes2 =
    vtkSmartPointer<vtkAxesActor>::New();

  // simulate a left-handed coordinate system
  //
  transform->Identity();
  //transform->RotateY(90);
  axes2->SetShaftTypeToCylinder();
  axes2->SetUserTransform( transform );
  axes2->SetXAxisLabelText( "x" );
  axes2->SetYAxisLabelText( "y" );
  axes2->SetZAxisLabelText( "z" );

  axes2->SetTotalLength( 0.5, 0.5, 0.5 );
  axes2->SetCylinderRadius( 0.500 * axes2->GetCylinderRadius() );
  axes2->SetConeRadius    ( 1.025 * axes2->GetConeRadius() );
  axes2->SetSphereRadius  ( 1.500 * axes2->GetSphereRadius() );

  vtkTextProperty* tprop = axes2->GetXAxisCaptionActor2D()->
    GetCaptionTextProperty();
  tprop->ItalicOn();
  tprop->ShadowOn();
  tprop->SetFontFamilyToTimes();

  axes2->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->ShallowCopy( tprop );
  axes2->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->ShallowCopy( tprop );

  // combine orientation markers into one with an assembly
  //
  vtkSmartPointer<vtkPropAssembly> assembly =
    vtkSmartPointer<vtkPropAssembly>::New();
  assembly->AddPart( axes2 );
 // assembly->AddPart( cube );

   this->pvtkRenderer->AddViewProp( axes2 );

 
 // iren->Initialize();
  pvtkMFCWindow->GetRenderWindow()->Render();
 

  //iren->Start();

  return EXIT_SUCCESS;

posted on 2010-02-20 16:26  大哈  阅读(1861)  评论(0编辑  收藏  举报