MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Plane.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGPlane_HH_
6 #define _MGPlane_HH_
7 #include "mg/drawParam.h"
8 #include "mg/Position.h"
9 #include "mg/Unit_vector.h"
10 #include "mg/Surface.h"
11 #include "mgGL/VBO.h"
12 
13 // MGPlane.h
14 // Header for class MGPlane
15 class MGBPointSeq;
16 class MGCCisect;
17 class MGCSisect;
18 class MGTransf;
19 class MGStraight;
20 class MGSBRep;
21 class MGIfstream;
22 class MGOfstream;
23 class MGFace;
30 
38 class MG_DLL_DECLR MGPlane :public MGSurface{
39 
40 public:
41 
42 MG_DLL_DECLR friend MGPlane operator+ (const MGVector& v, const MGPlane& pl);
43 MG_DLL_DECLR friend MGPlane operator* (double scale, const MGPlane& pl);
44 
46 
48 MGPlane(void);
49 
51 MGPlane(const MGPlane& pl);
52 
54 MGPlane(
55  int dim,
56  const MGPlane& plane,
57  int start1=0,
58  int start2=0
59 );
60 
64 MGPlane(
65  const double g[4],
66  const double* root_point=0
67 );
68 
71 MGPlane(
72  const MGUnit_vector& normal,
73  double d
74 );
76 
79 MGPlane(
80  const MGUnit_vector& normal,
81  const MGPosition& p
82 );
83 
86 MGPlane(
87  const MGStraight& st,
88  const MGPosition& point
89 );
90 
95 MGPlane(
96  const MGVector& uderiv,
97  const MGVector& vderiv,
98  const MGPosition &origin
99 );
100 
105 MGPlane(
106  const MGPlane& plane1,
107  const MGPlane& plane2,
108  double t
109 );
112 
114 MGPlane(
115  const MGPosition& P1,
116  const MGPosition& P2,
117  const MGPosition& P3
118 );
119 
121 ~MGPlane();
122 
124 
128 MGPlane& operator=(const MGPlane& gel2);
129 MGPlane& operator=(const MGGel& gel2);
130 
132 MGPlane operator+ (const MGVector& v) const;
133 MGPlane operator- (const MGVector& v) const;
134 MGPlane operator* (double scale) const;
135 MGPlane operator* (const MGMatrix& mat) const;
136 MGPlane operator* (const MGTransf& tr) const;
137 
139 MGPlane& operator+=(const MGVector& v);
140 MGPlane& operator-=(const MGVector& v);
141 MGPlane& operator*=(double scale);
142 MGPlane& operator*=(const MGMatrix& mat);
143 MGPlane& operator*=(const MGTransf& tr);
144 
146 bool operator==(const MGPlane& gel2)const;
147 bool operator==(const MGGel& gel2)const;
148 bool operator<(const MGPlane& gel2)const;
149 bool operator<(const MGGel& gel2)const;
150 bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));};
151 bool operator!=(const MGPlane& gel2)const{return !(gel2==(*this));};
152 
154 int out_to_IGES(
155  MGIgesOfstream& igesfile,
156  int SubordinateEntitySwitch=0
157 )const;
158 
160 
163 std::ostream& out(std::ostream &) const;
164 
166 
168 void abcd(double g[4]) const;
170 
174  const MGBox& uvrange
175 ) const;
176 
178 virtual MGPosition center() const{return m_root_point;};
179 
182  int sdim,
183  int start1=0,
184  int start2=0
185 );
186 
191  int is_u,
192  double t1,
193  double t2
194 ){return *this;};
195 
197 void change_root_point(
198  const MGPosition& new_point
199 );
200 
201 
204 MGPosition closest(const MGPosition& point) const;
205 
208 MGPlane* clone() const;
209 
214  int sdim,
215  int start1=0,
216  int start2=0
217 )const;
218 
219 void display_arrows(mgSysGL& sgl)const;
220 
223 double distance() const{return m_d;};
224 
227 double distance(const MGPosition& point) const;
228 
231 virtual void drawWire(
232  mgVBO& vbo,
233  double span_length,
234  int line_density=1
235 )const{drawWirePlane(vbo,span_length,line_density,mgVBO::WIRE);};
236 
239 void drawWirePlane(
240  mgVBO& vbo,
241  double span_length,
242  int line_density=1,
244 )const;
245 
247 virtual void shade(
248  mgVBO& vbo,
249  const MGDrawParam& para,
251 )const{drawWirePlane(vbo,para.span_length_wire(),1,target);};
252 
254 MGVector eval(
255  double u,
256  double v
257  , int ndu=0
258  , int ndv=0
259 )const;
260 
263  const MGPosition& uv
264  , int ndu=0
265  , int ndv=0
266 )const{return eval(uv.ref(0),uv.ref(1),ndu,ndv);}
267 
270 void eval_all(
271  double u,
272  double v,
273  MGPosition& f,
274  MGVector& fu,
275  MGVector& fv,
276  MGVector& fuv,
277  MGVector& fuu,
278  MGVector& fvv
279 )const;
280 
283 
285 long identify_type() const;
286 
287 bool in_range(double u, double v) const{ return 1;};
288 bool in_range(const MGPosition& uv) const{ return 1;};
289 
293 int intersect_dnum_u() const{ return 2;};
294 int intersect_dnum_v() const{ return 2;};
295 
298 MGCSisect_list isect(const MGCurve& curve)const;
299 MGCSisect_list isect(const MGStraight& curve)const;
300 MGCSisect_list isect(const MGRLBRep& curve)const;
301 MGCSisect_list isect(const MGEllipse& curve)const;
302 MGCSisect_list isect(const MGLBRep& curve)const;
303 MGCSisect_list isect(const MGSurfCurve& curve)const;
304 MGCSisect_list isect(const MGBSumCurve& curve)const;
305 
308 MGSSisect_list isect(const MGSurface& srf2)const;
309 MGSSisect_list isect(const MGPlane& srf2)const;
310 MGSSisect_list isect(const MGSphere& srf2)const;
311 MGSSisect_list isect(const MGCylinder& srf2)const;
312 MGSSisect_list isect(const MGSBRep& srf2)const;
313 MGSSisect_list isect(const MGRSBRep& srf2)const;
314 MGSSisect_list isect(const MGBSumSurf& srf2)const;
315 
326 int isect_startHPL(
327  const MGPosition& uvuv_startIn,
328  MGPosition_list& uvuv_list,
329  const MGSurface& sf2,
333  MGSSisect& ssi,
340 ) const;
341 
343 double knot_u(int)const ;
344 double knot_v(int)const ;
345 
347 const MGKnotVector& knot_vector_u() const;
349 
351 const MGKnotVector& knot_vector_v() const;
353 
355 virtual void make_display_list(
357 )const;
358 
360 void negate(
361  int is_u
362 );
363 
367 MGPosition negate_param(const MGPosition& uv, int is_u=1)const;
368 
370 MGVector normal(double u, double v) const{return m_normal;}
371 MGVector normal(const MGPosition& uv) const{return m_normal;}
372 const MGUnit_vector& normal() const{return m_normal;}
373 
376 void normalize();
377 
383 std::auto_ptr<MGSurface> offset_c1(
384  double ofs_value,
385  int& error
386 ) const;
388 
391 bool on(const MGPosition& point) const;
392 bool on(
393  const MGPosition& point,
394  MGPosition& puv
395 ) const;
397 
400 bool on(const MGStraight&) const;
401 
405  double& u,
406  double& v,
407  int& perim_num
408 )const{return false;};
410 
414  int perim_num,
415  double u,
416  double v
417 )const{return false;};
418 
423  const MGPosition&
424 ) const;
425 
427 double param_error() const;
428 double param_error_u() const;
429 double param_error_v() const;
430 
432 virtual double param_e_u() const{return mgInfiniteVal;}
433 virtual double param_e_v() const{return mgInfiniteVal;}
434 
437 virtual MGBox param_range() const;
438 
440 virtual double param_s_u() const{return -mgInfiniteVal;}
441 virtual double param_s_v() const{return -mgInfiniteVal;}
442 
445 virtual MGCurve* parameter_curve(
446  int is_u
447  , double x
448 )const;
450 
454 MGSurface* part(
455  const MGBox& uvbox,
456  int multiple=0
457 )const;
459 
462 virtual MGCurve* perimeter_curve(int i) const{return 0;};
463 
465 virtual int perimeter_num() const{return 0;};
466 
471 virtual MGPosition perimeter_uv(int i,double t) const;
472 
477 int perp_point(
478  const MGPosition& P,
479  MGPosition& uv,
480  const MGPosition* uvguess=NULL
481 ) const;
482 
485  const MGPosition& P
486 ) const;
487 
490 int planar(
491  MGPlane& plane,
492  double& deviation
494 ) const;
495 
500 int planar(
501  const MGBox& uvbox,
502  double tol,
503  int* divideU=0
504 )const;
506 
535 int project(
536  const MGStraight& sl,
537  MGPvector<MGCurve>& vec_crv_uv,
538  MGPvector<MGCurve>& vec_crv,
539  const MGVector& vec= mgNULL_VEC
540 )const;
542 
564 int project(
565  const MGCurve& crv,
566  MGPvector<MGCurve>& vec_crv,
567  const MGVector& vec = mgNULL_VEC
568 ) const;
570 
574 MGPosition range(const MGPosition& uv) const{return uv;}
575 
578 MGPSRELATION relation(
579  const MGPlane&,
580  MGStraight&
581 ) const;
583 
586 MGPSRELATION relation(
587  const MGStraight&,
588  MGCSisect&
589 ) const;
590 
593 const MGPosition& root_point() const{return m_root_point;}
594 
596 int sdim() const;
597 
602 virtual MGPvector<MGCurve> skeleton(int density=1)const;
603 
606 
608 void split(
609  double param,
610  bool is_u,
612  MGPvector<MGFSurface>& surfaces
613 )const;
614 
617 virtual MGSURFACE_TYPE type() const{return MGSURFACE_PLANE;}
618 
621 const MGVector& u_deriv() const{return m_uderiv;}
622 
625 const MGVector& v_deriv() const{return m_vderiv;}
626 
629 MGPosition uv(const MGPosition& p) const;
630 
634 MGVector uv(const MGVector& v) const;
635 
636 std::string whoami()const{return "Plane";};
637 
638 protected:
639 
648 bool flat(
649  const MGBox& uvbox,
650  double tol,
651  int& direction,
653  MGPosition& P,
655  MGUnit_vector& N
656 )const;
657 
667 bool flat_tess(
668  double u0,
669  double u1,
670  double v0,
671  double v1,
672  double tol,
673  bool& direction
675 )const;
677 
680  const MGStraight& sl,
681  const MGBox& uvbox=mgNULL_BOX
682 )const;
684 
686 void ReadMembers(MGIfstream& buf);
687 
689 void WriteMembers(MGOfstream& buf) const;
690 
691 protected:
693  MGVector m_uderiv;
695  MGVector m_vderiv;
697 
699 private:
700 
701  MGUnit_vector m_normal;
702  double m_d;
706  mutable MGKnotVector* m_uknotV;
707  mutable MGKnotVector* m_vknotV;
710 
713 virtual MGBox* compute_box() const;
714 
716 void MGPlane::get_uv_display_vector(
717  MGVector& u,
718  MGVector& v
719 )const;
720 
723 int isect_area_length() const{return 10;};
724 
728 int isect_guess(
729  const MGCurve& crv,
730  const MGPosition& uvi,
731  double ti,
733  MGPosition& uv,
734  double& t
735 )const;
736 
742  const MGStraight& sl,
743  double ti,
744  const MGPosition& uvi,
745  double& t,
747  MGPosition& uvout
748 ) const;
749 
753  const MGPosition& uv,
754  int kdt,
755  double du, double dv,
757  double& u,
758  double& v,
759  int incr=1
760 ) const;
761 
765 void isect_inner_dt(
766  int n,
767  const MGPosition& uvnow,
768  double& du, double& dv,
769  int& kdt,
771  double acuRatio=1.
774 ) const;
775 
778 int isect_order() const{return 4;}
779 
781 MGCSisect_list isect_withC1LB(const MGLBRep& lb)const;
782 
785 
788 int offset_div_num() const;
789 
794 MGSBRep* surf1D(const MGPlane& pl)const{
795  assert(false); return 0;
796 };
797 
798 };
799  // end of GEO group
801 #endif
virtual MGSBRep * surf1D(const MGPlane &pl) const =0
virtual MGVector eval(double u, double v, int ndu=0, int ndv=0) const =0
Evaluate surface data.
MG_DLL_DECLR const MGBox mgNULL_BOX
virtual MGSurface & operator=(const MGSurface &gel2)
Definition: Surface.h:74
virtual const MGKnotVector & knot_vector_v() const =0
Returns the v knot vector.
virtual void ReadMembers(MGIfstream &buf)
virtual const MGKnotVector & knot_vector_u() const =0
Returns the u knot vector.
virtual int perp_point(const MGPosition &P, MGPosition &uv, const MGPosition *uvguess=0) const
Return the foot of the perpendicular straight line from P.
virtual void split(double param, bool is_u, MGPvector< MGFSurface > &surfaces) const
split this fsurface at the parameter param.
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
bool in_range(double u, double v) const
Test if the parameter(u,v) is in this surface's parameter range.
Definition: Plane.h:287
virtual std::ostream & out(std::ostream &ostrm) const
Output virtual function.
MGPlane is infinite plane in 3D space.
Definition: Plane.h:38
MGTransf represents a transformation of a space dimension.
Definition: Transf.h:35
virtual bool operator<(const MGGel &gel2) const =0
MGCylinder is a Cylinder in 3D space.
Definition: Cylinder.h:37
Is a container of one intersection of two curves.
Definition: CCisect.h:24
virtual MGCurve * isect_incr_pline(const MGPosition &uv, int kdt, double du, double dv, double &u, double &v, int incr=0) const =0
Definition: MGCL.h:272
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
virtual MGPvector< MGCurve > skeleton_at_knots() const
Obtain all the parameter curves at knots of u and v knot vector.
virtual void WriteMembers(MGOfstream &buf) const
virtual MGBox box_limitted(const MGBox &uvrange) const =0
Return minimum box that includes limitted surface by uvrange.
virtual MGSurface & exchange_uv()=0
Exchange parameter u and v.
MGPSRELATION
Definition: MGCL.h:131
MGPosition range(const MGPosition &uv) const
Definition: Plane.h:574
Plane. 平面
Definition: MGCL.h:175
virtual int isect_guess_straight(const MGStraight &sl, double ti, const MGPosition &uvi, double &t, MGPosition &uv) const
virtual MGSURFACE_TYPE type() const
Definition: Plane.h:617
virtual long identify_type() const =0
Return This object's typeID.
MGIfstream is a class to read the serialized data generated by MGOfstream.
Definition: Ifstream.h:30
virtual MGPosition center() const
Obtain ceter coordinate of the geometry.
Definition: Plane.h:178
virtual int sdim() const =0
Return the surface type.
virtual MGPosition param(const MGPosition &) const
Return surface parameter value of a point on the surface.
virtual MGPosition perimeter_uv(int i, double t) const
Construct perimeter i's (u,v) parameter position.
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
Definition: VBO.h:86
virtual double param_error_u() const
virtual MGSSisect_list isect(const MGSurface &srf2) const =0
Surface and Surface intersection.
virtual void eval_all(double u, double v, MGPosition &f, MGVector &fu, MGVector &fv, MGVector &fuv, MGVector &fuu, MGVector &fvv) const
Evaluate right continuous surface data.
Vector of a general n space dimension.
Definition: Vector.h:26
virtual void shade(mgVBO &vbo, const MGDrawParam &para, mgVBO::ELEMENT_TARGET target=mgVBO::SHADING) const
Shade the object in world coordinates.
Definition: Plane.h:247
Defines a Box of any space dimendion.
Definition: Box.h:34
virtual bool on(const MGPosition &P, MGPosition &) const
Test if point P is ont the surface or not.
virtual MGCSisect_list isect_withC1LB(const MGLBRep &lb) const
Compute intersections with MGLBRep lb that does not have C0 continuity in it.
Define MGBSumCurve Class(Boolean sum curve of three curves).
Definition: BSumCurve.h:28
MGSurface & operator*=(double scale)=0
double distance() const
Definition: Plane.h:223
MGSurface & operator-=(const MGVector &v)=0
Defines parameters to draw MGObject, maily to approximate by lines and facets.
Definition: drawParam.h:53
virtual MGSurface * clone() const =0
Construct new surface object by copying to newed area.
MGFace is a trimmed surface.
Definition: Face.h:51
virtual void drawWire(mgVBO &vbo, double span_length, int line_density=1) const
Definition: Plane.h:231
double span_length_wire() const
Definition: drawParam.h:93
virtual MGSurface * copy_change_dimension(int sdim, int start1=0, int start2=0) const =0
Construct new surface object by changing the original object's space dimension.
bool operator!=(const MGGel &gel2) const
Definition: Plane.h:150
virtual bool flat(const MGBox &uvbox, double tol, int &direction, MGPosition &P, MGUnit_vector &N) const
MGGel is an abstract class which represents a group element.
Definition: Gel.h:53
MGStraight is a curve of any space dimension, represent a straight line.
Definition: Straight.h:49
virtual MGCSisect_list isectSl(const MGStraight &sl, const MGBox &uvbox=mgNULL_BOX) const
Intersection of Surface and a straight line.
virtual void display_arrows(mgSysGL &sgl) const
MGSSisect represents one intersection line of two surfaces.
Definition: SSisect.h:29
virtual MGSurface * part(const MGBox &bx, int multiple=0) const =0
Compute part of the surface limitted by the parameter range bx.
Definition: VBO.h:85
One Intersection of curve and surface.
Definition: CSisect.h:26
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
virtual void isect_inner_dt(int n, const MGPosition &uvnow, double &du, double &dv, int &kdt, double acuRatio=1.) const
Definition: Surface.h:1199
virtual int isect_order() const =0
Represent a positional data.
Definition: Position.h:28
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
int intersect_dnum_u() const
Definition: Plane.h:293
MGPlane & change_range(int is_u, double t1, double t2)
Definition: Plane.h:190
MGSurface & operator+=(const MGVector &v)=0
Object transformation.
MGSSisect_list defines linked list of MGSSisect.
Definition: SSisect_list.h:26
MGCSisect_list defines linked list of MGCSisect.
Definition: CSisect_list.h:22
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
ELEMENT_TARGET
Definition: VBO.h:84
virtual double param_e_v() const
Definition: Plane.h:433
Defines Boolean sum surface.
Definition: BSumSurf.h:26
bool on_a_perimeter(double &u, double &v, int &perim_num) const
Definition: Plane.h:404
virtual MGPvector< MGCurve > skeleton(int density=1) const
virtual MGCSisect_list isect_with_noCompoSC(const MGSurfCurve &scrv) const
isect with SurfCurve whose m_curve is not a MGTrimmedCurve of MGCompositeCurve.
virtual int project(const MGCurve &crv, MGPvector< MGCurve > &vec_crv_uv, MGPvector< MGCurve > &vec_crv, const MGVector &vec=mgNULL_VEC) const
virtual MGPosition closest(const MGPosition &point) const
Compute the closest point parameter value (u,v)of this surface from a point.
virtual std::auto_ptr< MGSurface > offset_c1(double ofs_value, int &error) const
C1 continuous Surface offset.
Defines BPoint seq of a space dimension and of a capacity.
Definition: BPointSeq.h:38
MGVector eval(const MGPosition &uv, int ndu=0, int ndv=0) const
Evaluate surface data.
Definition: Plane.h:262
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual void negate()
Negate direction of surface.
Definition: Surface.h:730
VIEWMODE
Definition: MGCL.h:271
MGPosition m_root_point
Definition: Plane.h:692
bool in_range(const MGPosition &uv) const
Definition: Plane.h:288
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
int intersect_dnum_v() const
Definition: Plane.h:294
virtual int perimeter_num() const
Return how many perimeters this surface has.
Definition: Plane.h:465
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
virtual bool operator==(const MGGel &gel2) const =0
comparison
virtual double knot_u(int i) const
Access to i-th element of u knot.
Definition: Surface.h:691
virtual double param_error() const
Obtain parameter space error.
virtual MGCurve * perimeter_curve(int i) const
Definition: Plane.h:462
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
container_type::iterator iterator
Definition: Position_list.h:33
virtual MGSurface & change_dimension(int sdim, int start1=0, int start2=0)=0
Changing this object's space dimension.
virtual double param_e_u() const
Return ending parameter value.
Definition: Plane.h:432
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
virtual double param_s_u() const
Return starting parameter value.
Definition: Plane.h:440
virtual MGBox param_range() const
Return parameter range.
const MGPosition & root_point() const
Definition: Plane.h:593
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
bool on_the_perimeter(int perim_num, double u, double v) const
Definition: Plane.h:413
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
virtual double param_s_v() const
Definition: Plane.h:441
double ref(int i) const
Definition: Position.h:304
virtual MGPosition_list perps(const MGPosition &P) const
Return all foots of perpendicular straight lines from P.
MGSURFACE_TYPE
Surface type(曲面の種類).
Definition: MGCL.h:173
const MGUnit_vector & normal() const
Definition: Plane.h:372
virtual int isect_area_length() const
Definition: Surface.h:1161
const double mgInfiniteVal
Definition: MGCL.h:107
mgSysGL is a class to provide a facility to draw temporal pictures.
Definition: sysGL.h:26
OpenGL 4 用描画のためのクラス, in other words, display list.
Definition: VBO.h:76
virtual void make_display_list(MGCL::VIEWMODE vmode=MGCL::DONTCARE) const
Make a display list of this gel.
virtual double param_error_v() const
virtual int isect_guess(const MGCurve &crv, const MGPosition &uvi, double ti, MGPosition &uv, double &t) const
MGVector normal(const MGPosition &uv) const
Compute normal vector(not unit) at uv.
Definition: Plane.h:371
const MGVector & v_deriv() const
Definition: Plane.h:625
bool operator!=(const MGPlane &gel2) const
Definition: Plane.h:151
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGVector normal(double u, double v) const
Return the normal of the plane, 平面の法線を返却する.
Definition: Plane.h:370
virtual double knot_v(int i) const
Access to i-th element of v knot.
Definition: Surface.h:694
const MGVector & u_deriv() const
Definition: Plane.h:621
virtual MGCurve * parameter_curve(int is_u, double x) const =0
Compute parameter curve.
MGSurfCurve is a curve on a surface.
Definition: SurfCurve.h:43
friend class MGPlane
Definition: Surface.h:1306
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30
std::string whoami() const
Definition: Plane.h:636