Geometric Modeler |
Topology |
Computing the Area of a CATFace and the Length of a CATEdgeHow to calculate the area of a face and the length of an edge |
Use Case |
AbstractThe CATDynMassProperties3D class provides services whereby you can calculate the properties of a body as well as the properties of the cells making up the body. This use case explains how to calculate the area of a CATFace along with the length of a CATEdge |
In this use case, you learn how to compute the area of a face as well as the length of an edge.
[Top]
CAATopProperties is a use case of the CAATopologicalOperators.edu framework that illustrates TopologicalOperators framework capabilities.
[Top]
This use case:
[Top]
To launch CAATopProperties, you will need to set up the build time environment, then compile CAATopProperties.m along with its prerequisites, set up the run time environment, and then execute the use case [1].
If you simply type CAATopProperties 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 CAATopProperties
e:\Properties.NCGM
With UNIX CAATopProperties
/u/Properties.NCGM
This NCGM file can be displayed using the CAAGemBrowser use case.
[Top]
The CAATopProperties use case is made of a main named CAATopProperties.cpp located in the CAATopProperties.m module of the CAATopologicalOperators.edu framework:
Windows | InstallRootDirectory\CAATopologicalOperators.edu\CAATopProperties.m\ |
Unix | InstallRootDirectory/CAATopologicalOperators.edu/CAATopProperties.m/ |
where InstallRootDirectory is the directory where the CAA CD-ROM is installed.
[Top]
The program:
[Top]
The geometry factory (CATGeoFactory) creates and manages all the CATICGMObject : it creates the points, curves, surfaces and bodies and remove them.
The CATGeoFactory creation itself 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]
CATMathPoint p1(0,0,0); // the sphere center CATSolidSphere * pSphereOpe = ::CATCreateSolidSphere(piGeomFactory, &topdata, p1, 100.0); // the radius ... pSphereOpe -> Run(); CATBody * pBodySphere = pSphereOpe -> GetResult(); ... |
[Top]
To retrieve a face area, you must:
for (int i=1;(i <= nbFaces) ;i++) { CATFace * pFace = (CATFace *)listFaces[i]; CATDynMassProperties3D * pDynMassOpe0 = CATDynCreateMassProperties3D(pFace ) ; if (NULL == pDynMassOpe0) { ::CATCloseCGMContainer(piGeomFactory); return (1); } // Expected area 4*PI*(R**2)/4 cout << "Face " << i << " area: " << pDynMassOpe0->GetWetArea() << endl; delete pDynMassOpe0; pDynMassOpe0=NULL; } |
[Top]
To retrieve a face area, you must:
for (i=1;(i <= nbEdges) ;i++) { CATEdge * pEdge = (CATEdge *)listEdges[i]; if (pEdge == NULL) return 1; CATDynMassProperties3D * pDynMassOpe1 = CATDynCreateMassProperties3D(pEdge ) ; if (NULL == pDynMassOpe1) { ::CATCloseCGMContainer(piGeomFactory); return (1); } cout << "Edge " << i << " length: " << pDynMassOpe1->GetLength() << endl; cout << pEdge->GetPersistentTag() << endl; delete pDynMassOpe1; pDynMassOpe1=NULL; } |
This is the length with is displayed on the standard output:
|
|
|
|
|
|
[Top]
Before ending, we must first release the software configuration.
// Releases the configuration pConfig->Release(); |
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(); } // // Close the container // ::CATCloseCGMContainer(piGeomFactory); |
[Top]
This use case explains how to compute the area of a face and the length of an edge by using the CATDynMassProperties3D class.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Feb 2002] | Document created |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.