Public Member Functions

HitMesh Class Reference

Search for all occurrences

Detailed Description

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

Description:
This class is available in release 2.0 and later only.

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.

#include <osnaphit.h>

Inheritance diagram for HitMesh:
Inheritance graph
[legend]

List of all members.

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)
Point3 getVert (int i)
Point3 getVertPtr ()

Constructor & Destructor Documentation

CoreExport HitMesh ( )
Remarks:
Constructor. The number of points is set to zero and the point list is set to NULL.
CoreExport ~HitMesh ( )
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.
CoreExport HitMesh ( int  n )
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.
{return m_pverts[i];}
int getNumVerts ( void  ) [inline]
Remarks:
Returns the number of points in this HitMesh.
{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));
}
{ m_pverts[i] = xyz; }  
Point3& getVert ( int  i ) [inline]
Remarks:
Returns the 'i-th' vertex.
{return m_pverts[i];}
Point3* getVertPtr ( ) [inline]
Remarks:
Returns a pointer to the array of points.
Operators:
{return m_pverts;}

HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh
HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh HitMesh