HitMesh Class Reference

#include <osnaphit.h>

Class Description

See also
Class Osnap, The Advanced Topics section on Snapping..

Description:
This is a class to hold a list of object space points for highlighting the geometry associated with a hit. One oddity of this class is that you need to allocate one point more than the number of points you actually need. This additional storage is used for clipping against the viewport at display time. For example the "endpoint" snap would alocate a three-point hitmesh to highlight the edge which was hit (See the example below) .

The class has data members for the number of points and a pointer to the actual Point3 list.

In practice, developers need only use the first two methods shown below.
+ Inheritance diagram for HitMesh:

Public Member Functions

CoreExport HitMesh ()
 
CoreExport ~HitMesh ()
 
CoreExport HitMesh (const HitMesh &h)
 
CoreExport HitMesh (int n)
 
Point3 operator[] (int i)
 
int getNumVerts ()
 
CoreExport void setNumVerts (int n)
 
void setVert (int i, const Point3 &xyz)
 
Point3getVert (int i)
 
Point3getVertPtr ()
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

Remarks
Constructor. The number of points is set to zero and the point list is set to NULL.
Remarks
Destructor. If point list is allocated it is freed.
CoreExport HitMesh ( const HitMesh h)
Remarks
Constructor. The number of points and the points are initialized from the HitMesh passed.
Parameters:
const HitMesh& h

The HitMesh to init from.
Remarks
Constructor. The number of vertices is set to the value n passed and the points array is allocated with that size. This is the constructor that plugin developers will typically use in conjunction with the setVert() method described below.
Parameters:
int n

The number of points to allocate.

Member Function Documentation

Point3 operator[] ( int  i)
inline
Remarks
Access operator. Return the 'i-th' point.
Parameters:
int i

Specifies the point to return.
245 {return m_pverts[i];}
int getNumVerts ( )
inline
Remarks
Returns the number of points in this HitMesh.
247 {return m_numverts;}
CoreExport void setNumVerts ( int  n)
Remarks
Sets the number of vertices. This frees any existing verts and allocates new ones.
Parameters:
int n

The number of points to allocate.
void setVert ( int  i,
const Point3 xyz 
)
inline
Remarks
Sets the 'i-th' vertex to the specified value.
Parameters:
int i

The vertex to set.

const Point3 &xyz

The value to set.

In practice, developers need only use the two previous methods. The following code segment from the mesh snap exemplifies their use.

//add the hit points based on the active subsnaps
if(GetActive(EDGE_SUB)) // The edge snapping is active and we have a hit on the edge defined by from and to.
{
HitMesh *hitmesh = new HitMesh(3); //Allocate one more than we need.
hitmesh->setVert(0, from);
hitmesh->setVert(1, to);
float dap = Length(cursor - sf2);
assert(Length(st2 - sf2)>=0.0f);
float pct = (float)sqrt(fabs(dap*dap - distance*distance)) / Length(st2 - sf2);
Point3 cand;
float pctout = gw->interpWorld(&xyz[0],&xyz[1],pct,&cand);
theman->RecordHit(new EdgeHit(cand, this, EDGE_SUB, hitmesh, ifrom, ito, pct));
}
277 { m_pverts[i] = xyz; }
Point3& getVert ( int  i)
inline
Remarks
Returns the 'i-th' vertex.
279 {return m_pverts[i];}
Point3* getVertPtr ( )
inline
Remarks
Returns a pointer to the array of points.
Operators:
283 {return m_pverts;}