예제 #1
0
        private IEnumerable <IPart> Traverse(Reference3D ref3D, Instance3D instance3D)
        {
            var instance3Ds  = Aggregated <Instance3D>(ref3D.Id);
            var instanceReps = Aggregated <InstanceRep>(ref3D.Id);
            var refReps      = instanceReps.Select(x => Get <ReferenceRep>(x.InstanceOf));

            return(refReps.Select(x => Part.FromReferenceRep(x, instance3D))
                   .Concat(instance3Ds.SelectMany(inst => Traverse(Get <Reference3D>(inst.InstanceOf), inst))));
        }
예제 #2
0
 /// <summary>
 /// Creates a part from a give reference representation.
 /// </summary>
 /// <param name="rep">The reference representation of that part.</param>
 /// <param name="instance3D"></param>
 /// <returns>a new part object</returns>
 public static IPart FromReferenceRep(ReferenceRep rep, Instance3D instance3D)
 {
     var triangles = rep.Shell.Triangles;
     var p = new Part
     {
         Name = rep.Name,
         Vertices = triangles.SelectMany(x => new List<Vector3> {x.V1, x.V2, x.V3}).ToList(),
         Triangles = Enumerable.Range(0, triangles.Count*3).ToList(),
         Position = instance3D.Position,
         Rotation = instance3D.Rotation
     };
     return p;
 }
 public static Instance3D FromXDocument(XElement xElement)
 {
     var id = int.Parse(xElement.Attribute(XName.Get("id")).Value);
     var name = xElement.Attribute(XName.Get("name")).Value;
     var instance = new Instance3D(id, name)
     {
         AggregatedBy = ParseUtility.ValueOfDescendant(xElement, "IsAggregatedBy", Convert.ToInt32, 0),
         InstanceOf = ParseUtility.ValueOfDescendant(xElement, "IsInstanceOf", Convert.ToInt32, 0),
         RelativeMatrix =
             ParseUtility.ValueOfDescendant<IList<double>>(xElement, "RelativeMatrix",
                 ParseList, new List<double>())
     };
     return instance;
 }
예제 #4
0
        /// <summary>
        /// Creates a part from a give reference representation.
        /// </summary>
        /// <param name="rep">The reference representation of that part.</param>
        /// <param name="instance3D"></param>
        /// <returns>a new part object</returns>
        public static IPart FromReferenceRep(ReferenceRep rep, Instance3D instance3D)
        {
            var triangles = rep.Shell.Triangles;
            var p         = new Part
            {
                Name     = rep.Name,
                Vertices = triangles.SelectMany(x => new List <Vector3> {
                    x.V1, x.V2, x.V3
                }).ToList(),
                Triangles = Enumerable.Range(0, triangles.Count * 3).ToList(),
                Position  = instance3D.Position,
                Rotation  = instance3D.Rotation
            };

            return(p);
        }