Geometric Modeler |
Geometry |
How to Read an AttributeReading a streamed attribute |
Use Case |
AbstractThis use case explains how to read a CATCGMStreamAttribute. It is associated with the How to Create an Attribute article. Run this use case after you have run the CAAGobAttributeCreation use case. The file generated by the CAAGobAttributeCreation use case is to be used as input file for the CAAGobAttributeRead use case. |
The use case explains how to read a CATCGMStreamAttribute. The attribute implementation is defined in the CAAGobAttribute.m module. The way it has to be created is explained in How to Create an Attribute.
[Top]
CAAGobAttributeRead is a use case of the CAAGeometricObjects.edu framework that illustrates GeometricObjects framework capabilities.
[Top]
This use case loads a file and scans the geometry to search for the attributes of a given type (CAAGobAttributeManagement) on a geometry of a given type (PLineType).
[Top]
To launch CAAGobAttributeRead, you will need to set up the build time environment, then compile CAAGobAttributeRead.m and CAAGobAttribute.m along with their prerequisites, set up the run time environment, and then execute the use case [1].
You must type CAAGobAttributeRead with an argument to execute the use case.
With Windows CAAGobCreation e:\AttToBeRead.NCGM
With UNIX CAAGobCreation /u/AttToBeRead.NCGM
AttToBeRead.NCGM is the file generated by CAAGobAttributeCreation.m
[Top]
The CAAGobAttributeRead use case is made of a main named CAAGobAttributeRead.cpp located in the CAAGobAttributeRead.m module of the CAAGeometricObjects.edu framework:
Windows |
InstallRootDirectory\CAAGeometricObjects.edu\CAAGobAttributeRead.m\ |
Unix |
InstallRootDirectory/CAAGeometricObjects.edu/CAAGobAttributeRead.m/ |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed.
The use case uses a class defined in the CAAGobAttribute.m module.
[Top]
The main program peforms the following steps:
[Top]
The geometry factory (CATGeoFactory) creates and manages all the
CATICGMObject (and the curves and surfaces in particular). In this use case,
the factory is defined by reading a NCGM file that was previously stored,
the global function ::CATLoadCGMContainer
must be used to retrieve
the factory.
CATGeoFactory* piGeomFactory = CATLoadCGMContainer(filetoread); |
[Top]
Here are the step to follow in order to read specific attributes in a geometry.
// (b) --- Loop through the geometry // ... for (piCurG = piGeomFactory->Next(NULL,CATPLineType); piCurG != NULL; piCurG = piGeomFactory->Next(piCurG)) { // Find the PLine from its persistent tag // curtag = piCurG->GetPersistentTag(); CATICGMObject * piCGMObj = piGeomFactory->FindObjectFromTag(curtag); if (piCGMObj == NULL) { cout << "No object with the specified tag" <<endl; return 1; } // Retrieve the CATCGMAttribute from its identifier // CATCGMAttribute * piActAttr = piCGMObj-> GetAttribute(UAIDPtr(CAAGobAttributeManagement)); // No searched attribute found on the PLine // if (NULL == piActAttr) { cout << "------------------------------------------------- " << endl; cout << "PLine with no CAAGobAttributeManagement attribute " << endl; } // The searched attribute found on the Pline // else { cout << "------------------------------------------------- " << endl; cout << "PLine with CAAGobAttributeManagement attribute " << endl; CAAGobAttributeManagement * iPersAttr = NULL; iPersAttr = (CAAGobAttributeManagement *) piActAttr; // Retrieve the attribute value // See the CAAAttributeManagement module // if (iPersAttr) { long oPersval; iPersAttr->GetValue(oPersval); } else return 1; cout << "----------------------------------- " << endl; } } } |
[Top]
The use case ends with the closure of the file and the CGM container (done
by the ::CATCloseCGMContainer
global function).
filetoread.close(); CATCloseCGMContainer(piGeomFactory); |
[Top]
The use case illustrates how to read attributes.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Apr 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.