Geometry Framework¶
The geometry framework provides a unified infrastructure for handling all 3D objects in the scene, including CAD models, scanned models, and fabrication instructions. This framework enables easy interaction between application layers and 3D objects while being tightly integrated with the rendering system, which implicitly manages OpenGL resources, simplifying the workload for application layers.
Usage of Geometry Framework¶
The geometry framework is defined in GOPrimitive.h
. The geometry is organized into the following primitive shapes: point, line, circle, cylinder, polyline, triangle, mesh, and text. Each of them is a class (e.g., GOPoint
, GOLine
, GOCircle
, etc.) that inherits the base class GOPrimitive
, where "GO" stands for Geometry Object. The base class manages general attributes and provides interfaces such as visibility and transformation, while the subclasses handle their specific data and functions.
Tip
The m_Id
would be generated automatically when a new GO
is initialized and is ensured to be unique in the system. m_Type
can be used to easily determine the sub-class while the object is held as a GOPrimitive
pointer. Draw()
and m_GLObjects
are used for rendering, which will be introduced in AR-rendering.
Tip
To initialize a GO
object, instead of calling the constructor, one must use the static function Add()
of the corresponding class to create an object. This is due to the design of the GORegistry
, which manages all GOs, ensuring them accessible across the system.
Creating a GO¶
The GO
needed to be initialized using Add()
function, which returns a std::shared_ptr<GO>
. For example, to create a point at the origin:
The only exception that you can create without using the Add()
function is GOPoint
, as they are used as parameters in other GO
s. For example, to create a GOLine
:
GOPoint p1 = GOPoint(0, 0, 0);
GOPoint p2 = GOPoint(1, 1, 1);
std::shared_ptr<GOLine> line = GOLine::Add(p1, p2);
GO Registry¶
The system maintains a global registry, GORegistry
, to keep track of all GOs. When the Add()
function of the GO
is called, it acquires a unique UUID(m_Id
) and registers itself in the global hash table. Since this table is accessible throughout the entire system, it maximize the accessbility of GOs.
Interact with GO Registry¶
To access the global registry, one can use the macro AIAC_GOREG
to get the instance. It provides two APIs to retrive GO(s): either getting one by its UUID or all objects registered in the system.
To retrieve a GO
by its id:
To get all GO
s in the registry: