Geometric Modeler |
Geometry |
Creating Explicit ObjectsUsing the explicit factory |
Use Case |
AbstractThe use case illustrates how to create explicit objects and how they are managed by the CATIA Geometric Modeler in terms of life cycle. |
The use case explains how to create explicit objects and illustrates how their life cycle is managed. This use case has to be compared with CAAGobLifeCycleImplicit for a good understanding of the behavior of implicit objects with respect to explicit objects.
[Top]
CAAGobLifeCycleExplicit is a use case of the CAAGeometricObjects.edu framework that illustrates GeometricObjects framework capabilities.
[Top]
With this use case, you create an explicit CATPlane on which an explicit CATPline is created. Then this CATPLine is cloned. Because the CATCloneManager is created with the CatCGMSingleDuplicate option, the cloned CATPline points to the CATPlane. Then you remove the CATPline and make an attempt to re-use the initial CATPlane pointer.
[Top]
To launch CAAGobLifeCycleExplicit, you will need to set up the build time environment, then compile CAAGobLifeCycleExplicit.m along with its prerequisites, set up the run time environment, and then execute the use case [1].
If you simply type CAAGobLifeCycleExplicit with no argument, the use case executes, but doesn't save the result in an NCGM file. If you want to save this result, provide the full pathname of the NCGM file to create. For example:
With Windows CAAGobLifeCycleExplicit
e:\Obj.NCGM
With UNIX CAAGobLifeCycleExplicit
/u/Obj.NCGM
This NCGM file can be displayed using the CAAGemBrowser use case.
[Top]
The CAAGobLifeCycleExplicit use case is made of a main named CAAGobLifeCycleExplicit.cpp located in the CAAGobLifeCycleExplicit.m module of the CAAGeometricObjects.edu framework:
Windows | InstallRootDirectory\CAAGeometricObjects.edu\CAAGobLifeCycleExplicit.m\ |
Unix | InstallRootDirectory/CAAGeometricObjects.edu/CAAGobLifeCycleExplicit.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
The main program is divided into the following steps:
[Top]
The geometry factory (CATGeoFactory
) creates and manages all the
CATICGMObject. This creation is done by the global function ::CATCreateCGMContainer
.
Notice that the factory can be defined by reading a NCGM file that was
previously stored. In that case, the global function ::CATLoadCGMContainer
must be used.
CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ; if (NULL == piGeomFactory) return (1); |
[Top]
The implicit factory is retrieved from the standard factory by using the CATGeoFactory::GetImplicitGeoFactory( ) method.
CATGeoFactory * piImplicitFactory =piGeomFactory->GetImplicitGeoFactory( ); if (NULL == piImplicitFactory) return (1); |
[Top]
There are two ways to create a cloned objects:
CATPlane * piPlane = piGeomFactory->CreatePlane(CATMathOIJ); ... CATPLine * pPline = piGeomFactory->CreatePLine (p1, p2, piPlane ); // ----- Clone pPline - Single duplication mode // The duplicated // PLine points to the already existing plane. CATCloneManager * pCloneManager= new CATCloneManager(piGeomFactory, CatCGMSingleDuplicate); ... pCloneManager->Add(pPline); pCloneManager->Run(); CATICGMObject* piClonedPLine=NULL; piClonedPLine = pCloneManager->ReadImage(pPline); |
[Top]
The RemoveDependancies option only applies to implicit objects. By using it, you will remove all the implicit objects no longer used by the object which is to be removed. In this case all the objects are explicit. Removing pPline and or piClonedPLine will not affect the existence of piPlane. Whatever the CATCloneManager option, you will be able to re-use the piPlane pointer.
piImplicitFactory->Remove(pPline,CATICGMContainer::RemoveDependancies); piImplicitFactory->Remove(piClonedPLine,CATICGMContainer::RemoveDependancies); |
[Top]
To save the model in a file, the ::CATSaveCGMContainer
global
function is used. Notice that in the use case, the save is conditioned by an
input parameter representing the file inside which the model must be saved.
The use case ends with the closure of the geometry factory, done by the ::CATCloseCGMContainer
global function.
if(1==toStore) { #ifdef _WINDOWS_SOURCE ofstream filetowrite(pfileName, ios::binary ) ; #else ofstream filetowrite(pfileName,ios::out,filebuf::openprot) ; #endif ::CATSaveCGMContainer(piGeomFactory,filetowrite); filetowrite.close(); } // // Closes the container // ::CATCloseCGMContainer(piGeomFactory); |
[Top]
This use case to be compared with the CAAGobLifeCycleImplit
use
case, illustrates the behavior of explicit objects vs the behavior of implicit
objects in terms of life cyle.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Jun 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.