Geometric Modeler |
Free Form Operators |
Converting Surfaces into NURBSHow to use the CATSurFittingToNurbsSur operator |
Use Case |
AbstractYou can convert surfaces into NURBS by using the CATSurFittingToNurbsSur operator. These 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 surface. |
This use case is intended to help you use the free form operators. It particularly illustrates how to convert a curve/surface into a NURBS curve/surface.
[Top]
The CATSurFittingToNurbsSur 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 surfaces. You must replay the sequence below:
as many times as you need.
[Top]
CAASurFittingToNurbsSur is a use case of the CAAFreeFormOperators.edu framework that illustrates the FreeFormOperators framework capabilities.
[Top]
This use case
[Top]
To launch CAASurFittingToNurbsSur, you will need to set up the build time environment, then compile CAASurFittingToNurbsSur.m along with its prerequisites, set up the run time environment, and then execute the use case [4].
If you simply type CAASurFittingToNurbsSur 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 CAASurFittingToNurbsSur e:\NurbsSur.NCGM
With UNIX CAASurFittingToNurbsSur /u/NurbsSur.NCGM
This NCGM file can be displayed using the CAAGemBrowser use case.
[Top]
The CAASurFittingToNurbsSur use case is made of a main named CAASurFittingToNurbsSur.cpp located in the CAASurFittingToNurbsSur.m module of the CAAFreeFormOperators.edu framework:
Windows | InstallRootDirectory\CAAFreeFormOperators.edu\CAASurFittingToNurbsSur.m\ |
Unix | InstallRootDirectory/CAAFreeFormOperators.edu/CAASurFittingToNurbsSur.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
CAASurFittingToNurbsSur.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]
The surface to be converted is a revolution surface created from a spline curve. Both the spline and the revolution surface are geometric objects created from the geometry factory.
[Top]
This first operator is intended to create an operator instance with the following parameters:
CATSurFittingToNurbsSur * pSurFitting1 = ::CATCreateSurFittingToNurbsSur(piGeomFactory, piSurface, surLimits, 0.001, 1, ADVANCED); |
At this stage, you have just created an instance of operator, if you want to get the converted NURBS, you must Run the operator and retrieve the resulting NURBS by using the GetNurbsSurface operator.
pSurFitting1->Run(); CATNurbsSurface * pNurbsSurf1 = pSurFitting1->GetNurbsSurface(); |
The transformation of the surface into NURBS is exact. To check this, you can use the IsExactTransformation method or retrieve the maximum deviation (0 is returned in the present use case).
// (g) --- Determine whether the transformation is exact // "Transformation exact" expected as the surface // has been specified rational // IsExact = pSurFitting1->IsExactTransformation(); if (IsExact == 0) cout << "Transformation not exact" << endl; else {cout << "Exact transformation" << endl;} // (h) --- Display the maximum deviation on the standard output // maxDeviat = pSurFitting1->GetMaxDeviation(); cout << "Maximum deviation of surface 1 " << maxDeviat << endl; |
Modify the rationality factor by replacing 1 with 0 in the argument 4 of the CATCreateSurFittingToNurbsSur operator. Recompile and rerun, the curve cannot be converted exactly because actually, you have set a constraint on the control point weights (1 everywhere).
This second operator is intended to create an operator instance with the same parameters as the first operator. Prior to running the operator, the minimum length of an arc is set to 32. The resulting transformation is not exact and a maximum deformation around 0.09 is achieved.
The operator tries first to comply the parameters specified by using the Setxxx methods.[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 CATCreateSurFittingToNurbsSur operators allows you to convert a surface into a NURBS surface. Apart from the usual parameters, this operator requires you specify the maximum deviation you would like to obtain from the initial surface as well as the rationality. Constraints on the resulting surface 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 |
[Top] |
Version: 1 [Feb 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.