Пример #1
0
// returns non-NULL pointer on success
    void * win_alloc(long reverse) {
        try {

            // window
            GoslVTK::Win * win = new GoslVTK::Win();
            win->Init();
            win->SetViewDefault(reverse>0);

            // success
            return win;
        }

        // fail
        GOSLVTK_CATCH;
        return NULL;
    }
Пример #2
0
// returns 0 on success
    int scene_run(
        void       * input_win,
        double       axeslen,
        long         hydroline,
        long         reverse,
        long         fullaxes,
        long         withplanes,
        long         interact,
        long         saveeps,
        long         savepng,
        long         pngmag,
        char const * fnk,
        char const * lblX,
        char const * lblY,
        char const * lblZ,
        long         lblSz,
        double     * lblClr) {

        try {

            // window
            GoslVTK::Win * win = (GoslVTK::Win*) input_win;

            // axes
            GoslVTK::Axes axe;
            axe.Init(axeslen, hydroline>0, reverse>0, fullaxes>0);
            axe.SetLabels(lblX, lblY, lblZ, lblClr[0], lblClr[1], lblClr[2], lblSz);
            axe.AddTo(*win);

            // auxiliary planes
            GoslVTK::Plane pxy, pyz, pzx;
            if (withplanes > 0) {
                double al = axeslen;
                double dat[][4][3] = {
                    { {-al,-al,0}, {al,-al,0}, {-al,al,0}, {0,0,1} }, // ori, pt1, pt2, normal
                    { {0,-al,-al}, {0,al,-al}, {0,-al,al}, {1,0,0} },
                    { {-al,0,-al}, {-al,0,al}, {al,0,-al}, {0,1,0} },
                };
                pxy.Init(dat[0][0], dat[0][1], dat[0][2], dat[0][3]);
                pyz.Init(dat[1][0], dat[1][1], dat[1][2], dat[1][3]);
                pzx.Init(dat[2][0], dat[2][1], dat[2][2], dat[2][3]);
                pxy.SetColor(1, 0.5, 0, 0.05);
                pyz.SetColor(1, 0.5, 0, 0.05);
                pzx.SetColor(1, 0.5, 0, 0.05);
                pxy.AddTo(*win);
                pyz.AddTo(*win);
                pzx.AddTo(*win);
            }

            // interact
            if (interact > 0) {
                win->Show();
            }

            // save figure
            if (savepng > 0) {
                bool large = (pngmag > 0 ? true : false);
                win->WritePNG(fnk, large, pngmag);
            }
            if (saveeps > 0) {
                win->WriteEPS(fnk);
            }

            // success
            return 0;
        }

        // fail
        GOSLVTK_CATCH;
        return 1;
    }