| GSNLib Tutorial | ![]() |
Contents
Tutorial OverviewThe Tutorial is designed as a set of exercises for the programmer to either work through or browse. Once they have completed this tutorial, they should understand the basics. This tutorial assumes a basic knowledge of the C++ language and some understanding of NURBS curves and surfaces. All of the source code in this tutorial is working code which can be found in the "prog_test\GSNLib_tutorial.cpp" file. Linear Algebra TutorialThis section of the tutorial gives you some of the basics of how to utilize the linear algebra objects. The linear algebra classes can be thought of as the basic building blocks of GSNLib. We have attempted to make them as efficient as possible both in terms of memory usage and performance. The linear algebra classes are top level classes (i.e. they do not inherit from any other objects). In general, these classes are either declared on the stack or as part of a more complex object. Although it is possible, it is recommended that they not be created on heap (i.e. via new). They have no special memory management system and will directly invoke the default system new and delete to handle their memory. Much of the implementation of the methods of the linear algebra classes is done using inline methods to enable maximum performance. Points and VectorsThere are two actual classes (IwVector2d), IwVector3d), and two symbolic classes (IwPoint2d), IwPoint3d). In other words, a IwPoint2d does not actually exist; it is just another name for a IwVector2d. The point classes are just #define equivalents to the vector classes. The symbolic point classes exist primarily to clarify documentation. Nearly all of the vector methods are implemented as inline methods. The vector classes also provide a reasonable set of math operator overloading to help simplify and clarify the vector operations. 2D vectors and points are often used in conjunction with surface parameter space, where the "X" component of the vector maps to the "U" parameter of the surface and "Y" maps to the "V" parameter. See the Source code for iwtutorial_IwVector3d()
ExtentsThere are four extent classes: IwExtent1d, IwExtent2d, IwExtent3d, and IwExtentNd. Extent classes define a domain of the corresponding dimension by specifying the minimum and maximum values for the range of the domain. IwExtent1d defines a one-dimensional domain on the real line. IwExtent2d defines a two-dimensional domain in the real plane. IwExtent3d defines a three-dimensional domain in three space. IwExtentNd defines an N-dimensional domain in N-Space. IwExtent1d is often used to define the parameter interval of a curve. IwExtent2d is often used to define the domain of the parameters of a surface. IwExtent3d is often used to define a three-dimensional axis-aligned bounding box. IwExtentNd is used primarily as the domain representation to limit parameters for solving N-dimensional equations.
Pseudo-BoxA Pseudo-Box, IwPseudoBox, is a non-axis aligned bounding volume. In many cases it can provide a much tighter bound on curves and surfaces than the IwExtent3d object. See the Source code for iwtutorial_IwPseudoBox()
Axis PlacementThe Axis Placement, IwAxis2Placement, defines a local coordinate system. It contains a point representing the origin of the new coordinate system and two vectors representing the new X and Y axes of the new coordinate system. It is derived from the STEP representation of the equivalent name with the exception that the X and Y axes must be orthogonal. The IwAxis2Placement is used primarily to represent transformations from one coordinate system to another. See the Source code for iwtutorial_IwAxis2Placement()
Container Tutorial
Curve Tutorial
See the Source code for iwtutorial_Curve()
Surface TutorialThe two primary surface classes of interest to the users are IwBSplineSurface and its abstract superclass IwSurface The other surface class (IwCurveBoundedSurface) is used for internal computation and is not currently part of the public interface of GSNLib. The >IwBSplineSurface is the class which represents a NURBS surface. It provides a method interface for creation, query and editing of the NURBS representation. The IwBSplineSurface class also contains implementations for abstract IwSurface methods. The IwSurface class contains the method interface for most of the numerical algorithms
Local Solver TutorialThis portion of the tutorial is for advanced users who wish to programatically extend the Local Solver functionality of GSNLib to suit their particular application. GSNLib provides a class interface for determining solutions to one-dimensional functions (IwLocalSolve1d) and N-dimensional functions (IwLocalSolveNd). A majority of the local solving is done utilizing Newton-based itteration. All of the "Local" methods on curves and surfaces invoke one of these solvers. One can create new solvers by providing new function evaluators. This can be done by subclassing the corresponding evaluator object (IwEvalFunctionObject, IwEvalNFunctionsObject). The evaluators must be able to evaluate the function/functions and supply its derivative/Jacobian. If you are unable to compute the Jacobian matrix for the function you are solving, there are publicly available methods for computing solutions to equations which compute their own Jacobian (see Numerical Recipes in C). The basic procedure for creating a new local N-dimensional solver is as follows:
The following example demonstrates the creation of a local solver which normalizes two curves:
Global Solver TutorialThis portion of the tutorial is for advanced users who wish to programatically extend the global solver functionality of GSNLib to suit their particular application. The Global Solver is a customizable search engine. It searches one or more binary trees (IwTree) with bounding boxes on the nodes. There are several search criterion which are already implemented, minimization, maximization, intersection, and at distance. By default the global solver (IwGlobalSolver) will return pointers to the nodes which satisfy the search criterion. Typically you will want to subclass IwGlobalSolver to specialize one or more of the following:
Depending upon what you want to do and how, the details of how to implement these methods can vary greatly. We suggest that you attempt to familiarize yourself with the global solver implementations done in IwCurve.cpp and IwSurface.cpp prior to attempting an implementation. User Defined Curve/Surface TutorialThis portion of the tutorial is for advanced users who wish to programmatically extend the geometry classes by adding a user defined curve or surface. There are two levels of functionality that may be achieved when adding a new curve or surface; Local Solver support and Global Solver support. To achieve support sufficient to execute all of the Local Solver operations it is sufficient to implement only three methods other then the constructor and destructor. These methods are as follows:
The following example shows what is needed to define a new curve type:
In order to extend the curve/surface to support the Global Solver algorithms, they need to support the curve/surface cache creation. This could be accomplished by implementing a number of the methods and rewriting the existing tessellation routines. However, this would be quite difficult. The best way is to create a corresponding NURBS representation and create the cache using the IwBSplineCurve/IwBSplineSurface objects. Ideally you should create an exact NURBS representation of the curve/surface. If this is not possible, you can create an approximation. If you create an approximation, make sure that the approximation tolerance is sufficiently tight and then refine the resulting answers using one of the local solver algorithms and the original geometry. Note that the approximation tolerance should be at least 10 times smaller than the 3D tolerance utilized by the global solver operations. Legal StuffAll of the software and documentation received with this release is copyrighted by Solid Modeling Solutions, Inc. You may not distribute source code or documentation for this software outside of the company and the site which owns the license. The standard license agreement allows you to freely distribute object code in any application which does not contain a programmatic interface. All software and documentation is considered proprietary information and the intellectual property of Solid Modeling Solutions, Inc. This document contains trade secret information which is deemed proprietary.Copyright © 1998-2010 Solid Modeling Solutions
All rights reserved. |
|