Body Builder Previous page

Extending BodyBuilder

There are a several ways the user could enhance or customize BodyBuilder. A few are listed here.

Adding a new Primitive to list

There are currently 5 Primitive Shapes:

  • Brick,
  • Cone,
  • Cylinder,
  • Sphere, and
  • Torus.
  • The class definintion for each Primitive Shape is very similar. To introduce a new shape, it would be easiest to start from the class file for one of the existing Primitve Shapes. Customization then involves the following steps:

  • Modify the properties to represent the geometric measures of the new Primitive (e.g., radius, height).
  • Update PROPERTY_LIST and set() methods accordingly
  • Adjust calculations in get() methods for volume and moment_of_inertia_about_CG
  • Make sure the correct geometric classes are called in methods attach_primitive and attach_generator
  • Adding a new Material

    Custom Materials are easily added by hardcoding additional materials as part of the constructor method in BodyBuilder.m. Take a look at the code and you will see several materials created and added to the BodyBuilder's property "material," which is a cell array.

    Of course, a better solution would be a menu item that enables the user to define materials.

    Exporting VRML files

    There are classes available to do this, but we simply didn't get around to implementing. If interested, you could take it from where we left off. Check out the method cb_export2VRML_ActionPerformedCallback() in the svSupport.m file located in the private folder of the BodyBuilder class.

    Once you have something to try and wish to add a menu item that uses that callback, just uncomment the appropriate code (following the comment "Export to VRML") in the method create_menu_bar within BodyBuilder.m.

    Introducing Boolean Operations

    Three common Boolean operations are pictured below:

  • Union
  • Intersect
  • Subtract
  • In some cases such as when one shape is wholly within another or the intersecting surface between shapes is planar, Boolean operations are not too difficult to implement; however, by changing the types of shapes or relative orientation, the Boolean operations can quickly become difficult. (If it was easy, it would have been done in this release.) How do you handle operations requiring different material types? Good question.

    To visualize the three operations stated above, consider first this body consisting of two intersecting shapes, a red Brick and a blue Cylinder.

    Union

    The Union operation would return the universe of the two shapes minus any overlap.

    Intersect

    The Intersect operation can be considered the inverse of the Union operation, returning that volume shared by the two initial shapes

    Subtract

    The Subtract operation would return the first shape's volume minus the second shape's volume.

    Previous page   Understanding BodyBuilder