//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: virtual NetgenGeometry *LoadFromMeshFile(istream & ist) const public virtual NetgenGeometry LoadFromMeshFile(istream ist) { for (int i = 0; i < Size(); i++) { NetgenGeometry hgeom = this[i].LoadFromMeshFile(ist); if (hgeom != null) { return(hgeom); } } return(null); }
private Vector4[] CreateFileData(out float minx, out float miny, out float minz, out float maxx, out float maxy, out float maxz) { //string file = "../../test/data/1.2-with-color.las"; string file = "../../test/data/hobu.las"; Vector4 red = new Vector4(1, 0, 0, 1); Vector4 green = new Vector4(0, 1, 0, 1); Vector4 blue = new Vector4(0, 0, 1, 1); List <Vector4> points = new List <Vector4>(); istream istr = Utils.openFile(file); m_reader = new LiblasReader(istr); Stage stage = m_reader; { int np = (int)m_reader.getNumPoints(); if (np > 100000) { int step = np / 100000; m_filter = new DecimationFilter(m_reader, step); stage = m_filter; } } Header header = stage.getHeader(); Bounds_double bounds = header.getBounds(); minx = (float)bounds.getMinimum(0); miny = (float)bounds.getMinimum(1); minz = (float)bounds.getMinimum(2); maxx = (float)bounds.getMaximum(0); maxy = (float)bounds.getMaximum(1); maxz = (float)bounds.getMaximum(2); // 1.2-with-color //minx 635619.9f //miny 848899.7f //minz 406.59f //maxx 638982.563 //maxy 853535.438 //maxz 586.38 ulong numPoints = stage.getNumPoints(); //numPoints = Math.Min(numPoints, 100000); Schema schema = stage.getHeader().getSchema(); SchemaLayout layout = new SchemaLayout(schema); PointData data = new PointData(layout, (uint)numPoints); uint numRead = stage.read(data); uint offsetX = (uint)schema.getDimensionIndex(Dimension.Field.Field_X); uint offsetY = (uint)schema.getDimensionIndex(Dimension.Field.Field_Y); uint offsetZ = (uint)schema.getDimensionIndex(Dimension.Field.Field_Z); uint offsetR = (uint)schema.getDimensionIndex(Dimension.Field.Field_Red); uint offsetG = (uint)schema.getDimensionIndex(Dimension.Field.Field_Green); uint offsetBG = (uint)schema.getDimensionIndex(Dimension.Field.Field_Blue); for (uint index = 0; index < numRead; index++) { Int32 xraw = data.getField_Int32(index, offsetX); Int32 yraw = data.getField_Int32(index, offsetY); Int32 zraw = data.getField_Int32(index, offsetZ); float x = (float)schema.getDimension(offsetX).getNumericValue_Int32(xraw); float y = (float)schema.getDimension(offsetY).getNumericValue_Int32(yraw); float z = (float)schema.getDimension(offsetZ).getNumericValue_Int32(zraw); if (index == 0) { minx = maxx = x; miny = maxy = y; minz = maxz = z; } else { minx = Math.Min(x, minx); miny = Math.Min(y, miny); minz = Math.Min(z, minz); maxx = Math.Max(x, maxx); maxy = Math.Max(y, maxy); maxz = Math.Max(z, maxz); } UInt16 r = data.getField_UInt16(index, offsetX); UInt16 g = data.getField_UInt16(index, offsetY); UInt16 b = data.getField_UInt16(index, offsetZ); points.Add(new Vector4(x, y, z, 1)); float rf = (float)r / 65535.0f; float gf = (float)g / 65535.0f; float bf = (float)b / 65535.0f; points.Add(new Vector4(rf, gf, bf, 1)); //points.Add(blue); } Utils.closeFile(istr); return(points.ToArray()); }
//C++ TO C# CONVERTER WARNING: 'const' methods are not available in C#: //ORIGINAL LINE: virtual NetgenGeometry * LoadFromMeshFile(istream &) const public virtual NetgenGeometry LoadFromMeshFile(istream UnnamedParameter) { return(null); }
//C++ TO C# CONVERTER WARNING: The original C++ declaration of the following method implementation was not found: public void LoadRule(istream ist) { string buf = new string(new char[256]); char ch; Point2d p = new Point2d(); INDEX_2 lin = new INDEX_2(); int i; int j; DenseMatrix tempoldutonewu = new DenseMatrix(20, 20); DenseMatrix tempoldutofreearea = new DenseMatrix(20, 20); DenseMatrix tempoldutofreearealimit = new DenseMatrix(20, 20); tempoldutonewu = 0; tempoldutofreearea = 0; tempoldutofreearealimit = 0; noldp = 0; noldl = 0; ist.get(buf, sizeof(char), '"'); ist.get(ch); ist.get(buf, sizeof(char), '"'); ist.get(ch); // if(name != NULL) name = null; name = new char[buf.Length + 1]; name = buf; //(*testout) << "name " << name << endl; // (*mycout) << "Rule " << name << " found." << endl; do { ist >> buf; //(*testout) << "buf " << buf << endl; if (string.Compare(buf, "quality") == 0) { ist >> quality; } else if (string.Compare(buf, "mappoints") == 0) { ist >> ch; while (ch == '(') { ist >> p.X(); ist >> ch; // ',' ist >> p.Y(); ist >> ch; // ')' points.Append(p); noldp++; tolerances.SetSize(noldp); tolerances.Elem(noldp).f1 = 1.0; tolerances.Elem(noldp).f2 = 0; tolerances.Elem(noldp).f3 = 1.0; ist >> ch; while (ch != ';') { if (ch == '{') { ist >> tolerances.Elem(noldp).f1; ist >> ch; // ',' ist >> tolerances.Elem(noldp).f2; ist >> ch; // ',' ist >> tolerances.Elem(noldp).f3; ist >> ch; // '}' } else if (ch == 'd') { // delpoints.Append (noldp); ist >> ch; // 'e' ist >> ch; // 'l' } ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "maplines") == 0) { ist >> ch; while (ch == '(') { ist >> lin.I1(); ist >> ch; // ',' ist >> lin.I2(); ist >> ch; // ')' //(*testout) << "read line " << lin.I1() << " " << lin.I2() << endl; lines.Append(lin); linevecs.Append(points.Get(lin.I2()) - points.Get(lin.I1())); noldl++; linetolerances.SetSize(noldl); linetolerances.Elem(noldl).f1 = 0; linetolerances.Elem(noldl).f2 = 0; linetolerances.Elem(noldl).f3 = 0; //(*testout) << "mapl1" << endl; ist >> ch; while (ch != ';') { //(*testout) << "working on character \""<<ch<<"\""<< endl; if (ch == '{') { ist >> linetolerances.Elem(noldl).f1; ist >> ch; // ',' ist >> linetolerances.Elem(noldl).f2; ist >> ch; // ',' ist >> linetolerances.Elem(noldl).f3; ist >> ch; // '}' } else if (ch == 'd') { dellines.Append(noldl); ist >> ch; // 'e' ist >> ch; // 'l' //(*testout) << "read del" << endl; } ist >> ch; //(*testout) << "read character \""<<ch<<"\""<< endl; } ist >> ch; //(*testout) << "read next character \""<<ch<<"\""<< endl; } ist.putback(ch); } else if (string.Compare(buf, "newpoints") == 0) { ist >> ch; while (ch == '(') { ist >> p.X(); ist >> ch; // ',' ist >> p.Y(); ist >> ch; // ')' points.Append(p); ist >> ch; while (ch != ';') { if (ch == '{') { LoadMatrixLine(ist, tempoldutonewu.functorMethod, 2 * (points.Size() - noldp) - 1); ist >> ch; // '{' LoadMatrixLine(ist, tempoldutonewu.functorMethod, 2 * (points.Size() - noldp)); } ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "newlines") == 0) { ist >> ch; while (ch == '(') { ist >> lin.I1(); ist >> ch; // ',' ist >> lin.I2(); ist >> ch; // ')' lines.Append(lin); linevecs.Append(points.Get(lin.I2()) - points.Get(lin.I1())); ist >> ch; while (ch != ';') { ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "freearea") == 0) { ist >> ch; while (ch == '(') { ist >> p.X(); ist >> ch; // ',' ist >> p.Y(); ist >> ch; // ')' freezone.Append(p); freezonelimit.Append(p); ist >> ch; while (ch != ';') { if (ch == '{') { LoadMatrixLine(ist, tempoldutofreearea.functorMethod, 2 * freezone.Size() - 1); ist >> ch; // '{' LoadMatrixLine(ist, tempoldutofreearea.functorMethod, 2 * freezone.Size()); } ist >> ch; } ist >> ch; } for (i = 1; i <= tempoldutofreearealimit.Height(); i++) { for (j = 1; j <= tempoldutofreearealimit.Width(); j++) { tempoldutofreearealimit.Elem(i, j) = tempoldutofreearea.Elem(i, j); } } ist.putback(ch); } else if (string.Compare(buf, "freearea2") == 0) { ist >> ch; int freepi = 0; tempoldutofreearealimit = 0; while (ch == '(') { freepi++; ist >> p.X(); ist >> ch; // ',' ist >> p.Y(); ist >> ch; // ')' freezonelimit.Elem(freepi) = p; ist >> ch; while (ch != ';') { if (ch == '{') { LoadMatrixLine(ist, tempoldutofreearealimit.functorMethod, 2 * freepi - 1); ist >> ch; // '{' LoadMatrixLine(ist, tempoldutofreearealimit.functorMethod, 2 * freepi); } ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "elements") == 0) { ist >> ch; while (ch == '(') { elements.Append(new Element2d(ELEMENT_TYPE.TRIG)); ist >> elements.Last().PNum(1); ist >> ch; // ',' if (ch == DefineConstants.COMMASIGN) { ist >> elements.Last().PNum(2); ist >> ch; // ',' } if (ch == DefineConstants.COMMASIGN) { ist >> elements.Last().PNum(3); ist >> ch; // ',' } if (ch == DefineConstants.COMMASIGN) { elements.Last().SetType(ELEMENT_TYPE.QUAD); ist >> elements.Last().PNum(4); ist >> ch; // ',' // const Element2d & el = elements.Last(); /* * orientations.Append (threeint(el.PNum(1), el.PNum(2), el.PNum(3))); * orientations.Append (threeint(el.PNum(2), el.PNum(3), el.PNum(4))); * orientations.Append (threeint(el.PNum(3), el.PNum(4), el.PNum(1))); * orientations.Append (threeint(el.PNum(4), el.PNum(1), el.PNum(2))); */ } ist >> ch; while (ch != ';') { ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "orientations") == 0) { ist >> ch; while (ch == '(') { // threeint a = threeint(); orientations.Append(new threeint()); ist >> orientations.Last().i1; ist >> ch; // ',' ist >> orientations.Last().i2; ist >> ch; // ',' ist >> orientations.Last().i3; ist >> ch; // ',' ist >> ch; while (ch != ';') { ist >> ch; } ist >> ch; } ist.putback(ch); } else if (string.Compare(buf, "endrule") != 0) { PrintSysError("Parser error, unknown token ", buf); } } while (!ist.eof() && string.Compare(buf, "endrule") != 0); oldutonewu.SetSize(2 * (points.Size() - noldp), 2 * noldp); oldutofreearea.SetSize(2 * freezone.Size(), 2 * noldp); oldutofreearealimit.SetSize(2 * freezone.Size(), 2 * noldp); for (i = 1; i <= oldutonewu.Height(); i++) { for (j = 1; j <= oldutonewu.Width(); j++) { oldutonewu.Elem(i, j) = tempoldutonewu.Elem(i, j); } } for (i = 1; i <= oldutofreearea.Height(); i++) { for (j = 1; j <= oldutofreearea.Width(); j++) { oldutofreearea.Elem(i, j) = tempoldutofreearea.Elem(i, j); } } for (i = 1; i <= oldutofreearea.Height(); i++) { for (j = 1; j <= oldutofreearea.Width(); j++) { oldutofreearealimit.Elem(i, j) = tempoldutofreearealimit.Elem(i, j); } } freesetinequ.SetSize(freezone.Size()); { char ok; int minn; Array <int> pnearness = new Array <int>(noldp); for (i = 1; i <= pnearness.Size(); i++) { pnearness.Elem(i) = 1000; } for (j = 1; j <= 2; j++) { pnearness.Elem(GetPointNr(1, j)) = 0; } do { ok = 1; for (i = 1; i <= noldl; i++) { minn = 1000; for (j = 1; j <= 2; j++) { minn = min2(minn, pnearness.Get(GetPointNr(i, j))); } for (j = 1; j <= 2; j++) { if (pnearness.Get(GetPointNr(i, j)) > minn + 1) { ok = 0; pnearness.Elem(GetPointNr(i, j)) = minn + 1; } } } } while (!ok); lnearness.SetSize(noldl); for (i = 1; i <= noldl; i++) { lnearness.Elem(i) = 0; for (j = 1; j <= 2; j++) { lnearness.Elem(i) += pnearness.Get(GetPointNr(i, j)); } } } oldutofreearea_i.SetSize(10); freezone_i.SetSize(10); for (i = 0; i < oldutofreearea_i.Size(); i++) { double lam1 = 1.0 / (i + 1); oldutofreearea_i[i] = new DenseMatrix(oldutofreearea.Height(), oldutofreearea.Width()); DenseMatrix mati = *oldutofreearea_i[i]; for (j = 0; j < oldutofreearea.Height(); j++) { for (int k = 0; k < oldutofreearea.Width(); k++) { mati.functorMethod(j, k) = lam1 * oldutofreearea(j, k) + (1 - lam1) * oldutofreearealimit(j, k); } } freezone_i[i] = new Array <Point2d> (freezone.Size()); Array <Point2d> fzi = *freezone_i[i]; for (int j = 0; j < freezone.Size(); j++) { fzi[j] = freezonelimit[j] + lam1 * (freezone[j] - freezonelimit[j]); } } }