Hi,
To ease the transition of some tests to generic primitives, I made an
XSLT converter that takes a pre-generic primitive polyhedron mesh and
translates it to a generic mesh. Is there any interest in adding this
to the source tree, and if so, where should it be put?
The file is attached, it can be used with an XSLT 2.0 processor such as saxonb.
Cheers,
--
Bart
<?xml version='1.0'?>
<xsl:stylesheet version='2.0' xmlns:xsl='
http://www.w3.org/1999/XSL/Transform'>
<!-- Copy everything not matched otherwise -->
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<!-- Process the mesh arrays, just copying everything except polyhedra -->
<xsl:template match="//mesh_arrays">
<mesh_arrays>
<xsl:apply-templates select="* except polyhedra"/>
<xsl:if test="count(vertex_data) = 0">
<vertex_data/>
</xsl:if>
<primitives>
<xsl:apply-templates select="polyhedra"/>
</primitives>
</mesh_arrays>
</xsl:template>
<!-- Conversion of polyhedra -->
<xsl:template match="polyhedra">
<primitive type="polyhedron">
<structure>
<xsl:apply-templates select="* except (constant_data | uniform_data | face_varying_data)"/>
</structure>
<attributes>
<xsl:if test="count(constant_data) = 0">
<arrays type="constant"/>
</xsl:if>
<xsl:if test="count(uniform_data) = 0">
<arrays type="uniform"/>
</xsl:if>
<xsl:if test="count(face_varying_data) = 0">
<arrays type="face_varying"/>
</xsl:if>
<xsl:apply-templates select="constant_data | uniform_data | face_varying_data"/>
</attributes>
</primitive>
</xsl:template>
<!-- Conversion of mesh arrays -->
<xsl:template match="clockwise_edges | face_first_loops | face_loop_counts | loop_first_edges">
<array>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:attribute name="type">k3d::uint_t</xsl:attribute>
<xsl:value-of select="text()"/>
</array>
</xsl:template>
<xsl:template match="edge_points">
<array>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:attribute name="type">k3d::uint_t</xsl:attribute>
<xsl:value-of select="text()"/>
<metadata>
<pair name="k3d:domain">/points/indices()</pair>
</metadata>
</array>
</xsl:template>
<xsl:template match="edge_selection">
<array>
<xsl:attribute name="name">edge_selections</xsl:attribute>
<xsl:attribute name="type">k3d::double_t</xsl:attribute>
<xsl:value-of select="text()"/>
<metadata>
<pair name="k3d:selection-component">split_edge</pair>
</metadata>
</array>
</xsl:template>
<xsl:template match="face_selection">
<array>
<xsl:attribute name="name">face_selections</xsl:attribute>
<xsl:attribute name="type">k3d::double_t</xsl:attribute>
<xsl:value-of select="text()"/>
<metadata>
<pair name="k3d:selection-component">uniform</pair>
</metadata>
</array>
</xsl:template>
<xsl:template match="face_materials">
<array>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:attribute name="type">k3d::imaterial*</xsl:attribute>
<xsl:value-of select="text()"/>
</array>
</xsl:template>
<xsl:template match="face_counts">
<array name="shell_face_counts" type="k3d::uint_t">
<xsl:value-of select="text()"/>
</array>
</xsl:template>
<xsl:template match="first_faces">
<array name="shell_first_faces" type="k3d::uint_t">
<xsl:value-of select="text()"/>
</array>
</xsl:template>
<xsl:template match="types">
<array name="shell_types" type="k3d::int32_t">
<xsl:value-of select="replace(replace(text(), 'polygons', '0'), 'catmull_clark', '1')"/>
</array>
</xsl:template>
<!-- Conversion of attribute arrays -->
<xsl:template match="constant_data | uniform_data | face_varying_data">
<arrays>
<xsl:attribute name="type"><xsl:value-of select="replace(name(), '_data', '')"/></xsl:attribute>
<xsl:apply-templates/>
</arrays>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------------------------------------
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development