1.1 环境描述
1.2
基本关系
T=G.Shape(); 几何转换成拓扑。
I = new OCAIS_Shape(T);拓扑变成交互对象。
Context.Display(I);交互对象显示在View中。
1.3 Graphic3d_WNTGraphicDevice
创建window NT的图形设备对象类。
设置光源;
1.4 V3d_Viewer
创建基于图形设备对象的绘图器类。
(1) public void Init()
说明:对象的初始化。
(2) public void SetDefaultLights()
说明:设置默认模式的灯光。
(3) public void SetLightOn()
说明:设置灯光是打开的。
(4) public OCV3d_View CreateView()
说明:在OCV3d_Viewer中创建一个OCV3d_View的实例。
1.5 AIS_InteractiveContext
交互对象管理类,用于管理在一个或多个viewer中交互对象。
方法参数中的“updateviewer”表示,是否要同步更新VIEW。
(1) public void Display(OCAIS_InteractiveObject anIobj, bool updateviewer)
说明:将交互对象输出到图形设备。
(2) public OCAIS_StatusOfPick Select(int XPMin, int YPMin, int XPMax, int YPMax, OCV3d_View aView, bool updateviewer)
说明:拾取矩形框选中的对象。
(3) public void InitCurrent()
说明:初始化一系列选中的对象。
(4) public bool MoreCurrent()
说明:这些选中的对象是否大于一个。
(5) public void NextCurrent()
说明:继续寻找这些选中对象集合的下一个。
(6) public OCAIS_InteractiveObject Current()
说明:选中对象集合中当前的对象。
(7) public bool IsDisplayed(OCAIS_InteractiveObject aniobj, int aMode)
说明:当前对象是否已经显示。
(8) public void SetTransparency(OCAIS_InteractiveObject aniobj, double aValue,
bool updateviewer)
说明:为当前对象设置透明度。
(9) public void SetColor(OCAIS_InteractiveObject aniobj, OCQuantity_NameOfColor aColor, bool updateviewer);
说明:设置交互对象的颜色。
(10) public void SetMaterial(OCAIS_InteractiveObject aniobj, OCGraphic3d_NameOfMaterial aName, bool updateviewer);
说明:设置交互对象的显示材料。
(11) public void SetDisplayMode(OCAIS_DisplayMode AMode, bool updateviewer);
public void SetDisplayMode(OCAIS_InteractiveObject aniobj, int aMode, bool updateviewer);
说明:设置交互环境的显示模式、交互对象的显示模式。
(12) Select(int XPMin, int YPMin, int XPMax, int YPMax, OCV3d_View aView, bool updateviewer)
说明:框选时应用
(13) ShiftSelect(int XPMin, int YPMin, int XPMax, int YPMax, OCV3d_View aView, bool updateviewer)
说明:按下Shift框选时应用
(14) public ShiftSelect(bool updateviewer)
说明:按下Shift选择时应用
(15) public Select(bool updateviewer)
说明:选择时应用
(16) public MoveTo(int XPix, int YPix, OCV3d_View aView)
说明:移动经过时选择
(17) public void Erase
说明:擦除(不显示)指定交互对象
(18) public void EraseAll
说明:擦除当前VIEW中所有对象
(19) public void Remove
说明:移除(删除)指定交互对象
(20) public void RemoveAll
说明:移除当前VIEW中所有对象
1.6 V3d_View
绘图视窗对象类。
(1) public void SetWindow(OCAspect_Window IdWin)
说明:激活视图类中于要与屏幕建立映射的窗口。
(2) public void Redraw()
说明:重新显示视图。
(3) public void MustBeResized()
说明:视图的窗口支持视图大小的改变。
(4) public void Reset(bool update)
说明:恢复默认视窗
(5) public void Size(ref double Width, ref double Height)
说明:设置视图的大小。
(6) public void SetZoom(double Coef, bool Start)
说明:视图中相对于初始值的缩放。
(7) public void Rotation(int X, int Y)
说明:继续视图的旋转。
(8) public void StartRotation(int X, int Y, double zRotationThreshold);
说明:开始视图的旋转。
(9) public void BackgroundColor(OCQuantity_TypeOfColor Type, ref double V1, ref double V2, ref double V3)
说明:根据参数1来获取视图背景的颜色。
(10) public void SetProj(OCV3d_TypeOfOrientation Orientation)
说明:设置当前视窗的可视方向
view.SetProj(OCV3d_TypeOfOrientation.V3d_Xpos);//FrontView前视图
view.SetProj(OCV3d_TypeOfOrientation.V3d_Zpos);//TopView
view.SetProj(OCV3d_TypeOfOrientation.V3d_Ypos);//LeftView
view.SetProj(OCV3d_TypeOfOrientation.V3d_Xneg);//BackView
view.SetProj(OCV3d_TypeOfOrientation.V3d_Yneg);//RightView
view.SetProj(OCV3d_TypeOfOrientation.V3d_Zneg);//BottomView
view.SetProj(OCV3d_TypeOfOrientation.V3d_XposYnegZpos);//AxoView
(11) public void FitAll(double Coef, bool FitZ, bool update);
说明:让所有的交互对象,适应整个VIEW的大小。
(12) public void ZFitAll(double Coef)
说明:让所有的交互对象,适应整个VIEW的大小。
(13) public void WindowFitAll
说明:局部放大时可以使用该方法
(14) public void Convert
说明:坐标转换
1.7 OCAIS_InteractiveObject
基本交互对象基类。
(1)
关系图如下:
(2) 交互对象的显示在视窗中(实例):
实例一:
OCTopoDS_Shape SecondShape;
OCAIS_Shape white2 = new OCAIS_Shape(SecondShape);
context.Display(white2, false); //context是AIS_InteractiveContext的实例。
1.8 综合实例
(1) 三维环境的初始化:
device = new OCGraphic3d_WNTGraphicDevice();
viewer = new OCV3d_Viewer(device, "Visu3D", "", 1000.0,
OCV3d_TypeOfOrientation.V3d_XposYnegZpos,
OCQuantity_NameOfColor.Quantity_NOC_GRAY30,
OCV3d_TypeOfVisualization.V3d_ZBUFFER, OCV3d_TypeOfShadingModel.V3d_GOURAUD,
OCV3d_TypeOfUpdate.V3d_WAIT,
true, false, OCV3d_TypeOfSurfaceDetail.V3d_TEX_NONE);
viewer.Init();
viewer.SetDefaultLights();
viewer.SetLightOn();
view = viewer.CreateView();
//绑定view到控件(this.panel.Handle)
OCWNT_Window aWNTWindow = new OCWNT_Window(
device,
this.panel.Handle,
OCQuantity_NameOfColor.Quantity_NOC_MATRAGRAY);
if (aWNTWindow != null)
{
view.SetWindow(aWNTWindow);
if (!aWNTWindow.IsMapped())
aWNTWindow.Map();
}
context = new OCAIS_InteractiveContext(viewer);
context.UpdateCurrentViewer();
view.Redraw();
view.MustBeResized();