Editing Deuces

From BRL-CAD

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 119: Line 119:
 
 
 
 
  
 +
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 +
| style="padding: 20px;" |
 +
=== Debug and fix a bug converting cylinders ===
 +
 +
BRL-CAD has many 3D object types, one of them being a "Right Hyperbolic Cylinder".  If you run MGED with "mged -c cylinder.g", then run "make rhc rhc" on the mged> command prompt, it will create one.  If you then quit mged and run "dbupgrade -r cylinder.g" and reopen the file with "mged -c cylinder.g", the rhc object will be corrupted (try running "l rhc" in mged before and after).
 +
 +
This task's goal is to reproduce, identify, and fix the bug so that the rhc object doesn't get corrupted.  To do this, you'll want to use a debugger like lldb or gdb or Visual Studio (there are tutorials all over the web if you've never used a debugger), or simply use print statements.
 +
 +
See the rt_rhc_import5(), ..export5(), .._import4(), and .._export4() functions as they implement the read/write support.
 +
 +
Code:
 +
* src/librt/primitives/rhc/rhc.c, <- you'll probably need to modify this file
 +
* src/librt/primitives/table.c
 +
* include/rtgeom.h
 +
 +
&nbsp;
 +
|}
 +
&nbsp;
  
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
Line 148: Line 166:
 
Implement this function:
 
Implement this function:
  
     int estimate_volume(struct db_i *dbip,  
+
     int estimate_volume(struct db_i *dbip, struct directory *dp, size_t min_samples, double confidence);
                        struct directory *dp,
 
                        size_t min_samples,
 
                        double confidence);
 
  
For this function, you'll want to read up on some of BRL-CAD's basic data structures by looking at headers in the include/rt directory or by reading our [https://brlcad.org/docs/api/ API documentation].  Calling rt_db_internal() and rt_bound_internal() will get you the bounding box around geometry from which you can calculate a bounding sphere.  Once you have the bounding sphere, randomly generate a set of min_samples*2 points on the surface of the sphere.  Shoot a ray through those points using rt_shootray(), as in the ray tracing [[Example_Application|example]].  Keep track of a volume estimate and keep shooting sets of min_samples rays until the estimate is less than the specified confidence value.  Volume of a sphere is (4/3 * pi * r^3) so dividing that by num_samples will give a per-ray factor and multiplying all hit thicknesses by that factor will give a running volume estimate.
+
For this function, you'll want to read up on some of BRL-CAD's basic data structures by looking at headers in the include/rt directory or by reading our API documentation.  Calling rt_db_internal() and rt_bound_internal() will get you the bounding box around geometry from which you can calculate a bounding sphere.  Once you have the bounding sphere, randomly generate a set of min_samples*2 points on the surface of the sphere.  Shoot a ray through those points using rt_shootray(), as in the ray tracing [[Example_Application|example]].  Keep track of a volume estimate and keep shooting sets of min_samples rays until the estimate is less than the specified confidence value.  Volume of a sphere is (4/3 * pi * r^3) so dividing that by num_samples and multiplying all hit thicknesses by that factor is a preliminary method for calculating a running volume estimate.
  
 
References:
 
References:
Line 160: Line 175:
 
* https://stackoverflow.com/questions/9600801/evenly-distributing-n-points-on-a-sphere
 
* https://stackoverflow.com/questions/9600801/evenly-distributing-n-points-on-a-sphere
 
* https://karthikkaranth.me/blog/generating-random-points-in-a-sphere/
 
* https://karthikkaranth.me/blog/generating-random-points-in-a-sphere/
 
&nbsp;
 
|}
 
&nbsp;
 
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
| style="padding: 20px;" |
 
 
=== Implement a function to return an object's color ===
 
 
CAD geometry can have colors specified in a number of ways including directly on that object, in a parent object, and in a lookup table.  For this task, you're going to implement a function that reports the color of an object given a path to that object:
 
 
    int get_color(struct db_i *dbip, const char *path, struct bu_color *rgb);
 
 
You'll need to iteratively consider each object named on the specified path (e.g., "/car/wheel/tire.r/torus") starting with "car" and working your down the path (i.e., 'wheel', 'tire.r', and then 'torus') to 1) see if a color is set on that object and 2) see if that color overrides lower-level colors (i.e., is inherited down the path), and 3) if it's a region object, whether there is a color set in the region table.  You'll need to db_lookup() each object on the path to get access to its data.
 
 
For this function, you'll want to read up on some of BRL-CAD's basic data structures by looking at headers in the include/rt directory or by reading our [https://brlcad.org/docs/api/ API documentation].  This task may seem complicated if you're not familiar with C/C++ APIs, data structures, or hierarchical paths, so don't be shy [https://brlcad.zulipchat.com asking] questions.
 
 
References:
 
* https://brlcad.org/docs/api/
 
 
Code References:
 
* src/libged/display_list.c
 
* src/libged/color/color.c
 
* src/librt/prep.c
 
 
&nbsp;
 
|}
 
&nbsp;
 
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
| style="padding: 20px;" |
 
 
=== Stub in an OpenVDB object ===
 
 
BRL-CAD has dozens of distinct primitive object types.  For this task, you're going to implement the bare minimum to necessary to create a new object with the "make" command in MGED.
 
 
The best way to achieve this task is by searching for a keyword for another primitive (e.g., 'grep -r -i superell .') and implementing your new object the same way.  Start with the 'make' command itself in src/libged/make/make.c and add "vdb" alongside where you find one of the other primitive types (e.g., superell).  To get that to compile, you'll have to add new symbols you've defined into header files (e.g., include/rt/rtgeom.h).  You'll eventually need to implement barebones logic in src/librt/primitives/vdb too.
 
 
Code:
 
* include/rt/defines.h <- needs an ID
 
* include/rt/geom.h <- needs an "internal" i.e., in-memory structure
 
* src/libged/make/make.c <- needs to recognize "vdb" as a valid type
 
* src/librt/primitives/table.cpp <- needs an entry
 
* src/librt/primtiives/vdb <- needs a dir
 
* src/librt/primitives/vdb/vdb.c <- needs _import5/_export5 callbacks, maybe _describe too
 
  
 
&nbsp;
 
&nbsp;
Line 243: Line 212:
 
Reference:
 
Reference:
 
* Come [https://brlcad.zulipchat.com talk with us] to make sure you get a copy of the latest version.
 
* Come [https://brlcad.zulipchat.com talk with us] to make sure you get a copy of the latest version.
* https://brlcad.org/w/images/9/90/Intro_to_BRL-CAD.pdf
 
* https://brlcad.org/w/images/c/cf/Introduction_to_MGED.pdf
 
* ... there's another new one, but you have to ask for it ...
 
  
 
&nbsp;
 
&nbsp;
Line 253: Line 219:
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
| style="padding: 20px;" |
 
| style="padding: 20px;" |
 
 
=== Translate "Contributors Guide To BRL-CAD" To Any Language ===
 
=== Translate "Contributors Guide To BRL-CAD" To Any Language ===
  
Line 488: Line 453:
  
 
Building on the previous GCI task work, take it to the next step.  Try setting a vector to 1/3, 1/3, 1/3 and 0.1, 0.1, 0.1 and get proper values to print.  Change the V3ARGS() macro if needed.  If that all works, try to get bn_dist_pt3_pt3() to work.  Report and discuss your progress.
 
Building on the previous GCI task work, take it to the next step.  Try setting a vector to 1/3, 1/3, 1/3 and 0.1, 0.1, 0.1 and get proper values to print.  Change the V3ARGS() macro if needed.  If that all works, try to get bn_dist_pt3_pt3() to work.  Report and discuss your progress.
 
&nbsp;
 
|}
 
&nbsp;
 
 
{| style="background-color:#fefefe; border-style: solid; border-width: 4px;" width="100%"
 
| style="padding: 20px;" |
 
=== Upgrade OpenNURBS, report issues ===
 
 
BRL-CAD uses a customized OpenNURBS library for advanced geometry but it's out of date.  For this task, you're going to download the latest OpenNURBS code and upgrade the sources we bundle.  The easiest way is probably to move src/other/openNURBS to src/other/openNURBS.backup, and then put the latest OpenNURBS release into src/other/openNURBS.
 
 
Once that's done, you'll need to add the src/other/openNURBS.backup/CMakeLists.txt file and make sure the list of files it has matches the files in src/other/openNURBS.  Last but not least, re-run cmake and make sure it compiles.  You may need to consult the newer openNURBS makefile to see if there are other edits needed in the CMakeLists.txt file.
 
 
Save output from any commands you run because you'll probably encounter an error, and that's okay.  Just submit logs of all output so we can figure out next steps.
 
 
References:
 
* https://github.com/mcneel/opennurbs
 
 
Code:
 
* src/other/openNURBS <- replace existing with latest openNURBS from github
 
  
 
&nbsp;
 
&nbsp;

Please note that all contributions to BRL-CAD may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see BRL-CAD:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)