Mechanical Modeler |
Creating Combined Curve's Factory InterfaceDefining and implementing the Combined Curve's factory interface |
|
Use Case | ||
Creating a New Geometrical Feature: The Combined Curve > Creating Combined Curve's Factory Interface |
AbstractThis article shows how to create new Combined Curve Instances by instantiating the Combined Curve StartUp. |
This use case illustrates how to create new Combined Curve instances.
To achieve this goal, two steps are necessary:
[Top]
CAAMmrCombinedCurve is a use case of the CAAMechanicalModeler.edu framework that illustrates MechanicalModeler framework capabilities.
[Top]
This use case makes it possible to create run time Instances of Combined Curve from the Combined Curve StartUp. Of course, this new skill means a new Interface. It will be called CAAIMmrCombinedCurveFactory. Its definition is straightforward, it could be translated in "create a Combined Curve from its two input curves and its two input directions".
CAAIMmrCombinedCurveFactory Interface's definition is very simple. A single method is enough to create any Combined Curve, whatever its input Curves and Directions are:
CAAIMmrCombinedCurveFactory::CreateCombinedCurve( Curve1, Direction1, Curve2, Direction2 , Output CombinedCurve ) |
Now that you have defined this new factory Interface, you have to choose a
good candidate to implement it. As described in the technical article entitled
"Creating a New StartUp deriving from a Mechanical StartUp" [1],
the candidate is CATPrtCont
the container of specifications [2].
To create Combined Curve instances, CATPrtCont
has to implement CAAIMmrCombCrvFactory
interface and CombinedCurve has to implement an interface of type, CAAIMmrCombinedCurve
[3], to valuate the attributes.
[Top]
See the section entitled "How to Launch the Combined Curve Use Case" in the "Creating a New Geometrical Feature: The Combined Curve" use case for a detailed description of how this use case should be launched.
[Top]
The CAAMmrCombinedCurve use case is made of a several classes located in the CAAMmrCombinedCurve.m module of the CAAMechanicalModeler.edu framework:
Windows | InstallRootDirectory\CAAMechanicalModeler.edu\CAAMmrCombinedCurve.m\ |
Unix | InstallRootDirectory/CAAMechanicalModeler.edu/CAAMmrCombinedCurve.m/ |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed.
In the ProtectedInterfaces of the CAAMechanicalModeler.edu framework there is the CATIMmrCombCrvFactory.h file.
[Top]
This use case is divided into the following steps:
[Top]
The Combined Curve Factory Interface (CAAIMmrCombCrvFactory) is pretty simple: a single method is enough to create a Combined Curve.
Here is its description. This is the main part of CAAIMmrCombCrvFactory.h:
class ExportedByCAAMmrCombinedCurve CAAIMmrCombCrvFactory: public CATBaseUnknown { CATDeclareInterface; public: virtual HRESULT CreateCombinedCurve ( CATISpecObject *ipCurve1, CATISpecObject *ipDirection1, CATISpecObject *ipCurve2, CATISpecObject *ipDirection2, CATISpecObject **opCombinedCurve ) = 0 ; } |
Do not hesitate to consult the Object Modeler documentation if you have trouble defining a new interface [4] (what to write in .h, .cpp and .tsrc files ).
[Top]
The object chosen as Combined Curve Factory extends the "CATPrtCont
"
late type. The following code extracted from CATEMmrCombCrvFactory.cpp declares
that CATPrtCont
is extended to implement the Combined Curve factory interface.
CATImplementClass ( CAAEMmrCombCrvFactory , DataExtension , CATBaseUnknown , CATPrtCont ); // Tie the implementation to its interface // --------------------------------------- #include "TIE_CAAIMmrCombCrvFactory.h" // needed to tie the implementation to its interface TIE_CAAIMmrCombCrvFactory( CAAEMmrCombCrvFactory); |
As usual, update your dictionary to declare that CATPrtCont
implements
CAAIMmrCombCrvFactory.
[Top]
To create a new Combined Curve Instance, all you need to do is to instantiate the Combined Curve StartUp. To do so, you first have to retrieve this StartUp. It has been stored in the Combined Curve Catalog file named CAAMmrCombinedCurveCatalog.CATfct [5].
Let's look at CATEMmrCombCrvFactory.cpp again to see how to retrieve the Combined Curve StartUp.
... CATIContainer *piContainerOnThis = NULL; HRESULT rc = QueryInterface( IID_CATIContainer , ( void**) &piContainerOnThis ); ... |
Then, the AccessCatalog
global function opens the Combined Curve
Catalog.
... CATICatalog * piCombinedCurveCatalog = NULL; CATUnicodeString StorageName = "CAAMmrCombinedCurveCatalog.CATfct"; CATUnicodeString ClientId = "SAMPLES"; rc = ::AccessCatalog( &StorageName, &ClientId, piContainerOnThis , &piCombinedCurveCatalog); ... |
CATICatalog::RetrieveSU
method finally retrieves the Combined
Curve StartUp.
... CATBaseUnknown *pCombinedCurveStartup = NULL; CATUnicodeString StartupType = "CombinedCurve"; piCombinedCurveCatalog->RetrieveSU( &pCombinedCurveStartup , &StartupType , "CATISpecObject" ); ... CATISpecObject *piSpecOnCombinedCurveStartup = NULL; rc = pCombinedCurveStartup->QueryInterface( IID_CATISpecObject , ( void**) &piSpecOnCombinedCurveStartup ); ... |
[Top]
The Combined Curve instance is created by instantiating the Combined Curve StartUp.
... *opiSpecOnCombinedCurve = piSpecOnCombinedCurveStartup->Instanciate( NULL_string , piContainerOnThis); ... |
You have just created your first Combined Curve instance!
[Top]
To define versioning on your mechanical feature [6],
you have to initialize a data needed to store the software configuration on your
feature.
This initialization is done calling the method "CreateConfigurationData" of
CATMmrAlgoConfigServices class.
... rc = CATMmrAlgoConfigServices::CreateConfigurationData(*opiSpecOnCombinedCurve); ... |
Your feature can now be versioned! This means that its mechanical behaviors can be fixed for next software generation.
[Top]
BackUp / StartUp is a specific mode which occurs when something goes wrong
with the CAAfeature (when startup catalog and code are not longer available on
the runtime view) [7]
As Combined Curve is a geometrical feature deriving from GeometricalElement3D,
you need to define and store its type according to CATIInputDescription
implementation. This information, stored on the instance, will be useful in
BackUpStartUp Mode to determine which behaviors are authorized.
This operation is done after instantiation, calling CATMmrFeatureAttributes::SetFeatureType
... CATIInputDescription* pInputDescriptionOnCombinedCurve = NULL; rc = (*opiSpecOnCombinedCurve)->QueryInterface( IID_CATIInputDescription, (void**) &pInputDescriptionOnCombinedCurve); ... CATIInputDescription::FeatureType Feature_type = CATIInputDescription::FeatureType_Unset; rc = pInputDescriptionOnCombinedCurve -> GetFeatureType(Feature_type); ... rc = CATMmrFeatureAttributes::SetFeatureType(*opiSpecOnCombinedCurve, Feature_type); ... |
You have now defined the feature type of your Combined Curve! Let's now valuate this instance!
[Top]
The attributes of this newly Combined Curve Instance are still empty. The interface of type for Combined Curve (CAAIMmrCombinedCurve) has methods to fill in the Combined Curve instance's attributes.
... CAAIMmrCombinedCurve *piCombinedCurve = NULL; rc = (*opiSpecOnCombinedCurve)->QueryInterface( IID_CAAIMmrCombinedCurve, (void**) &piCombinedCurve ); ... piCombinedCurve->SetCurve ( 1 , ipiSpecOnCurve1 ); piCombinedCurve->SetDirection( 1 , ipiSpecOnDirection1 ); piCombinedCurve->SetCurve ( 2 , ipiSpecOnCurve2 ); piCombinedCurve->SetDirection( 2 , ipiSpecOnDirection2 ); ... |
A complete documentation of this Interface is available [3].
[Top]
This use case has demonstrated how to create Combined Curve Instances by instantiating the Combined Curve StartUp retrieved in the Combined Curve StartUp Catalog file.
[Top]
Version: 1 [Mar 2000] | Document created |
Version: 2 [Jan 2003] | Document updated |
Version: 3 [Jan 2007] | Document updated (Algorithm Services and BackUp/StartUp data) |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.