Blender  V2.93
normal_cycle.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is:
17  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
18  * Copyright (C) 2000 Bruno Levy
19  * Contact: Bruno Levy
20  * <levy@loria.fr>
21  * ISA Project
22  * LORIA, INRIA Lorraine,
23  * Campus Scientifique, BP 239
24  * 54506 VANDOEUVRE LES NANCY CEDEX
25  * FRANCE
26  */
27 
28 #pragma once
29 
34 #include "Geom.h"
35 
36 #include "../system/FreestyleConfig.h"
37 
38 #ifdef WITH_CXX_GUARDEDALLOC
39 # include "MEM_guardedalloc.h"
40 #endif
41 
42 namespace Freestyle {
43 
44 using namespace Geometry;
45 
46 namespace OGF {
47 
48 template<class T> inline void ogf_swap(T &x, T &y)
49 {
50  T z = x;
51  x = y;
52  y = z;
53 }
54 
55 //_________________________________________________________
56 
65 class NormalCycle {
66  public:
67  void begin();
68  void end();
72  void accumulate_dihedral_angle(const Vec3r &edge, real angle, real neigh_area = 1.0);
73 
74  const Vec3r &eigen_vector(int i) const
75  {
76  return axis_[i_[i]];
77  }
78 
79  real eigen_value(int i) const
80  {
81  return eigen_value_[i_[i]];
82  }
83 
84  const Vec3r &N() const
85  {
86  return eigen_vector(2);
87  }
88 
89  const Vec3r &Kmax() const
90  {
91  return eigen_vector(1);
92  }
93 
94  const Vec3r &Kmin() const
95  {
96  return eigen_vector(0);
97  }
98 
99  real n() const
100  {
101  return eigen_value(2);
102  }
103 
104  real kmax() const
105  {
106  return eigen_value(1);
107  }
108 
109  real kmin() const
110  {
111  return eigen_value(0);
112  }
113 
114  private:
115  /* UNUSED */
116  // real center_[3];
117  Vec3r axis_[3];
118  real eigen_value_[3];
119  real M_[6];
120  int i_[3];
121 
122 #ifdef WITH_CXX_GUARDEDALLOC
123  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:OGF:NormalCycle")
124 #endif
125 };
126 
127 inline void NormalCycle::accumulate_dihedral_angle(const Vec3r &edge,
128  const double beta,
129  double neigh_area)
130 {
131  double s = beta * neigh_area / edge.norm();
132 
133  M_[0] += s * edge.x() * edge.x();
134  M_[1] += s * edge.x() * edge.y();
135  M_[2] += s * edge.y() * edge.y();
136  M_[3] += s * edge.x() * edge.z();
137  M_[4] += s * edge.y() * edge.z();
138  M_[5] += s * edge.z() * edge.z();
139 }
140 
141 //_________________________________________________________
142 
143 } // namespace OGF
144 
145 } /* namespace Freestyle */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Vectors and Matrices (useful type definitions)
Read Guarded memory(de)allocation.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
const Vec3r & eigen_vector(int i) const
Definition: normal_cycle.h:74
const Vec3r & N() const
Definition: normal_cycle.h:84
const Vec3r & Kmin() const
Definition: normal_cycle.h:94
const Vec3r & Kmax() const
Definition: normal_cycle.h:89
real eigen_value(int i) const
Definition: normal_cycle.h:79
value_type x() const
Definition: VecMat.h:532
value_type z() const
Definition: VecMat.h:552
value_type y() const
Definition: VecMat.h:542
value_type norm() const
Definition: VecMat.h:109
#define T
void ogf_swap(T &x, T &y)
Definition: normal_cycle.h:48
inherits from class Rep
Definition: AppCanvas.cpp:32
static unsigned x[3]
Definition: RandGen.cpp:87
double real
Definition: Precision.h:26
ccl_device_inline float beta(float x, float y)
Definition: util_math.h:666