Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBezierMeshDetails::Mesh< NodeArg, PatchArg > Class Template Reference

#include <KisBezierMesh.h>

+ Inheritance diagram for KisBezierMeshDetails::Mesh< NodeArg, PatchArg >:

Classes

class  control_point_iterator_impl
 
struct  ControlPointIndex
 
struct  NodeIndex
 
class  patch_iterator_impl
 
struct  PatchIndex
 
class  segment_iterator_impl
 

Public Types

using control_point_const_iterator = control_point_iterator_impl<true>
 
using control_point_iterator = control_point_iterator_impl<false>
 
using ControlType = typename ControlPointIndex::ControlType
 
using Node = NodeArg
 
using Patch = PatchArg
 
using patch_const_iterator = patch_iterator_impl<true>
 
using patch_iterator = patch_iterator_impl<false>
 
using segment_const_iterator = segment_iterator_impl<true>
 
using segment_iterator = segment_iterator_impl<false>
 
using SegmentIndex = std::pair<NodeIndex, int>
 

Public Member Functions

control_point_iterator beginControlPoints ()
 
control_point_const_iterator beginControlPoints () const
 
patch_iterator beginPatches ()
 
patch_const_iterator beginPatches () const
 
segment_iterator beginSegments ()
 
segment_const_iterator beginSegments () const
 
control_point_const_iterator constBeginControlPoints () const
 
patch_const_iterator constBeginPatches () const
 
segment_const_iterator constBeginSegments () const
 
control_point_const_iterator constEndControlPoints () const
 
patch_const_iterator constEndPatches () const
 
segment_const_iterator constEndSegments () const
 
control_point_const_iterator constFind (const ControlPointIndex &index) const
 
control_point_const_iterator constFind (const NodeIndex &index) const
 
patch_const_iterator constFind (const PatchIndex &index) const
 
segment_const_iterator constFind (const SegmentIndex &index) const
 
QRectF dstBoundingRect () const
 
control_point_iterator endControlPoints ()
 
control_point_const_iterator endControlPoints () const
 
patch_iterator endPatches ()
 
patch_const_iterator endPatches () const
 
segment_iterator endSegments ()
 
segment_const_iterator endSegments () const
 
control_point_iterator find (const ControlPointIndex &index)
 
control_point_const_iterator find (const ControlPointIndex &index) const
 
control_point_iterator find (const NodeIndex &index)
 
control_point_const_iterator find (const NodeIndex &index) const
 
patch_iterator find (const PatchIndex &index)
 
patch_const_iterator find (const PatchIndex &index) const
 
segment_iterator find (const SegmentIndex &index)
 
segment_const_iterator find (const SegmentIndex &index) const
 
ControlPointIndex hitTestControlPoint (const QPointF &pt, qreal distanceThreshold) const
 
ControlPointIndex hitTestNode (const QPointF &pt, qreal distanceThreshold) const
 
SegmentIndex hitTestSegment (const QPointF &pt, qreal distanceThreshold, qreal *t=0) const
 
bool isIdentity () const
 
template<typename T >
bool isIndexValid (const T &index) const
 
Patch makePatch (const PatchIndex &index) const
 
Patch makePatch (int col, int row) const
 
 Mesh ()
 
 Mesh (const QRectF &mapRect, const QSize &size=QSize(2, 2))
 
Nodenode (const NodeIndex &index)
 
const Nodenode (const NodeIndex &index) const
 
Nodenode (int col, int row)
 
const Nodenode (int col, int row) const
 
bool operator== (const Mesh &rhs) const
 
QRectF originalRect () const
 
void removeColumn (int column)
 
void removeColumnOrRow (NodeIndex index, bool row)
 
void removeRow (int row)
 
void reshapeMeshHorizontally (int numColumns)
 
void reshapeMeshVertically (int numRows)
 
QSize size () const
 
int subdivideColumn (int leftColumn, qreal relProportionalT)
 
int subdivideColumn (qreal proportionalT)
 
int subdivideRow (int topRow, qreal relProportionalT)
 
int subdivideRow (qreal proportionalT)
 
void subdivideSegment (SegmentIndex index, qreal proportionalT)
 
void transform (const QTransform &t)
 
void transformSrcAndDst (const QTransform &t)
 
void translate (const QPointF &offset)
 

Protected Attributes

std::vector< qreal > m_columns
 
std::vector< Nodem_nodes
 
QRectF m_originalRect
 
std::vector< qreal > m_rows
 
QSize m_size
 

Private Member Functions

ControlPointIndex hitTestPointImpl (const QPointF &pt, qreal distanceThreshold, bool onlyNodeMode) const
 
void splitCurveHorizontally (Node &left, Node &right, qreal t, Node &newNode)
 
void splitCurveVertically (Node &top, Node &bottom, qreal t, Node &newNode)
 
void unlinkNodeHorizontally (Mesh::Node &left, const Mesh::Node &node, Mesh::Node &right)
 
void unlinkNodeVertically (Mesh::Node &top, const Mesh::Node &node, Mesh::Node &bottom)
 

Static Private Member Functions

template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType beginControlPoints (MeshType &mesh)
 
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType beginPatches (MeshType &mesh)
 
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType beginSegments (MeshType &mesh)
 
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType endControlPoints (MeshType &mesh)
 
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType endPatches (MeshType &mesh)
 
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType endSegments (MeshType &mesh)
 
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType find (MeshType &mesh, const ControlPointIndex &index)
 
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType find (MeshType &mesh, const NodeIndex &index)
 
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType find (MeshType &mesh, const PatchIndex &index)
 
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType find (MeshType &mesh, const SegmentIndex &index)
 

Detailed Description

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
class KisBezierMeshDetails::Mesh< NodeArg, PatchArg >

Definition at line 128 of file KisBezierMesh.h.

Member Typedef Documentation

◆ control_point_const_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::control_point_const_iterator = control_point_iterator_impl<true>

Definition at line 971 of file KisBezierMesh.h.

◆ control_point_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::control_point_iterator = control_point_iterator_impl<false>

Definition at line 970 of file KisBezierMesh.h.

◆ ControlType

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::ControlType = typename ControlPointIndex::ControlType

Definition at line 238 of file KisBezierMesh.h.

◆ Node

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::Node = NodeArg

Definition at line 131 of file KisBezierMesh.h.

◆ Patch

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::Patch = PatchArg

Definition at line 132 of file KisBezierMesh.h.

◆ patch_const_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::patch_const_iterator = patch_iterator_impl<true>

Definition at line 968 of file KisBezierMesh.h.

◆ patch_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::patch_iterator = patch_iterator_impl<false>

Definition at line 967 of file KisBezierMesh.h.

◆ segment_const_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::segment_const_iterator = segment_iterator_impl<true>

Definition at line 974 of file KisBezierMesh.h.

◆ segment_iterator

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::segment_iterator = segment_iterator_impl<false>

Definition at line 973 of file KisBezierMesh.h.

◆ SegmentIndex

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
using KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::SegmentIndex = std::pair<NodeIndex, int>

Definition at line 160 of file KisBezierMesh.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::Mesh ( )
inline

Definition at line 717 of file KisBezierMesh.h.

718 : Mesh(QRectF(0.0, 0.0, 1.0, 1.0))
719 {
720 }

◆ Mesh() [2/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::Mesh ( const QRectF & mapRect,
const QSize & size = QSize(2,2) )
inline

Definition at line 722 of file KisBezierMesh.h.

723 : m_size(size),
724 m_originalRect(mapRect)
725 {
726 const qreal xControlOffset = 0.2 * (mapRect.width() / size.width());
727 const qreal yControlOffset = 0.2 * (mapRect.height() / size.height());
728
729 for (int row = 0; row < m_size.height(); row++) {
730 const qreal yPos = qreal(row) / (size.height() - 1) * mapRect.height() + mapRect.y();
731
732 for (int col = 0; col < m_size.width(); col++) {
733 const qreal xPos = qreal(col) / (size.width() - 1) * mapRect.width() + mapRect.x();
734
735 Node node(QPointF(xPos, yPos));
736 node.setLeftControlRelative(QPointF(-xControlOffset, 0));
737 node.setRightControlRelative(QPointF(xControlOffset, 0));
738 node.setTopControlRelative(QPointF(0, -yControlOffset));
739 node.setBottomControlRelative(QPointF(0, yControlOffset));
740
741 m_nodes.push_back(node);
742 }
743 }
744
745 for (int col = 0; col < m_size.width(); col++) {
746 m_columns.push_back(qreal(col) / (size.width() - 1));
747 }
748
749 for (int row = 0; row < m_size.height(); row++) {
750 m_rows.push_back(qreal(row) / (size.height() - 1));
751 }
752 }
std::vector< qreal > m_rows
std::vector< qreal > m_columns
std::vector< Node > m_nodes
Node & node(int col, int row)
Definition Node.h:24

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::size().

Member Function Documentation

◆ beginControlPoints() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginControlPoints ( )
inline

Definition at line 984 of file KisBezierMesh.h.

984{ return beginControlPoints(*this); }
control_point_iterator beginControlPoints()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginControlPoints().

◆ beginControlPoints() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginControlPoints ( ) const
inline

◆ beginControlPoints() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginControlPoints ( MeshType & mesh)
inlinestaticprivate

Definition at line 1257 of file KisBezierMesh.h.

1257 {
1258 return IteratorType(&mesh, 0, 0, ControlType::RightControl);
1259 }

◆ beginPatches() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches ( )
inline

Definition at line 976 of file KisBezierMesh.h.

976{ return beginPatches(*this); }
patch_iterator beginPatches()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches().

◆ beginPatches() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches ( ) const
inline

Definition at line 977 of file KisBezierMesh.h.

977{ return beginPatches(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches().

◆ beginPatches() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches ( MeshType & mesh)
inlinestaticprivate

Definition at line 1243 of file KisBezierMesh.h.

1243 {
1244 return IteratorType(&mesh, 0, 0);
1245 }

◆ beginSegments() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments ( )
inline

Definition at line 992 of file KisBezierMesh.h.

992{ return beginSegments(*this); }
segment_iterator beginSegments()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments().

◆ beginSegments() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments ( ) const
inline

Definition at line 993 of file KisBezierMesh.h.

993{ return beginSegments(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments().

◆ beginSegments() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments ( MeshType & mesh)
inlinestaticprivate

Definition at line 1271 of file KisBezierMesh.h.

1271 {
1272 return IteratorType(&mesh, 0, 0, 0);
1273 }

◆ constBeginControlPoints()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constBeginControlPoints ( ) const
inline

◆ constBeginPatches()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constBeginPatches ( ) const
inline

Definition at line 978 of file KisBezierMesh.h.

978{ return beginPatches(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches().

◆ constBeginSegments()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constBeginSegments ( ) const
inline

Definition at line 994 of file KisBezierMesh.h.

994{ return beginSegments(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments().

◆ constEndControlPoints()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constEndControlPoints ( ) const
inline

Definition at line 990 of file KisBezierMesh.h.

990{ return endControlPoints(*this); }
control_point_iterator endControlPoints()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endControlPoints().

◆ constEndPatches()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constEndPatches ( ) const
inline

Definition at line 982 of file KisBezierMesh.h.

982{ return endPatches(*this); }
patch_iterator endPatches()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches().

◆ constEndSegments()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constEndSegments ( ) const
inline

Definition at line 998 of file KisBezierMesh.h.

998{ return endSegments(*this); }
segment_iterator endSegments()

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments().

◆ constFind() [1/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constFind ( const ControlPointIndex & index) const
inline

Definition at line 1002 of file KisBezierMesh.h.

1002{ return find(*this, index); }
control_point_iterator find(const ControlPointIndex &index)

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ constFind() [2/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constFind ( const NodeIndex & index) const
inline

Definition at line 1006 of file KisBezierMesh.h.

1006{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ constFind() [3/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constFind ( const PatchIndex & index) const
inline

Definition at line 1014 of file KisBezierMesh.h.

1014{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ constFind() [4/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::constFind ( const SegmentIndex & index) const
inline

Definition at line 1010 of file KisBezierMesh.h.

1010{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ dstBoundingRect()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
QRectF KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::dstBoundingRect ( ) const
inline

Definition at line 1024 of file KisBezierMesh.h.

1024 {
1025 QRectF result;
1026 for (auto it = beginPatches(); it != endPatches(); ++it) {
1027 result |= it->dstBoundingRect();
1028 }
1029 return result;
1030 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginPatches(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches().

◆ endControlPoints() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endControlPoints ( )
inline

◆ endControlPoints() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endControlPoints ( ) const
inline

◆ endControlPoints() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endControlPoints ( MeshType & mesh)
inlinestaticprivate

Definition at line 1264 of file KisBezierMesh.h.

1264 {
1265 return IteratorType(&mesh, 0, mesh.m_size.height(), 0);
1266 }

◆ endPatches() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches ( )
inline

Definition at line 980 of file KisBezierMesh.h.

980{ return endPatches(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches().

◆ endPatches() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches ( ) const
inline

Definition at line 981 of file KisBezierMesh.h.

981{ return endPatches(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches().

◆ endPatches() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endPatches ( MeshType & mesh)
inlinestaticprivate

Definition at line 1250 of file KisBezierMesh.h.

1250 {
1251 return IteratorType(&mesh, 0, mesh.m_size.height() - 1);
1252 }

◆ endSegments() [1/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments ( )
inline

Definition at line 996 of file KisBezierMesh.h.

996{ return endSegments(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments().

◆ endSegments() [2/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments ( ) const
inline

Definition at line 997 of file KisBezierMesh.h.

997{ return endSegments(*this); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments().

◆ endSegments() [3/3]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments ( MeshType & mesh)
inlinestaticprivate

Definition at line 1278 of file KisBezierMesh.h.

1278 {
1279 return IteratorType(&mesh, 0, mesh.m_size.height(), 0);
1280 }

◆ find() [1/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const ControlPointIndex & index)
inline

Definition at line 1000 of file KisBezierMesh.h.

1000{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [2/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const ControlPointIndex & index) const
inline

Definition at line 1001 of file KisBezierMesh.h.

1001{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [3/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const NodeIndex & index)
inline

Definition at line 1004 of file KisBezierMesh.h.

1004{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [4/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
control_point_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const NodeIndex & index) const
inline

Definition at line 1005 of file KisBezierMesh.h.

1005{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [5/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const PatchIndex & index)
inline

Definition at line 1012 of file KisBezierMesh.h.

1012{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [6/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
patch_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const PatchIndex & index) const
inline

Definition at line 1013 of file KisBezierMesh.h.

1013{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [7/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const SegmentIndex & index)
inline

Definition at line 1008 of file KisBezierMesh.h.

1008{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [8/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
segment_const_iterator KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( const SegmentIndex & index) const
inline

Definition at line 1009 of file KisBezierMesh.h.

1009{ return find(*this, index); }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find().

◆ find() [9/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( MeshType & mesh,
const ControlPointIndex & index )
inlinestaticprivate

Definition at line 1211 of file KisBezierMesh.h.

1211 {
1212 IteratorType it(&mesh, index.nodeIndex.x(), index.nodeIndex.y(), index.controlType);
1213 return it.isValid() ? it : mesh.endControlPoints();
1214 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::ControlPointIndex::controlType, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::ControlPointIndex::nodeIndex.

◆ find() [10/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = control_point_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( MeshType & mesh,
const NodeIndex & index )
inlinestaticprivate

Definition at line 1219 of file KisBezierMesh.h.

1219 {
1220 IteratorType it(&mesh, index.x(), index.y(), Mesh::ControlType::Node);
1221 return it.isValid() ? it : mesh.endControlPoints();
1222 }

◆ find() [11/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = patch_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( MeshType & mesh,
const PatchIndex & index )
inlinestaticprivate

Definition at line 1235 of file KisBezierMesh.h.

1235 {
1236 IteratorType it(&mesh, index.x(), index.y());
1237 return it.isValid() ? it : mesh.endPatches();
1238 }

◆ find() [12/12]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<class MeshType , class IteratorType = segment_iterator_impl<std::is_const<MeshType>::value>>
static IteratorType KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find ( MeshType & mesh,
const SegmentIndex & index )
inlinestaticprivate

Definition at line 1227 of file KisBezierMesh.h.

1227 {
1228 IteratorType it(&mesh, index.first.x(), index.first.y(), index.second);
1229 return it.isValid() ? it : mesh.endSegments();
1230 }

◆ hitTestControlPoint()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
ControlPointIndex KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestControlPoint ( const QPointF & pt,
qreal distanceThreshold ) const
inline

Definition at line 1059 of file KisBezierMesh.h.

1059 {
1060 return hitTestPointImpl(pt, distanceThreshold, false);
1061 }
ControlPointIndex hitTestPointImpl(const QPointF &pt, qreal distanceThreshold, bool onlyNodeMode) const

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestPointImpl().

◆ hitTestNode()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
ControlPointIndex KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestNode ( const QPointF & pt,
qreal distanceThreshold ) const
inline

Definition at line 1055 of file KisBezierMesh.h.

1055 {
1056 return hitTestPointImpl(pt, distanceThreshold, true);
1057 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestPointImpl().

◆ hitTestPointImpl()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
ControlPointIndex KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestPointImpl ( const QPointF & pt,
qreal distanceThreshold,
bool onlyNodeMode ) const
inlineprivate

Definition at line 1188 of file KisBezierMesh.h.

1188 {
1189 const qreal distanceThresholdSq = pow2(distanceThreshold);
1190
1191 auto result = endControlPoints();
1192 qreal minDistanceSq = std::numeric_limits<qreal>::max();
1193
1194 for (auto it = beginControlPoints(); it != endControlPoints(); ++it) {
1195 if (onlyNodeMode != (it.type() == ControlType::Node)) continue;
1196
1197 const qreal distSq = kisSquareDistance(*it, pt);
1198 if (distSq < minDistanceSq && distSq < distanceThresholdSq) {
1199 result = it;
1200 minDistanceSq = distSq;
1201 }
1202 }
1203
1204 return result.controlIndex();
1205 }
T pow2(const T &x)
Definition kis_global.h:166
qreal kisSquareDistance(const QPointF &pt1, const QPointF &pt2)
Definition kis_global.h:194

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginControlPoints(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endControlPoints(), kisSquareDistance(), and pow2().

◆ hitTestSegment()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
SegmentIndex KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::hitTestSegment ( const QPointF & pt,
qreal distanceThreshold,
qreal * t = 0 ) const
inline

Definition at line 1063 of file KisBezierMesh.h.

1063 {
1064 auto result = endSegments();
1065 qreal minDistance = std::numeric_limits<qreal>::max();
1066
1067 for (auto it = beginSegments(); it != endSegments(); ++it) {
1068
1069 qreal foundDistance = 0.0;
1070 const qreal foundT = KisBezierUtils::nearestPoint({it.p0(), it.p1(), it.p2(), it.p3()}, pt, &foundDistance);
1071
1072 if (foundDistance < minDistance && foundDistance < distanceThreshold) {
1073 result = it;
1074 minDistance = foundDistance;
1075 if (t) {
1076 *t = foundT;
1077 }
1078 }
1079 }
1080
1081 return result.segmentIndex();
1082 }
qreal nearestPoint(const QList< QPointF > controlPoints, const QPointF &point, qreal *resultDistance, QPointF *resultPoint)

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::beginSegments(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments(), and KisBezierUtils::nearestPoint().

◆ isIdentity()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
bool KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::isIdentity ( ) const
inline

Definition at line 1032 of file KisBezierMesh.h.

1032 {
1033 Mesh identityMesh(m_originalRect, m_size);
1034 return *this == identityMesh;
1035 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_originalRect, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size.

◆ isIndexValid()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
template<typename T >
bool KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::isIndexValid ( const T & index) const
inline

◆ makePatch() [1/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
Patch KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::makePatch ( const PatchIndex & index) const
inline

Definition at line 927 of file KisBezierMesh.h.

927 {
928 return makePatch(index.x(), index.y());
929 }
Patch makePatch(const PatchIndex &index) const

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::makePatch().

◆ makePatch() [2/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
Patch KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::makePatch ( int col,
int row ) const
inline

Definition at line 931 of file KisBezierMesh.h.

932 {
933 const Node &tl = node(col, row);
934 const Node &tr = node(col + 1, row);
935 const Node &bl = node(col, row + 1);
936 const Node &br = node(col + 1, row + 1);
937
938 Patch patch;
939
940 patch.points[Patch::TL] = tl.node;
941 patch.points[Patch::TL_HC] = tl.rightControl;
942 patch.points[Patch::TL_VC] = tl.bottomControl;
943
944 patch.points[Patch::TR] = tr.node;
945 patch.points[Patch::TR_HC] = tr.leftControl;
946 patch.points[Patch::TR_VC] = tr.bottomControl;
947
948 patch.points[Patch::BL] = bl.node;
949 patch.points[Patch::BL_HC] = bl.rightControl;
950 patch.points[Patch::BL_VC] = bl.topControl;
951
952 patch.points[Patch::BR] = br.node;
953 patch.points[Patch::BR_HC] = br.leftControl;
954 patch.points[Patch::BR_VC] = br.topControl;
955
956 const QRectF relRect(m_columns[col],
957 m_rows[row],
958 m_columns[col + 1] - m_columns[col],
959 m_rows[row + 1] - m_rows[row]);
960
962 tl, tr, bl, br);
963
964 return patch;
965 }
KisNodeSP node() const
Definition Node.cpp:827
QPointF relativeToAbsolute(const QPointF &pt, const QRectF &rc)
void assignPatchData(KisBezierPatch *patch, const QRectF &srcRect, const BaseMeshNode &tl, const BaseMeshNode &tr, const BaseMeshNode &bl, const BaseMeshNode &br)

References KisBezierMeshDetails::assignPatchData(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_originalRect, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, Node::node(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisAlgebra2D::relativeToAbsolute().

◆ node() [1/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
Node & KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node ( const NodeIndex & index)
inline

Definition at line 772 of file KisBezierMesh.h.

772 {
773 return node(index.x(), index.y());
774 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node().

◆ node() [2/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
const Node & KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node ( const NodeIndex & index) const
inline

Definition at line 776 of file KisBezierMesh.h.

776 {
777 return node(index.x(), index.y());
778 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node().

◆ node() [3/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
Node & KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node ( int col,
int row )
inline

Definition at line 762 of file KisBezierMesh.h.

762 {
763 KIS_ASSERT(col >= 0 && col < m_size.width() && row >= 0 && row < m_size.height());
764 return m_nodes[row * m_size.width() + col];
765 }
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References KIS_ASSERT, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size.

◆ node() [4/4]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
const Node & KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node ( int col,
int row ) const
inline

Definition at line 767 of file KisBezierMesh.h.

767 {
768 KIS_ASSERT(col >= 0 && col < m_size.width() && row >= 0 && row < m_size.height());
769 return m_nodes[row * m_size.width() + col];
770 }

References KIS_ASSERT, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size.

◆ operator==()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
bool KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::operator== ( const Mesh< NodeArg, PatchArg > & rhs) const
inline

◆ originalRect()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
QRectF KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::originalRect ( ) const
inline

Definition at line 1020 of file KisBezierMesh.h.

1020 {
1021 return m_originalRect;
1022 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_originalRect.

◆ removeColumn()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeColumn ( int column)
inline

Definition at line 873 of file KisBezierMesh.h.

873 {
874 const bool hasNeighbours = column > 0 || column < m_size.width() - 1;
875
876 if (hasNeighbours) {
877 for (int row = 0; row < m_size.height(); row++) {
878 unlinkNodeHorizontally(node(column - 1, row), node(column, row), node(column + 1, row));
879 }
880 }
881
882 auto it = m_nodes.begin() + column;
883 for (int row = 0; row < m_size.height(); row++) {
884 it = m_nodes.erase(it);
885 it += m_size.width() - 1;
886 }
887
888 m_size.rwidth()--;
889 m_columns.erase(m_columns.begin() + column);
890 }
void unlinkNodeHorizontally(Mesh::Node &left, const Mesh::Node &node, Mesh::Node &right)

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::unlinkNodeHorizontally().

◆ removeColumnOrRow()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeColumnOrRow ( NodeIndex index,
bool row )
inline

Definition at line 908 of file KisBezierMesh.h.

908 {
909 if (row) {
910 removeRow(index.y());
911 } else {
912 removeColumn(index.x());
913 }
914 }
void removeColumn(int column)

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeColumn(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeRow().

◆ removeRow()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeRow ( int row)
inline

Definition at line 892 of file KisBezierMesh.h.

892 {
893 const bool hasNeighbours = row > 0 || row < m_size.height() - 1;
894
895 if (hasNeighbours) {
896 for (int column = 0; column < m_size.width(); column++) {
897 unlinkNodeVertically(node(column, row - 1), node(column, row), node(column, row + 1));
898 }
899 }
900
901 auto it = m_nodes.begin() + row * m_size.width();
902 m_nodes.erase(it, it + m_size.width());
903
904 m_size.rheight()--;
905 m_rows.erase(m_rows.begin() + row);
906 }
void unlinkNodeVertically(Mesh::Node &top, const Mesh::Node &node, Mesh::Node &bottom)

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::unlinkNodeVertically().

◆ reshapeMeshHorizontally()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::reshapeMeshHorizontally ( int numColumns)
inline

Definition at line 1089 of file KisBezierMesh.h.

1089 {
1090 KIS_SAFE_ASSERT_RECOVER_RETURN(numColumns >= 2);
1091
1092 std::vector<int> insertedIndexes;
1093
1094 for (int i = 1; i < numColumns - 1; i++) {
1095 const qreal pos = qreal(i) / (numColumns - 1);
1096 int inserted = subdivideColumn(pos);
1097 KIS_SAFE_ASSERT_RECOVER(inserted >= 0) { continue; }
1098
1099 insertedIndexes.push_back(inserted);
1100 }
1101
1102 for (int i = m_columns.size() - 2; i >= 1; i--) {
1103 if (std::find(insertedIndexes.begin(), insertedIndexes.end(), i) == insertedIndexes.end()) {
1104 removeColumn(i);
1105 }
1106 }
1107 }
int subdivideColumn(qreal proportionalT)
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_RETURN, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeColumn(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideColumn().

◆ reshapeMeshVertically()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::reshapeMeshVertically ( int numRows)
inline

Definition at line 1109 of file KisBezierMesh.h.

1109 {
1110 KIS_SAFE_ASSERT_RECOVER_RETURN(numRows >= 2);
1111
1112 std::vector<int> insertedIndexes;
1113
1114 for (int i = 1; i < numRows - 1; i++) {
1115 const qreal pos = qreal(i) / (numRows - 1);
1116 int inserted = subdivideRow(pos);
1117 KIS_SAFE_ASSERT_RECOVER(inserted >= 0) { continue; }
1118
1119 insertedIndexes.push_back(inserted);
1120 }
1121
1122 for (int i = m_rows.size() - 2; i >= 1; i--) {
1123 if (std::find(insertedIndexes.begin(), insertedIndexes.end(), i) == insertedIndexes.end()) {
1124 removeRow(i);
1125 }
1126 }
1127 }
int subdivideRow(qreal proportionalT)

References KIS_SAFE_ASSERT_RECOVER, KIS_SAFE_ASSERT_RECOVER_RETURN, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::removeRow(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideRow().

◆ size()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
QSize KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::size ( ) const
inline

Definition at line 1016 of file KisBezierMesh.h.

1016 {
1017 return m_size;
1018 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size.

◆ splitCurveHorizontally()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::splitCurveHorizontally ( Node & left,
Node & right,
qreal t,
Node & newNode )
inlineprivate

Definition at line 1130 of file KisBezierMesh.h.

1130 {
1132 using KisAlgebra2D::lerp;
1133
1134 QPointF p1, p2, p3, q1, q2;
1135
1136 deCasteljau(left.node, left.rightControl, right.leftControl, right.node, t,
1137 &p1, &p2, &p3, &q1, &q2);
1138
1139 left.rightControl = p1;
1140 newNode.leftControl = p2;
1141 newNode.node = p3;
1142 newNode.rightControl = q1;
1143 right.leftControl = q2;
1144
1145 newNode.topControl = newNode.node + lerp(left.topControl - left.node, right.topControl - right.node, t);
1146 newNode.bottomControl = newNode.node + lerp(left.bottomControl - left.node, right.bottomControl - right.node, t);
1147
1148 lerpNodeData(left, right, t, newNode);
1149 }
QPointF q1
QPointF p2
QPointF q2
QPointF p3
QPointF p1
QPointF lerp(const QPointF &p1, const QPointF &p2, qreal t)
void deCasteljau(const std::array< QPointF, 4 > &points, qreal t, QPointF *p1, QPointF *p2, QPointF *p3, QPointF *p4, QPointF *p5)
Point lerp(const Point &pt1, const Point &pt2, qreal t)
void lerpNodeData(const BaseMeshNode &left, const BaseMeshNode &right, qreal t, BaseMeshNode &dst)
void deCasteljau(const QPointF &q0, const QPointF &q1, const QPointF &q2, const QPointF &q3, qreal t, QPointF *p0, QPointF *p1, QPointF *p2, QPointF *p3, QPointF *p4)

References KisBezierUtils::deCasteljau(), deCasteljau(), KisAlgebra2D::lerp(), lerp(), KisBezierMeshDetails::lerpNodeData(), Node::node(), p1, p2, p3, q1, and q2.

◆ splitCurveVertically()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::splitCurveVertically ( Node & top,
Node & bottom,
qreal t,
Node & newNode )
inlineprivate

Definition at line 1151 of file KisBezierMesh.h.

1151 {
1153 using KisAlgebra2D::lerp;
1154
1155 QPointF p1, p2, p3, q1, q2;
1156
1157 deCasteljau(top.node, top.bottomControl, bottom.topControl, bottom.node, t,
1158 &p1, &p2, &p3, &q1, &q2);
1159
1160 top.bottomControl = p1;
1161 newNode.topControl = p2;
1162 newNode.node = p3;
1163 newNode.bottomControl = q1;
1164 bottom.topControl = q2;
1165
1166 newNode.leftControl = newNode.node + lerp(top.leftControl - top.node, bottom.leftControl - bottom.node, t);
1167 newNode.rightControl = newNode.node + lerp(top.rightControl - top.node, bottom.rightControl - bottom.node, t);
1168
1169 lerpNodeData(top, bottom, t, newNode);
1170 }

References KisBezierUtils::deCasteljau(), deCasteljau(), KisAlgebra2D::lerp(), lerp(), KisBezierMeshDetails::lerpNodeData(), Node::node(), p1, p2, p3, q1, and q2.

◆ subdivideColumn() [1/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
int KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideColumn ( int leftColumn,
qreal relProportionalT )
inline

Definition at line 843 of file KisBezierMesh.h.

843 {
844 const auto it = m_columns.begin() + leftColumn;
845 const int rightColumn = leftColumn + 1;
846 const qreal absProportionalT = KisAlgebra2D::lerp(*it, *next(it), relProportionalT);
847
848 std::vector<Node> newColumn;
849 newColumn.resize(m_size.height());
850 for (int row = 0; row < m_size.height(); row++) {
851 const qreal t =
853 node(leftColumn, row).rightControl,
854 node(rightColumn, row).leftControl,
855 node(rightColumn, row).node,
856 relProportionalT,
857 0.01);
858
859 splitCurveHorizontally(node(leftColumn, row), node(rightColumn, row), t, newColumn[row]);
860 }
861
862 auto dstIt = m_nodes.begin() + rightColumn;
863 for (auto columnIt = newColumn.begin(); columnIt != newColumn.end(); ++columnIt) {
864 dstIt = m_nodes.insert(dstIt, *columnIt);
865 dstIt += m_size.width() + 1;
866 }
867
868 m_size.rwidth()++;
869 auto insertedIt = m_columns.insert(next(it), absProportionalT);
870 return distance(m_columns.begin(), insertedIt);
871 }
qreal distance(const QPointF &p1, const QPointF &p2)
void splitCurveHorizontally(Node &left, Node &right, qreal t, Node &newNode)
QAction * next(const QObject *recvr, const char *slot, QObject *parent)
qreal curveParamByProportion(const QPointF p0, const QPointF p1, const QPointF p2, const QPointF p3, qreal proportion, const qreal error)

References KisBezierUtils::curveParamByProportion(), distance(), KisAlgebra2D::lerp(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::splitCurveHorizontally().

◆ subdivideColumn() [2/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
int KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideColumn ( qreal proportionalT)
inline

Definition at line 825 of file KisBezierMesh.h.

825 {
826 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(proportionalT >= 0.0 && proportionalT <= 1.0, -1);
827
828 {
829 auto existing = std::find(m_columns.begin(), m_columns.end(), proportionalT);
830 if (existing != m_columns.end()) {
831 return distance(m_columns.begin(), existing);
832 }
833 }
834
835 const auto it = prev(upper_bound(m_columns.begin(), m_columns.end(), proportionalT));
836 const int leftColumn = distance(m_columns.begin(), it);
837
838 const qreal relT = (proportionalT - *it) / (*next(it) - *it);
839
840 return subdivideColumn(leftColumn, relT);
841 }
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References distance(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideColumn().

◆ subdivideRow() [1/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
int KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideRow ( int topRow,
qreal relProportionalT )
inline

Definition at line 798 of file KisBezierMesh.h.

798 {
799 const auto it = m_rows.begin() + topRow;
800 const int bottomRow = topRow + 1;
801 const qreal absProportionalT = KisAlgebra2D::lerp(*it, *next(it), relProportionalT);
802
803 std::vector<Node> newRow;
804 newRow.resize(m_size.width());
805 for (int col = 0; col < m_size.width(); col++) {
806 const qreal t =
808 node(col, topRow).bottomControl,
809 node(col, bottomRow).topControl,
810 node(col, bottomRow).node,
811 relProportionalT,
812 0.01);
813
814 splitCurveVertically(node(col, topRow), node(col, bottomRow), t, newRow[col]);
815 }
816
817 m_nodes.insert(m_nodes.begin() + bottomRow * m_size.width(),
818 newRow.begin(), newRow.end());
819
820 m_size.rheight()++;
821 auto insertedIt = m_rows.insert(next(it), absProportionalT);
822 return distance(m_rows.begin(), insertedIt);
823 }
void splitCurveVertically(Node &top, Node &bottom, qreal t, Node &newNode)

References KisBezierUtils::curveParamByProportion(), distance(), KisAlgebra2D::lerp(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::splitCurveVertically().

◆ subdivideRow() [2/2]

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
int KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideRow ( qreal proportionalT)
inline

Definition at line 781 of file KisBezierMesh.h.

781 {
782 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(proportionalT >= 0.0 && proportionalT <= 1.0, -1);
783
784 {
785 auto existing = std::find(m_rows.begin(), m_rows.end(), proportionalT);
786 if (existing != m_rows.end()) {
787 return distance(m_rows.begin(), existing);
788 }
789 }
790
791 const auto it = prev(upper_bound(m_rows.begin(), m_rows.end(), proportionalT));
792 const int topRow = distance(m_rows.begin(), it);
793 const qreal relT = (proportionalT - *it) / (*next(it) - *it);
794
795 return subdivideRow(topRow, relT);
796 }

References distance(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows, and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideRow().

◆ subdivideSegment()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideSegment ( SegmentIndex index,
qreal proportionalT )
inline

Definition at line 916 of file KisBezierMesh.h.

916 {
917 auto it = find(index);
919
920 if (it.isHorizontal()) {
921 subdivideColumn(it.firstNodeIndex().x(), proportionalT);
922 } else {
923 subdivideRow(it.firstNodeIndex().y(), proportionalT);
924 }
925 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::endSegments(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::find(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideColumn(), and KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::subdivideRow().

◆ transform()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::transform ( const QTransform & t)
inline

Definition at line 1043 of file KisBezierMesh.h.

1043 {
1044 for (auto it = m_nodes.begin(); it != m_nodes.end(); ++it) {
1045 it->transform(t);
1046 }
1047 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes.

◆ transformSrcAndDst()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::transformSrcAndDst ( const QTransform & t)
inline

◆ translate()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::translate ( const QPointF & offset)
inline

Definition at line 1037 of file KisBezierMesh.h.

1037 {
1038 for (auto it = m_nodes.begin(); it != m_nodes.end(); ++it) {
1039 it->translate(offset);
1040 }
1041 }

References KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes.

◆ unlinkNodeHorizontally()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::unlinkNodeHorizontally ( Mesh< NodeArg, PatchArg >::Node & left,
const Mesh< NodeArg, PatchArg >::Node & node,
Mesh< NodeArg, PatchArg >::Node & right )
inlineprivate

Definition at line 1172 of file KisBezierMesh.h.

1173 {
1174 std::tie(left.rightControl, right.leftControl) =
1175 KisBezierUtils::removeBezierNode(left.node, left.rightControl,
1176 node.leftControl, node.node, node.rightControl,
1177 right.leftControl, right.node);
1178 }
std::pair< QPointF, QPointF > removeBezierNode(const QPointF &p0, const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &q1, const QPointF &q2, const QPointF &q3)
Adjusts position for the bezier control points after removing a node.

References Node::node(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierUtils::removeBezierNode().

◆ unlinkNodeVertically()

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
void KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::unlinkNodeVertically ( Mesh< NodeArg, PatchArg >::Node & top,
const Mesh< NodeArg, PatchArg >::Node & node,
Mesh< NodeArg, PatchArg >::Node & bottom )
inlineprivate

Definition at line 1180 of file KisBezierMesh.h.

1181 {
1182 std::tie(top.bottomControl, bottom.topControl) =
1183 KisBezierUtils::removeBezierNode(top.node, top.bottomControl,
1184 node.topControl, node.node, node.bottomControl,
1185 bottom.topControl, bottom.node);
1186 }

References Node::node(), KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::node(), and KisBezierUtils::removeBezierNode().

Member Data Documentation

◆ m_columns

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
std::vector<qreal> KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_columns
protected

Definition at line 1286 of file KisBezierMesh.h.

◆ m_nodes

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
std::vector<Node> KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_nodes
protected

Definition at line 1284 of file KisBezierMesh.h.

◆ m_originalRect

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
QRectF KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_originalRect
protected

Definition at line 1289 of file KisBezierMesh.h.

◆ m_rows

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
std::vector<qreal> KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_rows
protected

Definition at line 1285 of file KisBezierMesh.h.

◆ m_size

template<typename NodeArg = BaseMeshNode, typename PatchArg = KisBezierPatch>
QSize KisBezierMeshDetails::Mesh< NodeArg, PatchArg >::m_size
protected

Definition at line 1288 of file KisBezierMesh.h.


The documentation for this class was generated from the following file: