void CMapEditor10View::OnFileNew() { // TODO: 在此添加命令处理程序代码 int type; GetNewType(type); if(type&0x0001) NewPnt(); //新建点文件 if(type&0x0002) NewLin(); //新建线文件 if(type&0x0004) NewReg(); //新建区文件 }
int GaFillMesh(GaQuadMesh *mesh, int region, const GpColor *colors, long nColumns) { int value= 0; long iMax= mesh->iMax; long ijMax= iMax*mesh->jMax; GpReal *x= mesh->x, *y= mesh->y; int *ireg= mesh->reg; GpReal qx[4], qy[4]; long ij, row, col; int rgb = colors? gistA.rgb : 0; gistA.rgb = 0; /* Create default region array if none supplied */ if (!ireg) { ireg= NewReg(iMax, ijMax); if (!ireg) return 1; mesh->reg= ireg; } InitializeClip(); /* The only filled area attribute set is the color. */ row= col= 0; if (!colors) gistA.f.color = BG_COLOR; for (ij=iMax+1 ; ij<ijMax ; ij++) { if (EXISTS(ij)) { qx[0]= x[ij-iMax-1]; qy[0]= y[ij-iMax-1]; qx[1]= x[ij-iMax ]; qy[1]= y[ij-iMax ]; qx[2]= x[ij ]; qy[2]= y[ij ]; qx[3]= x[ij -1]; qy[3]= y[ij -1]; if (rgb) { gistA.f.color = P_RGB(colors[3*(row+col)], colors[3*(row+col)+1],colors[3*(row+col)+2]); } else if (colors) { gistA.f.color = colors[row+col]; } gpClipInit= 1; value|= GpFill(4, qx, qy); } col++; if (col==iMax) { col= 0; row+= nColumns; } } if (tmpReg) FreeTmpReg(); return value; }
int GaContourInit(GaQuadMesh *msh, int regn, const GpReal *zz, GpReal lev) /* Find the edges cut by the current contour, remembering z, triangle, and level for the GaContour routine, which actually walks the contour. The z array represents function values on the mesh msh. If triangle!=0, it represents the initial value of the triangulation array, which determines the behavior of GaContour in saddle zones. triangle[j][i]= 1, -1, or 0 as the zone bounded by [j-1][i-1], [j-1][i], [j][i], and [j][i-1] has been triangulated from (-1,-1) to (0,0), from (-1,0) to (0,-1), or has not yet been triangulated. The msh->triangle array is updated by GaContour. If a contour passes through an untriangulated saddle zone, GaContour chooses a triangulation and marks the triangle array approriately, so that subsequent calls to GaContour will never produce intersecting contour curves. */ { long iMax= msh->iMax; long ijMax= iMax*msh->jMax; int *ireg= msh->reg; long ij; /* Create default region array if none supplied */ if (!ireg) { ireg= NewReg(iMax, ijMax); if (!ireg) return 0; msh->reg= ireg; } /* Remember data for GaContour */ mesh= msh; region= regn; z= zz; level= lev; /* Get scratch space to hold edges */ if (GaGetScratchS(2*ijMax)) return 0; iedges= gasScratch; jedges= gasScratch+ijMax; /* Find all points above contour level */ for (ij=0 ; ij<ijMax ; ij++) iedges[ij]= zz[ij]>lev; /* Find j=const edges which cut level plane */ nj= njb= 0; for (ij=1 ; ij<ijMax ; ij++) { if ((iedges[ij]^iedges[ij-1]) && (EXISTS(ij)||EXISTS(ij+iMax))) { if ((ireg[ij]==region) ^ (ireg[ij+iMax]==region)) { jedges[ij]= 2; /* contour enters mesh here */ njb++; } else { jedges[ij]= 1; /* interior edge */ nj++; } } else { jedges[ij]= 0; } } jbegin= 1; /* Find i=const edges which cut level plane */ ni= nib= 0; for (ij=ijMax-1 ; ij>=iMax ; ij--) { if ((iedges[ij]^iedges[ij-iMax]) && (EXISTS(ij)||EXISTS(ij+1))) { if ((ireg[ij]==region) ^ (ireg[ij+1]==region)) { iedges[ij]= 2; /* contour enters mesh here */ nib++; } else { iedges[ij]= 1; /* interior edge */ ni++; } } else { iedges[ij]= 0; } } ibegin= iMax; /* Set keepLeft to a known value (arbitrary but repeatable) */ keepLeft= 0; /* Get scratch space for level curves */ if (GaGetScratchP(ni+nib+nj+njb+1)) return 0; if (tmpReg) FreeTmpReg(); return ni || nib || nj || njb; }
int GaVectors(GaQuadMesh *mesh, int region, const GpReal *u, const GpReal *v, GpReal scale) { int value= 0; long iMax= mesh->iMax; long ijMax= iMax*mesh->jMax; GpReal *x= mesh->x, *y= mesh->y; int *ireg= mesh->reg; int hollow= gistA.vect.hollow; GpReal aspect= gistA.vect.aspect; int etype= gistA.e.type; GpReal xc, yc, dx, dy, vx[3], vy[3]; long ij; GpReal scalx, offx, scaly, offy, dxscale, dyscale; /* Create default region array if none supplied */ if (!ireg) { ireg= NewReg(iMax, ijMax); if (!ireg) return 1; mesh->reg= ireg; } /* Save transform map, set up for transform here */ SwapNormMap(&scalx, &offx, &scaly, &offy); dxscale= 0.3333333333*scale*scalx; dyscale= 0.3333333333*scale*scaly; aspect*= 3.0; if (!hollow) gistA.e.type= L_NONE; InitializeClip(); for (ij=0 ; ij<ijMax ; ij++) { if (EXISTS(ij) || EXISTS(ij+1) || EXISTS(ij+1+iMax) || EXISTS(ij+iMax)) { xc= scalx*x[ij]+offx; yc= scaly*y[ij]+offy; dx= dxscale*u[ij]; dy= dyscale*v[ij]; /* Dart has centroid at (xc,yc), length 3*(dx,dy), given aspect */ vx[1]= xc + 2.0*dx; vy[1]= yc + 2.0*dy; vx[0]= xc - dx + aspect*dy; vx[2]= xc - dx - aspect*dy; vy[0]= yc - dy - aspect*dx; vy[2]= yc - dy + aspect*dx; if (hollow) { gpCloseNext= gpClipInit= 1; value|= GpLines(3, vx, vy); } else { gpClipInit= 1; value|= GpFill(3, vx, vy); } } } if (!hollow) gistA.e.type= etype; if (tmpReg) FreeTmpReg(); SwapMapNorm(); return value; }
int GaMesh(GaQuadMesh *mesh, int region, int boundary, int inhibit) { int value= 0; long iMax= mesh->iMax, jMax= mesh->jMax; long ijMax= iMax*jMax; GpReal *x= mesh->x, *y= mesh->y; int *ireg= mesh->reg; long i, j, k; int (*MeshRow)(long, long, int*, int, long*, long*); int (*MeshCol)(long, long, int*, int, GpReal*, GpReal*, long*, long*); /* Load appropriate edge existence scanners */ if (!boundary) { if (region==0) { /* draw entire mesh */ MeshRow= &MeshRowF; MeshCol= &MeshColF; } else { /* draw single region */ MeshRow= &MeshRowR; MeshCol= &MeshColR; } } else { /* draw region boundary */ MeshRow= &MeshRowB; MeshCol= &MeshColB; } /* Be sure there is enough scratch space to gather a column */ if (!(inhibit&2) && GaGetScratchP(jMax)) return 1; /* Create default region array if none supplied */ if (!ireg) { ireg= NewReg(iMax, ijMax); if (!ireg) return 1; mesh->reg= ireg; } /* Draw rows */ if (!(inhibit&1)) { for (i=0 ; i<ijMax ; /* i incremented in MeshRow */) { if (MeshRow(iMax, ijMax, ireg, region, &i, &j)) break; value|= GpLines(i-j, x+j, y+j); } } /* Draw columns */ if (!(inhibit&2)) { for (i=0 ; i<iMax ; i++) { j= i; for (;;) { if (MeshCol(iMax, ijMax, ireg, region, x, y, &j, &k)) break; value|= GpLines(k, gaxScratch, gayScratch); if (j>=ijMax) break; } } } if (tmpReg) FreeTmpReg(); return value; }