Difference between revisions of "Geometry Viewer Application for BRL-CAD"

From BRL-CAD
(Interace .g file with librt)
(Adding Development Environment Setup for Consistency)
Line 31: Line 31:
  
 
; 1. Evaluate technology to be used
 
; 1. Evaluate technology to be used
* Develop initial project design draft
+
* <s>Develop initial project design draft</s> [DONE]
 
* Setup development environment
 
* Setup development environment
 +
 +
** ''' Installing BRLCAD:''' ([http://svn.code.sf.net/p/brlcad/code/brlcad/trunk/INSTALL '''Install Instructions'''])
 +
 +
:: '''System Specs:''' CentOS 7, Dual Core, 4G RAM, 40 G Storage
 +
 +
<source lang="bash">
 +
# Fetch the STABLE version of BRLCAD (7.24.4):
 +
svn checkout http://svn.code.sf.net/p/brlcad/code/brlcad/branches/STABLE/ brlcad-stable
 +
 +
cd brlcad-stable
 +
 +
mkdir brlcad-build
 +
 +
cd brlcad-build
 +
 +
cmake ../ -DBRLCAD_BUNDLED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -BRLCAD_ENABLE_STRICT=OFF
 +
 +
# Without enable strict we get an error: "array subscript is above array bounds" during make
 +
 +
make -j6
 +
 +
make install
 +
 +
vim ~/.bash_profile
 +
 +
# Add "/usr/brlcad/rel-7.24.4/bin" to PATH.
 +
 +
vim brlcad-7.24.4.conf
 +
 +
# Add "/usr/brlcad/rel-7.24.4/lib"
 +
 +
ldconfig
 +
 +
</source>
 +
 +
 
* Evaluate programming language choice (C decided, for GUI may use some Python)
 
* Evaluate programming language choice (C decided, for GUI may use some Python)
 
; 2. Evaluate and look into current viewer applications:
 
; 2. Evaluate and look into current viewer applications:

Revision as of 16:50, 21 June 2016

European Summer of Code 2016

Mentor: Christopher Sean Morrison

Student: Asad

This document lists down the design for the project. This includes the major milestones and deadlines. Prettier Version


Outline

The idea is to build a geometry viewer application that generates a standalone double-clickable file that views a given model. The approach is to concatenate the contents of a given “.g” file with the function calls from librt, libdm that parse and display a “.g” file, in a standard brlcad setup.

Our motivation is to introduce portability and ability to share results of brlcad via email with users who don’t have brlcad setup in their environments. First we will develop a standalone application but later this can be integrated into mged or any other tool as a brlcad feature.


Task Breakdown

The brlcad suite has many tools and libraries that interact with each other to render and view models. The general architecture is given below:

Figure 1. BRL-CAD data flow structure

The most important part for us out of this architecture is the geometry rendering libraries, to be more specific librt & libdm.

Librt, the library that contains all of the geometry support. It parses the “.g” file and its function calls can be used to extract contents of “g” file. We will use this to parse our model file for Libdm. The relevant function call is “db_open”. There is also possibility to use a higher level library “libged” (ged_open)

Libdm is BRL-CAD's primary graphics display manager (dm) library. It is used to display geometry in GUI. This will be utilized by our source to visualize model files.

This resulting draw result will then be bundled into an “.exe” (windows) and later into packages for Mac & Linux.

Task list

1. Evaluate technology to be used
  • Develop initial project design draft [DONE]
  • Setup development environment
System Specs: CentOS 7, Dual Core, 4G RAM, 40 G Storage

<source lang="bash">

  1. Fetch the STABLE version of BRLCAD (7.24.4):

svn checkout http://svn.code.sf.net/p/brlcad/code/brlcad/branches/STABLE/ brlcad-stable

cd brlcad-stable

mkdir brlcad-build

cd brlcad-build

cmake ../ -DBRLCAD_BUNDLED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -BRLCAD_ENABLE_STRICT=OFF

  1. Without enable strict we get an error: "array subscript is above array bounds" during make

make -j6

make install

vim ~/.bash_profile

  1. Add "/usr/brlcad/rel-7.24.4/bin" to PATH.

vim brlcad-7.24.4.conf

  1. Add "/usr/brlcad/rel-7.24.4/lib"

ldconfig

</source>


  • Evaluate programming language choice (C decided, for GUI may use some Python)
2. Evaluate and look into current viewer applications
  • Mged / archer
  • Isst, it doesn’t use libdm.
  • Geometry viewer [1]
3. Create application interface to brlcad libraries [2]
  • Interface with librt

Librt is used to open brlcad geometry files and edit them. It reads a .g file by calling the function db_open and populates a db_i structure . To view the geometry files we need Libdm which takes this db_i structure as input to do so.

This commit takes a .g file and calls the db_open function from within the viewer application. Right now it just prints out a single value from the populated structure.

An example is already available that shows the usage of db_open. We are utilizing the skeleton of this example to populate the struct db_i.

  • Interface with libdm
4. Create application interface with model file
  • Create input interface to parse “.g” file

We need to read the binary ".g" file and concatenate it with our program. The first step is to identify the .g files from their file header. Using the hexdump command it is confirmed that all " .g" files have first 40 bytes common. <source lang="bash"> hexdump -C build/share/db/wave.g | head 00000000 76 01 00 00 00 00 01 35 76 02 00 00 00 00 0a 00 |v......5v.......| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|

00000050 00 00 00 00 00 00 00 35 76 02 00 00 00 00 02 00 |.......5v.......| 00000060 00 00 00 00 00 00 00 35 76 20 00 20 01 04 1a 06 |.......5v . ....|


00000070 62 61 73 65 31 00 c0 40 82 c0 00 00 00 00 00 c0 |base1..@........| </source>


The commit, simply reads a file into a buffer and prints out its contents. Our interest is in the header bits of the file i.e., the bits that start with 7601...., these will help us identify the start of a ".g" file later.

  • Create output interface to parse output from libdm.
5. Develop front end
  • Develop Single window view
  • Develop File Input
6. Write Functional testing test cases.

Project Workflow

  • This design document will be updated regularly to include the status of tasks as well as any changes in project scope and/or approach.
  • The source will be uploaded on: [3]
  • There will also be occasional weekly status meetings on irc #brlcad (Fridays 16:00 GMT+2)


References

[4] [5] [6] [7] [8] [9] [10] [11] [12]