qt下使用opencascade源代码

2023-05-16

c++基础太弱,纠正一下,在PRO中使用包含目录就可以使用<>,将下载的opencascade文件通过make编译和安装,添加引用就可以了。


如果你依然对以下没用的操作感兴趣,请继续....


使用PYTHON转换一下包含的文件格式,OCC默认使用的 <XXXX.hxx> qt不能识别,需要转换为 "xxxx.hxx"

补充:在QT的pro文件里添加 INCLUDE += /home/XXXX/Documents/opencascade-7.0.0/src/XXXX ,在头文件里引用即可 比如 #include  <gp_Pnt.hxx>

有知道怎么设置识别的请告诉我 谢谢


以下是python代码,从occ文件夹获取文件到qt程序下的目录

实现功能:指定需要使用的occ源代码文件,从源代码目录拷贝到指定文件夹,并将所有源代码头文件包含的文件也拷贝过来,同事将 #include <xxxx.hxx> 改为 #include "xxxx.hxx"


基本思路

1.设置默认需要的文件们,从源文件夹拷贝过来

2.将已经拷贝过来的文件添加列表sonsList

2.循环读取默认文件,将自己从list清除,检测#include <xxxx.hxx>

3.替换为 "xxxx.hxx"并记录到sonsList

4.从sonsList读取顶部的记录,递归查找

5.查找下一个默认定义的文件


    #coding=utf-8  
      
    #get the file from occ  
    # copy the file and change its header include  
      
    import os  
    import os.path  
    import shutil  
    import re  
      
      
    def findStr(fml_s):  
        match = re.search('(^#include\s+)<(.*\.(hxx|lxx))>', fml_s)  
        if match:  
            ms = match.group()  
            fline = chStr(fml_s)  
            headername=match.group(2)  
            print('find' ,match.group(2))  
            print('find in line',fline)  
            return True, fml_s, headername  
        else:  
            return False, fml_s, ''  
      
    def chStr(fml_s):  
        fml_s = re.sub('<','"occ_math/',fml_s)  
        fml_s=re.sub('>','"',fml_s)  
        return fml_s  
      
    def getPack(fml_s): #get a package name from file name /occ defined it  
        match=re.match('[a-zA-Z0-9]+',fml_s)  
        #print(match.group())  
        return match.group()  
    def rmSuffix(fml_s):  
        match=re.match('(.+)\.+',fml_s)  
        print(match)  
        return match.group(1)  
      
      
    class findSons:  
      
        filename=''  
        occPath= ''  
        ffn=''  
        ct=0  
      
        def __init__(self,fml_sName,fml_soccPath):  
            self.filename=fml_sName  
            self.occPath=fml_soccPath  
            self.tgt_path='/home/kare/Documents//QtProg/mCons1/occ_math'  
            self.ffn=self.tgt_path+'/'+self.filename  
      
        def find(self,fml_s):  
      
            self.filename = fml_s  
            self.ffn = self.tgt_path + '/' + self.filename  
      
            fstr=''  
            fsize=os.path.getsize(self.ffn)  
      
            #copy self  
            lca_pkNam=getPack(self.filename)  
            lca_sName=self.occPath+'/'+lca_pkNam+'/'+self.filename  
            if(os.path.exists(lca_sName) and not os.path.exists(self.ffn)):  
                shutil.copy(lca_sName, tgt_path)  
      
            #remove self from globan list  
            for lca_sn1 in sonList: #remove self  
                if(lca_sn1==self.filename):  
                    sonList.remove(lca_sn1)  
                    break  
      
      
            print('self size:',fsize)  
            fh=open(self.ffn, 'r+')  
            fline=fh.readline()  
            while (fsize != fh.tell()):  # read til ::,its shows that function start  
                brslt, fline, headername = findStr(fline)  # find a name witf 'hxx'  
      
                if (brslt):  # check it in copyfiles  
                    print('find header->'+headername)  
                    fline = chStr(fline)  
                    packname=getPack(headername)  
                    sFn=rmSuffix(headername)  
      
                    hxx=self.occPath + '/' + packname +'/'+ sFn + '.' + 'hxx'  
                    cxx=self.occPath + '/' + packname +'/'+ sFn + '.' + 'cxx'  
                    lxx=self.occPath + '/' + packname +'/'+ sFn+ '.' + 'lxx'  
                    thxx=self.tgt_path+'/'+ sFn + '.' + 'hxx'  
                    tcxx=self.tgt_path+'/'+ sFn+ '.' + 'cxx'  
                    tlxx=self.tgt_path+'/'+ sFn + '.' + 'lxx'  
      
                    if (os.path.exists(hxx) and not os.path.exists(thxx)):  
                        #self.sonList.append(fs2(sFn + '.' + 'hxx',self.occPath))  
                        sonList.append(sFn+'.hxx')  
                        shutil.copy(hxx, tgt_path)  
      
                    if (os.path.exists(cxx) and not os.path.exists(tcxx)):  
                        #self.sonList.append(fs2(sFn + '.' + 'cxx',self.occPath))  
                        sonList.append(sFn+'.cxx')  
                        shutil.copy(cxx, tgt_path)  
      
                    if (os.path.exists(lxx) and not os.path.exists(tlxx)):  
                        #self.sonList.append(fs2(sFn + '.' + 'lxx',self.occPath))  
                        sonList.append(sFn+'.lxx')  
                        shutil.copy(lxx, tgt_path)  
      
      
                fstr+=fline  
                fline=fh.readline()  
      
            fstr+=fline  
            fh.seek(0,0)  
            fh.write(fstr)  
            fh.close()  
            fline=fstr=''  
      
      
        def findRecursion(self):  
            while(len(sonList)!=0):  
                self.find(sonList[0])  
                self.ct+=1  
      
      
    class fs2(findSons):  
        pass  
      
    #default occ path  
    occ_path='/home/kare/Documents/opencascade-7.0.0/src'  
    tgt_path='/home/kare/Documents/QtProg/mCons1/occ_math'  
    copy_files=[] # files been copyed  
    lca_fileList=[]  
      
    #the files you want  
    occ_files=('math_Matrix','math_Vector','gp_Ax1')  
    occ_files_type=('hxx','cxx','lxx')  
      
    allPckName=[] # all kind of packname  
    for lca_name1 in occ_files: # get all packages name  
        lca_pckname=getPack(lca_name1)  
        if(lca_pckname not in allPckName):  
            allPckName.append(lca_pckname)  
      
    lca_str1=input('copyfile? y|n\r\n')  
    if(lca_str1=='y'):  
        #copy the files in define  
        for lca_pcknm in allPckName:  
            #get the files list  
            lca_fileList=os.listdir(occ_path + '/' + lca_pcknm)  
            print('package' + lca_pcknm)  
      
            for lca_file1 in lca_fileList: #all files in package  
                for lca_fnm1 in occ_files: # names be finding  
                    if(lca_fnm1 in lca_file1):# type  
                        print(occ_path +'/' + lca_pcknm + '/' + lca_file1)  
                        shutil.copy(occ_path +'/' + lca_pcknm + '/' + lca_file1, tgt_path)  
                        copy_files.append(lca_file1)  
    print('copy done,start aynlyzing')  
      
    os.chdir(tgt_path)  
    fstr=''  
    fline=''  
    nulLine=0 # space line number  
    bFindOrCh=False # find or change string  
    ct=[]  
      
    if len(copy_files)==0:  
        copy_files=os.listdir()  
      
    lca_fileList = os.listdir(tgt_path)  
    sonList=[]  
    print('start finding')  
    for lca_f in lca_fileList:  
        sonList.append(lca_f)  
        fs=findSons(lca_f,occ_path)  
        fs.findRecursion()  
        ct.append(fs.ct)  
      
    #remain file  
    shutil.copy(occ_path+'/'+'Standard/Standard_values.h',tgt_path)  
      
    print(ct)  
    print('======================done=======================')  

这个脚本会从occ源文件目录拷贝到QT程序目录(需要在代码中设置)

有一个特殊的文件 Standard_Valued.h  需要手动在其他代码中修改引用 <xxxx.h> 为 "xxxx.h"


以下是QT测试代码,可以使用,还没有用到其他的,有问题再解决

#include "occ_math/gp_Pnt.hxx"

extern int testGp()
{
    gp_Pnt p1(100,2,3);
    cout<<p1.X()<<endl;
}



本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

qt下使用opencascade源代码 的相关文章

随机推荐

  • 【C语言】数据结构C语言版 实验7 二叉树

    编写算法函数void preorder1 bintree t 实现二叉树t的非递归前序遍历 include 34 bintree h 34 char a 61 34 ABC D E F 34 扩充二叉树序树t的前序序列 函数preorder
  • 让input标签的range属性显示数值

    lt input type 61 34 range 34 name 61 34 salary 34 max 61 34 20 34 min 61 34 15 34 onchange 61 34 document getElementById
  • 【Linux】安装x11vnc和xrdp,使用windows远程deepin

    一 环境准备 1 已安装deepin 虚拟机或物理机 xff0c 安装教程自行查询 xff0c 很简单 xff0c 此处用的开源版deepin20 1做测试 目前已更新到20 2 2 启用root账号 xff0c 终端执行 xff1a su
  • 吐血整理,Ubuntu必备应用推荐,满满的干货!

    吐血整理 xff0c Ubuntu必备应用推荐 xff0c 满满的干货 xff01 哈喽 xff0c 大家好 xff0c 欢迎收看欢哥TV 我是欢哥 无论你是刚接触Ubuntu xff0c 还是最近从Windows改用Ubuntu xff0
  • Proxmox VE(PVE)添加硬盘做存储

    PVE安装后会默认将系统盘分出local和local lvm xff0c 但有时还需要别的硬盘作为虚拟主机的数据盘 xff0c 所以就需要添加硬盘进行扩充 一 硬盘分区 格式化 首先需要先先看下需添加硬盘的设备名称 xff0c 如下图的 d
  • 差分约束 解决区间选点问题

    题意 xff1a 给定一个数轴上的 n 个区间 xff0c 要求在数轴上选取最少的点使得第 i 个区间 ai bi 里至少有 ci 个点 input 输入第一行一个整数 n 表示区间的个数 xff0c 接下来的 n 行 xff0c 每一行两
  • 【已解决】Microsoft Visual C++ Redistributable is not installed

    Error 导入torch xff0c 提示报错 xff1a Microsoft Visual C 43 43 Redistributable is not installed this may lead to the DLL load f
  • 设置让Windows每天在指定时间自动关机

    其实我们的电脑是可以设置每天在指定的时间点自动关机的 xff0c 具体操作方法 xff1a 1 开打电脑 xff0c 点击电脑系统左下角windows图标 xff0c 选择 控制面板 并进入 xff1b 如图 2 在控制面板界面找到 管理工
  • 在 AlmaLinux 9安装Docker Compose

    首先先安装Docker 如何在 AlmaLinux 8 上安装和使用 Docker 检查Docker版本 docker version 安装Docker Compose sudo curl L 34 https github com doc
  • 使用python搭建一个简单的FTP服务器

    从配置文件获取访问FTP服务器目录的用户名 密码 span class token keyword from span pyftpdlib span class token punctuation span authorizers span
  • 更改win10系统C:\Users\中文用户名为英文用户名

    文章目录 前言一 打开注册表二 查找路径三 重启电脑四 将用中文名与英文名进行链接五 测试是否成功 前言 注意 xff1a 做之前请先浏览一遍 xff0c 做任何操作之前都建议不要直接就做 xff0c 先看一看文档中有哪些操作点是需要小心的
  • Cityscapes数据集的深度完整解析

    cityscapes数据集是分割模型训练时比较常用的一个数据集 xff0c 他还可以用来训练GAN网络生成街景图片 数据集下载和文件夹组成 xff1a 整个数据集包含50个欧洲城市 xff0c 5000张精细标注图像 标注位于gtFine文
  • 使用分支——处理Git merge 冲突

    使用分支 处理Git merge 冲突 版本控制系统就是负责管理来自于多个提交者 xff08 通常是开发者 xff09 之间的提交的 有时候多个开发者可能会编辑同一部分内容 一旦开发者A编辑了开发者B正在编辑的内容 xff0c 冲突就会产生
  • 纯手工解密几大在线js加密网站(1)

    0x0 开头 最近闲来无事 xff0c 来看一下目前网络上哪家加密工具的强度最高的 本人技术有限 xff0c 最终结果不能代表什么 xff0c 大家有遇到什么其他的js加密技术破解难题的 xff0c 也可以一起互相讨论 xff0c 也可以问
  • 纯手工解密几大在线js加密网站(3)

    0x0 开头 续接上章 xff0c 心血来潮想挨个破解一下各大js加密的网站 xff0c 了解一下现有的js加密的逻辑 0x1 介绍 Sojson支持js的不可逆混淆加密 xff0c 和很多高级的加密配置 xff0c 还增加了小白专用的一键
  • 如何在局域网内设置多个网段

    连接状态中的 属性 按钮 xff0c 选择 TCP IPv4 协议 xff0c 点击下面的 属性 按钮 xff0c 点击 高级 按钮 在高级TCP IP设置里面点击 添加 按钮 输入新网段的ip地址 xff08 以192网段为例 xff09
  • B-猫猫向前冲(拓扑排序

    题意 xff1a input 输入有若干组 xff0c 每组中的第一行为二个数N xff08 1 lt 61 N lt 61 500 xff09 xff0c M xff1b 其中N表示猫猫的个数 xff0c M表示接着有M行的输入数据 接下
  • 配置wsl2的图形界面

    1 更新源 span class token function sudo span span class token function apt get span update span class token function sudo s
  • 关于yyyyMMdd的正则表达式的使用

    String pattern 61 34 0 9 3 1 9 0 9 2 1 9 0 9 1 0 9 1 1 9 0 9 2 1 9 0 9 3 34 43 34 0 13578 1 02 0 1 9 12 0 9 3 01 0 469 1
  • qt下使用opencascade源代码

    c 43 43 基础太弱 xff0c 纠正一下 xff0c 在PRO中使用包含目录就可以使用 lt gt xff0c 将下载的opencascade文件通过make编译和安装 xff0c 添加引用就可以了 如果你依然对以下没用的操作感兴趣