Пример #1
0
//---------------------------------------------------------
void NDG3D::Normals3D()
//---------------------------------------------------------
{
  // function [nx, ny, nz, sJ] = Normals3D()
  // Purpose : Compute outward pointing normals at
  //	    elements faces as well as surface Jacobians

  GeometricFactors3D();

  // interpolate geometric factors to face nodes
  DMat frx=rx(Fmask,All),  fsx=sx(Fmask,All),  ftx=tx(Fmask,All);
  DMat fry=ry(Fmask,All),  fsy=sy(Fmask,All),  fty=ty(Fmask,All);
  DMat frz=rz(Fmask,All),  fsz=sz(Fmask,All),  ftz=tz(Fmask,All);

  // build normals
  nx.resize(4*Nfp, K); ny.resize(4*Nfp, K); nz.resize(4*Nfp, K);
  Index1D fid1(1,Nfp), fid2(Nfp+1,2*Nfp), fid3(2*Nfp+1,3*Nfp), fid4(3*Nfp+1,4*Nfp);

  // face 1
  nx(fid1, All) = -ftx(fid1,All);
  ny(fid1, All) = -fty(fid1,All);
  nz(fid1, All) = -ftz(fid1,All);

  // face 2
  nx(fid2, All) = -fsx(fid2,All);
  ny(fid2, All) = -fsy(fid2,All);
  nz(fid2, All) = -fsz(fid2,All);

  // face 3
  nx(fid3, All) = frx(fid3,All) + fsx(fid3,All) + ftx(fid3,All);
  ny(fid3, All) = fry(fid3,All) + fsy(fid3,All) + fty(fid3,All);
  nz(fid3, All) = frz(fid3,All) + fsz(fid3,All) + ftz(fid3,All);

  // face 4
  nx(fid4, All) = -frx(fid4,All);
  ny(fid4, All) = -fry(fid4,All);
  nz(fid4, All) = -frz(fid4,All);

  // normalise
  sJ = sqrt(sqr(nx) + sqr(ny) + sqr(nz));
  
  nx.div_element(sJ); ny.div_element(sJ); nz.div_element(sJ);
  sJ.mult_element(J(Fmask, All));  //sJ=sJ.*J(Fmask(:),:);
}
Пример #2
0
GlyphLayout::GlyphLayout(JNIEnv *env, jcharArray unicodes, jint offset, jint count,
            jint flags, jdoubleArray fontTX, jdoubleArray devTX, jboolean isAntiAliased,
            jboolean usesFractionalMetrics, fontObject *fo)
  : fNumGlyphs(0), fScriptCount(0), fScriptMax(eDefaultStorage), fRightToLeft(false), fDevTX(env, devTX)
{
    if (JNU_IsNull(env, unicodes) ) {
        JNU_ThrowIllegalArgumentException(env,"Unicode array is NULL!");
        return;
    }

    jint max = env->GetArrayLength(unicodes);

    if (offset + count > max) {
        JNU_ThrowArrayIndexOutOfBoundsException(env,
                                        "chars [offset + count]");
        return;
    }

    // !!! check to see how layout should adapt to devTX.  Should it ignore devTX
    // and then adjust the information by devTX afterwards?  Then it would perhaps
    // get incorrectly hinted advance information by the strike.  But if it uses
    // devTX then the advance and position information needs to be normalized
    // before returning it to native.

    TX gtx(fDevTX);
    TX ftx(env, fontTX);
    gtx.concat(ftx);
    FontTransform tx(gtx.m00, gtx.m10, gtx.m01, gtx.m11);

    jfloat x = (jfloat)gtx.m02;
    jfloat y = (jfloat)gtx.m12;

	const jchar *theChars = (const jchar *) env->GetPrimitiveArrayCritical(unicodes, NULL);

	if (theChars != NULL) {
	    const jchar *oldChars = theChars; // theChars can get changed, save original
        if (flags != 0) {
            if ((flags & 0x0001) != 0) {
                fRightToLeft = true;
            }

            if ((flags & 0x0002) != 0) {
                theChars += offset;
                max -= offset;
                offset = 0;
            }

            if ((flags & 0x0004) != 0) {
                max = offset + count;
            }
        }

        if (fo->GetFormat() == kCompositeFontFormat) {
            Strike *strike = &fo->getStrike(tx, isAntiAliased, usesFractionalMetrics);
            UInt32 *glyphs = new UInt32[count];
            ScriptRun scriptRun(theChars, offset, count);
            le_uint32 slot;

            charsToGlyphs(&theChars[offset], count, strike, glyphs);

            fScriptInfo = fScriptInfoBase;
            slot = glyphs[0] >> 24;

            while (scriptRun.next()) {
                le_int32 scriptStart = scriptRun.getScriptStart();
                le_int32 scriptEnd   = scriptRun.getScriptEnd();
                le_int32 scriptCode  = scriptRun.getScriptCode();

                le_int32 ch = scriptStart;
                while (ch < scriptEnd) {
                    while (ch < scriptEnd && slot == glyphs[ch - offset] >> 24) {
                        ch += 1;
                    }

                    if (fScriptCount >= fScriptMax) {
                        growScriptInfo();
                    }

                    fScriptInfo[fScriptCount].scriptStart = scriptStart;
                    fScriptInfo[fScriptCount].scriptCode  = scriptCode;
                    fScriptInfo[fScriptCount].scriptSlot  = slot;

                    fScriptCount += 1;

                    if (ch < scriptEnd) {
                        slot = glyphs[ch - offset] >> 24;
                        scriptStart = ch;
                    }
                }
            }

            delete[] glyphs;
            fScriptInfo[fScriptCount].scriptStart = scriptRun.getScriptEnd();
        } else {