第一范文网 - 专业文章范例文档资料分享平台

C++CLI调用ArcObjects (3)

来源:用户分享 时间:2020-06-24 本文由雨博韵潇 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

#pragma once

#include \ using namespace System; namespace NAoWrapper { }

public ref class RefAoWrapper { };

// TODO: Add your methods for this class here. AoHelper *ao; int line_test(); RefAoWrapper(); ~RefAoWrapper(); private: public:

修改NAoWrapper.cpp

// This is the main DLL file.

#include \ #include \

using namespace System::Diagnostics;

namespace NAoWrapper {

int RefAoWrapper ::line_test() {

Stopwatch^ watch=gcnew Stopwatch(); watch->Start();

RefAoWrapper::~RefAoWrapper() { }

delete ao;

RefAoWrapper::RefAoWrapper() { }

ao=new AoHelper();

}

}

ao->line_test(); watch->Stop();

Console::WriteLine(watch->ElapsedMilliseconds); return 0;

5 添加新项目,命名为CSharpAoHeleper,C#直接调用ArcObjects

添加ESRI.ArcGIS.相关引用

将Class1.cs重命名为CSharpAoHeleper,代码如下

using System;

using System.Collections.Generic; using System.Linq; using System.Text;

using ESRI.ArcGIS.Geometry; using System.Diagnostics;

namespace CSharpAoHeleper {

public class CSharpAoHeleper {

public int line_test() {

IPoint ipPt1 = new PointClass(); IPoint ipPt2 = new PointClass(); ipPt1.PutCoords(1, 2); ipPt2.PutCoords(2, 3);

ILine ipLine = new LineClass();

Stopwatch watch = new Stopwatch(); watch.Start();

for (long i = 0; i <= 10000000; i++) {

ipLine.PutCoords(ipPt1, ipPt2); //Console::WriteLine(i); }

watch.Stop();

Console.WriteLine(watch.ElapsedMilliseconds);

return 0; } } }

编译,完成C#直接操作AO封装库

6 添加新项目,命名为Test

右键项目属性,修改输出路径(Output path):即AoWrapperDemo\\Debug目录

添加ESRI.AcrGIS.相关引用 添加项目引用

修改Program.cs

using System; using ESRI.ArcGIS;

using ESRI.ArcGIS.esriSystem;

namespace Test {

static class Program {

///

/// The main entry point for the application. ///

[STAThread]

static void Main() {

if (!RuntimeManager.Bind(ProductCode.Engine))

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新高中教育C++CLI调用ArcObjects (3)全文阅读和word下载服务。

C++CLI调用ArcObjects (3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1100362.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top