From 026f5e01208257f8d9e2304c6d13486cb26c83f1 Mon Sep 17 00:00:00 2001 From: lampsonSong Date: Thu, 11 Jul 2013 11:22:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Update=20=E9=97=AE=E9=A2=98=E6=B1=87?= =?UTF-8?q?=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 道杆-》导杆 --- "\351\227\256\351\242\230\346\261\207\346\200\273" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\351\227\256\351\242\230\346\261\207\346\200\273" "b/\351\227\256\351\242\230\346\261\207\346\200\273" index 16d6db2..3d966d4 100644 --- "a/\351\227\256\351\242\230\346\261\207\346\200\273" +++ "b/\351\227\256\351\242\230\346\261\207\346\200\273" @@ -22,7 +22,7 @@ 缺失的部件: -俩根直线导杆, 一根带螺纹的导杆(高精度的), 四个道杆套, 内六角螺丝若干, 四个锁环,马达和螺纹导杆的衔接(俩个半圆rubber motor coupler "spider" +俩根直线导杆, 一根带螺纹的导杆(高精度的), 四个导杆套, 内六角螺丝若干, 四个锁环,马达和螺纹导杆的衔接(俩个半圆rubber motor coupler "spider" 出自step 3),DC电机一个, 尼龙套若干(用来垫高), From ef43b66b4bf4a5c73f1e1d6efd5a74796688770f Mon Sep 17 00:00:00 2001 From: shelvin Date: Sun, 1 Dec 2013 22:34:10 +0800 Subject: [PATCH 2/2] Create Slicing Algorithm --- Slicing Algorithm | 154 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Slicing Algorithm diff --git a/Slicing Algorithm b/Slicing Algorithm new file mode 100644 index 0000000..d1b8273 --- /dev/null +++ b/Slicing Algorithm @@ -0,0 +1,154 @@ + +//slicing to a job file! +void B9Layout::SliceWorldToJob(QString filename) +{ + + unsigned int m; + unsigned int i; + unsigned int l; + unsigned int numlayers; + int nummodels = 0; + double zhieght = project->GetBuildSpace().z(); + double thickness = project->GetPixelThickness()*0.001; + int xsize = project->GetResolution().x(); + int ysize = project->GetResolution().y(); + QString jobname = project->GetJobName(); + QString jobdesc = project->GetJobDescription(); + int x; + int y; + QRgb pickedcolor; + QRgb mastercolor; + QPixmap pix; + QImage img(xsize,ysize, QImage::Format_ARGB32_Premultiplied); + QImage imgfrommaster(xsize,ysize, QImage::Format_ARGB32_Premultiplied); + CrushedPrintJob* pMasterJob = NULL; + + + + //calculate how many layers we need + numlayers = qCeil(zhieght/thickness); + //calculate how many models there are + for(m=0;minstList.size();i++) + { + nummodels++; + } + } + //make a loading bar + LoadingBar progressbar(0, numlayers, this); + QObject::connect(&progressbar,SIGNAL(rejected()),this,SLOT(CancelSlicing())); + progressbar.setDescription("Processing Layout.."); + progressbar.setValue(0); + QApplication::processEvents(); + + + SliceContext paintwidget(NULL, this); + paintwidget.makeCurrent(); + + //make a master job file for use later + pMasterJob = new CrushedPrintJob(); + pMasterJob->setName(jobname); + pMasterJob->setDescription(jobdesc); + pMasterJob->setXYPixel(QString().number(project->GetPixelSize()/1000)); + pMasterJob->setZLayer(QString().number(project->GetPixelThickness()/1000)); + + + + pMasterJob->clearAll(numlayers);//fills the master job with the needed layers + + progressbar.setDescription("Slicing Layout.."); + progressbar.setMax(numlayers*nummodels); + progressbar.setValue(0); + //FOR Each Model Instance + for(m=0;minstList.size();i++) + { + ModelInstance* inst = ModelDataList[m]->instList[i]; + inst->BakeGeometry(); + + //slice all layers and add to instance's job file + for(l = 0; l < numlayers; l++) + { + //if we are in the model's z - bounds + if((double)l*thickness <= inst->GetMaxBound().z() && (double)l*thickness >= inst->GetMinBound().z()-0.5*thickness) + { + //ACTUALLY Generate the Slice. + inst->pSliceSet->GenerateSlice(l*thickness + thickness*0.5); + paintwidget.SetSlice(inst->pSliceSet->pSliceData); + + + pix = paintwidget.renderPixmap(xsize,ysize); + img = pix.toImage(); + + + for(x = 0; x < xsize; x++) + { + for(y = 0; y < ysize; y++) + { + pickedcolor = img.pixel(x,y); + if(qRed(pickedcolor) || qGreen(pickedcolor)) + { + int result = qRed(pickedcolor) - qGreen(pickedcolor); + if(result > 0) + { + result = 255; + } + img.setPixel(x,y,QColor(result,0,0,result).rgba()); + } + } + } + + QApplication::processEvents(); + imgfrommaster.fill(Qt::black); + pMasterJob->setCurrentSlice(l); + pMasterJob->inflateCurrentSlice(&imgfrommaster); + if(imgfrommaster.size() == QSize(0,0)) + { + imgfrommaster = QImage(xsize,ysize,QImage::Format_ARGB32_Premultiplied); + imgfrommaster.fill(Qt::black); + } + for(x = 0; x < xsize; x++) + { + for(y = 0; y < ysize; y++) + { + pickedcolor = img.pixel(x,y); + mastercolor = imgfrommaster.pixel(x,y); + if(qRed(pickedcolor) || qRed(mastercolor)) + { + imgfrommaster.setPixel(x,y,QColor(255,255,255).rgb()); + } + } + } + pMasterJob->crushCurrentSlice(&imgfrommaster); + QApplication::processEvents(); + + //update progress bar + progressbar.setValue(progressbar.GetValue() + 1); + + if(cancelslicing) + { + cancelslicing = false; + delete pMasterJob; + pWorldView->makeCurrent(); + inst->UnBakeGeometry(); + return; + } + } + } + inst->UnBakeGeometry(); + } + } + + QFile* pf = new QFile(filename); + + pMasterJob->saveCPJ(pf); + delete pf; + delete pMasterJob; + + + pWorldView->makeCurrent(); + + cancelslicing = false; +}