Example #1
0
        public static Dictionary <string, SkpFace> GetEntityFaces(SUEntitiesRef p_suEntitiesRef, SkpModel p_model)
        {
            Dictionary <string, SkpFace> surfaces = new Dictionary <string, SkpFace>(200);

            long faceCount = 0;

            SKPCExport.SUEntitiesGetNumFaces(p_suEntitiesRef, ref faceCount);

            if (faceCount > 0)
            {
                SUFaceRef[] faces = new SUFaceRef[faceCount];
                SKPCExport.SUEntitiesGetFaces(p_suEntitiesRef, faceCount, faces, ref faceCount);

                for (long i = 0; i < faceCount; i++)
                {
                    SkpFace surface = new SkpFace(p_model);
                    surface.Load(faces[i]);
                    surfaces.Add(surface.Identity, surface);
                }
            }

            return(surfaces);
        }
Example #2
0
        public static Task <Dictionary <string, SkpFace> > GetEntityFacesAsync(SUEntitiesRef p_suEntitiesRef, SkpModel p_model)
        {
            TaskCompletionSource <Dictionary <string, SkpFace> > tcs = new TaskCompletionSource <Dictionary <string, SkpFace> >();
            long faceCount = 0;

            SKPCExport.SUEntitiesGetNumFaces(p_suEntitiesRef, ref faceCount);

            if (faceCount > 0)
            {
                SUFaceRef[] faces = new SUFaceRef[faceCount];
                SKPCExport.SUEntitiesGetFaces(p_suEntitiesRef, faceCount, faces, ref faceCount);

                TaskExcutor.Run <SkpFace, SUFaceRef>(faces, f =>
                {
                    SkpFace surface = new SkpFace(p_model);
                    surface.Load(f);
                    return(surface);
                }).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        tcs.TrySetException(t.Exception);
                    }
                    else
                    {
                        tcs.TrySetResult(t.Result.ToDictionary(p => p.Identity, p => p));
                    }
                });
            }
            else
            {
                tcs.TrySetResult(new Dictionary <string, SkpFace>());
            }

            return(tcs.Task);
        }