/// <summary> /// 构造函数 /// </summary> /// <param name="groupRef"></param> public void Load(SUGroupRef groupRef) { SUDrawingElementRef drawingRef = SKPCExport.SUGroupToDrawingElement(groupRef); SUEntityRef entityRef = SKPCExport.SUDrawingElementToEntity(drawingRef); m_identity = SkpEntityCache.GetIdentity(entityRef); m_defaultMaterialIdentity = SkpEntityCache.GetMaterialDefault(drawingRef); SUEntitiesRef entities = default; SKPCExport.SUGroupGetEntities(groupRef, ref entities); m_faces = SkpFace.GetEntityFaces(entities, Model); m_instances = SkpInstance.GetEntityInstances(entities, Model); m_groups = SkpGroup.GetEntityGroups(entities, Model); SUTransformation transform = default; SKPCExport.SUGroupGetTransform(groupRef, ref transform); m_transform = new SkpTransform(transform); SUStringRef groupName = default(SUStringRef); SKPCExport.SUStringCreate(ref groupName); SKPCExport.SUGroupGetName(groupRef, ref groupName); m_name = Utilities.GetString(groupName); SKPCExport.SUStringRelease(ref groupName); m_clusters = SkpFaceCluster.Load(m_faces.Values, m_model); }
public static Task <Dictionary <string, SkpGroup> > GetEntityGroupsAsync(SUEntitiesRef p_suEntitiesRef, SkpModel p_model) { TaskCompletionSource <Dictionary <string, SkpGroup> > tcs = new TaskCompletionSource <Dictionary <string, SkpGroup> >(); long groupsCount = 0; SKPCExport.SUEntitiesGetNumGroups(p_suEntitiesRef, ref groupsCount); if (groupsCount > 0) { SUGroupRef[] groupRefs = new SUGroupRef[groupsCount]; SKPCExport.SUEntitiesGetGroups(p_suEntitiesRef, groupsCount, groupRefs, ref groupsCount); TaskExcutor.Run <SkpGroup, SUGroupRef>(groupRefs, g => { SkpGroup group = new SkpGroup(p_model); group.Load(g); return(group); }).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, SkpGroup>()); } return(tcs.Task); }
public static Dictionary <string, SkpGroup> GetEntityGroups(SUEntitiesRef p_suEntitiesRef, SkpModel p_model) { Dictionary <string, SkpGroup> groups = new Dictionary <string, SkpGroup>(100); long groupsCount = 0; SKPCExport.SUEntitiesGetNumGroups(p_suEntitiesRef, ref groupsCount); if (groupsCount > 0) { SUGroupRef[] groupRefs = new SUGroupRef[groupsCount]; SKPCExport.SUEntitiesGetGroups(p_suEntitiesRef, groupsCount, groupRefs, ref groupsCount); for (long i = 0; i < groupsCount; i++) { SkpGroup group = new SkpGroup(p_model); group.Load(groupRefs[i]); groups.Add(group.Identity, group); } } return(groups); }