/// <summary>
        /// Removes all vertices without faces.
        /// </summary>
        private void Cleanup()
        {
            if (Faces == null)
            {
                return;
            }

            List <Vector> newVertices = new List <Vector>();

            foreach (Vector vertex in Vertices)
            {
                bool contained = false;

                foreach (Face face in Faces)
                {
                    if (face.Contains(vertex))
                    {
                        contained = true;
                        break;
                    }
                }

                if (contained)
                {
                    newVertices.Add(vertex);
                }
            }

            Vertices           = newVertices;
            TextureCoordinates = Faces.SelectMany(x => x.Vertices).Where(x => x is Vertex).Select(x => new TextureCoordinate(((Vertex)x).U, ((Vertex)x).V)).Distinct().ToList();
        }
Ejemplo n.º 2
0
        private List <Edge2D> GetAllExistedEdges()
        {
            List <Edge2D> result = Faces.SelectMany(f => f.AllParents).SelectMany(f => f.BasicEdges).Distinct().ToList();

            result.AddRange(AllEdges);
            return(result);
        }
Ejemplo n.º 3
0
        public Coordinate GetOrigin()
        {
            var points = Faces.SelectMany(x => x.Vertices.Select(y => y.Location)).ToList();
            var origin = points.Aggregate(Coordinate.Zero, (x, y) => x + y) / points.Count;

            return(origin);
        }
Ejemplo n.º 4
0
        public Brush(IEnumerable <Face> faces)
        {
            Faces = faces.ToArray();

            InitializePlanes();
            InitializeVertices();
            BoundingBox = BoundingBox.FromPoints(Faces.SelectMany(face => face.Vertices));
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PrimitiveSurface" /> class.
 /// </summary>
 /// <param name="faces">The faces.</param>
 protected PrimitiveSurface(IEnumerable <PolygonalFace> faces)
 {
     Type  = PrimitiveSurfaceType.Unknown;
     Faces = faces.ToList();
     foreach (var face in faces)
     {
         face.BelongsToPrimitive = this;
     }
     Area     = Faces.Sum(f => f.Area);
     Vertices = Faces.SelectMany(f => f.Vertices).Distinct().ToList();
 }
Ejemplo n.º 6
0
        public Material(IPXMaterial material, IPXPmx pmx)
        {
            InstanceId = instanceCount;
            instanceCount++;

            Value     = material;
            ModelPath = pmx.FilePath;
            CreateTexFullPath();

            IEnumerable <IPXVertex> faceVertices = Faces.SelectMany(face => face.ToVertices());

            Vertices   = faceVertices.Distinct().ToList();
            IsSelected = Vertices.ToDictionary(vtx => vtx, _ => false);
            TemporaryTransformMatrices = Matrix.Identity;

            var VtxIdDic = Vertices.Select((vtx, i) => (vtx, i)).ToDictionary(pair => pair.vtx, pair => (uint)pair.i);

            FaceSequence = faceVertices.Select(vtx => VtxIdDic[vtx]).ToArray();
        }
Ejemplo n.º 7
0
 private List <Point2D> GetAllPoints()
 {
     return(Faces.SelectMany(f => f.ActualPoints).Distinct().ToList());
 }
Ejemplo n.º 8
0
 private List <Edge2D> GetAllEdges()
 {
     return(Faces.SelectMany(f => f.BasicEdges).Distinct().ToList());
 }
Ejemplo n.º 9
0
 private static List <FaceTrainingCase> GetTrainingCases()
 {
     return(Faces.SelectMany(face => face.Images.Select(faceImage => new FaceTrainingCase(face.Label, faceImage))).ToList());
 }