public void Execute(List <string> param, ObjModel model) { var vec = new ParamVector { values = param.ToArray() }; //Vector.Parse(param.ToArray()); if (!model.CurrentMesh.attrNames.Contains(name)) { model.CurrentMesh.attrNames.Add(name); } if (!model.CurrentMesh.data.ContainsKey(name)) { model.CurrentMesh.data[name] = new List <ParamVector>(); } model.CurrentMesh.data[name].Add(vec); }
public List <ParamVector[]> Select(params string[] attrNames) { List <ParamVector[]> result = new List <ParamVector[]>(); int vertexCount = objVertexList.Count; if (attrNames == null) { attrNames = this.attrNames.ToArray(); } int vectorRowLength = attrNames.Length; for (int cornerIndex = 0; cornerIndex < vertexCount; cornerIndex++) { ParamVector[] vectorRow = new ParamVector[vectorRowLength]; ObjVertex objVertex = objVertexList[cornerIndex]; for (int i = 0; i < vectorRow.Length; i++) { string componentName = attrNames[i]; int nameIndex = this.attrNames.FindIndex(str => str == componentName); if (nameIndex >= 0 && nameIndex < objVertex.attrIndex.Length) { int componentIndex = objVertex.attrIndex[nameIndex]; var componentList = data[componentName]; if (componentIndex >= 0 && componentIndex < componentList.Count) { vectorRow[i] = componentList[componentIndex]; } else { vectorRow[i] = null; } } else { vectorRow[i] = null; } } result.Add(vectorRow); } return(result); }
public static string Dump(this ParamVector vector) { if (vector == null) { return("<null>"); } return(string.Format("< {0} >", string.Join(", ", new List <string>(vector.values).ConvertAll( (v) => { var str = v; // string.Format("{0:####.000}", v); int strlen = str.Length; if (strlen < 9) { return GetSpaceStr(9 - strlen) + str; } else { return str; } })))); }