/usr/include/snlSurface.h is in libsnl-dev 0.2.1.svn.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | // libSNL - Simple Nurbs Library
// Copyright 2003 Scott A.E. Lanham, Australia.
// --------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// *** General NURBS Surface ***
#ifndef SNLSURFACE_H
#define SNLSURFACE_H
#include "snlCtrlPointNetSurface.h"
#include "snlCurve.h"
#include "snlKnotVector.h"
#include "snlPoint.h"
#include "snlSurfaceBase.h"
#include "snlVertex.h"
#include "snlVertexNet.h"
#include "ptrList.h"
#define SNL_INV_ITER_VP 8 // Number of iterations for velocity pass.
#define SNL_INV_ITER_NP 8 // Number of iterations for newton pass.
#define SNL_NUMERIC_NOISE 1.0e-14
typedef struct
{
/* Surface Edge */
int direction; // u = 0, v = 1.
knot pVal; // Parameter value.
} sEdge;
typedef struct
{
// surface location.
knot paramU; // Evaluated parameter in u direction. Point found.
knot paramV; // Evaluated parameter in v direction.
snlPoint pt; // Point corresponding to parameters.
basis dist; // Distance from point being inverted / projected to point found.
double cos; // Cos of angle to normal.
int origPtIndex; // For inversion and projection, the index of the original point handed to the
// relevant function.
} snlSurfLocn;
typedef struct
{
// surface location.
knot paramU; // Evaluated parameter in u direction. Point found.
knot paramV; // Evaluated parameter in v direction.
snlPoint pt; // Point corresponding to parameters.
basis dist; // Distance squared from point being inverted to point found.
double cos; // Cos of angle to normal.
int origPtIndex; // For inversion and projection, the index of the original point handed to the
// relevant function.
int spanNumber; // Absolute span number guess belongs to.
knot minU; // Parametric boundaries used for culling.
knot maxU;
knot minV;
knot maxV;
bool culled;
bool ignoreParamBounds; // Don't cull this point if it goes out of bounds.
bool converged;
} snlSurfLocnGuess;
typedef struct
{
// Control point location for surface
int uIndex; // Array indexes.
int vIndex;
snlCtrlPoint* ctrlPt; // Pointer to control point found.
double dist; // Distance to control point from comparison point.
} snlSCtrlPtLocn;
typedef struct
{
bool converged;
bool stalled; // Can't converge
int arcIndex;
double arcAngle;
// Controlling Surface.
knot cParamU;
knot cParamV;
snlPoint cPt; // Evaluated point.
snlPoint normPt; // Normal point.
snlVector velU; // U direction velocity.
snlVector velV; // V direction velocity.
// Matching Surface.
knot mParamU;
knot mParamV;
snlPoint mPt; // Evaluated point.
} arcLocn;
class snlSurface : public snlSurfaceBase
{
public:
virtual ~snlSurface();
snlSurface();
void init(); // Standard Initialisation.
snlSurface ( const snlSurface& surfaceToCopy ); // Copy constructor.
snlSurface ( int degreeU, int degreeV, unsigned sizeU, unsigned sizeV,
snlPoint& origin, snlPoint& cornerMaxU, snlPoint& cornerMaxV );
snlSurface ( int degreeU, int degreeV, unsigned sizeU, unsigned sizeV, snlCtrlPoint* points,
knot* knotsU, knot* knotsV );
snlSurface ( snlCurve& curve1, snlCurve& curve2, int direction = SNL_U_DIR ); // Generate ruled surface.
snlSurface ( snlCurve& generator, snlPoint& axisStart, snlPoint& axisEnd, double angle ); // Surface of revolution.
snlSurface ( snlCurve** curves, int numCurves, int dir = SNL_U_DIR ); // Skinned surface.
snlSurface ( int interpType, snlPoint* pointsInterp, int sizeU, int sizeV,
int degreeU, int degreeV ); // Interpolated surface.
typedef enum
{
//SNL_PRIM_AUTO,
SNL_PRIM_PLANE,
SNL_PRIM_SPHERE,
SNL_PRIM_CYLINDER,
SNL_PRIM_CONE,
SNL_BILINEAR_COONS
} snlPrimType;
// Construct surface that fits a closed loop as described by points.
snlSurface ( snlPoint* points, int numPoints ); // Unknown topology.
snlSurface ( snlPoint* points, int numPoints, snlPrimType primType, snlPoint* axisStart = 0, snlPoint* axisEnd = 0 );
snlSurface ( snlCurve* U1, snlCurve* U2, snlCurve* V1, snlCurve* V2 ); // Bilinear Coons patch.
// Operators
snlSurface& operator= ( const snlSurface& surface );
// Interpolation Functions.
enum SNL_INTERP_TYPES
{
SNL_GLOBAL_INTERP_CHORDLENGTH,
SNL_GLOBAL_INTERP_CENTRIFUGAL
};
// Data functions.
int degreeU() const;
int degreeV() const;
unsigned sizeU() const;
unsigned sizeV() const;
knot minU();
knot maxU();
knot minV();
knot maxV();
const snlCtrlPoint* controlPoints();
const knot* knotsU();
const knot* knotsV();
snlCtrlPointNetSurface& controlPointNet();
const snlKnotVector& knotVectorU();
const snlKnotVector& knotVectorV();
// Evaluation functions.
// Non-rational homogeneous surface point.
snlPoint evalHmg ( knot paramU, knot paramV, basis* basisU = 0, basis* basisV = 0 ) const;
// Rational non-homogeneous surface point.
virtual snlPoint eval ( knot paramU, knot paramV, basis* basisU, basis* basisV ) const;
virtual snlPoint eval ( knot paramU, knot paramV ) const;
// Derivatives.
snlPoint* evalDerivsHmg ( knot paramU, knot paramV, unsigned derivU, unsigned derivV,
basis* basisU = 0, basis* basisV = 0 );
snlPoint* evalDerivs ( knot paramU, knot paramV, unsigned derivU, unsigned derivV );
void velocities ( knot paramU, knot paramV, snlPoint& evalPoint, snlVector& velocityU, snlVector& velocityV,
basis* basisU = 0, basis* basisV = 0 );
// Knot manipulation.
void insertKnot ( knot iParam, int dir, bool reallocate = true );
void insertKnot ( knot iParam, int dir, int numToInsert, bool reallocate = true );
double removeKnots ( int numKnots, unsigned removalIndex, int direction, double tolerance, bool reallocate = true );
double removeKnot ( unsigned removalIndex, int direction, double tolerance, bool reallocate = true );
// Projection.
snlVertex* project_depr ( snlPoint* toProject, int numPoints, double convergTol, double
normTol, int maxPass );
snlSurfLocn* invert ( snlPoint* toInvert, int numPoints, int* retArraySize,
double convergTol, double normTol, int maxPass );
snlSurfLocn* project ( snlPoint* toProject, int numPoints, int* retArraySize,
double convergTol, double normTol, int maxPass );
snlSurfLocn* fastProject ( snlPoint* toProject, int numPoints, int* retArraySize,
double convergTol, double normTol, int maxPass,
int sensitivity, int maxLocns );
snlSCtrlPtLocn* findClosestCtrlPt ( snlPoint* points, int numPoints );
// Try to predict edges that may have ambiguities during projection.
int hasAmbigEdges ( sEdge* results, double tolerance = 1.0e-6 );
int hasAmbigEdges_depr ( sEdge* results );
// Surface decomposition.
unsigned createBezierSegments ( int dir, int** numKnotsAdded = 0);
void createBezierSegments ( int* numU = 0, int* numV = 0 );
void createConvexBezierSegments ( int* numU = 0, int* numV = 0, double sensitivity = 0.0 );
void elevateDegree ( int direction, int byDegree );
double reduceDegree ( int dir, unsigned numDeg, double tolerance );
void refine ( double tolerance ); // Refine control point net.
void refineHull_UV ( double tolerance ); // Refine control point net using convex hull methods.
bool refineHull_U ( double tolerance, bool singlePass = false );
bool refineHull_V ( double tolerance, bool singlePass = false );
void refineHullBezier ( double tolerance ); // Refine control point net by Bezier patch subdivision.
double maxCurvatureU();
double maxCurvatureV();
snlVector calcNormal ( knot paramU, knot paramV, snlPoint* evalPt = 0 );
snlCurve* extractEdge ( int edge );
snlSurface* fillet ( int edge, snlVector& frontFaceNormal,
snlSurface& surface2, snlVector& frontFaceNormal2,
double tolerance, double radius, bool trim1, bool trim2 );
void transform ( snlTransform& transf );
void makeCompatible ( snlSurface* surfaceToMatch, int direction );
void synchronise ( snlSurface& surface, int direction );
// Trimming Functions.
void addTrimCurve ( snlCurve* curve );
bool removeTrimCurve ( snlCurve* curve );
// Misc Functions.
void print();
void print_cpp();
// Abstract Implementation.
virtual void vertexNet ( snlVertexNet* vNet, double tolerance, bool parametric );
virtual void triangleMesh ( snlTriangleMesh* triMesh, int toleranceType, double tolerance );
enum parametricDirections
{
SNL_U_DIR = 0,
SNL_V_DIR = 1
};
enum surfaceEdges
{
SNL_EDGE_UMIN,
SNL_EDGE_UMAX,
SNL_EDGE_VMIN,
SNL_EDGE_VMAX
};
protected:
void copyFrom ( const snlSurface& surfaceToCopy );
void fitBilinearCoons ( snlPoint* points, int numPoints );
void genBilinearCoons ( snlCurve* curve_U1, snlCurve* curve_U2, snlCurve* curve_V1, snlCurve* curve_V2 );
void fitPlane ( snlPoint* points, int numPoints );
void fitCylinder ( snlPoint* points, int numPoints, snlPoint* axisStart, snlPoint* axisEnd );
void fitCone ( snlPoint* points, int numPoints, snlPoint* axisStart, snlPoint* axisEnd );
void fitSphere ( snlPoint* points, int numPoints, snlPoint* sphereCentre );
knot* globalInterpGenParams ( int type, snlPoint* points, int sizeU, int sizeV, int dir );
void genGlobalInterpSurf ( int interpType, snlPoint* pointsInterp, int sizeU, int sizeV, int degreeU, int degreeV );
snlSurfLocn* processGuesses ( snlPoint* points, int numPoints, int* retArraySize,
ptrList <snlSurfLocnGuess>* guesses, double convergTol,
double normTol, int maxPass, bool retNonConverged = false, bool noCull = false,
int numVelocity = SNL_INV_ITER_VP, int numNewton = SNL_INV_ITER_NP );
bool convergeVelocity ( snlPoint* convergToPts, ptrList <snlSurfLocnGuess>* guesses,
int numIterations, double convergTol, double normTol );
bool convergeNewton ( snlPoint* convergToPts, ptrList <snlSurfLocnGuess>* guesses,
int numIterations, double convergTol, double normTol );
ptrList <snlSurfLocnGuess>* guessInvLocation ( snlPoint* points, int numPoints, bool* pointMask,
int granU, int granV );
ptrList <snlSurfLocnGuess>* guessProjLocation ( snlPoint* points, int numPoints, bool* pointMask );
ptrList <snlSurfLocnGuess>* guessFastProjLocation ( snlPoint* points, int numPoints, int maxGuessPerPt,
int granU, int granV );
ptrList <snlSurfLocnGuess>* guessProjLocation_triMethod ( snlPoint* points, int numPoints,
bool* pointMask );
void genSurfRevolution ( snlCurve& generator, snlPoint& axisStart, snlPoint& axisEnd, double angle );
// Data Section
int degU; // Degree of surface in U direction.
int degV; // Degree of surface in V direction.
snlCtrlPointNetSurface* ctrlPtNet;
snlKnotVector* knotVectU;
snlKnotVector* knotVectV;
ptrList< snlCurve >* trim_curves;
};
#endif
|