锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / 英语翻译 / 基于opengl实现的模拟cad开发平台cadsurf
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源心得,转载请注明出处:锐英源,www.wisestudy.cn,孙老师作品,联系电话13803810136。


介绍


This is a basic surface modeler made using MFC and OpenGL on VC6. The geometry interface and graphics interface are separated so that you can simply define your curve or surface without worrying about the display. The display is in a generalized form i.e. if you derive your own curve from CCurve and override the PointAtPara and NormalAtmethods along with other mandatory methods, you can create an OpenGL curve as follows:
Some where in your project file you create your own derived classes' headers and source files...
这是一个使用VC6的MFC和OpenGL开发的基本的表面建模程序。几何界面和图形界面独立,让您可以简单地定义,而无需担心曲线或曲面的显示,显示进行了通用形式的封装,即如果用CCurve来派生你自己的曲线 且覆盖了PointAtPara和NormalAt函数,以及其他必须的函数,你可以创建一个自己的OpenGL曲线。示例如下:
在你的项目文件创建自己的派生类的头文件和源文件...


/ / 头文件
#include "Curve.h" 
class myCurve : public CCurve
{
....
};
 
//cpp file
#include "myCurve.h" 
CPoint3D myCurve::PointAtPara(double upar)
{
  double x, y, z;
  x = 2*sin(uPar)......
  y = .......
  z = .....
  CPoint3D P(x,y,z);
  return P;
}

CDocument相关位置添加如下代码...

#include "myCurve.h" 
void CMyProjDoc::OnCurve()
{
    myCurve crv(...);
    CGLCurve* myglCurve = new CGLCurve(&crv)
    dContext->Display(myglCurve);
    delete myglCurve;
}

Now dContext is the display context object (CGLDisplayContext) that manages all the display functions, so this is created in the constructor of the document. Similarly for surfaces also. There are currently almost all the general curves and surfaces implemented. Curves are: line, circle, ellipse, parabola, hyperbola, Bezier and bspline. Surfaces are: plane, cylinder, cone, sphere, torus, extruded, revolved, ruled and pipe.现在dContext是显示用的上下文对象(CGLDisplayContext),它管理所有的显示功能,所以它要在文档的构造函数里创建。面的处理类似。目前几乎所有的曲线和曲面都实现过了。曲线有:直线、圆、椭圆、抛物线、双曲线、Bezier和B样条。表面有:平面、圆柱、圆锥、球体、圆环、挤压突出、旋转、嵌线和管道。
The display of all curves are managed by the CGLCurve class and that of surfaces are by the CGLSurface class. Points and other geometric helpers like axes, coordinate systems etc. are also modeled. This is implemented in non interactive mode for demo. You can modify the source to make an interactive application. CGLCurve类管理所有曲线显示,CGLSurface类管理所有表面显示。点和其他几何助手,比如像轴、坐标系统等也进行了模型化处理。本例以非交互模式实现,只用于演示。你可以修改源代码使它成为一个交互式应用程序。
There are some modifications, dated 23/2/2003, made in the CGLView class which is the basic class for OpenGL viewing. Earlier it was derived from CView and the CCadSurfView class was derived from CGLView. The OpenGL manipulation methods were called from the CCadSurfView class's methods. e.g. mouse implementations etc. Like this: CGLView::RotateView(). Some how, I felt that there is no isolation for the OpenGL view. Hence with a better Object Oriented approach, I made the CGLView class, an independent class and the constructor of the class is passed with pointer to CWnd. The private data member in CGLView is the pointer to the CWnd which is initialized with OpenGL settings in the c'tor. Now an object of this CGLView is private member for CCadSurfView class which is dynamically initialized in the OnCreate() method of CCadSurfView and is deleted in OnDestroy() method. Now the methods are called using the object of the CGLView class instead of calling it directly as base class methods.--Like this: 在23/2/2003做了些修改,是对 CGLView类进行的处理,这是基本的OpenGL视图类。此前它派生自CView,CCadSurfView类派生自CGLView。CCadSurfView类的方法里调用了OpenGL的操作,例如鼠标相关的消息处理函数里等等,像CGLView :: RotateView()里也有 。某种程度上,我觉得是没有为OpenGL视图进行隔离。这样,提供了更好的面向对象的方法,我完成了独立的CGLView类,它的构造函数里有CWnd类指针参数。CGLView类的私有数据成员是CWnd的指针,这个CWnd在构造函数里参与了OpenGL设置的初始化。现在CGLView类的对象是CCadSurfView类的私有成员,在 OnCreate ()里对CGLView类对象初 始化, 并在OnDestroy()里删除该对象。通过CGLView的对象调用方法代替了以基类形式直接调用基类的方法操作模式-如下。

CCadSurfView::OnCreate(...)
{
  myView = new CGLView(this, GetDocument()->DisplayContext());
}
 
void CCadSurfView::OnMouseMove(...)
{
  .....
  myView->RotateView(....);
}
 
void CCadSurfView::OnSize(...)
{
  ...
  myView->Resize(cx, cy);
  CCadSurfView::OnSize.....
  ...
}
 
...CCadSurfView::OnDestroy(...)
{
  ...
  delete myView;
  ...
}

Whereas when it was derived earlier from CView, the calls were like this:而当它早期派生自CView时,调用如下这样:

void CCadSurfView::OnMouseMove(...)
{
  ...
  CGLView::RotateView(...);
  ...
}
友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内