Example #1
0
void MainFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
{
    wxFileDialog dialog (this, _T(""), _T(""), _T(""), _T("STL files (*.STL)|*.stl|XML files (*.XML)|*.xml"));

    dialog.SetFilename("D.STL");

    if (dialog.ShowModal() == wxID_OK)
    {
        wxString fn(dialog.GetPath().c_str());
        if (fn.Matches("*.xml"))
        {

            this->aniframe->UpdateControls();
        }
        else
        {
            // make the surface
            const char *fn = dialog.GetPath().c_str();
            GSTsurface *gstsurface = new GSTsurface();
            gst->gstees.push_back(gstsurface);
            gstsurface->LoadSTL(fn);
            gstsurface->AddToRenderer(&gst->ren1);

            // make a bounding box for it
            gst->MakeRectBoundary(gstsurface->xrg, gstsurface->yrg, gstsurface->zrg.hi + 1.0);
        }

        MaximizeView();

        gst->renWin->Render();
        UpdateActors();
        UpdateAnimate();
    }
}
Example #2
0
GSTsurface* MainFrame::SelectedSurface() const
{
    int ix = 0;

    while (ix < gst->gstees.size())
    {
        GSTbase *gb = gst->gstees[ix];
        GSTsurface *gstsurf = dynamic_cast<GSTsurface *>(gb);
        if ((gstsurf != NULL) && (gstsurf->GetVisibility()))
            return gstsurf;

        ++ix;
    }

    return NULL;
}
Example #3
0
void MainFrame::OnMachiningAreaclear(wxCommandEvent& WXUNUSED(event) )
{
    double cr = 3.;
    double fr = 0.;
    double sd = 15.;
    double si = cr / 2.;
    if (RunCoreRoughDlg(cr, fr, sd, si))
    {
        GSTsurface *gstsurf = SelectedSurface();
        GSTtoolpath *gstbound = SelectedBoundary();
        ASSERT((gstsurf != NULL) && (gstbound != NULL));

        if (!(gstsurf || gstbound))
            return;

        MachineParams params;
        // linking parameters
        params.leadoffdz = 0.1;
        params.leadofflen = 1.1;
        params.leadoffrad = 2.0;
        params.retractzheight = gstsurf->zrg.hi + 5.0;
        params.leadoffsamplestep = 0.6;

        // cutting parameters
        params.toolcornerrad = cr;
        params.toolflatrad = fr;
        params.samplestep = 0.4;
        params.stepdown = sd;
        params.clearcuspheight = sd / 3.0;

        // weave parameters
        params.triangleweaveres = 0.51;
        params.flatradweaveres = 0.71;

        // stearing parameters
        // fixed values controlling the step-forward of the tool and
        // changes of direction.
        params.dchangright = 0.17;
        params.dchangrightoncontour = 0.37;
        params.dchangleft = -0.41;
        params.dchangefreespace = -0.6;
        params.sidecutdisplch = 0.0;
        params.fcut = 1000;
        params.fretract = 5000;
        params.thintol = 0.0001;



        GSTtoolpath* gsttpath = new GSTtoolpath;
        gst->gstees.push_back(gsttpath);

        // define the empty surface
        SurfX sx(gstsurf->xrg.Inflate(2), gstsurf->yrg.Inflate(2), gstsurf->zrg);
        gstsurf->PushTrianglesIntoSurface(sx);
        sx.BuildComponents(); // compress thing

        ASSERT(gstbound->ftpaths.size() == 1);
        MakeCorerough(gsttpath->ftpaths, sx, gstbound->ftpaths[0], params);

        // write result to a file
        FILE* fpost = fopen("freesteel.tp", "w");
        ASSERT(fpost);
        PostProcess(fpost, gsttpath->ftpaths, params);
        fclose(fpost);


        gsttpath->toolshape = ToolShape(params.toolflatrad, params.toolcornerrad, params.toolcornerrad, params.toolcornerrad / 10.0);
        gsttpath->bound.Append(gstbound->ftpaths[0].pths);
        gsttpath->UpdateFromPax();
        gsttpath->AddToRenderer(&gst->ren1);

        UpdateActors();
        UpdateAnimate();
    }
}
Example #4
0
void FreesteelWindow::PushTrianglesIntoSurface(int ix, SurfX* sx)
{
	GSTsurface* surf = dynamic_cast<GSTsurface*>(gstees[ix]);
	ASSERT(surf != NULL);
	surf->PushTrianglesIntoSurface(*sx);
}
Example #5
0
int FreesteelWindow::LoadSTL(const char* str)
{
	GSTsurface* surf = new GSTsurface();
	surf->LoadSTL(str);
	return add(surf);
}