Sample Code


The following is a list of code samples available to HOOPS Visualize developers. These samples are short snippets that demonstrate a specific functional topic. The source code for each sample is distributed as part of the Visualize package. The sample sources are located at <hps_install_dir>/samples/code/. To run a specific sample, you must first build the samples project. Then, execute the program and specify the sample name on the command line. Optionally, you can provide a driver to use as well.
For example, to run the "bloom_silhouette" sample using the OpenGL2 driver:
hps_samples.exe -t bloom_silhouette -d OpenGL2

bloom_silhouette
bloom_silhouette.cpp
bloom_silhouette.cs
This sample shows the user how to:
See also: Programming Guide section 8.4 and section 8.9

complex_clip_regions
complex_clip_regions.cpp
complex_clip_regions.cs
This sample shows the user how to:
  • Create a grid and use a complex clip region to clip it
See also: Programming Guide section 3.5

conditional_styles_and_includes
conditional_styles_and_includes.cpp
conditional_styles_and_includes.cs
This sample shows the user how to:
  • Set styles only when certain conditions are met
  • Include geometry only when certain conditions are met
  • Create named styles
  • Build complex conditions using logical operators
See also: Programming Guide section 4.3

custom_event
custom_event.cpp
custom_event.cs
This sample shows the user how to:
  • Create a custom event
  • Create a custom event handler
  • Register an event
  • Get an event dispatcher and subscribe it to the custom event
  • Inject the custom event with a notifier
  • Wait for the event handling thread to terminate
See also: Programming Guide section 10.2

database_search
database_search.cpp
database_search.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Search the database for segments, shells, and vertices
  • Obtain a HPS::SearchResultsIterator object, and how to walk a search result list with the iterator
  • Inserting text through HPS::UTF8 objects
  • Setting a camera through a HPS::CameraKit object
See also: Programming Guide section 1.1

This sample shows the user how to:
  • Walk the component structure of a HPS::CADModel
  • Highlight a specific instance of a component
  • Highlight all instances of a component
  • Build a HPS::KeyPath
  • Define a named style used for highlighting
See also: Programming Guide section 1.2.1, section 6.4

This sample shows the user how to:
  • Import an Exchange file and check for exceptions
  • Traverse the component structure of a HPS::CADModel
  • Obtain a component from a selection event
  • Highlight a selected component
  • Define named styles and glyphs
See also: Programming Guide section 6.1, section 6.4, section 4.3, section 4.5

This sample shows the user how to:
  • Load an Exchange file and check for IO exceptions
  • Walk down a component structure
  • Verify the type of a component
  • Defining named styles
  • Highlighting PMIs and geometry referenced by a particular PMI component
  • Hide components using highlighting
  • Use a HPS::KeyPath to operate on a particular instance of geometry
See also: Programming Guide section 1.2.1, section 6.4

This sample shows the user how to:
  • Load an Exchange file through HPS::Exchange and check for Exchange IO exceptions
  • Output a 3D PDF file through HPS::Publish and check for Exchange IO exceptions
See also: Programming Guide section 9.6, section 9.5

hardcopy_export
hardcopy_export.cpp
hardcopy_export.cs

This sample shows the user how to:
  • Import an HSF file
  • Retrieve the size of the window at runtime
  • Export a 2D-PDF and PostScript file
  • Check whether the hardcopy export completed successfully

hidden_line
hidden_line.cpp
hidden_line.cs
This sample shows the user how to:
See also: Programming Guide section 8.7

hidden_line_advanced
hidden_line_advanced.cpp
hidden_line_advanced.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Tweak segment level visibility using a HPS::VisibilityControl object
  • Set up a drawing to use hidden lines with shadows
See also: Programming Guide section 8.7

highlighting
highlighting.cpp
highlighting.cs
This sample shows the user how to:
  • Load an HSF file
  • Load an image and use it to create a texture
  • Create an opaque style
  • Create a transparent style
  • Create a textured style
See also: Programming Guide section 4.3 and section 6.4

image_background
image_background.cpp
image_background.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Search portfolio objects for image definitions
  • Applying portfolios to segments
  • Searching a list of named images
  • Applying an image as the window background
See also: Programming Guide section 4.1, section 3.4

image_io
image_io.cpp
image_io.cs
This sample shows the user how to:
  • Load a JPG file through HPS::Image and check for Image IO exceptions
  • Obtain an HPS::ImageKit and how to interact with it (obtain image size, image data, etc)
  • Convert an image between formats
  • Output an image to a file
  • Insert text using HPS::UTF8 objects
See also: Programming Guide section 9.1

image_output
image_output.cpp
image_output.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Create an offscreen window
  • Render to an offscreen window
  • Save a snapshot to disk
See also: Programming Guide section 7.2

insert cube
insert_cube.cpp
insert_cube.cs
This sample shows the user how to:
  • Insert a basic cube
See also: Programming Guide section 2.1

interpolation
interpolation.cpp
interpolation.cs
This sample shows the user how to:
  • Create a material palette
  • Set colors on vertices using an HPS::RGBColor
  • Set colors on vertices using a material palette
  • Turning color interpolation on and off
See also: Programming Guide section 5.1, section 8.6

lightweight_subwindow
lightweight_subwindow.cpp
lightweight_subwindow.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Set up a legend, with a separate camera on the legend segment
  • Use of depth range and exclude bounding

mask_transforms
mask_transforms.cpp
mask_transforms.cs
This sample shows the user how to:
  • Insert a shell
  • Mask modelling matrix rotation, scaling, and translation
  • Rotate, scale, and translate a scene
See also: Programming Guide section 3.3.6

meshes
meshes.cpp
meshes.cs
This sample shows the user how to:
  • Insert a mesh
  • Set the normals on a mesh
  • Include segments into other segments
  • Set segment level attributes (color)
  • Change the modelling matrix
See also: Programming Guide section 2.2

priority
priority.cpp
priority.cs
This sample shows the user how to:
  • Control the drawing order of co-planar geometry using SetPriority()
See also: Programming Guide section 8.7.1

publish_widgets
publish_widgets.cpp
publish_widgets.cs
This sample shows the user how to:
  • Create a PDF file and insert a check box, button, and list box using HOOPS Publish
  • Demonstrate how to connect Javascript to a button
  • Output a the file through Publish and check for IO exceptions
See also: Programming Guide section 9.5

quickmoves
quickmoves.cpp
quickmoves.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Include segments into other segments
  • Setting different overlay settings (no overlay, normal overlay, overlay with z-value)
  • Shows performance difference between overlay styles
See also: Programming Guide section 6.5

reference_geometry
reference_geometry.cpp
reference_geometry.cs
This sample shows the user how to:
  • Load an HSF file which contains a shell
  • Search the segment tree for the shell
  • Use reference geometry to instance the shell multiple times
See also: Programming Guide section 2.14

render_modes
render_modes.cpp
render_modes.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Divide the screen into subwindows
  • Include segments into other segments
  • Render with flat shading, wireframe, hidden line, Gouraud, Phong algorithms
  • Use color index interpolation
See also: Programming Guide section 8.5

segment_attributes
segment_attributes.cpp
segment_attributes.cs
This sample shows the user how to:
  • Insert a shell
  • Include a segment
  • Correctly delete included geometry
  • Change segment level attributes (face color, edge color, face visibility, edge visibility)
  • Use transparency
  • Use subwindows
See also: Programming Guide section 1.1.3, section 3.3

select_by_point
select_by_point.cpp
select_by_point.cs
This sample shows the user how to:
  • Perform an analytic selection
  • Perform a visual selection
See also: Programming Guide section 6.3, "selection" sample

shell_attributes
shell_attributes.cpp
shell_attributes.cs
This sample shows the user how to:
  • Insert a shell
  • Include a segment
  • Change shell level attributes (face color, vertex color, vertex visibility, face visibility)
See also: Programming Guide section 2.1

selection
selection.cpp
selection.cs
This sample shows the user how to:
  • Load an HSF file and check for IO exceptions
  • Define a glyph to be used as a marker symbol
  • Define a named style
  • Select a single instance of an entity
  • Modify selection option and selectability
  • Highlight selected geometry
See also: Programming Guide section 6.3, section 6.4, section 4.3, section 4.5

spotlight
spotlight.cpp
spotlight.cs
This sample shows the user how to:
  • Insert a shell
  • Set segment level attributes (color)
  • Insert a spotlight
See also: Programming Guide section 2.4

subshell_attributes
sub_shell_attributes.cpp
sub_shell_attributes.cs
This sample shows the user how to:
  • Insert a shell
  • Divide the screen into sub-windows
  • Change shell-level attributes
See also: Programming Guide section 5.5.1

textures
textures.cpp
textures.cs
This sample shows the user how to:
  • Load an HSF file and check for exceptions
  • Load an image file through HPS::Image and check for Image IO exceptions
  • Search the database for segments, and iterate through a list of search results
  • Create a portfolio
  • Define textures with Sphere, Cylinder and UV parameterizations
  • Apply textures to geometry
See also: Programming Guide section 4.1, section 5.1.1, section 5.3