• 计算vtkRender的屏幕坐标范围和物理坐标范围


    vtkRenderWindow可以包含多个vtkRender,在模型检测等计算过程中需要计算一些vtkRender的屏幕范围和物理范围,最近想了一种方案:

    计算屏幕坐标范围:

    double vp[4];
    this->Renderer->GetViewport(vp);
    
    this->Renderer->NormalizedDisplayToDisplay(vp[0], vp[1]);
    this->Renderer->NormalizedDisplayToDisplay(vp[2], vp[3]);
    
    double dx = vp[2] - vp[0];
    double dy = vp[3] - vp[1];

    计算物理坐标范围:

    double vp[4];
    this->Renderer->GetViewport(vp);
    
    double wp1[3] = { vp[0], vp[1], 0.0 };
    double wp2[3] = { vp[2], vp[3], 0.0 };
    
    this->Renderer->NormalizedDisplayToViewport(wp1[0], wp1[1]);
    this->Renderer->ViewportToNormalizedViewport(wp1[0], wp1[1]);
    this->Renderer->NormalizedViewportToView(wp1[0], wp1[1], wp1[2]);
    this->Renderer->ViewToWorld(wp1[0], wp1[1], wp1[2]);
    
    this->Renderer->NormalizedDisplayToViewport(wp2[0], wp2[1]);
    this->Renderer->ViewportToNormalizedViewport(wp2[0], wp2[1]);
    this->Renderer->NormalizedViewportToView(wp2[0], wp2[1], wp2[2]);
    this->Renderer->ViewToWorld(wp2[0], wp2[1], wp2[2]);
  • 相关阅读:
    using 关键字在 C++ 中的几种用法
    Chromium 修改图片资源
    SAM&广义SAM
    Burnside和Polya
    笔记:杜教筛
    笔记:莫比乌斯反演
    Miller-Rabin
    点分治
    虚树
    计算几何
  • 原文地址:https://www.cnblogs.com/xuhui24/p/6833260.html
Copyright © 2020-2023  润新知