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 153: Line 171:
 
                         double confidence);
 
                         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 167: Line 185:
 
{| 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;" |
 
 
=== Implement a function to return an object's color ===
 
=== Implement a function to return an object's color ===
  
Line 176: Line 193:
 
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.
 
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.
+
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:
 
References:
Line 192: Line 209:
 
{| 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;" |
 
 
=== Stub in an OpenVDB object ===
 
=== Stub in an OpenVDB object ===
  
Line 243: Line 259:
 
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 266:
 
{| 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 ===
  

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)