예제 #1
0
        private string GenerateSubtractMethodCode(MvClassData resultClassData)
        {
            //The two classes are zero multivector classes
            if (resultClassData.ClassId == 0)
            {
                return("return Zero;");
            }

            var idCommon = ClassData.ClassId & CalcClassData.ClassId;

            var idDiff1 = ClassData.ClassId & ~CalcClassData.ClassId;

            var idDiff2 = ~ClassData.ClassId & CalcClassData.ClassId;

            var composer = new ListComposer("," + Environment.NewLine)
            {
                FinalPrefix      = "return new " + resultClassData.ClassName + "()" + Environment.NewLine + "{" + Environment.NewLine,
                FinalSuffix      = Environment.NewLine + "};",
                ActiveItemPrefix = "    "
            };

            var basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff1.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    $"{basisBlade.GradeIndexName} = {basisBlade.GradeIndexName}"
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idDiff2.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                composer.Add(
                    $"{basisBlade.GradeIndexName} = {"-mv." + basisBlade.GradeIndexName}"
                    );
            }

            basisBlades = ClassData.Frame.BasisBladesOfGrades(idCommon.PatternToPositions());

            foreach (var basisBlade in basisBlades)
            {
                var term = basisBlade.GradeIndexName + " - mv." + basisBlade.GradeIndexName;

                composer.Add(
                    $"{basisBlade.GradeIndexName} = {term}"
                    );
            }

            return(composer.ToString());
        }
예제 #2
0
        private void GenerateDerivedMvClassFiles(MvClassData classData)
        {
            CodeFilesComposer.DownFolder(classData.ClassName);

            CodeFilesComposer.InitalizeFile(classData.ClassName + ".cs");

            DerivedMvClassFileGenerator.Generate(this, classData);

            CodeFilesComposer.UnselectActiveFile();

            foreach (var classData2 in MultivectorClassesData.Values)
            {
                CodeFilesComposer.InitalizeFile(classData.ClassName + "Calc" + classData2.ClassId + ".cs");

                DerivedMvClassCalcFileGenerator.Generate(this, classData, classData2);

                CodeFilesComposer.UnselectActiveFile();
            }

            CodeFilesComposer.UpFolder();
        }
예제 #3
0
 private DerivedMvClassFileGenerator(MvLibrary libGen, MvClassData classData)
     : base(libGen)
 {
     ClassData = classData;
 }
예제 #4
0
        internal static void Generate(MvLibrary libGen, MvClassData classData)
        {
            var generator = new DerivedMvClassFileGenerator(libGen, classData);

            generator.Generate();
        }
예제 #5
0
        internal static void Generate(MvLibrary libGen, MvClassData derivedClassData, MvClassData calcClassData)
        {
            var generator = new DerivedMvClassCalcFileGenerator(libGen, derivedClassData, calcClassData);

            generator.Generate();
        }