您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > opencascade-使用指南
OpenCascadePreliminariesIntroductionOpenCASCADETechnologyisapowerfulopensourceC++library,consistingofthousandsofclassesandprovidingsolutionsintheareaofSurfaceandsolidmodeling:tomodelanytypeofobject,3Dand2Dvisualization:todisplayandanimateobjects,Dataexchange:toimportandexportstandardCADformats,Rapidapplicationdevelopment:tomanipulatecustomapplicationdata.andinmanyothersinCAD/CAM/CAE,notexcludingAEC,GISandPDM.OpenCASCADETechnologyisdesignedforindustrialdevelopmentof3Dmodeling,numericsimulationandvisualizationapplicationswhichrequireguaranteedquality,reliabilityandarobustsetoftools.OpenCASCADETechnologylibrariesaredistributedinopensourceformultipleplatforms,andprotectedbyOpenCASCADEPublicLicensewhichallowsunconditionalcommercialusageofourcodeandbinaries.AdvancedComponentsAdvancedDataExchangeDXFImport/ExportACISSATImport/ExportParasolidXTImportCatiaV5ImportAdvancedAlgorithmsSurfacefromScatteredPointsCanonicalRecognitionCollisionDetectionMeshrelatedMeshFrameworkExpressMesherAdvancedSamplesAdvancedXDEAdvancedOCAFShapeHealerKitchenDemoCamshaftDriveObjectLibrariesModulesEachmodulecontainsseverallibraries,eachlibrarycontainsclassesgroupedintopackages:DirectoriesStructureWhatYouShouldKnowTopassthroughthetrainingsuccessfullyitisnecessarytoknow:C++ObjectOrientedLanguageProgrammingtechnologiesInaddition,thefollowingknowledgemaybeuseful:Commonmathematics,algebra,geometryBasicsofComputerAidedDesignStandardTypesIINotionOfHandlesWhatIsAHandleInaconceptofObjectOrientedLanguage,anobjectisaninstanceofadatatype.Thedefinitionofthisobjectdeterminesthewayitcanbeused.Datatypesfallintotwocategoriesaccordingtothewaytheyaremanipulated:eitherbyvalue,orbyreference(pointer).C++usualproblemslinkedtousageofpointersare:Syntaxdifficulties:WheredoIput*,&,etc.?Managementdifficulties:WhenshouldIdeletemyobjects?Tocopewiththelastissue,OpenCASCADETechnologyprovidessocalledHandlemechanismthatisanimplementationofsmartpointermechanism.Withthismechanism,referencedobjectscreatedontheheapareautomaticallydestroyedwhennolongerinuse.TheHandleMechanismIngeneral,theHandlemechanismisbasedontwoelements:acounterthatstoresthenumberofreferencestoanobjectinmemory,apointertoanobjectinmemory.Everytimeanewhandletoanobjectiscreated,theobject'sreferencecounterisincremented.Everytimeahandletoanobjectisremoved,theobject'sreferencecounterisdecremented.Assoonasthereferencecounterreaches0,theobjectisautomaticallydeleted.Thiswaythereferencecountersecuresthedeletefunction.UseOfHandlesIntheprogram,thehandlesaremanipulatedasconventionalpointers:Declarationofahandle:Handle(Geom_BezierCurve)aBezierCurve;//Note:anewhandlepointstonothingAllocationofahandledobject:aBezierCurve=newGeom_BezierCurve(...);//Note:operator'new'isoverloadedtobenefitfromthecustommemorymanagementDe-referencingthehandle:Standard_IntegerNbPoles=aBezierCurve-NbPoles();//Note:operator??isoverloadedtoprovideaccesstothehandledobjectTobemanipulatedbyhandle,objectshavetoinheritMMgt_TSharedclass.GettingTypeOfAHandledObjectAspecificmechanismallowsyoutofindoutthetypeofanobjectpointedtobyahandleviaDynamicTypemethod:Handle(Standard_Type)aType=aGeom-DynamicType();TwomethodsinheritedfromMMgt_TSharedcanbeappliedtocheckthetypeofanobject:IsInstance(TheType):returnsStandard_TrueiftheobjectisaninstanceofTheTypeif(aGeom-IsInstance(STANDARD_TYPE(Geom_BezierCurve)))IsKind(TheType):returnsStandard_TrueiftheobjectisaninstanceofTheTypeoraninstanceofanyclassthatinheritsTheTypeif(aGeom-IsKind(STANDARD_TYPE(Geom_BoundedCurve)))ThemacroSTANDARD_TYPEreturnstheobjecttypefromaclassname.SpecificMethodsApplicableOnHandleIsNull():returnsStandard_TrueiftheHandlereferstonothing.if(aBezierCurve.IsNull())...Nullify():nullifiesthereferencetotheobject(thereferencecounterisdecremented).aBezierCurve.Nullify();DownCast():convertsthegivenreferenceintoareferencetoaspecifiedclass.InpureC++,ifBinheritsA,wecanassignbtoa,butnotatob.UsingDownCastthisispossible:Example:Handle(Geom_BezierCurve)aBezierCurve=Handle(Geom_BezierCurve)::DownCast(aCurve);IftheDownCastoperationfails,theresultisanullHandleDefinitionOfANewHandledClassCreationOfAHandledClassTheuserscancreatetheirsownhandledclasses(AISclassesforexample).TheseclassesmustinheritMMgt_TSharedoritsdescendants.Creatinganewhandledclassitisnecessarytorespectthefollowingprocedure:Definetheheaderfileforthehandledclass,Implementthehandledclassinthesourcefile.Oncetheheaderfileisdefined,creationoftheHandleclassisautomatic.Intheheaderfile:#includeStandard_Macro.hxx#includeAIS_Shape.hxx#includeStandard_DefineHandle.hxx//YourclasshastoinheritMMgt_TSharedoritsdescendantDEFINE_STANDARD_HANDLE(MyClass,AIS_Shape)classMyClass:publicAIS_Shape{//Declarethemethodsofyourclasshere//...DEFINE_STANDARD_RTTIEXT(MyClass)};Inthesourcefile:#includeMyClass.hxxIMPLEMENT_STANDARD_HANDLE(MyClass,AIS_Shape)IMPLEMENT_STANDARD_RTTI(MyClass,AIS_Shape)//Definethemethodsofyourclasshere//...GeometryI-ReviewOfGeometryAnalyticGeometryDefinedbyanexplicitequationo
本文标题:opencascade-使用指南
链接地址:https://www.777doc.com/doc-5173175 .html