当前位置: 首页>>代码示例>>C++>>正文


C++ BaseRenderer::GetCurrentWorldGeometry2D方法代码示例

本文整理汇总了C++中BaseRenderer::GetCurrentWorldGeometry2D方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseRenderer::GetCurrentWorldGeometry2D方法的具体用法?C++ BaseRenderer::GetCurrentWorldGeometry2D怎么用?C++ BaseRenderer::GetCurrentWorldGeometry2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseRenderer的用法示例。


在下文中一共展示了BaseRenderer::GetCurrentWorldGeometry2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: timeStep

bool
mitk::PlanarFigureInteractor::IsMousePositionAcceptableAsNewControlPoint(
    mitk::StateEvent const * stateEvent,
    const PlanarFigure* planarFigure )
{
  assert(stateEvent && planarFigure);

  BaseRenderer* renderer = stateEvent->GetEvent()->GetSender();

  assert(renderer);

  // Get the timestep to support 3D+t
  int timeStep( renderer->GetTimeStep( planarFigure ) );

  // Get current display position of the mouse
  //Point2D currentDisplayPosition = positionEvent->GetDisplayPosition();

  // Check if a previous point has been set
  bool tooClose = false;

  const Geometry2D *renderingPlane = renderer->GetCurrentWorldGeometry2D();

  mitk::Geometry2D *planarFigureGeometry =
    dynamic_cast< mitk::Geometry2D * >( planarFigure->GetGeometry( timeStep ) );

  Point2D point2D, correctedPoint;
  // Get the point2D from the positionEvent
  if ( !this->TransformPositionEventToPoint2D( stateEvent, point2D,
    planarFigureGeometry ) )
  {
    return false;
  }

  // apply the controlPoint constraints of the planarFigure to get the
  // coordinates that would actually be used.
  correctedPoint = const_cast<PlanarFigure*>( planarFigure )->ApplyControlPointConstraints( 0, point2D );

  // map the 2D coordinates of the new point to world-coordinates
  // and transform those to display-coordinates
  mitk::Point3D newPoint3D;
  planarFigureGeometry->Map( correctedPoint, newPoint3D );
  mitk::Point2D newDisplayPosition;
  renderingPlane->Map( newPoint3D, newDisplayPosition );
  renderer->GetDisplayGeometry()->WorldToDisplay( newDisplayPosition, newDisplayPosition );


  for( int i=0; i < (int)planarFigure->GetNumberOfControlPoints(); i++ )
  {
    if ( i != planarFigure->GetSelectedControlPoint() )
    {
      // Try to convert previous point to current display coordinates
      mitk::Point3D previousPoint3D;
      // map the 2D coordinates of the control-point to world-coordinates
      planarFigureGeometry->Map( planarFigure->GetControlPoint( i ), previousPoint3D );

      if ( renderer->GetDisplayGeometry()->Distance( previousPoint3D ) < 0.1 ) // ugly, but assert makes this work
      {
        mitk::Point2D previousDisplayPosition;
        // transform the world-coordinates into display-coordinates
        renderingPlane->Map( previousPoint3D, previousDisplayPosition );
        renderer->GetDisplayGeometry()->WorldToDisplay( previousDisplayPosition, previousDisplayPosition );

        //Calculate the distance. We use display-coordinates here to make
        // the check independent of the zoom-level of the rendering scene.
        double a = newDisplayPosition[0] - previousDisplayPosition[0];
        double b = newDisplayPosition[1] - previousDisplayPosition[1];

        // If point is to close, do not set a new point
        tooClose = (a * a + b * b < m_MinimumPointDistance );
      }
      if ( tooClose )
        return false; // abort loop early
    }
  }

  return !tooClose; // default
}
开发者ID:cewee,项目名称:MITK,代码行数:77,代码来源:mitkPlanarFigureInteractor.cpp


注:本文中的BaseRenderer::GetCurrentWorldGeometry2D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。