Skip to content

Commit

Permalink
Docs added
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulranjansah committed Jan 17, 2025
1 parent e7d82c7 commit ffe5b19
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 107 deletions.
88 changes: 0 additions & 88 deletions contrib/render/README.html

This file was deleted.

33 changes: 33 additions & 0 deletions contrib/render/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../../'))

project = '3D Render'
author = 'Rahul R. Sah'
release = '0.1'

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx_rtd_theme',
'myst_parser',
]

templates_path = ['_templates']
exclude_patterns = []

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

myst_enable_extensions = [
"colon_fence",
"deflist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"substitution",
"tasklist",
]
7 changes: 7 additions & 0 deletions contrib/render/docs/source/data_loader.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Data Loader Module
==================

.. automodule:: render.data_loader
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions contrib/render/docs/source/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Example Render Module
==================

.. automodule:: example_render
:members:
:undoc-members:
:show-inheritance:
25 changes: 25 additions & 0 deletions contrib/render/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. Project documentation master file, created by
sphinx-quickstart on Thu Jan 16 07:16:25 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
3D Asteroid Rendering documentation!
========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

scene
data_loader
example

.. include:: ../../README.md


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions contrib/render/docs/source/scene.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Scene Module
============

.. automodule:: render.scene
:members:
:undoc-members:
:show-inheritance:
35 changes: 29 additions & 6 deletions contrib/render/example_render.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University
[email protected].
"""
This module demonstrates how to render a 3D model using Vispy.
The module includes the following steps:
1. Load the 3D model data from a file.
2. Create a MainWindow instance.
3. Set the 3D model in the MainWindow.
4. Run the Vispy application.
Usage:
python example_render.py
"""

# How to render using this module
from vispy import app
from render.scene import MainWindow
from render.data_loader import load_data

vertices, faces = load_data("test_data/ROS_ST_K020_OSPCLAM_U_V1.OBJ")
main_w = MainWindow()
main_w.set_model(vertices, faces)
def main():
"""
Main function to render the 3D model.
This function performs the following steps:
1. Load the 3D model data from a file.
2. Create a MainWindow instance.
3. Set the 3D model in the MainWindow.
4. Run the Vispy application.
"""

vertices, faces = load_data("test_data/ROS_ST_K020_OSPCLAM_U_V1.OBJ")
main_w = MainWindow()
main_w.set_model(vertices, faces)
app.run()

app.run()
if __name__ == "__main__":
main()
11 changes: 9 additions & 2 deletions contrib/render/render/data_loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University
[email protected].
"""This module provides functionality to load 3D model data from a file.
The `load_data` function reads a file containing 3D model data, extracts the vertex and face
information, and returns them as numpy arrays. The file is expected to be in a specific format
where each line represents either a vertex or a face. Vertices are denoted by lines starting
with 'v' and faces by lines starting with 'f'.
The function uses pandas to read the file and process the data. The vertices and faces are
extracted based on their respective identifiers and returned as numpy arrays.
"""

import pandas as pd
Expand Down
19 changes: 8 additions & 11 deletions contrib/render/render/scene.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
"""@author: Rahul R. Sah, Physics and Computer Science Department, Furman University
[email protected].
"""
import numpy as np
from vispy import scene
from vispy import app
Expand All @@ -11,6 +8,11 @@ class MainWindow(scene.SceneCanvas):
"""
Main window for rendering 3D models using Vispy.
This class provides a graphical interface for rendering 3D models using the Vispy library.
It sets up a scene canvas with interactive capabilities, allowing users to visualize and
interact with 3D models. The canvas includes a grid layout and a view with a turntable
camera for easy manipulation of the 3D scene.
Parameters
----------
*args : tuple
Expand All @@ -28,6 +30,9 @@ def set_model(self, vertices, faces):
"""
Set the 3D model to be rendered.
This method takes arrays of vertices and faces, creates a mesh from them, and adds
the mesh to the view for rendering. The mesh is shaded smoothly and colored grey.
Parameters
----------
vertices : numpy.ndarray
Expand All @@ -39,11 +44,3 @@ def set_model(self, vertices, faces):
mesh = visuals.Mesh(meshdata=mesh_data, shading='smooth', color="grey")
self.view.add(mesh)

vertices = np.array([[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0]])

faces = np.array([[2, 2, 4]])
main_w = MainWindow()

main_w.set_model(vertices, faces)
app.run()
13 changes: 13 additions & 0 deletions contrib/render/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tox]
envlist = docs

[testenv:docs]
deps =
sphinx
sphinx_rtd_theme
myst-parser
pandas
numpy
vispy
commands =
sphinx-build -b html docs/source docs/build/html

0 comments on commit ffe5b19

Please sign in to comment.