Major Classes
The following are the major classes that are used in the
implemenattion of the CSG Applet.
- CSG
This is the main class for the program which extends the Applet and
inherits from the Thread class. This class instantiates the
csgCanvas class and also the csgUI class. All the
functions of initializaton and running of the applet is controlled by this
class. It has the init() method which initializes the whole
applet and also implements the run() method which is the heart of the applet.
- csgCanvas
This class extends Canvas class and is the area where the actual image is
drawn. It stores all the objects currently present on the screen
alongwith their relevant scale, rotate and translate values. It takes
care of updates made to the objects and re-draws them accordingly.
- csgUI
The csgUI class extends the Panel class and instantiates the
TitleSlider. It acts as a container for all the userinterface
controls so that we could use it in the CSG class. It defines
the Layout manager and initializes the User Interface Components. We
use a gridbag layout for placing the various components within the
panel to get more control in placing the components. It handles all
the user inputs such as entering of values or mouse movements.
- Solid
This basically represents a particular solid and forms the root node
of an instance of the HalfEdge data structure. It gives access to the
faces, edges and vertices of the solid by instantiating the Face,
Edge, Vertex and Box classes as describes in the theory section.
- ObjDetails
This class maintains information about the vertices of each of the
solids placed on the screen. It contains auxiliary information about
the scale, rotate and translation values of each of these solids.
- Tree
This class is used to maintain the CSG Tree.
- Tag
This class stores the Tag information required about each surface of a
Solid.
- Vectors
This class implements Vectors and all the operations such as cross and
dot product on these vectors.
- Mat
The Mat class has the various methods like matrix translation,
scaling, rotation about an axis. We use the above methods extensively
to transorm our image in world space to image in screen space.
- Stack
This class implements a stack and related functionality like push and
pop. It is used in the conversion of the infix CSG string to prefix.
- TitleSlider
This class extends the Panel class and has a Label and a TextField,
We can set the initial value needed of the TitleSlider from the constructor
along with the name.
- FileFormatException
This class is basically a Error Handling class that does not have much
functionality. It extends exception class and prints out the error to the
standard error which would be helpful in the debugging process.
The source files of these classes and more can be downloaded fom here.
And here is the applet that
made use of the above classes to implement CSG operations.