当前位置: 首页>>代码示例>>C#>>正文


C# GraphicResearchHuiZhao.TriMesh类代码示例

本文整理汇总了C#中GraphicResearchHuiZhao.TriMesh的典型用法代码示例。如果您正苦于以下问题:C# TriMesh类的具体用法?C# TriMesh怎么用?C# TriMesh使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TriMesh类属于GraphicResearchHuiZhao命名空间,在下文中一共展示了TriMesh类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateHodgeStar

        public void UpdateHodgeStar(TriMesh mesh)
        {
            foreach (TriMesh.Edge edge in mesh.Edges)
            {
                double sum = 0;

                TriMesh.HalfEdge currentHe = edge.HalfEdge0;
                do
                {
                    Vector3D a = currentHe.FromVertex.Traits.Position;
                    Vector3D b = currentHe.Next.FromVertex.Traits.Position;
                    Vector3D c = currentHe.Next.Next.FromVertex.Traits.Position;

                    Vector3D u = a - c;
                    Vector3D v = b - c;

                    double cotTheta = (u.Dot(v)) / u.Cross(v).Length();

                    sum += 0.5 * cotTheta;

                } while (currentHe != edge.HalfEdge0);

                EdgeHodgeStar1[edge.Index] = Math.Max(sum, 0);

            }


        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:28,代码来源:PriorNonTrivalConnection.cs

示例2: GrowByFaceAngle

        public static void GrowByFaceAngle(TriMesh mesh)
        {
            Queue<TriMesh.Face> queue = new Queue<HalfEdgeMesh.Face>();
            Vector3D[] normal = TriMeshUtil.ComputeNormalFace(mesh);
            foreach (var face in mesh.Faces)
            {
                if (face.Traits.SelectedFlag != 0)
                {
                    queue.Enqueue(face);
                }
            }

            double k = 0.449;
            while (queue.Count != 0)
            {
                TriMesh.Face center = queue.Dequeue();
                foreach (var round in center.Faces)
                {
                    if (round.Traits.SelectedFlag == 0)
                    {
                        if (normal[center.Index].Dot(normal[round.Index]) > k)
                        {
                            round.Traits.SelectedFlag = center.Traits.SelectedFlag;
                            queue.Enqueue(round);
                        }
                    }
                }
            }
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:29,代码来源:SegementationGrow.cs

示例3: KMean

        public static void KMean(TriMesh mesh)
        {
            Dictionary<int, Cluster> dict = new Dictionary<int, Cluster>();
            Queue<TriMesh.Face> queue = new Queue<HalfEdgeMesh.Face>();
            foreach (var face in mesh.Faces)
            {
                if (face.Traits.SelectedFlag != 0)
                {
                    dict[face.Traits.SelectedFlag] = new Cluster();
                    dict[face.Traits.SelectedFlag].Add(TriMeshUtil.GetMidPoint(face));
                    queue.Enqueue(face);
                }
            }

            while (queue.Count != 0)
            {
                TriMesh.Face center = queue.Dequeue();
                foreach (var round in center.Faces)
                {
                    if (round.Traits.SelectedFlag == 0)
                    {
                        int index = GetNearest(round, dict);
                        dict[index].Add(TriMeshUtil.GetMidPoint(round));
                        round.Traits.SelectedFlag = (byte)index;
                        queue.Enqueue(round);
                    }
                }
            }
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:29,代码来源:SegementationGrow.cs

示例4: AddSelectionVertex

         public TriMesh AddSelectionVertex(TriMesh mesh, int index)
         {
             List<TriMesh> sel = new List<TriMesh>();
             for(int i=0;i<mesh.Vertices.Count;i++)
             {

                 if (mesh.Vertices[i].Traits.SelectedFlag == index)
                 {

                     TriMesh selV = TriMeshIO.FromObjFile(ConfigShape.Instance.VertexFile);
                     for (int j = 0; j < selV.Vertices.Count;j++ )
                     {
                         selV.Vertices[j].Traits.SelectedFlag =(byte)index;
                     }
                         TriMeshUtil.ScaleToUnit(selV, ConfigShape.Instance.Scale);
                     TriMeshUtil.TransformationMove(selV, mesh.Vertices[i].Traits.Position);
                     sel.Add(selV);
                 }
                
             }

            TriMesh result= TriMeshUtil.Combine(sel);
            result.FileName = Path.GetFileNameWithoutExtension(mesh.FileName) + "-V-" + index.ToString();

            TriMeshUtil.SetUpVertexNormal(result, EnumNormal.AreaWeight);
             return result;
         }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:27,代码来源:TriMeshShapeSelection.cs

示例5: Move

 public static void Move(TriMesh mesh, Vector3D vec)
 {
     foreach (var v in mesh.Vertices)
     {
         v.Traits.Position += vec;
     }
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:7,代码来源:TriMeshInverse.cs

示例6: DrawColor

        public void DrawColor(TriMesh mesh)
        {
            GL.Enable(EnableCap.ColorMaterial);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.Enable(EnableCap.Normalize);

            GL.Begin(BeginMode.Triangles);
            for (int i = 0; i < mesh.Faces.Count; i++)
            {


                foreach (TriMesh.Vertex vertex in mesh.Faces[i].Vertices)
                {

                    GL.Color3(vertex.Traits.Color.R, vertex.Traits.Color.G, vertex.Traits.Color.B);

                    GL.Normal3(vertex.Traits.Normal.x,
                               vertex.Traits.Normal.y,
                               vertex.Traits.Normal.z);
                    GL.Vertex3(vertex.Traits.Position.x,
                               vertex.Traits.Position.y,
                               vertex.Traits.Position.z);

                }
            }
            GL.End();

        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:29,代码来源:OpenGLTriMeshDistance.cs

示例7: DrawMultiTextureUV

        private static void DrawMultiTextureUV(TriMesh mesh)
        {
            GL.Begin(BeginMode.Triangles);
            for (int i = 0; i < mesh.Faces.Count; i++)
            {
                foreach (TriMesh.Vertex vertex in mesh.Faces[i].Vertices)
                {
                    GL.Normal3(vertex.Traits.Normal.x, 
                               vertex.Traits.Normal.y, 
                               vertex.Traits.Normal.z); 

                    GL.MultiTexCoord2(TextureUnit.Texture0, 
                                      vertex.Traits.UV[0], 
                                      vertex.Traits.UV[1]);
                    GL.MultiTexCoord2(TextureUnit.Texture1, 
                                      vertex.Traits.UV[0], 
                                      vertex.Traits.UV[1]); 
                    
                    GL.Vertex3(vertex.Traits.Position.x, 
                               vertex.Traits.Position.y, 
                               vertex.Traits.Position.z);
                }
            }
            GL.End();
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:25,代码来源:OpenGLTriMeshTexture.cs

示例8: Split

        public static void Split(TriMesh mesh, EdgeContext ctx)
        {
            TriMesh.Vertex left = null;
            TriMesh.Vertex top = null;
            TriMesh.Vertex bottom = null;

            foreach (var v in mesh.Vertices)
            {
                if (v.Index == ctx.Left)
                {
                    left = v;
                }
                else if (v.Index == ctx.Top)
                {
                    top = v;
                }
                else if (v.Index == ctx.Bottom)
                {
                    bottom = v;
                }
            }

            TriMesh.Vertex right = TriMeshModify.VertexSplit(left, top, bottom, ctx.LeftPos, ctx.RightPos);
            TriMesh.HalfEdge hf = left.FindHalfedgeTo(right);
            right.Index = ctx.Right;
            hf.Next.ToVertex.Index = ctx.Top;
            hf.Opposite.Next.ToVertex.Index = ctx.Bottom;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:28,代码来源:SplitVertex.cs

示例9: ComputePrincipalCurvature

 public PrincipalCurvature ComputePrincipalCurvature(TriMesh.Vertex v)
 {
     Vector3D sum = Vector3D.Zero;
     Vector3D mid = v.Traits.Position;
     foreach (var hf in v.HalfEdges)
     {
         Vector3D buttom = hf.ToVertex.Traits.Position;
         Vector3D left = hf.Opposite.Next.ToVertex.Traits.Position;
         Vector3D right = hf.Next.ToVertex.Traits.Position;
         double cota = (mid - left).Dot(buttom - left) / (mid - left).Cross(buttom - left).Length();
         double cotb = (mid - right).Dot(buttom - right) / (mid - right).Cross(buttom - right).Length();
         sum += (cota + cotb) * (this.Normal[v.Index] - this.Normal[hf.ToVertex.Index]);
     }
     double mixedArea = TriMeshUtil.ComputeAreaMixed(v);
     Vector3D laplace = sum / mixedArea / 2d;
     double square = -laplace.Dot(this.Normal[v.Index]);
     double k = this.K[v.Index].Length();
     double delta = -k * k + 2d * square;
     if (delta < 0d)
     {
         delta = 0d;
     }
     PrincipalCurvature pc = new PrincipalCurvature();
     pc.max = (k + Math.Pow(delta, 0.5)) / 2d;
     pc.min = (k - Math.Pow(delta, 0.5)) / 2d;
     return pc;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:27,代码来源:CurvatureWithPG07.cs

示例10: SmoothTaubin

 public static void SmoothTaubin(TriMesh Mesh)
 {
     double weight =  ConfigMeshOP.Instance.SmoothTaubinLamda;
     int iterative = ConfigMeshOP.Instance.SmoothTaubinIterative;
     bool cot=ConfigMeshOP.Instance.SmoothTaubinCot;
     int n = Mesh.Vertices.Count;  
     double[][] lap =null; 
     for (int j = 0; j < iterative; j++)
     {
         if (cot)
         {
             lap = LaplaceManager.Instance.ComputeLaplacianCotNormalize(Mesh);
         }
         else
         {
             lap = LaplaceManager.Instance.ComputeLaplacianUniform(Mesh);
         }
         for (int i = 0; i < n; i++)
         {
            Mesh.Vertices[i].Traits.Position.x += lap[0][i] * weight;
            Mesh.Vertices[i].Traits.Position.y += lap[1][i] * weight;
            Mesh.Vertices[i].Traits.Position.z += lap[2][i] * weight;
         }
     } 
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:25,代码来源:TriMeshSmooth.cs

示例11: cBuildExteriorDerivative1Form

        public SparseMatrixComplex cBuildExteriorDerivative1Form(TriMesh mesh)
        {
            SparseMatrixComplex d1 = new SparseMatrixComplex(mesh.Faces.Count, mesh.Edges.Count);

            foreach (TriMesh.Face face in mesh.Faces)
            {
                foreach (TriMesh.HalfEdge hf in face.Halfedges)
                {
                    double s = 0;

                    if (hf.Edge.HalfEdge0 == hf)
                    {
                        s = -1;
                    }
                    else
                    {
                        s = 1;
                    }

                    d1[face.Index, hf.Edge.Index] = new Complex(s, 0);
                }
            }

            return d1;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:25,代码来源:DECMeshComplex.cs

示例12: Init

        public static void Init(TriMesh mesh)
        {
            nv = mesh.Vertices.Count;
            TriMeshIO.WriteToObjFile(FileName, mesh);

            FromObjFile(mesh.FileName);
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:7,代码来源:TriMeshCurvature.cs

示例13: Clone

        public static TriMesh Clone(TriMesh mesh)
        {
            TriMesh newMesh = new TriMesh();
            for (int i = 0; i < mesh.Vertices.Count; i++)
            {
                VertexTraits traits = new VertexTraits(mesh.Vertices[i].Traits.Position.x,
                                                       mesh.Vertices[i].Traits.Position.y,
                                                       mesh.Vertices[i].Traits.Position.z);
                newMesh.Vertices.Add(traits);
            }

            TriMesh.Vertex[] faceVetices = new TriMesh.Vertex[3];
            for (int i = 0; i < mesh.Faces.Count; i++)
            {
                int faceVertexIndex1 = mesh.Faces[i].GetVertex(0).Index;
                int faceVertexIndex2 = mesh.Faces[i].GetVertex(1).Index;
                int faceVertexIndex3 = mesh.Faces[i].GetVertex(2).Index;

                faceVetices[0] = newMesh.Vertices[faceVertexIndex1];
                faceVetices[1] = newMesh.Vertices[faceVertexIndex2];
                faceVetices[2] = newMesh.Vertices[faceVertexIndex3];
                newMesh.Faces.AddTriangles(faceVetices);
            }
            newMesh.TrimExcess();
            return newMesh;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:26,代码来源:TriMeshIO.cs

示例14: ComputeFunction

 public double[] ComputeFunction(TriMesh mesh)
 {
     SparseMatrix sparse = BuildMatrixA(mesh);
     double[] rightB = BuildRightB(mesh); 
     double[] unknownX = LinearSystem.Instance.SolveSystem(ref sparse, ref rightB, mesh.FileName);
     return unknownX;
 }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:7,代码来源:FunctionSmoothedCurvature.cs

示例15: CreateNBsplineCurve

        public  TriMesh CreateNBsplineCurve(TriMesh mesh)
        {
            TriMesh BezierCurve = new TriMesh();
            double x = 0;
            double y = 0;
            double z = 0;

            for (int i = 0; i < Point - 2; i++)
            {
                for (int t = 0; t <= VerticesNum; t++)
                {
                    double tt = (double)t / (double)VerticesNum;
                    //x = (double)1 / 6 * ((-Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) - 3 * tt + 1)) * mesh.Vertices[0].Traits.Position.x
                    //    + (double)1 / 6 * ((3 * Math.Pow(tt, 3) - 6 * Math.Pow(tt, 2) + 4)) * mesh.Vertices[1].Traits.Position.x
                    //    + (double)1 / 6 * ((-3 * Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) + 3 * tt + 1)) * mesh.Vertices[2].Traits.Position.x
                    //    + (double)1 / 6 * Math.Pow(tt, 3) * mesh.Vertices[3].Traits.Position.x;
                    //y = (double)1 / 6 * ((-Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) - 3 * tt + 1)) * mesh.Vertices[0].Traits.Position.y
                    //    + (double)1 / 6 * ((3 * Math.Pow(tt, 3) - 6 * Math.Pow(tt, 2) + 4)) * mesh.Vertices[1].Traits.Position.y
                    //    + (double)1 / 6 * ((-3 * Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) + 3 * tt + 1)) * mesh.Vertices[2].Traits.Position.y
                    //    + (double)1 / 6 * Math.Pow(tt, 3) * mesh.Vertices[3].Traits.Position.y;
                    x = (double)1 / 6 * ((-Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) - 3 * tt + 1)) * mesh.Vertices[i].Traits.Position.x
                        + (double)1 / 6 * ((3 * Math.Pow(tt, 3) - 6 * Math.Pow(tt, 2) + 4)) * mesh.Vertices[i + 1].Traits.Position.x
                        + (double)1 / 6 * ((-3 * Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) + 3 * tt + 1)) * mesh.Vertices[i + 2].Traits.Position.x
                        + (double)1 / 6 * Math.Pow(tt, 3) * mesh.Vertices[i + 3].Traits.Position.x;
                    y = (double)1 / 6 * ((-Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) - 3 * tt + 1)) * mesh.Vertices[i].Traits.Position.y
                       + (double)1 / 6 * ((3 * Math.Pow(tt, 3) - 6 * Math.Pow(tt, 2) + 4)) * mesh.Vertices[i + 1].Traits.Position.y
                       + (double)1 / 6 * ((-3 * Math.Pow(tt, 3) + 3 * Math.Pow(tt, 2) + 3 * tt + 1)) * mesh.Vertices[i + 2].Traits.Position.y
                       + (double)1 / 6 * Math.Pow(tt, 3) * mesh.Vertices[i + 3].Traits.Position.y;
                    BezierCurve.Vertices.Add(new VertexTraits(x, y, z));
                    x = 0;
                    y = 0;
                }
            }
            return BezierCurve;
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:35,代码来源:CurveBSpline.cs


注:本文中的GraphicResearchHuiZhao.TriMesh类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。