Repository: FloatingArrayDesign/MoorDyn (language: python)

Issue:
Drop OpenGL utilities
I really think the OpenGL utilities, which are rather outdated and I suppose not used anymore, shall be removed


Discussion / hints:

Fix patch:
diff --git a/compile/DLL/makefile b/compile/DLL/makefile
index ba9dc9ed..70d9fdab 100644
--- a/compile/DLL/makefile
+++ b/compile/DLL/makefile
@@ -3,7 +3,6 @@
 #
 # Several options can be set:
 #
-#  - USEGL: Enables the OpenGL visualization
 #  - COPTS: Compilation options. For good performance and compatibility use:
 #           COPTS='-msse2 -ffast-math -DMOORDYN_SINGLEPRECISSION'
 #           However, for local-only installations a more aggresive instructions
@@ -24,11 +23,6 @@
 LFLAGS = -shared -static-libgcc -static-libstdc++ -DMoorDyn_EXPORTS -fPIC
 CFLAGS = -c -O3 -g -Wall -Wextra -DMoorDyn_EXPORTS -fPIC -I../../source/
 
-ifdef USEGL
-CFLAGS += -DUSEGL
-LFLAGS += -lopengl32 -lglu32
-endif
-
 CFLAGS += $(COPTS)
 LFLAGS += $(LOPTS)
 
diff --git a/compile/DYLIB/makefile b/compile/DYLIB/makefile
index 9634c9bd..da4df230 100644
--- a/compile/DYLIB/makefile
+++ b/compile/DYLIB/makefile
@@ -3,7 +3,6 @@
 #
 # Several options can be set:
 #
-#  - USEGL: Enables the OpenGL visualization
 #  - COPTS: Compilation options. For good performance and compatibility use:
 #           COPTS='-msse2 -ffast-math -DMOORDYN_SINGLEPRECISSION'
 #           However, for local-only installations a more aggresive instructions
@@ -29,11 +28,6 @@
 LFLAGS = -shared -DOSX -DMoorDyn_EXPORTS -fPIC
 CFLAGS = -c -O3 -static -g -Wall -Wextra -DOSX -DMoorDyn_EXPORTS -fPIC -I../../source/
 
-ifdef USEGL
-CFLAGS += -DUSEGL
-LFLAGS += -lopengl32 -lglu32
-endif
-
 CFLAGS += $(COPTS)
 LFLAGS += $(LOPTS)
 
diff --git a/compile/SO/makefile b/compile/SO/makefile
index 68329ad9..d10d0c64 100644
--- a/compile/SO/makefile
+++ b/compile/SO/makefile
@@ -3,7 +3,6 @@
 #
 # Several options can be set:
 #
-#  - USEGL: Enables the OpenGL visualization
 #  - COPTS: Compilation options. For good performance and compatibility use:
 #           COPTS='-msse2 -ffast-math -DMOORDYN_SINGLEPRECISSION'
 #           However, for local-only installations a more aggresive instructions
@@ -25,11 +24,6 @@
 LFLAGS = -shared -static-libgcc -static-libstdc++ -DLINUX -DMoorDyn_EXPORTS -fPIC
 CFLAGS = -c -O3 -g -Wall -Wextra -DLINUX -DMoorDyn_EXPORTS -fPIC -I../../source/
 
-ifdef USEGL
-CFLAGS += -DUSEGL
-LFLAGS += -lopengl32 -lglu32
-endif
-
 CFLAGS += $(COPTS)
 LFLAGS += $(LOPTS)
 
diff --git a/source/Body.cpp b/source/Body.cpp
index 1f17c27f..43cb0879 100644
--- a/source/Body.cpp
+++ b/source/Body.cpp
@@ -770,16 +770,6 @@ Body::defaultVTK()
 }
 #endif
 
-// new function to draw instantaneous line positions in openGL context
-#ifdef USEGL
-void
-Body::drawGL(void)
-{
-	double radius = pow(BodyV / (4 / 3 * pi), 0.33333); // pointV
-	Sphere(r[0], r[1], r[2], radius);
-};
-#endif
-
 } // ::moordyn
 
 // =============================================================================
diff --git a/source/Body.hpp b/source/Body.hpp
index d7c5e3a0..9926ff9a 100644
--- a/source/Body.hpp
+++ b/source/Body.hpp
@@ -439,10 +439,6 @@ class Body final : public io::IO
 	void saveVTK(const char* filename) const;
 #endif
 
-#ifdef USEGL
-	void drawGL(void);
-#endif
-
   private:
 #ifdef USE_VTK
 	/// The 3D object that represents the body
diff --git a/source/Line.cpp b/source/Line.cpp
index 931f0855..7e57793e 100644
--- a/source/Line.cpp
+++ b/source/Line.cpp
@@ -1537,85 +1537,6 @@ Line::saveVTK(const char* filename) const
 }
 #endif
 
-// new function to draw instantaneous line positions in openGL context
-#ifdef USEGL
-void
-Line::drawGL(void)
-{
-	double maxTen = 0.0;
-	double normTen;
-	double rgb[3];
-	for (int i = 0; i <= N; i++) {
-		const double newTen = ((i == 0) || (i == N)) ?
-			getNodeForce(i).norm() :
-			getNodeTen(i).norm();
-		if (newTen > maxTen)
-			maxTen = newTen;
-	}
-
-	glColor3f(0.5, 0.5, 1.0);
-	glBegin(GL_LINE_STRIP);
-	for (int i = 0; i <= N; i++) {
-		glVertex3d(r[i][0], r[i][1], r[i][2]);
-		if (i < N) {
-			const double normTen = (((i == 0) || (i == N)) ?
-				getNodeForce(i).norm() :
-				getNodeTen(i).norm()) / maxTen;
-			ColorMap(normTen, rgb);
-			glColor3d(rgb[0], rgb[1], rgb[2]);
-		}
-	}
-	glEnd();
-};
-
-void
-Line::drawGL2(void)
-{
-	double maxTen = 0.0;
-	double normTen;
-	double rgb[3];
-	for (int i = 0; i <= N; i++) {
-		const double newTen = ((i == 0) || (i == N)) ?
-			getNodeForce(i).norm() :
-			(0.5 * (T[i] + T[i - 1])).norm();
-		if (newTen > maxTen)
-			maxTen = newTen;
-	}
-
-	// line
-	for (unsigned int i = 0; i < N; i++) {
-		const double normTen = 0.2 + 0.8 * pow((((i == 0) || (i == N)) ?
-			getNodeForce(i).norm() :
-			getNodeTen(i).norm()) / maxTen, 4.0);
-		ColorMap(normTen, rgb);
-		glColor3d(rgb[0], rgb[1], rgb[2]);
-
-		Cylinder(r[i][0],
-		         r[i][1],
-		         r[i][2],
-		         r[i + 1][0],
-		         r[i + 1][1],
-		         r[i + 1][2],
-		         27,
-		         0.5);
-	}
-	// velocity vectors
-	for (int i = 0; i <= N; i++) {
-		glColor3d(0.0, 0.2, 0.8);
-		double vscal = 5.0;
-
-		Arrow(r[i][0],
-		      r[i][1],
-		      r[i][2],
-		      vscal * rd[i][0],
-		      vscal * rd[i][1],
-		      vscal * rd[i][2],
-		      0.1,
-		      0.7);
-	}
-};
-#endif
-
 } // ::moordyn
 
 // =============================================================================
diff --git a/source/Line.hpp b/source/Line.hpp
index 016b88fc..770a97d6 100644
--- a/source/Line.hpp
+++ b/source/Line.hpp
@@ -905,11 +905,6 @@ class Line final : public io::IO
 	 */
 	void saveVTK(const char* filename) const;
 #endif
-
-#ifdef USEGL
-	void drawGL(void);
-	void drawGL2(void);
-#endif
 };
 
 } // ::moordyn
diff --git a/source/Misc.hpp b/source/Misc.hpp
index 759c77a4..3912ad1c 100644
--- a/source/Misc.hpp
+++ b/source/Misc.hpp
@@ -49,11 +49,6 @@
 #include <memory>
 #include <limits>
 
-// #ifdef USEGL
-//  #include <GL/gl.h>  // for openGL drawing option
-//  #include <GL/glu.h> // used in arrow function
-// #endif
-
 #ifdef OSX
 #include <sys/uio.h>
 #elif defined WIN32
diff --git a/source/MoorDyn.cpp b/source/MoorDyn.cpp
index 0aeba708..224c7610 100644
--- a/source/MoorDyn.cpp
+++ b/source/MoorDyn.cpp
@@ -281,11 +281,3 @@ GetNodePos(int LineNum, int NodeNum, double pos[3])
 	auto line = MoorDyn_GetLine(md_singleton, LineNum);
 	return MoorDyn_GetLineNodePos(line, NodeNum, pos);
 }
-
-int DECLDIR
-DrawWithGL()
-{
-	if (!md_singleton)
-		return MOORDYN_MEM_ERROR;
-	return MoorDyn_DrawWithGL(md_singleton);
-}
diff --git a/source/MoorDyn.h b/source/MoorDyn.h
index ccf0b0e9..02f96c26 100644
--- a/source/MoorDyn.h
+++ b/source/MoorDyn.h
@@ -142,8 +142,6 @@ extern "C"
 	int DECLDIR GetPointForce(int l, double force[3]);
 	int DECLDIR GetNodePos(int LineNum, int NodeNum, double pos[3]);
 
-	int DECLDIR DrawWithGL(void);
-
 	int AllOutput(double, double);
 
 	/**
diff --git a/source/MoorDyn2.cpp b/source/MoorDyn2.cpp
index 8e82c3b1..61339699 100644
--- a/source/MoorDyn2.cpp
+++ b/source/MoorDyn2.cpp
@@ -2593,22 +2593,6 @@ MoorDyn_Load(MoorDyn system, const char* filepath)
 	return err;
 }
 
-int DECLDIR
-MoorDyn_DrawWithGL(MoorDyn system)
-{
-	CHECK_SYSTEM(system);
-
-#ifdef USEGL
-	// draw the mooring system with OpenGL commands (assuming a GL context has
-	// been created by the calling program)
-	for (auto line : ((moordyn::MoorDyn*)system)->GetLines())
-		line->drawGL2();
-	for (auto point : ((moordyn::MoorDyn*)system)->GetPoints())
-		point->drawGL();
-#endif
-	return MOORDYN_SUCCESS;
-}
-
 int DECLDIR
 MoorDyn_SaveVTK(MoorDyn system, const char* filename)
 {
diff --git a/source/MoorDyn2.h b/source/MoorDyn2.h
index a46109ff..c51deaaa 100644
--- a/source/MoorDyn2.h
+++ b/source/MoorDyn2.h
@@ -470,16 +470,6 @@ extern "C"
 	 */
 	int DECLDIR MoorDyn_Load(MoorDyn system, const char* filepath);
 
-	/** @brief Draw the lines and points in the active OpenGL context
-	 *
-	 * The OpenGL context is assumed to be created by the caller before calling
-	 * this function
-	 * @param system The Moordyn system
-	 * @return MOORDYN_SUCESS If the data is correctly set, an error code
-	 * otherwise (see @ref moordyn_errors)
-	 */
-	int DECLDIR MoorDyn_DrawWithGL(MoorDyn system);
-
 	/** @brief Save the whole system to a VTK (.vtm) file
 	 *
 	 * In general it is more convenient to handle each object independently,
diff --git a/source/Point.cpp b/source/Point.cpp
index 62eb26f3..4e97064b 100644
--- a/source/Point.cpp
+++ b/source/Point.cpp
@@ -471,16 +471,6 @@ Point::saveVTK(const char* filename) const
 }
 #endif
 
-// new function to draw instantaneous line positions in openGL context
-#ifdef USEGL
-void
-Point::drawGL(void)
-{
-	double radius = pow(pointV / (4 / 3 * pi), 0.33333); // pointV
-	Sphere(r[0], r[1], r[2], radius);
-};
-#endif
-
 } // ::moordyn
 
 // =============================================================================
diff --git a/source/Point.hpp b/source/Point.hpp
index 8882d872..fb7ff43b 100644
--- a/source/Point.hpp
+++ b/source/Point.hpp
@@ -418,10 +418,6 @@ class Point final : public io::IO
 	 */
 	void saveVTK(const char* filename) const;
 #endif
-
-#ifdef USEGL
-	void drawGL(void);
-#endif
 };
 
 } // ::moordyn
diff --git a/source/Rod.cpp b/source/Rod.cpp
index 2cafc7b6..6ea1724c 100644
--- a/source/Rod.cpp
+++ b/source/Rod.cpp
@@ -1571,77 +1571,6 @@ Rod::saveVTK(const char* filename) const
 }
 #endif
 
-// new function to draw instantaneous line positions in openGL context
-#ifdef USEGL
-void
-Rod::drawGL(void)
-{
-	double maxTen = 0.0;
-	double normTen;
-	double rgb[3];
-	for (int i = 0; i <= N; i++) {
-		double newTen = getNodeTen(i);
-		if (newTen > maxTen)
-			maxTen = newTen;
-	}
-
-	glColor3f(0.5, 0.5, 1.0);
-	glBegin(GL_LINE_STRIP);
-	for (int i = 0; i <= N; i++) {
-		glVertex3d(r[i][0], r[i][1], r[i][2]);
-		if (i < N) {
-			normTen = getNodeTen(i) / maxTen;
-			ColorMap(normTen, rgb);
-			glColor3d(rgb[0], rgb[1], rgb[2]);
-		}
-	}
-	glEnd();
-};
-
-void
-Rod::drawGL2(void)
-{
-	double maxTen = 0.0;
-	double normTen;
-	double rgb[3];
-	for (int i = 0; i <= N; i++) {
-		double newTen = getNodeTen(i);
-		if (newTen > maxTen)
-			maxTen = newTen;
-	}
-
-	// line
-	for (int i = 0; i < N; i++) {
-		normTen = 0.2 + 0.8 * pow(getNodeTen(i) / maxTen, 4.0);
-		ColorMap(normTen, rgb);
-		glColor3d(rgb[0], rgb[1], rgb[2]);
-
-		Cylinder(r[i][0],
-		         r[i][1],
-		         r[i][2],
-		         r[i + 1][0],
-		         r[i + 1][1],
-		         r[i + 1][2],
-		         27,
-		         0.5);
-	}
-	// velocity vectors
-	for (int i = 0; i <= N; i++) {
-		glColor3d(0.0, 0.2, 0.8);
-		double vscal = 5.0;
-
-		Arrow(r[i][0],
-		      r[i][1],
-		      r[i][2],
-		      vscal * rd[i][0],
-		      vscal * rd[i][1],
-		      vscal * rd[i][2],
-		      0.1,
-		      0.7);
-	}
-};
-#endif
-
 } // ::moordyn
 
 // =============================================================================
diff --git a/source/Rod.hpp b/source/Rod.hpp
index 683e6812..af2c277a 100644
--- a/source/Rod.hpp
+++ b/source/Rod.hpp
@@ -579,11 +579,6 @@ class Rod final : public io::IO
 	 */
 	void saveVTK(const char* filename) const;
 #endif
-
-#ifdef USEGL
-	void drawGL(void);
-	void drawGL2(void);
-#endif
 };
 
 } // ::moordyn
diff --git a/wrappers/rust/bindings.rs b/wrappers/rust/bindings.rs
index 57344470..f26e181e 100644
--- a/wrappers/rust/bindings.rs
+++ b/wrappers/rust/bindings.rs
@@ -399,7 +399,3 @@ extern "C" {
         filepath: *const ::std::os::raw::c_char,
     ) -> ::std::os::raw::c_int;
 }
-extern "C" {
-    #[doc = " @brief Draw the lines and points in the active OpenGL context\n\n The OpenGL context is assumed to be created by the caller before calling\n this function\n @param system The Moordyn system\n @return MOORDYN_SUCESS If the data is correctly set, an error code\n otherwise (see @ref moordyn_errors)"]
-    pub fn MoorDyn_DrawWithGL(system: MoorDyn) -> ::std::os::raw::c_int;
-}


Test patch:
diff --git a/tests/c_api.c b/tests/c_api.c
index c55e4597..1122b3f3 100644
--- a/tests/c_api.c
+++ b/tests/c_api.c
@@ -88,11 +88,6 @@ main(int narg, char** arg)
 		printf("GetNodePos() test failed...");
 		return 255;
 	}
-	ret_code = DrawWithGL();
-	if (ret_code != MOORDYN_MEM_ERROR) {
-		printf("DrawWithGL() test failed...");
-		return 255;
-	}
 
 	// MoorDyn2.h
 	MoorDyn system = MoorDyn_Create("nofile");
@@ -250,11 +245,6 @@ main(int narg, char** arg)
 		printf("MoorDyn_Load() test failed...");
 		return 255;
 	}
-	ret_code = MoorDyn_DrawWithGL(NULL);
-	if (ret_code != MOORDYN_INVALID_VALUE) {
-		printf("MoorDyn_DrawWithGL() test failed...");
-		return 255;
-	}
 	ret_code = MoorDyn_SaveVTK(NULL, "nofile");
 	if (ret_code != MOORDYN_INVALID_VALUE && ret_code != MOORDYN_NON_IMPLEMENTED) {
 		printf("MoorDyn_SaveVTK() test failed...");