{"id":2096,"date":"2024-02-19T17:15:29","date_gmt":"2024-02-19T09:15:29","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=2096"},"modified":"2024-02-19T17:15:29","modified_gmt":"2024-02-19T09:15:29","slug":"vtk8-2%e7%ae%80%e5%8d%95%e9%85%8d%e7%bd%ae%e4%b8%8e%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2024\/02\/19\/vtk8-2%e7%ae%80%e5%8d%95%e9%85%8d%e7%bd%ae%e4%b8%8e%e6%b5%8b%e8%af%95\/","title":{"rendered":"VTK8.2\u7b80\u5355\u914d\u7f6e\u4e0e\u6d4b\u8bd5"},"content":{"rendered":"\n<p>\u5728 Visual Studio \u4e2d\u8bbe\u7f6e VTK \u5e93\u7684\u5f15\u7528\u548c\u914d\u7f6e\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>\u4e0b\u8f7d VTK\uff1a<\/strong> \u9996\u5148\uff0c\u60a8\u9700\u8981\u4e0b\u8f7d\u5e76\u89e3\u538b VTK \u5e93\u3002\u60a8\u53ef\u4ee5\u4ece VTK \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6e90\u4ee3\u7801\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u63d0\u4f9b\u7684\u8bf4\u660e\u8fdb\u884c\u7f16\u8bd1\uff0c\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u5bfb\u627e\u9884\u7f16\u8bd1\u7684\u7248\u672c\u3002<\/li><li><strong>\u521b\u5efa Visual Studio \u9879\u76ee\uff1a<\/strong> \u6253\u5f00 Visual Studio\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 C++ \u9879\u76ee\u3002<\/li><li><strong>\u8bbe\u7f6e\u5305\u542b\u76ee\u5f55\u548c\u5e93\u76ee\u5f55\uff1a<\/strong><ul><li>\u5728 Visual Studio \u4e2d\uff0c\u53f3\u952e\u5355\u51fb\u60a8\u7684\u9879\u76ee\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li><li>\u5728\u5c5e\u6027\u5bf9\u8bdd\u6846\u4e2d\uff0c\u9009\u62e9\u201cC\/C++\u201d &gt; \u201c\u5e38\u89c4\u201d\uff0c\u7136\u540e\u5728\u201c\u9644\u52a0\u5305\u542b\u76ee\u5f55\u201d\u4e2d\u6dfb\u52a0 VTK \u5934\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/li><li>\u7136\u540e\u9009\u62e9\u201c\u94fe\u63a5\u5668\u201d &gt; \u201c\u5e38\u89c4\u201d\uff0c\u5728\u201c\u9644\u52a0\u5e93\u76ee\u5f55\u201d\u4e2d\u6dfb\u52a0 VTK \u5e93\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/li><\/ul><\/li><li><strong>\u8bbe\u7f6e\u9644\u52a0\u4f9d\u8d56\u9879\uff1a<\/strong><ul><li>\u5728\u5c5e\u6027\u5bf9\u8bdd\u6846\u4e2d\uff0c\u9009\u62e9\u201c\u94fe\u63a5\u5668\u201d &gt; \u201c\u8f93\u5165\u201d\uff0c\u5728\u201c\u9644\u52a0\u4f9d\u8d56\u9879\u201d\u4e2d\u6dfb\u52a0\u9700\u8981\u94fe\u63a5\u7684 VTK \u5e93\u6587\u4ef6\u540d\uff08\u5982 <code>vtkCommon.lib<\/code>\u3001<code>vtkRenderingOpenGL2.lib<\/code> \u7b49\uff09\u3002<\/li><\/ul><\/li><li><strong>\u8bbe\u7f6e\u8fd0\u884c\u65f6\u5e93\uff1a<\/strong><ul><li>\u5728\u5c5e\u6027\u5bf9\u8bdd\u6846\u4e2d\uff0c\u9009\u62e9\u201cC\/C++\u201d &gt; \u201c\u4ee3\u7801\u751f\u6210\u201d\uff0c\u5c06\u201c\u8fd0\u884c\u65f6\u5e93\u201d\u8bbe\u7f6e\u4e3a\u4e0e VTK \u5e93\u76f8\u5339\u914d\u7684\u8fd0\u884c\u65f6\u5e93\u7c7b\u578b\uff08\u5982 <code>\/MT<\/code> \u6216 <code>\/MTd<\/code>\uff09\u3002<\/li><\/ul><\/li><li><strong>\u5c06 VTK DLL \u6587\u4ef6\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\uff1a<\/strong> \u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u9884\u7f16\u8bd1\u7684 VTK \u5e93\uff0c\u90a3\u4e48\u5728\u8fd0\u884c\u65f6\u60a8\u9700\u8981\u5c06 VTK DLL \u6587\u4ef6\u590d\u5236\u5230\u60a8\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u76ee\u5f55\u4e2d\u3002<\/li><\/ol>\n\n\n\n<p>\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u540e\uff0c\u60a8\u7684\u9879\u76ee\u5c31\u5e94\u8be5\u80fd\u591f\u6b63\u786e\u5730\u94fe\u63a5\u548c\u4f7f\u7528 VTK \u5e93\u4e86\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 VTK \u63d0\u4f9b\u7684\u5404\u79cd\u7c7b\u6765\u6784\u5efa\u60a8\u7684\u56fe\u5f62\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u60a8\u7684\u4ee3\u7801\u4e2d\u5305\u542b VTK \u5934\u6587\u4ef6\u5e76\u4f7f\u7528 VTK \u7c7b\u5373\u53ef\u5f00\u59cb\u7f16\u5199\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u522b\u4eba\u5df2\u7ecf\u7f16\u8bd1\u597d\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>\u51fa\u73b0\u4e0b\u9762\u62a5\u9519\u65f6\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Generic Warning: In G:VTKVTK-8.2.0RenderingiCorelvtkPolyDataMapper.cxx, line 28Error: no override found for vtkPolyDataMapper&#8217;.<\/p><\/blockquote>\n\n\n\n<p>\u4ee3\u7801\u5934\u6587\u4ef6\u6dfb\u52a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;vtkAutoInit.h>\nVTK_MODULE_INIT(vtkRenderingOpenGL2);\nVTK_MODULE_INIT(vtkInteractionStyle);<\/code><\/pre>\n\n\n\n<p>\u5c5e\u6027&#8212;&#8212;&#8211;\u94fe\u63a5\u5668&#8212;&#8212;\u8f93\u5165&#8212;\u9644\u52a0\u4f9d\u8d56\u9879&#8212;&#8212;\u6dfb\u52a0\uff1aopengl32.lib<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;vtkSmartPointer.h>\n#include &lt;vtkSphereSource.h>\n#include &lt;vtkPolyDataMapper.h>\n#include &lt;vtkActor.h>\n#include &lt;vtkRenderer.h>\n#include &lt;vtkRenderWindow.h>\n#include &lt;vtkRenderWindowInteractor.h>\n#include &lt;vtkAutoInit.h>\nVTK_MODULE_INIT(vtkRenderingOpenGL2);\nVTK_MODULE_INIT(vtkInteractionStyle);\n\nint main()\n{\n    \/\/ \u521b\u5efa\u4e00\u4e2a\u7403\u4f53\u6e90\n    vtkSmartPointer&lt;vtkSphereSource> sphereSource = vtkSmartPointer&lt;vtkSphereSource>::New();\n    sphereSource->SetRadius(1.0);\n    sphereSource->Update();\n\n    \/\/ \u521b\u5efa\u4e00\u4e2a mapper\n    vtkSmartPointer&lt;vtkPolyDataMapper> mapper = vtkSmartPointer&lt;vtkPolyDataMapper>::New();\n    mapper->SetInputConnection(sphereSource->GetOutputPort());\n\n    \/\/ \u521b\u5efa\u4e00\u4e2a actor\n    vtkSmartPointer&lt;vtkActor> actor = vtkSmartPointer&lt;vtkActor>::New();\n    actor->SetMapper(mapper);\n\n    \/\/ \u521b\u5efa\u6e32\u67d3\u5668\u548c\u6e32\u67d3\u7a97\u53e3\n    vtkSmartPointer&lt;vtkRenderer> renderer = vtkSmartPointer&lt;vtkRenderer>::New();\n    vtkSmartPointer&lt;vtkRenderWindow> renderWindow = vtkSmartPointer&lt;vtkRenderWindow>::New();\n    renderWindow->AddRenderer(renderer);\n\n    \/\/ \u521b\u5efa\u4ea4\u4e92\u5668\n    vtkSmartPointer&lt;vtkRenderWindowInteractor> interactor = vtkSmartPointer&lt;vtkRenderWindowInteractor>::New();\n    interactor->SetRenderWindow(renderWindow);\n\n    \/\/ \u5c06 actor \u6dfb\u52a0\u5230\u6e32\u67d3\u5668\u4e2d\n    renderer->AddActor(actor);\n\n    \/\/ \u8bbe\u7f6e\u6e32\u67d3\u5668\u7684\u80cc\u666f\u8272\u4e3a\u7070\u8272\n    renderer->SetBackground(0.2, 0.2, 0.2);\n\n    \/\/ \u542f\u52a8\u6e32\u67d3\n    renderWindow->Render();\n\n    \/\/ \u5f00\u59cb\u4ea4\u4e92\n    interactor->Start();\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u6548\u679c\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/sanlangcode.com\/wp-content\/uploads\/2024\/02\/image-1024x739.png\" alt=\"\" class=\"wp-image-2098\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Visual Studio &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[],"class_list":["post-2096","post","type-post","status-publish","format-standard","hentry","category-vtk"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=2096"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2096\/revisions"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=2096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=2096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=2096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}