C# Geometry Engine Base Class

C# Geometry Engine Base Classes

Just a quick side note, I’m not a classically trained developer, so there maybe some mistakes in here, so be kind, and hopefully I can learn from you as much as you can learn from me.

So, we’re going to start of with a geometry base class for our geometry engine. So let’s start out in visual studio with a Solution, Projects(.Net Core Class Library’s), Classes and a .Net Core Console Project.

Many of these are just going to be placeholders, for this post and in future posts well concentrate on other areas.

Let’s start of with the Solution, Projects and Folders.

Solution Setup

Next, the Geometry Core Abstract Class and it’s Interface.

IGeometryBase and GeometryBase

The Interface for now wont have anything but later on we will add some additional content.

C#

The Abstract object will inherit the System Object class and implement the Geometry Base Interface. All of our geometry objects will have a UUID, Name and Color. Also notice we will ensure that each derived class will override Equals and GetHashCode, these are really useful.

C#

Next well setup the Wireframe Base Interfaces

Wireframe Base Interfaces

Again these will be stubbed out and later on we’ll add more content. Since we are using interfaces, we want to include the two methods for Equals and GetHashCode also.

C#
C#
C#
C#
C#

Now we will start to define the guts of the Wireframe Base Classes.

Wireframe Base Classes

These base classes will support all of the wireframe types later on such as point by coordinates or point on plane will use point base class. To allow the project to build we will just stub out the two methods for Equals and GetHashCode, with some simple code.

C#
C#
C#

Finally we can create the PointByCoordinates Interface and Class.

Geometry Types Interfaces and Classes

The interface for PointByCoordinates will have any additional property’s and methods required for this specific point type.

C#

In the PointByCoordinates class well create the logic for this class.

C#

Finally, we want to create the factory’s that the end user will see.

IFactoryBase and FactoryBase Interface and Class

This Interface and Abstract Class are empty for now, but we will come back to them later on.

C#
C#

The specific WireframeFactory will contain all the constructors for all of our different geometry types.

IWireframeFactory and WireframeFactory Interface and Class

Ok, we should be at the top of the code stack now, at the factory level that will be exposed for our end users. Everything up till now is stubbed out with no error handling, I just wanted to show you the rough layout and how it will work from the end users perspective, with two simple functions for creating points.

So first the interface for the factory, with our two method descriptions.

C#

And the class implementation with our two methods.

C#

So now we can get to the use case.

Test Application Point By Coordinates
C#

We can now see all of the Functions, Methods, and Property’s for our PointByCoordinates object.

Point By Coordinates Property’s Methods and Functions

At run time we can also see some of the additional property’s from the abstract classes.

Point by Coordinates Runtime Object