Ejemplo n.º 1
0
 public static bool ContainsListPair(List <TopoEdgePair> list, TopoEdge a, TopoEdge b)
 {
     foreach (TopoEdgePair pair in list)
     {
         if (pair.ContainsEdgePair(a, b))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public List <TopoEdge> FindNeighbourEdgesWithOneFace()
        {
            List <TopoEdge> list     = null;
            TopoTriangle    thisFace = faces.First.Value;

            foreach (TopoTriangle face in v1.connectedFacesList)
            {
                if (face == thisFace)
                {
                    continue;
                }
                for (int e = 0; e < 3; e++)
                {
                    TopoEdge testEdge = face.edges[e];
                    if (testEdge.connectedFaces != 1)
                    {
                        continue;
                    }
                    if (testEdge.ContainsVertex(v1))
                    {
                        if (list == null)
                        {
                            list = new List <TopoEdge>();
                        }
                        list.Add(testEdge);
                    }
                }
            }
            foreach (TopoTriangle face in v2.connectedFacesList)
            {
                if (face == thisFace)
                {
                    continue;
                }
                for (int e = 0; e < 3; e++)
                {
                    TopoEdge testEdge = face.edges[e];
                    if (testEdge.connectedFaces != 1)
                    {
                        continue;
                    }
                    if (testEdge.ContainsVertex(v2))
                    {
                        if (list == null)
                        {
                            list = new List <TopoEdge>();
                        }
                        list.Add(testEdge);
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 3
0
        public void FlipDirection()
        {
            normal.Scale(-1);
            TopoVertex v = vertices[0];

            vertices[0] = vertices[1];
            vertices[1] = v;
            TopoEdge e = edges[1];

            edges[1] = edges[2];
            edges[2] = e;
        }
Ejemplo n.º 4
0
        public double alphaBeta; // Sum of dihedral angles to a virtual shared triangle

        public TopoEdgePair(TopoEdge _edgeA, TopoEdge _edgeB)
        {
            edgeA = _edgeA;
            edgeB = _edgeB;
            RHVector3 sharedPoint = null;
            RHVector3 p1 = null, p2 = null;

            if (edgeA.v1 == edgeB.v1)
            {
                sharedPoint = edgeA.v1.pos;
                p1          = edgeA.v2.pos;
                p2          = edgeB.v2.pos;
            }
            else if (edgeA.v1 == edgeB.v2)
            {
                sharedPoint = edgeA.v1.pos;
                p1          = edgeA.v2.pos;
                p2          = edgeB.v1.pos;
            }
            else if (edgeA.v2 == edgeB.v1)
            {
                sharedPoint = edgeA.v1.pos;
                p1          = edgeA.v1.pos;
                p2          = edgeB.v2.pos;
            }
            else if (edgeA.v2 == edgeB.v2)
            {
                sharedPoint = edgeA.v2.pos;
                p1          = edgeA.v1.pos;
                p2          = edgeB.v1.pos;
            }
            RHVector3 d1     = p1.Subtract(sharedPoint);
            RHVector3 d2     = p2.Subtract(sharedPoint);
            RHVector3 normal = d1.CrossProduct(d2);

            normal.NormalizeSafe();
            alphaBeta = normal.AngleForNormalizedVectors(edgeA.faces.First.Value.normal) + normal.AngleForNormalizedVectors(edgeB.faces.First.Value.normal);
            if (alphaBeta > Math.PI) // normal was wrong direction
            {
                alphaBeta = 2 * Math.PI - alphaBeta;
            }
        }
Ejemplo n.º 5
0
        public TopoEdge CommonThirdEdge()
        {
            TopoVertex v1 = edgeA.v1;

            if (edgeB.v1 == v1 || edgeB.v2 == v1)
            {
                v1 = edgeA.v2;
            }
            TopoVertex v2 = edgeB.v1;

            if (edgeA.v1 == v2 || edgeA.v2 == v2)
            {
                v2 = edgeB.v2;
            }
            foreach (TopoTriangle t in v1.connectedFacesList)
            {
                TopoEdge e = t.EdgeWithVertices(v1, v2);
                if (e != null)
                {
                    return(e);
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
 public bool ContainsEdgePair(TopoEdge a, TopoEdge b)
 {
     return(ContainsEdge(a) && ContainsEdge(b));
 }
Ejemplo n.º 7
0
 public bool ContainsEdge(TopoEdge edge)
 {
     return(edgeA == edge || edgeB == edge);
 }