本文整理汇总了C++中Stroke::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Stroke::clear方法的具体用法?C++ Stroke::clear怎么用?C++ Stroke::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stroke
的用法示例。
在下文中一共展示了Stroke::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Button
void Button(int button, int state, int x, int y)
{
if (state != GLUT_UP)
return;
switch (button)
{
case GLUT_LEFT_BUTTON:
curve.add(x,windowHeight-y);
glutPostRedisplay();
break;
case GLUT_RIGHT_BUTTON:
curve.clear();
glutPostRedisplay();
break;
}
}
示例2: mouseclick
/// Mouse press function
void mouseclick(int button, int state, int x, int y) {
xini = x; yini = winh - y;
if (state == GLUT_DOWN) {
buttonpressed = button;
if (buttonpressed == GLUT_MIDDLE_BUTTON) {
arcball.click(xini, yini);
}
else if (buttonpressed == GLUT_RIGHT_BUTTON) {
screenToWorld(x, winh - y, xwini, ywini, zwini);
}
else if (buttonpressed == GLUT_LEFT_BUTTON) {
stroke.clear();
screenToWorld(x, winh - y, xwini, ywini, zwini);
grabStart = Point3(xwini, ywini, zwini);
grabLast = grabStart;
}
sceneIniT = sceneT;
}
else if (state == GLUT_UP) {
if (buttonpressed == GLUT_LEFT_BUTTON)
if (stroke.size() > 3) {
stroke.subsampleStroke();
Point2 bbMin = stroke.getBBmin();
Point2 bbMax = stroke.getBBmax();
screenToWorld(bbMin[0], bbMin[1], xwini, ywini, zwini);
Point3 bbmin(xwini, ywini, 0.0);
screenToWorld(bbMax[0], bbMax[1], xwini, ywini, zwini);
Point3 bbmax(xwini, ywini, 0.0);
//if (mycloth != 0) delete mycloth;
//mycloth = new Cloth("mesh1.off");
//mycloth = new Cloth;
//mycloth->intersect(stroke);
}
}
glutPostRedisplay();
}
示例3: buildLine
/**
* Create a line by scaling a known PH5Curve to match the requested linear
* offset.
*/
Status StrokeBuilder::buildLine(Stroke & stroke, Quad<StepCoord> relPos) {
PH5TYPE K[QUAD_ELEMENTS];
PH5TYPE Ksqrt[QUAD_ELEMENTS];
StepCoord pulses = 0;
QuadIndex iMax = 0;
// Determine scale K for each Quad dimension
for (QuadIndex i = 0; i < QUAD_ELEMENTS; i++) {
K[i] = relPos.value[i] / 6400.0;
TESTCOUT2("K[", i, "]:", K[i]);
Ksqrt[i] = sqrt(abs(K[i]));
if (pulses < abs(relPos.value[i])) {
pulses = abs(relPos.value[i]);
iMax = i;
}
}
// Generate scaled PH5Curve coefficients
TESTCOUT1("buildLine:", relPos.toString());
#define Z6400 56.568542495
PHVECTOR<Complex<PH5TYPE> > z[QUAD_ELEMENTS];
PHVECTOR<Complex<PH5TYPE> > q[QUAD_ELEMENTS];
for (QuadIndex i = 0; i < QUAD_ELEMENTS; i++) {
z[i].push_back(Complex<PH5TYPE>());
if (K[i] < 0) {
z[i].push_back(Complex<PH5TYPE>(0, Z6400 * Ksqrt[i]));
z[i].push_back(Complex<PH5TYPE>(0, Z6400 * Ksqrt[i]));
} else {
z[i].push_back(Complex<PH5TYPE>(Z6400 * Ksqrt[i]));
z[i].push_back(Complex<PH5TYPE>(Z6400 * Ksqrt[i]));
}
q[i].push_back(Complex<PH5TYPE>());
q[i].push_back(Complex<PH5TYPE>(3200 * K[i]));
q[i].push_back(Complex<PH5TYPE>(6400 * K[i]));
}
// Use the longest PH5Curve to determine the parametric value for all
PH5Curve<PH5TYPE> phMax(z[iMax], q[iMax]);
PHFeed<PH5TYPE> phfMax(phMax, vMax, vMaxSeconds);
PH5TYPE tS = phfMax.get_tS();
// Calculate the optimal number of segments using weird heuristics
#define MS_PER_SEGMENT 30
int16_t N = 1000 * tS / MS_PER_SEGMENT;
int16_t minSegs = minSegments;
if (minSegs == 0) {
minSegs = 5; // minimum number of acceleration segments
minSegs = (float)minSegs * (float)abs(pulses) / (vMax * vMaxSeconds);
TESTCOUT4("pulses:", pulses, " minSegs:", minSegs, " vMax:", vMax, " vMaxSeconds:", vMaxSeconds);
int16_t minSegsK = abs(pulses) / 200.0;
if (minSegs < minSegsK) {
TESTCOUT1("minSegsK:", minSegsK);
minSegs = minSegsK;
}
minSegs = max((int16_t)16, min((int16_t)(STROKE_SEGMENTS - 1), minSegs));
}
N = max(minSegs, min(maxSegments, (int16_t)N));
if (N >= STROKE_SEGMENTS) {
return STATUS_STROKE_MAXLEN;
}
// Build the stroke dimension by dimension
stroke.clear();
stroke.setTimePlanned(tS);
stroke.length = N;
#define SCALE 2
stroke.scale = SCALE;
PH5TYPE E[STROKE_SEGMENTS + 1];
E[0] = phfMax.Ekt(0, 0);
for (int16_t iSeg = 1; iSeg <= N; iSeg++) {
PH5TYPE fSeg = iSeg / (PH5TYPE)N;
E[iSeg] = phfMax.Ekt(E[iSeg - 1], fSeg);
}
for (QuadIndex i = 0; i < QUAD_ELEMENTS; i++) {
PH5Curve<PH5TYPE> ph(z[i], q[i]);
StepCoord s = 0;
StepCoord v = 0;
for (int16_t iSeg = 1; iSeg <= N; iSeg++) {
PH5TYPE pos = ph.r(E[iSeg]).Re();
if (iSeg == N) {
stroke.dEndPos.value[i] = pos < 0 ? pos - 0.5 : pos + 0.5;
TESTCOUT2("dEndPos.value[", (int) i, "] ", stroke.dEndPos.value[i]);
}
pos /= SCALE;
StepCoord sNew = pos < 0 ? pos - 0.5 : pos + 0.5;
StepCoord vNew = sNew - s;
stroke.vPeak = max(stroke.vPeak, (int32_t)abs(vNew*SCALE));
StepCoord dv = vNew - v;
//TESTCOUT4("iSeg:", iSeg, " sNew:", sNew, " vNew:", vNew, " dv:", dv);
if (dv < (StepCoord) - 127 || (StepCoord) 127 < dv) {
TESTCOUT3(" STATUS_STROKE_SEGPULSES pulses:", dv, " i:", (int)i, " N:", (int)N);
return STATUS_STROKE_SEGPULSES;
}
stroke.seg[iSeg - 1].value[i] = dv;
v = vNew;
s = sNew;
//.........这里部分代码省略.........