本文整理汇总了C#中Mesh.Append方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.Append方法的具体用法?C# Mesh.Append怎么用?C# Mesh.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDisplayMesh
Mesh CreateDisplayMesh()
{
var mesh = new Mesh();
mesh.Append(BaseMesh);
foreach (var joint in Joints)
mesh.Append(joint.Mesh);
mesh.Transform(BasePlane.ToTransform());
return mesh;
}
示例2: CreateMeshFromBrep
public static Result CreateMeshFromBrep(RhinoDoc doc)
{
ObjRef obj_ref;
var rc = RhinoGet.GetOneObject("Select surface or polysurface to mesh", true, ObjectType.Surface | ObjectType.PolysrfFilter, out obj_ref);
if (rc != Result.Success)
return rc;
var brep = obj_ref.Brep();
if (null == brep)
return Result.Failure;
// you could choose anyone of these for example
var jagged_and_faster = MeshingParameters.Coarse;
var smooth_and_slower = MeshingParameters.Smooth;
var default_mesh_params = MeshingParameters.Default;
var minimal = MeshingParameters.Minimal;
var meshes = Mesh.CreateFromBrep(brep, smooth_and_slower);
if (meshes == null || meshes.Length == 0)
return Result.Failure;
var brep_mesh = new Mesh();
foreach (var mesh in meshes)
brep_mesh.Append(mesh);
doc.Objects.AddMesh(brep_mesh);
doc.Views.Redraw();
return Result.Success;
}
示例3: RunCommand
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
ObjRef[] objs;
RhinoGet.GetMultipleObjects("Select meshes", true, ObjectType.Mesh, out objs);
var mesh = new Mesh();
foreach (var obj in objs)
mesh.Append(obj.Geometry() as Mesh);
var meshInfo = new MeshInfo(mesh);
var dlg = new SaveFileDialog();
if (dlg.ShowDialog() != DialogResult.OK) return Result.Cancel;
meshInfo.Save(dlg.FileName);
return Result.Success;
}
示例4: Compute
public Mesh Compute(double isolevel, int length, int width, int height, double cellsize)
{
Mesh mesh = new Mesh();
Matrix_Octahedra mo = new Matrix_Octahedra(length, width, height, cellsize);
List<Mesh> x = new List<Mesh>();
x.AddRange(mo.mesh1); x.AddRange(mo.mesh2);
List<tribox> boxes = new List<tribox>();
for (int i = 0; i < x.Count; i++)
{
boxes.AddRange(tribox.FromMesh(x[i]));
}
//**************************************************
Mesh[] meshes = new Mesh[boxes.Count];
bool[] signs = new bool[boxes.Count];
//for(int i = 0;i < boxes.Count;i++){
System.Threading.Tasks.Parallel.For(0, boxes.Count, i =>
{
for (int j = 0; j < boxes[i].Points.Length; j++)
{
Point3f P = boxes[i].Points[j].loc;
boxes[i].Points[j].Value =
(Math.Sin(P.X) * Math.Cos(P.Y) +
Math.Sin(P.Y) * Math.Cos(P.Z) +
Math.Sin(P.Z) * Math.Cos(P.X)) + 0.8;
}
Mesh mesh1;
signs[i] = boxes[i].Compute(out mesh1, isolevel);
meshes[i] = mesh1;
});
//**************************************************
for (int i = 0; i < boxes.Count; i++)
{
if (signs[i]) mesh.Append(meshes[i]);
}
return mesh;
}
示例5: MeshSweep1
public Mesh MeshSweep1(Curve l, Polyline ls, Plane SectionPos, int Count)
{
List<Polyline> ps = new List<Polyline>();
Mesh mesh = new Mesh();
double[] div = l.DivideByCount(Count, true);
for (int i = 0; i < div.Length; i++)
{
Polyline l1 = new Polyline(ls);
Plane plane;
if (l.PerpendicularFrameAt(div[i], out plane))
{
l1.Transform(Transform.PlaneToPlane(SectionPos, plane));
ps.Add(l1);
}
}
mesh.Append(MeshLoft(ps, false, false));
return mesh;
}
示例6: RunScript
/// <summary>
/// This procedure contains the user code. Input parameters are provided as regular arguments,
/// Output parameters as ref arguments. You don't have to assign output parameters,
/// they will have a default value.
/// </summary>
private void RunScript(List<Point3d> x, double y, bool z, double u, ref object A, ref object B, ref object C, ref object D, ref object E, ref object F)
{
try
{
List<Line> ls = new List<Line>();//frofile
List<Polyline> pls = new List<Polyline>();//frofile
//////
List<Polyline> pls01 = new List<Polyline>();//frame1
List<Polyline> pls02 = new List<Polyline>();//frame2
////////
pls.Add(box(new Line(x[0], x[1])));
pls.Add(box(new Line(x[1], x[2])));
Polyline pl = new Polyline();
pl = box(new Line((x[0] + x[1]) / 2, (x[2] + x[1]) / 2));
pl.Transform(Transform.Translation(0, 0, -y));
pls.Add(pl);
////////
ls.Add(new Line(pls[2][0], pls[0][0]));
ls.Add(new Line(pls[2][1], pls[0][1]));
ls.Add(new Line(pls[2][2], pls[0][2]));
ls.Add(new Line(pls[2][3], pls[0][3]));
ls.Add(new Line(pls[2][0], pls[1][0]));
ls.Add(new Line(pls[2][1], pls[1][1]));
ls.Add(new Line(pls[2][2], pls[1][2]));
ls.Add(new Line(pls[2][3], pls[1][3]));
////////
for (double i = -y; i <= 0.4; i += 0.4)
{
Plane p = Plane.WorldXY;
p.Transform(Transform.Translation(0, 0, i));
double t = 0;
Polyline pl0 = new Polyline();
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[0], p, out t);
pl0.Add(ls[0].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[1], p, out t);
pl0.Add(ls[1].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[2], p, out t);
pl0.Add(ls[2].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[3], p, out t);
pl0.Add(ls[3].PointAt(t)); pl0.Add(pl0[0]);
pls01.Add(pl0);
pl0 = new Polyline();
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[4], p, out t);
pl0.Add(ls[4].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[5], p, out t);
pl0.Add(ls[5].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[6], p, out t);
pl0.Add(ls[6].PointAt(t));
Rhino.Geometry.Intersect.Intersection.LinePlane(ls[7], p, out t);
pl0.Add(ls[7].PointAt(t)); pl0.Add(pl0[0]);
pls02.Add(pl0);
}
///////////////////////////////////////
Mesh mesh1 = new Mesh();//frame
Mesh mesh2 = new Mesh();//screw
Mesh mesh3 = new Mesh();//Joint
List<Line> output1 = new List<Line>();//screw M6*40
List<Polyline> output2 = new List<Polyline>();//frame1&frame2
List<Line> output3 = new List<Line>();//screw M4*40
for (int i = 0; i < pls01.Count; i++)
{
Polyline pll = offset(pls01[i], 0.1);
pll.Transform(Transform.Translation(0, 0, 0.1));
pls01[i] = pll;
mesh1.Append(desk(pll, 0.2, 0.2));
if (i > 0)
{
output1.AddRange(Intersect(pls01[i], pls01[i - 1]));
}
}
pls02.RemoveAt(0);
for (int i = 0; i < pls02.Count; i++)
{
Polyline pll = offset(pls02[i], 0.1);
pll.Transform(Transform.Translation(0, 0, -0.1));
pls02[i] = pll;
mesh1.Append(desk(pll, 0.2, 0.2));
if (i > 0)
{
output1.AddRange(Intersect(pls02[i], pls02[i - 1]));
}
}
////////////////////////////////////////////////////////
for (int i = 1; i < pls01.Count; i++)
{
mesh3.Append(Joint(pls01[i - 1], pls01[i], 0.2, 0.2, 0.5));
}
for (int i = 1; i < pls02.Count; i++)
{
Polyline PL01 = new Polyline();
PL01.Add(pls02[i - 1][2]); PL01.Add(pls02[i - 1][3]); PL01.Add(pls02[i - 1][0]); PL01.Add(pls02[i - 1][1]);
Polyline PL02 = new Polyline();
PL02.Add(pls02[i][2]); PL02.Add(pls02[i][3]); PL02.Add(pls02[i][0]); PL02.Add(pls02[i][1]);
mesh3.Append(Joint(PL01, PL02, 0.2, 0.2, 0.5));
}
//.........这里部分代码省略.........
示例7: ComputeMeshTree
/// <summary>
/// unstable method, the level is 10
/// </summary>
public Mesh ComputeMeshTree(List<Line> x, Point3d y,double firstEnergy,double EnergyDecrease)
{
Vertice1.CreateCollection(x, out this.id, out this.vs);
for (int i = 0; i < vs.Count; i++)
{
if (vs[i].equalTo(y)) { vs[i].energy = firstEnergy; break; }
}
for (int i = 0; i < 40; i++)
{
vs.ForEach(delegate(Vertice1 v) { v.transferenergy(EnergyDecrease, ref vs); });
}
for (int i = 0; i < vs.Count; i++)
{
vs[i].CrateEdges(vs);
//Print(vs[i].edges.Count.ToString());
}
////////////////
Mesh mesh = new Mesh();
for (int i = 0; i < id.Count; i++)
{
Polyline pl1 = new Polyline(); Polyline pl2 = new Polyline();
if (vs[id[i].J].refer.Count == 3)
{
for (int j = 0; j < 3; j++)
{
if (vs[id[i].J].refer[j] == id[i].I)
{
pl1 = vs[id[i].J].edges[j]; break;
}
}
}
if (vs[id[i].I].refer.Count == 3)
{
for (int j = 0; j < 3; j++)
{
if (vs[id[i].I].refer[j] == id[i].J)
{
pl2 = vs[id[i].I].edges[j]; break;
}
}
}
//Print(pl1.Count.ToString());
if (pl1.Count == 4 && pl2.Count == 0)
{
Plane p = new Plane(vs[id[i].I].pos, vs[vs[id[i].I].refer[0]].pos - vs[id[i].I].pos);
pl2.AddRange(pl1);
pl2.Transform(Transform.PlanarProjection(p));
}
if (pl1.Count == 0 && pl2.Count == 4)
{
Plane p = new Plane(vs[id[i].J].pos, vs[vs[id[i].J].refer[0]].pos - vs[id[i].J].pos);
pl1.AddRange(pl2);
pl1.Transform(Transform.PlanarProjection(p));
}
if (pl1.Count == 4 && pl2.Count == 4)
{
Plane p1 = new Plane(pl1[0], pl1[1], pl1[2]);
Plane p2 = new Plane(pl2[0], pl2[1], pl2[2]);
if (Vector3d.VectorAngle(p1.Normal, p2.Normal) > Math.PI / 2) pl2.Reverse();
mesh.Append(mc.ClosedBridge(pl1, pl2));
}
}
return mesh;
}
示例8: Unfold
public Mesh Unfold(Mesh mesh)
{
List<face> Faces = new List<face>();
List<edge> Edges = new List<edge>();
mesh.Faces.ConvertQuadsToTriangles();
mesh.UnifyNormals();
mesh.Compact();
Rhino.Geometry.Collections.MeshTopologyEdgeList el = mesh.TopologyEdges;
Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
mesh.FaceNormals.ComputeFaceNormals();
//Print(mesh.FaceNormals.Count.ToString());
// Print(mesh.Vertices.Count.ToString());
for (int i = 0; i < mesh.Faces.Count; i++)
{
face f1 = new face(
new Point3d(mesh.Vertices[mesh.Faces[i].A]),
new Point3d(mesh.Vertices[mesh.Faces[i].B]),
new Point3d(mesh.Vertices[mesh.Faces[i].C]),
mesh.FaceNormals[i]
);
Faces.Add(f1);
}
for (int i = 0; i < el.Count; i++)
{
int[] faceid = el.GetConnectedFaces(i);
edge e1 = new edge(vs[el.GetTopologyVertices(i).I], vs[el.GetTopologyVertices(i).J]);
if (faceid.Length == 1)
{
e1.Faces = new face[1];
e1.Faces[0] = Faces[faceid[0]];
}
else if (faceid.Length > 1)
{
e1.Faces = new face[2];
e1.Faces[0] = Faces[faceid[0]];
e1.Faces[1] = Faces[faceid[1]];
}
e1.ID = i;
Edges.Add(e1);
}
for (int i = 0; i < mesh.Faces.Count; i++)
{
int[] edgeid = el.GetEdgesForFace(i);
face f1 = Faces[i];
f1.edges[0] = Edges[edgeid[0]];
f1.edges[1] = Edges[edgeid[1]];
f1.edges[2] = Edges[edgeid[2]];
f1.ID = i;
}
/* List< Mesh> output2 = new List< Mesh>();
for (int i = 0; i < Faces.Count; i++)
{
output2.Add(Faces[i].DrawFace());
}
B = output2;
*/
face f = Faces[0];
f.AddTransform(Transform.PlaneToPlane(new Plane(f.Center(), f.Normal), Plane.WorldXY));
FaceLoop(f);
//Print(f.Pts[0].X.ToString() + "/" + f.Pts[0].Y.ToString() + "/" + f.Pts[0].Z.ToString());
Mesh output = new Mesh();
for (int i = 0; i < Faces.Count; i++)
{
output.Append(Faces[i].DrawFace());
}
return output;
}
示例9: Mesh2Topo
/// 2Nurbs
///
public string Mesh2Topo(ref Mesh mesh, out Mesh mesh2, int edge, out IndexPair data)
{
Rhino.Geometry.Collections.MeshTopologyEdgeList el = mesh.TopologyEdges;
Rhino.Geometry.Collections.MeshTopologyVertexList vs = mesh.TopologyVertices;
string str = "";
List<int> firstLoop1;
str += FirstEdge(mesh, out firstLoop1);
double column = (double)vs.Count / (double)firstLoop1.Count;
int Column = (int)column;
if (column - Column != 0) str += "Points Count error,Please confirm the topo to be quad style";
int[] energy = new int[vs.Count];
List<int> indexPt = new List<int>();
indexPt.AddRange(firstLoop1);
for (int i = 0; i < firstLoop1.Count; i++) { energy[firstLoop1[i]] = 1; }
for (int i = 0; i < Column - 1; i++)
{
bool sign = true;
for (int j = 0; j < firstLoop1.Count; j++)
{
int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
for (int k = 0; k < index.Length; k++)
{
energy[index[k]]++;
}
}
for (int j = 0; j < firstLoop1.Count; j++)
{
int[] index = vs.ConnectedTopologyVertices(firstLoop1[j]);
for (int k = 0; k < index.Length; k++)
{
if (energy[index[k]] == 1)
{
firstLoop1[j] = index[k]; sign = false; break;
}
}
}
if (sign) { str += " Loop false,Not quad topo Or To the end"; }
else { indexPt.AddRange(firstLoop1); }
}
///
///*******
double MX = (double)Column - 1;
double MY = (double)firstLoop1.Count - 1;
List<Point3d> output1 = new List<Point3d>();
List<Point3d> output2 = new List<Point3d>();
int iCount = 0;
Color[] cl = new Color[mesh.Vertices.Count];
//edge
List<int> pl1 = new List<int>();
List<int> pl2 = new List<int>();
List<int> pl3 = new List<int>();
List<int> pl4 = new List<int>();
int edge1 = 0, edge2 = 0, edge3 = 0, edge4 = 0;
//////////
for (int i = 0; i < Column; i++)
{
for (int j = 0; j < firstLoop1.Count; j++)
{
if (i == 0) pl1.Add(iCount);
if (i == column - 1) pl3.Add(iCount);
if (j == 0) pl2.Add(iCount);
if (j == firstLoop1.Count - 1) pl4.Add(iCount);
if (i == 0 && j == 0) edge1 = iCount;
if (i == 0 && j == firstLoop1.Count - 1) edge2 = iCount;
if (i == column - 1 && j == firstLoop1.Count - 1) edge3 = iCount;
if (i == column - 1 && j == 0) edge4 = iCount;
output1.Add(vs[indexPt[iCount]]);
int indexV = vs.MeshVertexIndices(indexPt[iCount])[0];
cl[iCount] = mesh.VertexColors[indexV];
iCount++;
Point3d pt = new Point3d(edge * i, edge * j, 0);
output2.Add(pt);
}
}
mesh2 = mc.MeshFromPoints(output2, firstLoop1.Count, Column);
mesh = mc.MeshFromPoints(output1, firstLoop1.Count, Column);
mesh.VertexColors.Clear();
mesh.VertexColors.AppendColors(cl);
mesh2.VertexColors.Clear();
mesh2.VertexColors.AppendColors(cl);
///edge
List<Point3d> pts;
/////////////////////////////////////////////////////////
Color[] cl1 = new Color[pl1.Count * 2]; pts = new List<Point3d>();
for (int i = 0; i < pl1.Count; i++)
{
pts.Add(new Point3d(mesh2.Vertices[pl1[i]]));
pts.Add((Point3d)mesh2.Vertices[pl1[i]] + new Vector3d(-edge, 0, 0));
cl1[i * 2] = mesh2.VertexColors[pl1[i]]; cl1[i * 2 + 1] = mesh2.VertexColors[pl1[i]];
}
Mesh mesh3 = mc.MeshFromPoints(pts, 2, pl1.Count);
mesh3.VertexColors.AppendColors(cl1);
mesh2.Append(mesh3);
/////////////////////////////////////////////////////////
Color[] cl2 = new Color[pl2.Count * 2]; pts = new List<Point3d>();
for (int i = 0; i < pl2.Count; i++)
{
//.........这里部分代码省略.........
示例10: MeshOffset
public Mesh MeshOffset(Polyline pl, double t, int n)
{
Polyline pl2; Mesh mesh = new Mesh();
if (n < 1) return mesh;
for (int i = 1; i < n; i++)
{
mesh.Append(MeshOffset(pl, t / n, out pl2));
pl = pl2;
}
return mesh;
}
示例11: MeshVerticeDisplay
public Mesh MeshVerticeDisplay(Mesh mesh, List<double> data)
{
Mesh output = new Mesh();
output.Append(mesh);
double max = double.MinValue;
double min = double.MaxValue;
List<double> t = data;
Rhino.Geometry.Collections.MeshVertexList vs = mesh.Vertices;
if (data.Count < vs.Count) return output;
for (int i = 0; i < vs.Count; i++)
{
if (t[i] > max) max = t[i];
if (t[i] < min) min = t[i];
}
for (int i = 0; i < t.Count; i++)
{
double T;
if (max == min) { T = 0; }
else { T = (t[i] - min) / (max - min); }
double R; double G;
if (T >= 0.5)
{
R = 255.0;
G = 510.0 * (1 - T);
}
else
{
R = 510.0 * (T);
G = 255.0;
}
//R = 255 * T;G = 255 * (1 - T);
if (R > 255) R = 255;
if (G > 255) G = 255;
if (G < 0) G = 0;
if (R < 0) R = 0;
output.VertexColors.Add((int)R, (int)G, 0);
}
return output;
}
示例12: Compute
public Mesh Compute(double Iso)
{
Mesh meshoutput = new Mesh();
double iso = Iso;
for (int i = 0; i <= X; i++)
{
for (int j = 0; j <= Y; j++)
{
for (int k = 0; k <= Z; k++)
{
if (i < X) { EdgePoints[i, j, k, 0] = VertexInterp(i, j, k, i + 1, j, k, energy[i, j, k], energy[i + 1, j, k], iso); }
if (j < Y) { EdgePoints[i, j, k, 1] = VertexInterp(i, j, k, i, j + 1, k, energy[i, j, k], energy[i, j + 1, k], iso); }
if (k < Z) { EdgePoints[i, j, k, 2] = VertexInterp(i, j, k, i, j, k + 1, energy[i, j, k], energy[i, j, k + 1], iso); }
}
}
}
for (int i = 0; i < boxes.Count; i++)
{
box b = boxes[i];
Mesh mesh = new Mesh();
int cubeindex = 0;
if (energy[b.points[0, 0], b.points[0, 1], b.points[0, 2]] < iso) { cubeindex |= 1; }//;str += "1";}else{str += "0";}
if (energy[b.points[1, 0], b.points[1, 1], b.points[1, 2]] < iso) { cubeindex |= 2; }//;str += "1";}else{str += "0";}
if (energy[b.points[2, 0], b.points[2, 1], b.points[2, 2]] < iso) { cubeindex |= 4; }//;str += "1";}else{str += "0";}
if (energy[b.points[3, 0], b.points[3, 1], b.points[3, 2]] < iso) { cubeindex |= 8; }//;str += "1";}else{str += "0";}
if (energy[b.points[4, 0], b.points[4, 1], b.points[4, 2]] < iso) { cubeindex |= 16; }//;str += "1";}else{str += "0";}
if (energy[b.points[5, 0], b.points[5, 1], b.points[5, 2]] < iso) { cubeindex |= 32; }//;str += "1";}else{str += "0";}
if (energy[b.points[6, 0], b.points[6, 1], b.points[6, 2]] < iso) { cubeindex |= 64; }//;str += "1";}else{str += "0";}
if (energy[b.points[7, 0], b.points[7, 1], b.points[7, 2]] < iso) { cubeindex |= 128; }//;str += "1";}else{str += "0";}
int vs = 0;
for (int l = 0; l <= 4; l++)
{
if (triTable[cubeindex, l * 3] == -1) break;
int tr1 = triTable[cubeindex, l * 3];
int tr2 = triTable[cubeindex, l * 3 + 1];
int tr3 = triTable[cubeindex, l * 3 + 2];
Point3d p1 = EdgePoints[b.Cedges[tr1, 0], b.Cedges[tr1, 1], b.Cedges[tr1, 2], b.Cedges[tr1, 3]];
Point3d p2 = EdgePoints[b.Cedges[tr2, 0], b.Cedges[tr2, 1], b.Cedges[tr2, 2], b.Cedges[tr2, 3]];
Point3d p3 = EdgePoints[b.Cedges[tr3, 0], b.Cedges[tr3, 1], b.Cedges[tr3, 2], b.Cedges[tr3, 3]];
mesh.Vertices.Add(p1);
mesh.Vertices.Add(p2);
mesh.Vertices.Add(p3);
mesh.Faces.AddFace(vs * 3, vs * 3 + 1, vs * 3 + 2);
vs++;
}
meshoutput.Append(mesh);
}
return meshoutput;
}
示例13: createNewFaces
private Mesh createNewFaces(Point3d pt, Mesh mesh)
{
List<Polyline> list2 = new List<Polyline>();
list2.AddRange(mesh.GetNakedEdges());
List<Line> list = new List<Line>();
int num3 = list2.Count - 1;
for (int i = 0; i <= num3; i++)
{
Polyline polyline = new Polyline();
list.AddRange(list2[i].GetSegments());
}
Mesh other = new Mesh();
int num4 = list.Count - 1;
for (int j = 0; j <= num4; j++)
{
Mesh mesh4 = new Mesh();
Line line = list[j];
mesh4.Vertices.Add(line.From);
mesh4.Vertices.Add(line.To);
mesh4.Vertices.Add(pt);
mesh4.Faces.AddFace(0, 1, 2);
other.Append(mesh4);
}
mesh.Append(other);
mesh.Vertices.CombineIdentical(true, true);
mesh.UnifyNormals();
return mesh;
}
示例14: RunScript
/// <summary>
/// This procedure contains the user code. Input parameters are provided as regular arguments,
/// Output parameters as ref arguments. You don't have to assign output parameters,
/// they will have a default value.
/// </summary>
private void RunScript(List<Line> x, List<Point3d> y, ref object A, ref object B, ref object C)
{
try
{
List<IndexPair> id; List<Vertice> vs;
Vertice.CreateCollection(x, out id, out vs);
for (int i = 0; i < vs.Count; i++)
{
for (int j = 0; j < y.Count; j++)
{
if (vs[i].equalTo(y[j])) { vs[i].energe = 0.8; break; }
}
}
for (int i = 0; i < 10; i++)
{
vs.ForEach(delegate(Vertice v) { v.transferEnerge(0.70, ref vs); });
}
for (int i = 0; i < vs.Count; i++)
{
vs[i].CrateEdges(vs);
//Print(vs[i].edges.Count.ToString());
}
////////////////
Mesh mesh = new Mesh();
for (int i = 0; i < id.Count; i++)
{
Polyline pl1 = new Polyline(); Polyline pl2 = new Polyline();
if (vs[id[i].J].refer.Count == 3)
{
for (int j = 0; j < 3; j++)
{
if (vs[id[i].J].refer[j] == id[i].I)
{
pl1 = vs[id[i].J].edges[j]; break;
}
}
}
if (vs[id[i].I].refer.Count == 3)
{
for (int j = 0; j < 3; j++)
{
if (vs[id[i].I].refer[j] == id[i].J)
{
pl2 = vs[id[i].I].edges[j]; break;
}
}
}
//Print(pl1.Count.ToString());
if (pl1.Count == 4 && pl2.Count == 0)
{
Plane p = new Plane(vs[id[i].I].pos, vs[vs[id[i].I].refer[0]].pos - vs[id[i].I].pos);
pl2.AddRange(pl1);
pl2.Transform(Transform.PlanarProjection(p));
}
if (pl1.Count == 0 && pl2.Count == 4)
{
Plane p = new Plane(vs[id[i].J].pos, vs[vs[id[i].J].refer[0]].pos - vs[id[i].J].pos);
pl1.AddRange(pl2);
pl1.Transform(Transform.PlanarProjection(p));
}
if (pl1.Count == 4 && pl2.Count == 4)
{
Plane p1 = new Plane(pl1[0], pl1[1], pl1[2]);
Plane p2 = new Plane(pl2[0], pl2[1], pl2[2]);
if (Vector3d.VectorAngle(p1.Normal, p2.Normal) > Math.PI / 2) pl2.Reverse();
mesh.Append(mc.ClosedBridge(pl1, pl2));
}
}
A = mesh;
}
catch (Exception ex) { Print(ex.ToString()); }
}
示例15: RunScript
private void RunScript(Brep x, Curve y, int V, int U, ref object A)
{
Graphics g = Graphics.FromImage(bitmap1);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, u, v);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(Color.Black);
float step1 = u / U;
float step2 = v / V;
for (float i = 25; i < u - 25; i += step1)
{
for (float j = 25; j < v - 25; j += step2)
{
double Umin = x.Faces[0].Domain(0).Min;
double Umax = x.Faces[0].Domain(0).Max;
double Vmin = x.Faces[0].Domain(1).Min;
double Vmax = x.Faces[0].Domain(1).Max;
Point3d pos = x.Faces[0].PointAt(i / u * (Umax - Umin) + Umin, j / v * (Vmax - Vmin) + Vmin);
double t; float R;
if (y.ClosestPoint(pos, out t, 200))
{
double dis = y.PointAt(t).DistanceTo(pos);
dis /= 200;
R = (float)(1 / dis * 2);
// Print(R.ToString());
if (R > 40) R = 40;
;
}
else { R = 20; }
g.FillEllipse(myBrush, i - R, v - j - R, R * 2, R * 2);
}
}
myBrush.Dispose();
str = @"C:\maps\temp1.jpg";
bitmap1.Save(str);
Print(str);
///////////////////////////////////////////////////////////////////////////////////////////////////////
Mesh[] meshes = Mesh.CreateFromBrep(x, MeshingParameters.Smooth);
Mesh M = new Mesh();
foreach (Mesh partialMesh in meshes)
{
M.Append(partialMesh);
}
m_shapes.Add(M);
Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial();
mat.SetTransparencyTexture(str, true);
mat.BackTransparency = 0;
m_materials.Clear();
m_materials.Add(mat);
}