📄 ibgoview.cxx
字号:
#include <math.h>#include <stdio.h>extern "C"{#include <GL/gl.h>#include "gltools/glwin.h"}#include "wzoutput.hxx"#include "wzview.hxx"static void ibgOctreeViewCallback(wzWindow win, void *data);static wzInteger no=0,co=0,bo=0,lo=0,po=0,fo=0,eo=0,vo=0;const wzInteger ValueNode = 1;const wzInteger ValueCell = 2;const wzInteger ValueFace = 3;const wzInteger ValueEdge = 4;const wzInteger ValueBnode = 5;const wzInteger ValueVertex = 6;const wzInteger ValueLine = 7;const wzInteger ValuePlane = 8;void ibgOctreeView(wzWindow win, wzIndex i, ibgoctree o, char* name, char* title){ wzwDefineObject(win,i, name[0],name,title,"ibgoview.html#Keys", (wzwCallback)ibgOctreeViewCallback,*(void**)&o); wzwDefineInteger((wzWindow)win,i,ValueNode,GLW_n, "node","set node","ibgoview.html#n", 0,o->nodes.last()); wzwDefineInteger((wzWindow)win,i,ValueCell,GLW_c, "cell","set cell","ibgoview.html#c", 0,o->cells.last()); wzwDefineInteger((wzWindow)win,i,ValueBnode,GLW_b, "boundary node","set boundary node","ibgoview.html#b", 0,o->bnodes.last()); wzwDefineInteger((wzWindow)win,i,ValueLine,GLW_l, "line","set line","ibgoview.html#l", 0,o->lines.last()); wzwDefineInteger((wzWindow)win,i,ValuePlane,GLW_p, "plane","set plane","ibgoview.html#p", 0,o->planes.last()); wzwDefineInteger((wzWindow)win,i,ValueFace,GLW_f, "face","set face","ibgoview.html#f", 0,o->faces.last()); wzwDefineInteger((wzWindow)win,i,ValueEdge,GLW_e, "edge","set edge","ibgoview.html#e", 0,o->edges.last()); wzwDefineInteger((wzWindow)win,i,ValueVertex,GLW_v, "vertex","set vertex","ibgoview.html#v", 0,o->vertices.last()); /* wzwDefineInteger((wzWindow)win,i,Value,GLW_, "","set ","ibgoview.html#", 0,o->.last()); */}void gpo(ibgoctree g){g->po();}void gpn(ibgoctree g, wzIndex n){g->pn(n);}void gpc(ibgoctree g, wzIndex c){g->pc(c);}void gpe(ibgoctree g, wzIndex e){g->pe(e);}void gpf(ibgoctree g, wzIndex f){g->pf(f);}void gpv(ibgoctree g, wzIndex v){g->pv(v);}void gpl(ibgoctree g, wzIndex l){g->pl(l);}void gpp(ibgoctree g, wzIndex p){g->pp(p);}void gpb(ibgoctree g, wzIndex b){g->pb(b);}void gpbc(ibgoctree g, wzIndex e){g->pbc(e);}void ibgOctreeData::po(){ wzOutput& pout = wzOutput::Default; pout("<>D grid with <> nodes")<<GridDim,nodes.last(); pout(", <> bnodes, <> faces, <> lines, <> planes, <> edges")<< bnodes.last(),faces.last(),lines.last(),planes.last(),edges.last(); if(GridDim==3) pout(", <> cells")<<cells.last(); pout("<>")<<"\n";}void ibgOctreeData::pn(ibgiNode n){ int c,no,bn; wzOutput& pout = wzOutput::Default; if(nodes.invalid(n)){ pout("invalid node <> (last is <>)\n")<<n,nodes.last(); return; } pout("node <>: [<>,<>,<>] (region <>)\n")<<n,nX[0][n],nX[1][n],nX[2][n],(wzIndex)nPoint[n].region(); if(GridDim==2){ pout( " < 5> \n" " y| \n" " | \n" " < 5>----< 5>----< %> \n" " | x \n" " | \n" " < 5> \n" ); if(is_defined(no= nUp[1][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nDown[0][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; pout << n; if(is_defined(no= nUp[0][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nDown[1][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; }else if(GridDim==3){ pout( " < 5> \n" " z| \n" " | < 5> \n" " |/ \n" " < 5>----< 5>----< %> \n" " /| x \n" " < 5>| \n" " | \n" " < 5> \n" ); if(is_defined(no= nUp[2][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nUp[1][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nDown[0][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; pout << n; if(is_defined(no= nUp[0][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nDown[1][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; if(is_defined(no= nDown[2][n])) pout<<no; else if(is_outside(no)) pout<<"out"; else pout<<"und"; pout("cells:\n" " < 5>---------< 5> \n" " / | / | \n" " < 5>--------< 5>| \n" " z| | | | \n" " | y| | | \n" " | < 5>------|-< 5> \n" " | / x| / \n" " < 5>--------< 5> \n" ); if((c=nCell[cdirnpp][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirppp][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirnnp][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirpnp][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirnpn][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirppn][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirnnn][n])>0) pout << c; else pout << "out"; if((c=nCell[cdirpnn][n])>0) pout << c; else pout << "out"; } if(nBoundary.allocated() && (bn=nBoundary[n])){ if(bnType[bn] & ibgoHidden) pout("is hidden bnode <>\n")<<bn; else pout("is visible bnode <>\n")<<bn; }}void ibgOctreeData::pe(ibgIndex e){ wzOutput& pout = wzOutput::Default; if(edges.invalid(e)){ pout("invalid edge <> (last is <>)\n")<<e,edges.last(); return; } pout("edge <> [<>,<>,<>] on <> from face <>\n")<< e,ePoint[e].x(),ePoint[e].y(),ePoint[e].z(),ePlane[e],eFace[e]; cogFlag2 f1(ePoint[e],ePointFace[e],ePointDown[e],ePointUp[e]); f1.print();}void ibgOctreeData::pf(ibgIndex f){ wzOutput& pout = wzOutput::Default; char *typ; if(faces.invalid(f)){ pout("invalid face <> (last is <>)\n")<<f,faces.last(); return; } if(fType[f] & ibgoHidden) typ = "hidden"; else typ = "visible"; pout("<> face <> [<>,<>,<>] on <> (neighbours <>,<>)\n")<< typ,f,fPoint[f].x(),fPoint[f].y(),fPoint[f].z(),fLine[f],fUp[f],fDown[f]; cogFlag1 f1(fPoint[f],fPointDown[f],fPointUp[f]); f1.print();}void ibgOctreeData::pl(ibgIndex l){ int bu,bo,nu,no,f; wzOutput& pout = wzOutput::Default; if(lines.invalid(l)){ pout("invalid line <> (last is <>)\n")<<l,lines.last(); return; } pout("line <> from <>(<>) to <>(<>) ")<<l, bu=lNodeDown[l],nu=bnBase[bu], bo=lNodeUp [l],no=bnBase[bo]; pout("([<>,<>,<>] --> [<>,<>,<>])\n") ,nPoint[nu][0],nPoint[nu][1],nPoint[nu][2] ,nPoint[no][0],nPoint[no][1],nPoint[no][2]; if(f=lFaceUp[l]){ if(f==lFaceDown[l]){ pout(" with face <> [<>,<>,<>]\n")<<f ,fPoint[f].x(),fPoint[f].y(),fPoint[f].z(); }else{ pout(" with faces <>,..., <>\n")<<f,lFaceDown[l]; } }}void ibgOctreeData::pp(ibgIndex p){ int c,i; char* type[3]={"yz","xz","xy"}; wzOutput& pout = wzOutput::Default; if(planes.invalid(p)){ pout("invalid plane <> (last is <>)\n")<<p,planes.last(); return; } pout("<>-plane <>\n" " nodes boundary nodes \n" " < 5>---------< 5> < 5>---------< 5> \n" " | | | | \n" " | | | | \n" " | | | | \n" " < 5>---------< 5> < 5>---------< 5> \n")<< type[pDirection(p)],p, bnBase[pNode[2][p]],bnBase[pNode[3][p]], pNode[2][p],pNode[3][p], bnBase[pNode[0][p]],bnBase[pNode[1][p]], pNode[0][p],pNode[1][p]; if(pEdge[p]) pout(" first edge <>\n")<<pEdge[p]; if(PlaneSides){ pout(" <> ")<<"cells:"; for(i=0;i<PlaneSides;i++){ c = pCell[i][p]; if(c<=0) pout( " <> ")<<-c; else pout( " <> (boundary <>) ")<<bcBase[c],c; } pout("<>")<<"\n"; }}void ibgOctreeData::pv(ibgIndex v){ wzOutput& pout = wzOutput::Default; if(vertices.invalid(v)){ pout("invalid vertex <> (last is <>)\n")<<v,vertices.last(); return; }}void ibgOctreeData::pbc(ibgIndex bc){ int c; wzOutput& pout = wzOutput::Default; if(bcells.invalid(bc)){ pout("invalid boundary cell <> (last is <>)\n")<<bc,bcells.last(); return; } pout( "boundary cell <> of <> (<> edges)\n")<<bc,c=bcBase[bc],bcType[bc]; pout( " < 5>---------< 5> \n" " / | / | \n" "< 7> < 5>--------< 5>| \n" " z| | | | \n" " | y| | | \n" " | < 5>------|-< 5> < 7> \n" " | / x| / \n" "< 7> < 5>--------< 5> < 7> \n" " < 7> < 7> \n") ,nBoundary[cNode[cdirnpp][c]],nBoundary[cNode[cdirppp][c]] ,nPoint[cNode[cdirppp][c]].z() ,nBoundary[cNode[cdirnnp][c]],nBoundary[cNode[cdirpnp][c]] ,nBoundary[cNode[cdirnpn][c]],nBoundary[cNode[cdirppn][c]] ,nPoint[cNode[cdirppp][c]].y() ,nPoint[cNode[cdirnnn][c]].z() ,nBoundary[cNode[cdirnnn][c]],nBoundary[cNode[cdirpnn][c]] ,nPoint[cNode[cdirnnn][c]].y() ,nPoint[cNode[cdirnnn][c]].x() ,nPoint[cNode[cdirppp][c]].x();}void ibgOctreeData::pc(ibgiCell c){ wzOutput& pout = wzOutput::Default; if(cells.invalid(c)){ pout("invalid cell <> (last is <>)\n")<<c,cells.last(); return; } pout( "cell <> <> <>\n")<<c; if(cBoundary[c]) pout<<"bcell:",cBoundary[c]; else pout<<"",""; pout( " < 5>---------< 5> \n" " / | / | \n" "< 7> < 5>--------< 5>| \n" " z| | | | \n" " | y| | | \n" " | < 5>------|-< 5> < 7> \n" " | / x | / \n" "< 7> < 5>--------< 5> < 7> \n" " < 7> < 7> \n") ,cNode[cdirnpp][c],cNode[cdirppp][c] ,nPoint[cNode[cdirppp][c]].z() ,cNode[cdirnnp][c],cNode[cdirpnp][c] ,cNode[cdirnpn][c],cNode[cdirppn][c] ,nPoint[cNode[cdirppp][c]].y() ,nPoint[cNode[cdirnnn][c]].z() ,cNode[cdirnnn][c],cNode[cdirpnn][c] ,nPoint[cNode[cdirnnn][c]].y() ,nPoint[cNode[cdirnnn][c]].x() ,nPoint[cNode[cdirppp][c]].x();}void ibgOctreeData::pb(ibgIndex bn){ int o,n; char* typ; wzOutput& pout = wzOutput::Default; if(bnodes.invalid(bn)){ pout("invalid boundary node <> (last is <>)\n")<<bn,bnodes.last(); return; } if(bnType[bn] & ibgoHidden) typ = "hidden"; else typ = "visible"; pout("<> bnode <> of <>, [<>,<>,<>] up: <> <> <> down: <> <> <>\n")<< typ,bn,n=bnBase[bn], nX[0][n],nX[1][n],nX[2][n]; for(o=0;o<3;o++){ if(o>=GridDim) pout<<""; else if(bnUp[o][bn]) pout<<bnUp[o][bn]; else pout<<"und"; } for(o=0;o<3;o++){ if(o>=GridDim) pout<<""; else if(bnDown[o][bn]) pout<<bnDown[o][bn]; else pout<<"und"; } if(GridDim==3){ pout( " planes: | - - | + - | - + | + + |\n" " xy: | <3> | <3> | <3> | <3> |\n" " xz: | <3> | <3> | <3> | <3> |\n" " yz: | <3> | <3> | <3> | <3> |\n"); for(o=0;o<12;o++){ if(bnPlane[o][bn]) pout<<bnPlane[o][bn]; else pout<<"und"; } }else if(GridDim==2){ pout( " planes xy: nn <> pn <> np <> pp <>\n"); for(o=0;o<4;o++){ if(bnPlane[o][bn]) pout<<bnPlane[o][bn]; else pout<<"und"; } }}static void ibgOctreeViewCallback(wzWindow win, void *data){ wzInteger obj = wzwGetObject(win); wzInteger nn,cc,bb,ll,pp,ff,ee,vv; wzIndex mode; ibgoctree oct = * (ibgoctree *) &data; wzwGetInteger(win,obj,ValueNode,&nn); wzwGetInteger(win,obj,ValueCell,&cc); wzwGetInteger(win,obj,ValueBnode,&bb); wzwGetInteger(win,obj,ValueLine,&ll); wzwGetInteger(win,obj,ValuePlane,&pp); wzwGetInteger(win,obj,ValueFace,&ff); wzwGetInteger(win,obj,ValueEdge,&ee); wzwGetInteger(win,obj,ValueVertex,&vv); mode = 0; if(nn!=no){no=nn; oct->pn(nn); mode=ValueNode;} if(cc!=co){co=cc; oct->pc(cc); mode=ValueCell;} if(bb!=bo){bo=bb; oct->pb(bb); mode=ValueBnode;} if(ll!=lo){lo=ll; oct->pl(ll); mode=ValueLine;} if(pp!=po){po=pp; oct->pp(pp); mode=ValuePlane;} if(ff!=fo){fo=ff; oct->pf(ff); mode=ValueFace;} if(ee!=eo){eo=ee; oct->pe(ee); mode=ValueEdge;} if(vv!=vo){vo=vv; oct->pv(vv); mode=ValueVertex;}}static void wzGridInfo(wzWindow win, void *data){ wzInteger obj = wzwGetObject(win); wzInteger nn,cc,bb,ll,pp,ff,ee,vv; ibgoctree oct = * (ibgoctree *) &data; wzwGetInteger(win,obj,ValueNode,&nn); wzwGetInteger(win,obj,ValueCell,&cc); wzwGetInteger(win,obj,ValueBnode,&bb); wzwGetInteger(win,obj,ValueLine,&ll); wzwGetInteger(win,obj,ValuePlane,&pp); wzwGetInteger(win,obj,ValueFace,&ff); wzwGetInteger(win,obj,ValueEdge,&ee); wzwGetInteger(win,obj,ValueVertex,&vv); oct->po(); if(nn){oct->pn(nn);} if(cc){oct->pc(cc);} if(bb){oct->pb(bb);} if(ll){oct->pl(ll);} if(pp){oct->pp(pp);} if(ff){oct->pf(ff);} if(ee){oct->pe(ee);} if(vv){oct->pv(vv);}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -