Open CASCADE Technology 6.6.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
NIS_Triangulated Class Reference

#include <NIS_Triangulated.hxx>

Inheritance diagram for NIS_Triangulated:
Inheritance graph
[legend]

Public Types

enum  PolygonType { Polygon_Default = 0, Polygon_Line = 1, Polygon_Fill = 2 }

Public Member Functions

 NIS_Triangulated (const Standard_Integer nNodes=0, const Standard_Boolean is2D=Standard_False, const Handle_NCollection_BaseAllocator &theAlloc=0L)
void SetPolygonsPrs (const Standard_Integer nPolygons, const Standard_Integer nNodes=0)
void SetTriangulationPrs (const Standard_Integer nTriangles, const Standard_Integer nNodes=0)
void SetLinePrs (const Standard_Integer nPoints, const Standard_Boolean isClosed, const Standard_Integer nNodes=0)
void SetSegmentPrs (const Standard_Integer nSegments, const Standard_Integer nNodes=0)
Standard_Boolean IsTriangulation () const
Standard_Boolean IsPolygons () const
Standard_Boolean IsLine (Standard_Boolean &isLoop) const
Standard_Boolean IsSegments () const
void Clear ()
virtual ~NIS_Triangulated ()
virtual NIS_DrawerDefaultDrawer (NIS_Drawer *) const
void SetNode (const Standard_Integer ind, const gp_XYZ &thePnt)
void SetNode (const Standard_Integer ind, const gp_XY &thePnt)
void SetTriangle (const Standard_Integer ind, const Standard_Integer iNode0, const Standard_Integer iNode1, const Standard_Integer iNode2)
void SetPolygon (const Standard_Integer ind, const Standard_Integer theSz)
void SetLineNode (const Standard_Integer ind, const Standard_Integer iNode)
Standard_Integer NNodes () const
Standard_Integer NTriangles () const
Standard_Integer NLineNodes () const
Standard_Integer NPolygons () const
const Standard_ShortRealNode (const Standard_Integer ind) const
void SetPolygonNode (const Standard_Integer indPoly, const Standard_Integer ind, const Standard_Integer iNode)
Standard_Integer PolygonNode (const Standard_Integer indPoly, const Standard_Integer ind) const
Standard_Integer NPolygonNodes (const Standard_Integer indPoly) const
void SetDrawPolygons (const Standard_Boolean isDrawPolygons)
void SetPolygonType (const PolygonType theType)
void SetColor (const Quantity_Color &theColor)
Quantity_Color GetColor (const NIS_Drawer::DrawType theDrawType) const
void SetHilightColor (const Quantity_Color &theColor)
void SetDynHilightColor (const Quantity_Color &theColor)
void SetLineWidth (const Standard_Real theWidth)
virtual void Clone (const Handle_NCollection_BaseAllocator &theAll, Handle_NIS_InteractiveObject &theDest) const
virtual Standard_Real Intersect (const gp_Ax1 &theAxis, const Standard_Real theOver) const
virtual Standard_Boolean Intersect (const Bnd_B3f &theBox, const gp_Trsf &theTrf, const Standard_Boolean isFull) const
virtual Standard_Boolean Intersect (const NCollection_List< gp_XY > &thePolygon, const gp_Trsf &theTrf, const Standard_Boolean isFullIn) const
virtual void Delete () const

Static Public Member Functions

static int tri_line_intersect (const double start[3], const double dir[3], const float V0[3], const float V1[3], const float V2[3], double *tInter)
static int tri2d_line_intersect (const double start[3], const double dir[3], const float V0[2], const float V1[2], const float V2[2], double *tInter)
static int seg_line_intersect (const gp_XYZ &aStart, const gp_XYZ &aDir, const double over2, const float V0[3], const float V1[3], double *tInter)
static int seg2d_line_intersect (const gp_XYZ &aStart, const gp_XYZ &aDir, const double over2, const float V0[2], const float V1[2], double *tInter)
static int seg_box_intersect (const Bnd_B3f &theBox, const gp_Pnt thePnt[2])
static int seg_box_included (const Bnd_B3f &theBox, const gp_Pnt thePnt[2])
static int seg_polygon_intersect (const NCollection_List< gp_XY > &thePolygon, const gp_XY thePnt[2])
static int seg_polygon_included (const NCollection_List< gp_XY > &thePolygon, const gp_XY thePnt[2])
static void ComputeBox (Bnd_B3f &theBox, const Standard_Integer nNodes, const Standard_ShortReal *pNodes, const Standard_Integer nCoord)
static Standard_Boolean IsIn (const NCollection_List< gp_XY > &thePolygon, const gp_XY &thePoint)

Protected Types

enum  {
  Type_None = 0, Type_Loop = 1, Type_Line = 2, Type_Segments = 4,
  Type_Triangulation = 8, Type_Polygons = 16
}

Protected Member Functions

virtual void computeBox ()
void allocateNodes (const Standard_Integer nNodes)
gp_Pnt nodeAtInd (const Standard_Integer *theArr, const Standard_Integer i) const
float * nodeArrAtInd (const Standard_Integer *theArr, const Standard_Integer i) const

Protected Attributes

NCollection_BaseAllocatormyAlloc
 Usually from InteractiveContext.
Standard_Integer myType
 Combination of Type_* constants.
Standard_ShortRealmypNodes
Standard_IntegermypTriangles
Standard_IntegermypLines
Standard_Integer ** mypPolygons
Standard_Integer myNNodes
Standard_Integer myNTriangles
Standard_Integer myNLineNodes
unsigned int myNPolygons: 24
Standard_Boolean myIsDrawPolygons: 1
Standard_Boolean myIsCloned: 1
 How it is allocated.
unsigned int myIndexType: 2
 0:8bit, 1:16bit, 2:32bit
unsigned int myNodeCoord: 2
 2 or 3 coordinates
unsigned int myPolygonType: 2

Detailed Description

Interactive object that consists of triangles, lines and polygons without normals. Particularly can be used to render planar 2D shapes.

2D and 3D model
Vertices are stored in an array of float numbers, 2 or 3 numbers per vertex. The number of dimensions is defined in the constructor, see the parameter 'is2D'. When 2D is defined then for all vertices the Z coordinate is 0. To display planar objects in a plane different from XOY you should subclass this type together with the correponding Drawer and store the transformation parameters. In Drawer subclass either in method BeforeDraw() or in method Draw() you would call glTranslate() or glMultMatrix() so that all vertices should be located in their proper positions.
Compressed storage
For efficient memory utilization, indice (triangles, segments, polygons) are 8-bit, 16-bit or 32-bit numbers. The width of this numeric representation is chosen automatically when the total number of nodes is passed in the constructor or in any Set* method. For example, if this number of nodes is smaller than 256 then 8-bit representation is selected. The choice is stored in 'myIndexType' data member.

Member Enumeration Documentation

anonymous enum [protected]

Constants defining the mode (type) of presentation. They allow mixed type, e.g., Triangulation+Line. Line and Segments are not mixable, their mix is treated as Line only.

Enumerator:
Type_None 
Type_Loop 

modifier to Line

Type_Line 
Type_Segments 
Type_Triangulation 
Type_Polygons 

Enumerated type of polygon rendering.

Enumerator:
Polygon_Default 

Polygon as LINE, Triangulation as FILL.

Polygon_Line 

Both Polygon and Triangulation as LINE.

Polygon_Fill 

Both Polygon and Triangulation as FILL.


Constructor & Destructor Documentation

NIS_Triangulated::NIS_Triangulated ( const Standard_Integer  nNodes = 0,
const Standard_Boolean  is2D = Standard_False,
const Handle_NCollection_BaseAllocator &  theAlloc = 0L 
)

Constructor. Optionally defines the number of nodes that will be allocated (this number may be defined later in methods Set*Prs) as well as the memory allocator where the nodes, lines and triangles will be stored by this instance.

Parameters:
nNodesTotal number of nodes that will be initialized for this object
is2DIf true then the nodes will be 2D in plane Z=0, otherwise normal 3D.
theAllocAllocator for internal data
virtual NIS_Triangulated::~NIS_Triangulated ( ) [virtual]

Destructor.


Member Function Documentation

void NIS_Triangulated::allocateNodes ( const Standard_Integer  nNodes) [protected]

Create the memory buffer for the declared number of nodes, old nodes are deallocated.

void NIS_Triangulated::Clear ( )

Reset all data memebers and free all allocated memory. Called from the destructor, also can be usedto re-initialize a given Interactive Objects.

virtual void NIS_Triangulated::Clone ( const Handle_NCollection_BaseAllocator &  theAll,
Handle_NIS_InteractiveObject &  theDest 
) const [virtual]

Create a copy of theObject except its ID.

Parameters:
theAllAllocator where the Dest should store its private data.
theDest[in-out] The target object where the data are copied. If passed NULL then the target should be created.

Reimplemented from NIS_InteractiveObject.

static void NIS_Triangulated::ComputeBox ( Bnd_B3f theBox,
const Standard_Integer  nNodes,
const Standard_ShortReal pNodes,
const Standard_Integer  nCoord 
) [static]
virtual void NIS_Triangulated::computeBox ( ) [protected, virtual]

Allocator-based operator new for dynamic allocations in method Clone() Create a 3D bounding box of the object.

Implements NIS_InteractiveObject.

virtual NIS_Drawer* NIS_Triangulated::DefaultDrawer ( NIS_Drawer ) const [virtual]

Create a default drawer instance.

Implements NIS_InteractiveObject.

virtual void NIS_Triangulated::Delete ( ) const [virtual]

Implements deallocation of the object instance

Reimplemented from Standard_Transient.

Quantity_Color NIS_Triangulated::GetColor ( const NIS_Drawer::DrawType  theDrawType) const

Get Normal, Transparent or Hilighted color of the presentation.

Parameters:
theDrawTypeThe draw type, for which the color is retrieved.
virtual Standard_Real NIS_Triangulated::Intersect ( const gp_Ax1 theAxis,
const Standard_Real  theOver 
) const [virtual]

Intersect the InteractiveObject geometry with a line/ray.

Parameters:
theAxisThe line or ray in 3D space.
theOverHalf-thickness of the selecting line.
Returns:
If the return value is more than 0.1*RealLast() then no intersection is detected. Otherwise returns the coordinate of thePnt on the ray. May be negative.

Implements NIS_InteractiveObject.

virtual Standard_Boolean NIS_Triangulated::Intersect ( const Bnd_B3f theBox,
const gp_Trsf theTrf,
const Standard_Boolean  isFull 
) const [virtual]

Intersect the InteractiveObject geometry with an oriented box.

Parameters:
theBox3D box of selection
theTrfPosition/Orientation of the box.
isFullTrue if full inclusion is required, False - if partial.
Returns:
True if the InteractiveObject geometry intersects the box or is inside it

Reimplemented from NIS_InteractiveObject.

virtual Standard_Boolean NIS_Triangulated::Intersect ( const NCollection_List< gp_XY > &  thePolygon,
const gp_Trsf theTrf,
const Standard_Boolean  isFullIn 
) const [virtual]

Intersect the InteractiveObject geometry with a selection polygon.

Parameters:
thePolygonthe list of vertices of a free-form closed polygon without self-intersections. The last point should not coincide with the first point of the list. Any two neighbor points should not be confused.
theTrfPosition/Orientation of the polygon.
isFullInTrue if full inclusion is required, False - if partial.
Returns:
True if the InteractiveObject geometry intersects the polygon or is inside it

Reimplemented from NIS_InteractiveObject.

static Standard_Boolean NIS_Triangulated::IsIn ( const NCollection_List< gp_XY > &  thePolygon,
const gp_XY thePoint 
) [static]

Classification of thePoint with respect to thePolygon.

Parameters:
thePolygonthe list of vertices of a free-form closed polygon without self-intersections. The last point should not coincide with the first point of the list. Any two neighbor points should not be confused.
thePointthe point to be classified.
Returns:
Standard_True if thePoint in inside thePolygon or lies on its boundary.
Standard_Boolean NIS_Triangulated::IsLine ( Standard_Boolean isLoop) const [inline]

Query if there is Line component in the presentation.

Standard_Boolean NIS_Triangulated::IsPolygons ( ) const [inline]

Query if there is Polygons component in the presentation.

Standard_Boolean NIS_Triangulated::IsSegments ( ) const [inline]

Query if there is Segments component in the presentation.

Standard_Boolean NIS_Triangulated::IsTriangulation ( ) const [inline]

Query if there is Triangulation component in the presentation.

Standard_Integer NIS_Triangulated::NLineNodes ( ) const [inline]

Query the number of line points.

Standard_Integer NIS_Triangulated::NNodes ( ) const [inline]

Query the number of nodes.

const Standard_ShortReal* NIS_Triangulated::Node ( const Standard_Integer  ind) const [inline]

Query the node by its index.

Returns:
pointer to array of 2 or 3 Standard_ShortReal values {X,Y(,Z) coord}
float* NIS_Triangulated::nodeArrAtInd ( const Standard_Integer theArr,
const Standard_Integer  i 
) const [protected]

Get the node pointed by the i-th index in the array.

gp_Pnt NIS_Triangulated::nodeAtInd ( const Standard_Integer theArr,
const Standard_Integer  i 
) const [protected]

Get the node pointed by the i-th index in the array.

Standard_Integer NIS_Triangulated::NPolygonNodes ( const Standard_Integer  indPoly) const

Get the number of nodes for the polygon number 'indPoly'.

Standard_Integer NIS_Triangulated::NPolygons ( ) const [inline]

Query the number of polygons.

Standard_Integer NIS_Triangulated::NTriangles ( ) const [inline]

Query the number of triangles.

Standard_Integer NIS_Triangulated::PolygonNode ( const Standard_Integer  indPoly,
const Standard_Integer  ind 
) const

Get the node with index 'ind' from the polygon number 'indPoly'.

static int NIS_Triangulated::seg2d_line_intersect ( const gp_XYZ aStart,
const gp_XYZ aDir,
const double  over2,
const float  V0[2],
const float  V1[2],
double *  tInter 
) [static]
static int NIS_Triangulated::seg_box_included ( const Bnd_B3f theBox,
const gp_Pnt  thePnt[2] 
) [static]
static int NIS_Triangulated::seg_box_intersect ( const Bnd_B3f theBox,
const gp_Pnt  thePnt[2] 
) [static]
static int NIS_Triangulated::seg_line_intersect ( const gp_XYZ aStart,
const gp_XYZ aDir,
const double  over2,
const float  V0[3],
const float  V1[3],
double *  tInter 
) [static]
static int NIS_Triangulated::seg_polygon_included ( const NCollection_List< gp_XY > &  thePolygon,
const gp_XY  thePnt[2] 
) [static]
static int NIS_Triangulated::seg_polygon_intersect ( const NCollection_List< gp_XY > &  thePolygon,
const gp_XY  thePnt[2] 
) [static]
void NIS_Triangulated::SetColor ( const Quantity_Color theColor)

Set the normal color for presentation.

Parameters:
theColorNew color to use for the presentation.
void NIS_Triangulated::SetDrawPolygons ( const Standard_Boolean  isDrawPolygons)

Set the boolean flag defining if the polygons or the triangulation should be drawn. This method does not affect the presentation of Line/Segments.

Parameters:
isDrawPolygonsTrue defines that no triangulation is drawn, only polygons are. False defines that only triangulation is drawn, no polygons.
void NIS_Triangulated::SetDynHilightColor ( const Quantity_Color theColor)

Set the color for dynamic hilight presentation.

Parameters:
theColorNew color to use for the presentation.
void NIS_Triangulated::SetHilightColor ( const Quantity_Color theColor)

Set the color for hilighted presentation.

Parameters:
theColorNew color to use for the presentation.
void NIS_Triangulated::SetLineNode ( const Standard_Integer  ind,
const Standard_Integer  iNode 
)

Define the line node by index.

void NIS_Triangulated::SetLinePrs ( const Standard_Integer  nPoints,
const Standard_Boolean  isClosed,
const Standard_Integer  nNodes = 0 
)

Define the line presentration (polygon through points)

Parameters:
nPointsNumber of nodes defining the line. If set to 0, line is cancelled
isClosedTrue if the polygon is closed, so the segment between the first and the last points is created automatically.
nNodesOptional: Number of nodes to allocate. If left as 0, the previous nodes allocation is used, otherwise a new allocation is created.
void NIS_Triangulated::SetLineWidth ( const Standard_Real  theWidth)

Set the width of line presentations in pixels.

Parameters:
theWidthNew line width to use for the presentation.
void NIS_Triangulated::SetNode ( const Standard_Integer  ind,
const gp_XYZ thePnt 
)

Define the coordinates of node [ind].

void NIS_Triangulated::SetNode ( const Standard_Integer  ind,
const gp_XY thePnt 
)

Define the coordinates of node [ind]. Z coordinate is assigned to 0.

void NIS_Triangulated::SetPolygon ( const Standard_Integer  ind,
const Standard_Integer  theSz 
)

Allocate a single polygon, should be called for each polygon following the call SetPolygonsPrs(). The polygon can be filled by node indices using the method SetPolygonNode().

Parameters:
indIndex of the polygon, should be [0..Npolygons-1]
theSzNumber of points (segments) in the polygon.
void NIS_Triangulated::SetPolygonNode ( const Standard_Integer  indPoly,
const Standard_Integer  ind,
const Standard_Integer  iNode 
)

Define the node of a polygon by index.

Parameters:
indPolyIndex of the Polygon, should be less than the number of polygons that is defined in SetPolygonsPrs() and can be returned by NPOlygons().
indIndex of the node in the Polygon. Should be less than the parameter theSz in the corresponding previous SetPolygon() call.
iNodeIndex of the node in the given position of the Polygon.
void NIS_Triangulated::SetPolygonsPrs ( const Standard_Integer  nPolygons,
const Standard_Integer  nNodes = 0 
)

Define the polygonal presentration.

Parameters:
nPolygonsNumber of separate polygons. If set to 0, polygons are cancelled
nNodesOptional: Number of nodes to allocate. If left as 0, the previous nodes allocation is used, otherwise a new allocation is created.
void NIS_Triangulated::SetPolygonType ( const PolygonType  theType)

Set the type of polygon rendering.

void NIS_Triangulated::SetSegmentPrs ( const Standard_Integer  nSegments,
const Standard_Integer  nNodes = 0 
)

Define the segments presentration. Each segment is defined by 2 nodes

Parameters:
nSegmentsNumber of segments. If set to 0, segments presentation is cancelled
nNodesOptional: Number of nodes to allocate. If left as 0, the previous nodes allocation is used, otherwise a new allocation is created.
void NIS_Triangulated::SetTriangle ( const Standard_Integer  ind,
const Standard_Integer  iNode0,
const Standard_Integer  iNode1,
const Standard_Integer  iNode2 
)

Define the triangle [ind] by indices of its three nodes.

void NIS_Triangulated::SetTriangulationPrs ( const Standard_Integer  nTriangles,
const Standard_Integer  nNodes = 0 
)

Define the triangulated presentration.

Parameters:
nTrianglesNumber of triangles. If set to 0, triangulation is cancelled
nNodesOptional: Number of nodes to allocate. If left as 0, the previous nodes allocation is used, otherwise a new allocation is created.
static int NIS_Triangulated::tri2d_line_intersect ( const double  start[3],
const double  dir[3],
const float  V0[2],
const float  V1[2],
const float  V2[2],
double *  tInter 
) [static]
static int NIS_Triangulated::tri_line_intersect ( const double  start[3],
const double  dir[3],
const float  V0[3],
const float  V1[3],
const float  V2[3],
double *  tInter 
) [static]

Field Documentation

unsigned int NIS_Triangulated::myIndexType [protected]
unsigned int NIS_Triangulated::myNodeCoord [protected]
unsigned int NIS_Triangulated::myNPolygons [protected]
unsigned int NIS_Triangulated::myPolygonType [protected]

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines