00001
00002
00003
00004
00005
00006
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030 #ifndef INTERFACE1D_H
00031 # define INTERFACE1D_H
00032
00033 # include <string>
00034 # include <iostream>
00035 # include <float.h>
00036 # include "../system/Id.h"
00037 # include "../system/Precision.h"
00038 # include "../winged_edge/Nature.h"
00039 # include "Functions0D.h"
00040
00041 using namespace std;
00045
00051 typedef enum {
00052 MEAN,
00053 MIN,
00054 MAX,
00055 FIRST,
00056 LAST
00057 } IntegrationType;
00058
00076 template <class T>
00077 T integrate(UnaryFunction0D<T>& fun,
00078 Interface0DIterator it,
00079 Interface0DIterator it_end,
00080 IntegrationType integration_type = MEAN) {
00081 T res;
00082 T res_tmp;
00083 unsigned size;
00084 switch (integration_type) {
00085 case MIN:
00086 res = fun(it);++it;
00087 for (; !it.isEnd(); ++it) {
00088 res_tmp = fun(it);
00089 if (res_tmp < res)
00090 res = res_tmp;
00091 }
00092 break;
00093 case MAX:
00094 res = fun(it);++it;
00095 for (; !it.isEnd(); ++it) {
00096 res_tmp = fun(it);
00097 if (res_tmp > res)
00098 res = res_tmp;
00099 }
00100 break;
00101 case FIRST:
00102 res = fun(it);
00103 break;
00104 case LAST:
00105 res = fun(--it_end);
00106 break;
00107 case MEAN:
00108 default:
00109 res = fun(it);++it;
00110 for (size = 1; !it.isEnd(); ++it, ++size)
00111 res += fun(it);
00112 res /= (size ? size : 1);
00113 break;
00114 }
00115 return res;
00116 }
00117
00118
00119
00120
00122
00124 class Interface1D
00125 {
00126 public:
00127
00129 Interface1D() {_timeStamp=0;}
00130
00132 virtual string getExactTypeName() const {
00133 return "Interface1D";
00134 }
00135
00136
00137
00141 virtual Interface0DIterator verticesBegin() = 0;
00145 virtual Interface0DIterator verticesEnd() = 0;
00155 virtual Interface0DIterator pointsBegin(float t=0.f) = 0;
00165 virtual Interface0DIterator pointsEnd(float t=0.f) = 0;
00166
00167
00168
00170 virtual real getLength2D() const {
00171 cerr << "Warning: method getLength2D() not implemented" << endl;
00172 return 0;
00173 }
00174
00176 virtual Id getId() const {
00177 cerr << "Warning: method getId() not implemented" << endl;
00178 return Id(0, 0);
00179 }
00180
00181
00183 virtual Nature::EdgeNature getNature() const {
00184 cerr << "Warning: method getNature() not implemented" << endl;
00185 return Nature::NO_FEATURE;
00186 }
00187
00189 virtual unsigned getTimeStamp() const {
00190 return _timeStamp;
00191 }
00192
00194 inline void setTimeStamp(unsigned iTimeStamp){
00195 _timeStamp = iTimeStamp;
00196 }
00197
00198 protected:
00199 unsigned _timeStamp;
00200 };
00201
00202 #endif // INTERFACE1D_H