Geometric Modeler |
Geometry |
Foreign SurfacesHow to introduce foreign surfaces |
Use Case |
AbstractThe GeometricObjects framework exposes the interfaces for the geometry: points, curves, surfaces, and some related classes (such as knot vector or surface and curve parameters for example). Moreover, it offers the programmer the capability to introduce its own definition of curve and surface. Such "foreign" definition is then taken into account as any CATIA curve and surface. The use cases illustrates the introduction of a new kind of surface. The way to use the geometry (and the foreign geometry in particular) is detailed in the CAAGobCreation use case. The same methodology can be used to introduce foreign curves, only differing by the parent class to derive. |
This use case explains the introduction of a new kind of geometric surface by describing all the steps of its introduction on a concrete case. The mathematical definition of the new surface is given by the CAAAmtForeignFunctionXY class, already presented in the CAAAmtForeign use case [6] of the CAAAdvancedMathematics.edu framework.
[Top]
CAAGobForeign is a use case of the CAAGeometricObjects.edu framework that illustrates GeometricObjects framework capabilities.
[Top]
The use case creates a new type of surface, which mathematical definition uses the CAAAmtForeignFctXY mathematical function class.
The principle of the introduction of a new kind of surface is fully described
in [1]. Once defined the mathematical definition CAAAmtForeignFctXY
,
one must create a persistent attribute to be the data of CATIForeignSurface
.
For that:
[Top]
As CAAGobForeign only provides the definition of the new surface, it cannot be run alone: you must launch CAAGobCreation to execute the CAAGobForeign code.
To launch CAAGobCreation, you will need to set up the build time environment,
then compile CAAGobForeign.m and CAAGobCreation.m along with their prerequisites
(such as CAAAmtForeignFct.m), set up the run time environment, and then execute
the use case [7]. Do not forget to run the mkCreateRuntimeView
command to update the runtime dictionary.
[Top]
The CAAGobForeign use case contains the definition of the new class located:
Windows | InstallRootDirectory\CAAGeometricObjects.edu\CAAGobForeign.m\ |
Unix | InstallRootDirectory/CAAGeometricObjects.edu/CAAGobForeign.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
Moreover, in order to register this new class,
Windows | InstallRootDirectory\CAAGeometricObjects.edu\CNext\code\dictionary\CAAGeometricObjects.edu.dico |
Unix | InstallRootDirectory/CAAGeometricObjects.edu/CNext/code/dictionary/CAAGeometricObjects.edu.dico |
[Top]
The use case is divided into the following steps:
Following the described scheme, first define the header of the surface attribute.
[Top]
The new attribute class CAAGobForeignSurfaceData derived from the CATForeignSurfaceData class, which is a special streamable attribute dedicated to the foreign surface introduction.
Methods are overridden to declare the specific behavior of the new class (only some of them are displayed below).
class ExportedByCAAGobForeign CAAGobForeignSurfaceData : public CATForeignSurfaceData { public : // Mandatory macro for inheriting from CATCGMAttribute . CATCGMDeclareAttribute (CAAGobForeignSurfaceData,CATForeignSurfaceData); // Constructs the surface data. // S(u,v) = iOrigin + u*iUDirection // + v*iVDirection // + iHeight*cos(u)*cos(v)*iUDirection^iVDirection, // uMin<=u<=uMax, vMin<=v<=vMax. </pre> CAAGobForeignSurfaceData(const CATMathPoint & iOrigin, const CATMathVector & iUDirection, const CATMathVector & iVDirection, const double iHeight, const double iUMin, const double iUMax, const double iVMin, const double iVMax ) ; //------------------------------------------------------------------------------ // Mandatory methods for CATCGMAttribute //------------------------------------------------------------------------------ // Default constructor. CAAGobForeignSurfaceData(); // Streams the data. void Stream(CATCGMStream & iStr) const ; // Unstreams the data. void UnStream(CATCGMStream & iStr) ; //------------------------------------------------------------------------------ // Mandatory methods for CATForeignGeometryData //------------------------------------------------------------------------------ // Clones <tt>this</tt> CAAAForeignSurfaceSample. CATForeignGeometryData* Clone(CATCloneManager & iCloning) const ; // Moves <tt>this</tt> CAAAForeignSurfaceSample. void Move3D(CATTransfoManager & iTransfo) ; // ... // // Retrieves the mathematical equation associated with a patch. void CreateLocalEquation(const long iPatchU, const long iPatchV, const CATMathFunctionXY* & oFx, const CATMathFunctionXY* & oFy, const CATMathFunctionXY* & oFz) ; private : // Data // S(u,v) = Origin + u*dU + v*dV + Height*cos(u)*cos(v)*dU^dV, // uMin<=u<=uMax, vMin<=v<=vMax. double _uMin ; double _uMax ; double _vMin ; double _vMax ; double _Origin[3] ; double _Height ; double _dU[3] ; double _dV[3] ; }; |
ExportedByCAAGobForeign
variable is defined in the CAAGobForeign.h
header.CATCGMDeclareAttribute
macro is also mandatory to declare
the derivation.[Top]
This section emphasizes on some methods of the .cpp:
Once again, a macro must be declared: CATCGMImplAttribute
.
// CAAGobFS is the application name that you will find in the dictionary. // This application name is declared in the CAAGobApplicationName.cpp file. // 1 must not be changed. CATCGMImplAttribute(CAAGobForeignSurfaceData, CATForeignSurfaceData, CAAGobFS, 1); |
Stream and unstream methods are mandatory to allow your data to be saved
and read. In this use case, the foreign surface is standalone: it does not
point to any other CGM objects. If it were not, use the CATCGMStreamAttribute::AddLink
method. In this case, the stream and unstream processes will automatically
take the links into account, so that you do not worry about them.
//----------------------------------------------------------------------------------- void CAAGobForeignSurfaceData::Stream(CATCGMStream & iStr) const //----------------------------------------------------------------------------------- { iStr.WriteDouble( _uMin ) ; iStr.WriteDouble( _uMax ) ; iStr.WriteDouble( _vMin ) ; iStr.WriteDouble( _vMax ) ; iStr.WriteDouble( _Origin, 3 ) ; // streams the origin (array of 3 doubles) iStr.WriteDouble( _Height ) ; // streams the other values iStr.WriteDouble( _dU , 3 ) ; // streams the first vector (array of 3 doubles) iStr.WriteDouble( _dV , 3 ) ; // streams the second vector (array of 3 doubles) } //----------------------------------------------------------------------------------- void CAAGobForeignSurfaceData::UnStream(CATCGMStream & iStr) //----------------------------------------------------------------------------------- { iStr.ReadDouble( _uMin ) ; iStr.ReadDouble( _uMax ) ; iStr.ReadDouble( _vMin ) ; iStr.ReadDouble( _vMax ) ; iStr.ReadDouble( _Origin, 3 ) ; // unstreams the origin (array of 3 doubles) iStr.ReadDouble( _Height ) ; // unstreams the other values iStr.ReadDouble( _dU , 3 ) ; // unstreams the first vector (array of 3 doubles) iStr.ReadDouble( _dV , 3 ) ; // unstreams the second vector (array of 3 doubles) } |
The clone process [2] is managed by the CATCloneManager
,
that duplicates the CATIForeignSurface
instance. It remains to
provide the clone of the attribute, as below:
//--------------------------------------------------------------------------------------- CATForeignGeometryData* CAAGobForeignSurfaceData::Clone(CATCloneManager & iCloning) const //--------------------------------------------------------------------------------------- { // only duplicates the attribute. // The duplication of the CATIForeignSurface is made by the clone manager return new CAAGobForeignSurfaceData(CATMathPoint(_Origin), CATMathVector(_dU), CATMathVector(_dV), _Height, _uMin, _uMax, _vMin, _vMax) ; } |
The transformation process [2] is managed by
the CATTransfoManager,
that coaches the CATIForeignSurface
instance. It remains to provide the transformation of the parameters, as
below:
//------------------------------------------------------------------------------------ void CAAGobForeignSurfaceData::Move3D(CATTransfoManager & iTransfo) //------------------------------------------------------------------------------------ { // manages the attribute values. // The duplication of the CATIForeignSurface is made by the clone manager if ( FALSE == iTransfo.IsIdentity() ) // in case of a non-identity tranformation { CATMathTransformation* pMathTransfo = NULL; iTransfo.GetMathTransformation( pMathTransfo ) ; if ( NULL != pMathTransfo ) { double determinant = pMathTransfo->GetMatrix().Determinant() ; if ( determinant > 0. ) // only direct tranformations { CATMathVector Vector ; // Gets the value before the transformation // --> reads the values of _dU and affects them to Vector Vector.SetCoord(_dU) ; Vector = (*pMathTransfo) * Vector ; // Uses the operator for the math. transf. // Sets the value after the transformation // --> reads the values of Vector and affects them to _dU Vector.GetCoord(_dU) ; Vector.SetCoord(_dV) ; // Gets the value before the transformation Vector = (*pMathTransfo) * Vector ; Vector.GetCoord(_dV) ; // Sets the value after the transformation CATMathPoint Point ; Point.SetCoord(_Origin) ; // Gets the value before the transformation Point = (*pMathTransfo) * Point ; Point.GetCoord(_Origin) ; // Sets the value after the transformation // determinant is the scale factor of the transformation _Height /= determinant ; // Sets the height after the transformation } } } } |
The equations of a surface can be accessed thanks to the following CATSurface
methods, that must be called in this order:
CATSurface::Lock
: locks the surface modifications during
the edition of the equationsCATSurface::GetEquation
: retrieves the corresponding
mathematical equations.CATSurface::Unlock
: frees the surface.To perform the GetEquation
step, the CATIForeignSurface
needs to recover the mathematical equations of the foreign surface: this is
the goal of the CreateLocalEquation
method. The CATIForeignSurface
deletes the allocated equations when unlock the surface.
//-------------------------------------------------------------------------------- void CAAGobForeignSurfaceData::CreateLocalEquation( const long iPu, // useless, only one patch const long iPv, // useless, only one patch const CATMathFunctionXY* & oFx, const CATMathFunctionXY* & oFy, const CATMathFunctionXY* & oFz) //--------------------------------------------------------------------------------- { // Creates the mathematical equations relative to the egg box // S(u,v) = Origin + u*dU + v*dV + Height*cos(u)*cos(v)*dU^dV. oFx = new CAAAmtForeignFctXY(_dU[0],_dV[0], _Height*(_dU[1]*_dV[2]-_dU[2]*_dV[1]), _Origin[0]) ; oFy = new CAAAmtForeignFctXY(_dU[1],_dV[1], _Height*(_dU[2]*_dV[0]-_dU[0]*_dV[2]), _Origin[1]) ; oFz = new CAAAmtForeignFctXY(_dU[2],_dV[2], _Height*(_dU[0]*_dV[1]-_dU[1]*_dV[0]), _Origin[2]) ; } |
[Top]
This file defines the logical name (here CAAGobFS
) of the load
module containing the CAAGobForeignSurfaceData
definition, by the
mean of the AppDef
macro.
// GeometricObjects #include "AppDef.h" // to use in next line // CAAGobFS is the unique name identifying the application AppDef(CAAGobFS); |
The dictionary keeps track of the correspondance between the logical
application name and the physical load module libCAAGobForeig
n.
CAAGobFS CATICGMDomainBinder libCAAGobForeign |
[Top]
This use case demonstrates a concrete case of introduction of a new type of foreign surfaces.
[Top]
Version: 1 [Apr 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.