Beispiel #1
0
KValueRef KObject::CallNS(const char *name, const ValueList& args)
{
    KValueRef callable_value = GetNS(name);
    if (callable_value->IsUndefined()) {
        return callable_value;
    }

    if (!callable_value->IsMethod()) {
        return Value::Undefined;
    }

    return callable_value->ToMethod()->Call(args);
}
Beispiel #2
0
/*
double stlgh;
double GetH(const Point3d& p, double x)
{
  return stlgh;//+0.5)*(x+0.5);
}
*/
STLLine* STLLine :: Mesh(const Array<Point<3> >& ap,
                         Array<Point3d>& mp, double ghi,
                         class Mesh& mesh) const
{
    static int timer1a = NgProfiler::CreateTimer ("mesh stl-line 1a");
    static int timer1b = NgProfiler::CreateTimer ("mesh stl-line 1b");
    static int timer2 = NgProfiler::CreateTimer ("mesh stl-line 2");
    static int timer3 = NgProfiler::CreateTimer ("mesh stl-line 3");

    NgProfiler::StartTimer (timer1a);

    STLLine* line = new STLLine(geometry);

    //stlgh = ghi; //uebergangsloesung!!!!

    double len = GetLength(ap);
    double inthl = 0; //integral of 1/h
    double dist = 0;
    double h;
    int ind;
    Point3d p;

    Box<3> bbox;
    GetBoundingBox (ap, bbox);
    double diam = bbox.Diam();

    double minh = mesh.LocalHFunction().GetMinH (bbox.PMin(), bbox.PMax());

    double maxseglen = 0;
    for (int i = 1; i <= GetNS(); i++)
        maxseglen = max2 (maxseglen, GetSegLen (ap, i));

    int nph = 10+int(maxseglen / minh); //anzahl der integralauswertungen pro segment

    Array<double> inthi(GetNS()*nph);
    Array<double> curvelen(GetNS()*nph);

    NgProfiler::StopTimer (timer1a);
    NgProfiler::StartTimer (timer1b);


    for (int i = 1; i <= GetNS(); i++)
    {
        //double seglen = GetSegLen(ap,i);
        for (int j = 1; j <= nph; j++)
        {
            p = GetPointInDist(ap,dist,ind);
            //h = GetH(p,dist/len);
            h = mesh.GetH(p);


            dist += GetSegLen(ap,i)/(double)nph;

            inthl += GetSegLen(ap,i)/nph/(h);
            inthi.Elem((i-1)*nph+j) = GetSegLen(ap,i)/nph/h;
            curvelen.Elem((i-1)*nph+j) = GetSegLen(ap,i)/nph;
        }
    }


    int inthlint = int(inthl+1);

    if ( (inthlint < 3) && (StartP() == EndP()))
    {
        inthlint = 3;
    }
    if ( (inthlint == 1) && ShouldSplit())
    {
        inthlint = 2;
    }

    double fact = inthl/(double)inthlint;
    dist = 0;
    int j = 1;


    p = ap.Get(StartP());
    int pn = AddPointIfNotExists(mp, p, 1e-10*diam);

    int segn = 1;
    line->AddPoint(pn);
    line->AddLeftTrig(GetLeftTrig(segn));
    line->AddRightTrig(GetRightTrig(segn));
    line->AddDist(dist);

    NgProfiler::StopTimer (timer1b);
    NgProfiler::StartTimer (timer2);

    inthl = 0; //restart each meshseg
    for (int i = 1; i <= inthlint; i++)
    {
        while (inthl < 1.000000001 && j <= inthi.Size())
        {
            inthl += inthi.Get(j)/fact;
            dist += curvelen.Get(j);
            j++;
        }

        //went too far:
        j--;
        double tofar = (inthl - 1)/inthi.Get(j);
        inthl -= tofar*inthi.Get(j);
        dist -= tofar*curvelen.Get(j)*fact;

        if (i == inthlint && fabs(dist - len) >= 1E-8)
        {
            PrintSysError("meshline failed!!!");
        }

        if (i != inthlint)
        {
            p = GetPointInDist(ap,dist,ind);
            pn = AddPointIfNotExists(mp, p, 1e-10*diam);
            segn = ind;
            line->AddPoint(pn);
            line->AddLeftTrig(GetLeftTrig(segn));
            line->AddRightTrig(GetRightTrig(segn));
            line->AddDist(dist);
        }

        inthl = tofar*inthi.Get(j);
        dist += tofar*curvelen.Get(j)*fact;
        j++;
    }

    NgProfiler::StopTimer (timer2);
    NgProfiler::StartTimer (timer3);


    p = ap.Get(EndP());
    pn = AddPointIfNotExists(mp, p, 1e-10*diam);
    segn = GetNS();
    line->AddPoint(pn);
    line->AddLeftTrig(GetLeftTrig(segn));
    line->AddRightTrig(GetRightTrig(segn));
    line->AddDist(dist);

    for (int ii = 1; ii <= line->GetNS(); ii++)
    {
        int p1, p2;
        line->GetSeg(ii,p1,p2);
    }
    /*
    (*testout) << "line, " << ap.Get(StartP()) << "-" << ap.Get(EndP())
         << " len = " << Dist (ap.Get(StartP()), ap.Get(EndP())) << endl;
    */

    NgProfiler::StopTimer (timer3);

    return line;
}