CuraEngine

这是一个3D打印切片和路经规划库.

The slicing process follows the following global steps:

  • Load 3D model
  • Analize and fix 3D model
  • Slice 3D model into 2D layers
  • Build LayerParts from sliced layers
  • Generate Insets
  • Generate up/down skins areas
  • Generate sparse infill areas
  • Generate GCode for each layer 我主要用到了它的二维规划子函数.
    • infill.cpp 用来完成内部填充
    • pathOrderOptimizer.cpp 内轮廓和外轮廓的规划
    • intpoint.h 以上两个文件需要的数据结构
    • clipper.cpp 对上面的数据结构体进行操作的库.可以区分内外边框

个人认为这是一个很好的路径规划和3D切片参考库.

1
2
3
generateLineInfill(PGtmp,m_PG,1000,m_ResolutionY*100,m_ResolutionY,45,PGtmp);
// 判断内外圈
bool mback = ClipperLib::Orientation(PGtmp[0]);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//hierarchy next and previous, first child contour and the parent contour
cv::findContours(phrone ,contours ,hierarchy, CV_RETR_CCOMP,CV_CHAIN_APPROX_SIMPLE );
cv::Mat dst = cv::Mat::zeros(phrone.rows,phrone.cols,CV_8UC3);
if (contours.size()==0)
{
continue;
}
// 遍历外框排序
PathOptimizer pathOptimize(ClipperLib::IntPoint(0,0));// 增加入口点
ClipperLib::Polygons plogs;
vector<int> orderid;
for( int idx = 0; idx >= 0; idx = hierarchy[idx][0] )//外框遍历
{
if (contours[idx].size() < 3)
{
continue;
}
ClipperLib::Polygon plog;
for (int i=0; i<contours[idx].size(); i++)
{
plog.push_back(ClipperLib::IntPoint(contours[idx][i].x,contours[idx][i].y));
}
plogs.push_back(plog);
orderid.push_back(idx);
}
pathOptimize.addPolygons(plogs);
pathOptimize.optimize();

留言

2017-03-29