コード例 #1
0
        /// <summary>
        /// Aplies the slope in a determined FootPrintRoof.
        /// </summary>
        /// <param name="overhang">The overhang value.</param>
        /// <param name="slope">The slope of the roof</param>
        /// <param name="slopeDirection">The vector that represents the directions that the slope should be applied.</param>
        /// <param name="footPrintRoof">The Roof</param>
        /// <param name="footPrintToModelCurveMapping">The ModelCurveArray generated with the roof instance.</param>
        private static void ApplySlope(double overhang, double slope, XYZ slopeDirection, FootPrintRoof footPrintRoof, ModelCurveArray footPrintToModelCurveMapping)
        {
            ModelCurveArrayIterator iterator = footPrintToModelCurveMapping.ForwardIterator();

            iterator.Reset();

            while (iterator.MoveNext())
            {
                ModelCurve modelCurve     = iterator.Current as ModelCurve;
                Curve      curve          = modelCurve.GeometryCurve;
                XYZ        curveDirection = VectorManipulator.GetCurveDirection(curve);

                if (curveDirection.DotProduct(slopeDirection) == 0)
                {
                    footPrintRoof.set_DefinesSlope(modelCurve, true);
                    footPrintRoof.set_SlopeAngle(modelCurve, slope);
                }

                double elevation = -(overhang - UnitUtils.ConvertToInternalUnits(0.1, UnitTypeId.Meters)) / 3;
                footPrintRoof.set_Offset(modelCurve, elevation);
            }
        }
コード例 #2
0
        /// <summary>
        /// Create the gables walls of a building.
        /// </summary>
        /// <param name="vectorDirection">
        /// The gable walls will be construct at the walls that its normal
        /// vector is parallel with the vectorDirection.
        /// </param>
        /// <param name="slope">
        /// The slope of the gable, must match the slope of the roof.
        /// </param>
        public void CreateAllGableWalls(XYZ vectorDirection, double slope, CurveArray perimeter, List <Wall> gableWalls)
        {
            Polygon perimiterPolygon = new Polygon(perimeter);

            perimiterPolygon.Normalize();
            perimeter = perimiterPolygon.CurveArray;
            foreach (Curve line in perimeter)
            {
                XYZ lineDirection = VectorManipulator.GetCurveDirection(line);
                if (lineDirection.CrossProduct(vectorDirection).IsZeroLength())
                {
                    Wall newGableWall     = CreateGableWall(line, slope);
                    Wall intersectionWall = FindIntersectionWall(gableWalls, newGableWall);
                    bool insert           = true;
                    if (intersectionWall != null)
                    {
                        LocationCurve intersectionWallLocation = intersectionWall.Location as LocationCurve;
                        LocationCurve newGableWallLocation     = newGableWall.Location as LocationCurve;
                        Wall          deleteWall;

                        if (intersectionWallLocation.Curve.Length > newGableWallLocation.Curve.Length)
                        {
                            deleteWall = newGableWall;
                            insert     = false;
                        }
                        else
                        {
                            deleteWall = intersectionWall;
                        }
                        gableWalls.Remove(deleteWall);
                        document.Delete(deleteWall.Id);
                    }
                    if (insert)
                    {
                        gableWalls.Add(newGableWall);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Verifies if the curve is collinear and have atleast one point in common with any line in the given list of lines.
        /// </summary>
        /// <param name="curve">The curve that will be compared with the list.</param>
        /// <param name="lines">The list of lines that the first will be compared with.</param>
        /// <returns>Returns true if the curve intersects and is parallel to any line in the array.</returns>
        private bool VerifyIntersectionInArray(Curve curve, List <Line> lines)
        {
            Transform transform = Transform.CreateTranslation(new XYZ(0, 0, -curve.GetEndPoint(0).Z));

            curve = curve.CreateTransformed(transform);
            foreach (Line line in lines)
            {
                // verifiy is the line is equal or a subset of the curve
                SetComparisonResult result = line.Intersect(curve);
                if (result == SetComparisonResult.Equal ||
                    result == SetComparisonResult.Subset)
                {
                    return(true);
                }
                // verify if the line intersects and is parallel
                if (result == SetComparisonResult.Overlap && (line.Direction.CrossProduct(VectorManipulator.GetCurveDirection(curve)).IsZeroLength()))
                {
                    return(true);
                }
            }
            return(false);
        }