コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="parameter"></param>
        /// <param name="desiredOffset"></param>
        /// <param name="agents"></param>
        /// <returns></returns>
        internal double GetStateValue(tAgent[] agents, double parameter, double desiredOffset = 14.0)
        {
            int furtherAgentIndex = -1;
            int closerAgentIndex  = -1;

            GetFurtherIntersectionAtParameter(parameter, _faceIndexA, agents, out Geo.Point furtherIntersect, out Geo.Point closerIntersect, out furtherAgentIndex, out closerAgentIndex);

            Geo.Point edgeIntersectionA = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                                         HMDynamoUtil.DSLineToHMLine(agents[furtherAgentIndex]._edge),
                                                                         HMDynamoUtil.DSLineToHMLine(GetLinesAtParameter(agents, parameter)[0])
                                                                         ));

            double value1      = 1 * Math.Abs(desiredOffset - Math.Abs(furtherIntersect.DistanceTo(closerIntersect)));
            double outOfBounds = 0;

            double outOfBoundsA1 = furtherIntersect.DistanceTo(_faceSurfaceA);
            double outOfBoundsA2 = closerIntersect.DistanceTo(_faceSurfaceA);

            if (outOfBoundsA1 > _tolerance)
            {
                outOfBounds += 1000 * outOfBoundsA1;
            }
            if (outOfBoundsA2 > _tolerance)
            {
                outOfBounds += 100 * outOfBoundsA2;
            }



            double value2 = 0;

            if (!_isNaked)
            {
                GetFurtherIntersectionAtParameter(parameter, _faceIndexB, agents, out furtherIntersect, out closerIntersect, out furtherAgentIndex, out closerAgentIndex);

                Geo.Point edgeIntersectionB = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                                             HMDynamoUtil.DSLineToHMLine(agents[furtherAgentIndex]._edge),
                                                                             HMDynamoUtil.DSLineToHMLine(GetLinesAtParameter(agents, parameter)[1])
                                                                             ));

                value2 = 1 * Math.Abs(desiredOffset - Math.Abs(furtherIntersect.DistanceTo(closerIntersect)));

                double outOfBoundsB1 = furtherIntersect.DistanceTo(_faceSurfaceB);
                double outOfBoundsB2 = closerIntersect.DistanceTo(_faceSurfaceB);
                if (outOfBoundsB1 > _tolerance)
                {
                    outOfBounds += 1000 * outOfBoundsB1;
                }
                if (outOfBoundsB2 > _tolerance)
                {
                    outOfBounds += 100 * outOfBoundsB2;
                }
            }

            double value = (_isNaked) ? value1 + outOfBounds : new List <double> {
                value1, value2
            }.Sum() + outOfBounds;

            return(value);
        }
コード例 #2
0
        public static List <Member> CurvedMemberFromPolyline(List <Geo.Line> lines)
        {
            var HMLines      = lines.Select(l => HMDynamoUtil.DSLineToHMLine(l));
            var curvedMember = new HM.hCurvedMember(HMLines.ToList());

            return(curvedMember.Segments.Select(m => new Member(m)).ToList());
        }
コード例 #3
0
        internal void GetFurtherIntersectionAtParameter(double parameter, int faceIndex, tAgent[] agents, out Geo.Point furtherIntersect, out Geo.Point closerIntersect, out int furtherAgentIndex, out int closerAgentIndex)
        {
            var linesAtParameter = GetLinesAtParameter(agents, parameter);

            Geo.Point p;
            Geo.Point p2;
            if (faceIndex == _faceIndexA)
            {
                p = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                   HMDynamoUtil.DSLineToHMLine(linesAtParameter[0]),
                                                   HMDynamoUtil.DSLineToHMLine(agents[_neighborsA[0]].GetLine(_faceIndexA))
                                                   ));
                p2 = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                    HMDynamoUtil.DSLineToHMLine(linesAtParameter[0]),
                                                    HMDynamoUtil.DSLineToHMLine(agents[_neighborsA[1]].GetLine(_faceIndexA))
                                                    ));
            }
            else if (faceIndex == _faceIndexB)
            {
                p = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                   HMDynamoUtil.DSLineToHMLine(linesAtParameter[1]),
                                                   HMDynamoUtil.DSLineToHMLine(agents[_neighborsB[0]].GetLine(_faceIndexB))
                                                   ));
                p2 = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                    HMDynamoUtil.DSLineToHMLine(linesAtParameter[1]),
                                                    HMDynamoUtil.DSLineToHMLine(agents[_neighborsB[1]].GetLine(_faceIndexB))
                                                    ));
            }
            else
            {
                throw new System.ArgumentException("Invalid faceIndex for this agent", _name.ToString());
            }

            if (_edge.PointAtParameter(parameter).DistanceTo(p) > _edge.PointAtParameter(parameter).DistanceTo(p2))
            {
                furtherAgentIndex = (faceIndex == _faceIndexA) ? _neighborsA[0] : _neighborsB[0];
                closerAgentIndex  = (faceIndex == _faceIndexA) ? _neighborsA[1] : _neighborsB[1];
                furtherIntersect  = p;
                closerIntersect   = p2;
            }
            else
            {
                furtherAgentIndex = (faceIndex == _faceIndexA) ? _neighborsA[1] : _neighborsB[1];
                closerAgentIndex  = (faceIndex == _faceIndexA) ? _neighborsA[0] : _neighborsB[0];
                furtherIntersect  = p2;
                closerIntersect   = p;
            }
        }
コード例 #4
0
        /// <summary>
        /// Find the intersection with other two members of a given face that is further away from the agent
        /// </summary>
        /// <param name="faceIndex"></param>
        /// <param name="agents"></param>
        /// <returns></returns>
        internal Geo.Point GetFurtherIntersection(int faceIndex, tAgent[] agents)
        {
            Geo.Point p;
            Geo.Point p2;
            if (faceIndex == _faceIndexA)
            {
                p = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                   HMDynamoUtil.DSLineToHMLine(_lineA),
                                                   HMDynamoUtil.DSLineToHMLine(agents[_neighborsA[0]].GetLine(_faceIndexA))
                                                   ));
                p2 = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                    HMDynamoUtil.DSLineToHMLine(_lineA),
                                                    HMDynamoUtil.DSLineToHMLine(agents[_neighborsA[1]].GetLine(_faceIndexA))
                                                    ));
            }
            else if (faceIndex == _faceIndexB)
            {
                p = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                   HMDynamoUtil.DSLineToHMLine(_lineB),
                                                   HMDynamoUtil.DSLineToHMLine(agents[_neighborsB[0]].GetLine(_faceIndexB))
                                                   ));
                p2 = HMDynamoUtil.TripleToPoint(HowickMaker.hStructure.ClosestPointToOtherLine(
                                                    HMDynamoUtil.DSLineToHMLine(_lineB),
                                                    HMDynamoUtil.DSLineToHMLine(agents[_neighborsB[1]].GetLine(_faceIndexB))
                                                    ));
            }
            else
            {
                throw new System.ArgumentException("Invalid faceIndex for this agent", _name.ToString());
            }

            if (_edge.PointAtParameter(_currentParameter).DistanceTo(p) > _edge.PointAtParameter(_currentParameter).DistanceTo(p2))
            {
                return(p);
            }
            else
            {
                return(p2);
            }
        }