Porting geometry to c++