/// <summary> /// show the mesh in the given image /// </summary> /// <param name="img"></param> public void Show(classimage_mono img) { for (int i = 0; i < features.Count; i++) { Feature feat = (Feature)features[i]; if (featureVisible(feat)) { for (int j = 0; j < feat.triangles.Count; j++) { model_triangle tri = (model_triangle)feat.triangles[j]; if (tri.isVisible()) { tri.Show(img); } } } } }
private void addFeature(Feature feat) { if (!features.Contains(feat)) { int j, i = 0; model_triangle insideTriangle = null; Feature f; // is this feature inside any visible triangle ? while ((i < features.Count) && (insideTriangle == null)) { f = (Feature)features[i]; if (featureVisible(f)) { // examine the triangles to which this feature belongs j = 0; while ((j < f.triangles.Count) && (insideTriangle == null)) { model_triangle tri = (model_triangle)f.triangles[j]; if (tri.isVisible()) { if (tri.isInside(feat)) { insideTriangle = tri; } } j++; } } i++; } // add the feature features.Add(feat); if (insideTriangle != null) { // insert the feature into the triangle update(feat, insideTriangle); } else { // connect the feature to its nearest neighbours if (features.Count > 2) { Feature neighbour1 = null; Feature neighbour2 = null; /* * i = 0; * while (i < features.Count) * { * Feature f1 = (Feature)features[i]; * if (f1 != feat) * { * if (featureVisible(f1)) * { * neighbour1 = f1; * j = i + 1; * while (j < features.Count) * { * Feature f2 = (Feature)features[j]; * if ((f2 != feat) && (f2 != neighbour1)) * { * if (featureVisible(f2)) * { * neighbour2 = f2; * add_triangle(feat, neighbour1, neighbour2); * } * } * j++; * } * } * } * i++; * } */ closest_neighbours(feat, ref neighbour1, ref neighbour2); if ((neighbour1 != null) && (neighbour2 != null)) { add_triangle(feat, neighbour1, neighbour2); } } } } }