/usr/share/doc/python-openctm/examples/ctminfo.py is in python-openctm 1.0.3+dfsg1-1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #! /usr/bin/env python
#------------------------------------------------------------------------------
# Program: ctminfo.py
# Description: Show information about an OpenCTM file
# License: Public domain
#------------------------------------------------------------------------------
import sys
import openctm
from openctm import *
# Check arguments
if len(sys.argv) != 2:
print("Usage: " + sys.argv[0] + " file")
sys.exit()
# Create an OpenCTM context, and load the file
ctm = ctmNewContext(CTM_IMPORT)
ctmLoad(ctm, sys.argv[1])
err = ctmGetError(ctm)
if err != CTM_NONE:
print("Error loading file: " + str(ctmErrorString(err)))
sys.exit()
# Interpret information
if ctmGetInteger(ctm, CTM_HAS_NORMALS) == CTM_TRUE:
hasNormals = "yes"
else:
hasNormals = "no";
method = ctmGetInteger(ctm, CTM_COMPRESSION_METHOD)
if method == CTM_METHOD_RAW:
methodStr = "RAW"
elif method == CTM_METHOD_MG1:
methodStr = "MG1"
elif method == CTM_METHOD_MG2:
methodStr = "MG2"
else:
methodStr = "Unknown"
# Print information
print(" File: " + sys.argv[1])
print(" Comment: " + str(ctmGetString(ctm, CTM_FILE_COMMENT)))
print("Triangle count: " + str(ctmGetInteger(ctm, CTM_TRIANGLE_COUNT)))
print(" Vertex count: " + str(ctmGetInteger(ctm, CTM_VERTEX_COUNT)))
print(" Has normals: " + hasNormals)
print(" Method: " + methodStr)
# List UV maps
uvMapCount = ctmGetInteger(ctm, CTM_UV_MAP_COUNT)
print(" UV maps: " + str(uvMapCount))
for i in range(uvMapCount):
print(" CTM_UV_MAP_" + str(i+1) + ": \"" + str(ctmGetUVMapString(ctm, CTM_UV_MAP_1 + i, CTM_NAME)) + "\", ref = \"" + str(ctmGetUVMapString(ctm, CTM_UV_MAP_1 + i, CTM_FILE_NAME)) + "\"")
# List attrib maps
attribMapCount = ctmGetInteger(ctm, CTM_ATTRIB_MAP_COUNT)
print("Attribute maps: " + str(attribMapCount))
for i in range(attribMapCount):
print(" CTM_ATTRIB_MAP_" + str(i+1) + ": \"" + str(ctmGetAttribMapString(ctm, CTM_ATTRIB_MAP_1 + i, CTM_NAME)) + "\"")
# Free the OpenCTM context
ctmFreeContext(ctm)
|