屌炸天的3D引擎OpenCASCADE的用法及案例(转载之处:)
What CASCADE?
Open CASCADE(简称OCC)平台是由法国Matra Datavision公司开发的CAD/CAE/CAM软件平台,可以说是世界上最重要的几何造型基础软件平台之一。开源OCC对象库是一个面向对象C++类库,用于快速开发设计领域的专业应用程序。
用它可以做很多三维模型,如下面两种。简单地说它可以开发三维CAD或者Solidworks等等软件,可以说强大无比。
OpenCASCADE的下载与安装
1.OpenCASCADE下载。
1)去官网下载:https://dev.opencascade.org/release
2)去CSDN下载:https://download.csdn.net/download/xipengbozai/18883824
3)下载你需要的版本,推荐下载安装版,比较省事:https://download.csdn.net/download/xipengbozai/18883824
2.OpenCASCADE安装。
1)匹配VS版本,我的是VS2017 64位版本,所以安装的是opencascade-7.4.0-vc14-64.exe
2)单机安装,选择下一步
3)然后安装full版本,也就是完全版,单击安装直到完成即可。
4)安装完的目录效果,opencascade-7.4.0是主目录,其他是附加库
OpenCASCADE的用法
1.建立项目工程,包含目录
2.添加库目录,如下所示
3.链接器-输入-附加依赖项输入如下项
TKBin.lib
TKBinL.lib
TKBinTObj.lib
TKBinXCAF.lib
TKBO.lib
TKBool.lib
TKBRep.lib
TKCAF.lib
TKCDF.lib
TKD3DHost.lib
TKDCAF.lib
TKDFBrowser.lib
TKDraw.lib
TKernel.lib
TKFeat.lib
TKFillet.lib
TKG2d.lib
TKG3d.lib
TKGeomAlgo.lib
TKGeomBase.lib
TKHLR.lib
TKIGES.lib
TKIVtk.lib
TKIVtkDraw.lib
TKLCAF.lib
TKMath.lib
TKMesh.lib
TKMeshVS.lib
TKOffset.lib
TKOpenGl.lib
TKPrim.lib
TKQADraw.lib
TKRWMesh.lib
TKService.lib
TKShapeView.lib
TKShHealing.lib
TKStd.lib
TKStdL.lib
TKSTEP.lib
TKSTEP209.lib
TKSTEPAttr.lib
TKSTEPBase.lib
TKSTL.lib
TKTInspector.lib
TKTInspectorAPI.lib
TKTObj.lib
TKTObjDRAW.lib
TKToolsDraw.lib
TKTopAlgo.lib
TKTopTest.lib
TKTreeModel.lib
TKV3d.lib
TKVCAF.lib
TKView.lib
TKViewerTest.lib
TKVInspector.lib
TKVRML.lib
TKXCAF.lib
TKXDEDRAW.lib
TKXDEIGES.lib
TKXDESTEP.lib
TKXMesh.lib
TKXml.lib
TKXmlL.lib
TKXmlTObj.lib
TKXmlXCAF.lib
TKXSBase.lib
TKXSDRAW.lib
4.添加头文件,一定要注意添加位置,#include <afxdisp.h> // MFC 自动化类之后,#ifndef _AFX_NO_OLE_SUPPORT之前的中间。
include <BRepTools.hxx>
include <Standard_DefineHandle.hxx>
include <DsgPrs_LengthPresentation.hxx>
include <GCPnts_TangentialDeflection.hxx>
include <Geom_Axis2Placement.hxx>
include <Geom_CartesianPoint.hxx>
include <Geom_Line.hxx>
include <Geom_Surface.hxx>
include <BRepAdaptor_Surface.hxx>
include <GeomAbs_CurveType.hxx>
include <GeomAdaptor_Curve.hxx>
include <GeomTools_Curve2dSet.hxx>
include <gp_Vec.hxx>
include <Graphic3d_NameOfMaterial.hxx>
include <MMgt_TShared.hxx>
include <OSD_Environment.hxx>
include <Precision.hxx>
include <Prs3d_IsoAspect.hxx>
include <Prs3d_LineAspect.hxx>
include <Prs3d_Projector.hxx>
include <Prs3d_Text.hxx>
include <Quantity_Factor.hxx>
include <Quantity_Length.hxx>
include <Quantity_NameOfColor.hxx>
include <Quantity_PhysicalQuantity.hxx>
include <Quantity_PlaneAngle.hxx>
include <Quantity_TypeOfColor.hxx>
include <SelectMgr_EntityOwner.hxx>
include <SelectMgr_SelectableObject.hxx>
include <SelectMgr_Selection.hxx>
include <SelectMgr_SelectionManager.hxx>
include <SelectMgr_ListOfFilter.hxx>
include <SelectMgr_Filter.hxx>
include <StdSelect_EdgeFilter.hxx>
include <StdSelect_ShapeTypeFilter.hxx>
include <Standard_Boolean.hxx>
include <Standard_CString.hxx>
include <Standard_ErrorHandler.hxx>
include <Standard_Integer.hxx>
include <Standard_IStream.hxx>
include <Standard_Macro.hxx>
include <Standard_NotImplemented.hxx>
include <Standard_OStream.hxx>
include <Standard_Real.hxx>
include <StdPrs_Curve.hxx>
include <StdPrs_Point.hxx>
include <StdPrs_PoleCurve.hxx>
include <TCollection_AsciiString.hxx>
include <TColgp_Array1OfPnt2d.hxx>
include <TColgp_HArray1OfPnt2d.hxx>
include <TCollection_AsciiString.hxx>
include <TColStd_HSequenceOfTransient.hxx>
include <TColStd_MapIteratorOfMapOfTransient.hxx>
include <TColStd_MapOfTransient.hxx>
include <TopExp_Explorer.hxx>
include <TopoDS.hxx>
include <TopoDS_Compound.hxx>
include <TopoDS_Shape.hxx>
include <TopoDS_Solid.hxx>
include <TopoDS_Vertex.hxx>
include <TopExp.hxx>
include <TopTools_HSequenceOfShape.hxx>
include <UnitsAPI.hxx>
include <V3d_View.hxx>
include <V3d_Viewer.hxx>
include <WNT_Window.hxx>
include <Prs3d_PointAspect.hxx>
include <AIS_Point.hxx>
include <AIS_InteractiveContext.hxx>
include <AIS_Shape.hxx>
include <BRep_Tool.hxx>
include <BRepAlgoAPI_Fuse.hxx>
include <BRepBuilderAPI_MakeEdge.hxx>
include <BRepBuilderAPI_MakeFace.hxx>
include <BRepBuilderAPI_MakeWire.hxx>
include <BRepBuilderAPI_MakeVertex.hxx>
include <BRepBuilderAPI_Transform.hxx>
include <BRepPrimAPI_MakeCone.hxx>
include <BRepPrimAPI_MakeRevol.hxx>
include <BRepFilletAPI_MakeFillet.hxx>
include <BRepBuilderAPI_Copy.hxx>
include <BRepBuilderAPI_MakePolygon.hxx>
include <BRepLib.hxx>
include <BRepOffsetAPI_MakeThickSolid.hxx>
include <BRepOffsetAPI_ThruSections.hxx>
include <BRepPrimAPI_MakeCylinder.hxx>
include <BRepPrimAPI_MakePrism.hxx>
include <BRepPrimAPI_MakeTorus.hxx>
include <BRepAlgoAPI_Section.hxx>
include <BRepPrimAPI_MakeSphere.hxx>
include <BRepFeat_SplitShape.hxx>
include <TColgp_HArray1OfPnt.hxx>
include <GeomAPI_Interpolate.hxx>
include <GC_MakeArcOfCircle.hxx>
include <GC_MakeSegment.hxx>
include <GC_MakeCircle.hxx>
include <GCE2d_MakeSegment.hxx>
include <gp.hxx>
include <gp_Ax1.hxx>
include <gp_Ax2.hxx>
include <gp_Ax2d.hxx>
include <gp_Dir.hxx>
include <gp_Dir2d.hxx>
include <gp_Pnt.hxx>
include <gp_Pnt2d.hxx>
include <gp_Trsf.hxx>
include <gp_Vec.hxx>
include <Geom_CylindricalSurface.hxx>
include <Geom_Plane.hxx>
include <Geom_Surface.hxx>
include <Geom_TrimmedCurve.hxx>
include <Geom2d_Ellipse.hxx>
include <Geom2d_TrimmedCurve.hxx>
include <TopExp_Explorer.hxx>
include <TopoDS.hxx>
include <TopoDS_Edge.hxx>
include <TopoDS_Face.hxx>
include <TopoDS_Wire.hxx>
include <TopoDS_Shape.hxx>
include <TopoDS_Compound.hxx>
include <GCPnts_AbscissaPoint.hxx>
include <BRepAdaptor_Curve.hxx>
include <GeomLib.hxx>
include <GeomConvert_CompCurveToBSplineCurve.hxx>
include <TopTools_ListOfShape.hxx>
include <TopTools_ListIteratorOfListOfShape.hxx>
include <TopTools_DataMapOfShapeInteger.hxx>
include <TopTools_DataMapOfShapeReal.hxx>
include <TopTools_IndexedDataMapOfShapeAddress.hxx>
include <V3d_PositionalLight.hxx>
include <V3d_DirectionalLight.hxx>
include <V3d_AmbientLight.hxx>
include <IGESControl_Controller.hxx>
include <IGESControl_Writer.hxx>
include <Interface_Static.hxx>
include <OpenGl_GraphicDriver.hxx>
include <Graphic3d_GraphicDriver.hxx>
OpenCASCADE开发案例
1.建立MFC工程
2.stdafx.h头文件中包含OpenCASCADE头文件
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
pragma once
ifndef VC_EXTRALEAN
define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
endif
include "targetver.h"
define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
// 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏
define _AFX_ALL_WARNINGS
include <afxwin.h> // MFC 核心组件和标准组件
include <afxext.h> // MFC 扩展
include <afxdisp.h> // MFC 自动化类
include <BRepTools.hxx>
include <Standard_DefineHandle.hxx>
include <DsgPrs_LengthPresentation.hxx>
include <GCPnts_TangentialDeflection.hxx>
include <Geom_Axis2Placement.hxx>
include <Geom_CartesianPoint.hxx>
include <Geom_Line.hxx>
include <Geom_Surface.hxx>
include <BRepAdaptor_Surface.hxx>
include <GeomAbs_CurveType.hxx>
include <GeomAdaptor_Curve.hxx>
include <GeomTools_Curve2dSet.hxx>
include <gp_Vec.hxx>
include <Graphic3d_NameOfMaterial.hxx>
include <MMgt_TShared.hxx>
include <OSD_Environment.hxx>
include <Precision.hxx>
include <Prs3d_IsoAspect.hxx>
include <Prs3d_LineAspect.hxx>
include <Prs3d_Projector.hxx>
include <Prs3d_Text.hxx>
include <Quantity_Factor.hxx>
include <Quantity_Length.hxx>
include <Quantity_NameOfColor.hxx>
include <Quantity_PhysicalQuantity.hxx>
include <Quantity_PlaneAngle.hxx>
include <Quantity_TypeOfColor.hxx>
include <SelectMgr_EntityOwner.hxx>
include <SelectMgr_SelectableObject.hxx>
include <SelectMgr_Selection.hxx>
include <SelectMgr_SelectionManager.hxx>
include <SelectMgr_ListOfFilter.hxx>
include <SelectMgr_Filter.hxx>
include <StdSelect_EdgeFilter.hxx>
include <StdSelect_ShapeTypeFilter.hxx>
include <Standard_Boolean.hxx>
include <Standard_CString.hxx>
include <Standard_ErrorHandler.hxx>
include <Standard_Integer.hxx>
include <Standard_IStream.hxx>
include <Standard_Macro.hxx>
include <Standard_NotImplemented.hxx>
include <Standard_OStream.hxx>
include <Standard_Real.hxx>
include <StdPrs_Curve.hxx>
include <StdPrs_Point.hxx>
include <StdPrs_PoleCurve.hxx>
include <TCollection_AsciiString.hxx>
include <TColgp_Array1OfPnt2d.hxx>
include <TColgp_HArray1OfPnt2d.hxx>
include <TCollection_AsciiString.hxx>
include <TColStd_HSequenceOfTransient.hxx>
include <TColStd_MapIteratorOfMapOfTransient.hxx>
include <TColStd_MapOfTransient.hxx>
include <TopExp_Explorer.hxx>
include <TopoDS.hxx>
include <TopoDS_Compound.hxx>
include <TopoDS_Shape.hxx>
include <TopoDS_Solid.hxx>
include <TopoDS_Vertex.hxx>
include <TopExp.hxx>
include <TopTools_HSequenceOfShape.hxx>
include <UnitsAPI.hxx>
include <V3d_View.hxx>
include <V3d_Viewer.hxx>
include <WNT_Window.hxx>
include <Prs3d_PointAspect.hxx>
include <AIS_Point.hxx>
include <AIS_InteractiveContext.hxx>
include <AIS_Shape.hxx>
include <BRep_Tool.hxx>
include <BRepAlgoAPI_Fuse.hxx>
include <BRepBuilderAPI_MakeEdge.hxx>
include <BRepBuilderAPI_MakeFace.hxx>
include <BRepBuilderAPI_MakeWire.hxx>
include <BRepBuilderAPI_MakeVertex.hxx>
include <BRepBuilderAPI_Transform.hxx>
include <BRepPrimAPI_MakeCone.hxx>
include <BRepPrimAPI_MakeRevol.hxx>
include <BRepFilletAPI_MakeFillet.hxx>
include <BRepBuilderAPI_Copy.hxx>
include <BRepBuilderAPI_MakePolygon.hxx>
include <BRepLib.hxx>
include <BRepOffsetAPI_MakeThickSolid.hxx>
include <BRepOffsetAPI_ThruSections.hxx>
include <BRepPrimAPI_MakeCylinder.hxx>
include <BRepPrimAPI_MakePrism.hxx>
include <BRepPrimAPI_MakeTorus.hxx>
include <BRepAlgoAPI_Section.hxx>
include <BRepPrimAPI_MakeSphere.hxx>
include <BRepFeat_SplitShape.hxx>
include <TColgp_HArray1OfPnt.hxx>
include <GeomAPI_Interpolate.hxx>
include <GC_MakeArcOfCircle.hxx>
include <GC_MakeSegment.hxx>
include <GC_MakeCircle.hxx>
include <GCE2d_MakeSegment.hxx>
include <gp.hxx>
include <gp_Ax1.hxx>
include <gp_Ax2.hxx>
include <gp_Ax2d.hxx>
include <gp_Dir.hxx>
include <gp_Dir2d.hxx>
include <gp_Pnt.hxx>
include <gp_Pnt2d.hxx>
include <gp_Trsf.hxx>
include <gp_Vec.hxx>
include <Geom_CylindricalSurface.hxx>
include <Geom_Plane.hxx>
include <Geom_Surface.hxx>
include <Geom_TrimmedCurve.hxx>
include <Geom2d_Ellipse.hxx>
include <Geom2d_TrimmedCurve.hxx>
include <TopExp_Explorer.hxx>
include <TopoDS.hxx>
include <TopoDS_Edge.hxx>
include <TopoDS_Face.hxx>
include <TopoDS_Wire.hxx>
include <TopoDS_Shape.hxx>
include <TopoDS_Compound.hxx>
include <GCPnts_AbscissaPoint.hxx>
include <BRepAdaptor_Curve.hxx>
include <GeomLib.hxx>
include <GeomConvert_CompCurveToBSplineCurve.hxx>
include <TopTools_ListOfShape.hxx>
include <TopTools_ListIteratorOfListOfShape.hxx>
include <TopTools_DataMapOfShapeInteger.hxx>
include <TopTools_DataMapOfShapeReal.hxx>
include <TopTools_IndexedDataMapOfShapeAddress.hxx>
include <V3d_PositionalLight.hxx>
include <V3d_DirectionalLight.hxx>
include <V3d_AmbientLight.hxx>
include <IGESControl_Controller.hxx>
include <IGESControl_Writer.hxx>
include <Interface_Static.hxx>
include <OpenGl_GraphicDriver.hxx>
include <Graphic3d_GraphicDriver.hxx>
ifndef _AFX_NO_OLE_SUPPORT
include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
endif
ifndef _AFX_NO_AFXCMN_SUPPORT
include <afxcmn.h> // MFC 对 Windows 公共控件的支持
endif // _AFX_NO_AFXCMN_SUPPORT
include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持
ifdef _UNICODE
if defined _M_IX86
pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'"")
elif defined _M_X64
pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'"")
else
pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='' publicKeyToken='6595b64144ccf1df' language=''"")
endif
endif
3.mfcoccc.h文件中创建三维引擎句柄,
Handle(Graphic3d_GraphicDriver) m_GraphicDriver;
Handle(Graphic3d_GraphicDriver) GetGraphicDriver() { return m_GraphicDriver; }
4.mfcocccDoc.h文件中声明上下文和显示view句柄,绘图函数声明
Handle(AIS_InteractiveContext) myAISContext;
Handle(V3d_Viewer) myViewer;
Handle(V3d_Viewer) GetViewer(void) { return myViewer; }
void DrawSphere(double Radius);
void DrawBox(double MyHeight,double MyWidth,double MyThickness); //画盒子
5.mfcocccView.h中声明视图句柄
Handle(V3d_View) myView;
6.实现代码较多,这里就不一一列出来了
7.案例达到的效果如下,是一个立体的空瓶子。
源码下载地址:https://download.csdn.net/download/xipengbozai/18884650
屌炸天的3D引擎OpenCASCADE的用法及案例(转载之处:)的更多相关文章
- 炸天的3D引擎OpenCASCADE的用法及案例(https://blog.csdn.net/xipengbozai/article/details/117044032?spm=1001.2014.3001.5502)
What CASCADE?Open CASCADE(简称OCC)平台是由法国Matra Datavision公司开发的CAD/CAE/CAM软件平台,可以说是世界上最重要的几何造型基础软件平台之一.开 ...
- 支持Android 的几款开源3D引擎调研
最近由于工作需要,对支持Android的一些开源3D引擎做了调研,结果如下: 1.Ogre 十分强大的一款3D引擎,号称工业级标准的开源项目,不仅可以用于游戏,还可以用于其他和3D相关的软件.大多数该 ...
- 从0开发3D引擎(四):搭建测试环境
目录 上一篇博文 了解自动化测试 单元测试 集成测试 端对端测试 通过打印日志来调试 了解运行测试 断点调试 通过Spector.js测试WebGL 通过log调试Shader 移动端测试 了解性能测 ...
- 关于如何学好游戏3D引擎编程的一些经验[转]
此篇文章献给那些为了游戏编程不怕困难的热血青年,它的神秘要我永远不间断的去挑战自我,超越自我,这样才能攀登到游戏技术的最高峰 ——阿哲VS自己 QQ79134054多希望大家一起交流与沟通 这篇文章是 ...
- 万圣节福利:红孩儿3D引擎开发课程《3ds max导出插件初步》
ds max文件夹,插件文件夹以及3ds max的可执行程序文件夹: 位的,这里要改成x64,否则启动程序后3ds max会提示"不是有效的win32程序"之类的对话框. 然后要将 ...
- 来手撸一个小小小小小"3D引擎"
开始的唠叨 说是3D引擎确实有点过于博眼球了,其实就是实现了一个透视投影,当然也不是那么简单的. 此篇文章是纯粹给小白看的 高手请勿喷 .也称之为小向带你图形学入门基础 . 哇哈哈哈哈 一说到做一个3 ...
- Flash Alternativa 3D引擎-基础理论
自由行走的花 网站设计,flash网站设计与动画制作,web,as3 2010-12-31 14:29 [转]Flash Alternativa 3D引擎-基础理论 <本文转载自:http:// ...
- 如何学好游戏3D引擎编程
注:本文是网上看到的一篇文章,感觉写的很好,因此收藏了下来 <如何学好游戏3D引擎编程>此篇文章献给那些为了游戏编程不怕困难的热血青年,它的神秘要我永远不间断的去挑战自我,超越自我,这样才 ...
- 转:典型开源3D引擎分类比较
常见的3D引擎有:Unreal.Quake.Lithtech.OGRE.Nebula.Irrlicht.Truevision3D... 其中开源免费的有:OGRE.irrlicht.fly3d.Neo ...
随机推荐
- .NET团队送给.NET开发人员的云原生学习资源
企业正在迅速采用云的功能来满足用户需求,提高应用程序的可伸缩性和可用性.要完全拥抱云并优化节约成本,就需要在设计应用程序时考虑到云的环境,也就是要用云原生的应用开发方法.这意味着不仅要更改应用程序的构 ...
- Macbook 安装kali linux 双系统 2020.3 超详细
博主折腾了一星期这东西,到现在都还有些坑没解决(最后面会讲).不过最起码系统装上了,可以用了,看到这桌面惊艳了,再点下左上角表示人间值得. 其实我是装了windos 10.macos 和kali三系统 ...
- [贪心]P1049 装箱问题
装箱问题 题目描述 有一个箱子容量为V(正整数,0≤V≤20000),同时有n个物品(0<n≤30),每个物品有一个体积(正整数). 要求n个物品中,任取若干个装入箱内,使箱子的剩余空间为最小. ...
- 你真的了解Innodb存储引擎?
前言 前几篇记录了如何查看SQL执行计划.数据库事务相关的知识点 除了这两个,数据库还有两个是非常重要的,必须要考的 就是存储引擎和索引 今天先记录以下InnoDB存储引擎相关的知识点 MySQL存储 ...
- 【设计模式】- 生成器模式(Builder)
生成器模式 建造者模式.Builder 生成器模式 也叫建造者模式,可以理解成可以分步骤创建一个复杂的对象.在该模式中允许你使用相同的创建代码生成不同类型和形式的对象. 生成器的结构模式 生成器(Bu ...
- 数据库MySQL三
进阶4:常见函数 字节长度为12,一个汉字3个字节 8个字符 注意起始索引 1 -1 0 红色是记忆的 二.数学函数 当前日期包括时间 获取日期 获取时间 四.流程控制函数 案例 分组函数 单行函数: ...
- buuctf --pwn part2
pwn难啊! 1.[OGeek2019]babyrop 先check一下文件,开启了NX 在ida中没有找到system.'/bin/sh'等相关的字符,或许需要ROP绕过(废话,题目提示了) 查看到 ...
- 如何建立一个足够安全的SSH连接?
1 概述 使用SSH连接服务器是一件很平常的事,但是,连接是否足够安全是一个令人担忧的问题.本文从如下几个方面介绍了如何建立一个足够安全的SSH连接: 端口 协议 用户 密码 密钥对 ssh-agen ...
- JFX11+Maven+IDEA 发布跨平台应用的完美解决方案
1 概述 前几天写了两篇关于JFX+IDEA打包跨平台应用的文章,这篇是使用IDEA自带功能打包的,这篇是使用Maven进行打包的,但是效果不太满意,因为从JDK9开始实现模块化,同时JFX部分从JD ...
- Queue API的几种实现详解
目录 Queue API的几种方法的使用 ArrayBlockingQueue原理及源码解析 ArrayBlockingQueue的成员变量 ArrayBlockingQueue的offer和put方 ...