MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Cylinder.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGCylinder_HH_
6 #define _MGCylinder_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 // MGCylinder.h
15 // Header for class MGCylinder
16 
17 class MGTransf;
18 class MGStraight;
19 class MGSBRep;
20 class MGIfstream;
21 class MGOfstream;
22 
28 
37 class MG_DLL_DECLR MGCylinder :public MGSurface{
38 
39 public:
40 
41 MG_DLL_DECLR friend MGCylinder operator+ (const MGVector& v, const MGCylinder& cyl);
42 
44 
46 MGCylinder(void);
47 
48 //Copy constructor.
49 //MGCylinder(const MGCylinder& cyl);
50 
54  int dim,
55  const MGCylinder& cyl,
56  int start1=0,
57  int start2=0
58 );
59 
63  const MGPosition& bottom,
64  const MGVector axis,
66  double radius,
67  bool outgoing=true
68 );
70 
75  const MGEllipse& ellipse,
76  const MGStraight& axis
77 );
80 
83 
85 
89 MGCylinder& operator=(const MGGel& gel2);
90 MGCylinder& operator=(const MGCylinder& gel2);
91 
93 MGCylinder operator+ (const MGVector& ) const;
94 
96 MGCylinder operator- (const MGVector& ) const;
97 
100 MGCylinder operator* (double) const;
101 
103 MG_DLL_DECLR friend MGCylinder operator* (double scale, const MGCylinder& cyl);
104 
106 MGCylinder operator* (const MGMatrix& ) const;
107 
109 MGCylinder operator* (const MGTransf& ) const;
110 
112 MGCylinder& operator+=(const MGVector& v);
113 MGCylinder& operator-=(const MGVector& v);
114 MGCylinder& operator*=(double scale);
115 MGCylinder& operator*=(const MGMatrix& mat);
116 MGCylinder& operator*=(const MGTransf& tr);
117 
119 bool operator==(const MGCylinder& gel2)const;
120 bool operator==(const MGGel& gel2)const;
121 bool operator<(const MGCylinder& gel2)const;
122 bool operator<(const MGGel& gel2)const;
123 bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));};
124 bool operator!=(const MGCylinder& gel2)const{return !(gel2==(*this));};
125 
127 int out_to_IGES(
128  MGIgesOfstream& igesfile,
129  int SubordinateEntitySwitch=0
130 )const;
131 
135 std::ostream& out(std::ostream &) const;
136 
138 
142  const MGBox& uvrange
143 ) const;
144 
146 MGPosition center() const;
147 
150  int sdim,
151  int start1=0,
152  int start2=0
153 );
154 
158  int is_u,
159  double t1,
160  double t2
161 );
162 
165 MGPosition closest(const MGPosition& point) const;
166 
169 MGCylinder* clone()const;
170 
175  int sdim,
176  int start1=0,
177  int start2=0
178 )const;
179 
182 double distance(const MGPosition& point) const;
183 
185 MGVector eval(
186  double u,
187  double v
188  , int ndu=0
189  , int ndv=0
190 ) const;
191 
194  const MGPosition& uv
195  , int ndu=0
196  , int ndv=0
197 ) const{return eval(uv.ref(0),uv.ref(1),ndu,ndv);}
198 
201 void eval_all(
202  double u,
203  double v,
204  MGPosition& f,
205  MGVector& fu,
206  MGVector& fv,
207  MGVector& fuv,
208  MGVector& fuu,
209  MGVector& fvv
210 ) const;
211 
214 void eval_all(
215  const MGPosition& uv,
216  MGPosition& f,
217  MGVector& fu,
218  MGVector& fv,
219  MGVector& fuv,
220  MGVector& fuu,
221  MGVector& fvv
222 ) const{ eval_all(uv(0),uv(1),f,fu,fv,fuv,fuu,fvv);}
223 
226 
232  int perimeter,
233  double param,
235  double length,
236  double dk=0.
237 );
243 
245 long identify_type() const;
246 
247 bool in_range(double u, double v) const;
248 bool in_range(const MGPosition& uv) const{return in_range(uv[0], uv[1]);};
249 
253 int intersect_dnum_u() const{ return m_ellipse.intersect_dnum();};
254 int intersect_dnum_v() const{ return m_axis.intersect_dnum();};
255 
258 MGCSisect_list isect(const MGCurve& curve)const;
259 MGCSisect_list isect(const MGStraight& line)const{return isectSl(line);};
260 MGCSisect_list isect(const MGRLBRep& curve)const;
261 MGCSisect_list isect(const MGEllipse& curve)const;
262 MGCSisect_list isect(const MGLBRep& curve)const;
263 MGCSisect_list isect(const MGSurfCurve& curve)const;
264 MGCSisect_list isect(const MGBSumCurve& curve)const;
265 
268 MGSSisect_list isect(const MGSurface& srf2)const;
269 MGSSisect_list isect(const MGPlane& srf2)const;
270 MGSSisect_list isect(const MGSphere& srf2)const;
271 MGSSisect_list isect(const MGCylinder& srf2)const;
272 MGSSisect_list isect(const MGSBRep& srf2)const;
273 MGSSisect_list isect(const MGRSBRep& srf2)const;
274 MGSSisect_list isect(const MGBSumSurf& srf2)const;
275 
277 double knot_u(int i)const{return m_ellipse.knot(i);};
278 double knot_v(int j)const{return m_axis.knot(j);};
279 
281 const MGKnotVector& knot_vector_u() const{return m_ellipse.knot_vector();};
282 MGKnotVector& knot_vector_u(){return m_ellipse.knot_vector();};
283 
285 const MGKnotVector& knot_vector_v() const{return m_axis.knot_vector();};
286 MGKnotVector& knot_vector_v(){return m_axis.knot_vector();};
287 
290 void negate(
291  int is_u
292 );
293 
297 MGPosition negate_param(const MGPosition& uv, int is_u=1)const;
298 
300 const MGEllipse& ellipse() const{return m_ellipse;};
301 
303 const MGStraight& axis() const{return m_axis;};
304 
311 std::auto_ptr<MGSurface> offset_c1(
312  double ofs_value,
313  int& error
314 )const;
316 
319 bool on(
320  const MGPosition& point,
321  MGPosition& puv
322 ) const;
324 
327 bool on_a_perimeter(
328  double& u,
329  double& v,
330  int& perim_num
331 )const;
333 
335 double param_error() const;
336 
338 double param_e_u() const{return m_ellipse.param_e();};
339 double param_e_v() const{return m_axis.param_e();};
340 
343 MGBox param_range() const;
344 
346 double param_s_u() const{return m_ellipse.param_s();};
347 double param_s_v() const{return m_axis.param_s();};
348 
352  int is_u
353  , double x
354 ) const;
356 
361  const MGBox& bx,
362  int multiple=0
363 ) const;
365 
368 MGCurve* perimeter_curve(int i) const;
369 
371 int perimeter_num() const{return 4;};
372 
377 int perp_point(
378  const MGPosition& P,
379  MGPosition& uv,
380  const MGPosition* uvguess=NULL
381 ) const;
382 
385  const MGPosition& P
386 ) const;
387 
391 MGPosition range(const MGPosition& uv) const;
392 
394 int sdim() const;
395 
399 
400 protected:
401 
410 bool flat(
411  const MGBox& uvbox,
412  double tol,
413  int& direction,
415  MGPosition& P,
417  MGUnit_vector& N
418 )const;
419 
423 bool flat_tess(
424  double u0,
425  double u1,
426  double v0,
427  double v1,
428  double tol,
429  bool& direction,
431  double max_edge_len
433 )const;
435 
438  const MGStraight& sl,
439  const MGBox& uvbox=mgNULL_BOX
440  ) const;
442 
446 int vrange(const MGPosition& P, double& v)const;
447 
449 void ReadMembers(MGIfstream& buf);
450 
452 void WriteMembers(MGOfstream& buf) const;
453 
454 std::string whoami()const{return "Cylinder";};
455 
456 private:
457 
458  MGEllipse m_ellipse;
459  MGStraight m_axis;
460  bool m_ortho;
461 
464 MGPosition axis_point(double v)const;
465 
468 MGBox* compute_box() const;
469 
472 int isect_area_length() const{return 10;};
473 
479 int isect_direction(
480  const MGFSurface& sf2,
481  int m1,
482  MGPosition& uvuvS,
484  double& du,
485  double& dv,
486  double acuRatio=1.
487 )const;
488 
491 void isect_dt(
492  double u, double v, double& du, double& dv,
493  double acuRatio=1.
494 ) const;
495 
499  const MGPosition& uv,
500  int kdt,
501  double du, double dv,
503  double& u,
504  double& v,
505  int incr=1
506 )const;
507 
511 void isect_inner_dt(
512  int n,
513  const MGPosition& uvnow,
514  double& du, double& dv,
515  int& kdt,
517  double acuRatio=1.
520 ) const;
521 
524 int isect_order() const{return 4;}
525 
527 MGSSisect_list intersectPl(const MGPlane& pl) const;
528 
531 int offset_div_num() const{return 1;};
532 
538 MGSBRep* surf1D(const MGPlane& plane)const{assert(false);return 0;};
539 
540 };
541  // end of GEO group
543 #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.
MGSURFACE_TYPE type() const
Definition: Cylinder.h:398
MGCurve is an abstract class which represents a whole curve.
Definition: Curve.h:63
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
friend class MGCylinder
Definition: Surface.h:1307
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
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
MGCSisect_list isect(const MGStraight &line) const
Definition: Cylinder.h:259
virtual void WriteMembers(MGOfstream &buf) const
double knot_v(int j) const
Access to i-th element of v knot.
Definition: Cylinder.h:278
virtual bool in_range(double u, double v) const =0
Test if the parameter(u,v) is in this surface's parameter range.
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.
double param_e_u() const
Return ending parameter value.
Definition: Cylinder.h:338
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.
double param_s_u() const
Return starting parameter value.
Definition: Cylinder.h:346
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
const MGKnotVector & knot_vector_u() const
Returns the u knot vector.
Definition: Cylinder.h:281
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.
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 MGPosition range(const MGPosition &) const
Round the input parameter value uv.
const MGEllipse & ellipse() const
Return the ellipse rep of the cylinder.
Definition: Cylinder.h:300
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.
int intersect_dnum_v() const
Definition: Cylinder.h:254
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.
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
bool operator!=(const MGCylinder &gel2) const
Definition: Cylinder.h:124
virtual MGCSisect_list isectSl(const MGStraight &sl, const MGBox &uvbox=mgNULL_BOX) const
Intersection of Surface and a straight line.
bool in_range(const MGPosition &uv) const
Definition: Cylinder.h:248
virtual MGSurface * part(const MGBox &bx, int multiple=0) const =0
Compute part of the surface limitted by the parameter range bx.
virtual int isect_direction(const MGFSurface &sf2, int m1, MGPosition &uvuvS, double &du, double &dv, double acuRatio=1.) const
Definition: Surface.h:1168
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
bool operator!=(const MGGel &gel2) const
Definition: Cylinder.h:123
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
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
int intersect_dnum_u() const
Definition: Cylinder.h:253
Defines Knot vector of B-Representation.
Definition: KnotVector.h:28
Defines Boolean sum surface.
Definition: BSumSurf.h:26
virtual MGPosition closest(const MGPosition &point) const
Compute the closest point parameter value (u,v)of this surface from a point.
MGKnotVector & knot_vector_u()
Definition: Cylinder.h:282
virtual std::auto_ptr< MGSurface > offset_c1(double ofs_value, int &error) const
C1 continuous Surface offset.
const MGKnotVector & knot_vector_v() const
Returns the v knot vector.
Definition: Cylinder.h:285
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual void negate()
Negate direction of surface.
Definition: Surface.h:730
const MGStraight & axis() const
Return the normal of the Cylinder.
Definition: Cylinder.h:303
MGFSurface is an abstract class to provide the comman interfaces to MGFace and MGSurface.
Definition: FSurface.h:33
int perimeter_num() const
Return how many perimeters this surface has.
Definition: Cylinder.h:371
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
MGVector eval(const MGPosition &uv, int ndu=0, int ndv=0) const
Evaluate surface data.
Definition: Cylinder.h:193
virtual bool operator==(const MGGel &gel2) const =0
comparison
virtual double param_error() const
Obtain parameter space error.
std::string whoami() const
Definition: Cylinder.h:454
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.
double knot_u(int i) const
Return knot value of (infinite-minus, infinite-plus)
Definition: Cylinder.h:277
Defines Surface B-Representation of rational form.
Definition: RSBRep.h:38
MGKnotVector & knot_vector_v()
Definition: Cylinder.h:286
virtual MGBox param_range() const
Return parameter range.
double param_s_v() const
Definition: Cylinder.h:347
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
Cylinder surface(A special case of MGSURFACE_CONE)
Definition: MGCL.h:183
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
virtual MGPosition center() const
Obtain ceter coordinate of the geometry.
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
virtual int isect_area_length() const
Definition: Surface.h:1161
void isect_dt(double u, double v, double &du, double &dv, double acuRatio=1.) const
virtual bool on_a_perimeter(double &u, double &v, int &perim_num) const
Test if input (u,v) is parameter value on a perimeter of the surface.
void eval_all(const MGPosition &uv, MGPosition &f, MGVector &fu, MGVector &fv, MGVector &fuv, MGVector &fuu, MGVector &fvv) const
Definition: Cylinder.h:214
double param_e_v() const
Definition: Cylinder.h:339
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.
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