void WidgetStrainVideo::on_horizontalSlider_valueChanged(int value) { if (!clip) { qDebug() << "on_horizontalSlider_valueChanged: no clip"; return; } if (clip->size() == 0) { qDebug() << "on_horizontalSlider_valueChanged: empty clip"; return; } if (value >= clip->size()) { qDebug() << "on_horizontalSlider_valueChanged: requested value exceeds clip size"; return; } Mat8 &frame = clip->frames[value]; QPixmap image = UIUtils::Mat8ToQPixmap(frame); ui->widgetResult->setImage(image); currentIndex = value; ui->lblIndex->setText(QString::number(value)); if (shapes.contains(currentIndex)) { ui->widgetResult->setResultPoints(Points(shapes[currentIndex]), clip->getMetadata()->getCoordSystem()); } else { ui->widgetResult->setResultPoints(Points(), clip->getMetadata()->getCoordSystem()); } emit displayIndexChanged(value); }
void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if ( !CanFireForActivator( pActivator ) ) return; // Only players can use this if ( pActivator->IsPlayer() ) { if ( AwardToTeam() ) { pActivator->AddPointsToTeam( Points(), AllowNegativeScore() ); } else { pActivator->AddPoints( Points(), AllowNegativeScore() ); } } }
AnnotatedDatasetInfo getAnnotatedImageData(Mat Image, string datafile){ AnnotatedDatasetInfo info; int rows = 240; int cols = 320; float depth = 50.00; Mat_<signed short int> Labels(rows, cols, CV_16SC1); vector< vector<Point> > Points(1); Mat_<Vec3f> Depths(rows, cols, CV_32FC3); // datafile is binary image that represent object mask // 1 represent object, 0 means non object ifstream ImgData(datafile.c_str()); int row = 0; if (ImgData.is_open()){ while (ImgData.good()) { string line; getline(ImgData, line); if(line.length() == 0) continue; int col = 0; for(unsigned int i = 0 ; i < line.length() ; i++){ char ch = line[i]; // add data into "Labels" if(ch != ' '){ if(ch == '1') { Labels(row, col) = 0; // add Point (row, col) in points for class 2 Point p(col, row); Points[0].push_back(p); } else { Labels(row, col) = -3; // add Point (row, col) in points for class 1 //Point p(col, row); //Points[0].push_back(p); } // add depth into "Depths" // Depths is a R X C X 3 matrix where each pixel has (X,Y,Z) location in world coords Depths(row, col) = Vec3f(float(col), float(row), depth); col++; } } row++; } ImgData.close(); } else cout << "Unable to open file"; info.Labels = Labels; info.Points = Points; info.Depths = Depths; return info; }
void ReadData( const string& inputfile, const int diff, const int nvar, const int tgtIdx, const vector< int >& delay, const vector< int >& nlags, vector< vector< float > >& Examples, vector< string >& Timestamp ) { float NAFlag = -1000.0; cout << "# Determine number of attributes" << endl; // attributes = number of lags of each variable but does not include the target variable int nattributes = 0; for( int j=0; j<nvar; j++ ) { nattributes += nlags[j]; } cout << "# Number of attributes is: " << nattributes << endl; cout << "# Determine maximum memory" << endl; int max_memory = 0; for (int j=0; j< nvar; j++ ) { if( max_memory < delay[j]+nlags[j] ) { max_memory = delay[j]+nlags[j]; } } cout << "# Maximum memory is: " << max_memory << endl; //open training data file ifstream ifile( inputfile.c_str() ); // create stack of examples vector< stack< float > > Points(nvar); stack< string > Timestamp_loc; string FullLine; getline(ifile, FullLine); while( ifile ) { if (FullLine[0]!='#') { //cout << FullLine << endl; string tstamp; istringstream DataLine( FullLine ); DataLine >> tstamp; for( int i=0; i<nvar; i++) { string a; DataLine >> a; // Flag NA records if( a == "NA" || a=="0.000" || a == "RM") { Points[i].push(NAFlag); } else { Points[i].push( atof( a.c_str() ) ); } } Timestamp_loc.push( tstamp ); } getline(ifile, FullLine); }
void setupInitialConditions() { //define side walls InfiniteWall w0; w0.set(Vec3D(-1,0,0), Vec3D(getXMin(), 0, 0)); wallHandler.copyAndAddObject(w0); w0.set(Vec3D( 1,0,0), Vec3D(getXMax(), 0, 0)); wallHandler.copyAndAddObject(w0); IntersectionOfWalls w1; std::vector<Vec3D> Points(3); //left neck wall //define the corners of your prismatic wall in clockwise direction Points[0] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); Points[1] = Vec3D(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); Points[2] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); w1.createOpenPrism(Points); wallHandler.copyAndAddObject(w1); //right neck wall Points[0] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); Points[1] = Vec3D(getXMax()-ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); Points[2] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); w1.createOpenPrism(Points); wallHandler.copyAndAddObject(w1); // The above wall definition is equivalent to //~ IntersectionOfWalls w1; //~ Vec3D A(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight); //~ Vec3D B(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 ); //~ Vec3D C(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight); //~ Vec3D D(0,1,0); //Periodic direction of the prism //~ w1.addObject(Vec3D::Cross(A-B,D),A); //~ w1.addObject(Vec3D::Cross(B-C,D),B); //~ wallHandler.copyAndAddObject(w1); w0.set(Vec3D(0,0,-1), Vec3D(0,0,-0.5*(getZMin()+getZMax()))); wallHandler.copyAndAddObject(w0); BaseParticle p0; p0.setVelocity(Vec3D(0.0,0.0,0.0)); //Mdouble Width = getXMax()-getXMin(); for (double z=(getZMin()+getZMax())/2.0+ContractionHeight; particleHandler.getNumberOfObjects()<=N; z+=2.0*MaxParticleRadius) for (double x=MaxParticleRadius; x<getXMax(); x+=1.999*MaxParticleRadius) { p0.setRadius(random.getRandomNumber(MinParticleRadius,MaxParticleRadius)); p0.setPosition(Vec3D(x, 0.0, z+p0.getRadius())); p0.setVelocity(1.0*Vec3D(random.getRandomNumber(-1,1),0.0,random.getRandomNumber(-1,0))); particleHandler.copyAndAddObject(p0); } //write(std::cout,false); }
std::string KMeansClient::MoveDataToMessage(Points& data, const size_t K) { std::stringstream message_stream; const size_t data_size = data.size(); const size_t dimensions = data[0].size(); message_stream.precision(20); message_stream << data_size << kComponentsDelimiter << dimensions << kComponentsDelimiter << K << kComponentsDelimiter; MovePointsToMessage(message_stream, data.begin(), data.end()); Points().swap(data); return message_stream.str(); }
void CGameScore::InputApplyScore( inputdata_t &inputdata ) { CBaseEntity *pActivator = inputdata.pActivator; if ( pActivator == NULL ) return; if ( CanFireForActivator( pActivator ) == false ) return; // Only players can use this if ( pActivator->IsPlayer() ) { if ( AwardToTeam() ) { pActivator->AddPointsToTeam( Points(), AllowNegativeScore() ); } else { pActivator->AddPoints( Points(), AllowNegativeScore() ); } } }
/// Return a Histogram based on previously set information. Throws if /// information is incomplete are inconsisten. Histogram HistogramBuilder::build() const { if (!m_x) throw std::runtime_error("HistogramBuilder: No X data has been set"); if (!m_y) throw std::runtime_error("HistogramBuilder: No Y data has been set"); std::unique_ptr<Histogram> histogram; if (getHistogramXMode(m_x->size(), m_y->size()) == Histogram::XMode::BinEdges) { if (m_isDistribution) histogram = Kernel::make_unique<Histogram>(BinEdges(m_x), Frequencies(m_y)); else histogram = Kernel::make_unique<Histogram>(BinEdges(m_x), Counts(m_y)); } else { if (m_isDistribution) histogram = Kernel::make_unique<Histogram>(Points(m_x), Frequencies(m_y)); else histogram = Kernel::make_unique<Histogram>(Points(m_x), Counts(m_y)); } if (m_e) histogram->setSharedE(m_e); return *histogram; }
CelestialWidget::CelestialWidget( QWidget* parent ) :QWidget( parent ), sphereRadio( 120.0 ), m_declination( 0 ), m_rightAscension( 0 ) { QVBoxLayout* mainLayout = new QVBoxLayout; setLayout( mainLayout ); QWidget* examinerWidget = new QWidget; examinerWidget->setFixedSize( 490, 300 ); mainLayout->addWidget(examinerWidget); m_rootNode = new SoSeparator; m_rootNode->addChild( Ejes() ); m_rootNode->addChild( Sphere() ); m_rootNode->addChild( CelestialEquator() ); m_rootNode->addChild( Ecliptic() ); m_rootNode->addChild( Points() ); m_rootNode->addChild( RightAscension() ); m_rootNode->addChild( Declination() ); m_rootNode->addChild( Star() ); SoQtExaminerViewer* myRenderArea = new SoQtExaminerViewer( examinerWidget ); myRenderArea->setSceneGraph( m_rootNode ); SbColor col( 0.86f, 0.86f, 0.86f ); myRenderArea->setBackgroundColor(col); myRenderArea->show( ); QWidget* labelsWidget = new QWidget; mainLayout->addWidget( labelsWidget ); QGridLayout* labelsLayout = new QGridLayout; labelsWidget->setLayout( labelsLayout ); QLabel* m_rightLabel = new QLabel; m_rightLabel->setText( "Right Ascension:" ); labelsLayout->addWidget( m_rightLabel, 0, 0, 1, 1 ); m_rightValue = new QLabel; m_rightValue->setText( QString::number( m_rightAscension ) ); labelsLayout->addWidget( m_rightValue, 0, 1, 1, 3 ); QLabel* m_declinationLabel = new QLabel; m_declinationLabel->setText( "Declination:" ); labelsLayout->addWidget( m_declinationLabel, 1, 0, 1, 1 ); m_declinationValue = new QLabel; m_declinationValue->setText( QString::number( m_declination ) ); labelsLayout->addWidget( m_declinationValue, 1, 1, 1, 3 ); }
void CgalPatch::insert_polygonInter2(ImageSpline& is, PatchSpline& ps) { LineIndex start_idx = ps.m_LineIndexs.front(); Point last; if (start_idx.m_Forward) { Vector2 v = is.m_LineFragments[start_idx.m_id].m_Points.front(); last = Point(v.x, v.y); } else { Vector2 v = is.m_LineFragments[start_idx.m_id].m_Points.back(); last = Point(v.x, v.y); } Point start = last; m_Inter.push_back(Points()); Points& points = m_Inter.back(); points.push_back(last); for (auto it = ps.m_LineIndexs.begin(); it != ps.m_LineIndexs.end(); ++it) { Line pts = is.m_LineFragments[it->m_id].m_Points; if (it->m_Forward) { for (auto it2 = pts.begin(); it2 != pts.end(); ++it2) { Point now(it2->x, it2->y); points.push_back(now); last = now; } } else { for (auto it2 = pts.rbegin(); it2 != pts.rend(); ++it2) { Point now(it2->x, it2->y); points.push_back(now); last = now; } } } }
PyObject* create_Path(const utf8_string& path, const Optional<Settings>& maybeSettings) { // Fixme: Duplicates py-canvas.cpp if (!is_ascii(path)){ // Fixme: Consider adding ascii_string type throw ValueError("Non-ascii-characters in path definition."); } std::vector<PathPt> points(parse_svg_path(path.str())); if (points.empty()){ throw ValueError("Failed parsing path definition."); } if (points.front().IsNotMove()){ throw ValueError("Paths must begin with a Move-entry."); } const auto s = merge_settings(maybeSettings, default_path_settings()); return create_Shape(create_path_object_raw(Points(points), s)); }
void onOnceBeforeDraw() override { struct Rect : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { SkRect rect = SkRect::MakeXYWH(0, 0, 50, 50); canvas->drawRect(rect, paint); return rect; } }; struct Circle : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { static const SkScalar radius = 25; canvas->drawCircle(radius, radius, radius, paint); return SkRect::MakeXYWH(0, 0, 2 * radius, 2 * radius); } }; struct RRect : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { SkRRect rrect; rrect.setRectXY(SkRect::MakeXYWH(0, 0, 50, 50), 10, 10); canvas->drawRRect(rrect, paint); return rrect.getBounds(); } }; struct DRRect : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { SkRRect outerRRect; outerRRect.setRectXY(SkRect::MakeXYWH(0, 0, 50, 50), 5, 5); SkRRect innerRRect; innerRRect.setRectXY(SkRect::MakeXYWH(5, 8, 35, 30), 8, 3); canvas->drawDRRect(outerRRect, innerRRect, paint); return outerRRect.getBounds(); } }; struct Path : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { SkPath path; path.addCircle(15, 15, 10); path.addOval(SkRect::MakeXYWH(2, 2, 22, 37)); path.setFillType(SkPath::kEvenOdd_FillType); canvas->drawPath(path, paint); return path.getBounds(); } }; struct Points : public Prim { Points(SkCanvas::PointMode mode) : fMode(mode) {} SkRect draw(SkCanvas* canvas, const SkPaint& paint) override { SkRandom random; SkPoint points[500]; SkRect bounds = SkRect::MakeWH(50, 50); int count = SkToInt(SK_ARRAY_COUNT(points)); if (SkCanvas::kPoints_PointMode != fMode) { count = SkTMin(count, 10); } for (int p = 0; p < count; ++p) { points[p].fX = random.nextUScalar1() * bounds.width(); points[p].fY = random.nextUScalar1() * bounds.width(); } canvas->drawPoints(fMode, count, points, paint); return bounds; } SkCanvas::PointMode fMode; }; struct Text : public Prim { SkRect draw(SkCanvas* canvas, const SkPaint& origPaint) override { SkPaint paint = origPaint; paint.setTextSize(30.f); this->setFont(&paint); const char* text = this->text(); static const SkVector offset = SkVector::Make(10, 10); canvas->drawText(text, strlen(text), offset.fX, offset.fY, paint); SkRect bounds; paint.measureText(text, strlen(text), &bounds); bounds.offset(offset); return bounds; } virtual void setFont(SkPaint* paint) { sk_tool_utils::set_portable_typeface(paint); } virtual const char* text() const { return "Hello, Skia!"; } }; struct BmpText : public Text { void setFont(SkPaint* paint) override { if (!fTypeface) { fTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); } paint->setTypeface(fTypeface); } const char* text() const override { return "Hi, Skia!"; } SkAutoTUnref<SkTypeface> fTypeface; }; fPrims.push_back(SkNEW(Rect)); fPrims.push_back(SkNEW(Circle)); fPrims.push_back(SkNEW(RRect)); fPrims.push_back(SkNEW(DRRect)); fPrims.push_back(SkNEW(Path)); fPrims.push_back(SkNEW(Points(SkCanvas::kPoints_PointMode))); fPrims.push_back(SkNEW(Points(SkCanvas::kLines_PointMode))); fPrims.push_back(SkNEW(Points(SkCanvas::kPolygon_PointMode))); fPrims.push_back(SkNEW(Text)); fPrims.push_back(SkNEW(BmpText)); }
bool delete_all_copies() { return this->set_copies(Points()); }
/*! @brief A function to solve wireless mesh channel allocation problem. @details This function solves wireless mesh channel allocation problem. */ int PSP(int ArgC, char * ArgV[]) { if (ArgC <= 2) { cerr << endl; cout << "Protein Structure Prediction Problem" << endl << endl; cerr << "Usage:" << endl; cerr << ArgV[0] << " -n ProteinLength -p ProteinHPString -f FitnessUseRatio -i MaxIter [-t TabuLength -s RandomSeed]" << endl << endl; cerr << "Output:" << endl; cerr << "BestEnergy IterationCount Run-Time MemoryUsage" << endl; cerr << "TabuLength" << endl; cerr << endl; return ExitOnFailure; } Dim ProteinSize = 0; // Size of the protein. Dim FitnessRatio = 0; // Fitness usage ratio. Dim MaxIteration = 0; // Maximum iteration for local search algorithm. Rnd theRnd; // Random number generator Dim TabuLength = 0; // Tabu length for constraint based local search. Dim ProteinIdx = 0; // Parameter index having the amino acid. for(Idx tIdx = 2; tIdx < castIdx(ArgC); ++tIdx) { if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'n') ProteinSize = parseN(ArgV[tIdx+1]); else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'f') FitnessRatio = parseN(ArgV[tIdx+1]); else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'i') MaxIteration = parseN(ArgV[tIdx+1]); else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 't') TabuLength = parseN(ArgV[tIdx+1]); else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'p') ProteinIdx = tIdx+1; else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 's') theRnd.seed(parseN(ArgV[tIdx+1])); } if(!MaxIteration || !ProteinIdx || !FitnessRatio) { cerr << endl; cerr << "Error in commandline parameter/value. Run only with parameter " << ArgV[1] << " to see usage." << endl; cerr << endl; return ExitOnFailure; } b1<Bll,kmm> AminoAcids(ProteinSize);// Amino acid types of the amino acids. for(Idx tIdx = 0; tIdx < ProteinSize; ++tIdx) AminoAcids[tIdx] = (ArgV[ProteinIdx][tIdx] == 'H'); Sys & tSys = Sys::refm(Sys::def()); #if CompDnwd tSys.setMultiCandExec(); #if SimulFixedFlexi #if SelcSimulFlexi tSys.setMultiFlexiSimul(); #else tSys.setMultiFixedSimul(); #endif #elif SimulFixedOnly tSys.setMultiFixedSimul(); #elif SimulFlexiOnly tSys.setMultiFlexiSimul(); #endif #endif EvalTi::def(tSys.SysHdl); EvalTi const & tEvalTbl = EvalTi::refc(tSys.SysHdl); QcSv2Tabu::def(tSys.SysHdl, TabuLength); b1<Prm,kmm> Xvars(ProteinSize); b1<Prm,kmm> Yvars(ProteinSize); b1<Prm,kmm> Zvars(ProteinSize); b1<EvalRecInt const *,kmm> XvarRecs(ProteinSize); b1<EvalRecInt const *,kmm> YvarRecs(ProteinSize); b1<EvalRecInt const *,kmm> ZvarRecs(ProteinSize); b1<StatRangeVarVi *,kmm> XvarPtrs(ProteinSize); b1<StatRangeVarVi *,kmm> YvarPtrs(ProteinSize); b1<StatRangeVarVi *,kmm> ZvarPtrs(ProteinSize); for (Idx tIdx = 0; tIdx < ProteinSize; ++tIdx) { Xvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize)); Yvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize)); Zvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize)); XvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Xvars[tIdx].TermHdl).ValueLoc()); YvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Yvars[tIdx].TermHdl).ValueLoc()); ZvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Zvars[tIdx].TermHdl).ValueLoc()); XvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Xvars[tIdx].TermHdl); YvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Yvars[tIdx].TermHdl); ZvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Zvars[tIdx].TermHdl); } b2<Prm> Dists(ProteinSize, ProteinSize); for (Idx tIdx1 = 0; tIdx1 < ProteinSize - 1; ++tIdx1) for (Idx tIdx2 = tIdx1 + 1; tIdx2 < ProteinSize; ++tIdx2) { b1<Prm,kmm> tDist(3); tDist[0] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Xvars[tIdx1], Xvars[tIdx2])))); tDist[1] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Yvars[tIdx1], Yvars[tIdx2])))); tDist[2] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Zvars[tIdx1], Zvars[tIdx2])))); Dists.item(tIdx1,tIdx2) = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, tDist.items(), 3)); } b1<Prm, xmm> Fhdists, Edists, Fhpdists; for (Idx tIdx1 = 0; tIdx1 < ProteinSize - 1; ++tIdx1) { for (Idx tIdx2 = tIdx1 + 1; tIdx2 < ProteinSize; ++tIdx2) { Fhpdists.insertMem(Dists.item(tIdx1, tIdx2)); if (!AminoAcids[tIdx1] || !AminoAcids[tIdx2]) continue; Fhdists.insertMem(Dists.item(tIdx1, tIdx2)); Edists.insertMem(Prm(Tf, UeqsXiFeVi::def(Xv, tSys.SysHdl, Dists.item(tIdx1,tIdx2), UeqsXiFeVi::bind(2)))); } } Prm Etop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Edists.items(), Edists.itemCount())); Prm Fhtop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Fhdists.items(), Fhdists.itemCount())); Prm Fhptop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Fhpdists.items(), Fhpdists.itemCount())); // random valid initialisation hsetd<Point,nmmh> AllDiff(ProteinSize); b1<Point,kmm> Points(ProteinSize); b1<Idx, kmm> AllDiffIdx(ProteinSize); Point tp = {0,0,0}; Idx ti = 0; Points[ti] = tp; AllDiffIdx[ti] = AllDiff.insertItr(tp); while(ti < ProteinSize - 1) { Idx vn = uniform(theRnd, 12); tp.x = Points[ti].x + vx[vn]; tp.y = Points[ti].y + vy[vn]; tp.z = Points[ti].z + vz[vn]; Cnt tc = 0; while (tc < 12 && AllDiff.findBll(tp)) { ++tc; Idx vni = uniform(theRnd, 12); tp.x = Points[ti].x + vx[vni]; tp.y = Points[ti].y + vy[vni]; tp.z = Points[ti].z + vz[vni]; } if (tc < 12) { Points[++ti] = tp; AllDiffIdx[ti] = AllDiff.insertItr(tp); } else AllDiff.removeWithItr(AllDiffIdx[--ti]); } { b1<Hdl,kmm> VarHdls(3*ProteinSize); b1<Wrp,kmm> ValWrps(3*ProteinSize); for(Idx tIdx = 0; tIdx < ProteinSize; ++tIdx) { VarHdls[tIdx * 3 + 0] = Xvars[tIdx].TermHdl; VarHdls[tIdx * 3 + 1] = Yvars[tIdx].TermHdl; VarHdls[tIdx * 3 + 2] = Zvars[tIdx].TermHdl; ValWrps[tIdx * 3 + 0] = Wrp(Points[tIdx].x); ValWrps[tIdx * 3 + 1] = Wrp(Points[tIdx].y); ValWrps[tIdx * 3 + 2] = Wrp(Points[tIdx].z); } tSys.initialiseVarsWrap(VarHdls.items(), ValWrps.items()); } Refm(tEtop, SumXiFeVi, tSys.SysHdl, Etop.TermHdl); Refm(tFhtop, SumXiFeVi, tSys.SysHdl, Fhtop.TermHdl); Refm(tFhptop, SumXiFeVi, tSys.SysHdl, Fhptop.TermHdl); #if CompLazyHalf tEtop.require(true); #endif QcSv2Tabu const & tQcSv2Tabu = QcSv2Tabu::refc(tSys.SysHdl); Int BestEnergy = tEtop.ValueRec().CurrData(); while(tSys.ExecClk() < MaxIteration) { Int MinFitness = MaxInt; Idx MinPointIdx = InvIdx; Point tMinPointValue; for(Idx tIdx1 = 0; tIdx1 < ProteinSize; ++tIdx1) { if (tQcSv2Tabu.state(Xvars[tIdx1].TermHdl) || tQcSv2Tabu.state(Yvars[tIdx1].TermHdl) || tQcSv2Tabu.state(Zvars[tIdx1].TermHdl)) continue; Idx kl = tIdx1 == 0 ? tIdx1 + 1: tIdx1 - 1; Idx kr = tIdx1 == (ProteinSize - 1) ? tIdx1 - 1: tIdx1 + 1; Hdl AsgnVars[3] = { Xvars[tIdx1].TermHdl, Yvars[tIdx1].TermHdl, Zvars[tIdx1].TermHdl }; #if SimulFixedFlexi #if SelcSimulFlexi tSys.setSimulFlexiVars(AsgnVars, 3); #else tSys.setSimulFixedVars(AsgnVars, 3); #endif #elif SimulFixedOnly tSys.setSimulFixedVars(AsgnVars, 3); #elif SimulFlexiOnly tSys.setSimulFlexiVars(AsgnVars, 3); #endif for(Idx tIdx2 = 0; tIdx2 < 12; ++tIdx2) { Point tPoint = { castInt(XvarRecs[kl]->CurrData() + vx[tIdx2]), castInt(YvarRecs[kl]->CurrData() + vy[tIdx2]), castInt(ZvarRecs[kl]->CurrData() + vz[tIdx2]) }; if (AllDiff.findBll(tPoint)) continue; if (!checkNeighbour(tPoint.x,tPoint.y,tPoint.z,XvarRecs[kr]->CurrData(), YvarRecs[kr]->CurrData(),ZvarRecs[kr]->CurrData())) continue; tSys.setSimulMode(DiffAsgn); XvarPtrs[tIdx1]->simulIncrValue(tPoint.x); YvarPtrs[tIdx1]->simulIncrValue(tPoint.y); ZvarPtrs[tIdx1]->simulIncrValue(tPoint.z); tSys.setSimulMode(DiffProp); #if SimulUpwd tSys.propagateSimulIncr(); #endif if (tSys.ExecClk() % FitnessRatio != 0) { #if SimulDnwd Term::performSimulIncr(tFhtop); #endif if (MinFitness > tFhtop.ValueRec().CurrData()) { MinFitness = tFhtop.ValueRec().CurrData(); MinPointIdx = tIdx1; tMinPointValue = tPoint; } } else { #if SimulDnwd Term::performSimulIncr(tFhptop); #endif if (MinFitness > tFhptop.ValueRec().CurrData()) { MinFitness = tFhptop.ValueRec().CurrData(); MinPointIdx = tIdx1; tMinPointValue = tPoint; } } } } if (MinPointIdx != InvIdx) { Hdl AsgnVars[3] = { Xvars[MinPointIdx].TermHdl, Yvars[MinPointIdx].TermHdl, Zvars[MinPointIdx].TermHdl }; Wrp AsgnVals[3] = { Wrp(tMinPointValue.x), Wrp(tMinPointValue.y), Wrp(tMinPointValue.z) }; tSys.execIncrDiffVarsWrap(AsgnVars, AsgnVals, 3); } } cout << BestEnergy << " " << tSys.ExecClk() << " " << getTime() << " " << getMemory() << endl; cout << TabuLength; cout << " " << theRnd.Seed() << endl; return ExitOnSuccess; }
void CGameScore::Spawn( void ) { int iScore = Points(); BaseClass::Spawn(); SetPoints( iScore ); }
void MainWindow::createActions(TCViewer* viewer) { openAct= new QAction(tr("&Open Mesh..."), this); openAct->setShortcut(tr("Ctrl+O")); openAct->setStatusTip(tr("Open a mesh file")); connect(openAct, SIGNAL(triggered()), viewer, SLOT(query_open_mesh_file())); texAct = new QAction(tr("Open Texture..."), this); texAct->setShortcut(tr("Ctrl+T")); texAct->setStatusTip(tr("Open a texture file")); connect(texAct, SIGNAL(triggered()), viewer, SLOT(query_open_texture_file())); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), viewer, SLOT(about())); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(aboutQtAct, SIGNAL(triggered()), viewer, SLOT(aboutQt())); SmoothAct = new QAction(tr("&Smooth"), this); SmoothAct->setCheckable(true); SmoothAct->setShortcut(tr("Shift+S")); SmoothAct->setStatusTip(tr("Smooth Shading")); connect(SmoothAct, SIGNAL(triggered()), viewer, SLOT(Smooth())); FlatAct = new QAction(tr("&Flat"), this); FlatAct->setCheckable(true); FlatAct->setShortcut(tr("Shift+F")); FlatAct->setStatusTip(tr("Flat Shading")); connect(FlatAct, SIGNAL(triggered()), viewer, SLOT(Flat())); WireframeAct = new QAction(tr("&Wireframe"), this); WireframeAct->setCheckable(true); WireframeAct->setShortcut(tr("Shift+W")); WireframeAct->setStatusTip(tr("Display Wireframe")); connect(WireframeAct, SIGNAL(triggered()), viewer, SLOT(Wireframe())); PointsAct = new QAction(tr("&Points"), this); PointsAct->setCheckable(true); PointsAct->setShortcut(tr("Shift+P")); PointsAct->setStatusTip(tr("Display Points")); connect(PointsAct, SIGNAL(triggered()), viewer, SLOT(Points())); HiddenLineAct = new QAction(tr("&Hidden-Line"), this); HiddenLineAct->setCheckable(true); HiddenLineAct->setShortcut(tr("Shift+H")); HiddenLineAct->setStatusTip(tr("Hidden-Line")); connect(HiddenLineAct, SIGNAL(triggered()), viewer, SLOT(HiddenLine())); ValenceAct = new QAction(tr("&Valence"), this); ValenceAct->setCheckable(true); ValenceAct->setShortcut(tr("Shift+V")); ValenceAct->setStatusTip(tr("View Vertex Valence")); connect(ValenceAct, SIGNAL(triggered()), viewer, SLOT(Valence())); GaussianCurvatureAct = new QAction(tr("&Gaussian Curvature"), this); GaussianCurvatureAct->setCheckable(true); GaussianCurvatureAct->setShortcut(tr("Shift+G")); GaussianCurvatureAct->setStatusTip(tr("View Gaussian Curvature")); connect(GaussianCurvatureAct, SIGNAL(triggered()), viewer, SLOT(GaussianCurvature())); MeanCurvatureAct = new QAction(tr("&Mean Curvature"), this); MeanCurvatureAct->setCheckable(true); MeanCurvatureAct->setShortcut(tr("Shift+M")); MeanCurvatureAct->setStatusTip(tr("View Mean Curvature")); connect(MeanCurvatureAct, SIGNAL(triggered()), viewer, SLOT(MeanCurvature())); renderModeGroup = new QActionGroup(this); renderModeGroup->addAction(SmoothAct); renderModeGroup->addAction(FlatAct); renderModeGroup->addAction(WireframeAct); renderModeGroup->addAction(PointsAct); renderModeGroup->addAction(HiddenLineAct); renderModeGroup->addAction(ValenceAct); renderModeGroup->addAction(GaussianCurvatureAct); renderModeGroup->addAction(MeanCurvatureAct); SmoothAct->setChecked(true); }
Mat Tracker::process(const Mat frame, Stats& stats) { TickMeter tm; vector<KeyPoint> kp; Mat desc; tm.start(); detector->detectAndCompute(frame, noArray(), kp, desc); stats.keypoints = (int)kp.size(); vector< vector<DMatch> > matches; vector<KeyPoint> matched1, matched2; matcher->knnMatch(first_desc, desc, matches, 2); for(unsigned i = 0; i < matches.size(); i++) { if(matches[i][0].distance < nn_match_ratio * matches[i][1].distance) { matched1.push_back(first_kp[matches[i][0].queryIdx]); matched2.push_back( kp[matches[i][0].trainIdx]); } } stats.matches = (int)matched1.size(); Mat inlier_mask, homography; vector<KeyPoint> inliers1, inliers2; vector<DMatch> inlier_matches; if(matched1.size() >= 4) { homography = findHomography(Points(matched1), Points(matched2), RANSAC, ransac_thresh, inlier_mask); } tm.stop(); stats.fps = 1. / tm.getTimeSec(); if(matched1.size() < 4 || homography.empty()) { Mat res; hconcat(first_frame, frame, res); stats.inliers = 0; stats.ratio = 0; return res; } for(unsigned i = 0; i < matched1.size(); i++) { if(inlier_mask.at<uchar>(i)) { int new_i = static_cast<int>(inliers1.size()); inliers1.push_back(matched1[i]); inliers2.push_back(matched2[i]); inlier_matches.push_back(DMatch(new_i, new_i, 0)); } } stats.inliers = (int)inliers1.size(); stats.ratio = stats.inliers * 1.0 / stats.matches; vector<Point2f> new_bb; perspectiveTransform(object_bb, new_bb, homography); Mat frame_with_bb = frame.clone(); if(stats.inliers >= bb_min_inliers) { drawBoundingBox(frame_with_bb, new_bb); } Mat res; drawMatches(first_frame, inliers1, frame_with_bb, inliers2, inlier_matches, res, Scalar(255, 0, 0), Scalar(255, 0, 0)); return res; }
//Keyboard handler function void kbd(unsigned char key, int x, int y) { y = 500 - y; if(key == 'q' || key == 27) { exit(0); } if(key == 's') { flip1 = true; } if(key == 'a') { flip2 = true; } if(key == 's' && key == 'a') { flip1 = true; flip2 = true; } if (key == '1') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectType = 1; } } printf("Cube selected\n"); } if (key == '2') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectType = 2; } } printf("Sphere selected\n"); } if (key == '3') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectType = 3; } } printf("Ring selected\n"); } if (key == '8') { cameraParticlePosition = true; printf("Pinball Perspective\n"); } if (key == '9') { cameraParticlePosition = false; printf("Regular Perspective\n"); } if (key == 'x') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateX(0.1); } } } if (key == 'X') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateX(-0.1); } } } if (key == 'y') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateY(0.1); } } } if (key == 'Y') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateY(-0.1); } } } if (key == 'z') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateZ(0.1); } } } if (key == 'Z') { for (int count = 0; count < game.ActiveObjects.size(); count++) { if (game.ActiveObjects.at(count).hit == true) { game.ActiveObjects.at(count).objectTranslateZ(-0.1); } } } if (key == ' ') { //check to see if on, is so turn off and vice versa if (startStop == true) { startStop = false; printf("stoped animation\n"); } else if (startStop == false) { startStop = true; printf("started animation\n"); } } if (key == 'r') { //check to see if on, is so turn off and vice versa game.ball = Particle(); game.points = Points(); gameOver = false; printf("Restart\n"); } if (key == 'l') { if(lightswitch == true) { lightswitch = false; glEnable(GL_LIGHTING); printf("Light Enabled\n"); } else { lightswitch = true; glDisable(GL_LIGHTING); printf("Light Disabled\n"); } } }
//--------------------------------------------------------- bool CSTL_Import::On_Execute(void) { int Method; DWORD iFacette, nFacettes; TSTL_Point p[3]; CSG_String sFile, sHeader; CSG_File Stream; //----------------------------------------------------- sFile = Parameters("FILE") ->asString(); Method = Parameters("METHOD") ->asInt(); r_sin_x = sin(Parameters("ROT_X")->asDouble() * M_DEG_TO_RAD); r_sin_y = sin(Parameters("ROT_Y")->asDouble() * M_DEG_TO_RAD); r_sin_z = sin(Parameters("ROT_Z")->asDouble() * M_DEG_TO_RAD); r_cos_x = cos(Parameters("ROT_X")->asDouble() * M_DEG_TO_RAD); r_cos_y = cos(Parameters("ROT_Y")->asDouble() * M_DEG_TO_RAD); r_cos_z = cos(Parameters("ROT_Z")->asDouble() * M_DEG_TO_RAD); //----------------------------------------------------- if( !Stream.Open(sFile) ) { return( false ); } if( !Stream.Read(sHeader, 80) ) { return( false ); } Message_Add(sHeader); if( !Stream.Read(&nFacettes, sizeof(nFacettes)) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("Number of Facettes"), nFacettes)); //----------------------------------------------------- switch( Method ) { //----------------------------------------------------- case 0: { // Point Cloud CSG_Rect Extent; if( Get_Extent(Stream, Extent, nFacettes) ) { CSG_PRQuadTree Points(Extent); CSG_PointCloud *pPoints = SG_Create_PointCloud(); Parameters("POINTS")->Set_Value(pPoints); pPoints->Set_Name(SG_File_Get_Name(sFile, false)); pPoints->Add_Field((const char *)NULL, SG_DATATYPE_Undefined); for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++) { if( Read_Facette(Stream, p) ) { for(int i=0; i<3; i++) { if( Points.Add_Point(p[i].x, p[i].y, p[i].z) ) { pPoints->Add_Point(p[i].x, p[i].y, p[i].z); } } } } } break; } //----------------------------------------------------- case 1: { // Point Cloud (centered) CSG_PointCloud *pPoints = SG_Create_PointCloud(); Parameters("POINTS")->Set_Value(pPoints); pPoints->Set_Name(SG_File_Get_Name(sFile, false)); pPoints->Add_Field((const char *)NULL, SG_DATATYPE_Undefined); for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++) { if( Read_Facette(Stream, p) ) { pPoints->Add_Point( (p[0].x + p[1].x + p[2].x) / 3.0, (p[0].y + p[1].y + p[2].y) / 3.0, (p[0].z + p[1].z + p[2].z) / 3.0 ); } } break; } //----------------------------------------------------- case 2: { // Points CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, SG_File_Get_Name(sFile, false)); pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Float); Parameters("SHAPES")->Set_Value(pPoints); for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++) { if( Read_Facette(Stream, p) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point( (p[0].x + p[1].x + p[2].x) / 3.0, (p[0].y + p[1].y + p[2].y) / 3.0 ); pPoint->Set_Value(0, (p[0].z + p[1].z + p[2].z) / 3.0 ); } } break; } //----------------------------------------------------- case 3: { // Raster CSG_Rect Extent; if( Get_Extent(Stream, Extent, nFacettes) ) { int nx, ny; double d; nx = Parameters("GRID_RES")->asInt(); d = Extent.Get_XRange() / nx; ny = 1 + (int)(Extent.Get_YRange() / d); m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, Extent.Get_XMin(), Extent.Get_YMin()); m_pGrid->Set_Name(SG_File_Get_Name(sFile, false)); m_pGrid->Set_NoData_Value(-99999); m_pGrid->Assign_NoData(); Parameters("GRID")->Set_Value(m_pGrid); //--------------------------------------------- for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++) { if( Read_Facette(Stream, p) ) { TSG_Point_Z Point[3]; for(int i=0; i<3; i++) { Point[i].x = (p[i].x - m_pGrid->Get_XMin()) / m_pGrid->Get_Cellsize(); Point[i].y = (p[i].y - m_pGrid->Get_YMin()) / m_pGrid->Get_Cellsize(); Point[i].z = p[i].z; } Set_Triangle(Point); } } } break; } } //----------------------------------------------------- return( true ); }
static void SimplifySketch(const double deviation, bool make_bspline ) { wxGetApp().CreateUndoPoint(); double original_tolerance = wxGetApp().m_geom_tol; wxGetApp().m_geom_tol = sketch_tool_options.m_cleanup_tolerance; std::list<HeeksObj *> selected_sketches; std::copy( wxGetApp().m_marked_list->list().begin(), wxGetApp().m_marked_list->list().end(), std::inserter( selected_sketches, selected_sketches.begin() )); std::list<HeeksObj*>::const_iterator It; for(It = selected_sketches.begin(); It != selected_sketches.end(); It++){ HeeksObj* object = *It; std::list<HeeksObj *> new_objects; if (object->GetType() == SketchType) { std::list<TopoDS_Shape> wires; try { heekscad_interface.ConvertSketchToFaceOrWire(object, wires, false); } // End try catch(...) { continue; } for (std::list<TopoDS_Shape>::iterator itWire = wires.begin(); itWire != wires.end(); itWire++) { std::list<SimplifySketchTool::SortPoint> points = SimplifySketchTool::GetPoints( TopoDS::Wire(*itWire), deviation ); if (sketch_tool_options.m_sort_points) { // The sort points option is turned on. The idea of this is to detect shapes that include // sections that 'double back' on themselves. The first example being a shape made up of // a box as well as a single line that layed along one edge of the box. In this case the extra // line was superfluous. If we sort the points so that each point is closest to the previous // point then, hopefully, we will reorder these shapes that double back on themselves. If this // doesn't work then the user can always turn the 'sort points' option off and try again. std::vector<SimplifySketchTool::SortPoint> sorted_points; std::copy( points.begin(), points.end(), std::inserter( sorted_points, sorted_points.begin() )); for (std::vector<SimplifySketchTool::SortPoint>::iterator l_itPoint = sorted_points.begin(); l_itPoint != sorted_points.end(); l_itPoint++) { // We've already begun. Just sort based on the previous point's location. std::vector<SimplifySketchTool::SortPoint>::iterator l_itNextPoint = l_itPoint; l_itNextPoint++; if (l_itNextPoint != sorted_points.end()) { SimplifySketchTool::sort_points_by_distance compare( *l_itPoint ); std::sort( l_itNextPoint, sorted_points.end(), compare ); } // End if - then } // End for points.clear(); std::copy( sorted_points.begin(), sorted_points.end(), std::inserter( points, points.begin() )); // This sorting process will have resulted in the start and end points being located next to each other // and hence removed. If the original wire was periodic (closed shape) then make sure the last point // is the same as the first point. TopoDS_Wire wire(TopoDS::Wire(*itWire)); if (wire.Closed()) { if (*(points.begin()) != *(points.rbegin())) { points.push_back(*points.begin()); // Close the shape manually. } } } // Whether we sorted or not, we may want to close the shape. if (sketch_tool_options.m_force_closed_shape) { if (*(points.begin()) != *(points.rbegin())) { points.push_back(*points.begin()); // Close the shape manually. } } // Now keep removing points from this list as long as the midpoints are within deviation of // the line between the two neighbour points. bool points_removed = false; do { points_removed = false; for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++ ) { std::list<SimplifySketchTool::SortPoint>::iterator itP1 = itPoint; std::list<SimplifySketchTool::SortPoint>::iterator itP2 = itPoint; std::list<SimplifySketchTool::SortPoint>::iterator itP3 = itPoint; itP2++; if (itP2 != points.end()) { itP3 = itP2; itP3++; if (itP3 != points.end()) { // First see if p1 and p2 are too close to each other. if (itP1->Distance(*itP2) < deviation) { // Discard p2. points.erase(itP2); points_removed = true; continue; } if (itP2->Distance(*itP3) < deviation) { // Discard p2 points.erase(itP2); points_removed = true; continue; } if (itP1->Distance(*itP3) > deviation) { // Now draw a line between p1 and p3. Measure the distance between p2 and the nearest point // along that line. If this distance is less than the max deviation then discard p2. gp_Lin line(*itP1, gp_Dir(itP3->X() - itP1->X(), itP3->Y() - itP1->Y(), itP3->Z() - itP1->Z())); if (line.SquareDistance(*itP2) < deviation) { // Discard p2 points.erase(itP2); points_removed = true; continue; } } } } } // End for } while (points_removed == true); if (points.size() >= 2) { if (make_bspline) { try { TColgp_Array1OfPnt Points(0, points.size()-1); Standard_Integer i=0; for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++, i++) { Points.SetValue(i, *itPoint); } // GeomAPI_PointsToBSpline bspline(Points); GeomAPI_PointsToBSpline bspline(Points, sketch_tool_options.m_degree_min, sketch_tool_options.m_degree_max, GeomAbs_Shape(sketch_tool_options.m_continuity), sketch_tool_options.m_cleanup_tolerance); // Standard_EXPORT GeomAPI_PointsToBSpline(const TColgp_Array1OfPnt& Points,const Standard_Integer DegMin = 3,const Standard_Integer DegMax = 8,const GeomAbs_Shape Continuity = GeomAbs_C2,const Standard_Real Tol3D = 1.0e-3); HSpline *hspline = new HSpline(bspline.Curve(), &(wxGetApp().current_color)); heekscad_interface.Add( hspline, NULL ); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught(); wxMessageBox(_("Failed to create BSpline curve")); } } // End if - then else { // We're making straight lines HeeksObj *sketch = heekscad_interface.NewSketch(); for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++) { std::list<SimplifySketchTool::SortPoint>::iterator itNext = itPoint; itNext++; if (itNext == points.end()) continue; double start[3], end[3]; itPoint->ToDoubleArray(start); itNext->ToDoubleArray(end); sketch->Add(heekscad_interface.NewLine(start, end), NULL); } // End for // heekscad_interface.Add(sketch, NULL); new_objects.push_back(sketch); } // End if - else } // End if - then } // End for if (new_objects.size() > 0) { #ifdef MULTIPLE_OWNERS std::list<HeeksObj *> parents = object->Owners(); for (std::list<HeeksObj *>::iterator itOwner = parents.begin(); itOwner != parents.end(); itOwner++) { #else if(object->m_owner) { #endif if ((object->CanEditString()) && (object->GetShortString())) { // (*itOwner)->Remove(object); // Mark the old sketches with a name that can be easily recognised so that we can delete the // old objects if we're satisfied with the replacements. wxString title; title << _("Replaced ") << object->GetShortString(); object->OnEditString(title); } // End if - then for (std::list<HeeksObj *>::iterator itNewChild = new_objects.begin(); itNewChild != new_objects.end(); itNewChild++) { #ifdef MULTIPLE_OWNERS (*itOwner)->Add( *itNewChild, NULL ); #else object->m_owner->Add( *itNewChild, NULL ); #endif } // End for } // End for } // End if - then } // End if - then } // End for wxGetApp().m_geom_tol = original_tolerance; wxGetApp().Changed(); } void SimplifySketchTool::Run() { SimplifySketch(m_deviation, false); } // End Run() method
static void CALLBACK Paint(void) { glDisable(GL_SCISSOR_TEST); glClearColor(1.0,1.0,1.0,1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); AUX_SETCOLOR(windType,AUX_BLACK); if(antialiasing) { glBlendFunc(GL_SRC_ALPHA,GL_ZERO); glEnable(GL_BLEND); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); } if(depthTesting) glEnable(GL_DEPTH_TEST); if(fogging) { glEnable(GL_FOG); glHint(GL_FOG_HINT,(niceFogging)?GL_NICEST:GL_FASTEST); } if(lighting) { static GLfloat ambient[4]={1,0.5,0.5,0}; glEnable(GL_NORMALIZE); glNormal3f(1.0,1.0,1.0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } (shading)?glShadeModel(GL_SMOOTH):glShadeModel(GL_FLAT); if(texturing) { static GLfloat modulate[1]={GL_DECAL}; static GLfloat clamp[1]={GL_CLAMP}; static GLfloat linear[1]={GL_LINEAR}; glPixelStorei(GL_UNPACK_ALIGNMENT,1); glTexImage2D(GL_TEXTURE_2D,0,3,2,2,0,GL_RGB ,GL_UNSIGNED_BYTE,(GLvoid*)texture); glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,modulate); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,clamp); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,clamp); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,linear); glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,linear); glEnable(GL_TEXTURE_2D); } Viewport(0,0); Points(); Viewport(0,1); Lines(); Viewport(0,2); Triangles(); Viewport(0,3); Rects(); glFlush(); if(doubleBuffer) auxSwapBuffers(); }
//--------------------------------------------------------- bool CKriging_Regression::On_Execute(void) { //----------------------------------------------------- CSG_Shapes Points(SHAPE_TYPE_Point); CSG_Grid *pPrediction = Parameters("PREDICTION")->asGrid(); CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); CSG_Grid *pResiduals = Parameters("RESIDUALS" )->asGrid(); CSG_Grid *pVariance = Parameters("VARIANCE" )->asGrid(); //----------------------------------------------------- if( !pResiduals ) { pResiduals = pPrediction; } //----------------------------------------------------- SG_RUN_MODULE_ExitOnError("statistics_regression", 1, // Multiple Regression Analysis (Points and Predictor Grids) SG_MODULE_PARAMETER_SET("PREDICTORS", Parameters("PREDICTORS")) && SG_MODULE_PARAMETER_SET("POINTS" , Parameters("POINTS" )) && SG_MODULE_PARAMETER_SET("ATTRIBUTE" , Parameters("FIELD" )) && SG_MODULE_PARAMETER_SET("INFO_COEFF", Parameters("INFO_COEFF")) && SG_MODULE_PARAMETER_SET("INFO_MODEL", Parameters("INFO_MODEL")) && SG_MODULE_PARAMETER_SET("INFO_STEPS", Parameters("INFO_STEPS")) && SG_MODULE_PARAMETER_SET("RESAMPLING", Parameters("RESAMPLING")) && SG_MODULE_PARAMETER_SET("COORD_X" , Parameters("COORD_X" )) && SG_MODULE_PARAMETER_SET("COORD_Y" , Parameters("COORD_Y" )) && SG_MODULE_PARAMETER_SET("INTERCEPT" , Parameters("INTERCEPT" )) && SG_MODULE_PARAMETER_SET("METHOD" , Parameters("METHOD" )) && SG_MODULE_PARAMETER_SET("P_VALUE" , Parameters("P_VALUE" )) && SG_MODULE_PARAMETER_SET("REGRESSION", pRegression) && SG_MODULE_PARAMETER_SET("RESIDUALS" , &Points ) ); //----------------------------------------------------- Process_Set_Text(m_OK.Get_Name()); m_OK.Set_Manager(NULL); if( !m_OK.Set_Parameter("POINTS" , &Points) || !m_OK.Set_Parameter("FIELD" , 2) // residual || !m_OK.Set_Parameter("LOG" , Parameters("LOG" )) || !m_OK.Set_Parameter("BLOCK" , Parameters("BLOCK" )) || !m_OK.Set_Parameter("DBLOCK" , Parameters("DBLOCK" )) || !m_OK.Set_Parameter("SEARCH_RANGE" , Parameters("SEARCH_RANGE" )) || !m_OK.Set_Parameter("SEARCH_RADIUS" , Parameters("SEARCH_RADIUS" )) || !m_OK.Set_Parameter("SEARCH_POINTS_ALL", Parameters("SEARCH_POINTS_ALL")) || !m_OK.Set_Parameter("SEARCH_POINTS_MIN", Parameters("SEARCH_POINTS_MIN")) || !m_OK.Set_Parameter("SEARCH_POINTS_MAX", Parameters("SEARCH_POINTS_MAX")) || !m_OK.Set_Parameter("SEARCH_DIRECTION" , Parameters("SEARCH_DIRECTION" )) || !m_OK.Set_Parameter("TARGET_DEFINITION", 1) // grid or grid system || !m_OK.Set_Parameter("PREDICTION" , pResiduals) || !m_OK.Set_Parameter("VARIANCE" , pVariance ) || (!SG_UI_Get_Window_Main() && ( // saga_cmd !m_OK.Set_Parameter("VAR_MAXDIST" , Parameters("VAR_MAXDIST" )) || !m_OK.Set_Parameter("VAR_NCLASSES" , Parameters("VAR_NCLASSES" )) || !m_OK.Set_Parameter("VAR_NSKIP" , Parameters("VAR_NSKIP" )) || !m_OK.Set_Parameter("VAR_MODEL" , Parameters("VAR_MODEL" )))) ) { Error_Set(CSG_String::Format(SG_T("%s [%s].[%s]"), _TL("could not initialize tool"), SG_T("statistics_regression"), m_OK.Get_Name().c_str())); return( false ); } if( !m_OK.Execute() ) { Error_Set(CSG_String::Format(SG_T("%s [%s].[%s]"), _TL("could not execute tool"), SG_T("statistics_regression"), m_OK.Get_Name().c_str()));\ return( false ); } //----------------------------------------------------- #pragma omp parallel for for(int y=0; y<Get_NY(); y++) { for(int x=0; x<Get_NX(); x++) { if( pRegression->is_NoData(x, y) || pResiduals->is_NoData(x, y) ) { pPrediction->Set_NoData(x, y); } else { pPrediction->Add_Value(x, y, pRegression->asDouble(x, y) + pResiduals->asDouble(x, y)); } } } //----------------------------------------------------- pRegression->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Regression"))); pPrediction->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Prediction"))); if( Parameters("RESIDUALS")->asGrid() ) { pResiduals->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Residuals"))); } if( pVariance ) { pVariance ->Set_Name(CSG_String::Format("%s.%s [%s]", Parameters("POINTS")->asGrid()->Get_Name(), Parameters("FIELD")->asString(), _TL("Quality"))); } //----------------------------------------------------- return( true ); }
inline Field::Points Field::getPoints() const { return Points(m_points.begin(), m_points.end()); }