Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoPattern Class Reference

VSG extension Node that defines the pattern to use when rendering shapes. More...

#include <Inventor/nodes/SoPattern.h>

+ Inheritance diagram for SoPattern:

Public Types

enum  FilterType {
  INCLUSIVE_FILTER ,
  EXCLUSIVE_FILTER
}
 Possible value of the filterType used by the method loadPatterns. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoPattern ()
 Constructor.
 
virtual void setOverride (const SbBool state)
 Set the state of the override field.
 
virtual SbBool isOverride () const
 Returns the state of the override field.
 
- Public Member Functions inherited from SoNode
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual SbBool affectsState () const
 Returns TRUE if a node has an effect on the state during traversal.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNONUNICODE SbBool loadPatterns (const char *fileName, int numFilters=0, const SbString *filterNames=NULL, FilterType filterType=INCLUSIVE_FILTER)
 Loads a pattern file, with optional filtering of patterns.
 
static SbBool loadPatterns (const SbString &fileName, int numFilters=0, const SbString *filterNames=NULL, FilterType filterType=INCLUSIVE_FILTER)
 Loads a pattern file, with optional filtering of patterns.
 
static void getPatternNames (int &number, SbString *&names, const char *category=NULL)
 Gets the names of loaded patterns.
 
static SoNONUNICODE void addPattern (const char *category, const char *name, const unsigned char *bytes)
 Adds a new pattern specified as an array of 128 bytes.
 
static void addPattern (const SbString &category, const SbString &name, const unsigned char *bytes)
 Adds a new pattern specified as an array of 128 bytes.
 
static SoNONUNICODE void getPattern (const char *category, const char *name, unsigned char *&bytes)
 Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.
 
static void getPattern (const SbString &category, const SbString &name, unsigned char *&bytes)
 Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoSFString category
 Specifies the name of a group of patterns.
 
SoSFString name
 Specifies the name of a pattern within a category.
 

Detailed Description

VSG extension Node that defines the pattern to use when rendering shapes.

This node specifies the current pattern for all subsequent shape nodes in a scene graph.

A pattern is a 32x32 bitmap that is interpreted as a mask of 0s and 1s. Where a 1 appears, the corresponding pixel in the polygon is drawn; where a 0 appears, nothing is drawn.

You can load a pattern file containing one or more patterns using the loadPatterns() method. You can also define and load patterns programmatically using the addPattern() method.

Here is a sample showing the pattern file format.

  "GEOLOGY"
  # The first string is the category name of the first pattern.
  # This is a comment !
  "PATTERN N1"
  # The second string is the name of the pattern.
  # To define the pattern, you must define a 32x32 sequence of
  # '1' and '0'.
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
  #============================================
  "PATTERN N2"
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...

Note:

  • A pattern file can contain only one category.

Usage Notes

  • Patterns can be used for distinguishing, for example, different kinds of rocks in a geologic formation.
  • The HardCopy extension (formerly known as PlotMaster) allows you to generate resolution-independent vector hardcopy output. It handles patterns but does not handle textures (they are ignored). If you are planning to use the HardCopy extension, you may want to use patterns rather than textures to distinguish different shapes in your scene graph.

FILE FORMAT/DEFAULT

    Pattern {
    category ""
    name ""
    }

    NOTE: When you write a pattern node out to a file, the file will not contain enough information to fully reconstruct the original scene graph. The pattern node and its current fields are written out (as expected). However, the current fields only specify a category name and a pattern name. They do not specify the actual pattern(s) (like a typical attribute node) or a filename to get the patterns from (like a texture node).

SEE ALSO

SoMaterial

Definition at line 107 of file SoPattern.h.

Member Enumeration Documentation

◆ FilterType

Possible value of the filterType used by the method loadPatterns.

In the case INCLUSIVE_FILTER, we only load patterns of the file define by the list of patterns names. In the case EXCLUSIVE_FILTER, we load all patterns defined in the file without those define by the list of patterns names.

Enumerator
INCLUSIVE_FILTER 

Load only the patterns that are in the list of pattern names.

EXCLUSIVE_FILTER 

Load all patterns except those specified in the list of pattern names.

Definition at line 136 of file SoPattern.h.

Constructor & Destructor Documentation

◆ SoPattern()

SoPattern::SoPattern ( )

Constructor.

Member Function Documentation

◆ addPattern() [1/2]

static SoNONUNICODE void SoPattern::addPattern ( const char *  category,
const char *  name,
const unsigned char *  bytes 
)
static

Adds a new pattern specified as an array of 128 bytes.

A category and a name are specified for this pattern. If the category and name are already in the list of patterns, the new pattern will not be added. If either the category or the name is an empty string, no pattern is added.

Non Unicode: This function should not be used in a Unicode application.

◆ addPattern() [2/2]

static void SoPattern::addPattern ( const SbString category,
const SbString name,
const unsigned char *  bytes 
)
static

Adds a new pattern specified as an array of 128 bytes.

A category and a name are specified for this pattern. If the category and name are already in the list of patterns, the new pattern will not be added. If either the category or the name is an empty string, no pattern is added.

◆ getClassTypeId()

static SoType SoPattern::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getPattern() [1/2]

static SoNONUNICODE void SoPattern::getPattern ( const char *  category,
const char *  name,
unsigned char *&  bytes 
)
static

Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.

the pattern data pointed to by bytes is read-only.

Non Unicode: This function should not be used in a Unicode application.

◆ getPattern() [2/2]

static void SoPattern::getPattern ( const SbString category,
const SbString name,
unsigned char *&  bytes 
)
static

Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.

the pattern data pointed to by bytes is read-only.

◆ getPatternNames()

static void SoPattern::getPatternNames ( int &  number,
SbString *&  names,
const char *  category = NULL 
)
static

Gets the names of loaded patterns.

Category is optional. You are responsible for deleting the names array when it is no longer needed. For example, delete []names;

◆ getTypeId()

virtual SoType SoPattern::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoNode.

◆ isOverride()

virtual SbBool SoPattern::isOverride ( ) const
inlinevirtual

Returns the state of the override field.

Reimplemented from SoNode.

Definition at line 234 of file SoPattern.h.

◆ loadPatterns() [1/2]

static SoNONUNICODE SbBool SoPattern::loadPatterns ( const char *  fileName,
int  numFilters = 0,
const SbString filterNames = NULL,
FilterType  filterType = INCLUSIVE_FILTER 
)
static

Loads a pattern file, with optional filtering of patterns.

You can specify the file name with or without a full path. If you specify the file name without the path, the file will be loaded from the directory $OIVHOME/data/patterns. If the file name is not found, a default pattern will be used.

filterNames is an array of pattern names. This will be an array of patterns to include (or exclude) depending on the FilterType. The size of this array is numFilters.

Non Unicode: This function should not be used in a Unicode application.

◆ loadPatterns() [2/2]

static SbBool SoPattern::loadPatterns ( const SbString fileName,
int  numFilters = 0,
const SbString filterNames = NULL,
FilterType  filterType = INCLUSIVE_FILTER 
)
static

Loads a pattern file, with optional filtering of patterns.

You can specify the file name with or without a full path. If you specify the file name without the path, the file will be loaded from the directory $OIVHOME/data/patterns. If the file name is not found, a default pattern will be used.

filterNames is an array of pattern names. This will be an array of patterns to include (or exclude) depending on the FilterType. The size of this array is numFilters.

◆ setOverride()

virtual void SoPattern::setOverride ( const SbBool  state)
inlinevirtual

Set the state of the override field.

see SoNode::setOverride doc.

Reimplemented from SoNode.

Definition at line 228 of file SoPattern.h.

Member Data Documentation

◆ category

SoSFString SoPattern::category

Specifies the name of a group of patterns.

If the category name is invalid or not found, the default pattern is used.

Definition at line 118 of file SoPattern.h.

◆ name

SoSFString SoPattern::name

Specifies the name of a pattern within a category.

If the pattern name is invalid or not found, the default pattern is used.

Definition at line 124 of file SoPattern.h.


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