/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #include "MGCLStdAfx.h" #include "mg/Pvector.h" #include "mg/SPointSeq.h" #include "mg/LBRepEndC.h" #include "mg/SBRepEndC.h" #include "mg/SBRepTP.h" #include "mg/SBRep.h" #include "mg/BSumSurf.h" #include "mg/Tolerance.h" #include "cskernel/blg4sp2.h" using namespace std; #if defined(_DEBUG) #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //境界線、ブレンド関数、接続面を与え、対辺が同じノットベクトルのスプライン曲線 //になるように再作成して、点列、ノットベクトル、データポイントを求め、境界線の //パラメータにあわせてあった接続面をリビルドした後のパラメータに変更する。 //境界線はC1連続であり、vmin,umax,vmax,uminの順で、vmin,vmaxの向きをuminから //umaxの方向にumin,umaxの向きをvminからvmaxの方向になっているものとする。 //境界線のノットベクトルをあわせるときの誤差はline_zero()を使用している。 void rebuild_curve( const MGCurve* edge_crvl[4], //境界線リスト(vmin,umax,vmax,uminの順) MGSBRepTP& tp, //接続面(パラメータ範囲は境界線と同じ) MGPvector& perimeters ); void get_all_derivatives( const MGPvector& perimeters,//perimeters. const MGSBRep& surf, //Original surface. const MGSBRepTP& tp, //接続面(パラメータ範囲は境界線と同じ) MGPvector& derivatives //array of derivatives[4], must have size 4. ){ int sd=surf.sdim(); double azero=MGTolerance::angle_zero()*.05; const MGKnotVector& tu=surf.knot_vector_u(); const MGKnotVector& tv=surf.knot_vector_v(); int m; ///////////perimeter 0 and 2. int nu=surf.bdim_u();int num1=nu-1; MGNDDArray utau; utau.update_from_knot(tu); MGBPointSeq deris_u(nu,sd); MGBPointSeq dpu(nu,1); double v[2]={tv.param_s(),tv.param_e()}; for(m=0; m<2; m++){//for perimeter 0 and 2. int perim=m*2; if(tp.specified(perim)){ double vm=v[m]; deris_u.store_at(0,perimeters[3]->eval(vm,1)); for(int i=1; ieval(vm,1)); dpu(0,0)*=.2;dpu(num1,0)*=.2;//Make precise at the ends. dpu(1,0)*=.4;dpu(nu-2,0)*=.4;//Make precise at the ends. derivatives.reset(perim,new MGLBRep(utau,deris_u,tu));//***NON Smoothing version/// //std::cout<<"driv at perim="<eval(um,1)); for(int j=1; jeval(um,1)); derivatives.reset(perim,new MGLBRep(vtau,deris_v,tv)); //std::cout<<"driv at perim="<param_e(),ti=derivatives[i]->param_s(); if(im1>=2) tim1=derivatives[im1]->param_s(); if(i>=2) ti=derivatives[i]->param_e(); MGVector deriim1=derivatives[im1]->eval(tim1,1), derii=derivatives[i]->eval(ti,1); twist[i]=(deriim1+derii)*.5; //std::cout<& perimeters, const MGPvector& derivatives, MGPvector& perimeters2, MGPvector& derivatives2 //array of derivatives[4], must have size 4. ){ perimeters2.resize(4); derivatives2.resize(4); int m; ///////////perimeter 0 and 2. const MGLBRep* deriS=derivatives[3]; const MGLBRep* deriE=derivatives[1]; for(m=0; m<=2; m+=2){//for perimeter 0 and 2. perimeters2.reset(m, get_perriderisub(*(perimeters[m]),deriS,deriE)); if(derivatives[m]){ derivatives2.reset(m, get_perriderisub(*(derivatives[m]),deriS,deriE)); }else derivatives2.reset(m); } ////////// perimeter 1 and 3. deriS=derivatives[0]; deriE=derivatives[2]; for(m=1; m<=3; m+=2){//for perimeter 1 and 3. perimeters2.reset(m, get_perriderisub(*(perimeters[m]),deriS,deriE)); if(derivatives[m]){ derivatives2.reset(m, get_perriderisub(*(derivatives[m]),deriS,deriE)); }else derivatives2.reset(m); } } MGLBRep get1deri_of_peri( int peri, //perimeter number const MGSBRep& surf ){ bool alongu=true; if(peri%2) alongu=false; const MGKnotVector* t; const MGKnotVector* t_other; if(alongu){ t=&(surf.knot_vector_u()); t_other=&(surf.knot_vector_v()); }else{ t=&(surf.knot_vector_v()); t_other=&(surf.knot_vector_u()); } double t0=t_other->param_s(); if(peri==1 || peri==2) t0=t_other->param_e(); int len=t->bdim(); MGBPointSeq dbp(len,3); const MGSPointSeq& spoint=surf.surface_bcoef(); for(int j=0; j& perimeters, const MGPvector& derivatives ){ int ncd=3; int ids,ide,otherS, otherE; if(udire){ ids=0; ide=2; otherS=3; otherE=1; }else{ ids=3; ide=1; otherS=0; otherE=2; } //Herafter, u and v directions are temporal. When udire==true, u is v, and v is u. //Construct u-direction data point and knot vector. double u0=perimeters[otherS]->param_s(),u1=perimeters[otherS]->param_e(); MGENDCOND ecu0=MGENDC_1D, ecu1=MGENDC_1D; int lenu=2; if(!derivatives[ids]) ecu0=MGENDC_NO; else lenu++; if(!derivatives[ide]) ecu1=MGENDC_NO; else lenu++; int orderu=4; if(orderu>lenu) orderu=lenu; MGNDDArray utau(lenu); size_t i=0; utau((int)i++)=u0; if(ecu0==MGENDC_1D) utau((int)i++)=u0; if(ecu1==MGENDC_1D) utau((int)i++)=u1; utau((int)i++)=u1; MGKnotVector tu(utau,orderu); //Construct v-direction data point and knot vector. const MGKnotVector& tv=perimeters[ids]->knot_vector(); MGNDDArray vtau(3,tv.bdim()-2,tv); if(!derivatives[otherS]) vtau.add_data((vtau(0)+vtau(1))*.5); if(!derivatives[otherE]){ int nvtau2=vtau.length(); vtau.add_data((vtau(nvtau2-1)+vtau(nvtau2-2))*.5); } //std::cout< lines; int error=2; for(int j=0; jeval(vtauj)); if(ecu0==MGENDC_1D){ bp.store_at(1,derivatives[ids]->eval(vtauj)); MGVector der=derivatives[ids]->eval(vtauj); //std::cout<exchange_uv(); delete[] q; delete[] wk; size_t nlines=lines.size(); for(i=0; i& lines, const MGLBRep* deriS, const MGLBRep* deriE ):MGSurface(){ int i,j,k; const int ncd=3; m_uknot=lines[0]->knot_vector(); MGENDCOND ec0=MGENDC_1D, ec1=MGENDC_1D; if(!deriS) ec0=MGENDC_NO; if(!deriE) ec1=MGENDC_NO; // Compute b-rep dimension along v in lenv. //v=min and max condition. int lenu=m_uknot.bdim(), lenv1,lenv; lenv1=lenv=(int)lines.size(); int ivs=0; if(ec0==MGENDC_1D){lenv+=1; ivs=1;} if(ec1==MGENDC_1D) lenv+=1; int orderv=4; if(orderv>lenv) orderv=lenv; MGSPointSeq surface_bcoef(lenv,lenu,ncd);//Temporal spoint seq. // Prepare data point ordinate. // 1. Copy original data. int js; for(j=0; jline_bcoef(); for(k=0; kline_bcoef(); for(k=0; kline_bcoef(); for(k=0; kknot_vector(); MGKnotVector& tv=perimeters[1]->knot_vector(); MGSBRep ruled0(true,perimeters);//std::cout< derivatives(4); get_all_derivatives(perimeters,ruled01,tp2,derivatives); //std::cout<eval(t2,1)<eval_gap(*edge_crvl[0],0, uv);///////////// //cur_gap = g1->eval_gap(*edge_crvl[2],2, uv);///////////// //std::cout<