0
点赞
收藏
分享

微信扫一扫

OpenCASCADE基本建模环境

生活记录馆 2022-04-16 阅读 68
c++

OpenCASCADE 是一套开放源代码的CAD/CAM/CAE几何模型核心,这一套函数库系统原来是著名的CADCAM软体EUCLID的开发平台,源自于法国的Matra Datavision公司。OpenCASCADE是一个真正工业级的3D建模工具,基于OpenCASCADE可以快速的开发其他CAD系统,能够处理2D或3D建模的各种问题,比如建立实体模型、提供布尔操作、面角操作(倒角、圆角)、计算实体属性、可视化操作、数据格式转换等。

本文基于eryar大神的提供了示例接着进行了扩展,补充了视方体、三视图、模型线框与实体的切换,线框视图遮挡线的消隐、导入导出IGES、STEP、Brep、STL文件等功能,以期提供更为完备的CAD开发基础环境。

演示示例:

0416-01

0416-02

 给出相关代码:

线框模式和实体模式的切换:

void OccView::onWireframe(void)
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	//如果在扫描所选对象列表时发现了另一个对象,则返回true。  
	for (myContext->InitCurrent(); myContext->MoreCurrent(); myContext->NextCurrent())
		myContext->SetDisplayMode(myContext->Current(),0,false);
	myContext->UpdateCurrentViewer();
	//getApplication()->onSelectionChanged();
	QApplication::restoreOverrideCursor();
}

void OccView::onShading(void)
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	for (myContext->InitSelected(); myContext->MoreSelected(); myContext->NextSelected())
		myContext->SetDisplayMode(myContext->Current(), 1, false);
	myContext->UpdateCurrentViewer();
	//getApplication()->onSelectionChanged();
	QApplication::restoreOverrideCursor();
}

线框图的消隐

void OccView::hlrOn(void)
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	myHlrModeIsOn = Standard_True;
	myView->SetComputedMode(myHlrModeIsOn);
	myView->Redraw();
	QApplication::restoreOverrideCursor();
}

void OccView::hlrOff(void)
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	myHlrModeIsOn = Standard_False;
	myView->SetComputedMode(myHlrModeIsOn);
	myView->Redraw();
	QApplication::restoreOverrideCursor();
}

视方体:

void OccView::displayCube()
{
	//视图立方体
	Handle(AIS_ViewCube) H_AisViewCube = new AIS_ViewCube();
	//myContext->SetDisplayMode(AIS_Shaded, true);   //设置显示模式为阴影
	H_AisViewCube->SetBoxSideLabel(V3d_Xpos, "Right");
	H_AisViewCube->SetBoxSideLabel(V3d_Ypos, "Back");
	H_AisViewCube->SetBoxSideLabel(V3d_Zpos, "Top");
	H_AisViewCube->SetBoxSideLabel(V3d_Xneg, "Left");
	H_AisViewCube->SetBoxSideLabel(V3d_Yneg, "Front");
	H_AisViewCube->SetBoxSideLabel(V3d_Zneg, "Bottoom");
	H_AisViewCube->SetTransparency(0.8);
	H_AisViewCube->SetTextColor(Quantity_Color(Quantity_NOC_MATRABLUE));
	H_AisViewCube->SetFontHeight(20);
	H_AisViewCube->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_ALUMINIUM));
	H_AisViewCube->SetTransformPersistence(
		new Graphic3d_TransformPers(
			Graphic3d_TMF_TriedronPers,
			Aspect_TOTP_RIGHT_UPPER,
			Graphic3d_Vec2i(100, 100)));
	myContext->Display(H_AisViewCube, Standard_True);
}
举报

相关推荐

0 条评论