Example #1
0
        private void AssignPatchesToModel()
        {
            int counterElementID = 0;
            int counterCPID      = 0;

            for (int patchID = 0; patchID < NumberOfPatches; patchID++)
            {
                Patch patch = new Patch()
                {
                    NumberOfDimensions        = this.NumberOfDimensions,
                    DegreeKsi                 = DegreeKsiDictionary[patchID],
                    DegreeHeta                = DegreeHetaDictionary[patchID],
                    DegreeZeta                = (NumberOfDimensions == 2) ? 0 : DegreeZetaDictionary[patchID],
                    NumberOfControlPointsKsi  = NumberOfControlPointsKsiDictionary[patchID],
                    NumberOfControlPointsHeta = NumberOfControlPointsHetaDictionary[patchID],
                    NumberOfControlPointsZeta = (NumberOfDimensions == 2) ? 0 : NumberOfControlPointsZetaDictionary[patchID],
                    Material            = this.Material,
                    Thickness           = (NumberOfDimensions == 2) ? this.Thickness : 0,
                    KnotValueVectorKsi  = Vector.CreateFromArray(KnotValueVectorsKsiDictionary[patchID]),
                    KnotValueVectorHeta = Vector.CreateFromArray(KnotValueVectorsHetaDictionary[patchID]),
                    KnotValueVectorZeta = (NumberOfDimensions == 2) ? null : Vector.CreateFromArray(KnotValueVectorsZetaDictionary[patchID]),
                };

                for (int j = 0; j < ControlPointIDsDictionary[patchID].Length; j++)
                {
                    ((List <ControlPoint>)patch.ControlPoints).Add(ControlPointsDictionary[ControlPointIDsDictionary[patchID][j]]);
                }
                patch.CreatePatchData();
                foreach (var element in patch.Elements)
                {
                    Model.ElementsDictionary.Add(counterElementID++, element);
                }
                foreach (var controlPoint in patch.ControlPoints)
                {
                    Model.ControlPointsDictionary.Add(counterCPID++, controlPoint);
                }

                this.Model.PatchesDictionary.Add(patchID, patch);
            }
        }
Example #2
0
        private void AssignContinuousPatchesToModel()
        {
            int counterPatch = 0;

            for (int patchID = 0; patchID < NumberOfPatches; patchID++)
            {
                #region FindSubPatches

                var tupleKsi      = DetectSubPatches(Vector.CreateFromArray(KnotValueVectorsKsiDictionary[patchID]), DegreeKsiDictionary[patchID]);
                int subpatchesKsi = tupleKsi.Item1;
                Dictionary <int, Vector> subKnotVectorsKsi = tupleKsi.Item2;

                var tupleHeta      = DetectSubPatches(Vector.CreateFromArray(KnotValueVectorsHetaDictionary[patchID]), DegreeHetaDictionary[patchID]);
                int subpatchesHeta = tupleHeta.Item1;
                Dictionary <int, Vector> subKnotVectorsHeta = tupleHeta.Item2;

                int subpatchesZeta = 1;
                Tuple <int, Dictionary <int, Vector> > tupleZeta = new Tuple <int, Dictionary <int, Vector> >(1, null);
                Dictionary <int, Vector> subKnotVectorsZeta      = new Dictionary <int, Vector>();
                if (this.NumberOfDimensions == 3)
                {
                    tupleZeta          = DetectSubPatches(Vector.CreateFromArray(KnotValueVectorsZetaDictionary[patchID]), DegreeZetaDictionary[patchID]);
                    subpatchesZeta     = tupleZeta.Item1;
                    subKnotVectorsZeta = tupleZeta.Item2;
                }

                #endregion FindSubPatches

                var controlPointIDs = FindControlPointsOfEachSubPatch(patchID, tupleKsi, tupleHeta, tupleZeta);

                for (int i = 0; i < subpatchesKsi; i++)
                {
                    for (int j = 0; j < subpatchesHeta; j++)
                    {
                        for (int k = 0; k < subpatchesZeta; k++)
                        {
                            Patch patch = new Patch()
                            {
                                NumberOfDimensions        = this.NumberOfDimensions,
                                DegreeKsi                 = DegreeKsiDictionary[patchID],
                                DegreeHeta                = DegreeHetaDictionary[patchID],
                                DegreeZeta                = (NumberOfDimensions == 2) ? 0 : DegreeZetaDictionary[patchID],
                                NumberOfControlPointsKsi  = subKnotVectorsKsi[i].Length - DegreeKsiDictionary[patchID] - 1,
                                NumberOfControlPointsHeta = subKnotVectorsHeta[j].Length - DegreeHetaDictionary[patchID] - 1,
                                NumberOfControlPointsZeta = (NumberOfDimensions == 2) ? 0 : subKnotVectorsZeta[k].Length - DegreeZetaDictionary[patchID] - 1,
                                Material            = this.Material,
                                Thickness           = (NumberOfDimensions == 2) ? this.Thickness : 0,
                                KnotValueVectorKsi  = subKnotVectorsKsi[i],
                                KnotValueVectorHeta = subKnotVectorsHeta[j],
                                KnotValueVectorZeta = (NumberOfDimensions == 2) ? null : subKnotVectorsZeta[k]
                            };

                            for (int m = 0; m < controlPointIDs[i, j, k].Length; m++)
                            {
                                ((List <ControlPoint>)patch.ControlPoints).Add(ControlPointsDictionary[ControlPointIDsDictionary[patchID][controlPointIDs[i, j, k][m]]]);
                            }
                            patch.CreatePatchData();
                            this.Model.PatchesDictionary.Add(counterPatch++, patch);
                        }
                    }
                }
            }
        }