当前位置: 首页>>代码示例>>C++>>正文


C++ smooth函数代码示例

本文整理汇总了C++中smooth函数的典型用法代码示例。如果您正苦于以下问题:C++ smooth函数的具体用法?C++ smooth怎么用?C++ smooth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了smooth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ny

 void GenProcessor::procSmooth(quint8 *dst, const quint8 **src, quint8 index, quint8 octave) {
     quint8 t = 1 << octave;
     const quint8 y[3] = {ny(index - t), ny(index), ny(index + t)};
     quint32 count = m_size >> octave;
     quint32 x[3] = {m_size - t, 0, t};
     dst[0] = smooth(src, x, y);
     x[0] = x[1]; x[1] = x[2]; x[2] += t;
     for (quint32 i = 0; i < count; i++) {
         m_mutex.lock();
         dst[x[1]] = smooth(src, x, y);
         for (quint8 k = 0; k < t; k++) {
             if (octave != 0 && k != 0) {
                 dst[x[0] + k] = interpolate(dst[x[0]], dst[x[1]], m_steps[k << (5 - octave)]);
             }
             if (m_releasing != -1) {
                 m_semaphores[m_releasing].release();
             }
             m_iter++;
         }
         x[0] = x[1]; x[1] = x[2];
         if (i != count - 3) {
             x[2] += t;
         } else {
             x[2] = 0;
         }
         m_mutex.unlock();
     }
 }
开发者ID:DKeaton,项目名称:NoiseHeart,代码行数:28,代码来源:GenProcessor.cpp

示例2: dsmooth

RankTwoTensor
TensorMechanicsPlasticTensile::dyieldFunction_dstress(const RankTwoTensor & stress,
                                                      Real /*intnl*/) const
{
  Real mean_stress = stress.trace() / 3.0;
  RankTwoTensor dmean_stress = stress.dtrace() / 3.0;
  Real sin3Lode = stress.sin3Lode(_lode_cutoff, 0);
  if (sin3Lode <= _sin3tt)
  {
    // the non-edge-smoothed version
    std::vector<Real> eigvals;
    std::vector<RankTwoTensor> deigvals;
    stress.dsymmetricEigenvalues(eigvals, deigvals);
    Real denom = std::sqrt(smooth(stress) + Utility::pow<2>(eigvals[2] - mean_stress));
    return dmean_stress + (0.5 * dsmooth(stress) * dmean_stress +
                           (eigvals[2] - mean_stress) * (deigvals[2] - dmean_stress)) /
                              denom;
  }
  else
  {
    // the edge-smoothed version
    Real kk = _aaa + _bbb * sin3Lode + _ccc * Utility::pow<2>(sin3Lode);
    RankTwoTensor dkk = (_bbb + 2.0 * _ccc * sin3Lode) * stress.dsin3Lode(_lode_cutoff);
    Real sibar2 = stress.secondInvariant();
    RankTwoTensor dsibar2 = stress.dsecondInvariant();
    Real denom = std::sqrt(smooth(stress) + sibar2 * Utility::pow<2>(kk));
    return dmean_stress + (0.5 * dsmooth(stress) * dmean_stress +
                           0.5 * dsibar2 * Utility::pow<2>(kk) + sibar2 * kk * dkk) /
                              denom;
  }
}
开发者ID:aashiquear,项目名称:moose,代码行数:31,代码来源:TensorMechanicsPlasticTensile.C

示例3: smooth

void ShaderEffectSource::bind()
{
    GLint filtering = smooth() ? GL_LINEAR : GL_NEAREST;
    GLuint hwrap = (m_wrapMode == Repeat || m_wrapMode == RepeatHorizontally) ? GL_REPEAT : GL_CLAMP_TO_EDGE;
    GLuint vwrap = (m_wrapMode == Repeat || m_wrapMode == RepeatVertically) ? GL_REPEAT : GL_CLAMP_TO_EDGE;

    QOpenGLContext *context = QOpenGLContext::currentContext();
    QOpenGLFunctions *f = context->functions();
    if (!context->isOpenGLES())
        f->glEnable(GL_TEXTURE_2D);

    if (m_fbo && m_fbo->isValid()) {
        f->glBindTexture(GL_TEXTURE_2D, m_fbo->texture());
    } else {
        m_dirtyTexture = true;
        emit repaintRequired();
        markSourceItemDirty();
        f->glBindTexture(GL_TEXTURE_2D, 0);
    }

    f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
    f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth() ? GL_LINEAR : GL_NEAREST);
    f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, hwrap);
    f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vwrap);
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:25,代码来源:shadereffectsource.cpp

示例4: noise2d_get

static float noise2d_get(Noise2DContext* const ctx, const float x, const float y)
{
  Vec2 p = { x, y };
  
  // Cheap trick since inputs will always be [0, MAX_INT]
  const int x0 = (int)x;
  const int y0 = (int)y;
  const int x1 = x0 + 1;
  const int y1 = y0 + 1;
  const float x0f = (float)x0;
  const float y0f = (float)y0;

  const Vec2 grad0 = get_gradient(ctx, x0, y0);
  const Vec2 grad1 = get_gradient(ctx, x1, y0);
  const Vec2 grad2 = get_gradient(ctx, x0, y1);
  const Vec2 grad3 = get_gradient(ctx, x1, y1);

  const Vec2 origin0 = { x0f, y0f };
  const Vec2 origin1 = { x0f + 1.0f, y0f };
  const Vec2 origin2 = { x0f, y0f + 1.0f };
  const Vec2 origin3 = { x0f + 1.0f, y0f + 1.0f };
  
  float v0 = gradient(origin0, grad0, p);
  float v1 = gradient(origin1, grad1, p);
  float v2 = gradient(origin2, grad2, p);
  float v3 = gradient(origin3, grad3, p);

  float fx = smooth(x - origin0.x);
  float vx0 = lerp(v0, v1, fx);
  float vx1 = lerp(v2, v3, fx);
  float fy = smooth(y - origin0.y);
  return lerp (vx0, vx1, fy);
}
开发者ID:vonmoltke,项目名称:pnoise,代码行数:33,代码来源:test.c

示例5: __attribute__

// This ISR will execute whenever Timer1 has a compare match.
// it kicks off the periodic execution of user code and performs I/O
// Min period: 10msec due to X,Y switch time for touchscreen
void __attribute__((interrupt, auto_psv)) _T1Interrupt(void) {
  IFS0bits.T1IF = 0; // clear interrupt flag

  if(start == 1)
    deadline_miss++;

  if (select == X_DIM) {
    // DONE: read 5 samples from X-dimension and set Xpos as the median
    int i = 0;
    for (i = 0; i<N; i ++){
        xVal[i] = smooth(touch_adc(1), TOUCH_MAX_X, TOUCH_MIN_X,xPrevVal);
//        xVal[i] = touch_adc(1);//cap(touch_adc(1), TOUCH_MAX_X, TOUCH_MIN_X);
    }
    Xpos = median(xVal,N);
    xPrevVal = Xpos;
    touch_select_dim(Y_DIM);
    select = Y_DIM;
  }
  else {
    // DONE: read 5 samples from Y-dimension and set Ypos as the median
    int i = 0;
    for (i = 0; i<N; i ++){
        yVal[i] = smooth(touch_adc(2), TOUCH_MAX_Y, TOUCH_MIN_Y,yPrevVal);
//         yVal[i] = touch_adc(2);//cap(touch_adc(2), TOUCH_MAX_Y, TOUCH_MIN_Y);
    }

    Ypos = median(yVal,N);
    yPrevVal = Ypos;
    touch_select_dim(X_DIM);
    select = X_DIM;
  }
  start = 1;
}
开发者ID:ericmeyers12,项目名称:Embedded_Systems_dsPIC_MCU_Work,代码行数:36,代码来源:main.c

示例6: loop

void loop()
{
  
  while (digitalRead(DRDY) == LOW);

  temp_in = read_register16(TEMP);
  //temp_in = temp_in * 0.05;
  //temp_in = ((1.8) *temp_in) + 32;

  pressure_msb = read_register(PRESSURE);
  pressure_msb &= B00000111;
  pressure_lsb = read_register16(PRESSURE_LSB);
  pressure = UBLB19(pressure_msb, pressure_lsb);
  //pressure /= 4;
  //pressure = pressure*4;
  if (i==0) {
    smoothedVal = pressure;
    i = 1;
  }
  
  smoothedVal =  smooth(pressure, filterVal, smoothedVal);   // second parameter determines smoothness  - 0 is off,  .9999 is max smooth 
  //Serial.println(16250-smoothedVal);
  //Serial.print(14280-smoothedVal); Serial.print("     ");
  Serial.print(smoothedVal); Serial.print("     ");
  
  tempPressure = pressure * 0.25;
  //altitude = map(tempPressure, 101352.784, 98319.0955, 0, 820);
  tempAltitude = map(tempPressure, 101840, 98806, 0, 820);
  altitude = smooth(tempAltitude, filterVal, smoothedAlt);
  Serial.print(tempPressure); Serial.print("     "); Serial.println(altitude);
}
开发者ID:smooker,项目名称:ebrequad,代码行数:31,代码来源:SCP1000_SMOOTH.c

示例7: QPoint

void
CurveGroup::smooth(int key, int v0, int v1, int rad)
{
  QPoint cen = QPoint(v0, v1);

  if (m_cg.contains(key))
    {
      int ic = getActiveCurve(key, v0, v1);
      if (ic >= 0)
	{
	  QList<Curve*> curves = m_cg.values(key);
	  // replace pts with the smooth version
	  curves[ic]->pts = smooth(curves[ic]->pts,
				   cen,
				   rad,
				   curves[ic]->closed);

	  m_pointsDirtyBit = true;
	}
    }
  int mc = getActiveMorphedCurve(key, v0, v1);
  if (mc >= 0)
    {
      Curve c = m_mcg[mc].value(key);
      QVector<QPoint> w;
      w = smooth(c.pts,
		 cen,
		 rad,
		 c.closed);
      c.pts = w; // replace pts with the smooth version
      m_mcg[mc].insert(key, c);
    }
}
开发者ID:imclab,项目名称:drishti,代码行数:33,代码来源:curvegroup.cpp

示例8: smooth

void smooth(node *p)
{ /* go through tree getting new branch lengths and views */
  if (p->tip)
    return;
  update(p);
  smooth(p->next->back);
  smooth(p->next->next->back);
}  /* smooth */
开发者ID:Chrisss50,项目名称:ViralToolBox,代码行数:8,代码来源:contml.c

示例9: smooth

void CGenerator::smoothing(int from , int to)
{
	for(int i = from ; i < to ; i++)
	{
		smooth(i,1);
		smooth(i,1);
		smooth(i,1);
	}
}
开发者ID:Dreakii,项目名称:OpenWorld,代码行数:9,代码来源:CGenerator.cpp

示例10: insert_

void insert_(node *p, node *q)
{ /* put p and q together and iterate info. on resulting tree */
  long i;

  hookup(p->next->next, q->back);
  hookup(p->next, q);
  for (i = 1; i <= smoothings; i++) {
    smooth(p);
    smooth(p->back);
  }
}  /* insert_ */
开发者ID:Chrisss50,项目名称:ViralToolBox,代码行数:11,代码来源:contml.c

示例11: CkAbort

void CkQuadView::render(double alpha,CkView *v_old) {
#ifndef CMK_LIVEVIZ3D_CLIENT
	CkAbort("CkQuadView::render should never be called on server!\n");
#else
	glEnable(GL_TEXTURE_2D);
	CkQuadView *old=(CkQuadView *)v_old; // FIXME: what if he's not a quadview?
	
	if (old==NULL || old->nCorners!=nCorners || alpha>0.99) 
	{ /* just draw us */
		glColor4f(1.0,1.0,1.0,1.0);
		render();
	} 
	else 
	{ /* have old, and need to blend with him. */
#if 0 /* use multitexture: needs to have same corners (which sucks) */
		c_tex->bind(); // we're in texture unit 0
		glActiveTextureARB(GL_TEXTURE1_ARB);
		old->c_tex->bind(); // he's in texture unit 1
		glEnable(GL_TEXTURE_2D);
		oglTextureCombineLinear(1.0-alpha);
		glBegin (nCorners==4?GL_QUADS:GL_TRIANGLE_STRIP);
		for (int i=0;i<nCorners;i++) {
			glMultiTexCoord2dvARB(GL_TEXTURE0_ARB,texCoord[i]); 
			glMultiTexCoord2dvARB(GL_TEXTURE1_ARB,old->texCoord[i]);
			glVertex3dv(alpha*corners[i]+(1-alpha)*old->corners[i]); 
		}
		glEnd();
		glDisable(GL_TEXTURE_2D);
		glActiveTextureARB(GL_TEXTURE0_ARB);
#else /* draw two copies: first him, then me. */
		double separation=1.3;
		float of=smooth(separation*(1-alpha));
		glColor4f(of,of,of,of);
		old->render();
		
		float nf=smooth(separation*alpha);
		glColor4f(nf,nf,nf,nf);
		render();
		
		glColor4f(1.0,1.0,1.0,1.0);
#endif
	}
	
	
	if (oglToggles['f']) 
	{ // Draw a little frame around this texture
		glDisable(GL_TEXTURE_2D);
		for (int i=0;i<nCorners;i++)
			oglLine(corners[i],corners[(i+1)%nCorners]);
		glEnable(GL_TEXTURE_2D);
	}
#endif
}
开发者ID:davidheryanto,项目名称:sc14,代码行数:53,代码来源:ckviewable.cpp

示例12: processdata

int DATAPROCESS::ExtracSample(double *Lrawd, double *Rrawd, double *Lfiltd, double *Rfiltd, Throld throld, 
	int len, BpNetdata *pb, Processdata *prod , int winlen)
{
	//first process data.
	double *datasetL = new double[len];
	double *datasetR = new double[len];
	double *newdataL = new double[len];
	double *newdataR = new double[len];
	//BpNetdata data;
	Processdata psd;
	int Sampleblock = 0;
	for (int i = 0; i < len; i++)
	{
		if (i + winlen + 1 >= len)
		{
			psd = processdata(Lrawd + i, Rrawd + i, Lfiltd + i, Rfiltd + i, len - i - 1, throld);
		}
		else
			psd = processdata(Lrawd + i, Rrawd + i, Lfiltd + i, Rfiltd + i, winlen + 1, throld);
		datasetL[i] = psd.lmaxmin;
		datasetR[i] = psd.rmaxmin;
		newdataL[i] = psd.stdlval;
		newdataR[i] = psd.stdrval;
	}

	int smoothlen = 0;
	smooth(smoothlen, &newdataL, len);
	smooth(smoothlen, &newdataR, len);
	int distance = 0;
	for (int i = 0; i<len; i++)
	{
		if (newdataL[i]>0 || newdataR[i] > 0)
			distance++;
		else if (distance > 0)
		{
			pb[Sampleblock] = extractnetdata(datasetL + i - distance + 1, datasetR + i - distance + 1, distance, throld);
			pb[Sampleblock].sp = i - distance;
			pb[Sampleblock].ep = i;
			prod[Sampleblock].lmaxmin = prod[Sampleblock].rmaxmin = 0;
			prod[Sampleblock].stdlval = mean(newdataL + i - distance + 1, distance);
			prod[Sampleblock].stdrval = mean(datasetR + i - distance + 1, distance);
			Sampleblock++;
			distance = 0;
		}
	}
	delete newdataR;
	delete newdataL;
	delete datasetL;
	delete datasetR;
	return Sampleblock;
}
开发者ID:SproutOrc,项目名称:BiteProc,代码行数:51,代码来源:DataProcess.cpp

示例13: connect

QMenu* Scene_polylines_item::contextMenu() 
{
    const char* prop_name = "Menu modified by Scene_polylines_item.";

    QMenu* menu = Scene_item::contextMenu();

    // Use dynamic properties:
    // http://doc.qt.io/qt-5/qobject.html#property
    bool menuChanged = menu->property(prop_name).toBool();

    if(!menuChanged) {
        menu->addSeparator();
        // TODO: add actions to display corners
        QAction* action = menu->addAction(tr("Display corners with radius..."));
        connect(action, SIGNAL(triggered()),
                this, SLOT(change_corner_radii()));

        QAction* actionSmoothPolylines =
                menu->addAction(tr("Smooth polylines"));
        actionSmoothPolylines->setObjectName("actionSmoothPolylines");
        connect(actionSmoothPolylines, SIGNAL(triggered()),this, SLOT(smooth()));
        menu->setProperty(prop_name, true);
    }
    return menu;
}
开发者ID:NobodyZhou,项目名称:cgal,代码行数:25,代码来源:Scene_polylines_item.cpp

示例14: main

int main(int argc, char **argv){
  if(argc!=2){
    std::cerr << "Usage: " << argv[0] << " mesh_file" << std::endl;
  }

  Mesh *mesh = new Mesh(argv[1]);

  Quality q = mesh->get_mesh_quality();

  std::cout << "Initial quality:\n"
            << "Quality mean:  " << q.mean << std::endl
            << "Quality min:   " << q.min << std::endl;

  double time = get_wtime();
  smooth(mesh, 200);
  double time_smooth = get_wtime() - time;

  q = mesh->get_mesh_quality();

  std::cout<<"After smoothing:\n"
           << "Quality mean:  " << q.mean << std::endl
           << "Quality min:   " << q.min << std::endl;

  if((q.mean>0.90)&&(q.min>0.55))
    std::cout << "Test passed"<< std::endl;
  else
    std::cout << "Test failed"<< std::endl;

  std::cout<<"BENCHMARK: " << time_smooth << "s" << std::endl;

  delete mesh;

  return EXIT_SUCCESS;
}
开发者ID:Albex,项目名称:Advanced_Architecture,代码行数:34,代码来源:ACA2-2013.cpp

示例15: connect

void My3DViewer::setAztec(MyGLWidget* m){
	aztec=m;
	connect(splitQuad, SIGNAL(clicked()), aztec, SLOT(splitQuad()));
	connect(deleteVertex, SIGNAL(clicked()), aztec, SLOT(deleteVertex()));
	connect(insertEdge, SIGNAL(clicked()), aztec, SLOT(insertEdge()));
	connect(incrementSharpness, SIGNAL(clicked()), aztec, SLOT(incSharpness()));
	connect(decrementSharpness, SIGNAL(clicked()), aztec, SLOT(decSharpness()));
	connect(forcePlanarity, SIGNAL(clicked()), aztec, SLOT(toggleForcePlanarity()));
	connect(insertVertex, SIGNAL(clicked()), aztec, SLOT(insertVertex()));
	connect(smooth, SIGNAL(clicked()), aztec, SLOT(smooth()));
	connect(extrude, SIGNAL(clicked()), aztec, SLOT(extrude2()));

	connect(faceButton, SIGNAL(clicked()), aztec, SLOT(enterFaceMode()));
	connect(objectButton, SIGNAL(clicked()), aztec, SLOT(enterObjectMode()));
	connect(vertexButton, SIGNAL(clicked()), aztec, SLOT(enterVertexMode()));
	connect(edgeButton, SIGNAL(clicked()), aztec, SLOT(enterEdgeMode()));
	connect(cpButton, SIGNAL(clicked()), aztec, SLOT(enterCPMode()));

	connect(snapToFace, SIGNAL(clicked()), aztec, SLOT(snapToFace()));
	connect(snapToEdge, SIGNAL(clicked()), aztec, SLOT(snapToEdge()));
	connect(snapToVertex, SIGNAL(clicked()), aztec, SLOT(snapToVertex()));

	//Connect mouse move events
	connect(aztec, SIGNAL(sendMouseEvent(QMouseEvent*)), this, SLOT(moveEvent(QMouseEvent*)));

		//errors
	connect(aztec, SIGNAL(error(char*)), this, SLOT(throwError(char*)));
	
}
开发者ID:Jigarsenjallia,项目名称:Aztec,代码行数:29,代码来源:my3dviewer.cpp


注:本文中的smooth函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。