New Geometric Modeler Interfaces Layer |
| Technical Article |
AbstractThis article lists the modifications, and their migration path for the Geometric Modeler. |
One of the CAA V6 architecture goal is to minimize the code size at installation and manage to load the code which is strictly necessary for the achievement of some identified scenarios (open a model, perform measures on it ...). The new interfaces allow an application to load dynamically the dlls which are strictly needed for the execution of a given scenario.
Two interface frameworks are created:
The Tessellation, NewTopologicalObjects, GeometricOperators, TopologicalOperators, FreeFormOperators and AdvancedTopologicalOpe are no longer exposed. Their APIs are exposed through the GMModelInterfaces and GMOperatorsInterfaces frameworks.
Before
Now
GMModelInterfaces contains interfaces previously contained in the GeometricOperators, NewTopologicalObjects, Tessellation and BasicTopologicalOpe frameworks. GMOperatorsInterfaces contains interfaces previously contained in NewTopologicalObjects, BasicTopologicalOpe, FreeFormOperators and AdvancedTopologicalOpe frameworks.
The frameworks below are no longer packaged in the CAA offer:
#ifndef CATTopWire_h
#define CATTopWire_h
/**
* @CAA2Level L1
* @CAA2Usage U1
*/
#include "CATGeoToTopOperator.h"
...
class ExportedByPrimitives CATTopWire :public CATGeoToTopOperator
{
CATCGMVirtualDeclareClass(CATTopWire);
public:
/** @nodoc */
CATTopWire(CATGeoFactory *iFactory,
CATTopData * iData);
/** @nodoc */
...
virtual ~CATTopWire();
}
/**
* Creates an operator to build a wire body from several curves...
...
*/
ExportedByPrimitives
CATTopWire * CATCreateTopWire(CATGeoFactory *iFactory,
CATTopData *iData,...);
/** @nodoc */
ExportedByPrimitives CATBody * CATCreateWire(CATGeoFactory *iFactory,
CATTopData *iData, ...);
#endif
#ifndef CATICGMTopWire_h_
#define CATICGMTopWire_h_
...
/**
* @CAA2Level L1
* @CAA2Usage U3
*/
#include "CATGMOperatorsInterfaces.h"
#include "CATICGMGeoToTopOperator.h"
...
extern ExportedByCATGMOperatorsInterfaces IID IID_CATICGMTopWire;
class ExportedByCATGMOperatorsInterfaces CATICGMTopWire: public CATICGMGeoToTopOperator
{
public:
CATICGMTopWire();
protected:
virtual ~CATICGMTopWire(); // -> delete can't be called
}
/**
* Creates an operator to build a wire body from several curves...
...
*/
ExportedByCATGMOperatorsInterfaces
CATICGMTopWire *CATCGMCreateTopWire(CATGeoFactory *iFactory, ...);
#endif
#include "CATTopWire.h"
...
CATTopWire * pWire0 = ::CATCreateTopWire(piGeomFactory,
&topdata,
nbcurve0,
ListOfCurves0,
curLimits0,
wireOrientations0);
...
pWire0->Run();
...
CATBody * pWireBody0 = pWire0->GetResult();
...
delete pWire0; pWire0=NULL;
|
#include "CATICGMTopWire.h"
...
CATICGMTopWire * pWire0 = ::CATCGMCreateTopWire(piGeomFactory,
&topdata,
nbcurve0,
ListOfCurves0,
curLimits0,
wireOrientations0);
...
pWire0->Run();
...
CATBody * pWireBody0 = pWire0->GetResult();
...
pWire0->Release(); pWire0=NULL;
|
List of modifications
delete pWire0->pWire0->Release()A migration tool is provided in GeometricObjects. You can run it:
Step 1
Run the tck_list command to display the list of available tck profile identifiers then run the mkmk profile:
tck_profile myProfile |
Refer to Using TCKs for Accessing Tools for more information.
You can also open a command window from MsDev by using the CAA customization.
Step 2:
Set the CGMITF_WS_DIR environment variable
set CGMITF_WS_DIR=E:\MyWorkspace |
Step 3:
Run the profile below
CAAMathematics.edu\Data.d\Tools\CGMItfProfile.bat |
Step 4:
Run either command below:
CGMItfMigrate MyFramework |
or
CGMItfMigrate MyFramework\MyModule |
or
CGMItfMigrate MyFramework\MyModule\src\MyCode.cpp |
The files generated by this command have the .CGMItf_new extension
and a log file is generated in the ToolsData\CGMItfMigration folder.
Step 5:
Run either command below:
CGMItfMerge [-replace_all] MyFramework |
or
CGMItfMerge [-replace_all] MyFramework\MyModule |
or
CGMItfMerge [-replace_all] MyFramework\MyModule\src\MyCode.cpp |
The migrated files together with the CATIA Version 5 files are displayed.
Note: The vdiff32 tool is used by default to display the file differences. If need
be, you can specify a different tool by using the CGMITF_DIFF environment
variable.
Exit the vdiff32 application. The question below is displayed:
Do you want to get the migrated source? Y(es)/N(o)/Q(uit)
Reply:
Once you have migrated your application, you have to re-build your code. The migration tools described here above can leave some compilation errors behind. If so, here is a way to fix the major part of these compilation errors.
Step 1:
When re-compiling your frameworks, redirect the output in a text file. Example:
mkcpl MyFramework >c:\temp\traces.txt |
Step 2:
In Visual Studio, install the CGM Interface Migration Macros. To do so, open
the directory CAAMathematics.edu\Data.d\CGMItfVisualStudio in your Explorer and
double-click on CAACGMItfVisualStudio.vsmacros
The CAACGMItfMacros macros are now installed. They can be viewed in
the Visual Studio Macro Explorer (Alt+F8).

Step 3:
The FixCGMItfErrors macro should be launched first. Double-click the FixCGMItfErrors macro in the tree view above. The dialog box below is displayed.

To fill in field, enter the path of your trace file. Click OK.
Step 4:
Fix the other errors by clicking the other macros in the Macro Explorer tree structure. Here are the macro descriptions:
{ if (MyOperatorPointer) { MyOperatorPointer->Release(); MyOperatorPointer=
0; } |
See Creating, Running and Releasing a GM Operator in CAA V6
// CAA V5 MyOperatorPointer->Release(); |
is modified in:
// CAA V6
{ if (MyOperatorPointer) { MyOperatorPointer->Release(); MyOperatorPointer= 0; }
|
// CAA V5
{
CATSolidCylinder cylinder1 (factory, topdata, ..., ...)
...
}
|
which is converted into
// CAA V6 right after migration
{ CATIPGMSolidCylinder cylinder1 (factory, topdata, ..., ...) ... }
|
does not build because the CATIPGMSolidCylinder class is virtual.
The ReplaceAutoVarByCreate adds the appropriate creation fonctions, as well
as the Release() statement:
// CAA V6 after ReplaceAutoVarByCreate is activated
{
CATIPGMSolidCylinder *pcylinder1 = CATPGMCreateSolidCylinder(Factory, TopData,p1, p2, p3);
// ### CGMInterfaces AddRef()/Release() - BEGIN
pcylinder1->Release(); pcylinder1 = NULL;
// ### CGMInterfaces AddRef()/Release() - END
}
|
Example:
// CAA V5 delete MyOperatorPointer; |
is modified in:
// CAA V6 MyOperatorPointer->Release(); |
The macro takes into account CATSysDeletePtr, CATShDelete, CATPrt_DELETE, SAFE_DELETE, Remove, RemoveMapping.
// ### CGMInterfaces AddRef()/Release()
- END.// ### CGMInterfaces
string is replaced by // CGMInterfaces
so that it can no longer be treated by the VerifyEndOfLifeInFiles macro.
// ### CGMInterfaces AddRef()/Release()
- END and // ### CGMInterfaces new/delete
- ENDreturn! Running
the macro helps you to find these statements and relocate them properly if need
be (i.e before the return). Another point to be checked: The CATCatchs
block in which these statements should be duplicated. Example:
// CAA V5 _GSDOperator = (CATTopBlendInt*)CATCreateTopBlend (_Factory,...); |
which is converted into
// CAA V6 right after migration _GSDOperator = (CATIPGMTopBlendInt*)CATPGMCreateTopBlend (_Factory,...); |
The CAA V5 code is not correct because the CATCreateTopBlend function
returns a CATTopBlend pointer. Casting it as a derived class CATTopBlendInt
is not recommended as nothing guarantees that the returned object type matches.
It is a potential source of crash.
This is how it should be coded:
// CAA V6 right after migration
CATIPGMTopBlend *pTopBlend = CATPGMCreateTopBlend (_Factory, ...);
if (pTopBlend != NULL)
{
HRESULT hr = pTopBlend->QueryInterface(IID_CATIPGMTopBlendInt, (void **)&_GSDOperator);
pTopBlend->Release();
pTopBlend = NULL;
}
|
Recommendation:
Run the VerifyItfInCastInFiles.
For each cast, verify the class hierarchy:
// not clear !!!!!! CATIPGMOperator *pOperator = CATPGMCreateTopBlend (_Factory,...); ... CATIPGMTopBlend *pTopBlend = (CATIPGMTopBlend *)pOperator; |
should be replaced by
CATIPGMTopBlend *pTopBlend = CATPGMCreateTopBlend (_Factory,...); CATIPGMOperator *pOperator = pTopBlend; ... |
QueryInterface.| Frameworks | Replaced APIs |
|---|---|
| AdvancedTopologicalOpe | Replaced Interfaces |
| BasicTopologicalOpe | Replaced Interfaces |
| FreeFormOperators | Replaced Interfaces |
| GeometricObjects | Replaced Interfaces |
| GeometricOperators | Replaced Interfaces |
| NewTopologicalObjects | Replaced Interfaces |
| Tessellation | Replaced Interfaces |
| TopologicalOperators | Replaced Interfaces |
Some .h files have also been moved into other frameworks, the complete list
is available here.
| Version: 1 [Oct 2006] | Document created |