Debian Codegraph @

lib/database/src/so/nodes/nurbs/SoCurveMaps.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision $
44 |
45 | Classes:
46 | _SoNurbsCurveV3Map
47 | _SoNurbsCurveV4Map
48 |
49 | Author(s) : Dave Immel
50 |
51 ______________ S I L I C O N G R A P H I C S I N C . ____________
52 _______________________________________________________________________
53 */
54
55
56 /* Polynomial Evaluator Interface */
57
58 #include <cstring>
59 #include "SoCurveMaps.h"
60
61 _SoNurbsCurveV3Map::~_SoNurbsCurveV3Map()
62 {
63 }
64
65 _SoNurbsCurveV4Map::~_SoNurbsCurveV4Map()
66 {
67 }
68
69
70 void
71 _SoNurbsCurveV3Map::initialize( int32_t *nv, int32_t *nav, SbVec2f **v )
72 {
73 numVertices = nv;
74 numAllocVertices = nav;
75 vertices = v;
76 }
77
78 void
79 _SoNurbsCurveV4Map::initialize( int32_t *nv, int32_t *nav, SbVec2f **v )
80 {
81 numVertices = nv;
82 numAllocVertices = nav;
83 vertices = v;
84 }
85
86 void
87 _SoNurbsCurveV3Map::point( float *v )
88 {
89 //
90 // Add the vertex to the list of vertices. The 3rd component of the
91 // vertex is 0.0 and is ignored. Allocate more vertices if there is
92 // not enough space.
93 //
94 if (*numVertices == *numAllocVertices)
95 {
96 *numAllocVertices += CRV_ALLOC_BLOCK;
97 SbVec2f *tmpBlock = new SbVec2f[*numAllocVertices];
98 memcpy ((void *)tmpBlock, (void *)*vertices,
99 (int) *numVertices*sizeof(SbVec2f));
100 delete[] *vertices;
101 *vertices = tmpBlock;
102 }
103
104 (*vertices)[*numVertices][0] = v[0];
105 (*vertices)[(*numVertices)++][1] = v[1];
106 }
107
108
109 void
110 _SoNurbsCurveV4Map::point( float *v )
111 {
112 //
113 // Add the vertex to the list of vertices. The 3rd component of the
114 // vertex is 0.0 and is ignored. Allocate more vertices if there is
115 // not enough space.
116 //
117 if (*numVertices == *numAllocVertices)
118 {
119 *numAllocVertices += CRV_ALLOC_BLOCK;
120 SbVec2f *tmpBlock = new SbVec2f[*numAllocVertices];
121 memcpy ((void *)tmpBlock, (void *)*vertices,
122 (int) *numVertices*sizeof(SbVec2f));
123 delete[] *vertices;
124 *vertices = tmpBlock;
125 }
126
127 (*vertices)[*numVertices][0] = v[0]/v[3];
128 (*vertices)[*numVertices++][1] = v[1]/v[3];
129 }
130
131
132