void defiFill::print(FILE* f) const { int i, j; struct defiPoints points; if (hasLayer()) fprintf(f, "- LAYER %s", layerName()); if (layerMask()) fprintf(f, " + Mask %d", layerMask()); if (hasLayerOpc()) fprintf(f, " + OPC"); fprintf(f, "\n"); for (i = 0; i < numRectangles(); i++) { fprintf(f, " RECT %d %d %d %d\n", xl(i), yl(i), xh(i), yh(i)); } for (i = 0; i < numPolygons(); i++) { fprintf(f, " POLYGON "); points = getPolygon(i); for (j = 0; j < points.numPoints; j++) fprintf(f, "%d %d ", points.x[j], points.y[j]); fprintf(f, "\n"); } fprintf(f,"\n"); if (hasVia()) fprintf(f, "- VIA %s", viaName()); if (viaTopMask() || viaCutMask() || viaBottomMask()) { fprintf(f, " + MASK %d", viaTopMask(), viaCutMask(), viaBottomMask()); } if (hasViaOpc()) fprintf(f, " + OPC"); fprintf(f, "\n"); for (i = 0; i < numViaPts(); i++) { fprintf(f, " "); points = getViaPts(i); for (j = 0; j < points.numPoints; j++) fprintf(f, "%d %d ", points.x[j], points.y[j]); fprintf(f, "\n"); } fprintf(f,"\n"); }
void dlgReports::report_sign() { Document xl(App::theApp()->tmplPath() + "tmpl_sign.xlsx"); Worksheet *sh; // Лист "Финал" view --> viewReport_sign_total; xl.selectSheet("Финал"); sh = xl.currentWorksheet(); sh->write("A3", QString(xl.read("A3").toString()).arg(_dateA.toString("dd.MM.yyyy")).arg(_dateZ.toString("dd.MM.yyyy"))); sh->write("O4", QString(xl.read("O4").toString()).arg(_dateX.toString("dd.MM.yyyy"))); int r1_t(10); int r2_t(0); QString q_total = QString("call p_Report_sign_total('%1','%2');") .arg(_dateA.toString("yyyy-MM-dd")) .arg(_dateZ.toString("yyyy-MM-dd")); queryToSheet(sh, q_total, r1_t, r2_t); r1_t++; sh->write(r2_t, 9, QString("=COUNT(I%1:I%2)").arg(r1_t).arg(r2_t - 1)); sh->write(r2_t,10, QString("=COUNT(J%1:J%2)").arg(r1_t).arg(r2_t - 1)); sh->write(r2_t,11, QString("=COUNT(K%1:K%2)").arg(r1_t).arg(r2_t - 1)); sh->write(r2_t,12, QString("=COUNT(L%1:L%2)").arg(r1_t).arg(r2_t - 1)); sh->write(r2_t,13, QString("=COUNT(M%1:M%2)").arg(r1_t).arg(r2_t - 1)); // Лист "Свод" view --> viewReport_sign_stat; xl.selectSheet("Свод"); sh = xl.currentWorksheet(); sh->write("A3", QString(xl.read("A3").toString()).arg(_dateA.toString("dd.MM.yyyy")).arg(_dateZ.toString("dd.MM.yyyy"))); int r1_s(5); int r2_s(0); QString q_stat = QString("call p_Report_sign_stat('%1','%2');") .arg(_dateA.toString("yyyy-MM-dd")) .arg(_dateZ.toString("yyyy-MM-dd")); queryToSheet(sh, q_stat, r1_s, r2_s); r1_s++; sh->write(r2_s, 8, QString("=SUM(H%1:H%2)").arg(r1_s).arg(r2_s - 1)); xl.selectSheet("Финал"); save_report(xl, "sign"); qDebug() << "report_sign ok!"; }
template <> DLL_HEADER void Ngx_Mesh :: ElementTransformation<2,2> (int elnr, const double * xi, double * x, double * dxdxi) const { Point<2> xl(xi[0], xi[1]); Point<3> xg; Mat<3,2> dx; mesh->GetCurvedElements().CalcSurfaceTransformation (xl, elnr, xg, dx); if (x) for (int i = 0; i < 2; i++) x[i] = xg(i); if (dxdxi) for (int i=0; i<2; i++) { dxdxi[2*i] = dx(i,0); dxdxi[2*i+1] = dx(i,1); } }
static void print_all_info(int fd, apm_info_t aip, int bioscall_available) { struct apm_bios_arg args; int apmerr; const char *line_msg[] = { "off-line", "on-line" , "backup power"}; printf("APM version: %d.%d\n", aip->ai_major, aip->ai_minor); printf("APM Management: %s\n", aip->ai_status ? "Enabled" : "Disabled"); printf("AC Line status: "); if (aip->ai_acline == APM_UNKNOWN) printf("unknown\n"); else if (aip->ai_acline > 2) printf("invalid value (0x%x)\n", aip->ai_acline); else printf("%s\n", line_msg[aip->ai_acline]); print_batt_stat(aip->ai_batt_stat); print_batt_life(aip->ai_batt_life); print_batt_time(aip->ai_batt_time); if (aip->ai_infoversion >= 1) { printf("Number of batteries: "); if (aip->ai_batteries == ~0U) printf("unknown\n"); else { u_int i; struct apm_pwstatus aps; printf("%d\n", aip->ai_batteries); for (i = 0; i < aip->ai_batteries; ++i) { bzero(&aps, sizeof(aps)); aps.ap_device = PMDV_BATT0 + i; if (ioctl(fd, APMIO_GETPWSTATUS, &aps) == -1) continue; printf("Battery %d:\n", i); if (aps.ap_batt_flag & APM_BATT_NOT_PRESENT) { printf("not present\n"); continue; } printf("\t"); print_batt_stat(aps.ap_batt_stat); printf("\t"); print_batt_life(aps.ap_batt_life); printf("\t"); print_batt_time(aps.ap_batt_time); } } } if (bioscall_available) { /* * try to get the suspend timer */ bzero(&args, sizeof(args)); args.eax = (APM_BIOS) << 8 | APM_RESUMETIMER; args.ebx = PMDV_APMBIOS; args.ecx = 0x0001; if (ioctl(fd, APMIO_BIOS, &args)) { printf("Resume timer: unknown\n"); } else { apmerr = APMERR(args.eax); if (apmerr == 0x0d || apmerr == 0x86) printf("Resume timer: disabled\n"); else if (apmerr) warnx( "failed to get the resume timer: APM error0x%x", apmerr); else { /* * OK. We have the time (all bcd). * CH - seconds * DH - hours * DL - minutes * xh(SI) - month (1-12) * xl(SI) - day of month (1-31) * DI - year */ struct tm tm; char buf[1024]; time_t t; tm.tm_sec = bcd2int(xh(args.ecx)); tm.tm_min = bcd2int(xl(args.edx)); tm.tm_hour = bcd2int(xh(args.edx)); tm.tm_mday = bcd2int(xl(args.esi)); tm.tm_mon = bcd2int(xh(args.esi)) - 1; tm.tm_year = bcd2int(args.edi) - 1900; if (cmos_wall) t = mktime(&tm); else t = timegm(&tm); if (t != -1) { tm = *localtime(&t); strftime(buf, sizeof(buf), "%c", &tm); printf("Resume timer: %s\n", buf); } else printf("Resume timer: unknown\n"); } } /* * Get the ring indicator resume state */ bzero(&args, sizeof(args)); args.eax = (APM_BIOS) << 8 | APM_RESUMEONRING; args.ebx = PMDV_APMBIOS; args.ecx = 0x0002; if (ioctl(fd, APMIO_BIOS, &args) == 0) { printf("Resume on ring indicator: %sabled\n", args.ecx ? "en" : "dis"); } } if (aip->ai_infoversion >= 1) { if (aip->ai_capabilities == 0xff00) return; printf("APM Capabilities:\n"); if (aip->ai_capabilities & 0x01) printf("\tglobal standby state\n"); if (aip->ai_capabilities & 0x02) printf("\tglobal suspend state\n"); if (aip->ai_capabilities & 0x04) printf("\tresume timer from standby\n"); if (aip->ai_capabilities & 0x08) printf("\tresume timer from suspend\n"); if (aip->ai_capabilities & 0x10) printf("\tRI resume from standby\n"); if (aip->ai_capabilities & 0x20) printf("\tRI resume from suspend\n"); if (aip->ai_capabilities & 0x40) printf("\tPCMCIA RI resume from standby\n"); if (aip->ai_capabilities & 0x80) printf("\tPCMCIA RI resume from suspend\n"); } }
void ElasticForceBeamColumn2d::compSectionDisplacements(Vector sectionCoords[], Vector sectionDispls[]) const { // get basic displacements and increments static Vector ub(NEBD); ub = crdTransf->getBasicTrialDisp(); double L = crdTransf->getInitialLength(); // get integration point positions and weights // const Matrix &xi_pt = quadRule.getIntegrPointCoords(numSections); // get integration point positions and weights static double xi_pts[maxNumSections]; beamIntegr->getSectionLocations(numSections, L, xi_pts); // setup Vandermode and CBDI influence matrices int i; double xi; // get CBDI influence matrix Matrix ls(numSections, numSections); getCBDIinfluenceMatrix(numSections, xi_pts, L, ls); // get section curvatures Vector kappa(numSections); // curvature static Vector vs; // section deformations for (i=0; i<numSections; i++) { // THIS IS VERY INEFFICIENT ... CAN CHANGE LATER int sectionKey = 0; const ID &code = sections[i]->getType(); int ii; for (ii = 0; ii < code.Size(); ii++) if (code(ii) == SECTION_RESPONSE_MZ) { sectionKey = ii; break; } if (ii == code.Size()) { opserr << "FATAL NLBeamColumn2d::compSectionDispls - section does not provide Mz response\n"; exit(-1); } // get section deformations vs = sections[i]->getSectionDeformation(); kappa(i) = vs(sectionKey); } Vector w(numSections); static Vector xl(NDM), uxb(NDM); static Vector xg(NDM), uxg(NDM); // w = ls * kappa; w.addMatrixVector (0.0, ls, kappa, 1.0); for (i=0; i<numSections; i++) { xi = xi_pts[i]; xl(0) = xi * L; xl(1) = 0; // get section global coordinates sectionCoords[i] = crdTransf->getPointGlobalCoordFromLocal(xl); // compute section displacements uxb(0) = xi * ub(0); // consider linear variation for axial displacement. CHANGE LATER!!!!!!!!!! uxb(1) = w(i); // get section displacements in global system sectionDispls[i] = crdTransf->getPointGlobalDisplFromBasic(xi, uxb); } return; }
virtual bool configure(ResourceFinder &rf) { Time::turboBoost(); fprintf(stderr, "Getting projections\n"); Matrix PiRight; Bottle b; b = rf.findGroup("CAMERA_CALIBRATION_RIGHT"); //fprintf(stderr, "CAMERA_CALIBRATION_RIGHT contains: %s\n", b.toString().c_str()); if (getProjectionMatrix(b, PiRight) == 0) { fprintf(stderr, "CAMERA_CALIBRATION_RIGHT was missing some params\n"); return false; } else { fprintf(stderr, "Working with RightProjection \n"); for (int i=0; i < PiRight.rows(); i++) fprintf(stderr, "%s\n", PiRight.getRow(i).toString().c_str()); } Matrix PiLeft; b = rf.findGroup("CAMERA_CALIBRATION_LEFT"); //fprintf(stderr, "CAMERA_CALIBRATION_LEFT contains: %s\n", b.toString().c_str()); if (getProjectionMatrix(b, PiLeft) == 0) { fprintf(stderr, "CAMERA_CALIBRATION_LEFT was missing some params\n"); return false; } else { fprintf(stderr, "Working with LeftProjection \n"); for (int i=0; i < PiLeft.rows(); i++) fprintf(stderr, "%s\n", PiLeft.getRow(i).toString().c_str()); } int period=50; if (rf.check("period")) period=rf.find("period").asInt(); bool enableKalman=false; if (rf.check("kalman")) enableKalman=true; string ctrlName=rf.find("name").asString().c_str(); string robotName=rf.find("robot").asString().c_str(); fprintf(stderr, "Initializing eT\n"); eT=new eyeTriangulation(rf, PiLeft, PiRight, enableKalman, period, ctrlName, robotName); Vector xr(3); xr(0)=PiRight(0,2); xr(1)=PiRight(1,2); xr(2)=1.0; Vector xl(3); xl(0)=PiLeft(0,2); xl(1)=PiLeft(1,2); xl(2)=1.0; eT->xInit(xl, xr); if (rf.check("const")) eT->xSetConstant(xl, xr); eT->start(); string rpcPortName="/"+ctrlName+"/rpc"; rpcPort.open(rpcPortName.c_str()); attach(rpcPort); return true; }
void triangulatePoints(InputArrayOfArrays _points2d, InputArrayOfArrays _projection_matrices, OutputArray _points3d) { // check size_t nviews = (unsigned) _points2d.total(); CV_Assert(nviews >= 2 && nviews == _projection_matrices.total()); // inputs size_t n_points; vector<Mat_<double> > points2d(nviews); vector<Matx34d> projection_matrices(nviews); { vector<Mat> points2d_tmp; _points2d.getMatVector(points2d_tmp); n_points = points2d_tmp[0].cols; vector<Mat> projection_matrices_tmp; _projection_matrices.getMatVector(projection_matrices_tmp); // Make sure the dimensions are right for(size_t i=0; i<nviews; ++i) { CV_Assert(points2d_tmp[i].rows == 2 && points2d_tmp[i].cols == n_points); if (points2d_tmp[i].type() == CV_64F) points2d[i] = points2d_tmp[i]; else points2d_tmp[i].convertTo(points2d[i], CV_64F); CV_Assert(projection_matrices_tmp[i].rows == 3 && projection_matrices_tmp[i].cols == 4); if (projection_matrices_tmp[i].type() == CV_64F) projection_matrices[i] = projection_matrices_tmp[i]; else projection_matrices_tmp[i].convertTo(projection_matrices[i], CV_64F); } } // output _points3d.create(3, n_points, CV_64F); cv::Mat points3d = _points3d.getMat(); // Two view if( nviews == 2 ) { const Mat_<double> &xl = points2d[0], &xr = points2d[1]; const Matx34d & Pl = projection_matrices[0]; // left matrix projection const Matx34d & Pr = projection_matrices[1]; // right matrix projection // triangulate for( unsigned i = 0; i < n_points; ++i ) { Vec3d point3d; triangulateDLT( Vec2d(xl(0,i), xl(1,i)), Vec2d(xr(0,i), xr(1,i)), Pl, Pr, point3d ); for(char j=0; j<3; ++j) points3d.at<double>(j, i) = point3d[j]; } } else if( nviews > 2 ) { // triangulate for( unsigned i=0; i < n_points; ++i ) { // build x matrix (one point per view) Mat_<double> x( 2, nviews ); for( unsigned k=0; k < nviews; ++k ) { points2d.at(k).col(i).copyTo( x.col(k) ); } Vec3d point3d; nViewTriangulate( x, projection_matrices, point3d ); for(char j=0; j<3; ++j) points3d.at<double>(j, i) = point3d[j]; } } }