00001
00002
00008 #if !defined(__geom_SimplexWithFreeVertex_h__)
00009 #define __geom_SimplexWithFreeVertex_h__
00010
00011 #if defined(DEBUG_geom) && !defined(DEBUG_SimplexWithFreeVertex)
00012 #define DEBUG_SimplexWithFreeVertex
00013 #endif
00014
00015 #ifdef DEBUG_SimplexWithFreeVertex
00016 #ifndef DEBUG_Simplex
00017 #define DEBUG_Simplex
00018 #endif
00019 #endif
00020
00021 #include "Simplex.h"
00022
00023 BEGIN_NAMESPACE_GEOM
00024
00026
00059 template<template<int,typename> class QF,
00060 int N,
00061 typename T = double>
00062 class SimplexWithFreeVertex {
00063 private:
00064
00065
00066
00067
00068
00069 typedef QF<N,T> QualityFunction;
00070
00071 public:
00072
00073
00074
00075
00076
00078 typedef T Number;
00079
00081 typedef typename QualityFunction::Vertex Vertex;
00082
00084 typedef Simplex<N,Vertex,Number> Simplex;
00085
00087 typedef typename Simplex::Face Face;
00088
00089 private:
00090
00091
00092 Simplex _simplex;
00093
00094 QualityFunction _qualityFunction;
00095
00096 public:
00097
00098
00101
00103 SimplexWithFreeVertex() :
00104 _simplex(),
00105 _qualityFunction()
00106 {}
00107
00109 SimplexWithFreeVertex(const Face& face) :
00110 _simplex(),
00111 _qualityFunction() {
00112 set(face);
00113 }
00114
00116 SimplexWithFreeVertex(const SimplexWithFreeVertex& other) :
00117 _simplex(other._simplex),
00118 _qualityFunction(other._qualityFunction)
00119 {}
00120
00122 SimplexWithFreeVertex&
00123 operator=(const SimplexWithFreeVertex& other) {
00124 if (&other != this) {
00125 _simplex = other._simplex;
00126 _qualityFunction = other._qualityFunction;
00127 }
00128 return *this;
00129 }
00130
00132 ~SimplexWithFreeVertex()
00133 {}
00134
00136
00139
00141 Vertex
00142 getFreeVertex() const {
00143 return _simplex[0];
00144 }
00145
00147 void
00148 computeBBox(BBox<N,T>* bb) const {
00149 _simplex.computeBBox(bb);
00150 }
00151
00153
00156
00158 void
00159 set(const Face& face) {
00160 for (int i = 0; i != N; ++i) {
00161 _simplex[i+1] = face[i];
00162 }
00163 }
00164
00166 void
00167 setFunction(const Vertex& v) {
00168 _simplex[0] = v;
00169 _qualityFunction.setFunction(_simplex);
00170 }
00171
00173 void
00174 set(const Vertex& v) {
00175 _simplex[0] = v;
00176 _qualityFunction.set(_simplex);
00177 }
00178
00179
00180
00183
00185 Number
00186 operator()() const {
00187 return _qualityFunction();
00188 }
00189
00191 void
00192 computeGradient(Vertex* gradient) const {
00193 _qualityFunction.computeGradient(gradient);
00194 }
00195
00197 Number
00198 operator()(const Number minimumDeterminant) const {
00199 return _qualityFunction(minimumDeterminant);
00200 }
00201
00203 void
00204 computeGradient(const Number minimumDeterminant, Vertex* gradient) const {
00205 _qualityFunction.computeGradient(minimumDeterminant, gradient);
00206 }
00207
00209 Number
00210 getDeterminant() const {
00211 return _qualityFunction.getDeterminant();
00212 }
00213
00215 Number
00216 computeContent() const {
00217 return _qualityFunction.computeContent();
00218 }
00219
00221 void
00222 computeGradientOfContent(Vertex* gradient) const {
00223 _qualityFunction.computeGradientContent(gradient);
00224 }
00225
00226
00227 };
00228
00229 END_NAMESPACE_GEOM
00230
00231 #endif