udConvertCustom

udConvertCustomItem provides a way to convert proprietary or unsupported file formats to Unlimited Detail format

Enums

enum udConvertCustomItemFlags

Settings the custom converts need to be aware of that are set by the user

Values:

ValueDescription
udCCIF_NoneNo additional flags specified.
udCCIF_SkipErrorsWherePossibleIf its possible to continue parsing, that is perferable to failing.
udCCIF_PolygonVerticesOnlyDo not rasterise the polygons, just use the vertices as points.
udCCIF_BakeLightingBake normals into color channel for polygons conversion.
udCCIF_ExportImagesExport images contained in e57 files.

enum udPrimitiveVertexType

Indicates the geometry type of a vertex passed to pReadPrimitives

Values:

ValueDescription
udPVT_NullThe vertex does not form part of a primitive.
udPVT_LineThe vertex is the start point of a line, the next vertex will represent the endpoint.
udPVT_TriangleThe next 3 vertices in the buffer represent a triangle.

enum udPrimitiveTextureFlags

Indicates the geometry type of a vertex passed to pReadPrimitives

Values:

ValueDescription
udPMF_NoneDefault material options.
udPMF_FilterApply bilinear filtering to the texture.
udPMF_ClampApply clamping to the texture.

Functions

enum udError udConvert_AddCustomItem(struct udConvertContext *pConvertContext, struct udConvertCustomItem *pCustomItem)

Adds a prefilled udConvertCustomItem to a udConvertContext

ParameterDescription
pConvertContextThe convert context to add the item to
pCustomItemThe custom convert item to add

Returns: A udError value based on the result of adding the item

enum udError udConvert_AddCustomItemFormat(struct udConvertContext *pConvertContext, int (*pExtensionCheck)(const char *pFilename), enum udError (*pTryAddItem)(struct udConvertContext *pConvertContext, const char *pFilename, struct udConvertCustomItem *pCustomItem))

Registers a format in the udConvertContext to allow users to just call udConvert_AddItem

!NOTE pTryAddItem needs to handle being called if a file doesn’t match any of the extensions

ParameterDescription
pConvertContextThe convert context to register the format with
pExtensionCheckThe callback used to determine if the format should be used, returns 1 when a match, 0 otherwise
pTryAddItemThe callback used when calling udConvert_AddItem needs to populate the pCustomItem parameter, returns udE_Success on success

Returns: A udError value based on the result of registering the format

enum udError udConvert_GetPrimitiveMaterialID(struct udConvertCustomItem *pConvertItem, uint32_t *pMaterialID, const char *pTexturePath, enum udPrimitiveTextureFlags textureFlags)

Gets the id of a material suitable for use in a primitive

ParameterDescription
pConvertItemThe convert item to get the material ID from
pMaterialIDA pointer to the ID to be populated.
pTexturePathTHe path to the texture to be used in the material
textureFlagsflags indicating how the texture is processed

Returns: A udError value based on the result of getting the texture ID

enum udError udConvert_EstimatePointsVertexBuffer(struct udPointBufferF64 *pBuffer, double gridResolution, int64_t *pPointCount)

Estimates the number of points generated by a vertex buffer when passed to a udPrimitive convert.

ParameterDescription
pBufferThe buffer of vertices as passed to pReadPrimitives, each vertex must have at minimum a udPrimitiveID indicating the type of primitive (udPVT_Line or udPVT_Triangle)
gridResolutionThe resolution that the conversion takes place at
pPointCounta pointer to which the resultant estimate will be written

Returns: A udError value based on the result of estimating the number of points generated by the vertex buffer

Structs

struct udConvertCustomItem

Allows for conversion of custom data formats to UDS

FieldTypeDescription
flags)enum [udError](udError.md) (\*pOpen)(struct udConvertCustomItem \*pConvertInput, uint32_t everyNth, double pointResolution, enum udConvertCustomItemFlagsOpen the file and provide information on the file (bounds, point count, etc.).
pBuffer)enum [udError](udError.md) (\*pReadPointsFloat)(struct udConvertCustomItem \*pConvertInput, struct [udPointBufferF64](udPointBuffer.md) \*Provide position and attribute data to convert to UDS.
pBuffer)enum [udError](udError.md) (\*pReadPrimitives)(struct udConvertCustomItem \*pConvertInput, struct [udPointBufferF64](udPointBuffer.md) \*Provide vertex data of primitives to convert to UDS.
pConvertInput)void (\*pDestroy)(struct udConvertCustomItem \*Cleanup all memory related to this custom convert item.
pConvertInput)void (\*pClose)(struct udConvertCustomItem \*This function will be called on completion of reading the file.
pDatavoid \*Private user data relevant to the specific geomtype, must be freed by the pClose function.
pNameconst char \*Filename or other identifier.
boundMin[3]doubleOptional (see boundsKnown) source space minimum values.
boundMax[3]doubleOptional (see boundsKnown) source space maximum values.
sourceResolutiondoubleSource resolution (eg 0.01 if points are 1cm apart). 0 indicates unknown.
pointCountint64_tNumber of points coming, -1 if unknown.
sridint32_tIf non-zero, this input is considered to be within the given srid code (useful mainly as a default value for other files in the conversion).
attributesstruct [udAttributeSet](udAttributes.md)Content of the input; this might not match the output.
boundsKnownuint32_tIf not 0, boundMin and boundMax are valid, if 0 they will be calculated later.
pointCountIsEstimateuint32_tIf not 0, the point count is an estimate and may be different.
pReservedvoid \*Contains information used in primitive convert.