Ejemplo n.º 1
0
		/// <summary>
		/// Normalize the region specification.
		/// The text interface allow a region to be specified in terms of
		/// rectangles, circles, polygons, convex hulls of points, etc.
		/// A so called <i>normal form</i> is a string that contains only
		/// a union of convexes.
		/// </summary>
		/// <param name="textSpec">Legacy style descritption of region</param>
		/// <returns>A specification consisting of a union of Convexes</returns>
		public static string NormalForm ( String textSpec ) {
			Region reg = new Region();
			Parser par = new Parser();
			par.input = textSpec;
			par.buildto(reg);
			if (par.parse() == false) {
				return null;
			}
			reg.normalize();
			return reg.ToString();
		}
Ejemplo n.º 2
0
		public static string NormalForm(String textSpec, out String errmsg) {
			Region reg = new Region();
			Parser par = new Parser();
			par.input = textSpec;
			par.buildto(reg);
			if (par.parse() == false) {
				errmsg = par.errmsg();
				return null;
			} else {
				errmsg = "ok";
			}
			reg.normalize();
			return reg.ToString();
		}
Ejemplo n.º 3
0
		public static Double[,] CoverToHalfspaces ( String textSpec ) {
			Region reg = new Region ( );
			Parser par = new Parser ( );
			double cid, hid;
			int rowcount, row;
			par.input = textSpec;
			par.buildto ( reg );
			if ( par. parse ( ) == false ) {
				return null;
			}
			reg.normalize ( );
			

			rowcount = 0;
			for (int i = 0; i < reg.Count; i++) {
				rowcount += reg.getNth(i).Count;
			}
			row = 0;
			Double[,] result = new Double[rowcount, 6];
			cid = 0.0;
			for (int i = 0; i < reg.Count; i++) {
				Convex con = reg.getNth (i);
				hid = 0.0;
				for (int j=0; j< con.Count; j++ ) {
					Halfspace h = con.hsAt (j);
					result[row, 0] = cid;
					result[row, 1] = hid;
					result[row, 2] = h.sv.x;
					result[row, 3] = h.sv.y;
					result[row, 4] = h.sv.z;
					result[row, 5] = h.d;
					hid += 1.0;
					row++;
				}
				cid += 1.0;
			}
			return result;
		}