示例#1
0
        public void GetParameter()
        {
            BezierSegment1F b = new BezierSegment1F()
            {
                Point1        = 1,
                ControlPoint1 = 3,
                ControlPoint2 = 4,
                Point2        = 8,
            };

            Assert.IsTrue(Numeric.AreEqual(0, CurveHelper.GetParameter(b, 1, 100)));
            Assert.IsTrue(Numeric.AreEqual(1, CurveHelper.GetParameter(b, 8, 100)));
            Assert.IsTrue(Numeric.AreEqual(0.3f, CurveHelper.GetParameter(b, b.GetPoint(0.3f), 100)));
            Assert.IsTrue(Numeric.AreEqual(0.4f, CurveHelper.GetParameter(b, b.GetPoint(0.4f), 100)));
            Assert.IsTrue(Numeric.AreEqual(0.5f, CurveHelper.GetParameter(b, b.GetPoint(0.5f), 100)));
            Assert.IsTrue(Numeric.AreEqual(0.6f, CurveHelper.GetParameter(b, b.GetPoint(0.6f), 100)));
            Assert.IsTrue(Numeric.AreEqual(0.9f, CurveHelper.GetParameter(b, b.GetPoint(0.9f), 100)));

            Assert.IsFalse(Numeric.AreEqual(0.9f, CurveHelper.GetParameter(b, b.GetPoint(0.9f), 1))); // limited iterations.

            for (int i = 0; i < 1000; i++)
            {
                float u     = RandomHelper.Random.NextFloat(0, 1);
                float point = b.GetPoint(u);
                Assert.IsTrue(Numeric.AreEqual(u, CurveHelper.GetParameter(b, point, 100)));
            }

            for (int i = 0; i < 1000; i++)
            {
                float u     = RandomHelper.Random.NextFloat(0, 1);
                float point = b.GetPoint(u);
                Assert.IsTrue(Numeric.AreEqual(u, CurveHelper.GetParameter(b, point, 100), 0.01f));
            }
        }
示例#2
0
        public void GetCurveDescriptionFromEcParam()
        {
            var result = CurveHelper.GetCurveDescriptionFromEcParam("06092b2403030208010109");

            Assert.That(result, Contains.Substring("brainpoolP320r1"));
            Assert.That(result, Contains.Substring("320 bit"));
            Assert.That(result, Is.EqualTo("brainpoolP320r1 (320 bit)"));
        }
示例#3
0
    IEnumerator LaunchCameraZoom(Transform target_transform, Camera _camera_component, ShakeCounter counter)
    {
        float prev_value = _camera_component.orthographicSize;

        yield return(StartCoroutine(CurveHelper.LaunchCurveApply(cameras_zoom_curve, (time, val) => {
            _camera_component.orthographicSize = Mathf.Lerp(0f, prev_value, val);
        }, time_ratio)));

        _camera_component.orthographicSize = prev_value;
        counter._transformations_number--;
    }
示例#4
0
        void GenerateTrajectory()
        {
            float z = -Camera.main.transform.position.z;

            positions.Add(Camera.main.ViewportToWorldPoint(new Vector3(Rand.Range(edgeX, 1 - edgeX), 0.65f, z)));
            positions.Add(Camera.main.ViewportToWorldPoint(new Vector3(Rand.Range(edgeX, 1 - edgeX), 0.33f, z)));
            positions.Add(Camera.main.ViewportToWorldPoint(new Vector3(Rand.Range(edgeX, 1 - edgeX), -edgeY, z)));
            float distance = CurveHelper.GetPathLength(positions.ToArray());

            time      = 0;
            totalTime = distance / speed;
        }
示例#5
0
    IEnumerator LaunchMoveY(Transform target_transform, ShakeCounter counter)
    {
        float prev_delta = 0;

        yield return(StartCoroutine(CurveHelper.LaunchCurveApply(pos_y_curve, (time, val) => {
            float delta = (Random.Range(-random_pos_y, random_pos_y) + val) * value_ratio;
            target_transform.position = new Vector3(target_transform.position.x, target_transform.position.y - prev_delta + delta, target_transform.position.z);
            prev_delta = delta;
        }, time_ratio)));

        target_transform.position = new Vector3(target_transform.position.x, target_transform.position.y - prev_delta, target_transform.position.z);
        counter._transformations_number--;
    }
示例#6
0
    IEnumerator LaunchScaleX(Transform target_transform, ShakeCounter counter)
    {
        float prev_delta = 0;

        yield return(StartCoroutine(CurveHelper.LaunchCurveApply(scale_x_curve, (time, val) => {
            float delta = (Random.Range(-random_scale_x, random_scale_x) + val) * value_ratio;
            target_transform.localScale = new Vector3(target_transform.localScale.x - prev_delta + delta, target_transform.localScale.y, target_transform.localScale.z);
            prev_delta = delta;
        }, time_ratio)));

        target_transform.localScale = new Vector3(target_transform.localScale.x - prev_delta, target_transform.localScale.y, target_transform.localScale.z);
        counter._transformations_number--;
    }
示例#7
0
    IEnumerator LaunchRotate(Transform target_transform, ShakeCounter counter)
    {
        float prev_delta = 0;

        yield return(StartCoroutine(CurveHelper.LaunchCurveApply(angle_curve, (time, val) => {
            float delta = (Random.Range(-random_angle, random_angle) + val) * value_ratio;
            target_transform.localEulerAngles = new Vector3(target_transform.localEulerAngles.x, target_transform.localEulerAngles.y, target_transform.localEulerAngles.z - prev_delta + delta);
            prev_delta = delta;
        }, time_ratio)));

        target_transform.localEulerAngles = new Vector3(target_transform.localEulerAngles.x, target_transform.localEulerAngles.y, target_transform.localEulerAngles.z - prev_delta);
        counter._transformations_number--;
    }
示例#8
0
        public void GetLengthOfLineSegments3F()
        {
            var points = new[]
            {
                new Vector3(1, 2, 0.123f), new Vector3(12, 13, 123),
                new Vector3(1231, 2.2f, 0.123f), new Vector3(5, 122, 123),
                new Vector3(-11, 2, 0.123f), new Vector3(-1, 123, 123),
                new Vector3(-123.123f, 122, 0.123f), new Vector3(-2312, -123, 123),
            };
            var length = (points[1] - points[0]).Length
                         + (points[3] - points[2]).Length
                         + (points[5] - points[4]).Length
                         + (points[7] - points[6]).Length;

            Assert.AreEqual(length, CurveHelper.GetLength(points.ToList()));
        }
示例#9
0
        public void Flatten()
        {
            var s = new ArcSegment2F
            {
                Point1 = new Vector2F(1, 2),
                Point2 = new Vector2F(10, -3),
            };
            var points    = new List <Vector2F>();
            var tolerance = 1f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(Vector2F.AreNumericallyEqual(points[0], s.Point1));
            Assert.IsTrue(Vector2F.AreNumericallyEqual(points.Last(), s.Point2));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance * points.Count / 2);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
        public void Flatten()
        {
            var s = new BSplineSegment2F
            {
                Point1 = new Vector2F(1, 2),
                Point2 = new Vector2F(4, 5),
                Point3 = new Vector2F(7, 8),
                Point4 = new Vector2F(10, 12),
            };
            var points    = new List <Vector2F>();
            var tolerance = 0.01f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(points.Contains(s.GetPoint(0)));
            Assert.IsTrue(points.Contains(s.GetPoint(1)));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
示例#11
0
        public void Flatten()
        {
            var s = new BezierSegment2F
            {
                Point1        = new Vector2F(1, 2),
                ControlPoint1 = new Vector2F(4, 5),
                ControlPoint2 = new Vector2F(7, 8),
                Point2        = new Vector2F(10, 2),
            };
            var points    = new List <Vector2F>();
            var tolerance = 0.01f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(points.Contains(s.Point1));
            Assert.IsTrue(points.Contains(s.Point2));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance * points.Count / 2);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
        public void Flatten()
        {
            var s = new HermiteSegment3F
            {
                Point1   = new Vector3F(1, 2, 3),
                Tangent1 = (new Vector3F(10, 3, 6) - new Vector3F(1, 2, 3)) * 3,
                Tangent2 = (new Vector3F(10, 2, 12) - new Vector3F(7, 8, 19)) * 3,
                Point2   = new Vector3F(10, 2, 12),
            };
            var points    = new List <Vector3F>();
            var tolerance = 0.01f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(points.Contains(s.Point1));
            Assert.IsTrue(points.Contains(s.Point2));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance * points.Count / 2);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
        public void Flatten()
        {
            var s = new CatmullRomSegment3F
            {
                Point1 = new Vector3(1, 2, 3),
                Point2 = new Vector3(10, 3, 6),
                Point3 = new Vector3(7, 8, 19),
                Point4 = new Vector3(10, 2, 12),
            };
            var points    = new List <Vector3>();
            var tolerance = 0.01f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(points.Contains(s.Point2));
            Assert.IsTrue(points.Contains(s.Point3));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance * points.Count / 2);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
示例#14
0
    void Update()
    {
        if (timer > 0)
        {
            float animPercent = 1.0f - ((float)timer / (float)animationTime);
            if (timer - 1 == 0)
            {
                animPercent = 1f;
            }

            // -- type
            if (animationType == AnimationConstants.QUADRATIC_ANIM_TYPE)
            {
                rectTransform.anchoredPosition = CurveHelper.getQuadraticBezier(Origin, PathPoints[0], Destination, animPercent);
            }
            if (animationType == AnimationConstants.LINEAR_ANIM_TYPE)
            {
                rectTransform.anchoredPosition = CurveHelper.getQuadraticBezier(Origin, PathPoints[0], Destination, animPercent);
            }

            // -- card specific
            if (animationName == CardConstants.DRAW_CARD_ANIM)
            {
                transform.localScale = Vector3.one * animPercent;
            }

            // done animating a frame
            timer--;

            if (timer <= 0)
            {
                animationType = null;
                this.handleViewDoneAnimation();

                if (destroyAfterAnimation)
                {
                    this.handleDestroy();
                }
            }
        }
    }
        public void Flatten()
        {
            var s = new CardinalSegment2F
            {
                Point1  = new Vector2F(1, 2),
                Point2  = new Vector2F(10, 3),
                Point3  = new Vector2F(7, 8),
                Point4  = new Vector2F(10, 2),
                Tension = 0.3f
            };
            var points    = new List <Vector2F>();
            var tolerance = 0.01f;

            s.Flatten(points, 10, tolerance);
            Assert.IsTrue(points.Contains(s.Point2));
            Assert.IsTrue(points.Contains(s.Point3));
            var curveLength = s.GetLength(0, 1, 10, tolerance);

            Assert.IsTrue(CurveHelper.GetLength(points) >= curveLength - tolerance * points.Count / 2);
            Assert.IsTrue(CurveHelper.GetLength(points) <= curveLength);
        }
示例#16
0
        void Update()
        {
            if (!isServer)
            {
                return;
            }

            if (!randomTrajectory)
            {
                transform.Translate(Vector3.down * speed * Time.deltaTime);
            }
            else
            {
                if (time < totalTime)
                {
                    transform.position = CurveHelper.InterpBezierCube(positions[0], positions[1],
                                                                      positions[2], positions[3], Mathf.Clamp01(time / totalTime));
                    time += Time.deltaTime;
                }
            }
            RpcUpdateBallPosition(transform.position);
        }
示例#17
0
        public override void PostConstruct()
        {
            base.PostConstruct();

            var defs = GetAllDefinitions();

            //TODO: count lode array size properly!
            const int MAX_LODES_PER_DEF     = 20;
            const int MAX_THRESHOLD_PER_DEF = MAX_LODES_PER_DEF * GeometryConsts.CHUNK_HEIGHT;

            _biomeDefData         = new NativeArray <BiomeDefData>(defs.Length, Allocator.Persistent);
            _terrainCurvesSampled = new NativeArray <int>(defs.Length * GeometryConsts.CHUNK_HEIGHT, Allocator.Persistent);
            _lodes          = new NativeArray <LodeDefData>(defs.Length * MAX_LODES_PER_DEF, Allocator.Persistent);
            _lodeThresholds = new NativeArray <float>(defs.Length * MAX_THRESHOLD_PER_DEF, Allocator.Persistent);

            var lodeIndex = 0;

            for (var i = 0; i < defs.Length; i++)
            {
                var def = defs[i];

                //////////// BIOME DEF /////////////
                _biomeDefData[i] = new BiomeDefData(def, lodeIndex);

                ////////// TERRAIN CURVES //////////
                CurveHelper.SampleCurve(def.TerrainCurve, _terrainCurvesSampled, i * GeometryConsts.CHUNK_HEIGHT);

                ////////////// LODES //////////////
                foreach (var lodeDef in def.lodeDefs)
                {
                    _lodes[lodeIndex] = new LodeDefData(lodeDef);

                    CurveHelper.SampleCurve(lodeDef.ThresholdByY, _lodeThresholds, lodeIndex * GeometryConsts.CHUNK_HEIGHT);

                    lodeIndex++;
                }
            }
        }
示例#18
0
        public List <KeyNode> LoadAnimData(ResU.SkeletalAnim ska)
        {
            // Nodes.Clear();
            Bones.Clear();

            CanLoop = ska.FlagsAnimSettings.HasFlag(ResU.SkeletalAnimFlags.Looping);

            foreach (ResU.BoneAnim bn in ska.BoneAnims)
            {
                KeyNode keyNode = new KeyNode();
                keyNode.Name = bn.Name;
                keyNode.UseSegmentScaleCompensate = bn.ApplySegmentScaleCompensate;

                Bones.Add(keyNode);
                //    Nodes.Add(keyNode);

                if (ska.FlagsRotate == ResU.SkeletalAnimFlagsRotate.EulerXYZ)
                {
                    keyNode.RotType = RotationType.EULER;
                }
                else
                {
                    keyNode.RotType = RotationType.QUATERNION;
                }


                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Scale))
                {
                    keyNode.XSCA.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.X, IsKeyed = true
                    });
                    keyNode.YSCA.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.Y, IsKeyed = true
                    });
                    keyNode.ZSCA.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Scale.Z, IsKeyed = true
                    });
                }
                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Rotate))
                {
                    keyNode.XROT.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.X, IsKeyed = true
                    });
                    keyNode.YROT.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.Y, IsKeyed = true
                    });
                    keyNode.ZROT.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.Z, IsKeyed = true
                    });
                    keyNode.WROT.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Rotate.W, IsKeyed = true
                    });
                }
                if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Translate))
                {
                    keyNode.XPOS.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.X, IsKeyed = true
                    });
                    keyNode.YPOS.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.Y, IsKeyed = true
                    });
                    keyNode.ZPOS.Keys.Add(new Animation.KeyFrame()
                    {
                        Frame = 0, Value = bn.BaseData.Translate.Z, IsKeyed = true
                    });
                }

                for (int curve = 0; curve < bn.Curves.Count; curve++)
                {
                    Animation.KeyGroup keyGroup = CurveHelper.CreateTrackWiiU(bn.Curves[curve]);
                    keyGroup.AnimDataOffset = bn.Curves[curve].AnimDataOffset;
                    switch (keyGroup.AnimDataOffset)
                    {
                    case (int)TrackType.XPOS: keyNode.XPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YPOS: keyNode.YPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZPOS: keyNode.ZPOS.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.XROT: keyNode.XROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YROT: keyNode.YROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZROT: keyNode.ZROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.WROT: keyNode.WROT.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.XSCA: keyNode.XSCA.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.YSCA: keyNode.YSCA.Keys.AddRange(keyGroup.Keys); break;

                    case (int)TrackType.ZSCA: keyNode.ZSCA.Keys.AddRange(keyGroup.Keys); break;

                    default: throw new Exception("Unknown Anim Offset " + keyGroup.AnimDataOffset);
                    }
                }
            }

            return(Bones);
        }
 ///<summary>
 ///</summary>
 ///<param name="termCurve"></param>
 ///<param name="baseDate"></param>
 ///<param name="dayCounter"></param>
 public FxCurveInterpolator(TermCurve termCurve, DateTime baseDate, IDayCounter dayCounter)
     : base(CurveHelper.Converter(termCurve, baseDate, dayCounter), InterpolationFactory.Create(termCurve), CurveHelper.IsExtrapolationPermitted(termCurve))
 {
 }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // Initialize the result.
            Result result = Result.Succeeded;

            // Get the active ui document.
            UIDocument uIDocument = commandData.Application.ActiveUIDocument;

            // Get the document.
            Document document = uIDocument.Document;

            // Initialize the wall selection filter.
            WallSelectionFilter wallSelectionFilter = new WallSelectionFilter();

            // Prompt the user to select the walls.
            IList <Reference> references = uIDocument.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, wallSelectionFilter);

            if (references != null && references.Count > 0)
            {
                // Initialize the original curves list.
                List <Curve> originalWallCurves = new List <Curve>();

                // Initialize the List of original offset distances.
                List <double> originalOffsets = new List <double>();

                // Initialize the list of levels ids.
                List <ElementId> levelsIds = new List <ElementId>();

                foreach (var r in references)
                {
                    // Get the wall element.
                    Wall wall = document.GetElement(r) as Wall;

                    if (wall != null)
                    {
                        // Add the required offset to the list by dividing the wall width by 2.
                        originalOffsets.Add(wall.Width / 2.0);

                        // Add the wall curve to the original curves list.
                        originalWallCurves.Add((wall.Location as LocationCurve).Curve);

                        // Add wall level id to the levels ids list.
                        levelsIds.Add(wall.LevelId);
                    }
                }

                if (levelsIds.All(lvl => lvl == levelsIds[0]))
                {
                    // Get the contiguous curves with offsets tuple.
                    var contiguousCurvesWithOffsetsTuple = CurveHelper.GetContiguousCurvesWithOffsets(originalWallCurves, originalOffsets);

                    // Get the contiguous curves.
                    List <Curve> contiguousCurves = contiguousCurvesWithOffsetsTuple.curves;

                    // Get the contiguous curves.
                    List <double> contiguousOffsets = contiguousCurvesWithOffsetsTuple.offsets;

                    // Create a curve loop offset to the contiguous curves.
                    CurveLoop floorCurves = CurveLoop.CreateViaOffset(CurveLoop.Create(contiguousCurves), contiguousOffsets, new XYZ(0.0, 0.0, 1.0));

                    // Initialize the curve array.
                    CurveArray curveArray = new CurveArray();

                    // Append the floor curves in the curve array.
                    foreach (var c in floorCurves)
                    {
                        curveArray.Append(c);
                    }

                    // Get the walls level.
                    Level level = document.GetElement(levelsIds[0]) as Level;

                    // Name the floor type.
                    string floorTypeName = "Generic 300mm";

                    // Collect the floor type to be used.
                    FloorType floorType = new FilteredElementCollector(document)
                                          .OfClass(typeof(FloorType))
                                          .First <Element>(
                        e => e.Name.Equals(floorTypeName)) as FloorType;

                    using (Transaction transaction = new Transaction(document, "Create floor from Walls"))
                    {
                        // Start the transaction.
                        transaction.Start();

                        try
                        {
                            // Create the floor.
                            document.Create.NewFloor(curveArray, floorType, level, false);

                            // Commit the transaction and model changes.
                            transaction.Commit();
                        }
                        catch (Exception e)
                        {
                            // Asssign the error message to the message parameter.
                            message = e.Message;

                            // Roll back model changes.
                            transaction.RollBack();

                            // Assign result to be failed.
                            result = Result.Failed;
                        }
                    }
                }
                else
                {
                    // Assign result to be failed.
                    result = Result.Failed;
                }
            }
            else
            {
                // Assign result to be failed.
                result = Result.Failed;
            }

            // Return result.
            return(result);
        }
示例#21
0
        /// <summary>
        /// The method that allows the user to select walls and creates the floor.
        /// </summary>
        public void SelectWallsAndCreateFloor()
        {
            // Initialize the wall selection filter
            WallSelectionFilter wallSelectionFilter = new WallSelectionFilter();

            // Select the Walls
            IList <Reference> references = RevitBase.UIDocument.Selection.PickObjects(Autodesk.Revit.UI.Selection.ObjectType.Element, wallSelectionFilter);

            if (references != null && references.Count > 0)
            {
                // Initialize the original curves list
                List <Curve> originalWallCurves = new List <Curve>();

                // Initialize the List of original offset distances
                List <double> originalOffsets = new List <double>();

                // Initialize the list of levels ids
                List <ElementId> levelsIds = new List <ElementId>();

                foreach (var r in references)
                {
                    // Get the wall element
                    Wall wall = RevitBase.Document.GetElement(r) as Wall;

                    if (wall != null)
                    {
                        // Add the required offset to the list by dividing the wall width by 2
                        originalOffsets.Add(wall.Width / 2.0);

                        // Add the wall curve to the original curves list
                        originalWallCurves.Add((wall.Location as LocationCurve).Curve);

                        // Add wall level id to the levels ids list
                        levelsIds.Add(wall.LevelId);
                    }
                }

                if (levelsIds.All(lvl => lvl == levelsIds[0]))
                {
                    // Get the contiguous curves with offsets tuple.
                    var contiguousCurvesWithOffsetsTuple = CurveHelper.GetContiguousCurvesWithOffsets(originalWallCurves, originalOffsets);

                    // Get the contiguous curves.
                    List <Curve> contiguousCurves = contiguousCurvesWithOffsetsTuple.curves;

                    // Get the contiguous curves.
                    List <double> contiguousOffsets = contiguousCurvesWithOffsetsTuple.offsets;

                    // Create a curve loop offset to the contiguous curves.
                    CurveLoop floorCurves = CurveLoop.CreateViaOffset(CurveLoop.Create(contiguousCurves), contiguousOffsets, new XYZ(0.0, 0.0, 1.0));

                    // Initialize the curve array
                    CurveArray curveArray = new CurveArray();

                    // Append the floor curves in the curve array
                    foreach (var c in floorCurves)
                    {
                        curveArray.Append(c);
                    }

                    // Get the walls level
                    Level level = RevitBase.Document.GetElement(levelsIds[0]) as Level;

                    using (Transaction transaction = new Transaction(RevitBase.Document, "Create floor from Walls"))
                    {
                        transaction.Start();

                        try
                        {
                            //if (SelectedFloorType == null) SelectedFloorType = FloorTypes.First();

                            // Create the floor
                            RevitBase.Document.Create.NewFloor(curveArray, SelectedFloorType, level, false);

                            // Commit the transaction
                            transaction.Commit();
                        }
                        catch (Exception e)
                        {
                            // Asssign the error message to the message parameter
                            RevitBase.Message = e.Message;

                            // Roll back model changes
                            transaction.RollBack();

                            // Assign result to be failed
                            RevitBase.Result = Result.Failed;
                        }
                    }
                }
                else
                {
                    // Assign result to be failed
                    RevitBase.Result = Result.Failed;
                }
            }
            else
            {
                // Assign result to be failed
                RevitBase.Result = Result.Failed;
            }

            // Return result
        }