MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
RSBRep.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGRSBRep_HH_
6 #define _MGRSBRep_HH_
7 
8 #include "mg/Position.h"
9 #include "mg/SBRep.h"
10 
11 // MGRSBRep.h
12 //
13 
14 // Forward Declaration
15 class MGSPointSeq;
16 class MGKnotArray;
17 class MGMatrix;
18 class MGTransf;
19 class MGStraight;
20 class MGRLBRep;
21 class MGPlane;
22 class MGCSisect_list;
23 class MGSSisect_list;
24 class MGIfstream;
25 class MGOfstream;
31 
38 class MG_DLL_DECLR MGRSBRep: public MGSurface {
39 
40 public:
41 
44 MG_DLL_DECLR friend MGRSBRep operator* (double scale, const MGRSBRep& sb);
45 
47 
50 
52 MGRSBRep(
53  const MGSPointSeq& bcoef,
58  const MGKnotVector& tu,
59  const MGKnotVector& tv,
60  int homogeneous=1
61 );
63 
65 MGRSBRep(
66  const MGSPointSeq& bcoef,
68  const MGSPointSeq& weights,
69  const MGKnotVector& tu,
70  const MGKnotVector& tv
71 );
72 
78 MGRSBRep(
79  const MGRLBRep& rlb,
80  const MGStraight& sl,
81  double angle
83 );
87 
92 MGRSBRep(
93  const MGRLBRep& rlbrep,
94  const MGUnit_vector& uvec,
95  double start_dist,
96  double end_dist
97 );
98 
99 //**** 1. Approximation Constructor ****
100 
106 MGRSBRep(
107  const MGRSBRep& old,
108  const MGKnotVector& ut,
109  const MGKnotVector& vt,
110  int &error
111 );
112 
113 //**** 2.Conversion Constructor.****
114 
121 explicit MGRSBRep(
122  const MGSBRep& brep,
123  int homogeneous=0
126 );
128 
130 MGRSBRep(
131  const MGRSBRep& old,
132  const MGKnotArray& uknots,
133  const MGKnotArray& vknots
134 );
135 
136 /*
140 MGRSBRep(
141  const MGRSBRep& brep1, ///B-Rep 1.
142  int which1, ///which perimeter of brep1.
143  int continuity, ///continuity. Must >=0.
144  const MGRSBRep& brep2, ///B-Rep 2.
145  int which2, ///which perimeter of brep2.
146  int opposite /// Input if parameter direction of which2
149 );
150 */
151 
159 MGRSBRep(
160  const MGBox& uvrange,
161  const MGRSBRep& old,
162  int multiple=0
163 );
165 
168 MGRSBRep(
169  int dim,
170  const MGRSBRep& sbrep,
171  int start1=0,
172  int start2=0
173 );
174 
187 MGRSBRep(
188  const std::vector<const MGRLBRep*>& vecPtrRibRLBReps,
189  bool direction_adjustment=true//=true, curves[.] direction are adjusted to line
190  //to the same direction.
191 );
192 
195 
198 
200 
204 MGRSBRep& operator=(const MGGel& gel2);
205 MGRSBRep& operator=(const MGRSBRep& gel2);
206 
209 MGRSBRep operator+ (const MGVector& ) const;
210 
213 MGRSBRep operator- (const MGVector& ) const;
214 
217 MGRSBRep operator* (double) const;
218 
221 MGRSBRep operator* (const MGMatrix& ) const;
222 
225 MGRSBRep operator* (const MGTransf& ) const;
226 
228 MGRSBRep& operator+=(const MGVector& v);
229 MGRSBRep& operator-=(const MGVector& v);
230 MGRSBRep& operator*=(double scale);
231 MGRSBRep& operator*=(const MGMatrix& mat);
232 MGRSBRep& operator*=(const MGTransf& tr);
233 
235 bool operator==(const MGRSBRep& gel2)const;
236 bool operator==(const MGGel& gel2)const;
237 bool operator<(const MGRSBRep& gel2)const;
238 bool operator<(const MGGel& gel2)const;
239 bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));};
240 bool operator!=(const MGRSBRep& gel2)const{return !(gel2==(*this));};
241 bool operator==(const MGSBRep& sb)const;
242 
244 
248 
252 
254 int bdim_u() const{return m_surface.bdim_u();}
255 
257 int bdim_v() const{return m_surface.bdim_v();}
258 
261 MGBox box_limitted(const MGBox& bx) const;
262 
265  int sdim,
266  int start1=0,
267  int start2=0
268 );
269 
273  int is_u,
274  double t1,
275  double t2
276 );
277 
280 double& coef(int i, int j, int k)
281 { assert(i<bdim_u() && j<bdim_v() && k<=sdim());
282  return m_surface.coef(i,j,k);}
283 
286 double coef(int i, int j, int k)const{return m_surface.coef(i,j,k);}
287 
289 MGVector coef(int i, int j) const{return m_surface.coef(i,j);}
290 
292 const double* coef_data(int i=0, int j=0, int k=0) const
293 {return m_surface.coef_data(i,j,k);}
294 
295 /*
305 int continuity( /// Reuturn value is the continuity.
306  const MGRSBRep& brep2, /// Input second RSBRep
307  int& which1, /// Outputs which perimeter(which1) of this is
308  int& which2, /// connected to which(which2) of brep2.
310  int& opposite, /// Outputs if parameter direction of which2
313  double& ratio /// Ratio of 1st derivatives of the two surfaces will
316 ) const;
317 */
318 
321 MGRSBRep* clone() const;
322 
327  int sdim,
328  int start1=0,
329  int start2=0
330 )const;
331 
333 void display_control_polygon(mgSysGL& sgl)const;
334 
338  MGPvector<MGSurface>& srfl
339 ) const;
340 
344 MGVector eval(
345  double u,
346  double v,
347  int ndu=0,
348  int ndv=0
349 ) const;
350 
352 MGVector eval(
353  const MGPosition& uv
354  , int ndu=0
355  , int ndv=0
356 ) const;
357 
360 void eval_all(
361  double u,
362  double v,
363  MGPosition& f,
364  MGVector& fu,
365  MGVector& fv,
366  MGVector& fuv,
367  MGVector& fuu,
368  MGVector& fvv
369 ) const;
370 
374 void eval_all(
375  double u,
376  double v,
377  int ndu,
378  int ndv,
379  double* deriv
380 ) const;
384 
386 MGSurface& exchange_uv(){m_surface.exchange_uv(); return *this;};
387 
393  int perimeter,
394  double param,
396  double length,
397  double dk=0.
398 );
404 
406 const MGSBRep& homogeneous() const {return m_surface;};
407 
409 long identify_type() const;
410 
412 bool in_range(double u, double v) const{return m_surface.in_range(u,v);};
413 bool in_range(const MGPosition& uv) const{return m_surface.in_range(uv);};
414 
417 MGCSisect_list isect(const MGCurve& curve)const;
418 MGCSisect_list isect(const MGStraight& sl)const{return isectSl(sl);};
419 MGCSisect_list isect(const MGRLBRep& curve)const;
420 MGCSisect_list isect(const MGEllipse& curve)const;
421 MGCSisect_list isect(const MGLBRep& curve)const;
422 MGCSisect_list isect(const MGSurfCurve& curve)const;
423 MGCSisect_list isect(const MGBSumCurve& curve)const;
424 
431 MGSSisect_list isect(const MGSurface& srf2)const;
432 MGSSisect_list isect(const MGPlane& srf2)const;
433 MGSSisect_list isect(const MGSphere& srf2)const;
434 MGSSisect_list isect(const MGCylinder& srf2)const;
435 MGSSisect_list isect(const MGSBRep& srf2)const;
436 MGSSisect_list isect(const MGRSBRep& srf2)const;
437 MGSSisect_list isect(const MGBSumSurf& srf2)const;
438 
441 double& knot_u(int i){return m_surface.knot_u(i);}
442 
445 double knot_u(int i) const{return m_surface.knot_u(i);}
446 
447 double& knot_v(int i){return m_surface.knot_v(i);}
448 
451 double knot_v(int i) const{return m_surface.knot_v(i);}
452 
454 const double* knot_data_u() const{return m_surface.knot_data_u();}
455 
457 const double* knot_data_v() const{return m_surface.knot_data_v();}
458 
461 {return m_surface.knot_vector_u();}
462 MGKnotVector& knot_vector_u(){return m_surface.knot_vector_u();}
463 
466 {return m_surface.knot_vector_v();}
467 MGKnotVector& knot_vector_v(){return m_surface.knot_vector_v();}
468 
472  int i,
473  const MGPosition& uv1,
474  const MGPosition& uv2
475 )const{return m_surface.less_than(i,uv1,uv2);};
476 
480 MGRSBRep& limit(const MGBox& uvrange){m_surface.limit(uvrange); return *this;}
481 
483 void negate(
484  int is_u
485 ){m_surface.negate(is_u);}
487 
491 MGPosition negate_param(const MGPosition& uv, int is_u=1)const
492 { return m_surface.negate_param(uv,is_u);}
493 
496 MGSPointSeq non_homogeneous_bcoef() const;
497 
500 int non_rational() const;
501 
503 int order_u() const{return m_surface.knot_vector_u().order();}
504 
506 int order_v() const{return m_surface.knot_vector_v().order();}
507 
509 MGPosition param_e() const{return m_surface.param_e();}
510 double param_e_u() const{return m_surface.param_e_u();}
511 double param_e_v() const{return m_surface.param_e_v();}
512 
516  int is_u
517  , double x
518 ) const;
520 
522 MGRLBRep parameter_line(
523  int is_u
524  , double x
525 ) const;
527 
530 MGBox param_range() const;
531 
533 MGPosition param_s() const{return m_surface.param_s();}
534 double param_s_u() const{return m_surface.param_s_u();}
535 double param_s_v() const{return m_surface.param_s_v();}
536 
540 MGRSBRep* part(
541  const MGBox& bx,
542  int multiple=0
543 )const;
545 
550 MGRLBRep perimeter(int i) const;
551 
553 int perimeter_num() const{return 4;};
554 
557 int planar(
558  MGPlane& plane,
559  double& deviation
561 ) const;
562 
566 int planar(
567  const MGBox& uvbox,
568  double tol,
569  int* divideU=0
570 )const;
572 
576 MGPosition range(const MGPosition& uv)const{return m_surface.range(uv);}
577 
580 std::auto_ptr<MGSurface> rebuild(
581  int how_rebuild=1,
586  int parameter_normalization=2,
592  double tol=-1.,
593  int* order=0
595 )const;
599 
602 int reduce(
603  int is_u,
604  int ndec
605 ){return m_surface.reduce(is_u,ndec);}
606 
610  const MGKnotVector& uknot,
611  const MGKnotVector& vknot
612 ){m_surface.refine(uknot,vknot); return *this;}
613 
617 void remove_knot();
618 
620 int sdim() const{return m_surface.sdim()-1;}
621 
629  const MGBox& uvbx,
630  int multiple=0
631 ){m_surface.shrink_to_knot(uvbx,multiple);};
633 
636 const MGSPointSeq& surface_bcoef() const{return m_surface.surface_bcoef();}
637 
640 MGSPointSeq& surface_bcoef(){return m_surface.surface_bcoef();}
641 
646 
650 
653 MGSurface& unlimit(){return *this;};
654 
655 public:
656 
658 int out_to_IGES(
659  MGIgesOfstream& igesfile,
660  int SubordinateEntitySwitch=0
661 )const;
662 
664 std::ostream& out(std::ostream&) const;
665 
666 std::string whoami()const{return "RSBRep";};
667 
668 protected:
669 
672  const MGStraight& sl,
673  const MGBox& uvbox=mgNULL_BOX
674 )const;
676 
680 void ReadMembers(MGIfstream& buf);
681 
685 void WriteMembers(MGOfstream& buf) const;
686 
687 private:
688 
690  MGSBRep m_surface;
691 
694 int coef_sdim() const{return m_surface.sdim();};
695 
698 MGBox* compute_box() const;
699 
700 /*
706 int continuity( /// Reuturn value is the continuity.
707  const MGRSBRep& brep2, /// Input second RSBRep
708  int is_u1, /// Input if u-direction of this.
709  int is_u2, /// Input if u-direction of brep2.
710  int opposite, /// Input if parameter direction of which2 is equal or not.
711  int& which1, /// Outputs which perimeter(which1) of this is
712  int& which2, /// connected to which(which2) of brep2.
714  double& ratio /// Ratio of 1st derivatives of the two surfaces will
717 ) const;
718 */
719 
723 int intersect_dnum_u() const;
724 int intersect_dnum_v() const;
725 
729  const MGPosition& uv,
730  int kdt,
731  double du, double dv,
733  double& u,
734  double& v,
735  int incr=1
736 ) const;
737 
739 int isect_order() const;
740 
745 MGSBRep* surf1D(
746  const MGPlane& pl
747 )const;
748 
751 int divide_multi_knot_u(
752  MGPvector<MGRSBRep>& srfl) const;
753 
756 int divide_multi_knot_v(
757  MGPvector<MGSurface>& srfl) const;
758 
759 };
760 
761 namespace MGCL{
763 
768 extern MG_DLL_DECLR void Binominal(int m, double* bc);
769 
770 };
771  // end of GEO group
773 #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
double param_e_v() const
Definition: RSBRep.h:511
virtual void ReadMembers(MGIfstream &buf)
int order_u() const
Returns the B-Rep order(u-direction).
Definition: RSBRep.h:503
int sdim() const
Returns the space dimension.
Definition: RSBRep.h:620
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
MGCylinder is a Cylinder in 3D space.
Definition: Cylinder.h:37
double & coef(int i, int j, int k)
Definition: RSBRep.h:280
bool less_than(int i, const MGPosition &uv1, const MGPosition &uv2) const
Definition: RSBRep.h:471
virtual MGCurve * isect_incr_pline(const MGPosition &uv, int kdt, double du, double dv, double &u, double &v, int incr=0) const =0
MGPosition param_e() const
Return ending parameter value.
Definition: RSBRep.h:509
virtual int out_to_IGES(MGIgesOfstream &igesfile, int SubordinateEntitySwitch=0) const
Definition: Gel.h:93
bool in_range(const MGPosition &uv) const
Definition: RSBRep.h:413
double param_s_v() const
Definition: RSBRep.h:535
MGVector coef(int i, int j) const
Extract (i,j,k) elements for 0<=k
Definition: RSBRep.h:289
virtual void WriteMembers(MGOfstream &buf) const
const double * knot_data_u() const
Returns a pointer to the u knot vector data.
Definition: RSBRep.h:454
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.
virtual int intersect_dnum_u() const =0
virtual void remove_knot()
removal redundant knots within the tolerance line_zero().
MGPosition negate_param(const MGPosition &uv, int is_u=1) const
Definition: RSBRep.h:491
MGSurface & unlimit()
Definition: RSBRep.h:653
MGSURFACE_TYPE type() const
Definition: RSBRep.h:649
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
const double * knot_data_v() const
Returns a pointer to the v knot vector data.
Definition: RSBRep.h:457
virtual int sdim() const =0
Return the surface type.
const MGKnotVector & knot_vector_v() const
Returns the v knot vector.
Definition: RSBRep.h:465
int reduce(int is_u, int ndec)
Definition: RSBRep.h:602
MGLBRep is a class for B-SPline representation.
Definition: LBRep.h:41
virtual int coef_sdim() const
Obtain coefficient's space dimension.
Definition: Surface.h:174
virtual int bdim_u() const
Returns B-Rep Dimension of u.
Definition: Surface.h:132
MGPosition param_s() const
Return starting parameter value.
Definition: RSBRep.h:533
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
const MGKnotVector & knot_vector_u() const
Returns the u knot vector.
Definition: RSBRep.h:460
int bdim_v() const
Returns B-Rep Dimension of v.
Definition: RSBRep.h:257
MGKnotVector & knot_vector_u()
Definition: RSBRep.h:462
int perimeter_num() const
Return how many perimeters this surface has.
Definition: RSBRep.h:553
bool operator!=(const MGGel &gel2) const
Definition: RSBRep.h:239
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
MG_DLL_DECLR void Binominal(int m, double *bc)
Compute binominal coefficients.
Definition: MGCL.h:181
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.
void negate(int is_u)
Change direction of the surface.
Definition: RSBRep.h:483
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 int divide_multi_knot(MGPvector< MGSurface > &srfl) 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
double param_s_u() const
Return starting parameter value.
Definition: RSBRep.h:534
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)
const MGSBRep & homogeneous() const
Return homogeneous Surface B-Representation of the rational B-Spline.
Definition: RSBRep.h:406
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
std::string whoami() const
Definition: RSBRep.h:666
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
MGSPointSeq & surface_bcoef()
Definition: RSBRep.h:640
Defines Boolean sum surface.
Definition: BSumSurf.h:26
double & knot_u(int i)
Definition: RSBRep.h:441
virtual int bdim_v() const
Returns B-Rep Dimension of v.
Definition: Surface.h:135
MGCSisect_list isect(const MGStraight &sl) const
Definition: RSBRep.h:418
Definition: Curve.h:1282
MGSphere is a Sphere in 3D space.
Definition: Sphere.h:42
virtual int intersect_dnum_v() const =0
double & knot_v(int i)
Definition: RSBRep.h:447
int bdim_u() const
Returns B-Rep Dimension of u.
Definition: RSBRep.h:254
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 order_v() const
Returns the B-Rep order(v-direction).
Definition: RSBRep.h:506
virtual bool operator==(const MGGel &gel2) const =0
comparison
double knot_u(int i) const
Definition: RSBRep.h:445
MGOgesIfstream write out to *.iges file, transforming MGCL objects to IGES objects.
Definition: IgesOfstream.h:26
MGRSBRep & limit(const MGBox &uvrange)
Definition: RSBRep.h:480
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
MGRSBRep & refine(const MGKnotVector &uknot, const MGKnotVector &vknot)
Definition: RSBRep.h:609
virtual MGBox param_range() const
Return parameter range.
double coef(int i, int j, int k) const
Definition: RSBRep.h:286
Defines Surface B-Representation, that is , B-Spline surface.
Definition: SBRep.h:48
MGEllipse is a class to define an ellipse of 2D or 3D.
Definition: Ellipse.h:38
int sdim() const
Returns the space dimension.
Definition: SBRep.h:851
MGSURFACE_TYPE
Surface type(曲面の種類).
Definition: MGCL.h:173
Defines Array of Knots.
Definition: KnotArray.h:26
Defines Spoint seq of a space dimension and of a size.
Definition: SPointSeq.h:36
mgSysGL is a class to provide a facility to draw temporal pictures.
Definition: sysGL.h:26
double param_e_u() const
Return ending parameter value.
Definition: RSBRep.h:510
const double * coef_data(int i=0, int j=0, int k=0) const
Returns a pointer to the surface b-coef data.
Definition: RSBRep.h:292
Defines Vector of newed object pointers.
Definition: Pvector.h:27
virtual void display_control_polygon(mgSysGL &sgl) const
Definition: Gel.h:194
MGPosition range(const MGPosition &uv) const
Definition: RSBRep.h:576
double knot_v(int i) const
Definition: RSBRep.h:451
MGSurface & exchange_uv()
Exchange parameter u and v.
Definition: RSBRep.h:386
MGRSBRep()
Default constructor(dummy surface brep).
Definition: RSBRep.h:49
Define a unit vector, is a MGVector.
Definition: Unit_vector.h:17
MGKnotVector & knot_vector_v()
Definition: RSBRep.h:467
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
void shrink_to_knot(const MGBox &uvbx, int multiple=0)
Definition: RSBRep.h:628
const MGSPointSeq & surface_bcoef() const
Definition: RSBRep.h:636
MGMatrix is a matix of m by m, where m is the space dimension.
Definition: Matrix.h:30
bool operator!=(const MGRSBRep &gel2) const
Definition: RSBRep.h:240
bool in_range(double u, double v) const
Test if input parameter value is inside parameter range of the surface.
Definition: RSBRep.h:412