Geometric Modeler

Geometry

Creating Explicit Objects

Using the explicit factory
Use Case

Abstract

The use case illustrates how to create explicit objects and how they are managed by the CATIA Geometric Modeler in terms of life cycle.


What You Will Learn With This Use Case

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]

The CAAGobLifeCycleExplicit Use Case

CAAGobLifeCycleExplicit is a use case of the CAAGeometricObjects.edu framework that illustrates GeometricObjects framework capabilities.

[Top]

What Does CAAGobLifeCycleExplicit Do

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]

How to Launch CAAGobLifeCycleExplicit

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]

Where to Find the CAAGobLifeCycleExplicit Code

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]

Step-by-Step

The main program is divided into the following steps:

  1. Creating the Standard Geometry Factory
  2. Creating the Implicit Geometry Factory
  3. Creating the Explicit Objects: the CATPlane, the Initial CATPline and the Cloned CATPLine
  4. Removing the two Plines with RemoveDependancies and Attempting to Create a New CATPline
  5. Writing the Model and Closing the Container

[Top]

Creating the Sandard Geometry Factory

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]

Creating the Implicit Geometry Factory

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]

Creating the Explicit Objects: the CATPlane, the Initial CATPline and the Cloned CATPLine

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]

Removing the Two Plines with RemoveDependancies and Attempting to Create a New CATPline

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]

Writing the Model and Closing the Container

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]


In Short

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]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Jun 2003] Document created
[Top]

Copyright © 2003, Dassault Systèmes. All rights reserved.