The HUtility class contains a set of utility functions and data structures used widely in MVO classes. More...

#include <HUtility.h>

Public Types

enum  { X, Y, Z, W }
 
enum  { XY, XZ, YZ }
 

Static Public Member Functions

static void AdjustPositionToPlane (HBaseView *view, HPoint &position, HPoint point_in_plane)
 
static void ascii_to_unicode (char const *ascii, unsigned short *unicode)
 
static void BatchRead (HBaseModel *model, const char *directory, const char *extension)
 
static bool BuildIncludePath (HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey=INVALID_KEY)
 
static void BuildIncludePathFromSelection (HSmartSelItem *sitem, int &plen, HC_KEY *fullpath)
 
static void CalculateBoundingInfo (HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid)
 
static void CalculateCornerImagePosition (HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy)
 
static int CalculateKeyPath (HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray)
 
static int CalculateMajorAxis (HBaseView *view)
 
static void Camera_To_Transform (HCamera *camera, float *pos, float projection_matrix[], float complete_matrix[])
 
static bool CamerasEqual (const HCamera &camera1, const HCamera &camera2)
 
static void ClampPointToWindow (HPoint *point)
 
static long ClipPolygonAgainstPlane (long vertexCount, const HPoint vertex[], const float plane[], HPoint result[], bool *noCut=0)
 
static void CloseAllSegments (HC_KEY endkey=INVALID_KEY)
 
static float ComputeAngleBetweenVector (HPoint p1, HPoint p2)
 
static void ComputeDoublePrecisionCrossProduct (double *vector1, double *vector2, double *up)
 
static double ComputeDoublePrecisionDotProduct (double *vector1, double *vector2)
 
static double ComputeDoublePrecisionVectorLength (double *vector1)
 
static void ComputeShellNormal (HC_KEY skey, HPoint &tnormal)
 
static void ComputeVectorToVectorRotationMatrix (float matrix[], HPoint v1, HPoint v2)
 
static int ConstrainToVector (const float matrix_in[], const HVector &vector, float matrix_out[])
 
static void ConvertLocalPixelsToLocalWindow (HBaseView *view, HPoint *in_system, HPoint *out_system=0)
 
static void CountShellData (HC_KEY shell_key, int *faces, int *vertices, int *triangles, int *tristrips=0)
 
static bool CreateAxisCircle (HPoint const &center, float radius, int axis, bool convert=true)
 
static HC_KEY CreateScaleIndependentSegment (const char *segname, bool SetCallback=true)
 
static void CreateZebraStripeTexture (int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground)
 
static void DecipherTextureString (char *texdef, char *Source, bool *DownSampling=0, bool *DownSamplingSet=0, char *ParameterizationSource=0, char *InterpolationFilter=0, char *DecimationFilter=0, char *Layout=0, char *Tiling=0, bool *ValueScaleSet=0, bool *ValueScale=0, float *ValueScaleMin=0, float *ValueScaleMax=0, char *BlendingMode=0)
 
static void DeleteManipulators (HC_KEY key)
 
static float EaseInEaseOut (float t, float a, float b, float c)
 
static const char * extra_pointer_format ()
 
static bool ExtractRGB (char *text, float &r, float &g, float &b)
 
static void Find_Relative_Path (HC_KEY from_seg_key, HC_KEY to_seg_key, char *path)
 
static int FindContents (HC_KEY &key, bool original=false)
 
static int FindFaceByIndex (int findex, int *flist, int flen)
 
static void FindFileNameAndDirectory (const char *filename_in, char *dir_out, char *filename_out)
 
static void FindFileNameAndDirectory (__wchar_t const *filename_in, __wchar_t *dir_out, __wchar_t *filename_out)
 
static void FindFileNameExtension (const char *filename_in, char *ext_out, int size=-1)
 
static void FindFileNameExtension (__wchar_t const *const filename_in, __wchar_t *ext_out, int size=-1)
 
static HC_KEY FindOneObject (const char *type, bool l=0)
 
static void FindUnicodeFileNameExtension (const unsigned short *filename_in, char *ext_out)
 
static void Generate_LODs (bool do_recurse=true, bool delete_orig_shells=false, bool insert_null_lods=false, int n_lod_levels=2, float reduction_ratio=0.20)
 
static void GenerateCuboidPoints (HPoint const *max, HPoint const *min, HPoint *points)
 
static bool GetAllowAnimation (HC_KEY key)
 
static void GetCameraFromGLFrustum (double const left, double const right, double const bottom, double const top, double const near_z, double const far_z, bool const perspective, HPoint &pos, HPoint &target, HPoint &up, char *projection, double &width, double &height, double &near_limit)
 
static void GetCameraFromMatrix (float matrix[], HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation)
 
static HPoint GetCentroid (HC_KEY seg_key)
 
static void GetMatrixFromCamera (HPoint target, HPoint position, HPoint up_vector, HPoint translation, float matrix[])
 
static HC_KEY GetNextRenumberedKey (HBaseView *view)
 
static void GetScaleIndependentGeomPosition (HC_KEY segkey, float &x, float &y, float &z)
 
static HC_KEY GetScaleIndependentGeomSegmentKey (HC_KEY segkey)
 
static float GetTime ()
 
static HPoint GetTransformedCentroid (HC_KEY seg_key, float matrix[]=0)
 
static void GetViewplaneVectors (HC_KEY segment_key, double *view, double *up)
 
static HC_KEY GrabSegment (HC_KEY key)
 
static void InsertArrow (float stick_length, float tip_length, float stick_radius, float arrow_radius, const char *text, const char *stick_color, const char *tip_color, int num_sides=6, float tip_falloff=0.05, bool reverse=true)
 
static HC_KEY InsertBox (HPoint const *max, HPoint const *min)
 
static HC_KEY InsertRectangle (const char *seg, float x0, float y0, float x1, float y1, float z=0.0f, bool fill=false)
 
static void InsertRotatedArrow (float stick_length, float tip_length, float stick_radius, float tip_radius, float distance, int adelta, float rotang, const char *stick_color, const char *tip_color, int num_sides, float tip_falloff, bool reverse)
 
static HC_KEY InsertWireframeBox (HPoint *max, HPoint *min)
 
static void InterpolateNormalAlongEdge (HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3)
 
static void IntersectionLinePlane (HPoint *p1, HPoint *p2, HPlane *p, HPoint *res)
 
static int IsChildOf (HC_KEY owner, HC_KEY child, HC_KEY klist[]=0)
 
static bool IsIdentityMatrix (float matrix[])
 
static bool IsModelKey (HC_KEY modelkey, HC_KEY objectkey)
 
static bool IsPointInsideAllEdges (const float *pt, const float points1[], int len, const int face1[], const float plane1[], float fudge)
 
static bool IsSafeForSinglePrecision (double element, bool check_roundoff=false)
 
static bool IsSafeForSinglePrecision (int element_count, double const *elements, bool check_roundoff=false)
 
static bool IsSegmentKey (HC_KEY key)
 
static void LocalPixelsToWorld (HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float result[])
 
static void MakeViewSnapshot (HBaseView *view, int width, int height, char **data)
 
static void MakeViewSnapshot (HBaseView *view, HC_KEY image_key)
 
static void MatrixToQuaternion (float matrix[], float quaternion[])
 
static HC_KEY Merge_Shells (bool do_recurse, bool delete_orig_shells=false, bool optimize_shell=true, bool generate_regions=false)
 
static HC_KEY Merge_Shells_Generate_Regions (int num_shells, HC_KEY *shell_keys, bool delete_orig_shells=false)
 
static void MergePointsIntoShell (int num_shell_points, HPoint plist1[], int num_shell_facelist, int flist1[], int num_merge_points, HPoint merge_points[], HPoint merge_vectors[], float tolerance, bool AddExtraPoints, int newpoints[], int *newpointslen)
 
static void MergePolylines ()
 
static HC_KEY MergeShells (HC_KEY shell1, HC_KEY shell2)
 
static bool ModifyPushedAttribute (const char *attName, const char *newStyle)
 
static void MoveToTemp (HC_KEY movekey, HC_KEY tempkey)
 
static void MultiSmoothTransitions (HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float new_matrix[], HCamera *new_camera=0)
 
static void NameSegments (HC_KEY &key, HBaseView *view)
 
static void NormalizeDoublePrecisionVector (double *vector1)
 
static HC_KEY OpenSegmentFromKey (HC_KEY key, char *segment)
 
static void OptimizeModelByGrid (HBaseView *view, ShellToRegionMapper *mapper)
 
static void OptimizeSegmentTree (HC_KEY old_seg_key, HC_KEY *new_seg_key, bool transform_shells=true, bool merge_shells=true, bool create_shell_regions=false)
 
static void Order (HPoint *one, HPoint *two)
 
static bool PointsEqual (HPoint *point1, HPoint *point2)
 
static bool PopAttribute (const char *attName)
 
static void ProjectShell (HC_KEY shellkey)
 
static bool PushAttribute (const char *attName)
 
static void PushAttribute (const char *attName, const char *attText)
 
static void QuaternionToMatrix (float quaternion[], float matrix[])
 
static void ReadjustTarget (HBaseView *view)
 
static void Recursive_Merge_Shells (HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells=false, bool insert_null_lods=false)
 
static void RegisterCallbacks ()
 
static void RenameSegment (HC_KEY segkey, const char *newname)
 
static bool RLECompress (int const in_len, unsigned char const *const in_buf, int *out_len, unsigned char *const out_buf)
 
static void RotateToVector (HPoint start, HPoint end, bool doTranslation=true)
 
static bool SafeSetUserOption (const char *opt)
 
static bool SafeShowUserOption (char *opt)
 
static bool Segment_Shell_Allocate (HShell *total_info, HShell *max_info, bool do_recurse)
 
static bool SegmentExists (const char *segment)
 
static HC_KEY SelectUnderCursor (HBaseView *view, float x, float y, bool doSelection=true, bool DeSelect=false)
 
static void SetScaleIndependentGeomPosition (HC_KEY segkey, float x, float y, float z)
 
static void Shell_Search (HShell *total_info, HShell *max_info, bool do_recurse)
 
static void ShowContentsWithPath (const char *entitytypes, struct vlist_s **ret_pathlist, bool storePath=false, bool includeIncludes=true, bool filterIncludes=true)
 
static void ShowModellingMatrix (float *segment_modelling_matrix)
 
static void ShowNormals (HC_KEY shellkey, float normallength)
 
static bool ShowOneHeuristic (const char *type, char *res=0)
 
static bool ShowOneRenderingOption (const char *type, char *res=0)
 
static bool ShowOneUserOption (const char *option, char *res)
 
static bool ShowPushedAttribute (const char *attName, HUserOptions &attText)
 
static HC_KEY SmartSelectUnderCursor (HBaseView *view, float x, float y, bool doSelection=true, bool DeSelect=false)
 
static void SmoothMatrixTransition (HBaseView *m_pView, HC_KEY seg_key, float new_matrix[])
 
static void SmoothQuaternionTransition (HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions)
 
static void SmoothTransition (const HPoint &co, const HPoint &to, const HPoint &uo, float fieldwidtho, float fieldheighto, const HPoint &cn, const HPoint &tn, const HPoint &un, float fieldwidthn, float fieldheightn, HBaseView *view)
 
static void SmoothTransition (HCamera old_camera, const HCamera &new_camera, HBaseView *view)
 
static int strlen16 (const unsigned short *p16)
 
static void SubdivideShells (HC_KEY sskey, HC_KEY startkey, HC_KEY newkey, int numx, int numy, int numz, ShellToRegionMapper *mapper=0, bool DoCut=true, bool DeleteOriginalShells=false, bool breakShells=false)
 
static void SuppressAnimation ()
 
static void TransitionQuaternion (float quat_old[], float quat_new[], float t, float qt[])
 
static HFileOutputResult TwoPassPrint (const char *driver, HOutputHandlerOptions *options)
 
static unsigned short * uconvert (const char *text)
 
static void unicode_to_ascii (unsigned short const *unicode, char *ascii)
 
static void UnsetAttributes ()
 
static void UnwindIncludes (HC_KEY &key)
 
static void UnwindIncludes (HC_KEY &newkey, HC_KEY *keys, int count)
 
static void URIdecode (const char *in_string, char *out_buffer, MVO_POINTER_SIZED_UINT *n)
 
static void URIencode (const char *in_string, MVO_POINTER_SIZED_UINT n, char *out_buffer)
 
static HC_KEY UserOptionExists (HC_KEY key, const char *attrib, char *result)
 
static int ustrlen (unsigned short *text)
 
static bool ZlibCompress (int const in_len, unsigned char const *const in_buf, int &out_len, unsigned char *const out_buf)
 
static bool ZlibDecompress (int const in_len, unsigned char const *const in_buf, int &out_len, unsigned char *const out_buf)
 

Static Public Attributes

static const float EH_Epsilon
 default=0.01
 
static const float PI
 default=3.1415926f
 

Detailed Description

The HUtility class contains a set of utility functions and data structures used widely in MVO classes.

HUtility includes utility functions for double-precision vector math, creation of construction geometry, etc...

Member Function Documentation

◆ AdjustPositionToPlane()

static void HUtility::AdjustPositionToPlane ( HBaseView view,
HPoint position,
HPoint  point_in_plane 
)
static

This function projects a point in world space onto the plane that contains point_in_plane and is parallel to the near clipping plane which is perpindicular to the view vector.

Parameters
positionThe point to be projected into the plane. This function returns the new adjusted coordinates.
point_in_planeA point in the plane (which is perpindicular to the view vector) to which we're going to project out world space position point.

◆ ascii_to_unicode()

static void HUtility::ascii_to_unicode ( char const *  ascii,
unsigned short *  unicode 
)
static

This method converts an ASCII string to a unicode string. Please use H_UNICODE_TEXT in place of this function as this may be removed in the next release.

Parameters
asciiThe ASCII string you want to convert.
unicodeA pointer to the array that will hold the converted unicode string. Note this array should be at least as long as the ASCII string.

◆ BatchRead()

static void HUtility::BatchRead ( HBaseModel model,
const char *  directory,
const char *  extension 
)
static

This method loads all files with a particular extension into the model segment. It starts reading files in the given directory and then descends down the directory until it has read all files with the given extension.

Parameters
modelA pointer to the model object to be used.
directoryThe directory to start searching for files.
extensionThe extension of the files to be loaded. All files encountered with this extension will be loaded.

◆ BuildIncludePath()

static bool HUtility::BuildIncludePath ( HC_KEY  objectkey,
const HC_KEY *  includelist,
int  ilength,
HC_KEY *  fullpath,
int *  fplength,
HC_KEY  matchkey = INVALID_KEY 
)
static

Given an array of include keys, this method builds a full path consisting of segment keys and includes.

Parameters
objectkeyThe key to start segment or geometry.
includelistThe list of includes.
ilengthThe length of include list.
fullpathReturn the full key path derived from the object key and include list.
fplengthReturns the length of the key path.
matchkeyPass a key that when found by this method will stop building the path. If you want the method to walk the entire tree, pass INVALID_KEY.

◆ BuildIncludePathFromSelection()

static void HUtility::BuildIncludePathFromSelection ( HSmartSelItem sitem,
int &  plen,
HC_KEY *  fullpath 
)
static

This method builds the include path for a given selection item.

Parameters
sitemA pointer to the selection item.
plenReturns the length of the include path.
fullpathReturn the full key path of the selection item.

◆ CalculateBoundingInfo()

static void HUtility::CalculateBoundingInfo ( HC_KEY  startkey,
HPoint min,
HPoint max,
HPoint delta,
HPoint mid 
)
static

This method uses #HC_Compute_Circumcuboid to calculate bounding information for a given segment hierachy.

Parameters
startkeyThe key of the segment to calculate bounding for.
minReturns the minimum point of the bounding box.
maxReturns the maximum point of the bounding box.
deltaReturns the extent of the bounding box.
midReturns the center point of the bounding box.

◆ CalculateCornerImagePosition()

static void HUtility::CalculateCornerImagePosition ( HBaseView view,
int  iwidth,
int  iheight,
HWindowCorner  corner,
float &  posx,
float &  posy 
)
static

This method calculates the exact coordinates to place an image in a given corner of a window.

Parameters
viewA pointer to the HBaseView object.
iwidthThe width of the image.
iheightThe height of the image.
cornerThe corner in which you want to place the window which can be TopRight or BottomRight.
posxReturns the x coordinate for the image.
posyReturns the y coordinate for the image.

◆ CalculateKeyPath()

static int HUtility::CalculateKeyPath ( HC_KEY  startkey,
HBaseView view,
HC_KEY *  keyarray,
int  maxarray 
)
static

This function returns a list of keys from the current segment to the top level scene segment.

Parameters
startkeyThe segment to start the keylist from.
viewA pointer to the current HBaseView object.
keyarrayPass a pointer to an array that will hold the keylist. This method wil populate the array.
maxarrayThe maximum size of array to calculate.
Returns
The size of the final keylist.

◆ CalculateMajorAxis()

static int HUtility::CalculateMajorAxis ( HBaseView view)
static

This method calculates the major axis of the current camera.

Parameters
viewA pointer to the HBaseView object.
Returns
The value 0 if the major axis is X or the value 1 if the major axis is Y or the value 2 if the major axis is Z.

◆ Camera_To_Transform()

static void HUtility::Camera_To_Transform ( HCamera camera,
float *  pos,
float  projection_matrix[],
float  complete_matrix[] 
)
static

Given a camera, this method extracts the position, projection and full matrix information and returns it to the caller.

Parameters
cameraA pointer to the camera information.
posPass a pointer to an array that can hold a 4 x 4 matrix. The method will populate it with the position information.
projection_matrixPass a pointer to an array that can hold a 4 x 4 matrix. The method will populate it with the projection information.
complete_matrixPass a pointer to an array that can hold a 4 x 4 matrix. The method will populate it with the complete matix information.

◆ CamerasEqual()

static bool HUtility::CamerasEqual ( const HCamera camera1,
const HCamera camera2 
)
static

The CamerasEqual method tests two camera definitions for equality.

Parameters
camera1The first camera definition.
camera2The second camera definition.
Returns
True if the cameras have the same definition or false if they don't.

◆ ClampPointToWindow()

static void HUtility::ClampPointToWindow ( HPoint point)
static

ClampPointToWindow clamps a point to its nearest corner in window space.

Parameters
pointA pointer to an HPoint object.

◆ ClipPolygonAgainstPlane()

static long HUtility::ClipPolygonAgainstPlane ( long  vertexCount,
const HPoint  vertex[],
const float  plane[],
HPoint  result[],
bool *  noCut = 0 
)
static

This method clips a polygon against a plane described by the planar equation ax + by + cz + d = 0.

Parameters
vertexCountThe number of vertices in the input polygon.
vertexThe vertices of input polygon.
planeA pointer to an array that holds the five parameters a, b, c and d represented in the planar equation ax + by + cz + d = 0 respectively.
resultReturns the points of the newly clipped polygon.
Returns
The number of points in the clipped polygon.

◆ CloseAllSegments()

static void HUtility::CloseAllSegments ( HC_KEY  endkey = INVALID_KEY)
static

This method closes the current segment and then walks up the database tree closing the any segments that are open until it reaches the top level segment or the end key if one is passed.

Parameters
endkeyPass a key that will end the method.

◆ ComputeAngleBetweenVector()

static float HUtility::ComputeAngleBetweenVector ( HPoint  p1,
HPoint  p2 
)
static

This method calculates the angle between two vectors.

Parameters
p1The first vector.
p2The second Vector.
Returns
The angle between the two vectors.

◆ ComputeDoublePrecisionCrossProduct()

static void HUtility::ComputeDoublePrecisionCrossProduct ( double *  vector1,
double *  vector2,
double *  up 
)
static

ComputeDoublePrecisionCrossProduct computes the cross product of two double precision vectors.

Parameters
vector1A pointer to a double precision vector.
vector2A pointer to a double precision vector.
upPass a pointer to a double. This method will populate up with the result of the cross product.

◆ ComputeDoublePrecisionDotProduct()

static double HUtility::ComputeDoublePrecisionDotProduct ( double *  vector1,
double *  vector2 
)
static

ComputeDoublePrecisionDotProduct computes a double precision dot product of two vectors.

Parameters
vector1A pointer to a double precision vector.
vector2A pointer to a double precision vector.
Returns
The double precision dot product of the two vectors.

◆ ComputeDoublePrecisionVectorLength()

static double HUtility::ComputeDoublePrecisionVectorLength ( double *  vector1)
static

ComputeDoublePrecisionVectorLength computes the length of a double precision vector.

Parameters
vector1A pointer to a double precision vector.
Returns
The double precision length of the vector.

◆ ComputeShellNormal()

static void HUtility::ComputeShellNormal ( HC_KEY  skey,
HPoint tnormal 
)
static

The method determines an appropriate normal vector for the given shell. For closed objects, the normal can be somewhat random. This is used for Zoom to Shell like functionality.

Parameters
skeyThe key to the shell you want a normal for.
tnormalA pointer to an HPoint object. The method will populate this parameter with the calculated normal vector.

◆ ComputeVectorToVectorRotationMatrix()

static void HUtility::ComputeVectorToVectorRotationMatrix ( float  matrix[],
HPoint  v1,
HPoint  v2 
)
static

This method computes a rotation matrix that rotates between the two supplied vectors.

Parameters
matrixPass an array that can hold a 4 x 4 matrix. This method will populate the matrix with the values for the rotation matrix.
v1The vector to rotate from.
v2The vector to rotate to.

◆ ConstrainToVector()

static int HUtility::ConstrainToVector ( const float  matrix_in[],
const HVector vector,
float  matrix_out[] 
)
static

Given an input matrix and a vector, this method returns the original matrix but with the translation component constrained so that translation is along the provided vector.

Parameters
matrix_inA pointer to the modelling matrix.
vectorA vector along which translation should be constrained to.
matrix_outPass a pointer to an array that can hold a 4 x 4 matrix. The method will populate this array with the constrained matrix.

◆ ConvertLocalPixelsToLocalWindow()

static void HUtility::ConvertLocalPixelsToLocalWindow ( HBaseView view,
HPoint in_system,
HPoint out_system = 0 
)
static

This method converts a point from local pixels space to local window space.

Parameters
viewA pointer to the HBaseView Object.
in_systemThe coordinates in Local Pixels. The method will do an in place conversion if you pass null for out_system.
out_systemPass a pointer an HPoint distinct from in_system if you do not want an in place conversion. If you do, pass null.

◆ CountShellData()

static void HUtility::CountShellData ( HC_KEY  shell_key,
int *  faces,
int *  vertices,
int *  triangles,
int *  tristrips = 0 
)
static

This method counts the number of faces, vertices and triangles in a given shell primitive.

Parameters
shell_keyThe HOOPS key to a given shell.
facesReturns the number of faces in the given shell. Passed by reference.
verticesReturns the number of vertices in the shell, including duplicates. Passed by reference
trianglesReturns the number of triangles in the shell after HOOPS triangulation calculation. Passed by reference.
tristripsReturns the number of tristrips in the shell. Pass by reference.

◆ CreateAxisCircle()

static bool HUtility::CreateAxisCircle ( HPoint const &  center,
float  radius,
int  axis,
bool  convert = true 
)
static

CreateAxisCircle creates a circle based on a centerpoint and a radius. The centerpoint is assumed to be in viewpoint space. Note this function actually inserts a circle into the HOOPS scene using the HOOPS routine HC_Insert_Circle, whereas HUtilityGeometryCreation::GeneratePointsOnCircle only generates an array of points along a circular trajectory.

Parameters
centerThe center of the desired circle.
radiusThe length of the radius of the circle.
axisXY, XZ, or YZ. This defines the view plane in which the circle will be drawn.
convertPass true to convert to viewpoint space.
Returns
True if the operation was a success or false if it failed.

◆ CreateScaleIndependentSegment()

static HC_KEY HUtility::CreateScaleIndependentSegment ( const char *  segname,
bool  SetCallback = true 
)
static

This method is for internal use only.

◆ DeleteManipulators()

static void HUtility::DeleteManipulators ( HC_KEY  key)
static

This method removes manipulator handles from the geometry or segment identified by key

Parameters
keyThe key to the geometry or segment with manipulators

◆ EaseInEaseOut()

static float HUtility::EaseInEaseOut ( float  t,
float  a,
float  b,
float  c 
)
static

This method calculates the EaseIn/EaseOut for a given interval and speed. This ensure that animations have a smooth transition at the beginning and end.

Parameters
tThe current interval which is from 0 to 1.
aThe ease in duration given a normalized interval.
bThe constant speed duration.
cThe ease out duration given a normalized interval.
Returns
The newly recalculated interval.

◆ extra_pointer_format()

static const char* HUtility::extra_pointer_format ( )
static

HOOPS likes window handles and colormaps to be printed as hex value with the form 0xXXXXXXXX but some systems sprintf functions print pointer with out the 0x part.

So use sprintf(buffer,"%s%p",extra_pointer_format(),pointer) to ensure correct formating for HOOPS.

Returns
A system dependent pointer printing extention either "" or "0x".

◆ ExtractRGB()

static bool HUtility::ExtractRGB ( char *  text,
float &  r,
float &  g,
float &  b 
)
static

This method parses the input string with the format "R=0.23, G=0.34, B=0.12" for the red, green and blue color values.

Parameters
textA pointer to null terminated char array with color information.
rReturns the red color component.
gReturns the green color component.
bReturns the blue color component.
Returns
True if the operation was successful or false if it failed.

◆ Find_Relative_Path()

static void HUtility::Find_Relative_Path ( HC_KEY  from_seg_key,
HC_KEY  to_seg_key,
char *  path 
)
static

This method returns a relative path for the from_seg_key to the to_seg_key.

Parameters
from_seg_keyThe key to the start segment.
to_seg_keyThe key to the end segment.
pathPass an array that will be filled with the relative path.

◆ FindContents()

static int HUtility::FindContents ( HC_KEY &  key,
bool  original = false 
)
static

This method is a wrapper for #HC_Find_Contents. Note you must call HC_Begin_Contents_Search before this call and #HC_End_Contents_Search after this call.

Parameters
keyThe key to identify.
originalIndicates whether the original key of the item is desired. Default is the current (possibly Renumbered) key.
Returns
True if items were found.

◆ FindFaceByIndex()

static int HUtility::FindFaceByIndex ( int  findex,
int *  flist,
int  flen 
)
static

Given Face Index (0,1,2...), this method finds position of face in face list array as described in #HC_Insert_Shell.

Parameters
findexThe face index.
flistThe face list array.
flenThe length of face list array.
Returns
Position of the face in the face list array.

◆ FindFileNameAndDirectory() [1/2]

static void HUtility::FindFileNameAndDirectory ( const char *  filename_in,
char *  dir_out,
char *  filename_out 
)
static

Given a filename with path, this method returns the filename and directory.

Parameters
filename_inA null terminated string holding a filename.
dir_outPass a char pointer of size > strlen(filename_int)+1. The method returns the directory part of the filename.
filename_outPass a char pointer of size > strlen(filename_int)+1. The method returns the short filename part of the filename.

◆ FindFileNameAndDirectory() [2/2]

static void HUtility::FindFileNameAndDirectory ( __wchar_t const *  filename_in,
__wchar_t *  dir_out,
__wchar_t *  filename_out 
)
static

Given a filename with path, this method returns the filename and directory.

Parameters
filename_inA null terminated string holding a filename.
dir_outPass a char pointer of size > strlen(filename_int)+1. The method returns the directory part of the filename.
filename_outPass a char pointer of size > strlen(filename_int)+1. The method returns the short filename part of the filename.

◆ FindFileNameExtension() [1/2]

static void HUtility::FindFileNameExtension ( const char *  filename_in,
char *  ext_out,
int  size = -1 
)
static

Given a file name, this method returns the file extention. The extentions is returned in lowercase only.

Parameters
filename_inA null terminated string holding a filename.
ext_outPass a char pointer of size > strlen(filename_int)+1. This method will return the file extension.

◆ FindFileNameExtension() [2/2]

static void HUtility::FindFileNameExtension ( __wchar_t const *const  filename_in,
__wchar_t *  ext_out,
int  size = -1 
)
static

Given a file name, this method returns the file extention. The extentions is returned in lowercase only.

Parameters
filename_inA null terminated string holding a filename.
ext_outPass a char pointer of size > strlen(filename_int)+1. This method will return the file extension.

◆ FindOneObject()

static HC_KEY HUtility::FindOneObject ( const char *  type,
bool  l = 0 
)
static

This method find a objects of given type in the current segment or globally.

Parameters
typeHOOPS entity type like segment, shell, etc.
lPass true to search local or false to search globally.
Returns
The key to the matching HOOPS entity or INVALID_KEY if no object was found.

◆ FindUnicodeFileNameExtension()

static void HUtility::FindUnicodeFileNameExtension ( const unsigned short *  filename_in,
char *  ext_out 
)
static

Given a unicode file name, this method returns the file extention. The extentions is returned in lowercase only.

Parameters
filename_inA null terminated UNICODE string holding a filename.
ext_outPass a char pointer of size > strlen(filename_int)+1. This method will return the file extension.

◆ Generate_LODs()

static void HUtility::Generate_LODs ( bool  do_recurse = true,
bool  delete_orig_shells = false,
bool  insert_null_lods = false,
int  n_lod_levels = 2,
float  reduction_ratio = 0.20 
)
static

This function merges all the shells in the segement and generates LODs for the merged shell. These LODs are then attached to one of the shells in the segment.

Parameters
do_recursePass true to recursively searched for shells.
delete_orig_shellsPass true to erase the original shells once they have been merged into a new shell.
insert_null_lodsPass true to attach null shells as LOD geometry for all the shells except one.
n_lod_levelsThe number of lod levels to be generated.
reduction_ratioThe ratio of the number of triangles in an LOD vs. the number of triangles in the previous LOD.

◆ GenerateCuboidPoints()

static void HUtility::GenerateCuboidPoints ( HPoint const *  max,
HPoint const *  min,
HPoint points 
)
static

GenerateCuboidPoints creates the vertices of a cuboid based on two input points.

Parameters
maxA pointer to the first point that describes the cuboid.
minA pointer to the point the is diagonally opposite the first point.
pointsA pointer to an array that can hold the 8 HPoints that describe the cuboid. Passed by reference.

◆ GetAllowAnimation()

static bool HUtility::GetAllowAnimation ( HC_KEY  key)
static

This method returns whether the user option to suppress animation is set for a given segment.

Parameters
keyThe key of the segment in which you want to check the suppress animation option.
Returns
True if the suppress animation option was set or false if it wasn't.

◆ GetCameraFromGLFrustum()

static void HUtility::GetCameraFromGLFrustum ( double const  left,
double const  right,
double const  bottom,
double const  top,
double const  near_z,
double const  far_z,
bool const  perspective,
HPoint pos,
HPoint target,
HPoint up,
char *  projection,
double &  width,
double &  height,
double &  near_limit 
)
static

This method returns a set of HOOPS camera values and a HOOPS camera near-plane value based on a glFrustum or glOrtho definition. The resulting HOOPS camera values should be set within #HC_Set_Camera, AND the resulting near-plane should be set by #HC_Set_Camera_Near_Limit.

Parameters
leftThe same parameter used by the glFrustum or glOrtho calls.
rightThe same parameter used by the glFrustum or glOrtho calls.
bottomThe same parameter used by the glFrustum or glOrtho calls.
topThe same parameter used by the glFrustum or glOrtho calls.
near_zThe same parameter used by the glFrustum or glOrtho calls.
far_zThe same parameter used by the glFrustum or glOrtho calls.
perspectiveIf set to true, then a perspective frustrum (set via glFrustum) is assumed. If false, then an orthographic frustum (set via glOrtho) is assumed.
posThe HOOPS camera position which is passed by reference and returned to the user.
targetThe HOOPS camera target which is passed by reference and returned to the user.
upThe HOOPS camera up vector which is passed by reference and returned to the user.
projectionThe HOOPS camera projection which is passed by reference and returned to user. The caller should pass in a char array of 64 characters. This is returned because the HOOPS camera projection might not be a simple choice between 'perspective' or 'orthographic' and thus won't match what was passed in via the 'perspective' boolean. For example, the result HOOPS projection could be 'oblique perspective' based on the glFrustum values.
widthThe HOOPS camera field width which passed by reference and returned to the user.
heightThe HOOPS camera field height which passed by reference and returned to the user.
near_limitThe HOOPS camera near limit which passed by reference and returned to the user. This value represents the location of the HOOPS camera's near clip plane.

Assumptions regarding the glFrustum values:
right > left
top > bottom
far > near, and for perspective both should be positive.

◆ GetCameraFromMatrix()

static void HUtility::GetCameraFromMatrix ( float  matrix[],
HPoint target,
HPoint position,
HPoint up_vector,
HPoint translation 
)
static

This method extracts the camera attributes from the input transformation matrix.

Parameters
matrixA pointer to the transformation matrix.
targetA pointer to HPoint object representing the camera target.
positionA pointer to HPoint object representing the camera position which this method will populate.
up_vectorA pointer to HPoint object representing the view-up vector which this method will populate.
translationA pointer to HPoint object representing the translation which this method will populate.

◆ GetCentroid()

static HPoint HUtility::GetCentroid ( HC_KEY  seg_key)
static

This method returns the centroid of a segment in world space.

Parameters
seg_keyThe segment to get centroid from.
Returns
The coordinate of the centroid.

◆ GetMatrixFromCamera()

static void HUtility::GetMatrixFromCamera ( HPoint  target,
HPoint  position,
HPoint  up_vector,
HPoint  translation,
float  matrix[] 
)
static

This method composes a transformation martix from the given camera attributes.

Parameters
targetA pointer to HPoint object representing camera target.
positionA pointer to HPoint object representing camera position.
up_vectorA pointer to HPoint object representing view-up vector.
translationA pointer to HPoint object representing translation.
*matrixResultant transformation matrix. Pass a pointer to an array that can accomodate a 4 x 4 matrix.

◆ GetNextRenumberedKey()

static HC_KEY HUtility::GetNextRenumberedKey ( HBaseView view)
static

This method finds the next unused globally renumbered key.

Parameters
viewA pointer to the HBaseView object.
Returns
The next available renumbered key.

◆ GetScaleIndependentGeomPosition()

static void HUtility::GetScaleIndependentGeomPosition ( HC_KEY  segkey,
float &  x,
float &  y,
float &  z 
)
static

This is for internal use only.

◆ GetScaleIndependentGeomSegmentKey()

static HC_KEY HUtility::GetScaleIndependentGeomSegmentKey ( HC_KEY  segkey)
static

This is for internal use only.

◆ GetTime()

static float HUtility::GetTime ( )
static
Returns
The system time in seconds.

◆ GetTransformedCentroid()

static HPoint HUtility::GetTransformedCentroid ( HC_KEY  seg_key,
float  matrix[] = 0 
)
static

This method returns the centroid of a segment, transformed by a given matrix.

Parameters
seg_keyThe segment to get centroid from.
matrixThe transformation to apply to the centroid.
Returns
The coordinate of the centroid.

◆ GetViewplaneVectors()

static void HUtility::GetViewplaneVectors ( HC_KEY  segment_key,
double *  view,
double *  up 
)
static

GetViewplaneVectors computes the construction-plane-constrained vectors used for geometry insertion.

Parameters
segment_keyThe key to the construction segment.
viewA pointer to the double precision view vector. Passed by reference.
upA pointer to the double precision up vector. Passed by reference.

◆ GrabSegment()

static HC_KEY HUtility::GrabSegment ( HC_KEY  key)
static

This method returns the key of the input object's owner. If the input is itself a segment key, it is returned as is.

Parameters
keyThe object key which can be segment or geometry.
Returns
The owner segment key.

◆ InsertArrow()

static void HUtility::InsertArrow ( float  stick_length,
float  tip_length,
float  stick_radius,
float  arrow_radius,
const char *  text,
const char *  stick_color,
const char *  tip_color,
int  num_sides = 6,
float  tip_falloff = 0.05,
bool  reverse = true 
)
static

InsertArrow inserts an arrow consisting of a cylinder and a cone at the origin. This function is used by the Axis display. The arrow is completely customizable.

Parameters
stick_lengthThe length of the cylindrical shaft of the arrow.
tip_lengthThe length of the conical tip of the arrow.
stick_radiusThe radius of the cylindrical shaft of the arrow.
arrow_radiusThe radius of the circular base of the arrow's conical tip.
textA pointer to a string that annotates the arrow.
stick_colorThe color of the shaft of the arrow.
tip_colorThe color of the tip of the arrow.
num_sidesThe number of sides of arrow. The default is 6.
tip_falloffThe radius reduction value on stick. The default is 0.05.
reversePass true to reverse the orientation.

◆ InsertBox()

static HC_KEY HUtility::InsertBox ( HPoint const *  max,
HPoint const *  min 
)
static

InsertBox inserts a six-sided, rectangular cuboid based on 2 points.

Parameters
maxA pointer to an HPoint describing a point on the box.
minA pointer to an HPoint describing a point on the opposite face diagonal from the first point.
Returns
The key to the newly created box.

◆ InsertRectangle()

static HC_KEY HUtility::InsertRectangle ( const char *  seg,
float  x0,
float  y0,
float  x1,
float  y1,
float  z = 0.0f,
bool  fill = false 
)
static

InsertRectangle inserts a 2d rectangle as a HOOPS Polyline.

Parameters
segThe segment name into which the rectangle should be inserted.
x0X-value of vertex 1 of the rectangle.
y0Y-value of vertex 1 of the rectangle.
x1X-value of vertex 3 of the rectangle.
y1Y-value of vertex 3 of the rectangle.
zThe z coordinate shared by vertext 1 and 3.
fillPass true to create a filled rectangle.
Returns
The key to the new created rectangle.

◆ InsertRotatedArrow()

static void HUtility::InsertRotatedArrow ( float  stick_length,
float  tip_length,
float  stick_radius,
float  tip_radius,
float  distance,
int  adelta,
float  rotang,
const char *  stick_color,
const char *  tip_color,
int  num_sides,
float  tip_falloff,
bool  reverse 
)
static

Inserts a circular arrow consisting of a cylinder and a cone display. The arrow is completely customizable.

Parameters
stick_lengthThe length of the cylindrical shaft of the arrow.
tip_lengthThe length of the conical tip of the arrow.
stick_radiusThe radius of the cylindrical shaft of the arrow.
tip_radiusThe radius of the circular base of the arrow's conical tip.
distanceThe x coordinate position of the center of the shaft.
adeltaThe number of angular steps.
rotangThe angular interval. Multily this value by adelta to get maximum arrow radius.
stick_colorThe color of the shaft of the arrow.
tip_colorThe color of the tip of the arrow.
num_sidesThe number of sides of the arrow. The default is six.
tip_falloffThe radius reduction value on the stick. The default is 0.05.
reversePass true to invert the arrow's orientation.

◆ InsertWireframeBox()

static HC_KEY HUtility::InsertWireframeBox ( HPoint max,
HPoint min 
)
static

InsertWireframeBox uses a polyline to insert a six-sided, rectangular cuboid wireframe based on 2 points.

Parameters
maxA pointer to an HPoint describing a point on the box.
minA pointer to an HPoint describing a point on the opposite face diagonal from the first point.
Returns
The key to the newly created box.

◆ InterpolateNormalAlongEdge()

static void HUtility::InterpolateNormalAlongEdge ( HPoint p1,
HPoint n1,
HPoint p2,
HPoint n2,
HPoint p3,
HPoint n3 
)
static

Given two points and the normals at those points, this method calculates the interpolated normals given an additional third point.

Parameters
p1The first point used for interpolation.
n1The first normal used for interpolation.
p2The second point used for interpolation.
n2The second normal used for interpolation.
p3The third point used for interpolation,
n3Returns the calculated normal.

◆ IntersectionLinePlane()

static void HUtility::IntersectionLinePlane ( HPoint p1,
HPoint p2,
HPlane p,
HPoint res 
)
static

This method calculates the intersection point between a line and a plane.

Parameters
p1The starting point of the line.
p2The end point of the line.
pA pointer to the plane.
resReturns the intersection point.

◆ IsChildOf()

static int HUtility::IsChildOf ( HC_KEY  owner,
HC_KEY  child,
HC_KEY  klist[] = 0 
)
static

This method determines if a given segment is a child of the given owner segment.

Parameters
ownerThe key of the owner segment.
childThe key of the potential child segment.
klistA pointer to a list of keys. If non-null, the list of keys of segments between the child and owner will get written to the list.
Returns
True if the child segment is indeed a child of the owner segment.

◆ IsIdentityMatrix()

static bool HUtility::IsIdentityMatrix ( float  matrix[])
static

This function returns true if the matrix passed in is an identity matrix and false otherwise.

Parameters
matrixthe matrix to be queried.
Returns
True if matrix is an identity, false otherwise.

◆ IsModelKey()

static bool HUtility::IsModelKey ( HC_KEY  modelkey,
HC_KEY  objectkey 
)
static

This method determines if the given key is underneath the model segment.

Parameters
modelkeyThey key to the model segment.
objectkeyThe key to test.
Returns
True if the key is underneath the model segment or false if otherwise.

◆ IsPointInsideAllEdges()

static bool HUtility::IsPointInsideAllEdges ( const float *  pt,
const float  points1[],
int  len,
const int  face1[],
const float  plane1[],
float  fudge 
)
static

This method determine if the given point enclosed by all the given edges.

Parameters
ptThe point to test.
points1The points array.
lenThe length of the points array.
face1The face connectivity array as described in #HC_Insert_Shell.
plane1A pointer to an array of four values that specify the a, b, c and d values of the planar equation ax + by + cz + d = 0.
fudgeThe threshold to decide in the point is inside or outside the plane.
Returns
True if the point is inside the edges or false if it isn't.

◆ IsSafeForSinglePrecision() [1/2]

static bool HUtility::IsSafeForSinglePrecision ( double  element,
bool  check_roundoff = false 
)
inlinestatic

This method checks whether a double precision element (usually from a matrix) can be safely stored as a single precision element

Parameters
elementThe element to test.
check_roundoffIf true, take into consideration the acceptable round-off error due to the double-to-single precision conversion.

◆ IsSafeForSinglePrecision() [2/2]

static bool HUtility::IsSafeForSinglePrecision ( int  element_count,
double const *  elements,
bool  check_roundoff = false 
)
inlinestatic

This method checks whether a double precision matrix can be safely stored as a single precision matrix

Parameters
element_countThe length of elements.
elementsThe elements of a matrix.
check_roundoffIf true, take into consideration the acceptable round-off error due to the double-to-single precision conversion.

◆ IsSegmentKey()

static bool HUtility::IsSegmentKey ( HC_KEY  key)
static

This method determines if the given key belongs to a segment.

Parameters
keyThe key to identify.
Returns
True if the key is a segment key or false if it is not.

◆ LocalPixelsToWorld()

static void HUtility::LocalPixelsToWorld ( HCamera camera,
bool  righthanded,
float  xres,
float  yres,
int  xwpix,
int  ywpix,
float  result[] 
)
static

This method calculates the the transformation matrix for local pixels to world coordinates.

Parameters
cameraA pointer to the camera information.
righthandedPass true if the handedness setting is right or false if the handedness is left.
xresThe horizontal screen resolution.
yresThe vertical screen resolution.
xwpixThe number of horizontal pixels.
ywpixThe number of vertical pixels.
resultPass an array that can hold a 4 x 4 matrix. This method will return the transformation matrix.

◆ MakeViewSnapshot() [1/2]

static void HUtility::MakeViewSnapshot ( HBaseView view,
int  width,
int  height,
char **  data 
)
static

This method creates an image snapshot of the contents of a given view.

Parameters
viewA pointer to the view you want a snapshot of.
widthThe width of the image.
heightThe height of the image.
dataPass a double pointer so that HOOPS can return the character pointer used to store the image data. Note you must free this memory with delete [].

◆ MakeViewSnapshot() [2/2]

static void HUtility::MakeViewSnapshot ( HBaseView view,
HC_KEY  image_key 
)
static

This method creates an image snapshot of the contents of a given view.

Parameters
viewA pointer to the view you want a snapshot of.
image_keyto which we will render. Create this image before calling MakeViewSnapshot with this call: HC_KEY image_key = HC_KInsert_Image(0, 0, 0, "rgba", width, height, 0).

◆ MatrixToQuaternion()

static void HUtility::MatrixToQuaternion ( float  matrix[],
float  quaternion[] 
)
static

MatrixToQuaternion converts a 4 by 4 matrix to it's equivalent 4 by 1 vector in quaternion space.

Parameters
matrixA pointer to a 4 by 4 matrix of floating point values which typically represent a camera projection.
quaternionA pointer which contains the 4 by 1 vector of floating point values representing the matrix in quaternion space. This value is returned to the user.

◆ Merge_Shells()

static HC_KEY HUtility::Merge_Shells ( bool  do_recurse,
bool  delete_orig_shells = false,
bool  optimize_shell = true,
bool  generate_regions = false 
)
static

This method extracts all of the shells from the currently open segment and its children, and merges them into one.

Parameters
do_recurseA boolean value indicating if the children segments should also be searched for shells.
delete_orig_shellsPass true if you want the original shells to be deleted after the merge.
Returns
The key to the newly merged shell.

◆ Merge_Shells_Generate_Regions()

static HC_KEY HUtility::Merge_Shells_Generate_Regions ( int  num_shells,
HC_KEY *  shell_keys,
bool  delete_orig_shells = false 
)
static

This method merges the given shells into a single shell. The original shells are marked as regions in the merged shell.

Parameters
num_shellsThe number of elements in the shell_keys array.
shell_keysThe HOOPS keys of the shells to be merged.
delete_orig_shellsPass true if you want the original shells to be deleted after the merge.
Returns
The key to the newly merged shell.

◆ MergePointsIntoShell()

static void HUtility::MergePointsIntoShell ( int  num_shell_points,
HPoint  plist1[],
int  num_shell_facelist,
int  flist1[],
int  num_merge_points,
HPoint  merge_points[],
HPoint  merge_vectors[],
float  tolerance,
bool  AddExtraPoints,
int  newpoints[],
int *  newpointslen 
)
static

This method merges an array of points into a given shell.

Parameters
num_shell_pointsThe mumber of points in the shell
plist1The shell point list.
num_shell_facelistThe length of the face list
flist1The face list as described in #HC_Insert_Shell.
num_merge_pointsThe number of points to merge.
merge_pointsA pointer to an array of points to merge.
merge_vectorsAn optional vector array to find correct merge location on face.
tolerancePass a value that indicates if two points are within the tolerance distance, they will be merged into one point.
AddExtraPointsPass true to allow additional points to be added to improve tesselation.
newpointsPass an array for this method to populate with the newly created points.
newpointslenThis method returns length of the newpoints array after it has been populated.

◆ MergePolylines()

static void HUtility::MergePolylines ( )
static

This method merges all the polylines in the currently open segment.

◆ MergeShells()

static HC_KEY HUtility::MergeShells ( HC_KEY  shell1,
HC_KEY  shell2 
)
static

This method merges two shells into one.

Parameters
shell1The key to the first shell.
shell2The key to the secon shell.
Returns
The key of the newly merged shell.

◆ ModifyPushedAttribute()

static bool HUtility::ModifyPushedAttribute ( const char *  attName,
const char *  newStyle 
)
static

This method modifies the stored attribute in the currently open segment.
Example:
The stored attribute is "faces = red".
The newStyle is "lines = yellow".
The result is "faces = red, lines = yellow".

Parameters
attNameThe name of the stored attribute that needs to be modified.
newStyleThe modification string.
Returns
True if the stored attribute exists.

◆ MoveToTemp()

static void HUtility::MoveToTemp ( HC_KEY  movekey,
HC_KEY  tempkey 
)
static

This method moves a given segment to a temporary segment.

Parameters
movekeyThe segment you want to move.
tempkeyThe temporary segment to move to.

◆ MultiSmoothTransitions()

static void HUtility::MultiSmoothTransitions ( HBaseView m_pView,
int  num_keys,
HC_KEY *  seg_key,
float  new_matrix[],
HCamera new_camera = 0 
)
static

This method transitions multiple segments to multiple target modelling matrices. It uses quaternions to make the transition appear smooth.

Parameters
m_pViewA pointer to the HBaseView object.
num_keysThe number of segments in seg_key.
seg_keyA pointer to the array of segments to which the matrices should be applied.
new_matrixA pointer to an array of matrices to apply to the given segments.
new_cameraIf non-null, then the method will also smoothly transition the camera to this new camera.

◆ NameSegments()

static void HUtility::NameSegments ( HC_KEY &  key,
HBaseView view 
)
static

This method gives unique names to the passed segment and all its parents.

Parameters
keyThe key to the start segment.
viewA pointer to the HBaseView object.

◆ NormalizeDoublePrecisionVector()

static void HUtility::NormalizeDoublePrecisionVector ( double *  vector1)
static

NormalizeDoublePrecisionVector normalizes a double-precision vector in place so that its magnitude is 1.

Parameters
vector1A pointer to a double precision vector.

◆ OpenSegmentFromKey()

static HC_KEY HUtility::OpenSegmentFromKey ( HC_KEY  key,
char *  segment 
)
static

This method opens a segment with the given name underneath the segment given by key. If the segment doesn't exist, a new one is created.

Parameters
keyThe key of segment which contains the newly created/opened segment.
segmentThe name the segment you want to open.
Returns
The key to segment.

◆ OptimizeSegmentTree()

static void HUtility::OptimizeSegmentTree ( HC_KEY  old_seg_key,
HC_KEY *  new_seg_key,
bool  transform_shells = true,
bool  merge_shells = true,
bool  create_shell_regions = false 
)
static

This is currently an INTERNAL USE function that is in development. Walks down the tree starting with 'new_seg_key', and builds a new tree underneath a new segment identified by 'new_seg_key'. The 'old_seg_key' contents are flushed. The logic groups graphical primtives into segments based on attributes, and transforms primitives and merges shells depending on the passed-in parameters.

Parameters
old_seg_keyHOOPS key of the segment tree to be optimized
new_seg_keyHOOPS key of the top of the new segment tree; this is a subsegment of the 'old_seg_key'. Passed by reference, returned to user.
transform_shellsA boolean value indicating that shell points should be xformed through any local modeling matrix
merge_shellsA boolean value indicating that shells in each of the final segments should be merged into a single shell
create_shell_regionsA boolean value indicating that if original shells were merged, to mark them as regions in the final shell

◆ Order()

static void HUtility::Order ( HPoint one,
HPoint two 
)
static

This method orders the input points in each dimension. The resulting points are minimum and maximum for bounding box input.

Parameters
oneA pointer to the first point to order.
twoA pointer to the second point to order.

◆ PointsEqual()

static bool HUtility::PointsEqual ( HPoint point1,
HPoint point2 
)
static

PointsEqual compares the equality of two (x,y,z) points.

Parameters
point1A pointer to the first point to compare.
point2A pointer to the second point to compare.
Returns
True if the points are equal or false if they aren't.

◆ PopAttribute()

static bool HUtility::PopAttribute ( const char *  attName)
static

This method replaces the requested attribute in the currently open segment with the stored attribute found in user options. The stored user option associated with that attribute will be deleted.

Parameters
attNameThe name of the attribute that needs to be stored. The currently supported attribute names are color, visibility, rendering options and edge weight.
Returns
True if the stored attribute exists or false if it doesn't.

◆ ProjectShell()

static void HUtility::ProjectShell ( HC_KEY  shellkey)
static

This method projects the given shell to the net modelling matrix of the current segment.

Parameters
shellkeyThe key to the shell.

◆ PushAttribute() [1/2]

static bool HUtility::PushAttribute ( const char *  attName)
static

This method stores a local attribute as a user option in the currently open segment for later retrieval. This is useful for processes like highlighting and selection.

Parameters
attNamename of the attribute that needs to be stored. The currently supported attribute names are color, visibility, rendering options and edge weight.
Returns
True if the local attribute exist or false if it doesn't.

◆ PushAttribute() [2/2]

static void HUtility::PushAttribute ( const char *  attName,
const char *  attText 
)
static

This method stores a local attribute as a user option in the currently open segment for later retrieval. This function takes the attribute as a string instead of getting it from the segment directly This is useful for processes like highlighting and selection.

Parameters
attNamename of the attribute that needs to be stored. The currently supported attribute names are color, visibility, rendering options and edge weight.
attTextThe attribute definition (e.g. "faces = red, edges = blue").

◆ QuaternionToMatrix()

static void HUtility::QuaternionToMatrix ( float  quaternion[],
float  matrix[] 
)
static

QuaternionToMatrix converts an 4 by 1 array of floating point values to its equivalent 4 by 4 matrix in cartesian space.

Parameters
quaternionA pointer which contains the 4 by 1 vector of floating point values representing the matrix in quaternion space.
matrixA pointer to a 4 by 4 matrix of floating point values which typically represent a camera projection. This value is returned to the user.

◆ ReadjustTarget()

static void HUtility::ReadjustTarget ( HBaseView view)
static

This method resets the camera target to be in the center of the current view.

Parameters
viewA pointer to the HBaseView Object.

◆ Recursive_Merge_Shells()

static void HUtility::Recursive_Merge_Shells ( HShell total_info,
HShell max_info,
bool  do_recurse,
bool  delete_orig_shells = false,
bool  insert_null_lods = false 
)
static

This method steps through the child segments, and merges all of the shells into one. Note that this method assumes that the proper amount of memory has been allocated. You can use Segment_Shell_Allocate to allocate the correct amount of memory.

Parameters
total_infoA pointer to where the newly merged shell.
max_infoA pointer to the largest shell data.
do_recursePass true to recurse through the segment tree beneath or false to only merge shells in the currently open segment.
delete_orig_shellsPass true to delete original shells that have been merged or false to keep them.
insert_null_lodsPass true to insert placeholder LODs.

◆ RegisterCallbacks()

static void HUtility::RegisterCallbacks ( )
static

This method register callbacks for HUtility with the HImManager.

◆ RenameSegment()

static void HUtility::RenameSegment ( HC_KEY  segkey,
const char *  newname 
)
static

This method renames a segment given by the key.

Parameters
segkeyThe key to the segment you want to rename.
newnameThe new name of the segment.

◆ RLECompress()

static bool HUtility::RLECompress ( int const  in_len,
unsigned char const *const  in_buf,
int *  out_len,
unsigned char *const  out_buf 
)
static

This method compresses the given data using RLE, run length encoding.

Parameters
in_lenThe length of the input buffer.
in_bufA pointer to the data to be compressed.
out_lenPass the length of the output buffer. When this method returns, it will populate the out_len with the value of the lenght of the compressed data.
out_bufPass a pointer so that this method can return where the output data is to be stored. This can be the same as in_buf if you want to do an in place compresion..
Returns
True if the operation is was success or false if it failed.

◆ RotateToVector()

static void HUtility::RotateToVector ( HPoint  start,
HPoint  end,
bool  doTranslation = true 
)
static

This method rotates the contents of the currently opened segment to a given vector in space.

Parameters
startThe first point in space that defines vector.
endThe second point in space that defines vector.
doTranslationPass to perform translation in the segment via #HC_Translate_Object.

◆ SafeSetUserOption()

static bool HUtility::SafeSetUserOption ( const char *  opt)
static

This method acts as a wrapper around HC_Set_User_Options and protects and validates input to it. It acts on the currently open segment.

Parameters
optThe user option to be input.
Returns
true if the option was set successfully, false otherwise.

◆ SafeShowUserOption()

static bool HUtility::SafeShowUserOption ( char *  opt)
static

This method acts as a wrapper around HC_Show_User_Options and strips out extra characters inserted by SafeSetUserOption. It acts on the currently open segment.

Parameters
optThe user option (if any). Returned to user.
Returns
true if a user option was found, false otherwise.

◆ Segment_Shell_Allocate()

static bool HUtility::Segment_Shell_Allocate ( HShell total_info,
HShell max_info,
bool  do_recurse 
)
static

This method allocates memory for merging the shells contained below the segment open in the current segment tree for use in method like Recursive_Merge_Shells.

Parameters
total_infoPass a pointer in which this method can allocate memory large enough to hold all the shell data.
max_infoPass a pointer in which this method will allocate memory large enough to hold the largest shell data.
do_recursePass true if you want the segment to be recursively searched for shells and allocated memory for.

◆ SegmentExists()

static bool HUtility::SegmentExists ( const char *  segment)
static

This method determines if the segment with given name exists underneath the currently open segment.

Parameters
segmentThe name of the segment to test existence for.
Returns
True if the segment does exist underneath the currently open segment or false if it doesn't.

◆ SelectUnderCursor()

static HC_KEY HUtility::SelectUnderCursor ( HBaseView view,
float  x,
float  y,
bool  doSelection = true,
bool  DeSelect = false 
)
static

Deprecated. Please use SmartSelectUnderCursor. Puts item under cursor in selection list.

Parameters
viewPointer to HBaseView Object.
xWindow X Coordinate for selection testing
yWindow Y Coordinate for selection testing
doSelectionAdd Geometry to Selection List
DeSelectDe Select Geometry if already selected
Returns
Key to selected geometry

◆ SetScaleIndependentGeomPosition()

static void HUtility::SetScaleIndependentGeomPosition ( HC_KEY  segkey,
float  x,
float  y,
float  z 
)
static

This is for internal use only.

◆ Shell_Search()

static void HUtility::Shell_Search ( HShell total_info,
HShell max_info,
bool  do_recurse 
)
static

This method is a helper function to Segment_Shell_Allocate. It finds how much memory is necessary for the current and child segments shells.

Parameters
total_infoA pointer to the HShell that should be big enough to hold all the data for all of the shells put together.
max_infoA pointer to the HShell that should be big enough for the largest shell.
do_recursePass true for the segment to be recursively searched for shells.

◆ ShowContentsWithPath()

static void HUtility::ShowContentsWithPath ( const char *  entitytypes,
struct vlist_s **  ret_pathlist,
bool  storePath = false,
bool  includeIncludes = true,
bool  filterIncludes = true 
)
static

This method recursively finds all entities in and below the current segment and returns each entity with its complete segment path.

Parameters
entitytypesThe entities to search for.
ret_pathlistPass a pointer to a vlist. This method will populate it with all found entities. Each list element is a pointer to a HShowContentsWithPathType structure and needs to be freed by the caller.
storePathPass true if you want to the method to store the complete path in addition to entity key.
includeIncludesPass true to search included segments.
filterIncludesPass true to filter include keys from the list.

◆ ShowModellingMatrix()

static void HUtility::ShowModellingMatrix ( float *  segment_modelling_matrix)
static

This method returns the modelling matrix of the currently open segment or identity matrix in none exists.

Parameters
segment_modelling_matrixPass a pointer to an array that can hold a 4 x 4 matrix. The method will populate it with the values of the currently opened segment's modelling matrix.

◆ ShowNormals()

static void HUtility::ShowNormals ( HC_KEY  shellkey,
float  normallength 
)
static

This method renders the normals of a given shell as lines.

Parameters
shellkeyThe key of the shell to show the normals for.
normallengthThe length of the lines that will be rendered to represent the normals.

◆ ShowOneHeuristic()

static bool HUtility::ShowOneHeuristic ( const char *  type,
char *  res = 0 
)
static

This method shows the specificed heuristic setting in the currently open segment.

Parameters
typeThe heuristic Setting to query (e.g. "quick moves").
resThe result of query (e.g. "spriting").
Returns
True if the heuristic setting is set or false if it is not set.

◆ ShowOneRenderingOption()

static bool HUtility::ShowOneRenderingOption ( const char *  type,
char *  res = 0 
)
static

This method shows the specified rendering option setting in the currently open segment.

Parameters
typeThe rendering option setting to query (e.g. "lighting interpolation").
resThe result of the query (e.g. "phong")
Returns
True if the rendering option setting is set or false if it is not set.

◆ ShowOneUserOption()

static bool HUtility::ShowOneUserOption ( const char *  option,
char *  res 
)
static

This method shows the specified user option in the currently opened segment.

Parameters
optionThe user option to search for.
resThe result of the query.
Returns
True if the user option setting is set or false if it is not set.

◆ ShowPushedAttribute()

static bool HUtility::ShowPushedAttribute ( const char *  attName,
HUserOptions attText 
)
static

This method retrieves the stored attribute in the currently open segment if present.

Parameters
attNameThe name of the stored attribute that needs to be retrieved.
attTextThis method returns the attribute string.
Returns
True if the stored attribute exists or false if it doesn't exist.

◆ SmartSelectUnderCursor()

static HC_KEY HUtility::SmartSelectUnderCursor ( HBaseView view,
float  x,
float  y,
bool  doSelection = true,
bool  DeSelect = false 
)
static

This method puts the item under cursor in the selection list. This api uses improved selection capability which helps the selection set deal with instanced segments and entities.

Parameters
viewA pointer to HBaseView Object.
xThe window x coordinate for the selection testing.
yWindow Y Coordinate for selection testing.
doSelectionAdd Geometry to Selection List.
DeSelectPass true to deselect the geometry if it already selected.
Returns
The key to the selected geometry.

◆ SmoothMatrixTransition()

static void HUtility::SmoothMatrixTransition ( HBaseView m_pView,
HC_KEY  seg_key,
float  new_matrix[] 
)
static

This method transitions an object to the target modelling matrix. It uses quaternions to make the transition appear smooth.

Parameters
m_pViewA pointer to the HBaseView object.
seg_keyThe key of the segment to which the matrix should be applied.
new_matrixThe matrix to apply to the segment.

◆ SmoothQuaternionTransition()

static void HUtility::SmoothQuaternionTransition ( HBaseView m_pView,
char *  old_seg,
char *  new_seg,
int  num_of_transitions 
)
static

This method animates the rotation of an object from the object space of one segment to the object space of another. It uses quaternions to make the transition appear smooth.

Parameters
m_pViewA pointer to the HBaseView object.
old_segThe segment from which the transition should occur.
new_segThe segment which has the modelling matrix which we want to transition to.
num_of_transitionsThe numer of frames in the animation.

◆ SmoothTransition() [1/2]

static void HUtility::SmoothTransition ( const HPoint co,
const HPoint to,
const HPoint uo,
float  fieldwidtho,
float  fieldheighto,
const HPoint cn,
const HPoint tn,
const HPoint un,
float  fieldwidthn,
float  fieldheightn,
HBaseView view 
)
static

SmoothTransition takes two camera definitions and uses quaternions to smoothly move the camera on the HBaseView object from the first camera position to the next.

Parameters
coThe initial camera position.
toThe initial camera target.
uoThe initial camera up vector.
fieldwidthoThe initial camera field width.
fieldheightoThe initial camera field heigth.
cnThe final camera position.
tnThe final camera target.
unThe final camera up vector.
fieldwidthnThe final camera field width.
fieldheightnThe final camera field heigth.
viewA pointer to the HBaseView object you want the camera movements to be applied.

◆ SmoothTransition() [2/2]

static void HUtility::SmoothTransition ( HCamera  old_camera,
const HCamera new_camera,
HBaseView view 
)
static

SmoothTransition takes two camera definitions and uses quaternions to smoothly move the camera on the HBaseView object from the first camera position to the next.

Parameters
old_cameraThe initial camera definition.
new_cameraThe final camera definition.
viewA pointer to the HBaseView object you want the camera movements to be applied.

◆ strlen16()

static int HUtility::strlen16 ( const unsigned short *  p16)
static

This method calculates the length of the give 16-bit string.

Parameters
p16The 16-bit character string.
Returns
The string length.

◆ SubdivideShells()

static void HUtility::SubdivideShells ( HC_KEY  sskey,
HC_KEY  startkey,
HC_KEY  newkey,
int  numx,
int  numy,
int  numz,
ShellToRegionMapper mapper = 0,
bool  DoCut = true,
bool  DeleteOriginalShells = false,
bool  breakShells = false 
)
static

This function is still in development. Given a segment, this method subdivides the shells found into smaller shells according to how they are situated spatially. Given a cube that is divided into smaller sections, the new shells are created such that they are bounded by these smaller sections.

Parameters
startkeyThe key of segment to search for shells in.
newkeykey of segment to place subdivided geometry in.
numxThe subdivision sections in the X direction.
numyThe subdivision sections in Y direction.
numzThe subdivision sections in Z direction.
DoCutPass true to cut a shell that lies in between multiple sections or false to keep it in tact. Note that if you pass true, the image may not appear as seamless as the original.
DeleteOriginalShellsPass true to delete the original shells or false to leave them.
breakshells

◆ SuppressAnimation()

static void HUtility::SuppressAnimation ( )
static

This method sets the user option to suppress animation for the currently opened segment.

◆ TransitionQuaternion()

static void HUtility::TransitionQuaternion ( float  quat_old[],
float  quat_new[],
float  t,
float  qt[] 
)
static

TransitionQuaternion takes a start and end quaternion which represent two orientations in cartesian space. Based on a value t between 0 and 1, it comes up with a third quaternion vector that represents an orientation in cartesian space which is along the shortest, smooth path between the two initial orientations.

Parameters
quat_oldAn array of 4 by 1 floats representing the starting orientation in quaterion space.
quat_newAn array of 4 by 1 floats representing the final orientation in quaterion space.
tA floating point value between 0 and 1 indicating the amount you want the returned quaternion to be along the interpolated path.
qtA pointer which contains the 4 by 1 vector of the floating point values representing the transition quaternion. This value is returned to the user.

◆ TwoPassPrint()

static HFileOutputResult HUtility::TwoPassPrint ( const char *  driver,
HOutputHandlerOptions options 
)
static

This method performs a two pass print.

Parameters
driverThe driver to print to.
optionsA pointer to the options structure containing miscellaneous options.
Returns
The result of the printings.

◆ uconvert()

static unsigned short* HUtility::uconvert ( const char *  text)
static

This method converts an 8-bit string to a unicode string.

Parameters
textThe 8-bit string to convert.
Returns
A pointer to the newly created unicode string.

◆ unicode_to_ascii()

static void HUtility::unicode_to_ascii ( unsigned short const *  unicode,
char *  ascii 
)
static

This method converts a unicode string into an ASCII string. Please use H_ASCII_TEXT in place of this function as this may be removed in the next release.

Parameters
unicodeThe unicode string you want to convert.
asciiA pointer to the array that will hold the converted ASCII String. Note this array shold be at least as long as the unicode string.

◆ UnsetAttributes()

static void HUtility::UnsetAttributes ( )
static

The method unsets various attributes in current segment. Currently, it unsets visibility, heuristics, and rendering options.

◆ UnwindIncludes() [1/2]

static void HUtility::UnwindIncludes ( HC_KEY &  key)
static

From the current selection, this method walks up the segment tree until all includes are resolved.

Parameters
keySegment to unwind from.

◆ UnwindIncludes() [2/2]

static void HUtility::UnwindIncludes ( HC_KEY &  newkey,
HC_KEY *  keys,
int  count 
)
static

This method is a helper function for UnwindIncludes(HC_KEY &key).

Parameters
newkeyThe key to unwind from.
keysThe list of keys in the selection list.
countThe number of keys in the selection list.

◆ URIdecode()

static void HUtility::URIdecode ( const char *  in_string,
char *  out_buffer,
MVO_POINTER_SIZED_UINT *  n 
)
static

This function decodes a URI encoded string.

Parameters
in_stringA null terminated encoded string.
out_bufferA write back buffer of size strlen(in)+1 after call this contains unencoded string.
nA write back value with the length of the out_buffer.

◆ URIencode()

static void HUtility::URIencode ( const char *  in_string,
MVO_POINTER_SIZED_UINT  n,
char *  out_buffer 
)
static

This function takes an char buffer and create a URI encoded string.

Parameters
in_stringA unencoded string.
nThe length of the in buffer.
out_bufferA write back buffer of size 3*n+1.

◆ UserOptionExists()

static HC_KEY HUtility::UserOptionExists ( HC_KEY  key,
const char *  attrib,
char *  result 
)
static

This method determine if user options exists in or above the current segment.

Parameters
keyThe segment to begin the search.
attribThe attribute to search for.
resultThe attribute value of user option if it exists.
Returns
The highest segment where the user option was set or INVALID_KEY if no option existed.

◆ ustrlen()

static int HUtility::ustrlen ( unsigned short *  text)
static

This method returns the size of the unicode string.

Parameters
textThe unicode text string.
Returns
Size of the string excluding the delimiter.

◆ ZlibCompress()

static bool HUtility::ZlibCompress ( int const  in_len,
unsigned char const *const  in_buf,
int &  out_len,
unsigned char *const  out_buf 
)
static

This method compresses the input buffer using the 'zlib' compression library.

Parameters
in_lenThe length of the input buffer.
in_bufThe data to be compressed.
out_lenPass the length of the output buffer. On return, out_len is the length of the compressed data.
out_bufThe output data is stored here. To do an in place compression, you can pass the same pointer as in_buf.
Returns
True if the operation was a success or false if it failed.

◆ ZlibDecompress()

static bool HUtility::ZlibDecompress ( int const  in_len,
unsigned char const *const  in_buf,
int &  out_len,
unsigned char *const  out_buf 
)
static

This method decompresses the input buffer using the 'zlib' compression library.

Parameters
in_lenThe length of the input buffer.
in_bufThe data to be decompressed.
out_lenPass the length of the output buffer. On return, out_len is the length of the decompressed data.
out_bufThe output data is stored here. To do an in place decompression, you can pass the same pointer as in_buf.
Returns
True if the operation was a success or false if it failed.

The documentation for this class was generated from the following file: