EVAL_BODY_INCLUDE

本文深入探讨了Web开发中Evaluating Tag Actions的四种方式:EVAL_BODY_INCLUDE、EVAL_PAGE、SKIP_BODY、EVAL_BODY_TAG、EVAL_BODY_BUFFERED,并解释了它们在处理页面内容时的不同行为和应用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

EVAL_BODY_INCLUDE:把Body读入存在的输出流中,doStartTag()函数可用
EVAL_PAGE:继续处理页面,doEndTag()函数可用
SKIP_BODY:忽略对Body的处理,doStartTag()和doAfterBody()函数可用
SKIP_PAGE:忽略对余下页面的处理,doEndTag()函数可用
EVAL_BODY_TAG:已经废止,由EVAL_BODY_BUFFERED取代
EVAL_BODY_BUFFERED:申请缓冲区,由setBodyContent()函数得到的BodyContent对象来处理tag的body,如果类实现了BodyTag,那么doStartTag()可用,否则非法


With EVAL_BODY_INCLUDE, you have no chance to work with the body, as it is simply being written to the client.
With EVAL_BODY_BUFFERED, the body is stored in a buffer, which you can decide to output or not, and even change its content.
(imagine a “upper” tag which would change the body’s content in uppercase)

Note that if you are using BodyTagSupport, the default return value for doStartTag is EVAL_BODY_BUFFERED.

Details from the spec:
If EVAL_BODY_INCLUDE is returned, and the custom action element is not empty, setBodyContent() is not invoked, doInitBody() is not invoked, the body is evaluated and �passed through� to the current out, doAfterBody() is invoked and then, after zero or more iterations, doEndTag() is invoked. If the custom action element is empty, only doStart() and doEndTag() are invoked.

If EVAL_BODY_BUFFERED is returned, and the custom action element is not empty, setBodyContent() is invoked, doInitBody() is invoked, the body is evaluated, doAfterBody() is invoked, and then, after zero or more iterations, doEndTag() is invoked. If the custom action element is empty, only doStart() and doEndTag() are invoked
//方法1:UFUN方法//获得一条直线两个端点坐标、直线长度、向量方向//函数1(UF_CURVE_ask_line_data)UF_CURVE_line_t AskLinePoint;UF_CURVE_ask_line_data(LineTag, &AskLinePoint);double UF1LinePoint1[3] = { AskLinePoint.start_point[0], AskLinePoint.start_point[1], AskLinePoint.start_point[2] };//获得直线起点坐标double UF1LinePoint2[3] = { AskLinePoint.end_point[0], AskLinePoint.end_point[1], AskLinePoint.end_point[2] };//获得直线终点坐标//函数2(UF_EVAL_ask_line)UF_EVAL_p_t evaluator;UF_EVAL_initialize(LineTag, &evaluator);UF_EVAL_line_t line;UF_EVAL_ask_line(evaluator, &line);double UFLineLength = line.length;//获得直线长度double UF2LinePoint1[3] = { line.start[0], line.start[1], line.start[2] };//获得直线起点坐标double UF2LinePoint2[3] = { line.end[0], line.end[1], line.end[2] };//获得直线终点坐标double UFLineVec[3] = { line.unit[0], line.unit[1], line.unit[2] };//获得直线向量方向char msg[256];sprintf_s(msg, "直线的长度为:%.3f\n直线的起点坐标X为:%.3f 直线的起点坐标Y为:%.3f 直线的起点坐标Z为:%.3f\n直线的终点坐标X为%.3f 直线的终点坐标Y为:%.3f 直线的终点坐标Z为:%.3f\n直线的向量方向为:%.0f,%.0f,%.0f", UFLineLength, UF2LinePoint1[0], UF2LinePoint1[1], UF2LinePoint1[2], UF2LinePoint2[0], UF2LinePoint2[1], UF2LinePoint2[2], UFLineVec[0], UFLineVec[1], UFLineVec[2]);lw->Open();lw->WriteLine(msg);UF_EVAL_free(evaluator);参考以上代码获取方向,你给的代码一下部分错误 // 获取圆柱面的所有边 uf_list_p_t edgeList = NULL; if (UF_MODL_ask_face_edges(maxCylFace, &edgeList) == 0 && edgeList) { int edgeCount = 0; UF_MODL_ask_list_count(edgeList, &edgeCount); // 存储找到的垂直平面 std::set<tag_t> verticalPlaneSet; // 存储已处理的边(避免循环) std::set<tag_t> processedEdges; // 遍历圆柱面的每条边 for (int j = 0; j < edgeCount; j++) { tag_t edgeTag = NULL_TAG; if (UF_MODL_ask_list_item(edgeList, j, &edgeTag) == 0) { // 检查边是否平行Z轴 int edgeType = 0; UF_MODL_ask_edge_type(edgeTag, &edgeType); if (edgeType == UF_MODL_LINEAR_EDGE) // 直线边 { // 使用UF_EVAL_ask_line获取直线方向 UF_EVAL_p_t eval_p = NULL; if (UF_EVAL_initialize_edge(edgeTag, &eval_p) == 0 && eval_p) { UF_EVAL_line_p_t line_p = NULL; if (UF_EVAL_ask_line(eval_p, &line_p) == 0 && line_p) { double edgeDir[3] = { 0 }; UF_EVAL_ask_line_direction(line_p, edgeDir); double dot = fabs(edgeDir[0] * z_axis[0] + edgeDir[1] * z_axis[1] + edgeDir[2] * z_axis[2]); // 如果边平行Z轴(点积接近1) if (fabs(dot - 1.0) < normal_tolerance) { // 递归查找垂直平面 findVerticalPlanes(edgeTag, maxCylFace, verticalPlaneSet, processedEdges, z_axis, normal_tolerance); } } UF_EVAL_free(eval_p); // 释放求值器资源 } } } } UF_MODL_delete_list(&edgeList); // 释放边列表内存 // 高亮并计数找到的垂直平面 for (tag_t planeTag : verticalPlaneSet) { UF_DISP_set_highlight(planeTag, 1); // 高亮平面 totalVerticalPlanes++; // 增加垂直平面计数 } } } } UF_MODL_delete_list(&faceList); // 释放面列表内存 } // 4. 刷新显示使高亮生效 UF_DISP_refresh(); // 刷新视图 // 5. 显示处理结果 char resultMsg[256]; // 结果消息缓冲区 snprintf(resultMsg, sizeof(resultMsg), // 格式化结果消息 "处理完成!\nXY平面数量: %d\n圆柱面总数: %d\n选中圆柱面: %d\n垂直Z轴平面: %d", totalXYFaces, totalCylFaces, totalSelectedFaces, totalVerticalPlanes); theUI->NXMessageBox()->Show("处理结果", // 显示结果对话框 NXMessageBox::DialogTypeInformation, resultMsg); } catch (std::exception& ex) // 捕获异常 { theUI->NXMessageBox()->Show("MICH-明:系统错误", NXMessageBox::DialogTypeError, ex.what()); // 显示错误信息 } // ************ 新增递归函数:从边开始查找垂直平面 ************ void findVerticalPlanes(tag_t startEdge, tag_t startFace, std::set<tag_t>& verticalPlaneSet, std::set<tag_t>& processedEdges, const double z_axis[3], double normal_tolerance) { // 避免重复处理同一条边 if (processedEdges.find(startEdge) != processedEdges.end()) return; processedEdges.insert(startEdge); // 标记为已处理 // 获取与当前边相邻的面 uf_list_p_t adjacentFaces = NULL; if (UF_MODL_ask_edge_faces(startEdge, &adjacentFaces) != 0 || !adjacentFaces) return; int faceCount = 0; UF_MODL_ask_list_count(adjacentFaces, &faceCount); for (int i = 0; i < faceCount; i++) { tag_t faceTag = NULL_TAG; if (UF_MODL_ask_list_item(adjacentFaces, i, &faceTag) != 0) continue; // 跳过起始面(圆柱面) if (faceTag == startFace) continue; // 检查面类型 int faceType = 0; if (UF_MODL_ask_face_type(faceTag, &faceType) != 0) continue; // 只处理平面面 if (faceType == UF_MODL_PLANAR_FACE) { // 获取平面面的法向 double faceDir[3] = { 0 }, facePt[3] = { 0 }; double faceBox[6] = { 0 }, faceRad = 0, faceRadData[2] = { 0 }; int faceStatus = 0; if (UF_MODL_ask_face_data(faceTag, &faceType, facePt, faceDir, faceBox, &faceRad, faceRadData, &faceStatus) == 0) { // 计算法向与Z轴的点积 double dot = z_axis[0] * faceDir[0] + z_axis[1] * faceDir[1] + z_axis[2] * faceDir[2]; // 检查法向是否垂直于Z轴(点积接近0) if (fabs(dot) < normal_tolerance) { // 添加到垂直平面集合 verticalPlaneSet.insert(faceTag); // 获取当前面的所有边 uf_list_p_t faceEdges = NULL; if (UF_MODL_ask_face_edges(faceTag, &faceEdges) == 0 && faceEdges) { int edgeCountOnFace = 0; UF_MODL_ask_list_count(faceEdges, &edgeCountOnFace); // 遍历当前面的每条边 for (int j = 0; j < edgeCountOnFace; j++) { tag_t nextEdge = NULL_TAG; if (UF_MODL_ask_list_item(faceEdges, j, &nextEdge) == 0) { // 递归查找相邻的垂直平面 findVerticalPlanes(nextEdge, faceTag, verticalPlaneSet, processedEdges, z_axis, normal_tolerance); } } UF_MODL_delete_list(&faceEdges); } } } } } UF_MODL_delete_list(&adjacentFaces); }这段不对,报错提示:严重性 代码 说明 项目 文件 行 禁止显示状态 错误(活动) E0020 未定义标识符 "UF_EVAL_initialize_edge" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1420 错误(活动) E0167 "UF_EVAL_line_p_t *" 类型的实参与 "UF_EVAL_line_p_t" 类型的形参不兼容 gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1423 错误(活动) E0020 未定义标识符 "UF_EVAL_ask_line_direction" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1426 错误(活动) E0065 应输入“;” gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1480 错误(活动) E0020 未定义标识符 "faceTag" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1507 错误(活动) E0115 continue 语句只能在循环中使用 gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1508 错误(活动) E0020 未定义标识符 "z_axis" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1523 错误(活动) E0020 未定义标识符 "normal_tolerance" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1528 错误(活动) E0020 未定义标识符 "verticalPlaneSet" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1531 错误(活动) E0020 未定义标识符 "processedEdges" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1548 错误(活动) E0020 未定义标识符 "adjacentFaces" gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1557 错误(活动) E0530 try 块至少需要一个处理程序 gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1563 错误(活动) E0169 应输入声明 gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1564 错误(活动) E0169 应输入声明 gaiyansetool D:\NXopen\BaiduSyncdisk\studio\gaiyansetool\gaiyansetool.cpp 1571
最新发布
08-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值