public Structural2DElement[] Explode() { var elements = new List <Structural2DElement>(); var faceCounter = 0; for (var i = 0; i < Faces.Count(); i++) { var vertices = new List <double>(); var colors = new List <int>(); var numVertices = Faces[i++] + 3; for (var j = 0; j < numVertices; j++) { if (Colors != null && Colors.Count() > Faces[i]) { colors.Add(Colors[Faces[i]]); } vertices.AddRange(Vertices.Skip(Faces[i++] * 3).Take(3)); } i--; var element = new Structural2DElement( vertices.ToArray(), (new List <int>() { numVertices - 3 }).Concat(Enumerable.Range(0, numVertices)).ToArray(), colors.Count() == vertices.Count() / 3 ? colors.ToArray() : new int[0], ElementType, PropertyRef, Axis != null && Axis.Count() > faceCounter ? Axis[faceCounter] : null, Offset != null && Offset.Count() > faceCounter ? Offset[faceCounter] : 0, ElementApplicationId != null && ElementApplicationId.Count() > faceCounter ? ElementApplicationId[faceCounter] : Helper.CreateChildApplicationId(i, ApplicationId + "-" + faceCounter.ToString()) ) { GSADummy = GSADummy, GSAMeshSize = GSAMeshSize }; elements.Add(element); faceCounter++; } return(elements.ToArray()); }
public Structural1DElement[] Explode() { var elements = new List <Structural1DElement>(); for (var i = 0; i < Value.Count() / 3 - 1; i++) { var element = new Structural1DElement( Value.Skip(i * 3).Take(6).ToArray(), ElementType, PropertyRef, ZAxis == null || ZAxis.Count() <= i ? null : ZAxis[i], EndRelease == null || EndRelease.Count() < i * 2 + 2 ? null : EndRelease.Skip(i * 2).Take(2).ToArray(), Offset == null || Offset.Count() < i * 2 + 2 ? null : Offset.Skip(i * 2).Take(2).ToArray(), ElementApplicationId != null && ElementApplicationId.Count() > i ? ElementApplicationId[i] : ApplicationId + "_" + i.ToString() ); element.GSADummy = GSADummy; element.GSAMeshSize = GSAMeshSize; elements.Add(element); } return(elements.ToArray()); }