# Geometry

### Curves - SmCurve and SmBSplineCurve

The two primary curve classes of interest are SmBSplineCurve and its parent class SmCurve. The other curve classes (SmCrvOnSurf, SmCompositeCurve, SmOffsetCurve, SmHermiteCurve, SmIsoCurve) are for more specific uses or for internal or advanced use. The SmBSplineCurve class represents a NURBS curve. It provides a method interface for creation, modification, query, and eval of the NURBS representation. The SmCurve class contains the method interface for most of the numerical algorithms. Some common methods include:

- GetNaturalInterval() - returns the parametric domain of the curve.
- Evaluate() - evaluates the point and requested derivatives of the curve/surface.
- EvaluatePoint() - evaluates just the point of the curve/surface.

Figure 5: Curve Properties and Analysis

Figure 6: Curve Properties and Analysis continued

SmCurve

- point and derivative evaluation
- evaluation of geometric properties
- bounding box calculation
- creation of a mirror curve
- creation of a curve by projection to a plane
- transformation with optional scaling
- high precision curve length computation
- closure, periodicity and degeneracy testing
- tessellation using both chord height and angular tolerances
- find intersections with a plane
- find inflection points
- find minimum/maximum magnitude of 1st derivative and radius of curvature
- find 1st derivative or radius of curvature of a given magnitude
- find points where tangent is parallel to X, Y, and/or Z axis
- find points where tangent is parallel to a given vector
- find silhouette points with either parallel or perspective projection

SmBSplineCurve

- construction/modification/query/eval
- continuity calculation, removal of extra knots, conversion to 2D
- creation by joining connected curve segments
- creation of a circle segment, ellipse segment line segment, degenerate curve
- creation of mirror curve
- editing the end points of a B-Spline
- extraction of analytical information for lines and arcs
- curve offset

### Surfaces - SmSurface and SmBSplineSurface

The two primary surface classes are SmBSplineSurface and its parent class SmSurface. The other surface classes (SmOffsetSurface, SmCurveBoundedSurface, SmSrfInVolume, etc) are for more specific uses or for internal or advanced use.. The SmBSplineSurface is the class which represents a NURBS surface. It provides a method interface for creation, query and editing of the NURBS representation. The SmBSplineSurface class also contains implementations for abstract SmSurface methods. The SmSurface class contains the method interface for most of the numerical algorithms.

SmSurface

- point and derivative evaluation, evaluation of geometric properties
- normal evaluation, evaluation of a normal section
- high precision surface area computation
- dropping 3D vectors into parameter space
- closed and periodic testing, singularity testing
- validation
- transformation

SmBSplineSurface

- construction using STEP format or NLib data structures
- continuity calculation
- query
- creation of planar section curves - see Figure 14
- creation of parallel projection curves - see Figure 15

Figure 14: Creation of Planar Section Curves

Figure 15: Creation of Curves by Parallel Projection

### Trimmed Surfaces - SmFace

- SmBrep::CreateFaceFromSurface from a parametrically bounded NURBS surface.
- SmBrep::MakeFaceWithCurves from a surface and 2-D parameter space curves.
- From a surface and 3-D model space curves. Use SmBrep::MakeFaceWithCurves.
- From a surface with both 2-D and 3-D space curves. Use SmBrep::MakeFaceWithCurves.
- Creation of topological elements (vertices, edges, faces) using "Euler like" topological operators. See the tutorial on Solid Creation by Topology Tables.
- Adjustment of operational tolerances to compensate for gaps. See as an example SmEdge::SetTolerance.
- Sewing together trimmed surfaces to create shells or solids. Use SmBrep::SewFaces.

This section of the quick start is intended to help you to understand how to create trimmed surfaces such that the subsequent operations performed on them are very reliable. SMLib is designed to enable it to handle trimmed surfaces which are generated from a variety of different CAD and graphics systems. SMLib allows the creation of trimmed surfaces from either parameter space or model space curves. The operational tolerances can be adjusted to match those of the system which originally produced the trimmed surface.

An empty SmBrep is created which will eventually contain one or more trimmed surfaces. Prior to adding faces to the brep ( SmBrep::MakeFaceWithCurves )

The next major decision to make is what to use for trimming curves, 3-D model space curves or 2-D parameter space curves. In cases where only one set of trimming curves are available or one set is clearly the master representation your decision is not a difficult one. However if you have both sets of trimming curves and neither of them is the master representation, than you may have decisions to make. In this case is important to know what happens in each of your three options:

2-D Trimming Curves are used to create Trimmed Surfaces

- Approximate 3-D Curves are created using the mapping of the 2-D Curves through the surface.
- The 3-D Curves are approximated to within the SmBrep tolerance ( SmBrep::GetTolerance ) of the corresponding 2-D curves.
- The 3-D Curves are synchronized in terms of their parameter space and orientation.
- The 2-D Curves have their end points "joined" through a process which does extension and intersection.

3-D Trimming Curves are used to create Trimmed Surfaces

- 2-D curves are created using the SmSurface::DropCurve method.
- The tolerances of the corresponding edges are adjusted relative to the distance between the 3-D curve and its 2-D image.
- The 2-D Curves have their end points "joined" through a process which does extension and intersection.

Both 2-D and 3-D Curves are used to create Trimmed Surfaces

- The distance between the 3-D curve and the 3-D image of the 2-D curve is measured and an appropriate tolerance is chosen for the edge.
- The 2-D Curves have their end points "joined" through a process which does extension and intersection.

Of the three possibilities, #2 is by far the slowest and #3 is somewhat faster than #1. If you are doing primarily 2-D operations, #1 or #3 are probably a little better than #2. If you are doing primarily 3-D operations, #2 or #3 might give you some advantages. We have found that #1 seems to be the best option when we are reading and testing IGES trimmed surfaces generated by the RHINO NURBS Modeler.

### Trimmed Surface Creation

Creating correctly defined trimmed surfaces is essential. There are two different ways in which trimmed surfaces may be created. First you may create a trimmed surface (SmFace) directly from a surface and its parametric domain (SmBrep::CreateFaceFromSurface). You may also create a trimmed surface from the surface and a set of oriented boundary curves. This tutorial shows how this may be done. Our tutorial demonstrates the creation of a trimmed surface from class (SmCurveBoundedSurface) which mirrors the IGES trimmed surface structure. This code is actually used in our IGES processor to create trimmed surfaces. Note that this code allows you to add a trimmed surface to an already existing brep. It is possible to put multiple trimmed surfaces in a single brep. You need to first create a brep prior to invoking this method. The following code shows how you might set up a brep prior to calling the function:

__***Please refer to Example.cpp***__

Trimmed Surface/Point Solver Tutorial

The following code demonstrates the use of the SmTopologySolver to solve an operation between a brep and a point. This solver allows the user to find intersections (SM_SO_INTERSECT), minimum/maximum distance between the brep and the point (SM_SO_MINIMIZE/>SM_SO_MAXIMIZE), and points were the tangent plane of the trimmed surface is perpendicular to the vector to the point (SM_SO_NORMALIZE.

Trimmed Surface/Curve Solver Tutorial

The following code demonstrates the use of the SmTopologySolver to solve an operation between a brep and a curve. This solver allows the user to find intersections (SM_SO_INTERSECT, minimum/maximum distance between the brep and the curve (SM_SO_MINIMIZE SM_SO_MAXIMIZE), and points were the tangent plane of the trimmed surface and the tangent of the curve are perpendicular to the vector between the trimmed surface and the curve (SM_SO_NORMALIZE).

Trimmed Surface/Trimmed Surface Solver Tutorial

The following code demonstrates the use of the SmTopologySolver to solve an operation between two breps with trimmed surfaces. This solver allows the user to find the minimum/maximum distance between two breps with trimmed surfaces(SM_SO_MINIMIZE SM_SO_MAXIMIZE, and points were the tangent planes of the trimmed surfaces of each are perpendicular to the vector between the two trimmed surface (SM_SO_NORMALIZE).

Planar Sectioning Example

This tutorial demonstrates how to do planar sectioning of a brep with trimmed surfaces. It creates a set of planes which span the bounding box of the brep and uses them to section the brep.

Point Classification Example

This tutorial demonstrates the classification of a parameter space point on a surface relative to the surface boundary. The function creates a grid of points in the parameter space of the surface and classifies them.

Curve Classification Example

This tutorial demonstrates the classification of a 2D curve relative to the boundary of a trimmed surface. Please note that the method being demonstrated here also allows you to specify a 3D curve. The method will automatically choose the correct place to classify the curve based on its dimension.

### Analytical Classes

Analytic or exact representations of common curve or surface objects often provide faster results with more precision. The following classes have been implemented along with supporting methods for creation and evaluation.

- SmLine, SmEllipse, SmCircle, SmHyperbola, SmParabola
- SmPlane, SmCylinder, SmCone, SmSphere, SmTorus, SmSurfOfRevolution, SmSurfOfExtrusion

### Solids - SmBrep

The SmBrep class represents a collection of SmFaces. If the collection, one or more faces, form a closed, water tight object then the object is manifold. Otherwise the object is non manifold. In either case, the object can be merged (boolean) , filleted, offset, shelled, de-featured, sliced, etc. Some of the possible operations on SmBreps are:

__*****See SMLibBoolean.html, SMLibFilles.html, SMLibShell.html, etc*****__

A word about m_bEditingEnabled. We have added a flag to SmBrep which enables editing. There are many of the creation and a few editing operations which require the m_bEditingEnabled flag to be turned on. An example is sewing. This flag needs to be turned off to make many of the evaluation functions work.