MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
RLBRep.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGRLBRep_HH_
6 #define _MGRLBRep_HH_
7 
8 #include "mg/LBRep.h"
9 
10 // MGRLBRep.h
11 //
12 
13 // Forward Declaration
14 class MGPosition;
15 class MGKnotArray;
16 class MGCParam_list;
17 class MGPosition_list;
18 class MGIfstream;
19 class MGOfstream;
20 
26 
32 class MG_DLL_DECLR MGRLBRep: public MGCurve {
33 
34 public:
36 MG_DLL_DECLR friend MGRLBRep operator+ (const MGVector& v, const MGRLBRep& lb);
37 MG_DLL_DECLR friend MGRLBRep operator* (double scale, const MGRLBRep&);
38 
40 
43 
46 MGRLBRep(
47  const MGKnotVector& t,
48  const MGBPointSeq& bcoef,
49  int homogeneous=1
53 );
54 
56 MGRLBRep(
57  const MGKnotVector& t,
58  const MGBPointSeq& bcoef,
59  const std::vector<double>& weights
60 );
61 
63 explicit MGRLBRep(const MGEllipse& ellipse);
64 
68 MGRLBRep(
69  const MGPosition& P0,
70  const MGVector& T0,
71  const MGPosition& P,
72  const MGPosition& P2,
73  const MGVector& T2
74 );
75 
79 MGRLBRep(
80  const MGRLBRep& old_brep,
81  const MGKnotVector& t
82 );
83 
85 
92 MGRLBRep(
93 const MGLBRep& brep,
94 int homogeneous=0
97 );
99 
101 MGRLBRep(
102  const MGRLBRep& old_brep,
103  const MGKnotArray& knots
104 );
105 
107 MGRLBRep(
108  const MGRLBRep& brep1,
109  int continuity,
110  int which,
111  const MGRLBRep& brep2
118 );
119 
125 MGRLBRep(
126  double t1,
127  double t2,
128  const MGRLBRep& old_brep,
129  int multiple=0
130 );
132 
135 MGRLBRep(
136  int dim,
137  const MGRLBRep& lbrep,
138  int start1=0,
139  int start2=0
140 );
141 
145 MGRLBRep(
146  double a, double b,
147  double angle1, double angle2
148 );
149 
152 
155 
157 
161 MGRLBRep& operator=(const MGGel& gel2);
162 MGRLBRep& operator=(const MGRLBRep& gel2);
163 
165 MGRLBRep operator+ (const MGVector& ) const;
166 MGRLBRep operator- (const MGVector& ) const;
167 MGRLBRep operator* (double) const;
168 MGRLBRep operator* (const MGMatrix& ) const;
169 MGRLBRep operator* (const MGTransf& ) const;
170 
172 MGRLBRep& operator+=(const MGVector& v);
173 MGRLBRep& operator-=(const MGVector& v);
174 MGRLBRep& operator*=(double scale);
175 MGRLBRep& operator*=(const MGMatrix& mat);
176 MGRLBRep& operator*=(const MGTransf& tr);
177 
179 bool operator==(const MGRLBRep& gel2)const;
180 bool operator==(const MGGel& gel2)const;
181 bool operator<(const MGRLBRep& gel2)const;
182 bool operator<(const MGGel& gel2)const;
183 bool operator==(const MGLBRep& gel2)const;
184 
186 
193  MGLBRep& lb,
194  int ordr=0,
195  int parameter_normalization=0,
202  bool neglectMulti=false
203 )const;
206 
208 int bdim() const{return m_line.bdim();}
209 
212 MGBox box_limitted(const MGInterval& l) const;
213 
215 MGBox box_unlimit() const;
216 
220  double t1,
221  double t2
222 ){
223  m_line.change_range(t1,t2);
224  update_mark();
225 };
226 
229  int dim,
230  int start1=0,
231  int start2=0
232 );
233 
239 int order
240 ){m_line.change_order(order); return *this;};
241 
244 double& coef(int i, int j){update_mark(); return m_line.coef(i,j);};
245 
248 double coef(int i, int j) const{return m_line.coef(i,j);};
249 
252 MGVector coef(int i) const{return m_line.coef(i);};
253 
255 const double* coef_data(int i=0, int j=0) const
256 {return m_line.coef_data(i,j);};
257 
264 void connect(
265  int continuity,
266  int which,
267  const MGRLBRep& brep2
272 );
273 
283 int continuity(
284  const MGRLBRep& brep2,
285  int& which,
286  double& ratio
292 ) const;
295 
298 MGRLBRep& coordinate_exchange(int i, int j);
299 
302 MGRLBRep* clone() const;
303 
308 MGCurve* copy_as_nurbs() const{return clone();};
309 
314  int sdim,
315  int start1=0,
316  int start2=0
317 )const;
318 
322 MGCurve* copy_limitted(const MGInterval& prange) const;
323 
326 int divide_multi(
327  MGPvector<MGCurve>& crv_list,
328  int multiplicity=-1
329 ) const;
332 
334 void display_control_polygon(mgSysGL& sgl)const;
335 
350 void draw_2D(
351  void (*moveto)(int, int),
352  void (*lineto)(int, int),
353  const double wind[4],
354  int ynum
355 )const;
356 
357 void draw_2D(
358  void (*moveto)(float, float),
359  void (*lineto)(float, float),
360  const double wind[4],
361  int ynum
362 )const;
363 
364 void draw_2D(
365  void (*moveto)(double, double),
366  void (*lineto)(double, double),
367  const double wind[4],
368  int ynum
369 )const;
370 
377 void draw_1D(
378  void (*moveto)(int, int),
379  void (*lineto)(int, int),
380  int coordinate,
381  bool t_is_x,
382  const double wind[4],
383  int ynum
384 )const;
385 
386 void draw_1D(
387  void (*moveto)(float, float),
388  void (*lineto)(float, float),
389  int coordinate,
390  bool t_is_x,
391  const double wind[4],
392  int ynum
393 )const;
394 
395 void draw_1D(
396  void (*moveto)(double, double),
397  void (*lineto)(double, double),
398  int coordinate,
399  bool t_is_x,
400  const double wind[4],
401  int ynum
402 )const;
403 
404 void drawSE(
405  mgVBO& vbo,
406  double span_length,
407  double t0,
408  double t1
409 )const;
411 
414 MGVector eval(
415  double t,
416  int nderiv=0,
417  int left=0
418 ) const;
420 
423 void eval_all(
424  double tau,
425  MGPosition& P,
426  MGVector& V1,
427  MGVector& V2
428 ) const;
429 
434 void eval_all(
435  double tau,
436  int nderiv,
437  double* deriv,
438  int left=0
439 ) const;
441 
444 void extend(
445  double length,
446  bool start=false
447 );
449 
453  int start,
454  double length,
456  double dk=0.
457 );
463 
465 MGRLBRep& extend_with_parameter(
466  double tau,
467  double dk
470 );
472 
476 bool get_control_points(
477  MGBPointSeq& cpoints
478 )const;
479 
481 const MGLBRep& homogeneous() const {return m_line;}
482 MGLBRep& homogeneous(){update_mark();return m_line;}
483 
485 long identify_type() const;
486 
488 int intersect_dnum() const;
489 
493 bool is_coplanar(const MGCurve& curve2, MGPlane& plane)const;
494 
498 bool is_planar(MGPlane& plane)const;
499 
502 MGCCisect_list isect(const MGCurve&) const;
503 MGCCisect_list isect(const MGStraight& curve2)const;
504 MGCCisect_list isect(const MGSurfCurve& curve2)const;
505 MGCCisect_list isect(const MGBSumCurve& curve2)const;
506 
508 
510 MGCSisect_list isect(const MGSurface& surf) const;
511 MGCSisect_list isect(const MGPlane& surf) const;
512 MGCSisect_list isect(const MGSphere& surf)const;
513 MGCSisect_list isect(const MGCylinder& surf)const;
514 MGCSisect_list isect(const MGSBRep& surf)const;
515 MGCSisect_list isect(const MGRSBRep& surf)const;
516 MGCSisect_list isect(const MGBSumSurf& surf)const;
517 
527 MGCParam_list isect_2D(
528  const MGStraight& sl,
529  int coordinate=0
530 ) const;
531 
540 MGCParam_list isect_3D(
541  const MGPlane& pl,
542  int coordinate=0
543 ) const;
544 
547 double& knot(int i){return m_line.knot(i);}
548 
551 double knot(int i) const{return m_line.knot(i);}
552 
554 const double* knot_data() const{return m_line.knot_data();}
555 
558 const MGKnotVector& knot_vector() const{return m_line.knot_vector();}
559 
562 MGKnotVector& knot_vector(){return m_line.knot_vector();}
563 
566 MGRLBRep& limit(const MGInterval& itvl);
567 
570 const MGBPointSeq& line_bcoef() const{return m_line.line_bcoef();};
571 
574 MGBPointSeq& line_bcoef(){update_mark(); return m_line.line_bcoef();};
575 
577 void negate(){m_line.negate();};
578 
580 double negate_param(double t)const{return m_line.negate_param(t);};
581 
584 MGBPointSeq non_homogeneous_bcoef() const;
585 
588 int non_rational() const;
589 
591 int order() const{return m_line.order();}
592 
594 double param_e() const{return m_line.param_e();};
595 
598 double param_normalize(double t) const{return m_line.param_normalize(t);}
599 
601 double param_s() const{return m_line.param_s();};
602 
606 MGRLBRep* part(
607  double t1,
608  double t2,
609  int multiple=0
610 ) const;
612 
620 MGPosition_list perps(const MGCurve& crv2)const;
621 MGPosition_list perps(const MGStraight& crv2)const;
622 
628 int planar(
629  MGPlane& plane
630  , MGStraight& line
632  , MGPosition& point
633 )const;
634 
637 int reduce(
638  int ndec
639 ){
640  update_mark();
641  return m_line.reduce(ndec);
642 };
643 
647  const MGKnotVector& t
648 ){
649  m_line.refine(t);
650  update_mark();
651  return *this;
652 };
653 
655 std::auto_ptr<MGRLBRep> rebuild_with_new_knot_configuration(
656  double error, //Error alowed to rebuild. If error<=0., MGTolerance::line_zero()
657  //will be employed.
658  int parameter_normalization
659  //Indicates how the parameter normalization be done:
660  //=0: no parameter normalization.
661  //=1: normalize to range=(0., 1.);
662  //=2: normalize to make the average length of the 1st derivative
663  // is as equal to 1. as possible.
664 )const;
665 
669 void remove_knot();
670 
672 int sdim() const{return m_line.sdim()-1;};
673 
680  const MGUnit_vector& uvec,
681  double start_dist,
682  double end_dist
683 ) const;
684 
688 
691 MGCurve& unlimit(){return *this;};
692 
695 MGCurve& unlimit_end(){return *this;};
696 
699 MGCurve& unlimit_start(){return *this;};
700 
703 
705 public:
706 
708 int out_to_IGES(
709  MGIgesOfstream& igesfile,
710  int SubordinateEntitySwitch=0
711 )const;
712 
713 std::ostream& out(std::ostream&) const;
714 
715 protected:
716 
720  double f,
721  int coordinate=0
722 )const;
723 
728 std::auto_ptr<MGCurve> oneD(
729  const double g[4]
730 ) const;
731 
734 void ReadMembers(MGIfstream& buf);
735 
739 void WriteMembers(MGOfstream& buf) const;
740 
741 std::string whoami()const{return "RLBRep";};
742 
743 private:
744 
746 
747  MGLBRep m_line;
748 
751 MGBox* compute_box()const;
752 
754 void drawgl(
755  mgVBO& vbo,
756  double dl,
757  double tstart, double tend
758 )const;
759 
764 MGCParam_list isect_nD(
765  const MGVector& N,
766  int dimension,
767  int coordinate
768 ) const;
769 
772 void draw_all2D(
773  int kfunc,
774  int (*moveto)(...), int (*lineto)(...),
776  const double wind[4],
777  int ynum
778 )const;
779 
782 void draw_all1D(
783  int coordinate,
784  bool t_is_x,
786  int kfunc,
787  int (*moveto)(...), int (*lineto)(...),
789  const double wind[4],
790  int ynum
791 )const;
792 
795 MGRLBRep& split_conic(int i);
796 
799 
800 };
801 
813 MG_DLL_DECLR int MGRLBRep_ellipse_weight
814  (const MGPosition& P0, const MGVector& T0,
815  const MGPosition& P,
816  const MGPosition& P2, const MGVector& T2,
817  MGPosition& P1, double& w1
818 );
819  // end of GEO group
821 #endif
MG_DLL_DECLR int MGRLBRep_ellipse_weight(const MGPosition &P0, const MGVector &T0, const MGPosition &P, const MGPosition &P2, const MGVector &T2, MGPosition &P1, double &w1)
virtual MGCurve & operator=(const MGCurve &gel2)
Assignment.
Definition: Curve.h:84
MGCurve & unlimit_end()
Definition: RLBRep.h:695
MGVector coef(int i) const
Definition: RLBRep.h:252
std::string whoami() const
Definition: RLBRep.h:741
virtual long identify_type() const =0
Return This object's typeID.
virtual void remove_knot()
Remove redundant knot, and reduce the b-rep dimension.
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
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
double param_normalize(double t) const
Definition: RLBRep.h:598
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
int bdim() const
Returns NURBS Dimension.
Definition: RLBRep.h:208
virtual MGCParam_list perps(const MGPosition &P) const
Compute all foot points of the perpendicular line from point to the curve.
MGCurve & unlimit()
Definition: RLBRep.h:691
virtual void drawSE(mgVBO &vbo, double span_length, double t0, double t1) const
Draw this curve into vbo, approximating with polyline.
double param_s() const
Return starting parameter value.
Definition: RLBRep.h:601
virtual void update_mark()
Mark this as updated.
Definition: Curve.h:1173
virtual MGCurve & operator+=(const MGVector &v)=0
Object transformation.
double knot(int i) const
Definition: RLBRep.h:551
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.
MGRLBRep & change_order(int order)
Definition: RLBRep.h:238
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
int order() const
Returns the order.
Definition: RLBRep.h:591
void negate()
Change direction of the line.
Definition: RLBRep.h:577
MGRLBRep & refine(const MGKnotVector &t)
Definition: RLBRep.h:646
void change_range(double t1, double t2)
Definition: RLBRep.h:219
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
B-Spline(MGRLBRep)
Definition: MGCL.h:148
Vector of a general n space dimension.
Definition: Vector.h:26
MGCurve & unlimit_start()
Definition: RLBRep.h:699
const MGLBRep & homogeneous() const
Return homogeneous Line B-Representation of the rational B-Spline.
Definition: RLBRep.h:481
MGBPointSeq & line_bcoef()
Definition: RLBRep.h:574
Defines a Box of any space dimendion.
Definition: Box.h:34
Define MGBSumCurve Class(Boolean sum curve of three curves).
Definition: BSumCurve.h:28
MGLBRep & homogeneous()
Definition: RLBRep.h:482
virtual MGCurve & limit(const MGInterval &rng)=0
Update this by limiting the parameter range of the curve.
virtual MGCurve * copy_limitted(const MGInterval &prange) const
Construct new curve object limitting the parameter range to prange.
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
virtual void ReadMembers(MGIfstream &buf)
メンバデータを読み出す関数.
MGCurve * copy_as_nurbs() const
Definition: RLBRep.h:308
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.
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
MGRLBRep()
Default(dummy) constructor.
Definition: RLBRep.h:42
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
virtual void approximate_as_LBRep(MGLBRep &lb, int ordr=0, int parameter_normalization=0, bool neglectMulti=false) const
Approximate this curve as a MGLBRep.
Represent a positional data.
Definition: Position.h:28
const double * coef_data(int i=0, int j=0) const
Returns a pointer to the line b-coef data.
Definition: RLBRep.h:255
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
MGCURVE_TYPE type() const
Definition: RLBRep.h:687
MGCSisect_list defines linked list of MGCSisect.
Definition: CSisect_list.h:22
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
const MGBPointSeq & line_bcoef() const
Definition: RLBRep.h:570
Defines Boolean sum surface.
Definition: BSumSurf.h:26
virtual MGSurface * sweep(const MGUnit_vector &uvec, double start_dist, double end_dist) const =0
Return sweep surface from crv.
virtual MGCurve & operator-=(const MGVector &v)=0
double negate_param(double t) const
Obtain parameter value if this curve is negated by "negate()".
Definition: RLBRep.h:580
Defines BPoint seq of a space dimension and of a capacity.
Definition: BPointSeq.h:38
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 void extend(double length, bool start=false)=0
Extrapolate this curve by an (approximate) chord length.
virtual bool is_coplanar(const MGCurve &curve2, MGPlane &plane) const
Test if this cure is co-planar with the 2nd curve curve2.
MGOfstream is a class to serialize all of the subclasses of MGGel.
Definition: Ofstream.h:31
Defines Rational Line B-Representation.
Definition: RLBRep.h:32
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
double coef(int i, int j) const
Definition: RLBRep.h:248
int reduce(int ndec)
Definition: RLBRep.h:637
virtual MGCurve & operator*=(double scale)=0
const MGKnotVector & knot_vector() const
Definition: RLBRep.h:558
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
virtual bool get_control_points(MGBPointSeq &cpoints) const
Extracts control points.
Definition: Curve.h:455
virtual bool operator==(const MGCompositeCurve &crv) const
Comparison.
double param_e() const
Return ending parameter value.
Definition: RLBRep.h:594
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
double & coef(int i, int j)
Definition: RLBRep.h:244
virtual std::auto_ptr< MGCurve > oneD(const double g[4]) const =0
Obtain transformed 1D curve expression of this curve.
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
virtual int divide_multi(MGPvector< MGCurve > &crv_list, int multiplicity=-1) const
Divide this curve at the designated knot multiplicity point.
virtual bool operator<(const MGGel &gel2) const =0
virtual MGBox box_limitted(const MGInterval &) const =0
Return minimum box that includes the curve of parameter interval.
virtual MGCParam_list intersect_1D(double f, int coordinate=0) const
Compute intersection point of 1D sub curve of original curve.
Defines Array of Knots.
Definition: KnotArray.h:26
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.
mgSysGL is a class to provide a facility to draw temporal pictures.
Definition: sysGL.h:26
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
virtual void display_control_polygon(mgSysGL &sgl) const
Definition: Gel.h:194
double & knot(int i)
Definition: RLBRep.h:547
int sdim() const
Returns the space dimension.
Definition: RLBRep.h:672
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGKnotVector & knot_vector()
Definition: RLBRep.h:562
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43
const double * knot_data() const
Returns a pointer to the knot vector data.
Definition: RLBRep.h:554
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30