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(); } }
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; } }
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); }
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); }
// 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; }
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); }
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); } }
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 */
void CGenerator::smoothing(int from , int to) { for(int i = from ; i < to ; i++) { smooth(i,1); smooth(i,1); smooth(i,1); } }
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_ */
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 }
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; }
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; }
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; }
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*))); }
void ReduceSurfaceTriangulation::pass1() { cout << "\nFirst pass of surface reduction:\n(This is the expensive part...)" << endl; int iter = 0; bool done = false; m_UseNormalCorrectionForSmoothing = true; int num_initial_nodes = m_Grid->GetNumberOfPoints(); int num_del_max = 0; while (!done) { ++iter; cout << "\npass-1 iteration-" << iter << ":" << endl; computeMeshDensity(); int num_deleted = deleteNodes(); num_del_max = max(num_del_max, num_deleted); cout << "deleted nodes : " << num_deleted << endl; for (int i = 0; i < m_NumSmoothSteps; ++i) { cout << " smoothing : " << i+1 << "/" << m_NumSmoothSteps << endl; smooth(1); swap(); } done = num_deleted <= max(num_initial_nodes/100, num_del_max/100); cout << "total nodes : " << m_Grid->GetNumberOfPoints() << endl; cout << "total cells : " << m_Grid->GetNumberOfCells() << endl; //done = true; } }
void fileRead(FILE *fdr, FILE *ofdr) { char pattern[64][64]; char data[512]; int features[64]; int count=0, num; int x, y, i; fseek(fdr, 0, SEEK_END); num = ftell(fdr) / 512; fseek(fdr, 0, SEEK_SET); while (count<num) { if (fread(data, 512, 1, fdr) != 1) { printf("can't open a file\n"); exit(2); } printf("%d文字目\n", count); expand(data,pattern); noise(pattern, 15); smooth(pattern); normalize(pattern); outline(pattern); printpattern(pattern); extract(pattern, features); output(features, ofdr); count++; // while(getchar()!='\n'); } }
/** *\fn int getBackgroundTemplate(uint8 *input, uint8 *output, int r, int threshold, int cx, int cy) *\brief 生成背景模板 *\param[in] uint8 * input 输入原图像数据 *\param[in] uint8 * output 背景模板:255为背景,0为前景 *\param[in] int r 对幅值图像高度平滑滤波的滤波器半径 *\param[in] int threshold 分割的阈值 *\param[in] int cx 图像宽 *\param[in] int cy 图像高 *\return int 0成功,其它失败 */ int getBackgroundTemplate(uint8 *input, uint8 *output, int r, int threshold, int cx, int cy) { int x = 0; int y = 0; int num = 0; int lineBegin= 0; uint8 *src = NULL; // 对方向场幅值图像进行高度平滑滤波 smooth(input, output, cx, cy, r, 2); // 图像边缘均设置为背景 num = cx - 1; for (y = 0; y < cy; y++) { src = output + y*cx; *(src) = 255; *(src + num) = 255; } num = (cy-1)*cx; for (x = 0; x < cx; x++) { src = output + x; *(src) = 255; *(src + num) = 255; } num = 0; lineBegin = cx; for (y = 1; y < cy-1; y++) { for (x = 1; x < cx-1; x++) { src = output + lineBegin + x; // 根据幅值与阈值大小判断是否为背景区域 if (*src < threshold) { *src = 0; } else { *src = 255; num++; } } lineBegin += cx; } // 如果前景区域面积小于总面积的十分之一,则表示前景区域太小,返回错误 return ((num < (cx * cy / 10)) ? 1 : 0); }
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())); QMenu *container = new QMenu(tr("Line Width")); QWidgetAction *sliderAction = new QWidgetAction(0); connect(d->line_Slider, &QSlider::valueChanged, this, &Scene_polylines_item::itemChanged); sliderAction->setDefaultWidget(d->line_Slider); container->addAction(sliderAction); menu->addMenu(container); menu->setProperty(prop_name, true); } return menu; }
void setup() { size(200, 200); smooth(); noStroke(); max_distance = dist(0, 0, width, height); }
void InfluenceNetwork::calPoten(std::vector<double>& poten) const { poten.clear(); poten.resize(_net.size_n(), 0); int iterNum = 100; Edge e; double poten_sum = 1e300; double threshold = 1e-3; for(int i = 0; i < iterNum; ++i) { for(int j = 0; j < _net.size_n(); ++j) { double fluence = 0; for(int k = 0; k < _net.size_neighbor(j); ++k) { e = _net.edge(j, k); fluence += e.w1 * poten[e.v]; } poten[j] = ( (_lams[j] > 0 ? 1 : 0 )+ fluence) * smooth(_lams[j]); } double tpsum = 0; for(size_t j = 0; j < _net.size_n(); ++j) { tpsum += poten[j]; } if(fabs(tpsum - poten_sum) < threshold) break; std::cerr << "tpsum: " << tpsum << " ,poten_sum: " << poten_sum << std::endl; poten_sum = tpsum; } /// poten[*] is the calculated potentials. }
/** A callback function that will get called whenever the tracker * provides us with new data. This may be called repeatedly for each * record that we have missed if many records have been delivered * since the last call to the VRPN mainloop() function. */ static void VRPN_CALLBACK handle_tracker(void *name, vrpn_TRACKERCB t) { float fps = kuhl_getfps(&fps_state); if(fps_state.frame == 0) msg(INFO, "VRPN records per second: %.1f\n", fps); /* Some tracking systems return large values when a point gets * lost. If the tracked point seems to be lost, ignore this * update. */ float pos[3]; vec3f_set(pos, t.pos[0], t.pos[1], t.pos[2]); long microseconds = (t.msg_time.tv_sec* 1000000L) + t.msg_time.tv_usec; if(0) { printf("Current time %ld; VRPN record time: %ld\n", kuhl_microseconds(), microseconds); printf("Received position from vrpn: "); vec3f_print(pos); } if(vec3f_norm(pos) > 100) return; // Store the data in our map so that someone can use it later. std::string s = (char*)name; nameToCallbackData[s] = t; smooth(nameToCallbackData[s]); }
void Terrain::create(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::string& heightmapFilename, const std::string& blendmapFilename) { m_blendmap.texels.clear(); Utilities::loadPNG(blendmapFilename, m_blendmap); m_width = m_blendmap.width; m_depth = m_blendmap.height; UINT size = (m_width + 1) * (m_depth + 1); std::vector<unsigned char> in(size); std::ifstream file; file.open(heightmapFilename, std::ios_base::binary); if (file) { file.read((char*)&in[0], (std::streamsize)in.size()); file.close(); } m_heightmap.clear(); m_heightmap.resize(size); for (UINT i = 0; i < size; i++) m_heightmap[i] = (float)in[i]; smooth(); createBuffers(device, deviceContext); m_currentHeightmapFilepath = heightmapFilename; m_currentBlendmapFilepath = blendmapFilename; }
/* * Randomize the resonance function */ void Resonance::randomize(int type) { int r; int i; r = (int)(zyn_random() * 127.0); for (i = 0 ; i < N_RES_POINTS ; i++) { Prespoints[i] = r; if ((zyn_random() < 0.1) && (type == 0)) { r = (int)(zyn_random() * 127.0); } if ((zyn_random() < 0.3) && (type == 1)) { r = (int)(zyn_random() * 127.0); } if (type == 2) { r = (int)(zyn_random() * 127.0); } }; smooth(); };
double force_beagle_recalculate(world_fmt *world, long locus) { reset_beagle(world->beagle); set_all_dirty(world->root->next, crawlback (world->root->next), world, locus); smooth (world->root->next, crawlback (world->root->next), world, locus); return treelikelihood(world); }
int main(int argc, char *argv[]) { Image *img1; Image *img2; int ret; // Create and read img1 = image_Create(); ret = image_Read(img1, argv[1]); if(ret) printf("%d\n", ret); img2 = image_Create_Alloc(img1->width, img1->height, img1->depth, img1->channel); // Smooth smooth(img1, img2); // Write ret = image_Write(img2, argv[2]); if(ret) printf("%d\n", ret); // Destroy image_Destroy(&img1); image_Destroy(&img2); return 0; }
void Terrain::init(ID3D10Device* device, const InitInfo& initInfo) { md3dDevice = device; mTech = fx::TerrainFX->GetTechniqueByName("TerrainTech"); mfxWVPVar = fx::TerrainFX->GetVariableByName("gWVP")->AsMatrix(); mfxWorldVar = fx::TerrainFX->GetVariableByName("gWorld")->AsMatrix(); mfxDirToSunVar = fx::TerrainFX->GetVariableByName("gDirToSunW")->AsVector(); mfxLayer0Var = fx::TerrainFX->GetVariableByName("gLayer0")->AsShaderResource(); mfxLayer1Var = fx::TerrainFX->GetVariableByName("gLayer1")->AsShaderResource(); mfxLayer2Var = fx::TerrainFX->GetVariableByName("gLayer2")->AsShaderResource(); mfxLayer3Var = fx::TerrainFX->GetVariableByName("gLayer3")->AsShaderResource(); mfxLayer4Var = fx::TerrainFX->GetVariableByName("gLayer4")->AsShaderResource(); mfxBlendMapVar = fx::TerrainFX->GetVariableByName("gBlendMap")->AsShaderResource(); mInfo = initInfo; mNumVertices = mInfo.NumRows*mInfo.NumCols; mNumFaces = (mInfo.NumRows-1)*(mInfo.NumCols-1)*2; loadHeightmap(); smooth(); buildVB(); buildIB(); mLayer0 = GetTextureMgr().createTex(initInfo.LayerMapFilename0); mLayer1 = GetTextureMgr().createTex(initInfo.LayerMapFilename1); mLayer2 = GetTextureMgr().createTex(initInfo.LayerMapFilename2); mLayer3 = GetTextureMgr().createTex(initInfo.LayerMapFilename3); mLayer4 = GetTextureMgr().createTex(initInfo.LayerMapFilename4); mBlendMap = GetTextureMgr().createTex(initInfo.BlendMapFilename); }
void resetDrawSettings() { m_inSetup = false; fill(m_defaultFillColor.getHex()); stroke(m_defaultStrokeColor.getHex()); strokeWeight(m_defaultStrokeWeight); m_hasFill = m_defaultHasFill; m_hasStroke = m_defaultHasStroke; ofEnableBlendMode(OF_BLENDMODE_ALPHA); smooth(2); width = ofGetWidth(); height = ofGetHeight(); pmouseX = ofGetPreviousMouseX(); pmouseY = ofGetPreviousMouseY(); keyPressed = ofGetKeyPressed(); mousePressed = ofGetMousePressed(); mouseButton = NONE; if( ofGetMousePressed(0) ) mouseButton = LEFT; else if(ofGetMousePressed(1)) mouseButton = RIGHT; ofSetCircleResolution(100); ofSetCurveResolution(100); }
/** * TODO: Describe the purpose of having all this code in the constructor. * * @param const vector <const cRatioComponent *> & component_pointer_vector * * @param const char * filename for the ratio_[\d].txt files, which are * index by the number of the disambiguation round. * * @param const Record & rec */ cRatios::cRatios(const vector<const cRatioComponent *> & component_pointer_vector, const char * filename, const Record & rec) { std::cout << "Creating the final version ratios file ..." << std::endl; uint32_t ratio_size = 0; std::cout << "filename: " << filename << std::endl; vector< const cRatioComponent *>::const_iterator p = component_pointer_vector.begin(); for (p; p != component_pointer_vector.end(); ++p ) { std::cout << " Size of Ratio Component = " << (*p)->get_ratios_map().size() << std::endl; ratio_size += (*p)->get_component_positions_in_ratios().size(); } attrib_names.resize(ratio_size, "Invalid Attribute"); static const uint32_t impossible_value = 10000; vector<uint32_t> null_vect (ratio_size, impossible_value); final_ratios.insert(std::pair<vector<uint32_t>, double > (null_vect, 1) ); x_counts.insert(std::pair<vector<uint32_t>, uint32_t > (null_vect, 0)); m_counts.insert(std::pair<vector<uint32_t>, uint32_t > (null_vect, 0)); p = component_pointer_vector.begin(); for (p; p != component_pointer_vector.end(); ++p ) { More_Components(**p); } // LEAVE THIS IN, this is something which may be necessary. // It turns out that the following code often (usually? always?) // segfaults because the final_ratios map is zeroed out in the // More_Components function called above (which is a side effect). #if 1 if (final_ratios.size() > 0) { // now checking the final ratios //const vector < uint32_t > & firstline = final_ratios.begin()->first; map < const SimilarityProfile, double, SimilarityCompare>::const_iterator firstline = final_ratios.begin(); //vector< uint32_t >::const_iterator k = firstline.begin(); SimilarityProfile vec = (*firstline).first; SimilarityProfile::const_iterator k = vec.begin(); //for (k; k < firstline.end(); ++k) { //for (k; k != firstline.end(); ++k) { for (k; k != vec.end(); ++k) { if (*k == impossible_value) { throw cRatioComponent::cException_Ratios_Not_Ready( "Final Ratios is not ready yet. "); } } } #endif smooth(); write_ratios_file(filename); x_counts.clear(); m_counts.clear(); similarity_map.clear(); }
void Vanhanen::Move(int time_now ) { smooth( time_now - last_tick ); last_tick = time_now; //if ( (rand()%10) == 1 ) kakka[rand()%(WI*HE)]+=0.4f; }