The starting point program is very simple. It contains the following files:
sweeper.C
computecurve.[C,h]
curve.[C,h]
Curve
class. The
Curve
class is a simple C++ class which is responsible
for displaying and editing a curve. When the curve is modified
(when a user moves or adds control points, for example), the curve
object calls ComputeCurve
to generate the line segments
needed for display.
The only modification you should have to do in this file is to add
names for new curve types.
surface.[C,h]
Surface
class. The
Surface
class is also a C++ class, and it acts in much
the same way, calling the function ComputeMesh
when it
is modified.
The only modification you should have to do in this file is to add
names for new transport types.
menus.[C,h]
VecArray.[C,h]
VecArray
, and a 2-D array called Mesh
. Your code
will stick the curve and surface points that you compute into these type
of arrays to pass back to the Curve
and Surface
objects. You may want to add functions to this file to make manipulations
of the arrays more convenient. For example, adding a function that removes
the last element of a VecArray is very useful.
/usr/include/Inventor
.
SbVec3f
(a 3-element vector), has all the vector
algebra operators already defined for it, so you can type vector equations in your
code much like you see in class.
Here are the standard operators in vector algebra:
Suppose v and w vectors, so
v = [vx,
vy,
vz]
and
w = [wx,
wy,
wz]
and
s
is a scalar.
Then, the following operations are defined:
v+w =
[vx+wx,
vy+wy,
vz+wz]
v-w =
[vx-wx,
vy-wy,
vz-wz]
s*v =
[s*vx,
s*vy,
s*vz]
v/s =
[vx/s,
vy/s,
vz/s]
v.dot(w) =
vx*wx +
vy*wy +
vz*wz
v.cross(w) =
[vy*wz -
vz*wy,
vz*wx -
vx*wz,
vx*wy -
vy*w]
man SbVec3f
. You might also want to
man sbMatrix
)
for( int i = 0; i < 10; i++ );
This allows you to do things like:
SbVec3f a, b, c; c = a.cross(b); /* c is set to cross product of a and b */The function
cross
is an element of the SbVec3f class.
When a function is included
as part of a class, it is referred to as a method.Another handy feature of classes are overloaded operators. The most common use of these is to define arithmetic functions (+,-,/,*):
SbVec3f a, b, c; c = a + b; /* c is set to be the vector addition of a and b */