Geometric Modeler |
Geometry |
Geometric OperatorsThe general use explained on an example |
Use Case |
AbstractGeometric operators are transient objects that allow you to create new
geometric objects from existing ones or to analyze them. These operators
are based on the same scheme, which is described. The example of the
intersection between a curve and a surface illustrates the general
mechanism, and is discussed using the |
This use case is intended to help you use the geometric operator classes. It particularly details the intersection geometric operator, as an example of geometric operator.
[Top]
Using geometric operators is an easy way to create or analyze geometric objects. While the geometric objects provide basic services, that are easily computed by the objects themselves, the geometric operators do more complex operations using advanced mathematics tools. As an example, evaluations from parameters to Cartesian coordinates is offered by the geometric curve or surface, whereas the torsion or curvature are computed by a geometric operator.
All these operators never modify the input objects: they create new ones.
The geometric operators work inside one geometric container: the input and output objects must belong to the same geometric container.
The operators creating geometric objects are:
The operators of geometric analysis are:
The geometric operators are generic: the CATIntersectionCrvSur operator, for example, computes the intersection of any type of curves with any type of surfaces.
[Top]
All the geometric operators are based on the same scheme. The geometric operator instances, created by a global function, are transient (that is to say, they are not streamed when streaming the geometric factory). They are used to declare an operation, to run it, and to retrieve the resulting objects.
The geometric operators can be used in two modes, BASIC or ADVANCED.
For example, the intersection between a curve and a surface can lead to several resulting points and curves, so that this operator provides iterators on the resulting points and on the resulting curves.
[Top]
CAAGopIntersect is a use case of the CAAGeometricOperators.edu framework that illustrates GeometricOperators framework capabilities.
[Top]
This use case presents the global scheme of the geometric operators and takes the curve-surface intersection operator as example. The curve is a line, and the surface a cylinder. The operator being independent of the type of curve or surface, any kind of curve or surface can be used in the same way. |
[Top]
To launch CAAGobIntersect, you will need to set up the build time environment, then compile CAAGobIntersect.m along with its prerequisites, set up the run time environment, and then execute the use case [4].
If you simply type CAAGopIntersect 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 CAAGopIntersect e:\Intersect.NCGM
With UNIX CAAGopIntersect /u/Intersect.NCGM
This NCGM file can be displayed using the CAAGemBrowser use case.
[Top]
The CAAGopIntersect use case is made of a main named CAAGopIntersect.cpp located in the CAAGopIntersect.m module of the CAAGeometricOperators.edu framework:
Windows | InstallRootDirectory\CAAGeometricOperators.edu\CAAGopIntersect.m\ |
Unix | InstallRootDirectory/CAAGeometricOperators.edu/CAAGopIntersect.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
CAAGopIntersect.cpp is divided into five logical steps:
[Top]
The geometry factory (CATGeoFactory) creates and manages all the CATICGMObject (and the curves and surfaces in particular) [1]. 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]
// ------------ line passing thru (0,0,0), of direction (1.,1.,0) CATLine * piLine = piGeomFactory->CreateLine(CATMathO, // (0,0,0) math point CATMathVector(1.,1.,0.) ); if (NULL==piLine) { ::CATCloseCGMContainer(piGeomFactory); return (1); } // // ------------ cylinder double radius = 10.; double axisStart = -50.; double axisEnd = 50.; double angleStart = 0.; double angleEnd = CAT2PI; CATCylinder* piCylinder = piGeomFactory->CreateCylinder(CATMathOIJK, // canonical axis system radius, axisStart, axisEnd, angleStart, angleEnd); if (NULL==piCylinder) { ::CATCloseCGMContainer(piGeomFactory); return (1); } |
The geometry is created by the CATGeoFactory with the CreateLine and CreateCylinder methods.
[Top]
To operate in this mode, write the following steps:
The BASIC mode is the default mode. This argument can be omitted
The CATICGMContainer::Remove method removes the point from the geometry factory. If the point is not removed, it is streamed when streaming the factory.
Note: Although geometric objects are handled by the mean of interfaces, such as CATCartesianPoint, CATLine, or CATBody, the pointers on these objects must not be released. In fact, they are released at the closure of the factory (the CATCloseCGMContainer global function).
[Top]
This mode can be use, in case of the curve - surface intersection:
To operate in this mode, write the following steps that:
CATIntersectionCrvSur* pIntOp = ::CreateIntersection( piGeomFactory, // geometric factory piLine, // geometric line piCylinder, // geometric cylinder ADVANCED); // MODE if (NULL==pIntOp) return (3); // set limits. These limits were previously defined or computed pIntOp->SetLimits(crvLimits); // run pIntOp->Run(); // get the results // ... same way as in BASIC mode ..., but not same result! // as the curve limits are more restrictive, only one solution is found // set another line and new limits pIntOp->SetCurve(piNewLine); // piNewLine was previously created pIntOp->SetLimits(newCrvLimits); // newCrvLimits was previously defined // run again pIntOp->Run(); // get the results nbPoints = pIntOp->GetNumberOfPoints(); cout << " Number of intersection points: "<< nbPoints << endl; long nbCurves= pIntOp->GetNumberOfCurves(); cout << "Number of intersection curves: "<< nbCurves << endl; // delete delete pIntOp; pIntOp=NULL; |
Note:
CATCrvParam startParam, endParam; // piLine is the line of origin CATMathO and of direction (1.,1.,0.) // The use of GetParam is only possible because the points belong to the line // and piLine is canonical. // In other cases use a CATProjectionPtCrv operator piLine->GetParam(CATMathO,startParam); // another point on the line piLine->GetParam(CATMathPoint(35.,35.,0.),endParam); // the limits CATCrvLimits crvLimits(startParam,endParam); |
[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]
[Top]
[1] | The CGM Objects |
[2] | The CGM Curves |
[3] | The CGM Surfaces |
[4] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Feb 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.