1 /**************************************************************************\
2  * Copyright (c) Kongsberg Oil & Gas Technologies AS
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32 
33 /*!
34   \class SoFullPath Inventor/SoFullPath.h
35   \brief The SoFullPath class allows examination of hidden children in paths.
36 
37   \ingroup general
38 
39   SoPath allows only access from the head node to the first node with
40   hidden children, but not any further.
41 
42   Since the SoFullPath is derived from SoPath and contains no private
43   data, you can cast SoPath instances to the SoFullPath type.  This
44   will allow you to examine hidden children.
45 
46   (Actually, you are not supposed to allocate instances of this class
47   at all. It is only available as an "extended interface" into the
48   superclass SoPath.)
49 */
50 
51 /*!
52   \fn void SoFullPath::pop(void)
53 
54   This method overrides SoPath::pop() to allow clients to get at all
55   the nodes in the path.
56 */
57 
58 #include <Inventor/SoFullPath.h>
59 #include <cassert>
60 
61 
62 /*!
63   A constructor.
64 */
65 
SoFullPath(const int approxLength)66 SoFullPath::SoFullPath(const int approxLength)
67   : SoPath(approxLength)
68 {
69 }
70 
71 /*!
72   The destructor.
73 */
74 
~SoFullPath(void)75 SoFullPath::~SoFullPath(void)
76 {
77 }
78 
79 /*!
80   This method overrides SoPath::getTail() to allow clients to get the
81   tail node, counting internal path nodes.
82 */
83 SoNode *
getTail(void) const84 SoFullPath::getTail(void) const
85 {
86   return this->nodes[this->nodes.getLength() - 1];
87 }
88 
89 /*!
90   This method overrides SoPath::getNodeFromTail() to allow clients to
91   get the node positioned \a index nodes from the tail, counting
92   internal path nodes.
93 */
94 SoNode *
getNodeFromTail(const int index) const95 SoFullPath::getNodeFromTail(const int index) const
96 {
97   return this->nodes[this->nodes.getLength() - 1 - index];
98 }
99 
100 /*!
101   This method overrides SoPath::getIndexFromTail() to allow clients to
102   get the child index number for nodes based on their position from
103   the tail, counting hidden nodes.
104 */
105 int
getIndexFromTail(const int index) const106 SoFullPath::getIndexFromTail(const int index) const
107 {
108   return this->indices[this->nodes.getLength() - 1 - index];
109 }
110 
111 /*!
112   This method returns the length of the path, counting hidden nodes
113   also.
114 */
115 int
getLength(void) const116 SoFullPath::getLength(void) const
117 {
118   return this->nodes.getLength();
119 }
120