三维CAD建模 基于Brep的扫成与欧拉操作

基于B-rep的建模操作及其算法

上了高老师的cad课,高老师的课十几年来不变的大作业就是基于半边结构的5个欧拉操作和sweep扫成cad模型的实现,以下是高老师上课时讲的一些干货,brep的基础知识请自行百度。

欧拉操作

  1. 欧拉公式
    欧拉公式是基于初中的欧拉公式v-e+f=2的拓展,在有内环(洞)的时候也能成立,欧拉操作就是基于欧拉公式的操作

v(vertice)-e(edge)+f(front)=2(s(solid)-h(handle穿透))+r(内环) 整体构造成5维超平面

  1. 欧拉操作的基本思想

    • 提供一组 通 用 的 完 备 的 ‾ \underline{通用的完备的} 拓扑结构生成操作
    • 基于欧拉公式使其具有一定的 有 效 性 ‾ \underline{有效性}
  2. 欧拉操作的选取

    vefhrsmeaning
    110000mev
    011000mef
    101001mvfs
    0-10010kemr
    00-1110kfmre
    • 其中k=kill m=make vfs如上
    • 有时s=split
    • 增加一个操作semv
    • 每个操作都有一个逆操作 用k替换m用m替换k 总计12个操作
  3. 欧拉操作的功能与实现
    以简单的两个操作为例:

    • mvfs
      • 构造一个体,外面和边,这里编程时注意,在构造一个无依赖边的点的时候也构造了一个空面和一个空体
      • lp->ledge=NULL
    • mev
      • 构造一个新点,和一个接新点和给定点的边
      • HalfEdge * mev(v1,lp) lp=loop
        有效性原则,使得新定义的半边与其所属环中的其他半边形成一个有向封闭的环。

数据结构

本项目主要基于qt5开发

#ifndef DS_H
#define DS_H
#include <QWidget>
#include <stdlib.h>
#include <QVector3D>
#include <vector>
#include <iostream>
#include <QDebug>
using namespace std;
class Solid;
class Face;
class Loop;
class HalfEdge;
class Vertex;
class Edge;

class Solid
{
public:
  Face *faces; // list of all faces to construct this solid
  Edge *edges; // list of all edges to construct this solid
  void printEdge();
  Solid() : faces(nullptr), edges(nullptr){}
};

class Face
{
public:
  int id;
  Solid *solid; // the solid which the face belong to
  Loop *outLp; // out loop of the face--construct the face
  Loop *innerLp;//inner_lp of the face--inner loop
  Face *next;//for face list in solid
  Face *pre;
  static int numFace;
  void addInerLoop(Loop *&l);
  Face() : id(0), solid(nullptr), outLp(nullptr), innerLp(nullptr),next(nullptr),pre(nullptr){
      id=numFace++;
  }
  ~Face();
};

class Loop
{
public :
  int id;
  static vector<Loop*> loopArray;//an Automatic maintenance  pointer array
  static int numLoop;
  HalfEdge *halfedges; // list of all halfeges to construct this loop
  Face *face; // the face that constructed by this loop
  Loop *next;
  Loop *pre;
  QVector3D normal;
  void printLoop();//print Loop halfedge info for Debug
  QVector3D getOritation();//get normal 3Dvector
  Loop() : id(0), halfedges(nullptr), face(nullptr), next(nullptr), pre(nullptr){loopArray.push_back(this);id=numLoop++;
  }//for sake of plot loop
};

class Edge
{
public:
  HalfEdge *half_l; //the edge's left halfedge
  HalfEdge *half_r; //the edge's right halfedge
  Edge *next;
  Edge *pre;
  int id;
  static int numEdge;
  Edge() : half_l(nullptr), half_r(nullptr), next(nullptr), pre(nullptr){id=numEdge++;}
};

class HalfEdge
{
public:
  Edge *edge; //this halfedge belong to which edge
  Vertex *sv; //the start vertex of this halfedge
  Vertex *ev; //the end vertex of this halfedge
  Loop *lp; //pointer to the loop that this halfedge belong to
  HalfEdge *next;
  HalfEdge *pre;
  HalfEdge *brother;//useless
  void printHfEdge();
  HalfEdge() : edge(nullptr), sv(nullptr), lp(nullptr), next(nullptr), pre(nullptr), brother(nullptr){}
};

class Vertex
{
public:
  int id;
  static vector<Vertex*> vertexArray;//an Automatic maintenance  pointer array
  QVector3D coordinate;//coordinate of the vertex (x, y, z)
  Vertex *next;
  Vertex *pre;
  static int  numVertex;
  Vertex(QVector3D q) : next(nullptr), pre(nullptr)
  {
      coordinate=q;
      id=numVertex++;
      vertexArray.push_back(this);
  }
};
#endif

图形交互界面
在这里插入图片描述

下载地址:https://download.csdn.net/download/yhf_naive/10813480

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
对于 OpenCASCADE 的三维显示开发,您可以使用 OpenCASCADE 提供的 Visualization 层进行操作。OpenCASCADE 是一个用于 CAD/CAE 应用开发的开源几何核心库,它提供了一套丰富的工具和功能,包括三维型创、编辑、分析和可视化等。 要进行三维显示开发,您可以按照以下步骤进行操作: 1. 导入 OpenCASCADE 库:首先,您需要将 OpenCASCADE 库导入到您的开发环境中。您可以从 OpenCASCADE 的官方网站或 GitHub 上获取最新的库文件。 2. 创场景和视窗:使用 OpenCASCADE 的 Visualization 层,您可以创一个场景和一个视窗来显示您的三维型。场景是一个容器,用于存储型和其他对象,而视窗是显示型的图形界面。 3. 加载和显示型:使用 OpenCASCADE 提供的功能,您可以加载和显示各种不同格式的三维型文件,如 STEP、IGES、BREP 等。您可以使用适当的函数将型加载到场景中,并在视窗中显示出来。 4. 进行交互操作:通过结合 OpenCASCADE 的几何操作和可视化功能,您可以实现各种交互式操作,如旋转、缩放、平移等。这样用户就可以在视窗中对型进行实时操作和浏览。 5. 添加附加功能:根据您的需求,您还可以添加其他功能,如选择、标注、剖切等。OpenCASCADE 提供了一系列的工具和函数,使您能够根据自己的需求定制和扩展应用程序的功能。 请注意,这只是简要介绍了 OpenCASCADE 的三维显示开发的基本步骤。具体的实现细节和代码示例可以参考 OpenCASCADE 的官方文档和示例代码。希望这对您有所帮助!如果您有更多问题,我会很乐意为您解答。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值