zoukankan      html  css  js  c++  java
  • Building OpenCascade on Windows with Visual Studio

    Building OpenCascade on Windows with Visual Studio

    Building OpenCascade on Windows with Visual Studio

    eryar@163.com

     

    摘要Abstract:详细说明OpenCascade的编译配置过程,希望对你编译OpenCascacde有所帮助。本文内容来自OCCTOverview文档,详细信息可参考之。

    关键字Key WordsOpenCascadeCompiling

     

    一、源码包 Source package

    OpenCascade的源码包中包括OpenCascade的源代码、示例程序源代码及预先编译好的二进制程序。编译工具也提供了,在Windows平台上是Visual C++的工程文件,在Unix平台上是Makefile

     

    二、目录文件说明 Description of the Directory Tree

      l ros/adm/cmake:包含CMake的创建过程;

      l ros/adm/lin/amk:包含Automake创建过程;

      l ros/adm/mac/cbp:包含Code::Blocks工程;

      l Ros/adm/mac/xcd:包含Xcode工程;

      l Ros/adm/msvc:包含Visual Studio工程,支持的Visual Studio版本有Visual C++ 2005200820102012,可以在Windows平台上编译32位和64位的  OpenCascade

      l Ros/data:包含各种文件格式的数据,可以在OCCT中试验用;

      l Ros/doc/Overview:包含简要介绍OCCT的文档;

      l Ros/doc/ReferenceDocumentation:包含由Doxygen生成的OCCT参考文档;

      l Ros/drv:包含由WOK生成的源代码文件;

      l Ros/inc:包含所有OCCT的头文件;

      l Ros/src:包含OCCT的源代码,它们以文件夹的方式组织,一个开发单元一个文件夹;

      l Ros/samples:包含OCCT的示例程序及其源代码。(C#MFC的示例只适用于Windows平台。);

      l Ros/tests:包含OCCT的测试脚本;

     

     

     

     

     

     

     

     

     

     

     

    三、先决条件 Common pre-requisites

    OpenCascade Technology使用经支持的编译器认证的STL实现。尽管源码也可以在其他实现上重新编译(如STLPort),但是OpenCascade S.A.S对其稳定性不作任何保证。

    重新编译OpenCascade Technology需要2GB的可用硬盘空间;

    编译之前,你需要重新编译或安装第三方库(必须的第三方库是:tcl/tk8.5.8freetype2.4.10;可选的第三方库是:gl2ps1.3.5freeimage3.14.1tbb。);

     

    四、编译设置 Building on Windows with Visual Studio project files

    在编译之前,必须设置第三方库的头文件和库文件的路径。第三方库有TclTkFreeTypeFreeImagegl2psTBB。可以在Visual Studio的工具->选项中的目录来设置,也可以配置批处理文件custom.bat来设置。最好是通过批处理文件custom.bat来设置。

    gl2psTBBFreeImage是可选的第三方库。通过变量CSF_DEFINES来指定是否在编译OpenCascade中使用他们。

    HAVE_TBB:若想在OCCT中使用IntelTBB(内在管理);

    HAVE_FREEIMAGE:若想在OCCT中使用FreeImage

    HAVE_GL2PS:若想在OCCT中使用gl2ps

    不使用上述的三个库的custom.bat文件内容如下所示:

    set HAVE_FREEIMAGE=false

    set HAVE_GL2PS=false

    set HAVE_TBB=false

    这样定义在env.bat中产生在字符串的设置效果为: set CSF_DEFINES=

     

    使用上述三个库的custom.bat设置如下所示:

    set HAVE_FREEIMAGE=true

    set HAVE_GL2PS=true

    set HAVE_TBB=true

    这样定义在env.bat中产生的字符串的设置效果为:

    set CSF_DEFINES=HAVE_TBB;HAVE_FREEIMAGE;HAVE_GL2PS

     

    配置好custom.bat后,就可以用ros子文件夹中的msvc.bat来启动MS Visual Studio了,这样编译OCCT的环境变量已经设置好了。启动msvc.bat可以带可选参数:

    参数1:启动的Visual Studio的版本(vc8, vc9, vc10, vc11);

    参数2:系统架构(win32, win64);

    参数3:编译模式(Debug, Release);

    参数4Visual Studio解决方案路径;

    Windows平台上编译生成的库(dll, dlld, lib, libd)和可执行程序(exe)分别在文件夹ros/win32/vc8, vc9, vc10, vc11,或64位的在ros/win64文件夹中。

    文件夹ros/adm/msvc中包含vc8, vc9, vc10, vc11Visual Studio工程文件,可用来分别生成32位和64位的OCCT

     

    下列所示的workspaces必须按顺序编译:

    1. Foundation Classes (file FoundationClasses.sln)

    2. Modeling Data(file ModelingData.sln)

    3. Modeling Algorithms(file ModelingAlgorithms.sln)

    4. Visualization(file Visualization.sln)

    5. Application Framework(file ApplicationFramework.sln)

    6. Data Exchange(file DataExchange.sln)

    7. Draw(file Draw.sln)

     

    另外,包含所有工程文件的解决方案文件OCCT.sln也提供了,可以用OCCT.sln来编译一个完整的OCCT库。即直接运行:

    msvc.bat vc11 win64 Debug 

     

    [源代码] - C#代码搜索器 - 续

    在前文 [源代码] - C#代码搜索器 中我开发了一个代码搜索器. 我对其做的最后改动是将索引保存到磁盘中, 以备今后使用.

    如今, 我在工作中又接到一项新任务: 有一个大项目, 其中10个负责数据访问的service即将被淘汰, 将会替换成entity framework的方式. 这10个service一共有近130个operation. 项目中所有调用这些operation的地方都必须被替换成新的EF方式. 整个项目有47902个cs文件. 现在要做个分析, 找到所有需要修改的地方.

    稍作思考, 开工! 

    先创建一个console project, 引入WEBUS2.0 SDK. 将10个service和130个operation的信息放到字符串数组中:

    复制代码
    static string[] DS_OP_List = new string[] {
        "xxxxDS.CalculatePilotCloseOut",
        "xxxxDS.CreatexxFirstAcont",
        "xxxxDS.CreatexxUnallocatedULD",
        "xxxxDS.xxCargoGetTare",
        "xxxxDS.xxCargoCreateAbulk",
        "xxxxDS.xxCargoDeleteAbulk",
        "xxxxDS.xxCargoMoveAbulk"
        ...
    }; //共130个, 公司有规定, 所以用xxx替代真实值 :)
    复制代码

    然后打开Index (关于如何创建Index请参见前文:  [源代码] - C#代码搜索器), 再循环对operation进行搜索:

    复制代码
    static void Main(string[] args)
    {
        IIndexer index = new IndexManager(); //构造索引对象
        index.Open(@"C:xxxCodeSearch.Index", IndexOpenMode.Read); //以只读方式打开索引
        ISearcher se = new IndexSearcher(index); //构造搜索对象
        using (CSVFile csv = new CSVFile(@"c:	empxx_DS_Analysis.csv")) //将结果保存在csv文件中
        {
            foreach (var ds_op in DS_OP_List)
            {
                var key = ds_op.Split('.')[1].ToLower(); //从Service.Operation中提取Operation, 比如从xxxxDS.CalculatePilotCloseOut中提取CalculatePilotCloseOut中提取
                var hits = se.Search(string.Format("Code="{0}"", key)); //搜索表达式: Code="CalculatePilotCloseOut"
                Console.WriteLine("{0}/{1}", key, hits.Count);
                foreach (HitDoc hit in hits)
                {
                    csv.Write(ds_op, hit.GetDoc().GetField("FileName").Value.ToString()); //依次输出"服务名", "方法名", "文件名"到csv中
                }
            }
        }
        Console.ReadLine();
    }
    复制代码

    最后上一个生成CSV文件的工具类:

    复制代码
     View Code

    public class CSVFile : IDisposable
    {
    public string FileName { get; private set; }
    private StreamWriter sw = null;
    private StreamReader sr = null;
    private FileStream fsWrite = null;
    private FileStream fsRead = null;

    public CSVFile(string filename)
    : this(filename, Encoding.UTF8, FileMode.OpenOrCreate)
    {
    }

    public CSVFile(string filename, FileMode mode)
    : this(filename, Encoding.UTF8, mode)
    {
    }

    public CSVFile(string filename, Encoding encoding, FileMode mode)
    {
    this.FileName = filename;
    fsWrite = new FileStream(filename, mode, FileAccess.Write, FileShare.Read);
    fsWrite.Seek(0, SeekOrigin.End);
    fsRead = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
    sw = new StreamWriter(fsWrite, encoding);
    sr = new StreamReader(fsRead, encoding);
    }

    public void Close()
    {
    sw.Close();
    sr.Close();
    }

    public string[] Read()
    {
    string text = sr.ReadLine();
    if (string.IsNullOrEmpty(text))
    {
    return null;
    }
    return text.Split(',');
    }

    public string[] FindNext(string startKeyword, StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase)
    {
    string[] result = null;
    while ((result = this.Read()) != null)
    {
    if (result[0].StartsWith(startKeyword, comparisonType))
    {
    return result;
    }
    else
    {
    continue;
    }
    }
    return null;
    }

    public void Write(params string[] values)
    {
    StringBuilder sb = new StringBuilder();
    foreach (var v in values)
    {
    sb.Append(v + ",");
    }
    sw.WriteLine(sb.ToString().Substring(0, sb.Length - 1));
    }

    public void Dispose()
    {
    this.Close();
    }
    }

    复制代码

    ok, 大功告成! 运行:

     
     
    分类: WEBUS
     
     
  • 相关阅读:
    PossibleOrders TopCoder
    505C Mr. Kitayuta, the Treasure Hunter
    p2257 YY的GCD
    浅谈莫比乌斯反演
    Hive基础(3)---Fetch Task(转)
    Hive基础(2)---(启动HiveServer2)Hive严格模式
    mysql 命令行参数
    Hive基础(1)---Hive是什么
    mybatis运行时错误Illegal argument exception argument type mismatch
    【TOMCAT启动异常】The BASEDIR environment variable is not defined correctly
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/3271555.html
Copyright © 2011-2022 走看看