为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > AnyCAD C#三维图形控件使用说明

AnyCAD C#三维图形控件使用说明

2019-08-23 2页 pdf 930KB 95阅读

用户头像 个人认证

耀先

教书育人

举报
AnyCAD C#三维图形控件使用说明AnyCAD.NetGraphicsComponentUserManual(R2014UR1)anycad.net2014.52Copyright©2014anycad.net,allrightreserved.Contents1.Overview............................................................................................................................41.1.Capabili...
AnyCAD C#三维图形控件使用说明
AnyCAD.NetGraphicsComponentUserManual(R2014UR1)anycad.net2014.52Copyright©2014anycad.net,allrightreserved.Contents1.Overview............................................................................................................................41.1.Capabilities.................................................................................................................41.1.1.Modeling.............................................................................................................41.1.2.Dataexchange....................................................................................................41.1.3.Visualization........................................................................................................52.GetStart............................................................................................................................62.1.AddassemblyDLLs.....................................................................................................62.2.Addthevisualizationcontrol.....................................................................................63.Modeling............................................................................................................................73.1.Modeling....................................................................................................................73.2.Visualizationgeometry...............................................................................................73.3.ExploretheTopoShape..............................................................................................83.4.GetCommonGeometryProperty..............................................................................83.5.Curveinformation......................................................................................................83.6.Surfaceinformation...................................................................................................83.7.Facetriangulation.......................................................................................................94.Visualization....................................................................................................................114.1.Viewsettings............................................................................................................114.1.1.Backgroundcolor..............................................................................................114.1.2.Show/Hidedrawinggrid...................................................................................114.1.3.Setthecameraview.........................................................................................114.1.4.SetDisplayMode..............................................................................................124.1.5.SetPickMode...................................................................................................124.2.SceneManagement.................................................................................................134.2.1.VisualizeTopoShapeGeometry........................................................................134.2.2.CreateGroupNode...........................................................................................134.2.3.SetNodeStyle...................................................................................................134.2.4.Queryselectedgeometry.................................................................................144.3.PointConversion......................................................................................................143Copyright©2014anycad.net,allrightreserved.4.3.1.Worldpointtoscreenpoint(3D->2D)..............................................................144.3.2.Screenpointtoworldpoint(2D–3D)..............................................................145.DataExchange.................................................................................................................166.Reference........................................................................................................................174Copyright©2014anycad.net,allrightreserved.1.OverviewAnyCAD.NetGraphicsComponentistheprofessionalgraphicsSDKfor.Netdevelopers,whichcanhelpyoucreate3Dapplicationsrapidly.Thisrapidgraphicsframeworkisfocusingon3dmodeling,visualizationanddataexchange.Ourgoalistohelpourcustomerstomakegreat3Dapplications.Ifyouhaveanyissues,pleasecontactus:support@anycad.net1.1.Capabilities1.1.1.ModelingFeaturesof3dmodeling:Primitivegeometrymodelingforpoint,line,polyline,spline,arc,circle,sphere,box,cylinder,cone,surfacefrompointsetc…Compound:wire,shell,solid,compound.Modelingmethodsforextrude,sweep,loft,revole,chamfer,fillet,projection,rotate,move,scale,etc…Booleanoperationforunion,cut,common.1.1.2.DataexchangeThestandardAnyCAD.NetGraphicsComponentsupportsthefollowingSTEP,IGES,STL,DXFformats.STEPSupportimportandexport.Youcangetthe“tree”structureofSTEPfilewithshapenames.5Copyright©2014anycad.net,allrightreserved.IGESSupportimportandexport.STLSupportimportandexport.Youcancontrolthetriangulationprecisionwhenexporting.DXF(beta)SupportimportDXF.1.1.3.VisualizationAnyCAD.NetGraphicsComponentcontainsthevisualizationcontrolforWinFormandWPF,whichcanhelpyoutoaddthe3DcontroltoyouFormeasily.Featuresofvisualization:DefaultCameraoperationZoomin/out,fitwindow,rotation,pan…andnocodingrequired.SelectionmanagementPickbymouse.Addtoobjecttoselection/Clearselectionset.Queryselectednodeandgeometry,includingsubFace/Edge/Vertex.Setselectionfilterfornode,group,face,edge,vertex…ScenenodemanagementAdd,delete,findbyid.Createnodegroup.RenderStyleCustomizetheface,edge,vertexstyles,includingcolor,linewidth,pointsize,andfacematerials.DisplaymodeWireframe,shading,shadingwithedge…GradientbackgroundcolorsettingsPrintcurrentviewtoPDFExportcurrentviewtoimages,suchasjpg/png.6Copyright©2014anycad.net,allrightreserved.2.GetStart2.1.AddassemblyDLLsYouneedthefollowingtwoassemblydllstoyourproject:AnyCAD.Foundation.Net.dllAnyCAD.Presentation.Net.dll2.2.AddthevisualizationcontrolPleasereferencethesamplecodeofAnyCAD.Basicproject.YoucandraganddroptheRenderWindow3dcontroltoyourForm,orcreateitdynamically:publicpartialclassFormMain:Form{//RenderControlprivatePresentation.RenderWindow3drenderView;publicFormMain(){InitializeComponent();////CreaterenderView//this.renderView=newAnyCAD.Presentation.RenderWindow3d();//27istheheightofthemenubarthis.renderView.Location=newSystem.Drawing.Point(0,27);this.renderView.Size=this.Size;this.renderView.TabIndex=1;this.Controls.Add(this.renderView);}…Now,youcanrunyourapplicationandenjoythe3Dworld.7Copyright©2014anycad.net,allrightreserved.3.Modeling3.1.ModelingThemodelingAPIsisimplementedbyclassBrepToolswhichreturnstheTopoShapeObject.PleasereferencetheAnyCAD.NetonlinedocumentationformoremodelingAPIs.YoucanaccesstheglobalBrepToolsinstancebyGlobalInstance.BrepTools.3.2.VisualizationgeometryHerethecodesnipstocreateandshowthegeometrycylinder:TopoShapecylinder=GlobalInstance.BrepTools.MakeCylinder(newVector3(120,0,0),newVector3(0,0,1),20,100,40,315);//YouneedtoassigntheIdforgeometryforlatterqueryusage.renderView.ShowGeometry(cylinder,103);8Copyright©2014anycad.net,allrightreserved.3.3.ExploretheTopoShapeTopoExplorisusedtoexplorethesubshapesofaTopoShape,suchasvertex,edge,face,shell,solid.YoucanuseTopoShape::GetShapeType()totesttheshapetype:EnShapeType:Topo_COMPOUND,Topo_COMPSOLID,Topo_SOLID,Topo_SHELL,Topo_FACE,Topo_WIRE,Topo_EDGE,Topo_VERTEX,Topo_SHAPE3.4.GetCommonGeometryPropertyTopoShapePropertyisusedtogetthegeometryinformation:EdgelengthSurfaceAreaSolidVolumeCenteroftheshapemass3.5.CurveinformationGeomeCurveisusedtogetthecurveparameters,andusetheparametertogetthepointandderivativedata.3.6.SurfaceinformationGeomeSurfaceisusedtogetthefaceuvparameters,andusetheparameterstogetthepoint,normalandderivativedata.9Copyright©2014anycad.net,allrightreserved.3.7.FacetriangulationYoucantriangulatetheFacetomeshesviaFaceTriangulationAPI,andvisualizationthemesh,e.g.:TopoShapeface=…;if(face.GetShapeType()==(int)EnShapeType.Topo_FACE){MessageBox.Show("Thisisaface!");}FaceTriangulationft=newFaceTriangulation();ft.SetTolerance(5);ft.Perform(face);float[]points=ft.GetVertexBuffer();intpointCount=points.Length/3;uint[]indexBuffer=ft.GetIndexBuffer();intfaceCount=indexBuffer.Length/3;float[]normals=ft.GetNormalBuffer();float[]colorBuffer=newfloat[pointCount*4];Randomnum=newRandom();for(intii=0;ii<pointCount;++ii){intidx=ii*4;colorBuffer[idx]=num.Next(0,256)/256.0f;colorBuffer[idx+1]=num.Next(0,256)/256.0f;colorBuffer[idx+2]=num.Next(0,256)/256.0f;colorBuffer[idx+3]=1;}RenderableEntityentity=GlobalInstance.TopoShapeConvert.CreateColoredFaceEntity(points,indexBuffer,normals,colorBuffer,face.GetBBox());EntitySceneNodenode=newEntitySceneNode();node.SetEntity(entity);renderView.SceneManager.AddNode(node);10Copyright©2014anycad.net,allrightreserved.11Copyright©2014anycad.net,allrightreserved.4.Visualization4.1.ViewsettingsTherearemanysettingscanhelpyoutomakeyour3Dapplicationlooksdifferent.TherelatedAPIsareRenderWindow3dandView3d,youcanaccesstheView3dinstanceviathepropertyofRenderWindow3d::View3d.4.1.1.BackgroundcolorRenderWindow3d::SetBackgroundColor(top,middle,bottom)e.g:ColorValueclr=newColorValue(.5f,.5f,0.5f)4.1.2.Show/HidedrawinggridView3d::ShowWorkingGrid(bool)4.1.3.SetthecameraviewView3d::SetStandardView(EnumStandardViewnType)EnumStandardView:SV_Invalid,SV_Front,SV_Back,SV_Top,SV_Bottom,SV_Left,SV_Right,SV_ISOYoucanalsouseRenderWindow3d::LookAtfunctiontosetarbitrarydirectionforthecamera.12Copyright©2014anycad.net,allrightreserved.4.1.4.SetDisplayModeView3d::SetDisplayMode(intstyle)EnumDisplayStyle:DS_FaceDS_WireframeDS_RealisticDS_VertexDS_EdgeYoucancombinethesebitflags:intstyle=(int(EnumDisplayStyle.DS_Face|EnumDisplayStyle.DS_Edge));4.1.5.SetPickModeView3d::SetPickMode(intnMode)EnumPickMode:RF_NoneRF_FaceRF_EdgeRF_VertexRF_BBoxRF_SceneNodeRF_GroupSceneNodeYoucancombinethesebitflags:intpickMode=(int(EnumPickMode.RF_Face|EnumPickMode.RF_Edge));Youcansettopickthewholeobject,thenyouneedtosetRF_SceneNode|RF_Edge:RF_Face;Youcanalsosettopicktheagroupofobjects(GroupSceneNode),youneedtosetRF_GroupSceneNode|RF_Edge:RF_Face.13Copyright©2014anycad.net,allrightreserved.4.2.SceneManagement4.2.1.VisualizeTopoShapeGeometryTopoShapecylinder=GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO,Vector3.UNIT_Z,50,100,0);//0.1fistheprecisionforvisualization.EntitySceneNodesceneNode=GlobalInstance.TopoShapeConvert.ToEntityNode(cylinder,0.1f)sceneNode.SetId(myId);renderView.SceneManager.AddNode(sceneNode);4.2.2.CreateGroupNodeYoucancreateagroupofnodetosetthevisible/style/selection…TopoShapecylinder=GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO,Vector3.UNIT_Z,50,100,0);TopoShapesphere=GlobalInstance.BrepTools.MakeSphere(newVector3(0,0,150),50);//CreategroupGroupSceneNodegroup=newGroupSceneNode();group.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(cylinder,0.1f));group.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(sphere,0.1f));//ShowthegrouprenderView.SceneManager.AddNode(group);4.2.3.SetNodeStyleYoucansetthefacestyle,linestyleandvertexstyleforaSceneNode/GroupSceneNode,14Copyright©2014anycad.net,allrightreserved.SetanId/nameSetthevisibilityofthenode//SettransparentfaceFaceStylestyle=newFaceStyle();style.SetColor(newColorValue(0.5f,0.3f,0,0.5f));style.SetTransparent(true);sceneNode.SetFaceStyle(style);4.2.4.QueryselectedgeometryAfterpressingthemousebutton,youcanuseQuerySelectedElementContexttocheckselectedshapeornode.QuerySelectedElementContextcontext=newQuerySelectedElementContext();renderWindow.View3d.QuerySelection(context);//Getthesubgeometry,suchasFace,Edge,VertexTopoShapesubShape=context.GetSubGeometry();//GetthemainshapeTopoShapeshape=cotext.GetGeometry()//GetthenodeidintnodeId=context.GetNodeId();Youcanusethenodeidtofindotherdatainyourdatabase.4.3.PointConversion4.3.1.Worldpointtoscreenpoint(3D->2D)UsingView3d::WorldPoint2ScreenPointyoucanconvertthe3Dworldpointtoscreen2Dpointdirectly.View3d::WorldPoint2ScreenPoint4.3.2.Screenpointtoworldpoint(2D–3D)Youcan’tconvertscreen2dpointto3dworldpointdirectly,buttheSDKprovidesyoufunctiontocreate3Dray,andyoucanusethe3Draytogettheintersectionpointinworldspace.RayView3d::ComputeScreenRay(intcx,intcy)15Copyright©2014anycad.net,allrightreserved.e.g:Rayray=View3d.ComputeScreenRay(100,200);Vector3worldPt=ray.Intersect(Vector3.Zero,Vector3.UNIT_Z);TheRenderWindow3dcontrolprovidesthefunctiontocomputethe3Dpointontheworkinggrid:Vector3RenderWindow3d::HitPointOnGrid(intcx,intcy)Youcanalsogetthepointontheshape:Vector3RenderWindow3d::HitPointOnShape(intcx,intcy)16Copyright©2014anycad.net,allrightreserved.5.DataExchangeWeprovidetwosamplesforthedataexchangemodel,yougetthesourcecodebythelinks:StpViewerdxfViewer17Copyright©2014anycad.net,allrightreserved.6.ReferenceOfficialwebsite:http://www.anycad.netOnlineAPIdocument:http://www.anycad.net/help/AGP2014/WinFormandWPFSamplecodes:https://github.com/anycad/anycadnetsdkpro
/
本文档为【AnyCAD C#三维图形控件使用说明】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索