Beispiel #1
0
  Array* Time::calculate_decompose(STATE) {
    if(!decomposed_->nil_p()) return decomposed_;

    struct tm64 tm = get_tm();

    /* update Time::TM_FIELDS when changing order of fields */
    Array* ary = Array::create(state, 11);
    ary->set(state, 0, Integer::from(state, tm.tm_sec));
    ary->set(state, 1, Integer::from(state, tm.tm_min));
    ary->set(state, 2, Integer::from(state, tm.tm_hour));
    ary->set(state, 3, Integer::from(state, tm.tm_mday));
    ary->set(state, 4, Integer::from(state, tm.tm_mon + 1));
    ary->set(state, 5, Integer::from(state, tm.tm_year));
    ary->set(state, 6, Integer::from(state, tm.tm_wday));
    ary->set(state, 7, Integer::from(state, tm.tm_yday + 1));
    ary->set(state, 8, RBOOL(tm.tm_isdst));

    if (zone_->nil_p()) {
      if(offset_->nil_p() && tm.tm_zone) {
        zone(state, locale_string(state, tm.tm_zone));
      } else {
        zone(state, nil<String>());
      }
    }
    ary->set(state, 9, zone());

    // Cache it.
    decomposed(state, ary);
    return ary;
  }
Beispiel #2
0
Array* Time::calculate_decompose(STATE, Object* use_gmt) {
    if(!decomposed_->nil_p()) return decomposed_;

    time_t seconds = seconds_;
    struct tm tm;

    if(RTEST(use_gmt)) {
        gmtime_r(&seconds, &tm);
    } else {
        tzset();
        localtime_r(&seconds, &tm);
    }

    /* update Time::TM_FIELDS when changing order of fields */
    Array* ary = Array::create(state, 11);
    ary->set(state, 0, Integer::from(state, tm.tm_sec));
    ary->set(state, 1, Integer::from(state, tm.tm_min));
    ary->set(state, 2, Integer::from(state, tm.tm_hour));
    ary->set(state, 3, Integer::from(state, tm.tm_mday));
    ary->set(state, 4, Integer::from(state, tm.tm_mon + 1));
    ary->set(state, 5, Integer::from(state, tm.tm_year + 1900));
    ary->set(state, 6, Integer::from(state, tm.tm_wday));
    ary->set(state, 7, Integer::from(state, tm.tm_yday + 1));
    ary->set(state, 8, tm.tm_isdst ? Qtrue : Qfalse);

#ifdef HAVE_STRUCT_TM_TM_ZONE
    ary->set(state, 9, String::create(state, tm.tm_zone));
#else
    ary->set(state, 9, Qnil);
#endif

    // Cache it.
    decomposed(state, ary);
    return ary;
}
Beispiel #3
0
void woo::Volumetric::computePrincipalAxes(const Real& M, const Vector3r& Sg, const Matrix3r& Ig, Vector3r& pos, Quaternionr& ori, Vector3r& inertia){
	assert(M>0); // LOG_TRACE("M=\n"<<M<<"\nIg=\n"<<Ig<<"\nSg=\n"<<Sg);
	// clump's centroid
	pos=Sg/M;
	// this will calculate translation only, since rotation is zero
	Matrix3r Ic_orientG=inertiaTensorTranslate(Ig, -M /* negative mass means towards centroid */, pos); // inertia at clump's centroid but with world orientation
	//LOG_TRACE("Ic_orientG=\n"<<Ic_orientG);
	Ic_orientG(1,0)=Ic_orientG(0,1); Ic_orientG(2,0)=Ic_orientG(0,2); Ic_orientG(2,1)=Ic_orientG(1,2); // symmetrize
	Eigen::SelfAdjointEigenSolver<Matrix3r> decomposed(Ic_orientG);
	const Matrix3r& R_g2c(decomposed.eigenvectors());
	//cerr<<"R_g2c:"<<endl<<R_g2c<<endl;
	// has NaNs for identity matrix??
	//LOG_TRACE("R_g2c=\n"<<R_g2c);
	// set quaternion from rotation matrix
	ori=Quaternionr(R_g2c); ori.normalize();
	inertia=decomposed.eigenvalues();
}
Beispiel #4
0
static bool decomposedShaping(FT_Face face, HB_Script script, const QChar &ch)
{
    QString uc = QString().append(ch);
    Shaper shaper(face, script, uc);

    uc = uc.normalized(QString::NormalizationForm_D);
    Shaper decomposed(face, script, uc);

    if( shaper.shaper_item.num_glyphs != decomposed.shaper_item.num_glyphs )
        goto error;

    for (unsigned int i = 0; i < shaper.shaper_item.num_glyphs; ++i) {
        if ((shaper.shaper_item.glyphs[i]&0xffffff) != (decomposed.shaper_item.glyphs[i]&0xffffff))
            goto error;
    }
    return true;
 error:
    QString str = "";
    int i = 0;
    while (i < uc.length()) {
        str += QString("%1 ").arg(uc[i].unicode(), 4, 16);
        ++i;
    }
    qDebug("%s: decomposedShaping of char %4x failed\n    decomposedString: %s\n   nglyphs=%d, decomposed nglyphs %d",
           face->family_name,
           ch.unicode(), str.toLatin1().data(),
           shaper.shaper_item.num_glyphs,
           decomposed.shaper_item.num_glyphs);

    str = "";
    i = 0;
    while (i < shaper.shaper_item.num_glyphs) {
        str += QString("%1 ").arg(shaper.shaper_item.glyphs[i], 4, 16);
        ++i;
    }
    qDebug("    composed glyph result   = %s", str.toLatin1().constData());
    str = "";
    i = 0;
    while (i < decomposed.shaper_item.num_glyphs) {
        str += QString("%1 ").arg(decomposed.shaper_item.glyphs[i], 4, 16);
        ++i;
    }
    qDebug("    decomposed glyph result = %s", str.toLatin1().constData());
    return false;
}
Beispiel #5
0
static bool decomposedShaping( const QFont &f, const QChar &ch)
{
    QString str = QString().append(ch);
    QTextLayout layout(str, f);
    QTextEngine *e = layout.d;
    e->itemize();
    e->shape(0);

    QTextLayout decomposed(str.normalized(QString::NormalizationForm_D), f);
    QTextEngine *de = decomposed.d;
    de->itemize();
    de->shape(0);

    if( e->layoutData->items[0].num_glyphs != de->layoutData->items[0].num_glyphs )
        goto error;

    for (int i = 0; i < e->layoutData->items[0].num_glyphs; ++i) {
        if ((e->layoutData->glyphLayout.glyphs[i] & 0xffffff) != (de->layoutData->glyphLayout.glyphs[i] & 0xffffff))
            goto error;
    }
    return true;
 error:
    qDebug("%s: decomposedShaping of char %4x failed, nglyphs=%d, decomposed nglyphs %d",
           f.family().toLatin1().constData(),
           ch.unicode(),
           e->layoutData->items[0].num_glyphs,
           de->layoutData->items[0].num_glyphs);

    str = "";
    int i = 0;
    while (i < e->layoutData->items[0].num_glyphs) {
        str += QString("%1 ").arg(e->layoutData->glyphLayout.glyphs[i], 4, 16);
        ++i;
    }
    qDebug("    composed glyph result   = %s", str.toLatin1().constData());
    str = "";
    i = 0;
    while (i < de->layoutData->items[0].num_glyphs) {
        str += QString("%1 ").arg(de->layoutData->glyphLayout.glyphs[i], 4, 16);
        ++i;
    }
    qDebug("    decomposed glyph result = %s", str.toLatin1().constData());
    return false;
}
Beispiel #6
0
  Array* Time::calculate_decompose(STATE, Object* use_gmt) {
    if(!decomposed_->nil_p()) return decomposed_;

    time_t seconds = seconds_;
    struct tm tm = {0};

    if(CBOOL(use_gmt)) {
      gmtime_r(&seconds, &tm);
    } else {
      tzset();
      localtime_r(&seconds, &tm);
    }

    /* update Time::TM_FIELDS when changing order of fields */
    Array* ary = Array::create(state, 11);
    ary->set(state, 0, Integer::from(state, tm.tm_sec));
    ary->set(state, 1, Integer::from(state, tm.tm_min));
    ary->set(state, 2, Integer::from(state, tm.tm_hour));
    ary->set(state, 3, Integer::from(state, tm.tm_mday));
    ary->set(state, 4, Integer::from(state, tm.tm_mon + 1));
    ary->set(state, 5, Integer::from(state, tm.tm_year + 1900));
    ary->set(state, 6, Integer::from(state, tm.tm_wday));
    ary->set(state, 7, Integer::from(state, tm.tm_yday + 1));
    ary->set(state, 8, tm.tm_isdst ? cTrue : cFalse);

    const char* tmzone = timezone_extended(&tm);
    if(tmzone) {
      ary->set(state, 9, String::create(state, tmzone));
    } else {
      ary->set(state, 9, cNil);
    }

    // Cache it.
    decomposed(state, ary);
    return ary;
  }
int main(void)
{
	int N = 100;
	decomposed(N);
	return 0;
}