MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Sphere.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGSphere_HH_
6 #define _MGSphere_HH_
7 #include "mg/Position.h"
8 #include "mg/Unit_vector.h"
9 #include "mg/CSisect_list.h"
10 #include "mg/Surface.h"
11 #include "mg/Ellipse.h"
12 #include "mg/Straight.h"
13 
14 // MGSphere.h
15 // Header for class MGSphere
16 
17 class MGTransf;
18 class MGStraight;
19 class MGSBRep;
20 class MGIfstream;
21 class MGOfstream;
22 class MGIgesOfstream;
28 
42 class MG_DLL_DECLR MGSphere :public MGSurface{
43 
44 public:
45 
47 MG_DLL_DECLR friend MGSphere operator+ (const MGVector& v, const MGSphere& cyl);
48 
50 MG_DLL_DECLR friend MGSphere operator* (double scale, const MGSphere& cyl);
51 
53 
55 MGSphere(void);
56 
57 //Copy constructor.
58 //MGSphere(const MGSphere& cyl);
59 
61 MGSphere(
62  const MGPosition& cntr,
63  double radius
64 );
65 
70 MGSphere(
71  const MGPosition& cntr,
72  double radius,
73  const MGUnit_vector& B,
74  const MGVector& M
75 );
76 
79 MGSphere(
80  int dim,
81  const MGSphere& cyl,
82  int start1=0,
83  int start2=0
84 );
85 
90 MGSphere(
91  const MGEllipse& ellipse
92 );
93 
98 MGSphere(
99  const MGEllipse& ellipse,
100  MGInterval urange
101 );
102 
105 
107 
111 MGSphere& operator=(const MGGel& gel2);
112 MGSphere& operator=(const MGSphere& gel2);
113 
115 MGSphere operator+ (const MGVector& ) const;
116 
118 MGSphere operator- (const MGVector& ) const;
119 
122 MGSphere operator* (double) const;
123 
125 MGSphere operator* (const MGMatrix& ) const;
126 
128 MGSphere operator* (const MGTransf& ) const;
129 
131 MGSphere& operator+=(const MGVector& v);
132 MGSphere& operator-=(const MGVector& v);
133 MGSphere& operator*=(double scale);
134 MGSphere& operator*=(const MGMatrix& mat);
135 MGSphere& operator*=(const MGTransf& tr);
136 
138 bool operator==(const MGSphere& gel2)const;
139 bool operator==(const MGGel& gel2)const;
140 bool operator<(const MGSphere& gel2)const;
141 bool operator<(const MGGel& gel2)const;
142 bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));};
143 bool operator!=(const MGSphere& gel2)const{return !(gel2==(*this));};
144 
147 int out_to_IGES(
148  MGIgesOfstream& igesfile,
149  int SubordinateEntitySwitch=0
150 )const;
151 
155 std::ostream& out(std::ostream &) const;
156 
158 
162  const MGBox& uvrange
163 ) const;
164 
167  int sdim,
168  int start1=0,
169  int start2=0
170 );
171 
175  int is_u,
176  double t1,
177  double t2
178 );
179 
182 MGPosition closest(const MGPosition& point) const;
183 
186 MGPosition closest_on_perimeter(const MGPosition& point)const;
187 
190 MGSphere* clone() const;
191 
196  int sdim,
197  int start1=0,
198  int start2=0
199 )const;
200 
202 bool degenerate_at_v0()const;
203 
205 bool degenerate_at_v1()const;
206 
209 double distance(const MGPosition& point) const;
210 
212 const MGEllipse& ellipseu() const{return m_ellipseu;};
213 const MGEllipse& ellipsev() const{return m_ellipsev;};
214 MGEllipse& ellipseu(){return m_ellipseu;};
215 MGEllipse& ellipsev(){return m_ellipsev;};
216 
218 MGVector eval(
219  double u,
220  double v
221  , int ndu=0
222  , int ndv=0
223 ) const;
224 
227  const MGPosition& uv
228  , int ndu=0
229  , int ndv=0
230 )const{return eval(uv.ref(0),uv.ref(1),ndu,ndv);}
231 
234 
240  int perimeter,
241  double param,
243  double length,
244  double dk=0.
245 );
251 
253 long identify_type() const;
254 
255 bool in_range(double u, double v) const;
256 
260 int intersect_dnum_u() const{ return m_ellipseu.intersect_dnum();};
261 int intersect_dnum_v() const{ return m_ellipsev.intersect_dnum();};
262 
265 MGCSisect_list isect(const MGCurve& curve)const;
266 MGCSisect_list isect(const MGStraight& line)const{ return isectSl(line);};
267 MGCSisect_list isect(const MGRLBRep& curve)const;
268 MGCSisect_list isect(const MGEllipse& curve)const;
269 MGCSisect_list isect(const MGLBRep& curve)const;
270 MGCSisect_list isect(const MGSurfCurve& curve)const;
271 MGCSisect_list isect(const MGBSumCurve& curve)const;
272 
275 MGSSisect_list isect(const MGSurface& srf2)const;
276 MGSSisect_list isect(const MGPlane& srf2)const;
277 MGSSisect_list isect(const MGSphere& srf2)const;
278 MGSSisect_list isect(const MGCylinder& srf2)const;
279 MGSSisect_list isect(const MGSBRep& srf2)const;
280 MGSSisect_list isect(const MGRSBRep& srf2)const;
281 MGSSisect_list isect(const MGBSumSurf& srf2)const;
282 
284 double knot_u(int i)const{return m_ellipseu.knot(i);};
285 double knot_v(int j)const{return m_ellipsev.knot(j);};
286 
288 const MGKnotVector& knot_vector_u() const{return m_ellipseu.knot_vector();};
289 MGKnotVector& knot_vector_u(){return m_ellipseu.knot_vector();};
290 
292 const MGKnotVector& knot_vector_v() const{return m_ellipsev.knot_vector();};
293 MGKnotVector& knot_vector_v(){return m_ellipsev.knot_vector();};
294 
307 const MGVector& M()const{return m_ellipseu.major_axis();};
308 const MGVector& N()const{return m_ellipseu.minor_axis();};
309 const MGVector& B()const{return m_ellipsev.minor_axis();};
310 const MGPosition& C()const{return m_ellipsev.m_center;};
311 
314 void negate(int is_u);
315 
320 MGPosition negate_param(const MGPosition& uv, int is_u=1)const;
321 
328 std::auto_ptr<MGSurface> offset_c1(
329  double ofs_value,
330  int& error
331 )const;
333 
336 bool on(
337  const MGPosition& point,
338  MGPosition& puv
339 )const;
340 
343 bool outgoing()const;
344 
346 double param_error() const;
347 
349 double param_e_u()const{return m_ellipseu.param_e();};
350 double param_e_v()const{return m_ellipsev.param_e();};
351 
354 MGBox param_range()const;
355 
357 double param_s_u()const{return m_ellipseu.param_s();};
358 double param_s_v()const{return m_ellipsev.param_s();};
359 
363  int is_u
364  , double x
365 )const;
367 
371 MGSphere* part(
372  const MGBox& bx,
373  int multiple=0
374 )const;
376 
379 MGCurve* perimeter_curve(int i)const;
380 
382 int perimeter_num()const{return 4;};
383 
388 int perp_point(
389  const MGPosition& P,
390  MGPosition& uv,
391  const MGPosition* uvguess=NULL
392 )const;
393 
398  const MGPosition& P
399 )const;
400 
402 double radius()const{return m_ellipseu.radius();};
403 
407 MGPosition range(const MGPosition& uv) const;
408 
410 int sdim() const;
411 
413 bool sphere() const{return m_ellipseu.circle();};
414 
416 const MGPosition& sphere_center()const{return m_ellipsev.m_center;};
417 
421 
422 std::string whoami()const{return "Sphere";};
423 
424 protected:
425 
428  const MGStraight& sl,
429  const MGBox& uvbox=mgNULL_BOX
430 )const;
432 
434 void ReadMembers(MGIfstream& buf);
435 
437 void WriteMembers(MGOfstream& buf) const;
438 
439 private:
440 
441  MGEllipse m_ellipseu;
442  MGEllipse m_ellipsev;
444 
447 void box_driver(MGBox& bx)const;
448 
452 void box_uconst(MGBox& bx, double u)const;
453 
457 void box_vconst(MGBox& bx, double v)const;
458 
461 MGBox* compute_box() const;
462 
465 int isect_area_length() const{return 10;};
466 
469 void isect_dt(
470  double u, double v, double& du, double& dv,
471  double acuRatio=1.
472 ) const;
473 
477  const MGPosition& uv,
478  int kdt,
479  double du, double dv,
481  double& u,
482  double& v,
483  int incr=1
484 ) const;
485 
488 int isect_order() const{return 4;}
489 
491 MGSSisect_list intersectPl(const MGPlane& pl) const;
492 
495 int offset_div_num() const{return 1;};
496 
502 MGSBRep* surf1D(const MGPlane& plane)const{assert(false);return 0;};
503 
507 void compute_uv(const MGPosition& P, double&u, double&v)const;
508 
509 };
510  // end of GEO group
512 #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 MGCurve * perimeter_curve(int i) const
Retrieve perimeter i of this surface.
virtual void ReadMembers(MGIfstream &buf)
virtual int perp_point(const MGPosition &P, MGPosition &uv, const MGPosition *uvguess=0) const
Return the foot of the perpendicular straight line from P.
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
const MGVector & B() const
Definition: Sphere.h:309
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
virtual MGCurve * isect_incr_pline(const MGPosition &uv, int kdt, double du, double dv, double &u, double &v, int incr=0) const =0
int intersect_dnum_u() const
Definition: Sphere.h:260
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
MGEllipse & ellipseu()
Definition: Sphere.h:214
MGSURFACE_TYPE type() const
Definition: Sphere.h:420
double param_e_u() const
Return ending parameter value.
Definition: Sphere.h:349
MGEllipse & ellipsev()
Definition: Sphere.h:215
virtual void WriteMembers(MGOfstream &buf) const
virtual bool in_range(double u, double v) const =0
Test if the parameter(u,v) is in this surface's parameter range.
const MGKnotVector & knot_vector_u() const
Returns the u knot vector.
Definition: Sphere.h:288
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.
int perimeter_num() const
Return how many perimeters this surface has.
Definition: Sphere.h:382
MGSSisect_list intersectPl(const MGPlane &srf2) const
Default intersection program of MGSurface with a plane.
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 int sdim() const =0
Return the surface type.
bool operator!=(const MGSphere &gel2) const
Definition: Sphere.h:143
const MGEllipse & ellipseu() const
Return the constituent ellipses of the Sphere.
Definition: Sphere.h:212
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
MGKnotVector & knot_vector_v()
Definition: Sphere.h:293
double param_s_u() const
Return starting parameter value.
Definition: Sphere.h:357
virtual MGSurface & change_range(int is_u, double t1, double t2)=0
Change parameter range, able to change the direction by providing t1 greater than t2...
virtual MGSSisect_list isect(const MGSurface &srf2) const =0
Surface and Surface intersection.
Vector of a general n space dimension.
Definition: Vector.h:26
virtual MGPosition range(const MGPosition &) const
Round the input parameter value uv.
virtual MGPosition closest_on_perimeter(const MGPosition &point) const
Compute the closest point on all the perimeters of the surface.
virtual MGSurface & extend(int perimeter, double param, double length, double dk=0.)
Modify the original Surface by extrapolating the specified perimeter.
Definition: Surface.h:365
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.
Define MGBSumCurve Class(Boolean sum curve of three curves).
Definition: BSumCurve.h:28
MGSurface & operator*=(double scale)=0
MGSurface & operator-=(const MGVector &v)=0
virtual MGSurface * clone() const =0
Construct new surface object by copying to newed area.
double param_e_v() const
Definition: Sphere.h:350
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.
const MGKnotVector & knot_vector_v() const
Returns the v knot vector.
Definition: Sphere.h:292
Sphere. 球面
Definition: MGCL.h:177
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
Interval of 1 dimension, i.e. MGInterval is a real line.
Definition: Interval.h:22
virtual MGCSisect_list isectSl(const MGStraight &sl, const MGBox &uvbox=mgNULL_BOX) const
Intersection of Surface and a straight line.
virtual MGSurface * part(const MGBox &bx, int multiple=0) const =0
Compute part of the surface limitted by the parameter range bx.
MG_DLL_DECLR MGVector operator*(const MGVector &v, const MGMatrix &m)
virtual int isect_order() const =0
Represent a positional data.
Definition: Position.h:28
bool sphere() const
Return if this is sphere(i.e. the length of M, N, and B are all equal) or not.
Definition: Sphere.h:413
MGSurface is an abstract class of 3D surface.
Definition: Surface.h:54
double knot_u(int i) const
Return knot value of (infinite-minus, infinite-plus)
Definition: Sphere.h:284
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
const MGVector & N() const
Definition: Sphere.h:308
Defines Boolean sum surface.
Definition: BSumSurf.h:26
const MGVector & M() const
Definition: Sphere.h:307
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.
const MGEllipse & ellipsev() const
Definition: Sphere.h:213
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual void negate()
Negate direction of surface.
Definition: Surface.h:730
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
MGPosition_list provides a list of Positions.
Definition: Position_list.h:27
virtual bool operator==(const MGGel &gel2) const =0
comparison
virtual double param_error() const
Obtain parameter space error.
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
virtual MGSurface & change_dimension(int sdim, int start1=0, int start2=0)=0
Changing this object's space dimension.
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
const MGPosition & C() const
Definition: Sphere.h:310
MGVector eval(const MGPosition &uv, int ndu=0, int ndv=0) const
Evaluate surface data.
Definition: Sphere.h:226
virtual MGBox param_range() const
Return parameter range.
int intersect_dnum_v() const
Definition: Sphere.h:261
std::string whoami() const
Definition: Sphere.h:422
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
const MGPosition & sphere_center() const
Get the center of the sphere.
Definition: Sphere.h:416
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
double ref(int i) const
Definition: Position.h:304
MGKnotVector & knot_vector_u()
Definition: Sphere.h:289
virtual MGPosition_list perps(const MGPosition &P) const
Return all foots of perpendicular straight lines from P.
bool operator!=(const MGGel &gel2) const
Definition: Sphere.h:142
MGSURFACE_TYPE
Surface type(曲面の種類).
Definition: MGCL.h:173
double knot_v(int j) const
Access to i-th element of v knot.
Definition: Sphere.h:285
virtual int isect_area_length() const
Definition: Surface.h:1161
MGCSisect_list isect(const MGStraight &line) const
Definition: Sphere.h:266
void isect_dt(double u, double v, double &du, double &dv, double acuRatio=1.) const
double radius() const
Get the radius of the sphere.
Definition: Sphere.h:402
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
virtual MGCurve * parameter_curve(int is_u, double x) const =0
Compute parameter curve.
double param_s_v() const
Definition: Sphere.h:358
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