MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Position.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGPosition_HH_
6 #define _MGPosition_HH_
7 
11 #include "mg/Vector.h"
12 
13 // MGPosition.h
14 // Header for MGPosition.
15 
16 // Forward Declaration.
17 class MGMatrix;
18 class MGTransf;
19 class MGPoint;
20 class MGCurve;
21 class MGSurface;
22 class MGCParam_list;
23 class MGPosition_list;
24 class MGIfstream;
25 class MGOfstream;
26 
28 class MG_DLL_DECLR MGPosition{
29 
30 public:
31 
33 inline friend
34 MGPosition operator+(const MGPosition& p1,const MGVector& vec){return p1.m_element+vec;};
35 inline friend
36 MGPosition operator+(const MGPosition& p1,const MGPosition& p2){return p1.m_element+p2.m_element;};
37 inline friend
38 MGPosition operator+ (const MGVector& v, const MGPosition& p){return v+p.m_element;};
39 
41 inline friend
42 MGVector operator-(const MGPosition& p1,const MGPosition& p2){return p1.m_element-p2.m_element;}
43 
45 inline friend
46 MGPosition operator-(const MGPosition& p1,const MGVector& v){return p1.m_element-v;}
47 
49 inline friend
50 MGPosition operator-(const MGVector& v,const MGPosition& p1){return v-p1.m_element;}
51 
54 inline friend
55 double operator%(const MGPosition& p1,const MGVector& v){return p1.m_element%v;};
56 
59 MG_DLL_DECLR friend
60 MGPosition operator*(const MGPosition& p1,const MGMatrix& mat);
61 
64 MG_DLL_DECLR friend
65 MGPosition operator*(const MGPosition& p1,const MGTransf& tr);
66 
69 inline friend
70 MGPosition operator*(double s, const MGPosition& p){return p*s;};
71 
73 inline friend
74 MGPosition operator*(const MGPosition& p1,double s){return p1.m_element*s;};
75 
78 inline friend
79 MGPosition operator/(const MGPosition& p1,double s){return p1.m_element/s;};
80 
82 MG_DLL_DECLR friend std::ostream& operator<<(std::ostream&, const MGPosition&);
83 
86 MG_DLL_DECLR friend bool operator==(const MGPosition& p1,const MGPosition& p2);
87 MG_DLL_DECLR friend bool operator==(const MGVector& p1,const MGPosition& p2);
88 MG_DLL_DECLR friend bool operator==(const MGPosition& p1,const MGVector& p2);
89 inline friend
90 bool operator!=(const MGPosition& p1,const MGPosition& p2){return !(p1==p2);};
91 inline friend
92 bool operator!=(const MGVector& p1,const MGPosition& p2){return !(p1==p2);};
93 inline friend
94 bool operator!=(const MGPosition& p1,const MGVector& p2){return !(p1==p2);};
95 
98 inline friend
99 bool operator<(const MGPosition& p1,const MGPosition& p2){return p1.m_element<p2.m_element;};
100 inline friend
101 bool operator<=(const MGPosition& p1,const MGPosition& p2){return p1.m_element<=p2.m_element;};
102 inline friend
103 bool operator>(const MGPosition& p1,const MGPosition& p2){return p1.m_element>p2.m_element;};
104 inline friend
105 bool operator>=(const MGPosition& p1,const MGPosition& p2){return p1.m_element>=p2.m_element;};
106 
108 
110 MGPosition(const MGPoint& point);
111 
113 MGPosition(const MGVector& vec): m_element(vec){;};
114 
116 explicit MGPosition(int sdim=0):m_element(sdim,0.0){;};
117 
119 MGPosition(double x, double y):m_element(x,y){;};
120 
122 MGPosition(double x, double y, double z):m_element(x,y,z){;};
123 
125 MGPosition(double x, double y, double z, double w):m_element(x,y,z,w){;};
126 
131 MGPosition(int sdim, const double* v ):m_element(sdim,v){;};
132 
135 MGPosition(int sdim, const MGPosition& p
136  , int start1=0, int start2=0)
137  :m_element(sdim, p, start1, start2){;};
138 
140 MGPosition(const std::vector<double>& darrays): m_element(darrays){;};
141 
144 
146 // ~MGPosition(); We use default destructor.
147 
149 
152 MGPosition& operator=(const double* a);
153 
155 double operator[] (int i) const{return m_element.ref(i);}
156 double operator() (int i) const{return m_element.ref(i);}
157 
159 double& operator()(int i){return m_element(i);};
160 
163 MGPosition& operator+= (const MGVector& vec);
164 MGPosition& operator+= (const MGPosition& pos);
165 
168 MGPosition operator- () const;
169 
172 MGPosition& operator-= (const MGVector& vec);
173 
176 MGPosition& operator*=(double scale);
177 
181 
186 
189 MGPosition& operator/= (double);
190 
192 
196 double angle(
197  const MGPosition& start,
198  const MGPosition& end,
199  const MGVector& normal
200 )const;
201 
203 MGPosition& clear(double init=0.0);
204 
207 double closest(const MGCurve& curve) const;
208 
211 MGPosition closest(const MGSurface& surf) const;
212 
215 MGPosition* clone() const{return new MGPosition(*this);};
216 
218 const double* data()const{return m_element.data();};
219 double* data(){return m_element.data();};
220 
222 double distance(const MGPosition& P2)const;
223 
227 MGPosition interpolate(double t2, const MGPosition& vec2) const;
228 
233  const MGPosition& P2,
234  const MGPosition& P3
235 )const{return m_element.is_collinear(P2,P3);};
236 
238 bool is_null()const{return m_element.is_null();};
239 
242 double len() const{ return m_element.len();};
243 
250 bool on(
251  const MGCurve& curve,
252  double& t
253 ) const;
254 
261 bool on(
262  const MGSurface& surf,
263  MGPosition& uv
264 ) const;
265 
268 int out_to_IGES(
269  MGIgesOfstream& igesfile,
270  int SubordinateEntitySwitch=0
271 )const;
272 
276 double param(const MGCurve& crv) const;
277 
281 MGPosition param(const MGSurface& srf) const;
282 
287 MGCParam_list perps(
288  const MGCurve& crv
289 )const;
290 
295 MGPosition_list perps(
296  const MGSurface& srf
297 ) const;
298 
302 MGVector project(const MGVector& v2) const{return m_element.project(v2);};
303 
304 double ref(int i) const{return m_element.ref(i);}
305 
308 void resize(int new_sdim){m_element.resize(new_sdim);};
309 
311 int sdim() const {return m_element.sdim();}
312 
314 void set_null(){m_element.set_null();}
315 
320 void store_at(
321  int i,
322  const MGVector& vec2,
323  int j=0
324 );
325 
329 void store_at(
330  int i,
331  const MGVector& vec2,
332  int j,
333  int len
334 );
335 
338 void swap(int i, int j){m_element.swap(i,j);};
339 
340 const MGVector& vector() const{ return m_element;}
341 
343 int dump_size() const;
344 
346 int dump(MGOfstream& ) const;
347 
349 int restore(MGIfstream& );
350 
351 private:
352  MGVector m_element;
353 
354 };
355 
357 
360 MG_DLL_DECLR bool is_collinear(
361  const MGPosition& P1,
362  const MGPosition& P2,
363  const MGPosition& P3
364 );
365 
366 namespace MGCL{
367 
369 
371 inline double angle(const MGVector& V1, const MGVector& V2, const MGVector& N){
372  return V1.angle2pai(V2,N);
373 };
374 
376 
381 inline double angle(
382  const MGPosition& origin,
383  const MGPosition& P1,
384  const MGPosition& P2,
385  const MGVector& N
386 ){
387  return origin.angle(P1,P2,N);
388 };
389 
390 };
391  // end of BASE group
393 #endif
friend MGPosition operator*(double s, const MGPosition &p)
Definition: Position.h:70
double angle2pai(const MGVector &v2, const MGVector &N) const
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
double & operator()(int i)
Access to i-th element.
Definition: Position.h:159
MGPoint represents one dimensional manifold, a point in a space.
Definition: Point.h:28
friend MGPosition operator+(const MGPosition &p1, const MGVector &vec)
Translation of the position.
Definition: Position.h:34
MGPosition(double x, double y)
Construct 2D position by providing x,y coordinate data.
Definition: Position.h:119
double len() const
Definition: Position.h:242
MGPosition(const std::vector< double > &darrays)
Construct from std::vector
Definition: Position.h:140
bool is_null() const
Test if this is null.
Definition: Position.h:238
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
friend double operator%(const MGPosition &p1, const MGVector &v)
Definition: Position.h:55
std::ostream & operator<<(std::ostream &ostrm, const MGisect &is)
Debug Function.
Definition: isect.h:95
friend MGVector operator-(const MGPosition &p1, const MGPosition &p2)
自身のPositionと与えられたPositionの減算してMGVectorを生成
Definition: Position.h:42
MGPosition(int sdim, const double *v)
Definition: Position.h:131
MG_DLL_DECLR MGVector & operator*=(MGVector &v, const MGMatrix &m)
Vector of a general n space dimension.
Definition: Vector.h:26
friend bool operator!=(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:90
void swap(int i, int j)
Definition: Position.h:338
double angle(const MGPosition &start, const MGPosition &end, const MGVector &normal) const
bool is_collinear(const MGPosition &P2, const MGPosition &P3) const
Definition: Position.h:232
void set_null()
Set this as a null position.
Definition: Position.h:314
MG_DLL_DECLR bool is_collinear(const MGPosition &P1, const MGPosition &P2, const MGPosition &P3)
Test if P1, P2, and P3 are on a single straight line.
MGPosition(int sdim=0)
Void constructor void コンストラクタ
Definition: Position.h:116
friend MGPosition operator*(const MGPosition &p1, double s)
Scalarの乗算を行いPositionを生成
Definition: Position.h:74
friend bool operator>=(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:105
MGPosition(double x, double y, double z, double w)
Construct 4D position by providing x,y,z,w coordinate data.
Definition: Position.h:125
int sdim() const
Get the space dimension.
Definition: Position.h:311
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
Represent a positional data.
Definition: Position.h:28
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
double * data()
Definition: Position.h:219
friend MGPosition operator-(const MGVector &v, const MGPosition &p1)
自身のPositionと与えられたVectorの減算してMGPositionを生成
Definition: Position.h:50
MGVector project(const MGVector &v2) const
friend bool operator!=(const MGPosition &p1, const MGVector &p2)
Definition: Position.h:94
friend MGPosition operator+(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:36
friend MGPosition operator/(const MGPosition &p1, double s)
Definition: Position.h:79
MGParam_Vector provides a list to store parameters of a curve.
Definition: CParam_list.h:18
Definition: Curve.h:1282
friend bool operator<(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:99
double angle(const MGVector &V1, const MGVector &V2, const MGVector &N)
Compute the angel around the normal N in radian range[0., 2*pia).
Definition: Position.h:371
friend MGPosition operator-(const MGPosition &p1, const MGVector &v)
自身のPositionと与えられたVectorの減算してMGPositionを生成
Definition: Position.h:46
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
friend bool operator<=(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:101
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
MGPosition * clone() const
Definition: Position.h:215
MGPosition(const MGVector &vec)
Conversion Constructor from a vector.
Definition: Position.h:113
MGPosition(double x, double y, double z)
Construct 3D position by providing x,y,z coordinate data.
Definition: Position.h:122
void resize(int new_sdim)
Definition: Position.h:308
double ref(int i) const
Definition: Position.h:304
const MGVector & vector() const
Definition: Position.h:340
const double * data() const
Return the 1st address of the array of the point double data.
Definition: Position.h:218
MGVector project(const MGVector &v2) const
Definition: Position.h:302
friend bool operator!=(const MGVector &p1, const MGPosition &p2)
Definition: Position.h:92
MGPosition(int sdim, const MGPosition &p, int start1=0, int start2=0)
Definition: Position.h:135
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30
friend bool operator>(const MGPosition &p1, const MGPosition &p2)
Definition: Position.h:103