当前位置: 首页 > news >正文

淄博市建设工程质量协会网站个人网站建设教学视频百度云盘

淄博市建设工程质量协会网站,个人网站建设教学视频百度云盘,有需要做网站推广找我,阿里云账号密码发给网站开发CuraEngine之代码阅读#xff08;1#xff09;之路径优化函数 注#xff1a;整理一些突然学到的C知识#xff0c;随时mark一下 例如#xff1a;忘记的关键字用法#xff0c;新关键字#xff0c;新数据结构 C 的 STL CuraEngine之代码阅读#xff08;1#xff09;之路径…CuraEngine之代码阅读1之路径优化函数 注整理一些突然学到的C知识随时mark一下 例如忘记的关键字用法新关键字新数据结构 C 的 STL CuraEngine之代码阅读1之路径优化函数一、路径优化函数 提示本文为curaengine 中 路径优化函数代码 一、路径优化函数 CuraEngine的功能用于3D打印接受STL文件或其他格式的文件如AMF文件作为输入并输出G代码GCode。G代码类似于汇编代码可以直接在底层硬件上运行控制电机等运动单元动作。 void PathOrderOptimizer::optimize() {// NOTE: Keep this vector fixed-size, it replaces an (non-standard, sized at runtime) array:std::vectorbool picked(polygons.size(), false);loc_to_line nullptr;for (unsigned poly_idx 0; poly_idx polygons.size(); poly_idx) /// find closest point to initial starting point within each polygon initialize picked{const ConstPolygonRef poly *polygons[poly_idx];switch (config.type){case EZSeamType::USER_SPECIFIED:polyStart.push_back(getClosestPointInPolygon(config.pos, poly_idx));break;case EZSeamType::RANDOM:polyStart.push_back(getRandomPointInPolygon(poly_idx));break;case EZSeamType::SHARPEST_CORNER:case EZSeamType::SHORTEST:default:polyStart.push_back(getClosestPointInPolygon(startPoint, poly_idx));break;}assert(poly.size() ! 2);}Point prev_point;switch (config.type){case EZSeamType::USER_SPECIFIED:prev_point config.pos;break;case EZSeamType::RANDOM: //TODO: Starting position of the first polygon isnt random.case EZSeamType::SHARPEST_CORNER:case EZSeamType::SHORTEST:default:prev_point startPoint;}for (unsigned int poly_order_idx 0; poly_order_idx polygons.size(); poly_order_idx) /// actual path order optimizer{int best_poly_idx -1;float bestDist2 std::numeric_limitsfloat::infinity();for (unsigned int poly_idx 0; poly_idx polygons.size(); poly_idx){if (picked[poly_idx] || polygons[poly_idx]-size() 1) /// skip single-point-polygons{continue;}assert (polygons[poly_idx]-size() ! 2);const Point p (*polygons[poly_idx])[polyStart[poly_idx]];float dist2 vSize2f(p - prev_point);if (dist2 bestDist2 combing_boundary){// using direct routing, this poly is the closest so far but as the combing boundary// is available see if the travel would cross the combing boundary and, if so, either get// the combed distance and use that instead or increase the distance to make it less attractiveif (PolygonUtils::polygonCollidesWithLineSegment(*combing_boundary, p, prev_point)){if ((polygons.size() - poly_order_idx) 100){// calculating the combing distance for lots of polygons is too time consuming so, instead,// just increase the distance to penalise travels that hit the combing boundarydist2 * 5;}else{if (!loc_to_line){// the combing boundary has been provided so do the initialisation// required to be able to calculate realistic travel distances to the start of new pathsconst int travel_avoid_distance 2000; // assume 2mm - not really critical for our purposesloc_to_line PolygonUtils::createLocToLineGrid(*combing_boundary, travel_avoid_distance);}CombPath comb_path;if (LinePolygonsCrossings::comb(*combing_boundary, *loc_to_line, p, prev_point, comb_path, -40, 0, false)){float dist 0;Point last_point p;for (const Point comb_point : comb_path){dist vSize(comb_point - last_point);last_point comb_point;}dist2 dist * dist;}}}}if (dist2 bestDist2){best_poly_idx poly_idx;bestDist2 dist2;}}if (best_poly_idx -1) /// should always be true; we should have been able to identify the best next polygon{assert(polygons[best_poly_idx]-size() ! 2);prev_point (*polygons[best_poly_idx])[polyStart[best_poly_idx]];picked[best_poly_idx] true;polyOrder.push_back(best_poly_idx);}else{logError(Failed to find next closest polygon.\n);}}if (loc_to_line ! nullptr){delete loc_to_line;} }这段代码定义了一个名为 PathOrderOptimizer 的类的成员函数 optimize。这个函数的目的是优化多边形polygons的打印顺序通常用于3D打印或其他需要按顺序处理多边形的应用场景。以下是这段代码的详细解释 初始化: std::vector picked(polygons.size(), false);创建一个布尔向量其大小与多边形数组 polygons 相同并将所有元素初始化为 false。这个向量用于跟踪哪些多边形已经被选中或处理过。 loc_to_line nullptr;将 loc_to_line 设置为 nullptr。这可能是指向某个数据结构的指针但在这段代码中并没有进一步使用。 找到每个多边形的起始点: 遍历每个多边形并根据配置 config.type 的类型来找到每个多边形的起始点。 如果配置是 USER_SPECIFIED则使用用户指定的位置 config.pos 来找到最近点。 如果配置是 RANDOM则随机选择多边形内的一个点作为起始点。 如果配置是 SHARPEST_CORNER 或 SHORTEST或默认情况则使用 startPoint 来找到最近点。 polyStart 是一个容器用于存储每个多边形的起始点。 确定第一个多边形的起始点: 根据配置 config.type 的类型来确定整个路径的起始点 prev_point。 优化多边形打印顺序: 遍历每个多边形目的是确定它们应该被处理的顺序。 对于每个尚未处理的多边形计算其与当前 prev_point 的距离bestDist2并找到距离最小的多边形best_poly_idx。 如果多边形只有一个点或已被处理picked[poly_idx] 为 true则跳过该多边形。 断言确保多边形不只有两个点这可能是因为只有两个点的多边形对于此优化过程没有意义或可能导致错误。 到 assert (polygons[poly_idx]-size() ! 2);这里 后面的逻辑如如何处理 best_poly_idx 和 bestDist2以及如何更新 picked 向量和 prev_point还未读完。但基于这段代码我们可以推断 optimize 函数的目的是根据某种标准如距离来确定多边形的处理顺序可能是为了最小化打印头在打印不同多边形之间的移动距离。 需要注意的是这段代码依赖于一些外部定义和变量如 polygons、polyStart、config、startPoint 和可能的其他成员函数如 getClosestPointInPolygon 和 getRandomPointInPolygon
http://www.zqtcl.cn/news/702831/

相关文章:

  • sql数据库查询网站模板谷歌浏览器网页版入口
  • 成都h5建站市场监督管理局举报电话
  • 百度推广弄个网站头像要钱吗?最新新闻热点素材
  • 江苏做网站找谁wordpress主题设置插件
  • 郑州微信网站开发建筑网招工平台
  • 给网站挂黑链普工招聘最新招聘信息
  • 重庆推广网站排名价格上海房产信息网官网
  • 深圳网站公司制作网络公司排名
  • 郑州高端做网站网页制作与网站建设实战大全光盘
  • 科技网站制作公司免费模板建站网站
  • 网页排版精美的中文网站单页设计软件
  • 图书馆网站建设情况会员卡管理系统价格
  • 网站建设的通知沈阳品牌设计公司
  • html5网站框架宝安网站建设深圳信科
  • 做网站单页分销电商平台开发
  • 吉林网站备案南京网站开发选南京乐识好
  • 某网站建设方案纯文本网站连接
  • 怎样做网页游戏网站智通人才网东莞最新招聘信息官网
  • 中英文网站建设wordpress 旅行
  • ic商城网站建设南大资源分享wordpress
  • 永兴集团网站织梦网站模板下载
  • html怎么做网站地图柳州小程序制作公司
  • 微网站自助建站京东自营入驻流程及费用
  • 哪些网站适合用自适应开发板编程软件
  • 网站建设公司领导致辞传奇网页游戏大全
  • 公司网站简介网站建设中的英文
  • 没有防盗链的网站做网站市场报价步登顶
  • 网站建设基本话术服装店网站建设规划书
  • 网站建设公司品牌crm客户管理系统设计
  • 网站源码生成器英文网站建设600