本文整理汇总了C++中KoPathPoint::isSmooth方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathPoint::isSmooth方法的具体用法?C++ KoPathPoint::isSmooth怎么用?C++ KoPathPoint::isSmooth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathPoint
的用法示例。
在下文中一共展示了KoPathPoint::isSmooth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KoPathPointIndex
QList<KoSubpath *> KarbonSimplifyPath::split( const KoPathShape &path )
{
QList<KoSubpath *> res;
KoSubpath *subpath = new KoSubpath;
res.append( subpath );
for ( int i = 0; i < path.pointCount(); ++i )
{
KoPathPoint *p = path.pointByIndex( KoPathPointIndex(0, i) );
// if the path separates two subpaths
// (if it isn't smooth nor the first or last point)
if ( i != 0 && i != path.pointCount()-1 )
{
KoPathPoint *prev = path.pointByIndex( KoPathPointIndex(0, i-1) );
KoPathPoint *next = path.pointByIndex( KoPathPointIndex(0, i+1) );
if ( ! p->isSmooth(prev, next) )
{
// create a new subpath
subpath->append( new KoPathPoint(*p) );
subpath = new KoSubpath;
res.append( subpath );
}
}
subpath->append( new KoPathPoint(*p) );
}
return res;
}
示例2: roundPath
//.........这里部分代码省略.........
// TODO: not sure if we should only touch flat segment joins as the original algorithm
m_path->clear();
int subpathCount = m_copy->subpathCount();
for( int subpathIndex = 0; subpathIndex < subpathCount; ++subpathIndex )
{
int pointCount = m_copy->pointCountSubpath( subpathIndex );
if( ! pointCount )
continue;
// check if we have sufficient number of points
if( pointCount < 3 )
{
// copy the only segment
KoPathSegment s = m_copy->segmentByIndex( KoPathPointIndex( subpathIndex, 0 ) );
m_path->moveTo( m_copy->pointByIndex( KoPathPointIndex( subpathIndex, 0 ) )->point() );
addSegment( m_path, s );
continue;
}
KoPathSegment prevSeg = m_copy->segmentByIndex( KoPathPointIndex( subpathIndex, pointCount-1 ) );
KoPathSegment nextSeg = m_copy->segmentByIndex( KoPathPointIndex( subpathIndex, 0 ) );
KoPathSegment lastSeg;
KoPathPoint * currPoint = nextSeg.first();
KoPathPoint * firstPoint = 0;
KoPathPoint * lastPoint = 0;
// check if first path point is a smooth join with the closing segment
bool firstPointIsCorner = m_copy->isClosedSubpath( subpathIndex )
&& ! currPoint->isSmooth( prevSeg.first(), nextSeg.second() );
// Begin: take care of the first path point
if( firstPointIsCorner )
{
// split the previous segment at length - radius
qreal prevLength = prevSeg.length();
qreal prevSplit = prevLength > m_radius ? prevSeg.paramAtLength( prevLength-m_radius ) : 0.5;
QPair<KoPathSegment,KoPathSegment> prevParts = prevSeg.splitAt( prevSplit );
// split the next segment at radius
qreal nextLength = nextSeg.length();
qreal nextSplit = nextLength > m_radius ? nextSeg.paramAtLength( m_radius ) : 0.5;
QPair<KoPathSegment,KoPathSegment> nextParts = nextSeg.splitAt( nextSplit );
// calculate smooth tangents
QPointF P0 = prevParts.first.second()->point();
QPointF P3 = nextParts.first.second()->point();
qreal tangentLength1 = 0.5 * QLineF( P0, currPoint->point() ).length();
qreal tangentLength2 = 0.5 * QLineF( P3, currPoint->point() ).length();
QPointF P1 = P0 - tangentLength1 * tangentAtEnd( prevParts.first );
QPointF P2 = P3 - tangentLength2 * tangentAtStart( nextParts.second );
// start the subpath
firstPoint = m_path->moveTo( prevParts.second.first()->point() );
// connect the split points with curve
// TODO: shall we create a correct arc?
m_path->curveTo( P1, P2, P3 );
prevSeg = nextParts.second;
lastSeg = prevParts.first;
}
else