本文整理汇总了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));
}
}