Commits

Barry Schwartz committed f4c5d7f

More complete augmentation of <mvslices>; also now you optionally can specify the scalar and general slices explicitly.

Comments (0)

Files changed (2)

examples/c3ga.xml

 
     <mvslice name="mv_grade4"> &grade4; </mvslice>
     <mvslice name="mv_grade5"> &grade5; </mvslice>
-
-    <mvslice name="mv_general"> &basis-blades; </mvslice>
   </mvslices>
 
   <constant name="no"> no </constant>

geomalg/markup_augment.pure

 //
 // Augment <mvslices> tags.
 
+get_blade_groups my_root nodes =
+  [map (eval_multiblade_expr my_root.val) slist | slist = blade_group_strings]
+  when
+    blade_group_strings = [extract_list (xml::node_content n) | n = nodes];
+  end;
+
 augment_mvslices my_root =
   if ~null (xml::select my_root "mvslices[@basis-blade-indices]") then
     my_root
   else
     (xml::set_node_attr (parent_nodes!0) "blade-groups" (str blade_groups) $$
      xml::set_node_attr (parent_nodes!0) "bitmap-groups" (str bitmap_groups) $$
-     void [xml::set_node_attr (nodes!i) "slice-index" (str (i + 1)) |
+     void [xml::set_node_attr (nodes!i) "slice-index" (str i) |
            i = 0..#nodes - 1] $$
      my_root
        when
          parent_nodes = xml::select my_root "mvslices";
          nodes = xml::select my_root "mvslices/mvslice";
-         blade_group_strings = [extract_list (xml::node_content n) |
-                                n = nodes];
-         blade_groups = [[1]] +
-           [map (eval_multiblade_expr my_root.val) slist | slist = blade_group_strings];
+         explicit_blade_groups = get_blade_groups my_root nodes;
+
+         // Make sure there is a ‘scalar’ blade group.
+         case explicit_blade_groups!0 of
+           [_::integer] = ();
+           _ = (xml::add_first (parent_nodes!0)
+                (xml::element_text "mvslice" [] [] "1"));
+         end;
+
+         // Make sure there is a ‘general multivector’ blade group.
+         basis_blade_count = get_basis_blade_count my_root;
+         case last explicit_blade_groups of
+           g = () if #g == basis_blade_count;
+           _ = (xml::add_last (parent_nodes!0)
+                (xml::element_text "mvslice" [] [] (str $ tuple blades)))
+             when
+               blades = [symb::basis_blade 1 i | i = 0..basis_blade_count - 1];
+             end;
+         end;
+
+         blade_groups = get_blade_groups my_root nodes;
          bitmap_groups = [sort (<) $ map multiblade::bitmap B | B = blade_groups];
        end);