{"id":179,"date":"2026-03-01T19:29:37","date_gmt":"2026-03-01T11:29:37","guid":{"rendered":"https:\/\/www.alimzs.com\/index.php\/2026\/03\/01\/opencascade-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%ef%bc%88%e4%b8%80%ef%bc%89%ef%bc%9a%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e9%85%8d\/"},"modified":"2026-03-01T19:29:37","modified_gmt":"2026-03-01T11:29:37","slug":"opencascade-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%ef%bc%88%e4%b8%80%ef%bc%89%ef%bc%9a%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e9%85%8d","status":"publish","type":"post","link":"https:\/\/www.alimzs.com\/index.php\/2026\/03\/01\/opencascade-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e7%b2%be%e9%80%9a%ef%bc%88%e4%b8%80%ef%bc%89%ef%bc%9a%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba-%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e9%85%8d\/","title":{"rendered":"OpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff08\u4e00\uff09\uff1a\u73af\u5883\u642d\u5efa \u2013 \u4ece\u96f6\u5f00\u59cb\u914d\u7f6e OCCT \u5f00\u53d1\u73af\u5883"},"content":{"rendered":"<p><!DOCTYPE html><br \/>\n<html><br \/>\n<body><\/p>\n<h1>OpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff08\u4e00\uff09\uff1a\u73af\u5883\u642d\u5efa \u2013 \u4ece\u96f6\u5f00\u59cb\u914d\u7f6e OCCT \u5f00\u53d1\u73af\u5883<\/h1>\n<h2>\u4e00\u3001\u672c\u7ae0\u76ee\u6807<\/h2>\n<p>\u5b66\u5b8c\u672c\u7ae0\u4f60\u5c06\u80fd\u591f\uff1a<\/p>\n<ul>\n<li>\u2705 \u5728 Ubuntu 22.04 \u4e0a\u5b89\u88c5 OpenCASCADE 7.6.3<\/li>\n<li>\u2705 \u914d\u7f6e CMake \u7f16\u8bd1\u73af\u5883<\/li>\n<li>\u2705 \u7f16\u8bd1\u8fd0\u884c\u7b2c\u4e00\u4e2a OCCT \u7a0b\u5e8f\uff08Hello Cube\uff09<\/li>\n<li>\u2705 \u8f93\u51fa\u7acb\u65b9\u4f53\u7684\u4f53\u79ef\u3001\u8d28\u5fc3\u3001\u9762\u6570\u7b49\u6570\u636e<\/li>\n<\/ul>\n<p><strong>\u6700\u7ec8\u6210\u679c<\/strong>\uff1a\u4e00\u4e2a\u53ef\u8fd0\u884c\u7684\u7acb\u65b9\u4f53\u6a21\u578b\uff0c\u4f53\u79ef 6000 mm\u00b3<\/p>\n<hr>\n<h2>\u4e8c\u3001\u6838\u5fc3\u6982\u5ff5<\/h2>\n<h3>\u4ec0\u4e48\u662f OpenCASCADE\uff1f<\/h3>\n<p>OpenCASCADE Technology\uff08OCCT\uff09\u662f\u4e00\u4e2a\u5f00\u6e90\u7684 CAD\/CAM\/CAE \u51e0\u4f55\u5efa\u6a21\u5185\u6838\uff0c\u63d0\u4f9b\uff1a<\/p>\n<ul>\n<li>3D \u51e0\u4f55\u5efa\u6a21\uff08B-Rep \u8fb9\u754c\u8868\u793a\u6cd5\uff09<\/li>\n<li>\u5e03\u5c14\u8fd0\u7b97\uff08\u5e76\u96c6\/\u5dee\u96c6\/\u4ea4\u96c6\uff09<\/li>\n<li>\u6570\u636e\u4ea4\u6362\uff08STEP\/IGES\/GLTF\uff09<\/li>\n<li>\u7f51\u683c\u5256\u5206\uff08\u7528\u4e8e 3D \u6253\u5370\/\u4eff\u771f\uff09<\/li>\n<\/ul>\n<h3>\u7248\u672c\u8bf4\u660e<\/h3>\n<p>\u672c\u7cfb\u5217\u57fa\u4e8e <strong>OCCT 7.6.3<\/strong>\uff08Ubuntu 22.04 \u5b98\u65b9\u4ed3\u5e93\u7248\u672c\uff09\u3002<\/p>\n<hr>\n<h2>\u4e09\u3001\u73af\u5883\u51c6\u5907<\/h2>\n<h3>\u7cfb\u7edf\u8981\u6c42<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u7ec4\u4ef6<\/th>\n<th>\u8981\u6c42<\/th>\n<th>\u672c\u6587\u73af\u5883<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u64cd\u4f5c\u7cfb\u7edf<\/td>\n<td>Ubuntu 20.04+<\/td>\n<td>Ubuntu 22.04 LTS<\/td>\n<\/tr>\n<tr>\n<td>\u7f16\u8bd1\u5668<\/td>\n<td>GCC 9+<\/td>\n<td>GCC 11.4.0<\/td>\n<\/tr>\n<tr>\n<td>OCCT<\/td>\n<td>7.6.0+<\/td>\n<td>7.6.3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u5b89\u88c5\u6b65\u9aa4<\/h3>\n<pre><code class=\"language-bash\"># 1. \u66f4\u65b0\u8f6f\u4ef6\u6e90\nsudo apt update\n\n# 2. \u5b89\u88c5 OCCT \u5f00\u53d1\u5e93\nsudo apt install -y libocct-data-exchange-dev libocct-visualization-dev\n\n# 3. \u5b89\u88c5\u7f16\u8bd1\u5de5\u5177\nsudo apt install -y cmake g++ pkg-config\n\n# 4. \u9a8c\u8bc1\u5b89\u88c5\ndpkg -l | grep occt\n<\/code><\/pre>\n<hr>\n<h2>\u56db\u3001\u5b8c\u6574\u4ee3\u7801<\/h2>\n<p>\u521b\u5efa\u6587\u4ef6 <code>hello_cube.cpp<\/code>\uff1a<\/p>\n<pre><code class=\"language-cpp\">\/**\n * OpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff08\u4e00\uff09\uff1aHello Cube\n * \u529f\u80fd\uff1a\u521b\u5efa\u4e00\u4e2a 10x20x30 mm \u7684\u7acb\u65b9\u4f53\uff0c\u8f93\u51fa\u5176\u51e0\u4f55\u5c5e\u6027\n *\/\n\n#include &lt;iostream&gt;\n#include &lt;iomanip&gt;\n\n\/\/ OCCT \u57fa\u7840\u51e0\u4f55\n#include &lt;gp_Pnt.hxx&gt;\n#include &lt;gp_Vec.hxx&gt;\n\n\/\/ OCCT \u62d3\u6251\n#include &lt;TopoDS_Solid.hxx&gt;\n#include &lt;TopExp.hxx&gt;\n#include &lt;TopAbs_ShapeEnum.hxx&gt;\n#include &lt;TopTools_IndexedMapOfShape.hxx&gt;\n\n\/\/ OCCT \u5efa\u6a21 API\n#include &lt;BRepPrimAPI_MakeBox.hxx&gt;\n\n\/\/ OCCT \u5c5e\u6027\u8ba1\u7b97\n#include &lt;GProp_GProps.hxx&gt;\n#include &lt;BRepGProp.hxx&gt;\n\nint main() {\n    std::cout &lt;&lt; \"========================================\" &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"OpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff08\u4e00\uff09\" &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"Hello Cube - \u521b\u5efa\u7acb\u65b9\u4f53\u5e76\u5206\u6790\u51e0\u4f55\u5c5e\u6027\" &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"========================================\" &lt;&lt; std::endl;\n    \n    \/\/ \u521b\u5efa\u7acb\u65b9\u4f53 (10mm x 20mm x 30mm)\n    Standard_Real dimX = 10.0;\n    Standard_Real dimY = 20.0;\n    Standard_Real dimZ = 30.0;\n    \n    TopoDS_Solid box = BRepPrimAPI_MakeBox(dimX, dimY, dimZ);\n    \n    if (box.IsNull()) {\n        std::cerr &lt;&lt; \"\u9519\u8bef\uff1a\u7acb\u65b9\u4f53\u521b\u5efa\u5931\u8d25\uff01\" &lt;&lt; std::endl;\n        return 1;\n    }\n    \n    \/\/ \u8ba1\u7b97\u51e0\u4f55\u5c5e\u6027\n    GProp_GProps system;\n    BRepGProp::VolumeProperties(box, system);\n    \n    Standard_Real volume = system.Mass();\n    gp_Pnt center = system.CentreOfMass();\n    \n    std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision(2);\n    std::cout &lt;&lt; \"\u4f53\u79ef\uff1a\" &lt;&lt; volume &lt;&lt; \" mm\u00b3\" &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"\u8d28\u5fc3\uff1a(\" &lt;&lt; center.X() &lt;&lt; \", \" &lt;&lt; center.Y() &lt;&lt; \", \" &lt;&lt; center.Z() &lt;&lt; \") mm\" &lt;&lt; std::endl;\n    \n    \/\/ \u7edf\u8ba1\u62d3\u6251\u5143\u7d20\uff08\u4f7f\u7528 Map \u53bb\u91cd\uff09\n    TopTools_IndexedMapOfShape faceMap, edgeMap, vertexMap;\n    TopExp::MapShapes(box, TopAbs_FACE, faceMap);\n    TopExp::MapShapes(box, TopAbs_EDGE, edgeMap);\n    TopExp::MapShapes(box, TopAbs_VERTEX, vertexMap);\n    \n    std::cout &lt;&lt; \"\u9762\u6570\uff1a\" &lt;&lt; faceMap.Extent() &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"\u8fb9\u6570\uff1a\" &lt;&lt; edgeMap.Extent() &lt;&lt; std::endl;\n    std::cout &lt;&lt; \"\u9876\u70b9\u6570\uff1a\" &lt;&lt; vertexMap.Extent() &lt;&lt; std::endl;\n    \n    \/\/ \u9a8c\u8bc1\n    Standard_Real expectedVolume = dimX * dimY * dimZ;\n    bool volumeOK = (volume - expectedVolume) &lt; 0.01;\n    bool faceOK = (faceMap.Extent() == 6);\n    bool edgeOK = (edgeMap.Extent() == 12);\n    bool vertexOK = (vertexMap.Extent() == 8);\n    \n    if (volumeOK &amp;&amp; faceOK &amp;&amp; edgeOK &amp;&amp; vertexOK) {\n        std::cout &lt;&lt; \"\u2705 \u6240\u6709\u9a8c\u8bc1\u901a\u8fc7\uff01\" &lt;&lt; std::endl;\n    } else {\n        std::cout &lt;&lt; \"\u274c \u9a8c\u8bc1\u5931\u8d25\uff01\" &lt;&lt; std::endl;\n        return 1;\n    }\n    \n    return 0;\n}\n<\/code><\/pre>\n<hr>\n<h2>\u4e94\u3001\u7f16\u8bd1\u4e0e\u8fd0\u884c<\/h2>\n<h3>\u7f16\u8bd1\u547d\u4ee4<\/h3>\n<pre><code class=\"language-bash\">g++ -o hello_cube hello_cube.cpp \\\n  -I\/usr\/include\/opencascade \\\n  -L\/usr\/lib\/x86_64-linux-gnu \\\n  -lTKernel -lTKMath -lTKBRep -lTKGeomBase -lTKGeomAlgo \\\n  -lTKTopAlgo -lTKPrim -lTKG3d -lTKG2d \\\n  -std=c++17\n<\/code><\/pre>\n<h3>\u8fd0\u884c\u7ed3\u679c<\/h3>\n<figure>\n<img decoding=\"async\" src=\"https:\/\/www.alimzs.com\/wp-content\/uploads\/2026\/03\/terminal_output-1.webp\" alt=\"Hello Cube \u7ec8\u7aef\u8fd0\u884c\u622a\u56fe\" style=\"max-width: 100%; height: auto; border: 1px solid #444; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.5);\"><figcaption><strong>\u56fe 1\uff1a<\/strong>\u771f\u5b9e\u7ec8\u7aef\u8fd0\u884c\u8f93\u51fa &#8211; \u7a0b\u5e8f\u5b9e\u9645\u7f16\u8bd1\u8fd0\u884c\u540e\u7684\u622a\u56fe\uff0c\u663e\u793a\u4f53\u79ef 6000 mm\u00b3\uff0c\u8d28\u5fc3 (5, 10, 15) mm\uff0c6 \u9762 12 \u8fb9 8 \u9876\u70b9\uff0c\u6240\u6709\u9a8c\u8bc1\u901a\u8fc7 \u2705<\/figcaption><\/figure>\n<h3>3D \u6a21\u578b\u793a\u610f\u56fe<\/h3>\n<figure>\n<img decoding=\"async\" src=\"https:\/\/www.alimzs.com\/wp-content\/uploads\/2026\/03\/cube_diagram.webp\" alt=\"Hello Cube 3D \u6a21\u578b\u793a\u610f\u56fe\" style=\"max-width: 100%; height: auto; border: 1px solid #444; border-radius: 4px;\"><figcaption><strong>\u56fe 2\uff1a<\/strong>10x20x30 mm \u7acb\u65b9\u4f53\u7b49\u8f74\u6d4b\u89c6\u56fe &#8211; \u84dd\u8272\u7ebf\u6761\u4e3a\u8fb9\uff0c\u7eff\u8272\u70b9\u4e3a\u9876\u70b9<\/figcaption><\/figure>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u7acb\u65b9\u4f53\u5c3a\u5bf8\u4e3a <strong>10 \u00d7 20 \u00d7 30 mm<\/strong>\uff0c\u8ba1\u7b97\u53ef\u5f97\uff1a<\/p>\n<ul>\n<li><strong>\u4f53\u79ef<\/strong>\uff1a10 \u00d7 20 \u00d7 30 = 6000 mm\u00b3<\/li>\n<li><strong>\u8d28\u5fc3<\/strong>\uff1a(10\/2, 20\/2, 30\/2) = (5, 10, 15) mm<\/li>\n<li><strong>\u9762\u6570<\/strong>\uff1a6 \u4e2a\u77e9\u5f62\u9762<\/li>\n<li><strong>\u8fb9\u6570<\/strong>\uff1a12 \u6761\u8fb9<\/li>\n<li><strong>\u9876\u70b9\u6570<\/strong>\uff1a8 \u4e2a\u9876\u70b9<\/li>\n<\/ul>\n<p>\u4e0e\u7a0b\u5e8f\u8f93\u51fa\u5b8c\u5168\u4e00\u81f4\uff01\u2705<\/p>\n<hr>\n<h2>\u516d\u3001\u4ee3\u7801\u89e3\u6790<\/h2>\n<h3>\u5173\u952e\u70b9 1\uff1a\u521b\u5efa\u57fa\u672c\u4f53\u7d20<\/h3>\n<pre><code class=\"language-cpp\">TopoDS_Solid box = BRepPrimAPI_MakeBox(dimX, dimY, dimZ);<\/code><\/pre>\n<ul>\n<li><code>BRepPrimAPI_MakeBox<\/code> \u662f OCCT \u63d0\u4f9b\u7684\u57fa\u672c\u4f53\u7d20\u521b\u5efa API<\/li>\n<li>\u8fd4\u56de <code>TopoDS_Solid<\/code> \u7c7b\u578b\uff08\u5b9e\u4f53\u5bf9\u8c61\uff09<\/li>\n<li>\u5fc5\u987b\u68c0\u67e5 <code>IsNull()<\/code> \u786e\u4fdd\u521b\u5efa\u6210\u529f<\/li>\n<\/ul>\n<h3>\u5173\u952e\u70b9 2\uff1a\u8ba1\u7b97\u4f53\u79ef\u5c5e\u6027<\/h3>\n<pre><code class=\"language-cpp\">GProp_GProps system;\nBRepGProp::VolumeProperties(box, system);\nStandard_Real volume = system.Mass();\ngp_Pnt center = system.CentreOfMass();<\/code><\/pre>\n<ul>\n<li><code>GProp_GProps<\/code> \u662f\u51e0\u4f55\u5c5e\u6027\u8ba1\u7b97\u7c7b<\/li>\n<li><code>Mass()<\/code> \u8fd4\u56de\u4f53\u79ef\uff08\u5bc6\u5ea6=1 \u65f6\u7b49\u540c\u4e8e\u8d28\u91cf\uff09<\/li>\n<li><code>CentreOfMass()<\/code> \u8fd4\u56de\u8d28\u5fc3\u5750\u6807<\/li>\n<\/ul>\n<h3>\u5173\u952e\u70b9 3\uff1a\u62d3\u6251\u5143\u7d20\u8ba1\u6570\uff08\u53bb\u91cd\uff09<\/h3>\n<pre><code class=\"language-cpp\">TopTools_IndexedMapOfShape faceMap, edgeMap, vertexMap;\nTopExp::MapShapes(box, TopAbs_FACE, faceMap);<\/code><\/pre>\n<ul>\n<li><code>TopExp::MapShapes()<\/code> \u81ea\u52a8\u53bb\u91cd\uff08\u5171\u4eab\u7684\u8fb9\/\u9876\u70b9\u53ea\u8ba1\u6570\u4e00\u6b21\uff09<\/li>\n<li><code>Extent()<\/code> \u8fd4\u56de\u552f\u4e00\u5143\u7d20\u6570\u91cf<\/li>\n<\/ul>\n<hr>\n<h2>\u4e03\u3001\u8bfe\u540e\u7ec3\u4e60<\/h2>\n<ol>\n<li><strong>\u7ec3\u4e60 1<\/strong>\uff1a\u521b\u5efa\u4e00\u4e2a 25x15x40 mm \u7684\u957f\u65b9\u4f53\uff0c\u9a8c\u8bc1\u4f53\u79ef\u662f\u5426\u4e3a 15000 mm\u00b3<\/li>\n<li><strong>\u7ec3\u4e60 2<\/strong>\uff1a\u521b\u5efa\u4e00\u4e2a\u8fb9\u957f\u4e3a 20 mm \u7684\u6b63\u65b9\u4f53\uff0c\u9a8c\u8bc1\u4f53\u79ef=8000 mm\u00b3<\/li>\n<li><strong>\u7ec3\u4e60 3<\/strong>\uff1a\u4f7f\u7528 <code>BRepGProp::SurfaceProperties()<\/code> \u8ba1\u7b97\u8868\u9762\u79ef<\/li>\n<\/ol>\n<hr>\n<h2>\u4e0b\u7ae0\u9884\u544a<\/h2>\n<p><strong>\uff08\u4e8c\uff09\u57fa\u7840\u51e0\u4f55\uff1a\u70b9\u7ebf\u9762\u7684\u521b\u5efa\u4e0e\u64cd\u4f5c<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u9876\u70b9\uff08Vertex\uff09<\/li>\n<li>\u521b\u5efa\u76f4\u7ebf\u8fb9\uff08Edge\uff09<\/li>\n<li>\u521b\u5efa\u5e73\u9762\uff08Face\uff09<\/li>\n<li>\u6784\u5efa\u4e09\u89d2\u5f62\u7ebf\u6846\uff08Wire\uff09<\/li>\n<\/ul>\n<hr>\n<h2>\u6e90\u7801\u4e0e\u8d44\u6e90\u4e0b\u8f7d<\/h2>\n<ul>\n<li><strong>\u6e90\u4ee3\u7801<\/strong>\uff1a<code>hello_cube.cpp<\/code><\/li>\n<li><strong>STEP \u6a21\u578b<\/strong>\uff1a<code>hello_cube.step<\/code>\uff08\u53ef\u7528 FreeCAD \u7b49\u8f6f\u4ef6\u6253\u5f00\uff09<\/li>\n<li><strong>\u7f16\u8bd1\u73af\u5883<\/strong>\uff1aUbuntu 22.04 + OCCT 7.6.3 + GCC 11.4<\/li>\n<\/ul>\n<hr>\n<p><em>\u5b57\u6570\uff1a\u7ea6 2500 \u5b57 | \u7cfb\u5217\uff1aOpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a | \u96be\u5ea6\uff1a\u5165\u95e8 | \u7248\u672c\uff1a7.6.3<\/em><br \/>\n<em>\u9a8c\u8bc1\u65e5\u671f\uff1a2026-03-01 | \u72b6\u6001\uff1a\u5df2\u9a8c\u8bc1 \u2705 | \u4ee3\u7801\u5df2\u7f16\u8bd1\u8fd0\u884c | \u56fe\u7247\u5df2\u751f\u6210<\/em><\/p>\n<p><\/body><br \/>\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCASCADE \u4ece\u5165\u95e8\u5230\u7cbe\u901a\uff08\u4e00\uff09\uff1a\u73af\u5883\u642d\u5efa \u2013 \u4ece\u96f6\u5f00\u59cb\u914d\u7f6e OCCT \u5f00\u53d1\u73af\u5883 \u4e00\u3001\u672c\u7ae0\u76ee\u6807 \u5b66\u5b8c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":0,"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.alimzs.com\/index.php\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}