MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Straight.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGStraight_HH_
6 #define _MGStraight_HH_
7 
8 #include "mg/EReal.h"
9 #include "mg/Position.h"
10 #include "mg/Unit_vector.h"
11 #include "mg/Curve.h"
12 
13 // MGStraight.h
14 // Definition of MGStraight class
15 
16 class MGBox;
17 class MGInterval;
18 class MGVector;
19 class MGTransf;
20 class MGCCisect;
21 class MGCSisect;
22 class MGRLBRep;
23 class MGEllipse;
24 class MGLBRep;
25 class MGSurfCurve;
26 class MGBSumCurve;
27 class MGCompositeCurve;
28 class MGTrimmedCurve;
29 class MGKnotVector;
30 class MGPlane;
31 class MGSurface;
32 class MGCCisect_list;
33 class MGPosition_list;
34 class MGIfstream;
35 class MGOfstream;
41 
49 class MG_DLL_DECLR MGStraight: public MGCurve{
50 public:
51 
52 MG_DLL_DECLR friend MGStraight operator+ (const MGVector& v, const MGStraight& sl);
53 MG_DLL_DECLR friend MGStraight operator* (double scale, const MGStraight&);
54 
56 
58 MGStraight();
59 
61 MGStraight(const MGStraight& sl);
62 
65 explicit MGStraight (
66  const MGEReal& endparam,
67  const MGEReal& sparam,
68  const MGVector& direction,
69  const MGPosition& Origin
70 );
71 explicit MGStraight(
72  double endparam,
73  double sparam,
74  const MGVector& direction,
75  const MGPosition& Origin
76 );
77 
83  MGSTRAIGHT_TYPE type,
84  const MGVector& vec,
92  const MGPosition & = mgORIGIN
93 );
94 
100  const MGPosition& end,
101  const MGPosition& start
102 );
103 
108 MGStraight(
109  const MGPosition& endP,
110  const MGPosition& startP,
111  const double endT,
112  const double startT = 0.0
113 );
114 
117 MGStraight(
118  const MGUnit_vector& v,
119  double d,
120  const MGPosition& p= mgORIGIN
121 );
122 
127 explicit MGStraight(
128  const MGPosition& P1,
129  const MGPosition& P2,
130  const MGVector& N
131 );
132 
136 explicit MGStraight(
137  const MGVector& v0, //a vector whose end is uv.
138  const MGVector& v1, //a vector whose start is uv.
139  const MGPosition& uv//origin of sl.
140 );
141 
142 
145 MGStraight(
146  int dim,
147  const MGStraight& linne2,
148  int start1=0,
149  int start2=0
150 );
152 ~MGStraight();
153 
155 
159 MGStraight& operator=(const MGGel& gel2);
160 MGStraight& operator=(const MGStraight& gel2);
161 
164 MGStraight operator+ (const MGVector& vec)const;
165 MGStraight operator- (const MGVector& vec)const;
166 MGStraight operator* (double scale)const;
167 MGStraight operator* (const MGMatrix&)const;
168 MGStraight operator* (const MGTransf&)const;
169 
171 MGStraight& operator+=(const MGVector& v);
172 MGStraight& operator-=(const MGVector& v);
173 MGStraight& operator*=(double scale);
174 MGStraight& operator*=(const MGMatrix& mat);
175 MGStraight& operator*=(const MGTransf& tr);
176 
178 bool operator==(const MGStraight& sl2)const;
179 bool operator==(const MGGel& gel2)const;
180 bool operator<(const MGStraight& gel2)const;
181 bool operator<(const MGGel& gel2)const;
182 
184 
191  MGLBRep& lb,
192  int ordr=0,
193  int parameter_normalization=0,
201  bool neglectMulti=false
202 )const;
205 
207 int bdim()const{return 2;};
208 
211 MGBox box_limitted(const MGInterval& l)const;
212 
215  int sdim,
216  int start1=0,
217  int start2=0
218 );
219 
222 void change_range(
223  double t1,
224  double t2
225 );
226 
229 MGStraight& coordinate_exchange(int i, int j);
230 
233 MGStraight* clone()const;
234 
236 double closest(const MGPosition& point) const;
237 
241 MGPosition closest(const MGCurve& curve2) const;
242 
246 void convert_to_Bezier(MGLBRep& bezier)const;
247 
252 MGCurve* copy_as_nurbs()const;
253 
258  int sdim,
259  int start1=0,
260  int start2=0
261 )const;
262 
265 double curvature( double ) const{return 0.;};
266 
270 double curvilinear_integral(double t1, double t2)const;
271 
272 #ifdef __sgi
273  double curvilinear_integral()const
275 #endif
276 
280 MGUnit_vector direction(double)const{return m_direction;};
281 
284 const MGVector& direction()const{return m_direction;};
285 
287 double direction_len()const{return m_direction.len();};
288 
291 double distance( const MGPosition& = mgORIGIN )const;
292 
295 double distance( const MGStraight& )const;
296 
297 void drawWire(
298  mgVBO& vbo,
299  double span_length,
300  int line_density=1
301 )const;
302 
303 void drawSE(
304  mgVBO& vbo,
305  double span_length,
306  double t0,
307  double t1
308 )const;
310 
312 const MGEReal& end()const{ return m_endparam;};
313 
316 double end_param()const{return param_e();};
317 
320 MGPosition end_point()const;
321 
324 MGVector eval(
325  double t,
326  int nderiv=0,
327  int left=0
328 )const;
330 
334  void eval_all (
335  double t,
336  MGPosition&,
337  MGVector&,
338  MGVector&
339 ) const;
340 
343 MGVector eval_deriv(double t)const;
344 
348 MGPosition eval_position(double t)const;
349 
353 MGPosition eval_position_unlimitted(double t)const;
354 
357 void extend(
358  double length,
359  bool start=false
360 );
362 
364 bool finite()const{return m_sparam.finite() && m_endparam.finite();};
365 
367 long identify_type()const;
368 
370 bool infinite_above()const{return m_endparam.plus_infinite();};
371 
373 bool infinite_below()const{return m_sparam.minus_infinite();};
374 
376 bool in_range(double t)const;
377 
379 int intersect_dnum() const{return 2;}
380 
384 bool is_coplanar(const MGCurve& curve2, MGPlane& plane)const;
385 
387 bool is_startpoint_parameter(double t)const;
388 
390 bool is_endpoint_parameter(double t)const;
391 
395 bool is_linear(MGStraight& straight)const;
396 
400 bool is_planar(MGPlane& plane)const;
401 
404 MGCCisect_list isect(const MGCurve&)const;
405 MGCCisect_list isect(const MGStraight& curve2)const;
406 MGCCisect_list isect(const MGRLBRep& curve2)const;
407 MGCCisect_list isect(const MGEllipse& curve2)const;
408 MGCCisect_list isect(const MGSurfCurve& curve2)const;
409 MGCCisect_list isect(const MGBSumCurve& curve2)const;
410 
412 MGCSisect_list isect(const MGSurface& surf) const;
413 MGCSisect_list isect(const MGPlane& surf) const;
414 MGCSisect_list isect(const MGSphere& surf)const;
415 MGCSisect_list isect(const MGCylinder& surf)const;
416 MGCSisect_list isect(const MGSBRep& surf)const;
417 MGCSisect_list isect(const MGRSBRep& surf)const;
418 MGCSisect_list isect(const MGBSumSurf& surf)const;
419 MGCSisect_list isect(const MGFace& f)const;
420 
423 double knot(int i) const;
424 
426 const MGKnotVector& knot_vector() const;
428 
433 double length(double t1, double t2) const;
434 
440 double length() const;
441 
445 double length_param(double t, double len) const;
446 
449 MGStraight& limit(const MGInterval& );
450 
453 MGStraight& limit(const MGBox& box);
454 
456 MGPosition nearest_to_origin() const;
457 
461 void negate();
462 
464 double negate_param(double t)const;
465 
474  double ofs_value,
475  const MGVector& norm_vector = mgNULL_VEC
476 )const;
477 
484 bool on(
485  const MGPosition&,
486  double&
487 )const;
489 
494 bool on(
495  const MGPlane&
496 )const;
497 
499 int order() const{return 2;};
500 
505 double param (
506  const MGPosition &
507 ) const;
508 
510 double param_e() const{return m_endparam.value();};
511 
513 double param_error() const;
514 
517 double param_normalize(double t) const;
518 
520 MGInterval param_range() const;
521 
523 double param_s() const{return m_sparam.value();};
524 
529  double t1,
530  double t2,
531  int multiple=0
532 ) const;
534 
539 double perp_param(
540  const MGPosition &
541 ) const;
542 
546 int perp_point(
547  const MGPosition &,
548  double& d1,
549  const double* d2=NULL
550 ) const;
551 
557  const MGPosition& point
558 )const;
559 
567 MGPosition_list perps(const MGCurve& crv2)const;
568 MGPosition_list perps(const MGStraight& crv2)const;
569 MGPosition_list perps(const MGRLBRep& crv2)const;
570 MGPosition_list perps(const MGEllipse& crv2)const;
571 MGPosition_list perps(const MGSurfCurve& crv2)const;
572 MGPosition_list perps(const MGBSumCurve& crv2)const;
573 
597 int project(
598  const MGFSurface& surf, //given surface.
599  MGPvector<MGCurve>& vec_crv_uv, //uv projection curve will be appended.
600  MGPvector<MGCurve>& vec_crv, //3d projection curve will be appended.
601  const MGVector& vec //projection vector.
602  //if vec = NULL then calculate perpendicular project.
603 )const;
604 
607 double range(double) const;
608 
609 //Return two straight line's relationship.
610 //Whe two are parallel, MGPSREL_PARALLEL or MGPSREL_COIN will be returned.
611 //MGPSREL_PARALLEL takes place when no overlapping part exists, and
612 //MGPSREL_COIN when some parts overlaps.
613 //MGPSREL_ISECT when they have an intersection.
614 //MGPSREL_VIRTUAL_ISECT when there is an intersection at extended part of the lines.
615 //MGPSREL_TORSION when the two do not lie on a same plane.
616 MGPSRELATION relation(
617  const MGStraight& sl2,
618  MGCCisect& ip
625 ) const;
626 
629 MGPSRELATION relation(
630  const MGPlane &,
631  MGCSisect &
632 ) const;
633 
634 const MGPosition& root_point() const{return m_root_point;};
635 
637 int sdim() const;
638 
644 MGStraight& set_straight(
645  MGSTRAIGHT_TYPE type,
646  const MGVector& vec,
654  const MGPosition & = mgORIGIN
655 );
656 
658 const MGVector& sl_direction()const{return m_direction;}
659 
661 const MGEReal& start() const{ return m_sparam;};
662 
665 MGPosition start_point() const;
666 
676 MGSTRAIGHT_TYPE straight_type() const;
677 
684  const MGUnit_vector& uvec,
685  double start_dist,
686  double end_dist
687 )const;
688 
692 
696 MGCurve& unlimit();
697 
701 
705 
706 //Update the root point of this straight.
707 void update_root(const MGPosition& rootP);
708 
711 std::ostream& out(std::ostream &) const;
712 
713 int out_to_IGES(
714  MGIgesOfstream& igesfile,
715  int SubordinateEntitySwitch=0
716 )const;
717 
718 std::string whoami()const{return "Straight";};
719 
720 protected:
721 
725  double f,
726  int coordinate=0
727 )const;
728 
733 std::auto_ptr<MGCurve> oneD(
734  const double g[4]
735 ) const;
736 
740 void ReadMembers(MGIfstream& buf);
741 
745 void WriteMembers(MGOfstream& buf) const;
746 
747 private:
748 
752 
753  MGPosition m_root_point;
754  MGVector m_direction;
755  MGEReal m_sparam;
756  MGEReal m_endparam;
757  mutable MGKnotVector* m_knotV;
758 
761 MGBox* compute_box() const;
762 
766 MGPosition closestSL(const MGStraight& straight2)const;
767 
774 bool isect2D(const MGStraight& l2, double& t,double& s) const;
775 
777 MGCCisect_list isect_withC1LB(const MGLBRep& curve2)const;
778 
781 
789 MGPosition_list relation_parallel(const MGStraight& line2) const;
790 
794 void save_length_zero();
795 
796 //Compute two straight lines relationship of parallel or coincidence.
797 //Parallelness of the two is assumed.
798 //Obtain the relationship when two lines coinside.
799 //ip of a intersection or nearest point will be returned.
800 //When this and s do not coincide, MGPSREL_PARALLEL will be returned as
801 //the function's return value.
802 MGPSRELATION relation_coincide(const MGStraight& s, MGCCisect& ip)const;
803 
804 //relation_coincide when this is MGSTRAIGHT_SEGMENTt.
805 MGPSRELATION relation_coincide1(
806  const MGStraight& sl2,
807  MGCCisect& ip
808 )const;
809 
810 friend class MGCylinder;
811 
812 };
813  // end of GEO group
815 #endif
virtual MGCurve & operator=(const MGCurve &gel2)
Assignment.
Definition: Curve.h:84
virtual bool is_endpoint_parameter(double t) const
Test if the input parameter t is the start point parameter or not.
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をはずす).
MGTrimmedCurve is a part of an original curve of a limitted parameter range.
Definition: TrimmedCurve.h:50
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
virtual void convert_to_Bezier(MGLBRep &bezier) const
Convert this curve to Bezier curve.
const MGVector & direction() const
Definition: Straight.h:284
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
Is a container of one intersection of two curves.
Definition: CCisect.h:24
MGSTRAIGHT_TYPE
Straight line type(直線の種類).
Definition: MGCL.h:165
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.
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.
virtual MGPvector< MGCurve > offset(double ofs_value, const MGVector &norm_vector=mgNULL_VEC) const
Offset of costant deviation from this curve.
MGCompositeCurve is a composite of other leaf curves.
Definition: CompositeCurve.h:39
MGStraight(Straight line). 直線
Definition: MGCL.h:145
virtual MGPosition eval_position(double) const
Compute positional data.
virtual MGCurve & operator+=(const MGVector &v)=0
Object transformation.
MGPSRELATION
Definition: MGCL.h:131
virtual MGCurve * clone() const =0
Construct new geometry object by copying to newed area.
const MGVector & sl_direction() const
Return straight line's direction.
Definition: Straight.h:658
virtual MGCurve & coordinate_exchange(int i, int j)=0
Exchange ordering of the coordinates.
bool infinite_above() const
Test if infinite_above(infinite to larger parameter direction).
Definition: Straight.h:370
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.
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
virtual double param(const MGPosition &) const
Compute parameter value of given point.
virtual MGInterval param_range() const
Return parameter range of the curve(パラメータ範囲を返す).
virtual int project(const MGFSurface &surf, MGPvector< MGCurve > &vec_crv_uv, MGPvector< MGCurve > &vec_crv, const MGVector &vec) const
Obtain the projected curve of a curve onto the surface.
MGUnit_vector direction(double) const
Definition: Straight.h:280
Vector of a general n space dimension.
Definition: Vector.h:26
double param_s() const
Return starting parameter value.
Definition: Straight.h:523
virtual MGCCisect_list isect_withC1LB(const MGLBRep &curve2) const
Compute intersections with MGLBRep curve2 that does not have C0 continuity in it. ...
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.
MGFace is a trimmed surface.
Definition: Face.h:51
int intersect_dnum() const
Provide divide number of curve span for function intersect.
Definition: Straight.h:379
virtual MGPosition start_point() const
Return start point(始点を返却する).
double param_e() const
Return ending parameter value.
Definition: Straight.h:510
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 param_error() const
Obtain parameter space error.
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
One Intersection of curve and surface.
Definition: CSisect.h:26
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)
virtual void approximate_as_LBRep(MGLBRep &lb, int ordr=0, int parameter_normalization=0, bool neglectMulti=false) const
Approximate this curve as a MGLBRep.
std::string whoami() const
Definition: Straight.h:718
Represent a positional data.
Definition: Position.h:28
virtual MGCCisect_list isect_with_noCompoSC(const MGSurfCurve &curve2) const
isect with SurfCurve whose m_curve is not a MGTrimmedCurve of MGCompositeCurve.
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
int order() const
Returns the order.
Definition: Straight.h:499
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
virtual double closest(const MGPosition &point) const
Compute the closest point parameter value of this curve from a point.
virtual MGSurface * sweep(const MGUnit_vector &uvec, double start_dist, double end_dist) const =0
Return sweep surface from crv.
virtual MGPosition end_point() const
Return end point(終点を返却する)
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
MGParam_Vector provides a list to store parameters of a curve.
Definition: CParam_list.h:18
const MGPosition & root_point() const
Definition: Straight.h:634
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.
MGEReal is extended real number to define infinity.
Definition: EReal.h:22
virtual void extend(double length, bool start=false)=0
Extrapolate this curve by an (approximate) chord length.
bool infinite_below() const
Test if infinite_below(infinite to smaller parameter direction).
Definition: Straight.h:373
MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface.
Definition: FSurface.h:33
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
bool finite() const
Test if thie straight is a finite line.
Definition: Straight.h:364
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
const MGEReal & start() const
Return start point parameter value.
Definition: Straight.h:661
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
int bdim() const
Returns B-Rep Dimension.
Definition: Straight.h:207
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
virtual bool is_startpoint_parameter(double t) const
Test if the input parameter t is the start point parameter or not.
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.
double end_param() const
Definition: Straight.h:316
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
virtual void drawWire(mgVBO &vbo, double span_length, int line_density=1) const
Draw this curve into vbo, approximating with polyline.
Definition: Curve.h:347
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.
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 bool is_planar(MGPlane &plane) const
Test if this cure is planar or not.
double curvature(double) const
Definition: Straight.h:265
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual bool in_range(double t) const
Test if input parameter value is inside parameter range of the line.
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.
MGCURVE_TYPE type() const
Definition: Straight.h:691
const MGEReal & end() const
Return end parameter value.
Definition: Straight.h:312
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43
double direction_len() const
Return direction vector length of the straight line.
Definition: Straight.h:287
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30