예제 #1
0
        /**
         * Sets an end as edge (starting point if none end were defined, ending point otherwise)
         *
         * @param vertex1 one of the vertices of the intercepted edge
         * @param vertex2 one of the vertices of the intercepted edge
         * @return false if all ends were already defined, true otherwise
         */
        private bool SetEdge(Vertex vertex1, Vertex vertex2)
        {
            Vector3 point1        = vertex1.GetPosition();
            Vector3 point2        = vertex2.GetPosition();
            Vector3 edgeDirection = new Vector3(point2.x - point1.x, point2.y - point1.y, point2.z - point1.z);
            Line    edgeLine      = new Line(edgeDirection, point1);

            if (index == 0)
            {
                startVertex = vertex1;
                startType   = EDGE;
                startPos    = line.ComputeLineIntersection(edgeLine);
                StartDist   = line.ComputePointToPointDistance(startPos);
                middleType  = FACE;
                index++;
                return(true);
            }
            else if (index == 1)
            {
                endVertex  = vertex1;
                endType    = EDGE;
                endPos     = line.ComputeLineIntersection(edgeLine);
                endDist    = line.ComputePointToPointDistance(endPos);
                middleType = FACE;
                index++;

                //the ending point distance should be smaller than  starting point distance
                if (StartDist > endDist)
                {
                    SwapEnds();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /**
         * Sets an end as edge (starting point if none end were defined, ending point otherwise)
         *
         * @param vertex1 one of the vertices of the intercepted edge
         * @param vertex2 one of the vertices of the intercepted edge
         * @return false if all ends were already defined, true otherwise
         */
        private bool SetEdge(Vertex vertex1, Vertex vertex2)
        {
            Vector3d point1        = vertex1.Position;
            Vector3d point2        = vertex2.Position;
            Vector3d edgeDirection = new Vector3d(point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z);
            Line     edgeLine      = new Line(edgeDirection, point1);

            if (_Index == 0)
            {
                _StartVertex = vertex1;
                _StartType   = EDGE;
                _StartPos    = Line.ComputeLineIntersection(edgeLine);
                StartDist    = Line.ComputePointToPointDistance(_StartPos);
                _MiddleType  = FACE;
                _Index++;
                return(true);
            }
            else if (_Index == 1)
            {
                _EndVertex  = vertex1;
                _EndType    = EDGE;
                _EndPos     = Line.ComputeLineIntersection(edgeLine);
                _EndDist    = Line.ComputePointToPointDistance(_EndPos);
                _MiddleType = FACE;
                _Index++;

                //the ending point distance should be smaller than  starting point distance
                if (StartDist > _EndDist)
                {
                    SwapEnds();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// 设交线的结束点在平面的边上;
        /// 如果没有指定过结束点,就指定起点在边上,否则指定结束点在边上
        /// </summary>
        /// <param name="vertex1">交线线段的其中一点</param>
        /// <param name="vertex2">交线线段的其中一点</param>
        /// <returns></returns>
        private bool SetEdge(Vertex vertex1, Vertex vertex2)
        {
            Vector3Double point1        = vertex1.Position;
            Vector3Double point2        = vertex2.Position;
            Vector3Double edgeDirection = new Vector3Double(point2.x - point1.x, point2.y - point1.y, point2.z - point1.z);
            Line          edgeLine      = new Line(edgeDirection, point1);

            if (NumEndsSet == 0)
            {
                StartVertex      = vertex1;
                StartType        = EDGE;
                StartPosition    = line.ComputeLineIntersection(edgeLine);
                StartDistance    = line.ComputePointToPointDistance(StartPosition);
                IntermediateType = FACE;
                NumEndsSet++;
                return(true);
            }
            else if (NumEndsSet == 1)
            {
                EndVertex        = vertex1;
                EndType          = EDGE;
                EndPosition      = line.ComputeLineIntersection(edgeLine);
                EndDistance      = line.ComputePointToPointDistance(EndPosition);
                IntermediateType = FACE;
                NumEndsSet++;

                //the ending point distance should be smaller than  starting point distance
                if (StartDistance > EndDistance)
                {
                    SwapEnds();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// Sets an end as edge (starting point if none end were defined, ending point otherwise)
        /// </summary>
        /// <param name="vertex1"></param>
        /// <param name="vertex2"></param>
        /// <returns>false if all ends were already defined, true otherwise</returns>
        private bool SetEdge(Vertex vertex1, Vertex vertex2)
        {
            Vector3 edgeDirection = vertex2.Position - vertex1.Position;
            Line    edgeLine      = new Line(edgeDirection, vertex1.Position);

            if (index == 0)
            {
                StartVertex   = vertex1;
                StartType     = SegmentEnd.Edge;
                StartPosition = line.ComputeLineIntersection(edgeLine);
                StartDistance = line.ComputePointToPointDistance(StartPosition);
                MiddleType    = SegmentEnd.Face;
                index++;
                return(true);
            }
            else if (index == 1)
            {
                EndVertex   = vertex1;
                EndType     = SegmentEnd.Edge;
                EndPosition = line.ComputeLineIntersection(edgeLine);
                EndDistance = line.ComputePointToPointDistance(EndPosition);
                MiddleType  = SegmentEnd.Face;
                index++;

                //the ending point distance should be smaller than  starting point distance
                if (StartDistance > EndDistance)
                {
                    SwapEnds();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }