| 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 | // Some convenient routines for doing stuff with faces. |
| 39 | // |
| 40 | |
| 41 | #include <assert.h> |
| 42 | #include <cmath> |
| 43 | #include "Faces.h"cxx . . $ `<file>/apps/tools/ivnorm/Faces.h`/ |
| 44 | #include "Edges.h"cxx . . $ `<file>/apps/tools/ivnorm/Edges.h`/ |
| 45 | |
| 46 | #include <Inventor/nodes/SoNormal.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormal.h`/ |
| 47 | #include <Inventor/nodes/SoIndexedFaceSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedFaceSet.h`/ |
| 48 | |
| 49 | // |
| 50 | // Find a face's normal, assuming its vertices are in |
| 51 | // counter-clockwise order. |
| 52 | // |
| 53 | void |
| 54 | Facecxx . . $ Face#::findNormalcxx . . $ Face#findNormal(1bc23f47d9753cf8).(const SbVec3fcxx . . $ SbVec3f# *verts) |
| 55 | { |
| 56 | // Use Newell's method to find face normal. See Newman & Sproull, |
| 57 | // pg. 499. This is better than the three-point cross-product |
| 58 | // method. |
| 59 | |
| 60 | normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0] = normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1] = normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2] = 0.0; |
| 61 | |
| 62 | for (int i = 0; i < nvcxx . . $ Face#nv.; i++) |
| 63 | { |
| 64 | int iv1 = int(vcxx . . $ Face#v.[i]); |
| 65 | int iv2 = int(vcxx . . $ Face#v.[(i+1)%nvcxx . . $ Face#nv.]); |
| 66 | |
| 67 | if (iv1 == iv2) continue; |
| 68 | |
| 69 | SbVec3fcxx . . $ SbVec3f# v1 = verts[iv1]; |
| 70 | SbVec3fcxx . . $ SbVec3f# v2 = verts[iv2]; |
| 71 | |
| 72 | normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0] += (v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1] - v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1])*(v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2] + v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2]); |
| 73 | normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1] += (v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2] - v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2])*(v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0] + v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0]); |
| 74 | normalcxx . . $ Face#normal.[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).2] += (v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0] - v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).0])*(v1[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1] + v2[cxx . . $ SbVec3f#`operator[]`(5dbdaf238659ae67).1]); |
| 75 | } |
| 76 | if (orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CWcxx . . $ Face#CW.) normalcxx . . $ Face#normal..negatecxx . . $ SbVec3f#negate(49f6e7a06ebc5aa8).(); |
| 77 | |
| 78 | if (normalcxx . . $ Face#normal..lengthcxx . . $ SbVec3f#length(5036dfe8d4170af2).() < 0.00001) |
| 79 | { |
| 80 | degeneratecxx . . $ Face#degenerate. = 1; |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | normalcxx . . $ Face#normal..normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 85 | degeneratecxx . . $ Face#degenerate. = 0; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // |
| 90 | // Set this face's orientation relative to a given edge |
| 91 | // |
| 92 | void |
| 93 | Facecxx . . $ Face#::orientFacecxx . . $ Face#orientFace(3e454b8ccf442868).(int v1, int v2) |
| 94 | { |
| 95 | int v1_i; |
| 96 | |
| 97 | // First, figure out which index is v1 |
| 98 | |
| 99 | for (v1_i = 0; v1_i < nvcxx . . $ Face#nv.; v1_i++) |
| 100 | { |
| 101 | if (vcxx . . $ Face#v.[v1_i] == v1) |
| 102 | { |
| 103 | // Now just have to determine whether v2 is the next or previous |
| 104 | // vertex. |
| 105 | if (vcxx . . $ Face#v.[(v1_i+1)%nvcxx . . $ Face#nv.] == v2) // Next |
| 106 | { |
| 107 | orientationcxx . . $ Face#orientation. = CCWcxx . . $ Face#CCW.; |
| 108 | break; |
| 109 | } |
| 110 | else if (vcxx . . $ Face#v.[(v1_i+nvcxx . . $ Face#nv.-1)%nvcxx . . $ Face#nv.] == v2) // Previous |
| 111 | { |
| 112 | orientationcxx . . $ Face#orientation. = CWcxx . . $ Face#CW.; |
| 113 | break; |
| 114 | } |
| 115 | // Otherwise, keep on checking; we may be traversing a |
| 116 | // degenerate edge or strange facet where vertices are repeated. |
| 117 | } |
| 118 | } |
| 119 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(v1_i != nv); // Assertion: we found it. |
| 120 | } |
| 121 | |
| 122 | FaceListcxx . . $ FaceList#::FaceListcxx . . $ FaceList#FaceList(49f6e7a06ebc5aa8).() |
| 123 | { |
| 124 | vertscxx . . $ FaceList#verts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 125 | faceSetcxx . . $ FaceList#faceSet. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 126 | edcxx . . $ FaceList#ed. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 127 | vdcxx . . $ FaceList#vd. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 128 | convexcxx . . $ FaceList#convex. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 129 | solidcxx . . $ FaceList#solid. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 130 | verbosecxx . . $ FaceList#verbose. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 131 | } |
| 132 | |
| 133 | FaceListcxx . . $ FaceList#::FaceListcxx . . $ FaceList#FaceList(8cb8bf389e5f8720).(const SbVec3fcxx . . $ SbVec3f# *v, EdgeDictcxx . . $ EdgeDict# *e) |
| 134 | { |
| 135 | vertscxx . . $ FaceList#verts. = v; |
| 136 | edcxx . . $ FaceList#ed. = e; |
| 137 | vdcxx . . $ FaceList#vd. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 138 | faceSetcxx . . $ FaceList#faceSet. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 139 | convexcxx . . $ FaceList#convex. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 140 | solidcxx . . $ FaceList#solid. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 141 | verbosecxx . . $ FaceList#verbose. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 142 | } |
| 143 | |
| 144 | FaceListcxx . . $ FaceList#::FaceListcxx . . $ FaceList#FaceList(dd88af99dd740d16).(const SbVec3fcxx . . $ SbVec3f# *v, SoIndexedFaceSetcxx . . $ SoIndexedFaceSet# *fs, SbBoolcxx . . $ SbBool# vrb) |
| 145 | { |
| 146 | vertscxx . . $ FaceList#verts. = v; |
| 147 | faceSetcxx . . $ FaceList#faceSet. = fs; fs->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 148 | convexcxx . . $ FaceList#convex. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 149 | solidcxx . . $ FaceList#solid. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 150 | vdcxx . . $ FaceList#vd. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 151 | verbosecxx . . $ FaceList#verbose. = vrb; |
| 152 | |
| 153 | edcxx . . $ FaceList#ed. = new EdgeDictcxx . . $ EdgeDict#EdgeDict(d4f767463ce0a6b3).(1000); |
| 154 | |
| 155 | SoMFInt32cxx . . $ SoMFInt32# *coord_indices = &faceSetcxx . . $ FaceList#faceSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex.; |
| 156 | int ni = coord_indices->getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).(); |
| 157 | |
| 158 | int32_t *indices = coord_indices->startEditingcxx . . $ SoMFInt32#startEditing(a7741f82f5fc3640).(); |
| 159 | |
| 160 | int start_o_face = 0; |
| 161 | |
| 162 | // Now fill in face and edge structures |
| 163 | int n_degenerate_faces = 0; |
| 164 | int n_degenerate_edges = 0; |
| 165 | for (int i = 0, ct=0; i < coord_indices->getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).(); i++) |
| 166 | { |
| 167 | if (indices[i] == SO_END_FACE_INDEXcxx . . $ `lib/database/include/Inventor/nodes/SoIndexedFaceSet.h:76:9`! |
| 168 | || i == coord_indices->getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).()-1) |
| 169 | { |
| 170 | Facecxx . . $ Face# *f = new Facecxx . . $ Face#; |
| 171 | if (indices[i] == SO_END_FACE_INDEXcxx . . $ `lib/database/include/Inventor/nodes/SoIndexedFaceSet.h:76:9`!) |
| 172 | f->nvcxx . . $ Face#nv. = i - start_o_face; |
| 173 | else |
| 174 | f->nvcxx . . $ Face#nv. = i - start_o_face + 1; |
| 175 | f->vcxx . . $ Face#v. = indices+start_o_face; |
| 176 | f->vctcxx . . $ Face#vct. = ct; // first vertex index count for this face. |
| 177 | f->vidxcxx . . $ Face#vidx. = start_o_face; |
| 178 | f->vncxx . . $ Face#vn. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 179 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::UNKNOWNcxx . . $ Face#UNKNOWN.; |
| 180 | |
| 181 | f->findNormalcxx . . $ Face#findNormal(1bc23f47d9753cf8).(vertscxx . . $ FaceList#verts.); |
| 182 | if (f->degeneratecxx . . $ Face#degenerate.) |
| 183 | { |
| 184 | ++n_degenerate_faces; |
| 185 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.; |
| 186 | } |
| 187 | else for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) |
| 188 | { |
| 189 | int i1 = (int)f->vcxx . . $ Face#v.[j]; |
| 190 | int i2 = (int)f->vcxx . . $ Face#v.[(j+1)%f->nvcxx . . $ Face#nv.]; |
| 191 | if (i1 != i2) |
| 192 | edcxx . . $ FaceList#ed.->Addcxx . . $ EdgeDict#Add(9178463185742b1d).(f, i1, i2); |
| 193 | else ++n_degenerate_edges; |
| 194 | } |
| 195 | |
| 196 | start_o_face = i+1; |
| 197 | |
| 198 | appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(f); |
| 199 | } |
| 200 | else |
| 201 | ct++; // "ct" counts the non-END entries, for use |
| 202 | // as the index into a per_vertex normal set |
| 203 | } |
| 204 | if (n_degenerate_faces != 0) |
| 205 | { |
| 206 | if (verbosecxx . . $ FaceList#verbose.) fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Detected %d degenerate faces\n", |
| 207 | n_degenerate_faces); |
| 208 | } |
| 209 | if (n_degenerate_edges != 0) |
| 210 | { |
| 211 | if (verbosecxx . . $ FaceList#verbose.) fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Detected %d degenerate edges\n", |
| 212 | n_degenerate_edges); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | void |
| 217 | FaceListcxx . . $ FaceList#::appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(Facecxx . . $ Face# *f) |
| 218 | { |
| 219 | SbPListcxx . . $ SbPList#::appendcxx . . $ SbPList#append(5d22bdacc48458e8).((void *)f); |
| 220 | } |
| 221 | |
| 222 | // |
| 223 | // This isn't accurate; we just use it to figure out if the volume is |
| 224 | // positive or negative to try to figure out if the surface is |
| 225 | // oriented correctly. |
| 226 | // |
| 227 | float |
| 228 | FaceListcxx . . $ FaceList#::volumecxx . . $ FaceList#volume(9b8c9e39889c762c).() |
| 229 | { |
| 230 | int i, j; |
| 231 | |
| 232 | int total_v = 0; |
| 233 | SbVec3fcxx . . $ SbVec3f# averagecxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0.0, 0.0, 0.0); |
| 234 | |
| 235 | for (j = 0; j < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); j++) |
| 236 | { |
| 237 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]; |
| 238 | if (f->degeneratecxx . . $ Face#degenerate.) continue; |
| 239 | |
| 240 | for (i = 0; i < f->nvcxx . . $ Face#nv.; i++) |
| 241 | { |
| 242 | average +=cxx . . $ SbVec3f#`operator+=`(13422326b1abca17). vertscxx . . $ FaceList#verts.[f->vcxx . . $ Face#v.[i]]; |
| 243 | ++total_v; |
| 244 | } |
| 245 | } |
| 246 | average /=cxx . . $ SbVec3f#`operator/=`(3aaca777b5795e29). (float) total_v; |
| 247 | |
| 248 | float result = 0.0; |
| 249 | |
| 250 | for (j = 0; j < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); j++) |
| 251 | { |
| 252 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]; |
| 253 | if (f->degeneratecxx . . $ Face#degenerate.) continue; |
| 254 | |
| 255 | for (i = 1; i < f->nvcxx . . $ Face#nv.-1; i++) |
| 256 | { |
| 257 | SbVec3fcxx . . $ SbVec3f# v1 = vertscxx . . $ FaceList#verts.[f->vcxx . . $ Face#v.[0]] -cxx . . $ operator-(af63bf8d0639b76b). average; |
| 258 | SbVec3fcxx . . $ SbVec3f# v2 = vertscxx . . $ FaceList#verts.[f->vcxx . . $ Face#v.[i]] -cxx . . $ operator-(af63bf8d0639b76b). average; |
| 259 | SbVec3fcxx . . $ SbVec3f# v3 = vertscxx . . $ FaceList#verts.[f->vcxx . . $ Face#v.[i+1]] -cxx . . $ operator-(af63bf8d0639b76b). average; |
| 260 | |
| 261 | float t = (v1.crosscxx . . $ SbVec3f#cross(d67ad7d0c0b29ebb).(v2)).dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(v3); |
| 262 | if (f->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.) |
| 263 | { |
| 264 | result += t; |
| 265 | } |
| 266 | else if (f->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CWcxx . . $ Face#CW.) |
| 267 | { |
| 268 | result -= t; |
| 269 | } |
| 270 | else |
| 271 | { |
| 272 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(0); |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | return result; |
| 277 | } |
| 278 | |
| 279 | FaceListcxx . . $ FaceList#::~cxx . . $ FaceList#`~FaceList`(49f6e7a06ebc5aa8).FaceListcxx . . $ FaceList#() |
| 280 | { |
| 281 | if (faceSetcxx . . $ FaceList#faceSet. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 282 | { |
| 283 | delete edcxx . . $ FaceList#ed.; |
| 284 | faceSetcxx . . $ FaceList#faceSet.->coordIndexcxx . . $ SoIndexedShape#coordIndex..finishEditingcxx . . $ SoMFInt32#finishEditing(49f6e7a06ebc5aa8).(); |
| 285 | faceSetcxx . . $ FaceList#faceSet.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).(); |
| 286 | for (int i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 287 | { |
| 288 | delete (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 289 | } |
| 290 | truncatecxx . . $ SbPList#truncate(d4f767463ce0a6b3).(0); |
| 291 | } |
| 292 | |
| 293 | if (vdcxx . . $ FaceList#vd.) |
| 294 | delete [] vdcxx . . $ FaceList#vd.; |
| 295 | } |
| 296 | |
| 297 | void |
| 298 | FaceListcxx . . $ FaceList#::reverseOrientationcxx . . $ FaceList#reverseOrientation(49f6e7a06ebc5aa8).() |
| 299 | { |
| 300 | for (int i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 301 | { |
| 302 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 303 | |
| 304 | if (f->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CWcxx . . $ Face#CW.) |
| 305 | { |
| 306 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.; |
| 307 | } |
| 308 | else if (f->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.) |
| 309 | { |
| 310 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::CWcxx . . $ Face#CW.; |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(0); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | // |
| 320 | // This routine works by starting with a 'seed' face and assumes that |
| 321 | // its orientation is correct. It then visits all neighboring faces |
| 322 | // and makes their orientations consistent with the seed face's. |
| 323 | // |
| 324 | void |
| 325 | FaceListcxx . . $ FaceList#::findOrientationcxx . . $ FaceList#findOrientation(49f6e7a06ebc5aa8).() |
| 326 | { |
| 327 | orientOutwardcxx . . $ FaceList#orientOutward(49f6e7a06ebc5aa8).(); |
| 328 | |
| 329 | correctOrientationcxx . . $ FaceList#correctOrientation(49f6e7a06ebc5aa8).(); |
| 330 | } |
| 331 | |
| 332 | void |
| 333 | FaceListcxx . . $ FaceList#::findFacetNormalscxx . . $ FaceList#findFacetNormals(c3eb233a7f77e81d).(SoNormalcxx . . $ SoNormal# *n) |
| 334 | { |
| 335 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(n != NULL && faceSet != NULL); |
| 336 | |
| 337 | for (int i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 338 | { |
| 339 | (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]->findNormalcxx . . $ Face#findNormal(1bc23f47d9753cf8).(vertscxx . . $ FaceList#verts.); |
| 340 | n->vectorcxx . . $ SoNormal#vector..set1Valuecxx . . $ SoMFVec3f#set1Value(9c7ea36464c471ee).(i, (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]->normalcxx . . $ Face#normal.); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | // |
| 345 | // Assuming that the correct orientation of a 'seed' face has been |
| 346 | // discovered, this routine figures out the correct orientation for |
| 347 | // all faces connected to that face. |
| 348 | // |
| 349 | void |
| 350 | FaceListcxx . . $ FaceList#::recursivelyOrientcxx . . $ FaceList#recursivelyOrient(f7003f3e368fe0fc).(Facecxx . . $ Face# *seed) |
| 351 | { |
| 352 | int i, j; |
| 353 | FaceListcxx . . $ FaceList# otherscxx . . $ FaceList#FaceList(49f6e7a06ebc5aa8).; |
| 354 | |
| 355 | if (seed->degeneratecxx . . $ Face#degenerate.) return; |
| 356 | |
| 357 | for (i = 0; i < seed->nvcxx . . $ Face#nv.; i++) |
| 358 | { |
| 359 | j = (i+1)%seed->nvcxx . . $ Face#nv.; |
| 360 | |
| 361 | // Find other faces attached to this edge |
| 362 | edcxx . . $ FaceList#ed.->OtherFacescxx . . $ EdgeDict#OtherFaces(1a26c159804da3b).(seed, seed->vcxx . . $ Face#v.[i], seed->vcxx . . $ Face#v.[j], others); |
| 363 | |
| 364 | for (int f = 0; f < others.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); f++) |
| 365 | { |
| 366 | if (others[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::UNKNOWNcxx . . $ Face#UNKNOWN.) |
| 367 | { |
| 368 | if (seed->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CWcxx . . $ Face#CW.) |
| 369 | others[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]->orientFacecxx . . $ Face#orientFace(3e454b8ccf442868).((int)seed->vcxx . . $ Face#v.[i], (int)seed->vcxx . . $ Face#v.[j]); |
| 370 | else if (seed->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.) |
| 371 | others[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]->orientFacecxx . . $ Face#orientFace(3e454b8ccf442868).((int)seed->vcxx . . $ Face#v.[j], (int)seed->vcxx . . $ Face#v.[i]); |
| 372 | else assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(0); // Should never happen |
| 373 | |
| 374 | appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(others[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]); |
| 375 | recursivelyOrientcxx . . $ FaceList#recursivelyOrient(f7003f3e368fe0fc).(others[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]); |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // |
| 382 | // This routine takes a collection of faces and trys to figure out |
| 383 | // which way is out. |
| 384 | // |
| 385 | void |
| 386 | FaceListcxx . . $ FaceList#::orientOutwardcxx . . $ FaceList#orientOutward(49f6e7a06ebc5aa8).() |
| 387 | { |
| 388 | // int num_fragments = 0; |
| 389 | |
| 390 | // |
| 391 | // Loop through all the faces; if we find one whose orientation |
| 392 | // hasn't been determined, will try to determine its orientation. |
| 393 | // |
| 394 | for (int i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 395 | { |
| 396 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 397 | if (f->orientationcxx . . $ Face#orientation. != Facecxx . . $ Face#::UNKNOWNcxx . . $ Face#UNKNOWN.) continue; |
| 398 | |
| 399 | // First, take a wild guess... |
| 400 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.; |
| 401 | |
| 402 | // ++num_fragments; |
| 403 | |
| 404 | FaceListcxx . . $ FaceList# fragmentcxx . . $ FaceList#FaceList(8cb8bf389e5f8720).(vertscxx . . $ FaceList#verts., edcxx . . $ FaceList#ed.); |
| 405 | fragment.appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(f); |
| 406 | |
| 407 | // Now recursively orient the faces connected to this face. |
| 408 | fragment.recursivelyOrientcxx . . $ FaceList#recursivelyOrient(f7003f3e368fe0fc).(f); |
| 409 | |
| 410 | // Take a reasonable guess for whether or not that first face |
| 411 | // is oriented correctly: |
| 412 | float v = fragment.volumecxx . . $ FaceList#volume(9b8c9e39889c762c).(); |
| 413 | |
| 414 | if (v*v < 0.00001*0.00001) // FLAT |
| 415 | { |
| 416 | // Do something... |
| 417 | // fprintf(stderr, "Flat fragment found\n"); |
| 418 | } |
| 419 | else if (v < 0.0) |
| 420 | fragment.reverseOrientationcxx . . $ FaceList#reverseOrientation(49f6e7a06ebc5aa8).(); |
| 421 | } |
| 422 | // fprintf(stderr, "There were %d fragments\n", num_fragments); |
| 423 | } |
| 424 | |
| 425 | void |
| 426 | FaceListcxx . . $ FaceList#::correctOrientationcxx . . $ FaceList#correctOrientation(49f6e7a06ebc5aa8).() |
| 427 | { |
| 428 | for (int i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 429 | { |
| 430 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 431 | if (f->orientationcxx . . $ Face#orientation. == Facecxx . . $ Face#::CWcxx . . $ Face#CW.) |
| 432 | { |
| 433 | for (int j = 0; j < f->nvcxx . . $ Face#nv./2; j++) |
| 434 | { |
| 435 | int k = f->nvcxx . . $ Face#nv. - j - 1; |
| 436 | int32_t t = f->vcxx . . $ Face#v.[j]; |
| 437 | f->vcxx . . $ Face#v.[j] = f->vcxx . . $ Face#v.[k]; |
| 438 | f->vcxx . . $ Face#v.[k] = t; |
| 439 | } |
| 440 | f->orientationcxx . . $ Face#orientation. = Facecxx . . $ Face#::CCWcxx . . $ Face#CCW.; |
| 441 | } |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void |
| 446 | FaceListcxx . . $ FaceList#::findShapeInfocxx . . $ FaceList#findShapeInfo(49f6e7a06ebc5aa8).() |
| 447 | { |
| 448 | FaceListcxx . . $ FaceList# otherscxx . . $ FaceList#FaceList(49f6e7a06ebc5aa8).; |
| 449 | convexcxx . . $ FaceList#convex. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 450 | solidcxx . . $ FaceList#solid. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 451 | |
| 452 | for (int k=0; k< getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); k++) { |
| 453 | |
| 454 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).k]; |
| 455 | if (f->degeneratecxx . . $ Face#degenerate.) |
| 456 | continue; |
| 457 | |
| 458 | // If a face has more than 3 vertices, assume it's convex. |
| 459 | if (f->nvcxx . . $ Face#nv. > 3) { |
| 460 | convexcxx . . $ FaceList#convex. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 461 | } |
| 462 | |
| 463 | // run through the edges of the face |
| 464 | for (int i = 0; i < f->nvcxx . . $ Face#nv.; i++) { |
| 465 | |
| 466 | int j = (i+1)%f->nvcxx . . $ Face#nv.; |
| 467 | |
| 468 | // Find other faces attached to this edge |
| 469 | edcxx . . $ FaceList#ed.->OtherFacescxx . . $ EdgeDict#OtherFaces(1a26c159804da3b).(f, f->vcxx . . $ Face#v.[i], f->vcxx . . $ Face#v.[j], others); |
| 470 | |
| 471 | if (others.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).() == 0) { |
| 472 | solidcxx . . $ FaceList#solid. = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 473 | break; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | // we can quit searching if we've found |
| 478 | // out all there is to know. |
| 479 | if (!convexcxx . . $ FaceList#convex. && !solidcxx . . $ FaceList#solid.) |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | |
| 485 | int |
| 486 | FaceListcxx . . $ FaceList#::findBodiescxx . . $ FaceList#findBodies(b126dc7c1de90089).() |
| 487 | { |
| 488 | buildVertexDictcxx . . $ FaceList#buildVertexDict(49f6e7a06ebc5aa8).(); |
| 489 | |
| 490 | // clear all faces |
| 491 | int i; |
| 492 | for (i=0; i< getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 493 | (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]->bodycxx . . $ Face#body. = -1; |
| 494 | |
| 495 | int bodyN = 0; |
| 496 | |
| 497 | for (i=0; i<getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) { |
| 498 | |
| 499 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 500 | |
| 501 | // each time we find an unmarked face, |
| 502 | // it's on a previously-undiscovered body |
| 503 | if (f->bodycxx . . $ Face#body. == -1) { |
| 504 | f->bodycxx . . $ Face#body. = bodyN++; |
| 505 | recursivelyMarkBodycxx . . $ FaceList#recursivelyMarkBody(f7003f3e368fe0fc).(f); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | return bodyN; |
| 510 | } |
| 511 | |
| 512 | void |
| 513 | FaceListcxx . . $ FaceList#::recursivelyMarkBodycxx . . $ FaceList#recursivelyMarkBody(f7003f3e368fe0fc).(Facecxx . . $ Face# *f) |
| 514 | { |
| 515 | int i; |
| 516 | |
| 517 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(f->body != -1); // only recurse on marked faces |
| 518 | |
| 519 | for (i = 0; i < f->nvcxx . . $ Face#nv.; i++) |
| 520 | { |
| 521 | // get list of faces sharing this vertex |
| 522 | const FaceListcxx . . $ FaceList# &faces = vdcxx . . $ FaceList#vd.[f->vcxx . . $ Face#v.[i]]; |
| 523 | |
| 524 | for (int j=0; j<faces.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); j++) { |
| 525 | if (faces[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]->bodycxx . . $ Face#body. == f->bodycxx . . $ Face#body.) { |
| 526 | ; // nothing to do if the other face is already part of this body |
| 527 | } |
| 528 | else if (faces[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]->bodycxx . . $ Face#body. == -1) { |
| 529 | // the other face is still unmarked, so mark it and recurse |
| 530 | faces[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]->bodycxx . . $ Face#body. = f->bodycxx . . $ Face#body.; |
| 531 | recursivelyMarkBodycxx . . $ FaceList#recursivelyMarkBody(f7003f3e368fe0fc).(faces[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]); |
| 532 | } |
| 533 | else { |
| 534 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(0); // vertex dictionary isn't commutative?? |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | void |
| 541 | FaceListcxx . . $ FaceList#::extractBodycxx . . $ FaceList#extractBody(690c031c13bfca33).(int b, |
| 542 | int &bnf, int32_t *fNewFromOld, int32_t *fOldFromNew, |
| 543 | int &bnv, int32_t *vNewFromOld, int32_t *vOldFromNew) |
| 544 | { |
| 545 | // build the face maps |
| 546 | int f, bf; |
| 547 | for (f=0, bf=0; f < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); f++) { |
| 548 | if ((*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).f]->bodycxx . . $ Face#body. == b) { |
| 549 | // f is the old face index |
| 550 | // bf is the new face index |
| 551 | fNewFromOld[f] = bf; |
| 552 | fOldFromNew[bf] = f; |
| 553 | bf++; |
| 554 | } |
| 555 | } |
| 556 | bnf = bf; |
| 557 | |
| 558 | // build the vertex maps |
| 559 | int ni, i; |
| 560 | for (ni=0, i=0; i < vdSizecxx . . $ FaceList#vdSize.; i++) { |
| 561 | const FaceListcxx . . $ FaceList# &faces = vdcxx . . $ FaceList#vd.[i]; |
| 562 | SbBoolcxx . . $ SbBool# isInBody = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 563 | for (int j = 0; j < faces.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); j++) if (faces[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).j]->bodycxx . . $ Face#body. == b) { |
| 564 | isInBody = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 565 | break; |
| 566 | } |
| 567 | if (isInBody) { |
| 568 | // i is the old vertex index |
| 569 | // ni is the new vertex index |
| 570 | vNewFromOld[i] = ni; |
| 571 | vOldFromNew[ni] = i; |
| 572 | ni++; |
| 573 | } |
| 574 | else |
| 575 | vNewFromOld[i] = -1; |
| 576 | } |
| 577 | bnv = ni; |
| 578 | } |
| 579 | |
| 580 | |
| 581 | void |
| 582 | FaceListcxx . . $ FaceList#::buildVertexDictcxx . . $ FaceList#buildVertexDict(49f6e7a06ebc5aa8).() |
| 583 | { |
| 584 | // already built? |
| 585 | if (vdcxx . . $ FaceList#vd.) return; |
| 586 | |
| 587 | int biggest_index = 0; |
| 588 | int i; |
| 589 | for (i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) { |
| 590 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 591 | for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) { |
| 592 | if (f->vcxx . . $ Face#v.[j] > biggest_index) biggest_index = f->vcxx . . $ Face#v.[j]; |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | vdcxx . . $ FaceList#vd. = new FaceListcxx . . $ FaceList#[biggest_index+1]; |
| 597 | vdSizecxx . . $ FaceList#vdSize. = biggest_index+1; |
| 598 | |
| 599 | // Build list of faces around each vertex |
| 600 | for (i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 601 | { |
| 602 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 603 | |
| 604 | for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) |
| 605 | { |
| 606 | vdcxx . . $ FaceList#vd.[f->vcxx . . $ Face#v.[j]].appendcxx . . $ FaceList#append(f7003f3e368fe0fc).(f); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | } |
| 611 | |
| 612 | |
| 613 | void |
| 614 | FaceListcxx . . $ FaceList#::findVertexNormalscxx . . $ FaceList#findVertexNormals(9910a12f5746ab52).(SoNormalcxx . . $ SoNormal# *norm, SoIndexedFaceSetcxx . . $ SoIndexedFaceSet# *ifs, |
| 615 | float creaseAngle) |
| 616 | { |
| 617 | buildVertexDictcxx . . $ FaceList#buildVertexDict(49f6e7a06ebc5aa8).(); |
| 618 | |
| 619 | // Initialize all faces |
| 620 | int i; |
| 621 | for (i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 622 | { |
| 623 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 624 | |
| 625 | f->findNormalcxx . . $ Face#findNormal(1bc23f47d9753cf8).(vertscxx . . $ FaceList#verts.); |
| 626 | f->vncxx . . $ Face#vn. = new int32_t[f->nvcxx . . $ Face#nv.]; |
| 627 | for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) |
| 628 | { |
| 629 | f->vncxx . . $ Face#vn.[j] = -1; |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | // Finally, create normals |
| 634 | norm->vectorcxx . . $ SoNormal#vector..deleteValuescxx . . $ SoMField#deleteValues(3e454b8ccf442868).(0); // get rid of default value |
| 635 | int count = 0; |
| 636 | for (i = 0; i < getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) |
| 637 | { |
| 638 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 639 | |
| 640 | for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) |
| 641 | { |
| 642 | if (f->degeneratecxx . . $ Face#degenerate.) |
| 643 | { |
| 644 | f->vncxx . . $ Face#vn.[j] = getIdxcxx . . $ FaceList#getIdx(59a5dbe72ccf9cee).(norm->vectorcxx . . $ SoNormal#vector., SbVec3fcxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0)); |
| 645 | } |
| 646 | else if (f->vncxx . . $ Face#vn.[j] == -1) |
| 647 | { |
| 648 | SbVec3fcxx . . $ SbVec3f# tcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 649 | vdcxx . . $ FaceList#vd.[f->vcxx . . $ Face#v.[j]].averageNormalscxx . . $ FaceList#averageNormals(b182d064961417d).(norm->vectorcxx . . $ SoNormal#vector., f->normalcxx . . $ Face#normal., |
| 650 | creaseAngle, |
| 651 | f->vcxx . . $ Face#v.[j]); |
| 652 | } |
| 653 | ifs->normalIndexcxx . . $ SoIndexedShape#normalIndex..set1Valuecxx . . $ SoMFInt32#set1Value(3e454b8ccf442868).(count, f->vncxx . . $ Face#vn.[j]); |
| 654 | ++count; |
| 655 | } |
| 656 | ifs->normalIndexcxx . . $ SoIndexedShape#normalIndex..set1Valuecxx . . $ SoMFInt32#set1Value(3e454b8ccf442868).(count, SO_END_FACE_INDEXcxx . . $ `lib/database/include/Inventor/nodes/SoIndexedFaceSet.h:76:9`!); |
| 657 | ++count; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | // |
| 662 | // get the index of a vector in a SFVec3f; |
| 663 | // adds the vector if needed. |
| 664 | // |
| 665 | // use: private |
| 666 | // |
| 667 | |
| 668 | int |
| 669 | FaceListcxx . . $ FaceList#::getIdxcxx . . $ FaceList#getIdx(59a5dbe72ccf9cee).(SoMFVec3fcxx . . $ SoMFVec3f# &mf, const SbVec3fcxx . . $ SbVec3f# &p) |
| 670 | { |
| 671 | int n = mf.getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).(); |
| 672 | SbVec3fcxx . . $ SbVec3f# *v = mf.startEditingcxx . . $ SoMFVec3f#startEditing(d7218d170b8c46e1).(); |
| 673 | |
| 674 | // search from the end, since recent vectors are likely to be reused |
| 675 | for (int i=n-1; i>=0; i--) |
| 676 | if (p ==cxx . . $ `operator==`(648f52454fd9f27). v[i]) { |
| 677 | mf.finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 678 | return i; |
| 679 | } |
| 680 | |
| 681 | mf.finishEditingcxx . . $ SoMFVec3f#finishEditing(49f6e7a06ebc5aa8).(); |
| 682 | mf.set1Valuecxx . . $ SoMFVec3f#set1Value(9c7ea36464c471ee).(n, p); |
| 683 | return n; |
| 684 | } |
| 685 | |
| 686 | // |
| 687 | // Average the normals around a vertex to get a vertex normal. Skip |
| 688 | // faces that are too different (as defined by creaseAngle) |
| 689 | // |
| 690 | void |
| 691 | FaceListcxx . . $ FaceList#::averageNormalscxx . . $ FaceList#averageNormals(b182d064961417d).(SoMFVec3fcxx . . $ SoMFVec3f# &norms, SbVec3fcxx . . $ SbVec3f# &reference, |
| 692 | float creaseAngle, int whichV) |
| 693 | { |
| 694 | SbVec3fcxx . . $ SbVec3f# averagecxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 695 | average.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d).(0.0, 0.0, 0.0); |
| 696 | |
| 697 | float ca = cos(creaseAngle); |
| 698 | |
| 699 | int num = 0; |
| 700 | int max = getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); |
| 701 | |
| 702 | // first, loop through and compute the average |
| 703 | int i; |
| 704 | for (i = 0; i < max; i++) |
| 705 | { |
| 706 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 707 | if (f->degeneratecxx . . $ Face#degenerate.) continue; |
| 708 | |
| 709 | float dp = reference.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(f->normalcxx . . $ Face#normal.); |
| 710 | if (dp >= ca) |
| 711 | { |
| 712 | average +=cxx . . $ SbVec3f#`operator+=`(13422326b1abca17). f->normalcxx . . $ Face#normal.; ++num; |
| 713 | |
| 714 | } |
| 715 | } |
| 716 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(num != 0); |
| 717 | average /=cxx . . $ SbVec3f#`operator/=`(3aaca777b5795e29). (float)num; |
| 718 | average.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 719 | |
| 720 | // insert the average into the mfield |
| 721 | int index = getIdxcxx . . $ FaceList#getIdx(59a5dbe72ccf9cee).(norms, average); |
| 722 | |
| 723 | // loop through again and insert the average's index |
| 724 | // into the face arrays |
| 725 | for (i = 0; i < max; i++) |
| 726 | { |
| 727 | Facecxx . . $ Face# *f = (*this)[cxx . . $ FaceList#`operator[]`(45a0b426fc8d6873).i]; |
| 728 | if (f->degeneratecxx . . $ Face#degenerate.) continue; |
| 729 | |
| 730 | float dp = reference.dotcxx . . $ SbVec3f#dot(adcfb95606509c95).(f->normalcxx . . $ Face#normal.); |
| 731 | if (dp >= ca) |
| 732 | { |
| 733 | for (int j = 0; j < f->nvcxx . . $ Face#nv.; j++) |
| 734 | { |
| 735 | if (f->vcxx . . $ Face#v.[j] == whichV) |
| 736 | f->vncxx . . $ Face#vn.[j] = index; |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(num != 0); |
| 741 | average /=cxx . . $ SbVec3f#`operator/=`(3aaca777b5795e29). (float)num; |
| 742 | average.normalizecxx . . $ SbVec3f#normalize(9b8c9e39889c762c).(); |
| 743 | } |