public Mesh(List <Vector3Float> v, FaceList f) { Vertices.Clear(); Vertices.AddRange(v); Faces.Clear(); Faces.AddRange(f); }
//------------------------------------------------------------------------ public Faces GetFaces(Vector3D pt) { Faces faces = new Faces(); int sign = (int)Math3D.GetSign(_plane.GetDistanceToPlane(pt)); if (sign == 0) { foreach (Face face in _faces) { if (face.IsContained(pt)) { faces.Add(face); } } if (_positiveChild != null) { faces.AddRange(_positiveChild.GetFaces(pt)); } if (_negativeChild != null) { faces.AddRange(_negativeChild.GetFaces(pt)); } return(faces); } if (sign > 0) { if (_positiveChild != null) { faces.AddRange(_positiveChild.GetFaces(pt)); } return(faces); } if (sign < 0) { if (_negativeChild != null) { faces.AddRange(_negativeChild.GetFaces(pt)); } return(faces); } return(faces); }
public void AppendDetectedFaces(UIImage sourceImage, List <Model.Face> detectedFaces) { Faces.AddRange(detectedFaces); thumbnailImages = detectedFaces.GenerateThumbnails(sourceImage, thumbnailImages); CollectionView.ReloadData(); }
public void AppendDetectedFaces(UIImage sourceImage, List <Face> detectedFaces, bool append = false) { cleanup(true, false); SourceImage = sourceImage; Faces.AddRange(detectedFaces); addCroppedImages(detectedFaces, croppedImages); CollectionView.ReloadData(); }
public void AddFaces(List <Model.Face> faces, List <Bitmap> thumbnails) { if (faces != null && thumbnails != null) { System.Diagnostics.Debug.Assert(thumbnails?.Count == faces?.Count, "Must have an equal count of faces and thumbnails"); Faces.AddRange(faces); faceThumbnails.AddRange(thumbnails); NotifyDataSetChanged(); } }
/// <summary> /// Incrementally update the existing hull using provided points. /// </summary> /// <param name="points">Points used to update the hull.</param> public void Update(IList <Vector3> points) { var visible = new VisibleFaces(); var working_set = new LinkedList <Face>(Faces); var final_set = new LinkedList <Face>(); sort_points(points, Faces); Faces.Clear(); while (working_set.Count > 0) { Face f = working_set.Pop(); //if the face was dropped, skip it if (f.Dropped) { continue; } //if the face has no visible points it belongs to the hull if (f.VisiblePoints.Count == 0) { final_set.AddFirst(f); continue; } //if not, build the visible set of faces and the horizon for the furthest visible point visible.Clear(); build_horizon(f.Furthest, visible, f); //create new faces var new_faces = make_pyramid(f.Furthest, visible.Horizon); //add points from visible faces to the new faces for (int i = 0; i < visible.Count; i++) { sort_points(visible[i].VisiblePoints, new_faces); } //add new faces to the working set for (int i = 0; i < new_faces.Count; i++) { working_set.AddFirst(new_faces[i]); } } //filter out faces that are still visible Faces.AddRange(from f in final_set where !f.Dropped select f); //build a list of unique hull points Volume = Area = 0; var _Points = new HashSet <Vector3>(); for (int i = 0; i < Faces.Count; i++) { var f = Faces[i]; float area; Volume += f.Volume(out area); Area += area; _Points.Add(f.v0); _Points.Add(f.v1); _Points.Add(f.v2); } Points = new List <Vector3>(_Points.Count); Points.AddRange(_Points); }
//------------------------------------------------------------------------ public void CollectFaces(Faces faces) { if (this.IsPositiveChild) { this.PositiveChild.CollectFaces(faces); } faces.AddRange(this.Faces); if (this.IsNegativeChild) { this.NegativeChild.CollectFaces(faces); } }
public List <Triangle> FindTrianglesInBox(Vector3 pMin, Vector3 pMax) { var faceInBox = new List <Triangle>(); var faceNotInBox = new List <Triangle>(); foreach (var face in Faces) { if (face.IsTriangleInBox(pMin, pMax)) { faceInBox.Add(face); } else { faceNotInBox.Add(face); } } Faces.Clear(); Faces.AddRange(faceNotInBox); return(faceInBox); }
public void LoadFromStringArray(string[] data) { int vcount = data.Count() - 1; var vertexIndexList = new int[vcount]; var normalIndexList = new int[vcount]; bool success; for (int i = 0; i < vcount; i++) { string[] parts = data[i + 1].Split('/'); //Normals are loaded as not indexed for now ////If we have 3 or more parts we have normal data at the third position //if (parts.Length >= 3) //{ // int nIndex; // success = int.TryParse(parts[2], out nIndex); // if (!success) throw new ArgumentException("Could not parse normal parameter as int"); // vertexIndexList[i] = nIndex - 1; //} if (parts.Length >= 2) { int tIndex; success = int.TryParse(parts[1], out tIndex); if (success) { facesTextureCoords.Add(tIndex - 1); } } //Load Vertex data int vIndex; success = int.TryParse(parts[0], out vIndex); if (!success) { throw new ArgumentException("Could not parse face vertice index parameter as int"); } vertexIndexList[i] = vIndex - 1; } Faces.AddRange(vertexIndexList); }
public void Append(Model m, Vector3 pivot) { if (m.Vertices.Count < 3) { return; } int oldFacesPos = Faces.Count; Faces.AddRange(m.Faces); for (int i = oldFacesPos; i < Faces.Count; ++i) { for (int j = 0; j < Faces[i].VertexIndices.Length; ++j) { Faces[i].VertexIndices[j] += Vertices.Count; } for (int j = 0; j < Faces[i].NormalIndices.Length; ++j) { Faces[i].NormalIndices[j] += Normals.Count; } for (int j = 0; j < Faces[i].TextureIndices.Length; ++j) { Faces[i].TextureIndices[j] += TexCoords.Count; } } Vertices.AddRange(m.Vertices); Normals.AddRange(m.Normals); TexCoords.AddRange(m.TexCoords); for (int i = 0; i < Vertices.Count; ++i) { Vertices[i] += pivot; } }
public VertexError Add(IEnumerable <MutableFace> faces) { Faces.AddRange(faces); return(this); }
public VertexError Add(params MutableFace[] faces) { Faces.AddRange(faces); return(this); }
public void ChangeVertices(int n) { baseVertices = n; if (_vertices.Count > 6) { _vertices.RemoveRange(6, _vertices.Count - 6); } if (_edges.Count > 9) { _edges.RemoveRange(9, _edges.Count - 9); } if (Faces.Count > 5) { Faces.RemoveRange(5, Faces.Count - 5); } if (n == 0) { InitializeBasicObject(); return; } var newv = new List <Vertex>(); var newe = new List <Edge>(); var newf = new List <Face>(); for (var i = 0; i < n; i++) { newf.Add(new Face()); } for (var i = 0; i < n * 2; i++) { newv.Add(new Vertex { X = 50, Y = i % 2 == 0 ? -25 : 25 }); } for (var i = 0; i < n * 3; i++) { var e = new Edge { Left = newf[i / 3] }; switch (i % 3) { case 0: e.Left = Faces[0]; e.Init = newv[i / 3 * 2]; e.End = i == 0 ? _vertices[0] : newv[(i - 1) / 3 * 2]; e.Right = newf[i / 3]; e.Right.Edge = e; break; case 1: e.Right = i == n * 3 - 2 ? Faces[3] : newf[i / 3 + 1]; e.Init = newv[i / 3 * 2]; e.End = newv[i / 3 * 2 + 1]; break; case 2: e.Right = Faces[4]; e.End = i == 2 ? _vertices[3] : newv[(i - 3) / 3 * 2 + 1]; e.Init = newv[i / 3 * 2 + 1]; break; } e.Init.Edge = e; e.End.Edge = e; newe.Add(e); } for (var i = 0; i < n * 3; i++) { switch (i % 3) { case 0: if (i == 0) { newe[i].UpperRight = _edges[3]; newe[i].UpperLeft = _edges[0]; _edges[0].LowerLeft = newe[i]; _edges[3].LowerRight = newe[i]; } else { newe[i].UpperRight = newe[i - 2]; newe[i].UpperLeft = newe[i - 3]; } if (i == (n - 1) * 3) { newe[i].LowerLeft = _edges[2]; _edges[2].UpperLeft = newe[i]; } else { newe[i].LowerLeft = newe[i + 3]; } newe[i].LowerRight = newe[i + 1]; break; case 1: newe[i].UpperLeft = newe[i + 1]; newe[i].LowerLeft = newe[i - 1]; if (i == n * 3 - 2) { newe[i].LowerRight = _edges[2]; newe[i].UpperRight = _edges[8]; _edges[2].UpperRight = newe[i]; _edges[8].UpperLeft = newe[i]; } else { newe[i].LowerRight = newe[i + 2]; newe[i].UpperRight = newe[i + 4]; } break; case 2: if (i == 2) { newe[i].UpperLeft = _edges[3]; newe[i].UpperRight = _edges[6]; _edges[3].UpperRight = newe[i]; _edges[6].LowerRight = newe[i]; } else { newe[i].UpperLeft = newe[i - 4]; newe[i].UpperRight = newe[i - 3]; } newe[i].LowerLeft = newe[i - 1]; newe[i].LowerRight = i == n * 3 - 1 ? _edges[8] : newe[i + 3]; break; } } _edges[8].UpperRight = newe[n * 3 - 1]; _edges[8].End = newv[n * 2 - 1]; _edges[2].End = newv[(n - 1) * 2]; _edges[3].Right = n == 0 ? Faces[3] : newf[0]; var angle = 360.0 / (n + 3); var total = n * 2 - 2; for (var i = 0; i < newv.Count; i += 2) { var m = Matrix.YRotationMatrix(-angle * ((total - i) / 2 + 3)); var p1 = m * (Point)newv[i]; newv[i].X = p1.X; newv[i + 1].X = p1.X; newv[i].Z = p1.Z; newv[i + 1].Z = p1.Z; } _vertices[1].X = _vertices[4].X = _vertices[2].X = _vertices[5].X = _vertices[0].X; _vertices[1].Z = _vertices[4].Z = _vertices[2].Z = _vertices[5].Z = _vertices[0].Z; for (var i = 1; i < 3; i++) { var m = Matrix.YRotationMatrix(-angle * i); var p1 = m * (Point)_vertices[i]; _vertices[i].X = p1.X; _vertices[i + 3].X = p1.X; _vertices[i].Z = p1.Z; _vertices[i + 3].Z = p1.Z; } _vertices.AddRange(newv); _edges.AddRange(newe); Faces.AddRange(newf); }
public void Merge(Solid solid) { Vectors.AddRange(solid.Vectors); Faces.AddRange(solid.Faces); }