MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
NDDArray.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGNDDArray_HH_
6 #define _MGNDDArray_HH_
7 
11 #include "mg/MGCL.h"
12 
13 // MGNDDArray.h
14 //
15 
16 // Forward Declaration
17 class MGBPointSeq;
18 class MGKnotVector;
19 class MGKnot;
20 class MGIfstream;
21 class MGOfstream;
22 
24 
27 class MG_DLL_DECLR MGNDDArray{
28 
29 public:
30 
32 MG_DLL_DECLR friend MGNDDArray operator* (double scale, const MGNDDArray& nd);
33 
35 MG_DLL_DECLR friend std::ostream& operator<< (std::ostream&, const MGNDDArray&);
36 
38 
40 MGNDDArray():m_capacity(0),m_length(0),m_current(0),m_element(0){;};
41 
43 explicit MGNDDArray(
44  int n,
45  const double* data=0
46 );
47 
50 MGNDDArray(int n, double init, double increment=1.0);
51 
53 explicit MGNDDArray(const MGBPointSeq&);
54 
57 MGNDDArray(MGENDCOND begin, MGENDCOND end, const MGBPointSeq&);
58 
73 MGNDDArray(MGENDCOND begin, MGENDCOND end, const MGKnotVector& t);
74 
79 MGNDDArray(const MGNDDArray&, int nnew);
80 
84 MGNDDArray(const MGNDDArray&, double ts, double te);
85 
88  int start_id,
89  int num,
90  const MGNDDArray& array2
91 );
92 
99  int id1,
100  int num1,
101  const MGNDDArray& array1,
102  int id2,
103  int num2,
104  const MGNDDArray& array2
105 );
106 
108 MGNDDArray(const MGNDDArray& nd);
109 
111 virtual ~MGNDDArray(){if(m_element) delete[] m_element;};
112 
114 
116 double operator[] (int i) const{return m_element[i];};
117 double operator() (int i) const{return m_element[i];};
118 
120 double& operator[] (int i){return m_element[i];};
121 double& operator() (int i){return m_element[i];};
122 
124 MGNDDArray& operator= (const MGNDDArray& vec2);
125 
128 MGNDDArray operator+(double) const;
129 MGNDDArray& operator+=(double);
130 MGNDDArray operator-(double) const;
131 MGNDDArray& operator-=(double);
132 
136 MGNDDArray operator-() const;
137 
139 MGNDDArray operator*(double scale) const;
140 MGNDDArray& operator*= (double scale);
141 
143 bool operator== (const MGNDDArray& t2) const;
144 bool operator!= (const MGNDDArray& t2) const{return !operator==(t2);}
145 
147 
151 int add_data(double value, int mult_max=1);
152 
155 int add_data(const MGKnot& knot, int mult_max);
156 
158 void copy_removing_multi(
159  int start_id,
160  int num,
161  const MGNDDArray& array2
162 );
163 
165 const double* data(int i=0) const{ return &m_element[i]; };
166 
168 double* data(int i=0) { return &m_element[i]; };
169 
173 int del_data(int index);
174 
176 bool is_null()const{return m_length==0;};
177 
179 int length() const{ return m_length; };
180 
182 void set_length(int length);
183 
185 virtual void set_null();
186 
191 void store_with_capacityCheck(
192  int i,
193  double data
194 );
195 
202 virtual int locate(double tau) const;
203 
213 virtual int locate_multi(int start, int multi, int& index) const;
214 
217 virtual void change_range(double ts, double te);
218 
224 MGNDDArray& change_number(int nnew);
225 
227 double ref(int i) const{ return m_element[i];};
228 
230 void remove_too_near(
231  bool allow_multi=false,
232  double ratio=6.
235 );
239 
241 void remove_too_near(
242  MGBPointSeq& ordinates,
243  bool allow_multi=false,
245  double ratio=6.
248 );
252 
258 void reshape(int size, int start=0);
259 
262 void resize(int nsize);
263 
265 int capacity() const { return m_capacity; };
266 
268 MGNDDArray& update_from_knot(const MGKnotVector& t);
269 
272 virtual int dump_size() const;
273 
275 virtual int dump(MGOfstream&)const;
276 
278 virtual int restore(MGIfstream& );
279 
281 protected:
282  mutable int m_current;
283 
284 private:
285  int m_capacity;
286  int m_length;
287  double* m_element;
288 
289 };
290  // end of BASE group
292 #endif
int capacity() const
Return the size of MGNDDArray.
Definition: NDDArray.h:265
double * data(int i=0)
Return a pointer to raw data of MGNDDArray.
Definition: NDDArray.h:168
int length() const
Return the length of MGNDDArray.
Definition: NDDArray.h:179
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
MG_DLL_DECLR MGVector & operator*=(MGVector &v, const MGMatrix &m)
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
MGNDDArray()
void constructor.
Definition: NDDArray.h:40
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
bool is_null() const
Test if this is null.
Definition: NDDArray.h:176
double ref(int i) const
Reference to i-th element.
Definition: NDDArray.h:227
Defines BPoint seq of a space dimension and of a capacity.
Definition: BPointSeq.h:38
int m_current
current interval of the array is held.
Definition: NDDArray.h:282
const double * data(int i=0) const
Return a pointer to raw data of MGNDDArray.
Definition: NDDArray.h:165
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
virtual ~MGNDDArray()
Definition: NDDArray.h:111
MGENDCOND
End condition to get spline by interpolation.
Definition: MGCL.h:219
Defines non-decreasing double data array.
Definition: NDDArray.h:27
Defines knot value and its multiplicity.
Definition: Knot.h:20