Ejemplo n.º 1
0
 public void ApplyAttributesToFreeFormElement(ObjFreeFormElement element)
 {
     element.MergingGroupNumber = this.MergingGroupNumber;
     element.FreeFormType       = this.FreeFormType;
     element.IsRationalForm     = this.IsRationalForm;
     element.DegreeU            = this.DegreeU;
     element.DegreeV            = this.DegreeV;
     element.BasicMatrixU       = this.BasicMatrixU;
     element.BasicMatrixV       = this.BasicMatrixV;
     element.StepU = this.StepU;
     element.StepV = this.StepV;
     element.CurveApproximationTechnique   = this.CurveApproximationTechnique;
     element.SurfaceApproximationTechnique = this.SurfaceApproximationTechnique;
 }
Ejemplo n.º 2
0
        private static void WriteBodyOfFreeFormElement(StreamWriter stream, ObjFreeFormElement element)
        {
            bool writeEnd = false;

            if (element.ParametersU.Count != 0)
            {
                writeEnd = true;
                stream.Write("parm u");

                foreach (float value in element.ParametersU)
                {
                    stream.Write(' ');
                    stream.Write(value.ToString("F6", CultureInfo.InvariantCulture));
                }

                stream.WriteLine();
            }

            if (element.ParametersV.Count != 0)
            {
                writeEnd = true;
                stream.Write("parm v");

                foreach (float value in element.ParametersV)
                {
                    stream.Write(' ');
                    stream.Write(value.ToString("F6", CultureInfo.InvariantCulture));
                }

                stream.WriteLine();
            }

            if (element.OuterTrimmingCurves.Count != 0)
            {
                writeEnd = true;
                stream.Write("trim");

                foreach (ObjCurveIndex index in element.OuterTrimmingCurves)
                {
                    stream.Write(' ');
                    stream.Write(index);
                }

                stream.WriteLine();
            }

            if (element.InnerTrimmingCurves.Count != 0)
            {
                writeEnd = true;
                stream.Write("hole");

                foreach (ObjCurveIndex index in element.InnerTrimmingCurves)
                {
                    stream.Write(' ');
                    stream.Write(index);
                }

                stream.WriteLine();
            }

            if (element.SequenceCurves.Count != 0)
            {
                writeEnd = true;
                stream.Write("scrv");

                foreach (ObjCurveIndex index in element.SequenceCurves)
                {
                    stream.Write(' ');
                    stream.Write(index);
                }

                stream.WriteLine();
            }

            if (element.SpecialPoints.Count != 0)
            {
                writeEnd = true;
                stream.Write("sp");

                foreach (int point in element.SpecialPoints)
                {
                    stream.Write(' ');
                    stream.Write(point);
                }

                stream.WriteLine();
            }

            if (writeEnd)
            {
                stream.WriteLine("end");
            }
        }
Ejemplo n.º 3
0
        public void WriteAttributesOfFreeFormElement(StreamWriter stream, ObjFreeFormElement element)
        {
            if (element.MergingGroupNumber != this.MergingGroupNumber)
            {
                this.MergingGroupNumber = element.MergingGroupNumber;

                if (this.MergingGroupNumber == 0)
                {
                    stream.WriteLine("mg off");
                }
                else
                {
                    float res = obj.MergingGroupResolutions[this.MergingGroupNumber];
                    stream.WriteLine("mg {0} {1}", this.MergingGroupNumber, res.ToString("F6", CultureInfo.InvariantCulture));
                }
            }

            switch (element.FreeFormType)
            {
            case ObjFreeFormType.BasisMatrix:
                stream.Write("cstype");

                if (element.IsRationalForm)
                {
                    stream.Write(" rat");
                }

                stream.WriteLine(" bmatrix");
                break;

            case ObjFreeFormType.Bezier:
                stream.Write("cstype");

                if (element.IsRationalForm)
                {
                    stream.Write(" rat");
                }

                stream.WriteLine(" bezier");
                break;

            case ObjFreeFormType.BSpline:
                stream.Write("cstype");

                if (element.IsRationalForm)
                {
                    stream.Write(" rat");
                }

                stream.WriteLine(" bspline");
                break;

            case ObjFreeFormType.Cardinal:
                stream.Write("cstype");

                if (element.IsRationalForm)
                {
                    stream.Write(" rat");
                }

                stream.WriteLine(" cardinal");
                break;

            case ObjFreeFormType.Taylor:
                stream.Write("cstype");

                if (element.IsRationalForm)
                {
                    stream.Write(" rat");
                }

                stream.WriteLine(" taylor");
                break;
            }

            if (element.DegreeV == 0)
            {
                stream.WriteLine("deg {0}", element.DegreeU);
            }
            else
            {
                stream.WriteLine("deg {0} {1}", element.DegreeU, element.DegreeV);
            }

            if (element.BasicMatrixU != null)
            {
                stream.Write("bmat u");

                foreach (float value in element.BasicMatrixU)
                {
                    stream.Write(' ');
                    stream.Write(value.ToString("F6", CultureInfo.InvariantCulture));
                }

                stream.WriteLine();
            }

            if (element.BasicMatrixV != null)
            {
                stream.Write("bmat v");

                foreach (float value in element.BasicMatrixV)
                {
                    stream.Write(' ');
                    stream.Write(value.ToString("F6", CultureInfo.InvariantCulture));
                }

                stream.WriteLine();
            }

            if (element.StepV == 1.0f)
            {
                stream.WriteLine(
                    "step {0}",
                    element.StepU.ToString("F6", CultureInfo.InvariantCulture));
            }
            else
            {
                stream.WriteLine(
                    "step {0} {1}",
                    element.StepU.ToString("F6", CultureInfo.InvariantCulture),
                    element.StepV.ToString("F6", CultureInfo.InvariantCulture));
            }

            if (element.CurveApproximationTechnique != null)
            {
                if (element.CurveApproximationTechnique is ObjConstantParametricSubdivisionTechnique)
                {
                    var technique = (ObjConstantParametricSubdivisionTechnique)element.CurveApproximationTechnique;
                    stream.WriteLine("ctech cparm {0}", technique.ResolutionU.ToString("F6", CultureInfo.InvariantCulture));
                }
                else if (element.CurveApproximationTechnique is ObjConstantSpatialSubdivisionTechnique)
                {
                    var technique = (ObjConstantSpatialSubdivisionTechnique)element.CurveApproximationTechnique;
                    stream.WriteLine("ctech cspace {0}", technique.MaximumLength.ToString("F6", CultureInfo.InvariantCulture));
                }
                else if (element.CurveApproximationTechnique is ObjCurvatureDependentSubdivisionTechnique)
                {
                    var technique = (ObjCurvatureDependentSubdivisionTechnique)element.CurveApproximationTechnique;
                    stream.WriteLine(
                        "ctech curv {0} {1}",
                        technique.MaximumDistance.ToString("F6", CultureInfo.InvariantCulture),
                        technique.MaximumAngle.ToString("F6", CultureInfo.InvariantCulture));
                }
            }

            if (element.SurfaceApproximationTechnique != null)
            {
                if (element.SurfaceApproximationTechnique is ObjConstantParametricSubdivisionTechnique)
                {
                    var technique = (ObjConstantParametricSubdivisionTechnique)element.SurfaceApproximationTechnique;

                    if (technique.ResolutionU == technique.ResolutionV)
                    {
                        stream.WriteLine(
                            "stech cparmb {0}",
                            technique.ResolutionU.ToString("F6", CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        stream.WriteLine(
                            "stech cparma {0} {1}",
                            technique.ResolutionU.ToString("F6", CultureInfo.InvariantCulture),
                            technique.ResolutionV.ToString("F6", CultureInfo.InvariantCulture));
                    }
                }
                else if (element.SurfaceApproximationTechnique is ObjConstantSpatialSubdivisionTechnique)
                {
                    var technique = (ObjConstantSpatialSubdivisionTechnique)element.SurfaceApproximationTechnique;
                    stream.WriteLine("stech cspace {0}", technique.MaximumLength.ToString("F6", CultureInfo.InvariantCulture));
                }
                else if (element.SurfaceApproximationTechnique is ObjCurvatureDependentSubdivisionTechnique)
                {
                    var technique = (ObjCurvatureDependentSubdivisionTechnique)element.SurfaceApproximationTechnique;
                    stream.WriteLine(
                        "stech curv {0} {1}",
                        technique.MaximumDistance.ToString("F6", CultureInfo.InvariantCulture),
                        technique.MaximumAngle.ToString("F6", CultureInfo.InvariantCulture));
                }
            }
        }