/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #include "MGCLStdAfx.h" #include "mg/Point.h" #include "mg/Ellipse.h" #include "mg/Straight.h" #include "mg/Straight.h" #include "mg/LBRep.h" #include "mg/RLBRep.h" #include "mg/TrimmedCurve.h" #include "mg/CompositeCurve.h" #include "mg/SurfCurve.h" #include "mg/Plane.h" #include "mg/MGStl.h" #include "mgGL/VBO.h" #include "cskernel/bler.h" #include "cskernel/bpval2.h" #include "cskernel/bk2fli.h" #include "cskernel/Blcbpn.h" #if defined(_DEBUG) #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //Implements the drawWire functions of all the classes. //Draw 3D point(vertex) in world coordinates. //The object is converted to point(s) and is drawn. //This is valid only for topology objects or MGPoint. void MGGeometry::draw3DVertex(mgVBO& vbo)const{;} //Draw 3D point(vertex) in world coordinates. //The object is converted to point(s) and is drawn. //This is valid only for topology objects or MGPoint. void MGPoint::draw3DVertex( mgVBO& vbo ) const{vbo.drawPoint(ref(0), ref(1), ref(2));} void MGPoint::drawWire( mgVBO& vbo, int line_density //line density to draw a surface in wire mode. )const{ vbo.drawPoint(ref(0), ref(1), ref(2)); } #define MINIMUMANGLE 0.392 void MGEllipse::drawSE( mgVBO& vbo, double t0, //Start parameter value of the curve. double t1 //End parameter value of the curve. //Draw will be performed from t0 to t1. )const{ t0=gp_to_radian(t0); t1=gp_to_radian(t1); if(t1t[n]) t1=t[n]; MGVector P=eval(t0); vbo.Vertex3d(P[0],P[1],P[2]); int i0=t.locate(t0), i1=t.locate(t1); const MGBPointSeq& bp=line_bcoef(); for(int i=i0; ite) t1=te; m_curve->drawSE(vbo,t0,t1); } ////////////////////////////////////////////// void MGCompositeCurve::drawSE( mgVBO& vbo, double t0, //Start parameter value of the curve. double t1 //End parameter value of the curve. //Draw will be performed from t0 to t1. )const{ if(m_composite.size()==0) return; double s0,s1; if(t0>t1){ s0=t1; s1=t0;} else{ s0=t0; s1=t1;} int i0=find(s0), i1=find(s1); if(i0==i1){ m_composite[i0]->drawSE(vbo,s0,s1); }else{ m_composite[i0]->drawSE(vbo,s0,m_composite[i0]->param_e()); for(int i=i0+1; idrawSE(vbo, m_composite[i]->param_s(),m_composite[i]->param_e()); m_composite[i1]->drawSE(vbo, m_composite[i1]->param_s(), s1); } } #define NDIVIDE 3 #define NMAX 150 void MGCurve::drawSE( mgVBO& vbo, double t0, //Start parameter value of the curve. double t1 //End parameter value of the curve. //Draw will be performed from t0 to t1. )const{ int i; double s0,s1,s[NDIVIDE+1]; if(t0>t1){ s0=t1; s1=t0;} else{ s0=t0; s1=t1;} s[0]=range(s0); s[NDIVIDE]=range(s1); double ds=(s[NDIVIDE]-s[0])/NDIVIDE; for(i=1; ivlen2) vlen=vlen1+vlen2; else vlen=vlen1+vlen0; }else{ if(vlen0<=vlen2) vlen=vlen2+vlen1; else if(vlen1>vlen2) vlen=vlen0+vlen2; else vlen=vlen0+vlen1; } const MGDrawParam& para=mgVBOElement::getDrawParam(); double span_length=para.span_length_wire(); vlen*=.5; double span=(s1-s0); double df=vlen*span; int n=int(df/span_length); n+=2; if(n>NMAX) n=NMAX; double dt=span/double(n); double t=s0; for(int i=1; i3) sd=3; double t0=t[k-1], t1=t[n]; if(tstart>=tend){ tstart=t0; tend=t1; }else{ if(tstartt1) tend=t1; } if(t0>=t1) return; // ******* CONVERT TO PP AND DRAW EACH LINE ***** int np1=n+1, is1,is2; is1=bk2fli_(np1, t, tstart); is2=bk2fli_(np1, t, tend); while(t[is2-1]==tend) is2--; // ***** DRAW LINE FROM RW(I) TO RW(I+1) // *** MOVE TO THE FIRST POSITION int i; for(i=0;i=te) continue; if(j==is1) ts=tnow=tstart; if(j==is2) te=tend; // ...CONVERT THE ONE SPAN TO PP-REP int jmk=j-k; int lpp; double brk[2]; blcbpn_(k,k,t+jmk,rcoef+jmk,irc,sd,c1,wk1p3k,brk,wk1,&lpp); double tm=(ts+te)*0.5; double vlen=0.; for(i=0;i=tend){ tstart=t0; tend=t1; }else{ if(tstartt1) tend=t1; } // ******* CONVERT TO PP AND DRAW EACH LINE ***** int is1, is2; int np1=n+1; is1=bk2fli_(np1, t, tstart); is2=bk2fli_(np1, t, tend); while(t[is2-1]==tend) is2--; int i; int ncd=sdim(); int sd=ncd; if(sd>3) sd=3; // ***** DRAW LINE FROM RW(I) TO RW(I+1) // *** MOVE TO THE FIRST POSITION double w=bler_(k,n,t,rcoef+ncd*irc,tstart,c0); for(i=0;i=te) continue; if(j==is1) ts=tnow=tstart; if(j==is2) te=tend; // ...CONVERT THE ONE SPAN TO PP-REP int jmk=j-k; int lpp; double brk[2]; blcbpn_(k,k,&t[jmk],rcoef+jmk,irc,ncdp1,c1,scratch,brk,pcoef,&lpp); double tm=(ts+te)*0.5; double vlen=0.; for(i=0;iBegin(GL_LINE_STRIP,m_target); m_vbo->Vertex3d(v1[0], v1[1], v1[2]); m_vbo->Vertex3d(start[0], start[1], start[2]); m_vbo->Vertex3d(v2[0], v2[1], v2[2]); m_vbo->End(); m_vbo->Begin(GL_LINE_STRIP,m_target); m_vbo->Vertex3d(start[0], start[1], start[2]); m_vbo->Vertex3d(end[0], end[1], end[2]); m_vbo->End(); MGVector tmp(end - start); v1 += tmp; v2 += tmp; m_vbo->Begin(GL_LINE_STRIP,m_target); m_vbo->Vertex3d(v1[0], v1[1], v1[2]); m_vbo->Vertex3d(end[0], end[1], end[2]); m_vbo->Vertex3d(v2[0], v2[1], v2[2]); m_vbo->End(); }; mgVBO* m_vbo; const MGVector& m_u; const MGVector& m_v; mgVBO::ELEMENT_TARGET m_target; }; MGVector u,v; get_uv_display_vector(u,v); const MGPosition& cen = center(); vbo.Begin(GL_LINE_STRIP,target); MGVector V(cen + u + v); // (L, L). vbo.Vertex3d(V[0], V[1], V[2]); V -= 2 * u; vbo.Vertex3d(V[0], V[1], V[2]); // (-L, L) V -= 2 * v; vbo.Vertex3d(V[0], V[1], V[2]); // (-L, -L) V += 2 * u; vbo.Vertex3d(V[0], V[1], V[2]); // (L, -L) V += 2 * v; vbo.Vertex3d(V[0], V[1], V[2]); // (L, L) vbo.End(); const double ratio = 4.11; u /= ratio; v /= ratio; DrawCross da(&vbo,u, v,target); da(cen-3*u, cen+3*u, true); da(cen-3*v, cen+3*v, false); }