Ejemplo n.º 1
0
        private void offsetSegment(Segment seg, OffsetDir dir)
        {
            //simple version:
            XYZ vector = seg.OutsideRoomVector;

            if (dir == OffsetDir.Inward)
            {
                vector = vector.Negate();
            }

            // see online help for Curve.CreateOffset.
            // we don't specify the direction, we specify the up direction so that the curve is offset to the right.

            Transform t       = seg.Curve.ComputeDerivatives(0.5, true);
            XYZ       forward = t.BasisX;
            XYZ       cross   = vector.CrossProduct(forward).Normalize();

            // then use the cross product (presumably up or down) as the reference vector

            seg.Curve = seg.Curve.CreateOffset(seg.Thickness / 2.0, cross);
        }
Ejemplo n.º 2
0
        private void adjustByRules(RoomObject ro)
        {
            // remove any column type boundaries
            var columns = ro.Boundaries.Where(b => b.ElementType == "Columns").ToList();

            foreach (var col in columns)
            {
                ro.Boundaries.Remove(col);
            }

            bool isCorridor = (ro.Name.ToUpper().Contains("CORR"));

            if (isCorridor)
            {
                ignoreRoom(ro);
                return;
            }

            // go through the boundaries and offset.
            foreach (var seg in ro.Boundaries)
            {
                if (isCorridor)
                {
                    // we skip it unless it doesn't have an opposite
                    if (seg.OppositeRoom != null)
                    {
                        continue;
                    }
                }

                OffsetDir offset = OffsetDir.None;
                // determine whether to offset inwards, outwards, or leave
                if (seg.IsExterior)
                {
                    if (seg.WallKind != WallKind.Curtain)
                    {
                        offset = OffsetDir.Inward;
                    }
                }
                else
                {
                    // compare against an opposite room
                    if (seg.OppositeRoom != null)
                    {
                        if (seg.OppositeRoom.Score > ro.Score)
                        {
                            offset = OffsetDir.Inward;
                        }
                        if (seg.OppositeRoom.Score < ro.Score)
                        {
                            offset = OffsetDir.Outward;
                        }
                    }
                }


                // offset the segment:
                if (offset != OffsetDir.None)
                {
                    offsetSegment(seg, offset);
                }
            }
        }