Open CASCADE Technology  6.9.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
 
- Public Member Functions inherited from NIS_InteractiveObject
 NIS_InteractiveObject ()
 
virtual ~NIS_InteractiveObject ()
 
Standard_Integer ID () const
 
NIS_Drawer::DrawType DrawType () const
 
const Handle< NIS_Drawer > & SetDrawer (const Handle< NIS_Drawer > &theDrawer, const Standard_Boolean setUpdated=Standard_True)
 
const Handle< NIS_Drawer > & GetDrawer () const
 
const Bnd_B3fGetBox ()
 
Standard_Boolean IsTransparent () const
 
Standard_Boolean IsHidden () const
 
Standard_Boolean IsDisplayed () const
 
Standard_Boolean IsDynHilighted () const
 
virtual Standard_Boolean IsSelectable () const
 
virtual void SetSelectable (const Standard_Boolean isSel=Standard_True) const
 
Standard_ShortReal Transparency () const
 
void SetTransparency (const Standard_Real theValue=0.6)
 
void UnsetTransparency ()
 
void CloneWithID (const Handle< NCollection_BaseAllocator > &, Handle< NIS_InteractiveObject > &)
 
void SetAttribute (void *theAttributePtr)
 
void * GetAttribute () const
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual const
Handle_Standard_Type & 
DynamicType () const
 Returns a type information object about this object. More...
 
Standard_Boolean IsInstance (const Handle_Standard_Type &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const Handle_Standard_Type &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
virtual Handle_Standard_Transient This () const
 Returns a Handle which references this object. Must never be called to objects created in stack. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 

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 Member Functions inherited from NIS_InteractiveObject
void setDrawerUpdate () const
 
Standard_Boolean isUpdateBox () const
 
void setIsUpdateBox (const Standard_Boolean isUpdate)
 

Protected Attributes

NCollection_BaseAllocatormyAlloc
 Usually from InteractiveContext. More...
 
Standard_Integer myType
 Combination of Type_* constants. More...
 
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. More...
 
unsigned int myIndexType: 2
 0:8bit, 1:16bit, 2:32bit More...
 
unsigned int myNodeCoord: 2
 2 or 3 coordinates More...
 
unsigned int myPolygonType: 2
 
- Protected Attributes inherited from NIS_InteractiveObject
Bnd_B3f myBox
 
void * myAttributePtr
 

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 ( )
protectedvirtual

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

NCollection_BaseAllocator* NIS_Triangulated::myAlloc
protected

Usually from InteractiveContext.

unsigned int NIS_Triangulated::myIndexType
protected

0:8bit, 1:16bit, 2:32bit

Standard_Boolean NIS_Triangulated::myIsCloned
protected

How it is allocated.

Standard_Boolean NIS_Triangulated::myIsDrawPolygons
protected
Standard_Integer NIS_Triangulated::myNLineNodes
protected
Standard_Integer NIS_Triangulated::myNNodes
protected
unsigned int NIS_Triangulated::myNodeCoord
protected

2 or 3 coordinates

unsigned int NIS_Triangulated::myNPolygons
protected
Standard_Integer NIS_Triangulated::myNTriangles
protected
Standard_Integer* NIS_Triangulated::mypLines
protected
Standard_ShortReal* NIS_Triangulated::mypNodes
protected
unsigned int NIS_Triangulated::myPolygonType
protected
Standard_Integer** NIS_Triangulated::mypPolygons
protected
Standard_Integer* NIS_Triangulated::mypTriangles
protected
Standard_Integer NIS_Triangulated::myType
protected

Combination of Type_* constants.


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