Geometric Modeler |
Free Form Operators |
Converting Curves into NURBSHow to use the CATCrvFittingToNurbsCrv operator |
Use Case |
AbstractYou can convert curves into NURBS by using the CATCrvFittingToNurbsCrv operator. This operator allows you to specify the characteristics of the resulting NURBS as well as a maximum deviation you would like to obtain with respect to the initial curve. This maximum deviation may not be achieved. |
This use case is intended to help you use the free form operators. It particularly illustrates how to convert a curve into a NURBS.
[Top]
The CATCrvFittingToNurbsCrv operator is to be used according to the general scheme of operators:
Note: In ADVANCED mode, you cannot use the same operator to convert several curves. You must replay the sequence below:
as many times as you need.
[Top]
CAACrvFittingToNurbsCrv is a use case of the CAAFreeFormOperators.edu framework that illustrates the FreeFormOperators framework capabilities.
[Top]
This use case
[Top]
To launch CAACrvFittingToNurbsCrv, you will need to set up the build time environment, then compile CAACrvFittingToNurbsCrv.m along with its prerequisites, set up the run time environment, and then execute the use case [4].
If you simply type CAACrvFittingToNurbsCrv 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 CAACrvFittingToNurbsCrv e:\NurbsSur.NCGM
With UNIX CAACrvFittingToNurbsCrv /u/NurbsSur.NCGM
This NCGM file can be displayed using the CAAGemBrowser use case.
[Top]
The CAACrvFittingToNurbsCrv use case is made of a main named CAACrvFittingToNurbsCrv .cpp located in the CAACrvFittingToNurbsCrv.m module of the CAAFreeFormOperators.edu framework:
Windows | InstallRootDirectory\CAAFreeFormOperators.edu\CAACrvFittingToNurbsCrv.m\ |
Unix | InstallRootDirectory/CAAFreeFormOperators.edu/CAACrvFittingToNurbsCrv.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
CAACrvFittingToNurbsCrv .cpp is divided into four 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]
The curve to be converted is a PSpline. Its underlying geometry is a sphere. All the geometric objects are created from the geometry factory.
[Top]
This first operator is intended to create an operator instance with the following parameters:
CATCrvFittingToNurbsCrv * pCrvFitting1 = ::CATCreateCrvFittingToNurbsCrv(piGeomFactory, piCurve, crvLimits, maxdeviation, 1, ADVANCED) ; |
At this stage, you have just created an instance of operator. Prior to running the operator, the minimum length of an arc is set to 14.
// (d) --- Specifies the minimal length of an arc on the output curve // Should be properly specified with respect to the input curve // length - otherwise the execution results in an abend // pCrvFitting1->SetInternalMinLength(14); |
If you want to get the converted NURBS, you must Run the operator and retrieve the resulting NURBS by using the GetPNurbs method. To convert a CATPCurve into a CATNurbsCurve, you can use the Set3DCurveCreation method (before applying the Run method), then use the GetNurbsCurve method instead of GetPNurbs.
pCrvFitting1->Run(); CATPNurbs * piPNurbs1 = pCrvFitting1->GetPNurbs(); |
The transformation of the curve into NURBS is not exact. To check this, you can use the IsExactTransformation method or retrieve the maximum deviation (0.899 is returned in the present use case).
cout << "Maximum deviation is " << pCrvFitting1->GetMaxDeviation() << endl; |
[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]
The CATCreateCrvFittingToNurbsCrv operator allows you to convert a curve into a NURBS. Apart from the usual parameters, this operator requires you specify the maximum deviation you would like to obtain from the initial curve as well as the rationality. Constraints on the resulting curve can be specified by using Setxxx methods.
[Top]
[1] | The NURBS Curves |
[2] | The CGM Objects |
[3] | The CGM Curves |
[4] | Building and Launching a CAA V5 Use Case |
[5] | Converting Surfaces into NURBS |
[Top] |
Version: 1 [Feb 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.