/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGSBRep_HH_ #define _MGSBRep_HH_ #include #include "mg/MGCL.h" #include "mg/Vector.h" #include "mg/SPointSeq.h" #include "mg/KnotVector.h" #include "mg/Surface.h" #include "mg/CSisect_list.h" #include "mg/SSisect_list.h" // MGSBRep.h // // Forward Declaration class MGBox; class MGNDDArray; class MGPosition; class MGBPointSeq; class MGKnotArray; class MGMatrix; class MGTransf; class MGLBRep; class MGSBRepEndC; class MGSBRepTP; class MGSBRepVecTP; class MGStraight; class MGEllipse; class MGPlane; class MGIfstream; class MGOfstream; /** @file */ /** @addtogroup GEO * @{ */ ///Defines Surface B-Representation, that is , B-Spline surface. ///MGSBRep is a tensor product surface representation of MGLBRep. ///It has: ///(1) Surface control polygon MGSPointSeq surface_bcoef. ///(2) U direciton knot vector MGKnotVector uknot. ///(3) V direction knot vector MGKnotVector vknot. class MG_DLL_DECLR MGSBRep: public MGSurface { public: /// 与えられたスケーリングで曲面の変換を行いオブジェクトを生成する。 ///Scaling. MG_DLL_DECLR friend MGSBRep operator* (double scale, const MGSBRep& sb); ///build_SBRep_1direction constructs MGSBRep brep, by interpolating only u-direction. ///Input (utaui, tu) will make brep's v direction parameter, and (vtaui, tv) will make /// udirection parameter. That is, u and v will be exchanged for output brep. MG_DLL_DECLR friend void build_SBRep_1direction( MGSBRepEndC& endc, ///& lines, const MGLBRep* deriS, const MGLBRep* deriE ); //**** 2. Approximation Constructor **** ///Approximate an original B-Rep by a new knot configuration. ///The new knot config must be inside the range of the original B-Rep ///parameter. However new knots may be coarse or fine. ///Error indicates the contructor is successful(=0) or not(!=0). ///When error!=0, the original old_brep is copied to this. MGSBRep( const MGSBRep& old_brep,///& edges, ///<境界線リスト(vmin,umax,vmax,uminの順,辺番号0,1,2,3の順) int& error , ///<エラーコードが出力される(0:正常終了) const MGCurve* blendCrvU=0,///<空間次元1のu方向のブレンド曲線(パラメータ、値域ともに0,1) const MGCurve* blendCrvV=0 ///<空間次元1のv方向のブレンド曲線(パラメータ、値域ともに0,1) ); MGSBRep( const MGCurve* edge_crvl[4],///<境界線リスト(vmin,umax,vmax,uminの順,辺番号0,1,2,3の順) const MGSBRepTP&tp, ///<接続面(パラメータ範囲は境界線と同じ) int& error, ///<エラーコード const double* alpha=0 ///1. curvature will be made small. ///& perimeters ///<境界線リスト(vmin,umax,vmax,uminの順,辺番号0,1,2,3の順) ///=0. const MGSBRep& brep2, ///order_u() is 2). ///When direction_adjustment=true, curves[i] directions are adjusted to line up ///to the same direciton as the curves[i-1]'s. ///When direction_adjustment=false, no curves of curves[i] are negated and ///the directions of curves[i] are the direcitons of ribs. MGSBRep(const std::vector& curves,bool direction_adjustment=true); MGSBRep(const MGPvector& curves,bool direction_adjustment=true); ///Destructor /// ~MGSBRep(); ///We can use default destructor. //////////// Operator overload //////////// ///Assignment. ///When the leaf object of this and srf2 are not equal, this assignment ///does nothing. MGSBRep& operator=(const MGGel& gel2); MGSBRep& operator=(const MGSBRep& gel2); /// 曲面の平行移動を行いオブジェクトを生成する。 ///Translation. MGSBRep operator+ ( const MGVector & ) const; /// 曲面の逆方向に平行移動を行いオブジェクトを生成する。 ///Translation. MGSBRep operator- ( const MGVector & ) const; /// 与えられたスケーリングで曲面の変換を行いオブジェクトを生成する。 ///Scaling. MGSBRep operator* (double) const; /// 与えられた変換で曲面の変換を行いオブジェクトを生成する。 ///Matrix transformation. MGSBRep operator* ( const MGMatrix& ) const; /// 与えられた変換で曲面のトランスフォームを行いオブジェクトを生成する。 ///General transformation. MGSBRep operator*( const MGTransf & ) const; ///Object transformation. MGSBRep& operator+=(const MGVector& v); MGSBRep& operator-=(const MGVector& v); MGSBRep& operator*=(double scale); MGSBRep& operator*=(const MGMatrix& mat); MGSBRep& operator*=(const MGTransf& tr); ///Comparison of two objects. bool operator==(const MGSBRep& gel2)const; bool operator<(const MGSBRep& gel2)const; bool operator==(const MGGel& gel2)const; bool operator<(const MGGel& gel2)const; bool operator!=(const MGGel& gel2)const{return !(gel2==(*this));}; bool operator!=(const MGSBRep& gel2)const{return !(gel2==(*this));}; bool operator==(const MGRSBRep& gel2)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_bcoef.length_u();} ///Returns B-Rep Dimension of v. int bdim_v() const{return m_surface_bcoef.length_v();} ///Compute minimum box that includes the linitted parameter range surface. MGBox box_limitted(const MGBox& uvrange) const; ///Changing this object's space dimension. MGSBRep& 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. MGSBRep& 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". MGSBRep* clone() const; ///Construct new surface object by changing ///the original object's space dimension. ///User must delete this copied object by "delete". MGSBRep* 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, ///=4. ///The extrapolation is done so that extrapolating length is "length" ///at the position of the parameter value "param" of the perimeter. MGSBRep& extend( int perimeter, /// rebuild( int how_rebuild=1, ///< intdicates how rebuild be done. ///< =0: no approximation(only parameter change) ///< !=0: approximated by non-rational spline(MGSBRep) with new knot configuration. int parameter_normalization=2, ///< Indicates how the parameter normalization be done: ///< =0: no surface parameter normalization. ///< =1: normalize to u_range=(0., 1.), and v_range=(0.,1.); ///< =2: normalize to make the average length of the 1st derivative along u and v ///< of the base surface is as equal to 1. as possible. double tol=-1., ///=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; friend class MGSurface; friend class MGRSBRep; }; ///Construct 4 perimeters, given at least two of the four. ///Input perimeters may have different knot configuration. In this case they will be updated ///so as to have the same configuration. ///Function's return value indicates which perimeter(s) was missing: /// 10: all of the 4 were input(and knot configurations were updated to have the same). /// 0: only perimeter 0 was missing. /// 1: only perimeter 1 was missing. /// 2: only perimeter 2 was missing. /// 3: only perimeter 3 was missing. /// 4: perimeter 2 and 3 were missing. /// 5: perimeter 1 and 3 were missing. /// 6: perimeter 1 and 2 were missing. /// 7: perimeter 0 and 3 were missing. /// 8: perimeter 0 and 2 were missing. /// 9: perimeter 0 and 1 were missing. /// -2: less than 2 perimeters were provided. int MG_DLL_DECLR construct_perimeters( const MGPvector& peris, ///<境界線リスト(vmin,umax,vmax,uminの順,辺番号0,1,2,3の順). Let i be the perimeter number, ///& perimeters2 ///