/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGRSBRep_HH_ #define _MGRSBRep_HH_ #include "mg/Position.h" #include "mg/SBRep.h" // MGRSBRep.h // // Forward Declaration class MGSPointSeq; class MGKnotArray; class MGMatrix; class MGTransf; class MGStraight; class MGRLBRep; class MGPlane; class MGCSisect_list; class MGSSisect_list; class MGIfstream; class MGOfstream; /** @file */ /** @addtogroup GEO * @{ */ /// Defines Surface B-Representation of rational form. /// This NURBS is of homogeneous form, i.e., B-Coefficients have /// weight included values. /// When usual(non-homogeneous) NURBS form is (xij, yij, zij, wij) , /// MGRSBRep form is (xij*wij, yij*wij, zij*wij, wij) /// for i=0,..., m-1, and j=0,..., n-1. class MG_DLL_DECLR MGRSBRep: public MGSurface { public: /// 与えられたスケーリングで曲面の変換を行いオブジェクトを生成する。 ///Scaling. MG_DLL_DECLR friend MGRSBRep operator* (double scale, const MGRSBRep& sb); //////////// Constructor //////////// ///Default constructor(dummy surface brep). MGRSBRep():MGSurface(){;}; ///Construct MGRSBRep from the raw data. MGRSBRep( const MGSPointSeq& bcoef, ///=0. const MGRSBRep& brep2, ///B-Rep 2. int which2, ///which perimeter of brep2. int opposite /// Input if parameter direction of which2 /// is the same as which1 along common edge. /// If opposite is true, the direction is opposite. ); */ /// Gets new NURBS Surface by computing a part of the original. ///New one is exactly the same as the original except that it is partial. ///If multiple==true(!=0), knot_u(i)=t1 and knot_u(n+i)=t2 for i=0,..., k-1 ///will be guaranteed. Here, n=bdim_u(), k=order_u(), ///t1=uvrange(0).low_point(), and t2=uvrange(0).high_point(). ///About knot_v(j), the same. /// Both u-range and v-range must be inside the range of old. MGRSBRep( const MGBox& uvrange, ///order_u() is 2). /// ///If MGRLBRep's in vecPtrRibRLBReps may have different knot configurations, ///use the global function createSurfaceFromRibs(declared in MGSBRep.h). MGRSBRep( const std::vector& vecPtrRibRLBReps, bool direction_adjustment=true//=true, curves[.] direction are adjusted to line //to the same direction. ); /// MGRSBRep(const MGRSBRep&); ///Copy constructor. /// We can use default copy constructor. ///Destructor /// ~MGRSBRep(); ///We can use default destructor. //////////// Operator overload //////////// ///Assignment. ///When the leaf object of this and srf2 are not equal, this assignment ///does nothing. MGRSBRep& operator=(const MGGel& gel2); MGRSBRep& operator=(const MGRSBRep& gel2); /// 曲面の平行移動を行いオブジェクトを生成する。 ///Translation. MGRSBRep operator+ (const MGVector& ) const; /// 曲面の逆方向に平行移動を行いオブジェクトを生成する。 ///Translation. MGRSBRep operator- (const MGVector& ) const; /// 与えられたスケーリングで曲面の変換を行いオブジェクトを生成する。 ///Scaling. MGRSBRep operator* (double) const; /// 与えられた変換で曲面の変換を行いオブジェクトを生成する。 ///Matrix transformation. MGRSBRep operator* (const MGMatrix& ) const; /// 与えられた変換で曲面のトランスフォームを行いオブジェクトを生成する。 ///General transformation. MGRSBRep operator* (const MGTransf& ) const; ///Object transformation. MGRSBRep& operator+=(const MGVector& v); MGRSBRep& operator-=(const MGVector& v); MGRSBRep& operator*=(double scale); MGRSBRep& operator*=(const MGMatrix& mat); MGRSBRep& operator*=(const MGTransf& tr); ///Comparison of two curves. bool operator==(const MGRSBRep& gel2)const; bool operator==(const MGGel& gel2)const; bool operator<(const MGRSBRep& gel2)const; bool operator<(const MGGel& gel2)const; bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));}; bool operator!=(const MGRSBRep& gel2)const{return !(gel2==(*this));}; bool operator==(const MGSBRep& sb)const; //////////// Member Function //////////// /// 自身の曲面の全体の面積を返却する。 ///Compute total surface area. /// double area() const; /// 与えられたパラメータ範囲の曲面の面積を返す。 ///Compute surface area limitted by parameter range box. /// double area(const MGBox& box) const; ///Returns B-Rep Dimension of u. int bdim_u() const{return m_surface.bdim_u();} ///Returns B-Rep Dimension of v. int bdim_v() const{return m_surface.bdim_v();} /// 入力のパラメータ範囲の曲面部分を囲むボックスを返す。 ///Compute minimum box that includes the surface. MGBox box_limitted(const MGBox& bx) const;///Limited surface be the parameter box. ///Changing this object's space dimension. MGRSBRep& change_dimension( int sdim, ///< new space dimension int start1=0,///< Destination order of new object. int start2=0 ///< Source order of this object. ); ///Change parameter range, be able to change the direction by providing ///t1 greater than t2. MGRSBRep& change_range( int is_u, ///=0. int& opposite, /// Outputs if parameter direction of which2 /// is the same as which1 along common edge. /// If opposite is true, the direction is opposite. double& ratio /// Ratio of 1st derivatives of the two surfaces will /// be returned. /// ratio= d2/d1, where d1=1st deriv of this and d2=of brep2 ) const; */ ///Construct new surface object by copying to newed area. ///User must delete this copied object by "delete". MGRSBRep* clone() const; ///Construct new surface object by changing ///the original object's space dimension. ///User must delete this copied object by "delete". MGRSBRep* copy_change_dimension( int sdim, ///< new space dimension int start1=0, ///< Destination order of new line. int start2=0 ///< Source order of this line. )const; ///Display control polygons using mgVBO::MGDrawPointSeq(sp) void display_control_polygon(mgSysGL& sgl)const; ///uまたはv方向に折れ(マルチノット)があるとき面を分割する ///戻り値は、分割数を返却する int divide_multi_knot( MGPvector& srfl ///<分割した曲面リスト ) const; ///Evaluate right continuous ndu'th and ndv'th derivative data. ///Function's return value is (d(ndu+ndv)f(u,v))/(du**ndu*dv**ndv). /// ndu=0 and ndv=0 means positional data evaluation. MGVector eval( double u,///< U parameter value of the surface. double v,///< V parameter value of the surface. int ndu=0, ///< Order of Derivative along u. int ndv=0 ///< Order of Derivative along v. ) const; ///Evaluate surface data. MGVector eval( const MGPosition& uv///< Parameter value of the surface. , int ndu=0 ///< Order of derivative along u. , int ndv=0 ///< Order of derivative along v. ) const; ///Evaluate right continuous surface data. ///Evaluate all positional data and 1st and 2nd derivatives. void eval_all( double u, ///< U Parameter value of the surface. double v, ///< V Parameter value of the surface. MGPosition& f, ///< Positional data. MGVector& fu, ///< df(u,v)/du MGVector& fv, ///< df/dv MGVector& fuv, ///< d**2f/(du*dv) MGVector& fuu, ///< d**2f/(du**2) MGVector& fvv ///< d**2f/(dv**2) ) const; ///Evaluate all of i and j'th derivative data for 0<=i<=ndu, 0<=j<=ndv. /// Output. (d(i+j)f(u,v))/(du**i*dv**j) in deriv[r+j*dim+i*ndv*dim] ///for 0<=r=4. ///The extrapolation is done so that extrapolating length is "length" ///at the position of the parameter value "param" of the perimeter. MGRSBRep& extend( int perimeter, /// rebuild( int how_rebuild=1, ///< intdicates how rebuild be done. ///< =0: no approximation(only parameter change) ///< =1: Reconstructed with new knot configuration again as rational spline(MGRSBRep). ///< =2: approximated by non-rational spline(MGSBRep) with new knot configuration. int parameter_normalization=2, ///=4 is recomended. ///=0. double& ratio /// Ratio of 1st derivatives of the two surfaces will /// be returned. /// ratio= d2/d1, where d1=1st deriv of this and d2=of brep2 ) const; */ ///The following two function will be used in perps or isect ///to decide how many division of the surface along u or v direction ///should be applied before using perp_guess or isect_guess. int intersect_dnum_u() const; int intersect_dnum_v() const; ///"isect1_incr_pline" is a dedicated function of isect_start_incr, will get /// shortest parameter line necessary to compute intersection. MGCurve* isect_incr_pline( const MGPosition& uv,///& srfl) const; ///<分割した曲面リスト ///v方向に折れ(マルチノット)があるとき面を分割する ///戻り値は、分割数を返却する int divide_multi_knot_v( MGPvector& srfl) const; ///<分割した曲面リスト }; namespace MGCL{ ///Compute binominal coefficients. ///Let i=degree, then bc(i,j) contains j-th coefficient of the degree i. ///bc(i,j) for 0<=i<=m and 0<=j<=i in bc[(m+1)*i+j]. ///bc is an arrary of length (m+1)*(m+1). ///m must be greater than or equal to 1. extern MG_DLL_DECLR void Binominal(int m, double* bc); }; /** @} */ // end of GEO group #endif