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


C++ point_type::project方法代码示例

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


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

示例1: sliceTriangle

      void sliceTriangle(const point_type& A,
                         const point_type& B,
                         const point_type& C,
                         const vec_type& N,
                         SegmentStack& _segmentStack) const
      {
        using geometry::prim::Segment;
        typedef geometry::comp::Compound<Segment> SegmentPlane;
        
        SegmentStack::iterator _Ait = _segmentStack.get(A.z()),
                               _Bit = _segmentStack.get(B.z()),
                               _Cit = _segmentStack.get(C.z()),
                               it;

        Point2f _Aproj = A.project(geometry::base::Z);
        vec_type b = B - A;
        scalar_type _invBz = 1.0 / b.z();
        vec_type c = C - A;
        scalar_type _invCz = 1.0 / c.z();
        vec_type d = C - B;
        scalar_type _invDz = 1.0 / d.z();
        scalar_type _ratioR, _ratioS, _pos;
        Vec2f r,s;

        bool _passedB = false;

        for (it = _Ait ; it != _Cit && it != _segmentStack.end(); ++it)
        {
          SegmentPlane* _segmentPlane = &(it->second);
          if (it == _Bit) _passedB = true;

          if (!_passedB)
          {
            _pos = it->first - A.z();
            _ratioR = _pos * _invCz;
            _ratioS = _pos * _invBz;
            s(b.x()*_ratioS,b.y()*_ratioS);
          } else
          {
            _pos = it->first;
            _ratioR = (_pos - A.z()) * _invCz;
            _ratioS = (_pos - B.z()) * _invDz;
            s(b.x() + d.x()*_ratioS,b.y() + d.y()*_ratioS);
          }
          
          r(c.x()*_ratioR,c.y()*_ratioR);

          Point2f _p0 = _Aproj+r, _p1 = _Aproj+s;
          Vec2f _normal = _p1 - _p0;  // Normal of segment points
          if (_normal.sqrLength() == 0.0) continue;
          _normal(-_normal[1],_normal[0]);
          /// Swap point to assure that points are in proper order to be able to make lineSegments
          if (dot(Vec2f(N.x(),N.y()),_normal) > 0.0) std::swap(_p0,_p1);
          _segmentPlane->add(Segment(_p0,_p1));
        }
      }
开发者ID:aeickho,项目名称:Tomo,代码行数:56,代码来源:TriangleSlicer.hpp


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