ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/wrapBSDF.c
(Generate patch)

Comparing ray/src/util/wrapBSDF.c (file contents):
Revision 2.3 by greg, Fri Feb 13 20:49:59 2015 UTC vs.
Revision 2.4 by greg, Sat Feb 14 00:39:21 2015 UTC

# Line 79 | Line 79 | const char     top_level_name[] = "WindowElement";
79  
80   static char     basis_definition[][256] = {
81  
82 +        "\t<DataDefinition>\n"
83          "\t\t<IncidentDataStructure>Columns</IncidentDataStructure>\n"
84          "\t\t<AngleBasis>\n"
85          "\t\t\t<AngleBasisName>LBNL/Klems Full</AngleBasisName>\n"
86 <        "\t\t</AngleBasis>\n",
86 >        "\t\t\t</AngleBasis>\n"
87 >        "\t</DataDefinition>\n",
88  
89 +        "\t<DataDefinition>\n"
90          "\t\t<IncidentDataStructure>Columns</IncidentDataStructure>\n"
91          "\t\t<AngleBasis>\n"
92          "\t\t\t<AngleBasisName>LBNL/Klems Half</AngleBasisName>\n"
93 <        "\t\t</AngleBasis>\n",
93 >        "\t\t\t</AngleBasis>\n"
94 >        "\t</DataDefinition>\n",
95  
96 +        "\t<DataDefinition>\n"
97          "\t\t<IncidentDataStructure>Columns</IncidentDataStructure>\n"
98          "\t\t<AngleBasis>\n"
99          "\t\t\t<AngleBasisName>LBNL/Klems Quarter</AngleBasisName>\n"
100 <        "\t\t</AngleBasis>\n",
100 >        "\t\t\t</AngleBasis>\n"
101 >        "\t</DataDefinition>\n",
102  
103 <        "\t\t<IncidentDataStructure>TensorTree3</IncidentDataStructure>\n",
103 >        "\t<DataDefinition>\n"
104 >        "\t\t<IncidentDataStructure>TensorTree3</IncidentDataStructure>\n"
105 >        "\t</DataDefinition>\n",
106  
107 <        "\t\t<IncidentDataStructure>TensorTree4</IncidentDataStructure>\n",
107 >        "\t<DataDefinition>\n"
108 >        "\t\t<IncidentDataStructure>TensorTree4</IncidentDataStructure>\n"
109 >        "\t</DataDefinition>\n",
110   };
111  
112   /* Copy data from file descriptor to stdout and close */
# Line 309 | Line 319 | finish_angle_basis(ezxml_t ab)
319                  sprintf(buf, "%g", i ?
320                  .5*(abase_list[n].lat[i].tmin + abase_list[n].lat[i+1].tmin) :
321                                  .0);
322 +                ezxml_add_txt(abb, "\n\t\t\t\t");
323                  ezxml_set_txt_d(ezxml_add_child(abb,"Theta",strlen(abb->txt)), buf);
324                  sprintf(buf, "%d", abase_list[n].lat[i].nphis);
325 +                ezxml_add_txt(abb, "\n\t\t\t\t");
326                  ezxml_set_txt_d(ezxml_add_child(abb,"nPhis",strlen(abb->txt)), buf);
327 +                ezxml_add_txt(abb, "\n\t\t\t\t");
328                  tb = ezxml_add_child(abb, "ThetaBounds", strlen(abb->txt));
329 +                ezxml_add_txt(tb, "\n\t\t\t\t\t");
330                  sprintf(buf, "%g", abase_list[n].lat[i].tmin);
331 <                ezxml_set_txt(ezxml_add_child(tb,"LowerTheta",strlen(tb->txt)), buf);
331 >                ezxml_set_txt_d(ezxml_add_child(tb,"LowerTheta",strlen(tb->txt)), buf);
332 >                ezxml_add_txt(tb, "\n\t\t\t\t\t");
333                  sprintf(buf, "%g", abase_list[n].lat[i+1].tmin);
334 <                ezxml_set_txt(ezxml_add_child(tb,"UpperTheta",strlen(tb->txt)), buf);
334 >                ezxml_set_txt_d(ezxml_add_child(tb,"UpperTheta",strlen(tb->txt)), buf);
335 >                ezxml_add_txt(tb, "\n\t\t\t\t");
336 >                ezxml_add_txt(abb, "\n\t\t\t");
337 >                ezxml_add_txt(ab, "\n\t\t\t");
338          }
339          return 1;
340   }
# Line 332 | Line 350 | determine_angle_basis(const char *fn, ezxml_t wtl)
350          if (wtl == NULL)
351                  return -1;
352          ids = ezxml_txt(ezxml_child(wtl, "IncidentDataStructure"));
353 <        if (ids == NULL)
353 >        if (!ids[0])
354                  return -1;
355          for (i = 0; i < ABend; i++) {
356                  ezxml_t parsed = ezxml_parse_str(basis_definition[i],
# Line 490 | Line 508 | writeBSDF(const char *caller, ezxml_t fl)
508                  }
509          fputs(xml+ei, stdout);                  /* write trailer */
510          free(xml);                              /* free string */
511 +        fputc('\n', stdout);
512          return (fflush(stdout) == 0);
513   }
514  
# Line 570 | Line 589 | wrapBSDF(const char *caller)
589          }
590                                          /* check basis */
591          if (angle_basis != ABdefault) {
592 +                size_t  offset = 0;
593                  ezxml_t ab, dd = ezxml_child(wtl, "DataDefinition");
594 <                if (dd == NULL) {
595 <                        dd = ezxml_add_child(wtl, "DataDefinition", strlen(wtl->txt));
576 <                } else if (dd->child != NULL) {
594 >                if (dd != NULL) {
595 >                        offset = dd->off;
596                          fprintf(stderr,
597                  "%s: warning - replacing existing <DataDefinition> in '%s'\n",
598                                                  caller, xml_path);
599 <                        do
600 <                                ezxml_remove(dd->child);
601 <                        while (dd->child != NULL);
602 <                }
584 <                ezxml_insert(ezxml_parse_str(basis_definition[angle_basis],
599 >                        ezxml_remove(dd);
600 >                } else
601 >                        offset = strlen(wtl->txt);
602 >                dd = ezxml_insert(ezxml_parse_str(basis_definition[angle_basis],
603                                          strlen(basis_definition[angle_basis])),
604 <                                dd, 0);
604 >                                wtl, offset);
605                  if ((ab = ezxml_child(dd, "AngleBasis")) != NULL &&
606                                  !finish_angle_basis(ab))
607                          goto failure;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines