new <default> XML tag, which creates a default value for a parameter that has not been specified on the command line

metadata
Wenzel Jakob 2013-12-28 18:37:16 +01:00
parent 9c4a5fe47b
commit b5148cdfa3
5 changed files with 30 additions and 7 deletions

View File

@ -28,6 +28,7 @@
<xsd:element name="blackbody" type="blackbody"/> <xsd:element name="blackbody" type="blackbody"/>
<xsd:element name="alias" type="alias"/> <xsd:element name="alias" type="alias"/>
<xsd:element name="default" type="string"/>
</xsd:choice> </xsd:choice>
<xsd:attribute name="version" type="xsd:string"/> <xsd:attribute name="version" type="xsd:string"/>
</xsd:complexType> </xsd:complexType>
@ -49,6 +50,7 @@
<xsd:element name="rgb" type="rgb"/> <xsd:element name="rgb" type="rgb"/>
<xsd:element name="srgb" type="string"/> <xsd:element name="srgb" type="string"/>
<xsd:element name="blackbody" type="blackbody"/> <xsd:element name="blackbody" type="blackbody"/>
<xsd:element name="default" type="string"/>
</xsd:choice> </xsd:choice>
</xsd:group> </xsd:group>

View File

@ -368,13 +368,28 @@ This lets you include different parts of a scene configuration by changing the c
\begin{xml} \begin{xml}
<include filename="nested-scene-$\texttt{\$}$version.xml"/> <include filename="nested-scene-$\texttt{\$}$version.xml"/>
\end{xml} \end{xml}
\subsection{Default parameter values}
As mentioned before, scenes may contain named parameters that are supplied via the command line:
\begin{xml}
<bsdf type="diffuse">
<rgb name="reflectance" value="$\texttt{\$}$reflectance"/>
</bsdf>
\end{xml}
In this case, an error will occur when loading the scene without an explicit command line argument of the form
\code{-Dreflectance=}\mbox{$\langle$\emph{something}$\rangle$}. For convenience, it is possible to specify
a default parameter value that takes precedence when no command line arguments are given. The syntax for this is
\begin{xml}
<default name="reflectance" value="something"/>
\end{xml}
and must precede occurrences of the parameter in the XML file.
\subsection{Aliases} \subsection{Aliases}
Sometimes, it can be useful to associate an object (e.g. a scattering model) Sometimes, it can be useful to associate an object (e.g. a scattering model)
with multiple identifiers. This can be accomplished using the \code{alias with multiple identifiers. This can be accomplished using the \code{alias
as=..} keyword: as=..} keyword:
\begin{xml} \begin{xml}
<bsdf type="diffuse" id="myMaterial1"/> <bsdf type="diffuse" id="myMaterial1"/>
<alias id="myMaterial1" as="myMaterial2"/> <alias id="myMaterial1" as="myMaterial2"/>
\end{xml} \end{xml}
After this statement, the diffuse scattering model will be bound to After this statement, the diffuse scattering model will be bound to
\emph{both} identifiers ``\code{myMaterial1}'' and ``\code{myMaterial2}''. \emph{both} identifiers ``\code{myMaterial1}'' and ``\code{myMaterial2}''.

View File

@ -158,7 +158,7 @@ private:
ELookAt, EScale, EMatrix, EPoint, ELookAt, EScale, EMatrix, EPoint,
EVector, ERGB, ESRGB, EBlackBody, EVector, ERGB, ESRGB, EBlackBody,
ESpectrum, ETransform, EAnimation, ESpectrum, ETransform, EAnimation,
EInclude, EAlias EInclude, EAlias, EDefault
}; };
typedef std::pair<ETag, const Class *> TagEntry; typedef std::pair<ETag, const Class *> TagEntry;

View File

@ -195,7 +195,7 @@ void gaussLegendre(int n, Float *nodes, Float *weights) {
while (true) { while (true) {
if (++it > 20) if (++it > 20)
SLog(EError, "gaussLegendre(): did not converge after 20 iterations!"); SLog(EError, "gaussLegendre(%i): did not converge after 20 iterations!", n);
/* Search for the interior roots of P_{n+1}(x) using Newton's method. */ /* Search for the interior roots of P_{n+1}(x) using Newton's method. */
std::pair<double, double> L = legendrePD(n+1, x); std::pair<double, double> L = legendrePD(n+1, x);
@ -219,7 +219,6 @@ void gaussLegendre(int n, Float *nodes, Float *weights) {
} }
} }
void gaussLobatto(int n, Float *nodes, Float *weights) { void gaussLobatto(int n, Float *nodes, Float *weights) {
if (n-- < 2) if (n-- < 2)
SLog(EError, "gaussLobatto(): n must be >= 2"); SLog(EError, "gaussLobatto(): n must be >= 2");
@ -238,7 +237,7 @@ void gaussLobatto(int n, Float *nodes, Float *weights) {
while (true) { while (true) {
if (++it > 20) if (++it > 20)
SLog(EError, "gaussLobatto(): did not converge after 20 iterations!"); SLog(EError, "gaussLobatto(%i): did not converge after 20 iterations!", n);
/* Search for the interior roots of P_n'(x) using Newton's method. The same /* Search for the interior roots of P_n'(x) using Newton's method. The same
roots are also shared by P_{n+1}-P_{n-1}, which is nicer to evaluate. */ roots are also shared by P_{n+1}-P_{n-1}, which is nicer to evaluate. */

View File

@ -102,9 +102,10 @@ SceneHandler::SceneHandler(const SAXParser *parser,
m_tags["blackbody"] = TagEntry(EBlackBody, (Class *) NULL); m_tags["blackbody"] = TagEntry(EBlackBody, (Class *) NULL);
m_tags["spectrum"] = TagEntry(ESpectrum, (Class *) NULL); m_tags["spectrum"] = TagEntry(ESpectrum, (Class *) NULL);
m_tags["transform"] = TagEntry(ETransform, (Class *) NULL); m_tags["transform"] = TagEntry(ETransform, (Class *) NULL);
m_tags["animation"] = TagEntry(EAnimation, (Class *) NULL); m_tags["animation"] = TagEntry(EAnimation, (Class *) NULL);
m_tags["include"] = TagEntry(EInclude, (Class *) NULL); m_tags["include"] = TagEntry(EInclude, (Class *) NULL);
m_tags["alias"] = TagEntry(EAlias, (Class *) NULL); m_tags["alias"] = TagEntry(EAlias, (Class *) NULL);
m_tags["default"] = TagEntry(EDefault, (Class *) NULL);
XMLTransService::Codes failReason; XMLTransService::Codes failReason;
m_transcoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor( m_transcoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor(
@ -656,6 +657,12 @@ void SceneHandler::endElement(const XMLCh* const xmlName) {
} }
break; break;
case EDefault: {
if (m_params.find(context.attributes["name"]) == m_params.end())
m_params[context.attributes["name"]] = context.attributes["value"];
}
break;
default: { default: {
if (tag.second == NULL) if (tag.second == NULL)
XMLLog(EError, "Internal error: could not instantiate an object " XMLLog(EError, "Internal error: could not instantiate an object "