|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TSTROKE_UTIL_H
|
|
Toshihiro Shimizu |
890ddd |
#define TSTROKE_UTIL_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TVRENDER_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TStroke;
|
|
Toshihiro Shimizu |
890ddd |
class TStrokeDeformation;
|
|
Toshihiro Shimizu |
890ddd |
class TVectorRenderData;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Utility stroke functions
|
|
Toshihiro Shimizu |
890ddd |
//*******************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief Inserts control points in a stroke according to the input deformer.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\details This function inserts redundant control points to use in the
|
|
Toshihiro Shimizu |
890ddd |
specified deformation.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\par Unverified documentation
|
|
Toshihiro Shimizu |
890ddd |
The "increaser" studies the gradient (getDelta) of the input deformer
|
|
Toshihiro Shimizu |
890ddd |
object, and insert control points if there is increment.\n
|
|
Toshihiro Shimizu |
890ddd |
In "extremes" there are the first point of not zero potential and
|
|
Toshihiro Shimizu |
890ddd |
the last.\n\n
|
|
Toshihiro Shimizu |
890ddd |
Special case (plane at same potential)
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI bool increaseControlPoints(
|
|
Toshihiro Shimizu |
890ddd |
TStroke &stroke, //!< Stroke to be deformed.
|
|
Toshihiro Shimizu |
890ddd |
const TStrokeDeformation &deformer, //!< Deformer to be applied.
|
|
Toshihiro Shimizu |
890ddd |
double pixelSize = 1.0 //!< Resolution modifier.
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void modifyControlPoints(TStroke &stroke,
|
|
Toshihiro Shimizu |
890ddd |
const TStrokeDeformation &deformer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void modifyControlPoints(TStroke &stroke,
|
|
Toshihiro Shimizu |
890ddd |
const TStrokeDeformation &deformer,
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<double> &controlPointLen);</double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void modifyThickness(TStroke &stroke,
|
|
Toshihiro Shimizu |
890ddd |
const TStrokeDeformation &deformer,
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<double> &controlPointLen,</double>
|
|
Toshihiro Shimizu |
890ddd |
bool exponentially = false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief Transforms a stroke's thickness by a given polynomial function.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void transform_thickness(
|
|
Toshihiro Shimizu |
890ddd |
TStroke &stroke, //!< Stroke whose thickness will be transformed.
|
|
Toshihiro Shimizu |
890ddd |
const double poly[], //!< Polynomial coefficients, by increasing degree.
|
|
Toshihiro Shimizu |
890ddd |
int deg //!< Polynomial degree.
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief This function translates an input polyline to the control points
|
|
Toshihiro Shimizu |
890ddd |
of a sequence of quadratics.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\details The conversion is actually a 2 step process. First, segment midpoints
|
|
Toshihiro Shimizu |
890ddd |
are added to the sequence to be used as quadratic endpoints. Each
|
|
Toshihiro Shimizu |
890ddd |
"midpoint-vertex-midpoint" triplet is converted independently to
|
|
Toshihiro Shimizu |
890ddd |
quadratics, thus ensuring that tangent vectors at midpoints are
|
|
Toshihiro Shimizu |
890ddd |
preserved.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The triplets conversion step allows the following control parameters:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\a adherenceTol is the maximum distance allowed for quadratics to approximate a
|
|
Toshihiro Shimizu |
890ddd |
polyline corner (\p 0 meaning full corner).
|
|
Toshihiro Shimizu |
890ddd |
Polyline corners whose edges inner product is strictly above \a angleTol are
|
|
Toshihiro Shimizu |
890ddd |
transformed into full corners. The range for \a angleTol should be <tt>[-1, 1]</tt>.
|
|
Toshihiro Shimizu |
890ddd |
A quadratic approximating a polyline vertex triplet yields a minimum curvature
|
|
Toshihiro Shimizu |
890ddd |
radius in proximity of the triplet's corner. If the ratios between such
|
|
Toshihiro Shimizu |
890ddd |
radius and the edges extending from the corner are both below \a relativeTol,
|
|
Toshihiro Shimizu |
890ddd |
the triplet is transformed into a full corner. The edges are calculated along
|
|
Toshihiro Shimizu |
890ddd |
fat lines extending from the corner with \a relativeDist half-thickness.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Once this first approximating sequence has been produced, an optimal quadratics
|
|
Toshihiro Shimizu |
890ddd |
merging step is employed to simplify the overall sequence.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The \a mergeTol parameter specifies the allowed merging error that can be employed
|
|
Toshihiro Shimizu |
890ddd |
in this step (\p 0 meaning no simplification).
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\note The output cps are thick points with 0 thickness. In other words, thickness
|
|
Toshihiro Shimizu |
890ddd |
is not considered, but supplied in output as TStrokes require them for construction.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\sa The tcg::polyline_ops::toQuadratics template function.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void polylineToQuadratics(
|
|
Toshihiro Shimizu |
890ddd |
const std::vector<tpointd> &polyline, //!< Polyline to be translated to quadratics.</tpointd>
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tthickpoint> &cps, //!< Control points of the output quadratics sequence.</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
double adherenceTol = 1.0, //!< Maximum distance from quadratic to polyline corner.
|
|
Toshihiro Shimizu |
890ddd |
double angleTol = 0.0, //!< Inner product threshold for polyline angles.
|
|
Toshihiro Shimizu |
890ddd |
double relativeTol = 0.25,
|
|
Toshihiro Shimizu |
890ddd |
double relativeDistTol = 0.25,
|
|
Toshihiro Shimizu |
890ddd |
double mergeTol = 1.0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief Draws a stroke on a raster, under the specified rendering parameters.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void renderStroke(
|
|
Toshihiro Shimizu |
890ddd |
const TVectorRenderData &rd, //!< Render parameters (clipping rect, affine transform, etc).
|
|
Toshihiro Shimizu |
890ddd |
const TRaster32P &output, //!< Destination raster.
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke //!< Stroke to render.
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace Toonz
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief Merge an array of stroke in a single stroke.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\remark If two consecutive strokes don't touch at the endpoints,
|
|
Toshihiro Shimizu |
890ddd |
an additional joining segment is added between them.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
DVAPI TStroke *merge(const std::vector<tstroke *=""> &strokes);</tstroke>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace Toonz
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // TSTROKE_UTIL_H
|