Equipment & Systems Engineering |
Electrical Harness Flattening |
Retrieving the Active PlaneHow to retrieve flattening parameters and read the active plane |
Use Case |
AbstractThis article discusses the ElecFlatteningItf use case. This use case explains how to retrieve the flattening parameters and read the associated active plane |
This use case is intended to help you make your first steps in programming with CATIA EHF Interfaces. Its main intent is to allow you to retrieve the flattening parameters and read the associated active plane.
[Top]
CAAEhfFlatteningParameters.m is a use case of the CAAElecFlatteningItf.edu framework that illustrates the CATIA EHF Interfaces framework capabilities.
[Top]
The goal of CAAEhfFlatteningParameters use case is to show how to to retrieve the flattening parameters and read the associated active plane
[Top]
To launch CAAEhfFlatteningParameters , you will need to set up the build time environment, then compile CAAEhfFlatteningParameters along with its prerequisites, set up the run time environment, and then execute the sample.
To launch the use case, execute the following command:
mkrun -c "CAAEhfFlatteningParameters input.CATProduct"
Under Windows, the path would indicate: 'WS'\intel_a\resources\graphic\ModelFlatteningParameters directory.
[Top]
The CAAEhfFlatteningParameters sample is made of a single class named CAAEhfFlatteningParameters located in the CAAEhfFlatteningParameters .m module of the CAAElecFlatteningItf.edu framework:
Windows | InstallRootDirectory\CAAElecFlatteningItf.edu\CAAEhfFlatteningParameters.m\ |
Unix | InstallRootDirectory/CAAElecFlatteningItf.edu/CAAEhfFlatteningParameters.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
This sample deals with the following classes:
CATSession | Class for the session base class |
CATDocument | Class for the document base class |
CATDocumentServices | Class for managing document in the session |
CATIDocRoots | Class for browsing root object in document |
CATIProduct | Interface dedicated to define product behaviour |
CATIEleDocServices | Interface dedicated electrical environment initialization |
CATIEhfEnvironment | Interfaces dedicated to retrieve the flattening parameter |
CATIEhfFlatteningParameters | Interfaces dedicated to read attribute on flattening parameter |
CATMathPlane | Class representing a mathematical plane in 3D |
[Top]
We will now first comment the Electrical environment and it’s components creation by looking at the code of the Main . There are 7 logical steps in Main :
[Top]
... if ( 2 > argc ) { retCode = 1; goto EscapeWay; } ... |
[Top]
We need a CATSession pointer to create the Session.
... pSession = CATSession::Create_Session(sessionIdent); ... |
We need a CATDocument pointer to opening the document.
... CATDocumentServices::Open(argv[1], pDoc, cusInType); ... |
Once the current session has been created, the CATProduct document can be loaded into the session . pDoc is a pointer to this document.
[Top]
We initialize the Document by using CATIEleDocServices interface pointer and the method Initialize() on it.
.... hr = pDoc->QueryInterface(IID_CATIEleDocServices,(void**)&pIEleDocServices ); if ( FAILED(hr) ) { retCode = 4; goto EscapeWay; } hr = pIEleDocServices->Initialize(); if ( FAILED(hr) ) { retCode = 5; goto EscapeWay; } .... |
Initializing the electrical environment is mandatory to enable access to electrical object or electrical attributes.
[Top]
We need a CATProduct pointer to retrieving the root product.
.... hr = pDoc->QueryInterface(IID_CATIDocRoots, (void**)(&pIDocRootsOnDoc)); if(FAILED(hr)) { retCode = 6; goto EscapeWay; } // Get the root product which is the first element of root elements pListUnkRootProducts = pIDocRootsOnDoc->GiveDocRoots(); if(NULL == pListUnkRootProducts) { retCode = 7; goto EscapeWay; } nProducts = pListUnkRootProducts->Size(); if( 0 == nProducts) { retCode = 8; goto EscapeWay; } hUnkRootProd = (*pListUnkRootProducts)[1]; if(NULL_var == hUnkRootProd) { retCode = 9; goto EscapeWay; } hr = hUnkRootProd->QueryInterface(IID_CATIProduct, (void**)(&pIRootProduct)); if(FAILED(hr)) { retCode = 10; goto EscapeWay; } .... |
[Top]
We need a CATIEhfEnviroment pointer on root product to retrieve the Flattening parameters
... hr = pIRootProduct->QueryInterface(IID_CATIEhfEnvironment,(void**)&pIEhfEnvironment); if ( FAILED(hr) ) { retCode = 11; goto EscapeWay; } hr = pIEhfEnvironment->GetFlatteningParameters(&phListFlatteningPara); if ( ( FAILED(hr) ) || ( NULL == phListFlatteningPara ) ) { retCode = 12; goto EscapeWay; } nbFlatteningPara = phListFlatteningPara->Size(); if (0 >= nbFlatteningPara) { retCode = 13; goto EscapeWay; } hUnkFlatteningPara = (*phListFlatteningPara)[1]; if (NULL_var == hUnkFlatteningPara) { retCode = 14; goto EscapeWay; } ... |
[Top]
We need the method GetPlane() of the interface CATIEhfFlatteningParameters to Get the active plane.
... hr = hUnkFlatteningPara->QueryInterface(IID_CATIEhfFlatteningParameters, (void **)&pIFlatteningPara); if ( FAILED(hr) ) { retCode = 15; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get Name // ------------------------------------------------------------------------- pName= new CATUnicodeString(); hr = pIFlatteningPara->GetPlane(pName); if ( ( FAILED(hr) ) || ( NULL == pName) ) { retCode = 16; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get Active Plane // ------------------------------------------------------------------------- pActivePlane = new CATMathPlane(); hr = pIFlatteningPara->GetPlane(pActivePlane); if ( ( FAILED(hr) ) || ( NULL == pActivePlane ) ) { retCode = 17; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetAlgorithmMode // ------------------------------------------------------------------------- pAlgoMode = new CATString(); hr = pIFlatteningPara->GetAlgorithmMode(pAlgoMode ); if ( ( FAILED(hr) ) || ( NULL == pAlgoMode ) ) { retCode = 18; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetAngleMode // ------------------------------------------------------------------------- pAngleMode = new CATString(); hr = pIFlatteningPara->GetAngleMode(pAngleMode ); if ( ( FAILED(hr) ) || ( NULL == pAngleMode ) ) { retCode = 19; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetMinAngleBetweenBranches // ------------------------------------------------------------------------- pICkeInstMinAngle = new CATICkeInst(); hr = pIFlatteningPara->GetMinAngleBetweenBranches(pICkeInstMinAngle); if ( ( FAILED(hr) ) || ( NULL == pICkeInstMinAngle) ) { retCode = 20; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetKeepTangents // ------------------------------------------------------------------------- pTangentKept = new CATBoolean(); hr = pIFlatteningPara->GetKeepTangents(pTangentKept ); if ( ( FAILED(hr) ) || ( NULL == pTangentKept ) ) { retCode = 21; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetExtractOnlySupportsInsideGBN // ------------------------------------------------------------------------- pOnlySupportsInsideGBNExtracted = new CATBoolean(); hr = pIFlatteningPara->GetExtractOnlySupportsInsideGBN(pOnlySupportsInsideGBNExtracted ); if ( ( FAILED(hr) ) || ( NULL == pOnlySupportsInsideGBNExtracted ) ) { retCode = 22; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetDeviceOrientation // ------------------------------------------------------------------------- pDeviceOrientation = new CATString(); hr = pIFlatteningPara->GetDeviceOrientation(pDeviceOrientation ); if ( ( FAILED(hr) ) || ( NULL == pDeviceOrientation ) ) { retCode = 23; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetSupportOrientation // ------------------------------------------------------------------------- pSupportOrientation = new CATString(); hr = pIFlatteningPara->GetSupportOrientation(pSupportOrientation ); if ( ( FAILED(hr) ) || ( NULL == pSupportOrientation ) ) { retCode = 24; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetApplyScaling // ------------------------------------------------------------------------- pScalingApplied = new CATBoolean(); hr = pIFlatteningPara->GetApplyScaling(pScalingApplied ); if ( ( FAILED(hr) ) || ( NULL == pScalingApplied ) ) { retCode = 25; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetMinNumberOfBNSToApplyScaling // ------------------------------------------------------------------------- pMinNumberOfBNS = new int(); hr = pIFlatteningPara->GetMinNumberOfBNSToApplyScaling(pMinNumberOfBNS ); if ( ( FAILED(hr) ) || ( NULL == pMinNumberOfBNS ) ) { retCode = 26; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetScaleBNSProportionally // ------------------------------------------------------------------------- pBNSScaledProportionally = new CATBoolean(); hr = pIFlatteningPara->GetScaleBNSProportionally(pBNSScaledProportionally ); if ( ( FAILED(hr) ) || ( NULL == pBNSScaledProportionally ) ) { retCode = 27; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetLimitedLength // ------------------------------------------------------------------------- pICkeInstLimitedLength= new CATICkeInst(); hr = pIFlatteningPara->GetLimitedLength(pICkeInstLimitedLength); if ( ( FAILED(hr) ) || ( NULL == pICkeInstLimitedLength) ) { retCode = 28; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetReductionFactor // ------------------------------------------------------------------------- pReductionFactor = new double(); hr = pIFlatteningPara->GetReductionFactor(pReductionFactor ); if ( ( FAILED(hr) ) || ( NULL == pReductionFactor ) ) { retCode = 29; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetApplyReductionFactorToWholeBNS // ------------------------------------------------------------------------- pReductionFactorAppliedToWholeBNS = new CATBoolean(); hr = pIFlatteningPara->GetApplyReductionFactorToWholeBNS(pReductionFactorAppliedToWholeBNS ); if ( ( FAILED(hr) ) || ( NULL == pReductionFactorAppliedToWholeBNS ) ) { retCode = 30; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetFixedLength // ------------------------------------------------------------------------- pICkeInstFixedLength= new CATICkeInst(); hr = pIFlatteningPara->GetFixedLength(pICkeInstFixedLength); if ( ( FAILED(hr) ) || ( NULL == pICkeInstFixedLength) ) { retCode = 31; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetBNSTypeScaledDuringSync // ------------------------------------------------------------------------- pBNSType = new CATString(); hr = pIFlatteningPara->GetBNSTypeScaledDuringSync(pBNSType ); if ( ( FAILED(hr) ) || ( NULL == pBNSType ) ) { retCode = 32; goto EscapeWay; } // ------------------------------------------------------------------------- // - Get GetMoveIntermediatePtDuringSync // ------------------------------------------------------------------------- pMoveIntermediatePt = new CATBoolean(); hr = pIFlatteningPara->GetMoveIntermediatePtDuringSync(pMoveIntermediatePt ); if ( ( FAILED(hr) ) || ( NULL == pMoveIntermediatePt ) ) { retCode = 33; goto EscapeWay; } ... |
[Top]
Removing document from session and closing the session.
... CATDocumentServices::Remove (*pDoc) ; if ( NULL != pSession ) { pSession->Delete_Session(sessionIdent); } |
[Top]
This use case has demonstrated the way to retrieve the active plane use by the harness flattening command.
[Top]
[Top] |
Version: 2 [January 2007] | Document updated |
[Top] |
Copyright © 2007, Dassault Systèmes. All rights reserved.