Shape Design & Styling |
Generative Shape Design |
Converting a Shape Design Feature into a DatumUsing the Shape Design factory to convert a Shape Design feature into a datum |
Use Case |
AbstractThis article discusses the CAAGsiDatum use case. This use case explains how to convert feature into datum.
|
This use case illustrate the ability to convert any Wireframe and Shape Design
feature into a Datum.
Wireframe and Shape Design features to be converted do not have any child, that
is to say, they do not aggregate other features (Ex: contextual features)
[Top]
CAAGsiDatum is a use case of the CAAGSMInterfaces.edu framework that
illustrates the ConvertToDatum
method of theCATIGSMFactory
interface of the GSMInterfaces framework.
[Top]
The goal of CAAGsiDatum is to take the result of surface features of the CAAGsiNozzle use case, join them and convert the join into a corresponding datum feature (skin surface).
[Top]
To launch CAAGsiDatum, you will need to set up the build time environment, then compile CAAGsiDatum along with its prerequisites, and set up the run time environment, and then execute the use case [1].
Launch the use case as follows:
e:>CAAGsiDatum inputDirectory\GAAGsiNozzle.CATPart outputDirectory\CAAGsiDatum.CATPart |
$ CAAGsiDatum inputDirectory/GAAGsiNozzle.CATPart outputDirectory/CAAGsiDatum.CATPart |
where:
outputDirectory |
The directory into which CAAGsiDatum.CATPart is saved |
inputDirectory |
The directory into which CAAGsiNozzle.CATPart is found
|
CAAGsiDatum.CATPart |
The file that contains the part created with the datum surface t |
[Top]
The CAAGsiDatum use case is made of main program located in the CAAGsiDatum.m module of the CAAGSMInterfaces.edu framework:
Windows | InstallRootDirectory\CAAGSMInterfaces.edu\CAAGsiDatum.m\ |
Unix | InstallRootDirectory/CAAGSMInterfaces.edu/CAAGsiDatum.m/ |
The input CAAGsiNozzle.CATPart is proposed in Data.d directory of CAAGSMInterfaces.edu
Windows |
InstallRootDirectory\CAAGSMInterfaces.edu\Data.d\CAAGsiNozzle.CATPart
|
Unix |
InstallRootDirectory/CAAGSMInterfaces.edu/Data.d/CAAGsiNozzle.CATPart |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed.
[Top]
There are four logical step in CAAGsiDatum:
We will now comment each of those sections by looking at the code of the main method of file CAAGsiDatum.
[Top]
CAAGsiDatum sample first creates a session and opens the input CATPart.
Note: The important feature of the following sequence of code consists in the required call to the GetPart() method of the CATPrtContainer interfaces. \
This method allow to load in session the different containers of the part (feature container, geometric container,..)
... // creates a session char *pSessionName = "SampleSession"; CATSession *pSession = NULL; rc = Create_Session(pSessionName, pSession); if (NULL == pSession ) { cout << "(CAAGsiDatum) ERROR: Create_Session" << endl; TestCaseError = 1 ; } // loads the document and initializes it cout << "The input document " << InputName << " is opened" << endl ; CATDocument *pDoc = NULL; rc =CATDocumentServices::OpenDocument(InputName, pDoc) ; if (NULL == pDoc ) { cout << "(CAAGsiDatum) ERROR CATDocumentServices::OpenDocument" << endl; TestCaseError = 2 ; } // Part Container CATIPrtContainer *piPartContainer = NULL ; CATIPrtPart_var spPrtPart; if ( NULL != pDoc ) { // queries on the document to get the root container CATInit *pDocAsInit = NULL; pDoc->QueryInterface(IID_CATInit, (void**)&pDocAsInit) ; if ( NULL != pDocAsInit ) { // Extracts from document a reference to its part in hPartAsRequest piPartContainer = (CATIPrtContainer*)pDocAsInit->GetRootContainer("CATIPrtContainer"); pDocAsInit->Release(); pDocAsInit = NULL ; if( NULL != piPartContainer ) { CATISpecObject_var spPart = piPartContainer->GetPart() ; spPrtPart = spPart ; } } ... |
Finally, the wireframe and shape design factory is retrieved. .
.... // Retrieve the Generative Shape Design Interface CATIGSMFactory_var spGsmFact; if ( NULL !=piPartContainer ) { CATIGSMFactory * _pFact =NULL; rc = piPartContainer -> QueryInterface(IID_CATIGSMFactory ,(void**)&_pFact); if (SUCCEEDED(rc) ) { spGsmFact = _pFact; if (_pFact) _pFact -> Release(); _pFact = NULL; } } ... |
[Top]
Using standard creation method for join (also named assemble), sweep and loft features are joined
... // Join // ------------------ CATLISTV(CATISpecObject_var) aObjectParametersAssemble; aObjectParametersAssemble.Append(spSweep1); aObjectParametersAssemble.Append(spLoft1); aObjectParametersAssemble.Append(spSweep2); aObjectParametersAssemble.Append(spLoft2); // Create feature double MergingDistanceTol = 0.001 ; CATBoolean iCheckConnexity = TRUE ; CATICkeParm_var spParm; CATICkeParmFactory_var spCkeFact = spGsmFact ; if (!!spCkeFact) { spParm = spCkeFact -> CreateLength("MergingDistance",MergingDistanceTol/1000.0); } CATIGSMAssemble_var spAssemble = spGsmFact -> CreateAssemble(aObjectParametersAssemble,spParm,iCheckConnexity); aObjectParametersAssemble.RemoveAll(); // Insert in procedural view // ------------------ CATISpecObject_var spSpecTmp = spAssemble; if (NULL_var != spSpecTmp) { // Insert in procedural view CATIGSMProceduralView_var ispProcView = spSpecTmp; if (NULL_var != ispProcView ) { rc = ispProcView ->InsertInProceduralView(); } } // Update CAAGsiObjectUpdate(spSpecTmp); ... |
The join feature is then
[Top]
Verify that the feature to convert is not already a Datum
.... // Check the feature to convert is not already a Datum CATIMf3DBehavior_var ispBehave(ispSpec); if(NULL_var != ispBehave ){ if ( FAILED( ispBehave -> IsADatum() ) ) { .... } } ... |
Use the ConvertToDatum method of CATIGSMFactory interface.
This method is only available for features which do not have any child (do not
aggregate other features) , The argument "Verif" allow to verify it.
For multi-domain feature, one datum feature is generated by domain of the original feature
.... CATListValCATISpecObject_var *ListDatum=NULL; // Convert Spec in one or more Datum int iVerif =1 ; // Check feature do not have any child rc = ispGsmFact->ConvertToDatum(ispSpec, ListDatum,iVerif); if (FAILED(rc)) return E_FAIL; ... |
Once created the datum feature got the representation of the the original
feature thus it is mandatory to remove the original feature
This operation has to be done in 2 step
.... // Delete of Procedural Specification // -- Model event for delete / update visualization CATIModelEvents_var IME(ispSpec); if(NULL_var != IME) { CATDelete info(ispSpec->GetImpl()); IME->Dispatch(info); } // -- Delete Specification CATISpecObject_var ispFather = ispSpec->GetFather(); // Specification is aggretated in the prodecural view if (NULL_var != ispFather) { ispFather->Release(); CATIDescendants_var ispDes = ispFather; ispDes->RemoveChild (ispSpec); } // Specification is not in the prodecural view else { LifeCycleObject_var LCO = ispSpec; LCO -> remove(); } .... |
The Datum is created , previous feature is deleted, now the Datum has to be inserted in the procedural view as for any other shape designs feature (Wires, Surfaces and Volumes created in CATIGSMFactory).
.... // Insert in procedural view int i; int size = AllDatums.Size(); for(i=1;i<=size;i++) { CATIGSMProceduralView_var curobj = AllDatums[i]; if (NULL_var != curobj ) { rc = curobj->InsertInProceduralView(); if (FAILED(rc)) cout << " (CAAGsiDatum) Failed to insert datum in procedural view" << endl ; .... |
[Top]
Save part and close the session
... // save if (NULL != OutputName ) { rc = CATDocumentServices::SaveAs (*pDoc, OutputName ); if (SUCCEEDED(rc)) { cout << " (CAAGsiDatum) Document saved " << endl; } else { cout << " ERROR in saving document " << endl ; } } // Closes the document CATDocumentServices::Remove(*pDoc); // Ends session and drops document Delete_Session("SampleSession"); ... |
[Top]
This use case has demonstrated the way to convert de Datum from an existing feature.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | About Generative Shape Design Features |
[3] | Inserting a Shape Design Feature in the procedural view |
[4] | Updating a shape Design feature |
[Top] |
Version: 1 [May 2004] | Document created |
[Top] |
Copyright © 2004, Dassault Systèmes. All rights reserved.