MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Ellipse.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGEllipse_HH_
6 #define _MGEllipse_HH_
7 
8 #include "mg/Curve.h"
9 #include "mg/Position.h"
10 #include "mg/Unit_vector.h"
11 
12 // MGEllipse.h
13 // header for class MGEllipse
14 //
15 
16 class MGInterval;
17 class MGMatrix;
18 class MGTransf;
19 class MGCCisect_list;
20 class MGPosition_list;
21 class MGLBRep;
22 class MGStraight;
23 class MGIfstream;
24 class MGOfstream;
25 class MGKnotVector;
27 
33 
38 class MG_DLL_DECLR MGEllipse : public MGCurve {
39 
40 public:
41 
43 MG_DLL_DECLR friend MGEllipse operator+ (const MGVector& v, const MGEllipse& e);
44 MG_DLL_DECLR friend MGEllipse operator* (double scale, const MGEllipse& el);
45 
47 
49 MGEllipse();
50 
54 MGEllipse(const MGEllipse& el, bool to_radian=false);
55 
57 MGEllipse (int sdim
58  , const MGEllipse& ellip
59  , int start1=0
60  , int start2=0
61 );
62 
68 MGEllipse (
69  const MGPosition& center,
70  const MGVector& major_axis,
71  const MGVector& minor_axis,
72  const MGInterval& prange
73 );
74 
77 MGEllipse (
78  const MGPosition& center,
79  double r,
80  const MGVector& normal=mgZ_UVEC
81 );
82 
88 MGEllipse (
89  const MGPosition& center
90  , const MGPosition& spoint
91  , double d= mgDBLPAI
92  , const MGVector& v=mgZ_UVEC
93 );
94 
103 MGEllipse(
104  const MGPlane& plane,
105  const MGPosition& corner1,
106  MGPosition& corner2
107 );
108 
118 MGEllipse(
119  double r,
120  const MGPosition& start,
121  const MGPosition& end,
122  const MGVector& N,
123  bool whole_circle=false
124 );
125 
139 MGEllipse(
140  double r,
141  const MGPosition& start,
142  const MGPosition& end,
143  const MGPosition& reference,
144  bool whole_circle=false
145  );
146 
157 MGEllipse (
158  const MGPosition &P
159  , const MGVector & V1
160  , const MGVector & V2
161  , double d
162 );
163 
166 MGEllipse (
167  const MGPosition& start,
168  const MGPosition& through,
169  const MGPosition& end,
170  bool whole_circle=false
171 );
172 
174 MGEllipse(
175  const MGPosition& center,
176  const MGPosition& start,
177  const MGPosition& end,
178  const MGVector& N,
179  bool whole_circle=false
180 );
181 
184 MGEllipse(
185  const MGPosition& start,
186  const MGPosition& end,
187  const MGVector& dir_s,
188  bool whole_circle=false
189 );
190 
203 MGEllipse (
204  const MGCurve& crv1,
205  const MGCurve& crv2,
206  const MGUnit_vector& normal,
207  double dRadius,
208  double& t1,
209  double& t2,
211  int& rc
213 );
214 
228 MGEllipse (
229  const MGCurve& crv1,
230  const MGCurve& crv2,
231  const MGUnit_vector& normal,
232  double t1,
233  double& t2,
234  int& rc
236 );
237 
247 MGEllipse (
248  const MGCurve& crv1,
249  const MGCurve& crv2,
250  const MGCurve& crv3,
251  const MGUnit_vector& normal,
252  double& t1,
253  double& t2,
255  double& t3,
257  int& rc
259 );
260 
270 MGEllipse (
271  const MGCurve& crv,
272  const MGPosition& pos,
273  const MGUnit_vector& normal,
274  double dRadius,
275  double& dParam,
276  int& rc
278 );
279 
283 MGEllipse (
284  const MGCurve& crv,
285  const MGPosition& P2,
286  const MGUnit_vector& normal,
287  double t
288 );
289 
291 MGEllipse(
292  const MGIgesDirectoryEntry& de
293 );
294 
296 ~MGEllipse();
297 
299 
303 MGEllipse& operator=(const MGGel& gel2);
304 MGEllipse& operator=(const MGEllipse& el2);
305 
307 MGEllipse operator+ (const MGVector&) const;
308 MGEllipse operator- (const MGVector&) const;
309 MGEllipse operator* (double scale) const;
310 MGEllipse operator* (const MGMatrix&) const;
311 MGEllipse operator* (const MGTransf&) const;
312 
314 MGEllipse& operator+=(const MGVector& v);
315 MGEllipse& operator-=(const MGVector& v);
316 MGEllipse& operator*=(double scale);
317 MGEllipse& operator*=(const MGMatrix& mat);
318 MGEllipse& operator*=(const MGTransf& tr);
319 
321 bool operator==(const MGEllipse& gel2)const;
322 bool operator==(const MGGel& gel2)const;
323 bool operator<(const MGEllipse& gel2)const;
324 bool operator<(const MGGel& gel2)const;
325 
327 
329 int bdim() const {return 2;};
330 
334 MGBox box_limitted( const MGInterval&) const;
335 
337 MGPosition center()const{return m_center;};
338 
341  int sdim,
342  int start1=0,
343  int start2=0
344 );
345 
347 void change_param_to_radian();
348 
351 void change_range(
352  double t1,
353  double t2
354 );
355 
358 bool circle() const {return m_circle!=0;};
359 
362 MGEllipse* clone() const;
363 
368 MGCurve* copy_as_nurbs() const;
369 
374  int sdim,
375  int start1=0,
376  int start2=0
377 )const;
378 
381 MGEllipse& coordinate_exchange(int i, int j);
382 
390 bool create_ellipse(
391  const MGPosition& F0,
392  const MGPosition& F1,
393  const MGPosition& P
394  );
395 
399 double curvilinear_integral(double t1, double t2) const;
400 
401 #ifdef __sgi
402  double curvilinear_integral() const
403  { return curvilinear_integral(param_s(), param_e());};
404 #endif
405 
406 void drawSE(
407  mgVBO& vbo,
408  double span_length,
409  double t0,
410  double t1
411 )const;
413 
415 MGELLIPSE_TYPE ellipse_type()const;
416 
419 MGVector eval(
420  double,
421  int nderiv=0,
422  int left=0
423 ) const;
425 
428 MGVector eval_deriv ( double ) const;
429 
432 void eval_all (
433  double d,
434  MGPosition& p,
435  MGVector& v1,
436  MGVector& v2
437 ) const;
438 
441 MGVector eval_in_radian(
442  double t,
443  int nderiv=0
444 ) const;
445 
448 MGVector eval_in_degree(
449  double degree,
450  int nderiv=0
451 ) const;
452 
456 MGPosition eval_position(double t)const{
457  t=range(t);
458  return eval_in_radian2(gp_to_radian(t));
459 };
460 
463 void extend(
464  double length,
465  bool start=false
466 );
468 
470 double gp_to_radian(double t)const{
471  if(param_range_is_in_radian())
472  return t;
473  return m_prange[0]+(t-m_gprange[0])*m_gprange[2];
474 }
475 
477 long identify_type() const;
478 
482 bool in_RelativeRange_of_radian(double t) const;
483 
485 int intersect_dnum() const;
486 
489 MGCCisect_list isect(const MGCurve&) const;
490 MGCCisect_list isect(const MGStraight& curve2)const;
491 MGCCisect_list isect(const MGEllipse& curve2)const;
492 MGCCisect_list isect(const MGSurfCurve& curve2)const;
493 MGCCisect_list isect(const MGBSumCurve& curve2)const;
494 
496 
498 MGCSisect_list isect(const MGSurface& surf) const;
499 MGCSisect_list isect(const MGPlane& surf) const;
500 MGCSisect_list isect(const MGSphere& surf)const;
501 MGCSisect_list isect(const MGCylinder& surf)const;
502 MGCSisect_list isect(const MGSBRep& surf)const;
503 MGCSisect_list isect(const MGRSBRep& surf)const;
504 MGCSisect_list isect(const MGBSumSurf& surf)const;
505 
509 bool is_linear(MGStraight& straight)const;
510 
514 bool is_planar(MGPlane& plane)const;
515 
518 bool is_whole_ellipse()const;
519 
522 double knot(int i) const;
523 
525 const MGKnotVector& knot_vector() const;
527 
530 MGEllipse& limit(const MGInterval& );
531 
535 void negate();
536 
538 double negate_param(double t)const;
539 
541 MGCurve& unlimit();
542 
546 
550 
556 double length(double t1, double t2) const;
557 
560 double length() const;
561 
566 double length_param(double t, double len) const;
567 
569 const MGVector& major_axis() const {return m_m;};
570 
572 double major_len() const {return m_m.len();};
573 
575 const MGVector& minor_axis() const {return m_n;};
576 
578 double minor_len() const {return m_n.len();};
579 
581 const MGUnit_vector& normal() const {return m_normal;};
582 
589 bool on(
590  const MGPosition&,
591  double& d1
592 ) const;
593 
595 int order() const{return 2;};
596 
598 double param_e() const{
599  if(m_gprange) return m_gprange[1];
600  else return m_prange[1];
601 };
602 
605 double param_normalize(double t) const;
606 
608 double param_s() const{
609  if(m_gprange) return m_gprange[0];
610  else return m_prange[0];
611 };
612 
614 bool param_range_is_in_radian()const{return m_gprange==0;};
615 
619 MGEllipse* part(
620  double t1,
621  double t2,
622  int multiple=0
623 ) const;
625 
631 int perp_point (
632  const MGPosition &p,
633  double& d,
634  const double*g=NULL
635 ) const;
636 
642  const MGPosition &
643 ) const;
644 
652 MGPosition_list perps(const MGCurve& crv2)const;
653 MGPosition_list perps(const MGStraight& crv2)const;
654 
656 double radian_to_gp(double angle)const{
657  if(!m_gprange) return angle;
658  return m_gprange[0]+(angle-m_prange[0])/m_gprange[2];
659 }
660 
662 double radius()const{return m_r;};
663 
665 int sdim() const ;
666 
669 void set_arc(
670  const MGPosition& start,
671  const MGPosition& end,
672  const MGVector& dir_s
673 );
674 
681  const MGUnit_vector& uvec,
682  double start_dist,
683  double end_dist
684 ) const;
687 
689 
692 std::ostream& out(std::ostream& ostrm) const;
693 
695 int out_to_IGES(
696  MGIgesOfstream& igesfile,
697  int SubordinateEntitySwitch=0
698 )const;
699 
700 protected:
701 
705  double f,
706  int coordinate=0
707 ) const;
708 
713 std::auto_ptr<MGCurve> oneD(
714  const double g[4]
715 ) const;
716 
718 void ReadMembers(MGIfstream& buf);
719 
721 void WriteMembers(MGOfstream& buf) const;
722 
723 std::string whoami()const{return "Ellipse";};
724 
725 private:
726 
728  MGPosition m_center;
729  MGUnit_vector m_normal;
730  MGVector m_m;
732  MGVector m_n;
733  double m_r;
734  double m_prange[2];
735  int m_circle;
737  double* m_gprange;
738  mutable MGKnotVector* m_knotV;
742 
747 int axis() const;
748 
750 MGBox* compute_box() const;
751 
756 MGVector eval_in_radian2(
757  double t,
758  int nderiv=0
759 ) const;
760 
762 void copy_ellipse_data(const MGEllipse& ellipse2);
763 
767 bool in_radian_range(double angle) const;
768 
772 int isect2d(
773  const MGPosition& sp,
774  const MGVector& dir,
775  double t[2],
776  double angle[2],
777  int& tangen
778 ) const;
779 
783 int perp2d(double p,
784  double q,
785  double theta[4]
786 ) const;
787 
790 double param_length(double p1, double p2) const;
791 
795 double RelativeRange_in_radian(double angle) const;
796 
799 void set_param(
800  double a0,
801  double a1
802 );
803 
805 void set_normal_r_c();
806 
807 friend class MGCylinder;
808 friend class MGSphere;
809 
810 };
811  // end of GEO group
813 #endif
virtual MGCurve & operator=(const MGCurve &gel2)
Assignment.
Definition: Curve.h:84
virtual MGCurve & unlimit_start()=0
Unlimit parameter range of the curve to the start point direction.
virtual long identify_type() const =0
Return This object's typeID.
virtual MGCurve & unlimit()=0
Unlimit parameter range of the curve(limitをはずす).
int bdim() const
Returns B-Rep Dimension.
Definition: Ellipse.h:329
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
const MGVector & minor_axis() const
Return minor axis:短軸を返却する
Definition: Ellipse.h:575
MGPlane is infinite plane in 3D space.
Definition: Plane.h:38
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
virtual MGCurve * copy_change_dimension(int sdim, int start1=0, int start2=0) const =0
Construct new curve object by changing the original object's space dimension.
MGCylinder is a Cylinder in 3D space.
Definition: Cylinder.h:37
const double mgDBLPAI
2.0 * π 値の設定
Definition: MGCL.h:101
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
virtual MGCParam_list perps(const MGPosition &P) const
Compute all foot points of the perpendicular line from point to the curve.
virtual double length_param(double t, double len) const
Inverse function of length.
MGPosition center() const
Return the center of the ellipse:楕円の中心座標を返却する。
Definition: Ellipse.h:337
virtual void negate()=0
Negate the curve direction(曲線の方向を反転する).
virtual double negate_param(double t) const =0
Obtain the parameter value to t when this curve is negated by "negate()".
virtual void drawSE(mgVBO &vbo, double span_length, double t0, double t1) const
Draw this curve into vbo, approximating with polyline.
bool circle() const
Definition: Ellipse.h:358
const MGVector & major_axis() const
Return major axis:長軸を返却する。
Definition: Ellipse.h:569
virtual MGCurve & operator+=(const MGVector &v)=0
Object transformation.
virtual MGCurve * clone() const =0
Construct new geometry object by copying to newed area.
virtual MGCurve & coordinate_exchange(int i, int j)=0
Exchange ordering of the coordinates.
double radian_to_gp(double angle) const
Compute general parameter t from the radian parameter angle.
Definition: Ellipse.h:656
virtual void eval_all(double, MGPosition &, MGVector &, MGVector &) const
Compute position, 1st and 2nd derivatives.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual int sdim() const =0
Return space dimension.
MGPosition eval_position(double t) const
Definition: Ellipse.h:456
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
MGIgesDirectoryEntry describes a directory entry section of an IGES file.
Definition: IgesDirectoryEntry.h:20
int order() const
Returns the order.
Definition: Ellipse.h:595
Vector of a general n space dimension.
Definition: Vector.h:26
std::string whoami() const
Definition: Ellipse.h:723
double gp_to_radian(double t) const
Compute the radian parameter of the general parameter t;.
Definition: Ellipse.h:470
Defines a Box of any space dimendion.
Definition: Box.h:34
Define MGBSumCurve Class(Boolean sum curve of three curves).
Definition: BSumCurve.h:28
virtual void change_range(double t1, double t2)=0
Change parameter range.
double minor_len() const
Return major axis length:長軸の長さを返却する。
Definition: Ellipse.h:578
virtual MGCurve & limit(const MGInterval &rng)=0
Update this by limiting the parameter range of the curve.
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
virtual void ReadMembers(MGIfstream &buf)
メンバデータを読み出す関数.
virtual MGVector eval(double, int nderiv=0, int left=0) const =0
Evaluate n'th derivative data.
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
virtual MGCurve * part(double t1, double t2, int multiple=0) const =0
Compute part of this curve from parameter t1 to t2.
virtual double knot(int i) const =0
Access to i-th element of knot.
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
virtual double param_normalize(double t) const =0
Normalize parameter value t to the nearest knot if their distance is within tolerance.
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
Represent a positional data.
Definition: Position.h:28
virtual double param_s() const =0
Return starting parameter value.
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
MGCSisect_list defines linked list of MGCSisect.
Definition: CSisect_list.h:22
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
virtual double range(double t) const
Round t into curve's parameter range.
virtual MGCurve & unlimit_end()=0
Unlimit parameter range of the curve to the end point direction.
Defines Boolean sum surface.
Definition: BSumSurf.h:26
double param_s() const
Return starting parameter value.
Definition: Ellipse.h:608
virtual MGSurface * sweep(const MGUnit_vector &uvec, double start_dist, double end_dist) const =0
Return sweep surface from crv.
MGELLIPSE_TYPE
Ellipse type(楕円の種類).
Definition: MGCL.h:158
virtual bool is_linear(MGStraight &straight) const
Test if this cure is linear or not, that is, is straight or not.
virtual MGCurve & operator-=(const MGVector &v)=0
bool param_range_is_in_radian() const
Test if this ellipase 's parameter range is expressed in radian.
Definition: Ellipse.h:614
MGParam_Vector provides a list to store parameters of a curve.
Definition: CParam_list.h:18
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual void WriteMembers(MGOfstream &buf) const
メンバデータを書き込む関数.
Defines a list of MGCCisect(curve to curve intersection).
Definition: CCisect_list.h:20
virtual std::ostream & out(std::ostream &) const
Output virtual function.
virtual const MGKnotVector & knot_vector() const =0
Returns the knot vector of the curve.
virtual void extend(double length, bool start=false)=0
Extrapolate this curve by an (approximate) chord length.
double radius() const
Return the radius of the circle. This is valid only when circle() is true.
Definition: Ellipse.h:662
double major_len() const
Return major axis length:長軸の長さを返却する。
Definition: Ellipse.h:572
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
virtual MGCurve & change_dimension(int sdim, int start1=0, int start2=0)=0
Changing this object's space dimension.
MGCURVE_TYPE
Curve type(曲線の種類).
Definition: MGCL.h:143
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
virtual MGCurve & operator*=(double scale)=0
virtual double length() const
Compute whole curve length.
Definition: Curve.h:624
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
MGCURVE_TYPE type() const
Return curve type(曲線のタイプを返す)
Definition: Ellipse.h:686
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
virtual bool on(const MGPosition &point, double &t) const
Test if given point is on the curve or not.
virtual bool operator==(const MGCompositeCurve &crv) const
Comparison.
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
virtual std::auto_ptr< MGCurve > oneD(const double g[4]) const =0
Obtain transformed 1D curve expression of this curve.
virtual MGCurve * copy_as_nurbs() const =0
copy as a newed curve.
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
virtual bool operator<(const MGGel &gel2) const =0
const MGUnit_vector & normal() const
Return normal:楕円のある平面の法線ベクトルを返却する。
Definition: Ellipse.h:581
virtual MGBox box_limitted(const MGInterval &) const =0
Return minimum box that includes the curve of parameter interval.
virtual MGVector eval_deriv(double) const
Compute 1st derivative.
MGEllipse(Ellipse). 楕円
Definition: MGCL.h:146
virtual MGCParam_list intersect_1D(double f, int coordinate=0) const
Compute intersection point of 1D sub curve of original curve.
virtual double param_e() const =0
Return ending parameter value.
virtual double curvilinear_integral() const
Definition: Curve.h:299
virtual MGCCisect_list isect(const MGCurve &curve2) const =0
Intersection of Curve and other geometry.
virtual int intersect_dnum() const =0
Provide divide number of curve span for function intersect.
virtual bool is_planar(MGPlane &plane) const
Test if this cure is planar or not.
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
double param_e() const
Return ending parameter value.
Definition: Ellipse.h:598
virtual int perp_point(const MGPosition &p, double &t, const double *g=0) const
Compute a foot point of the perpendicular line from point p to the curve.
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30