|
@@ -10,92 +10,56 @@ namespace SharpGLTF.Schema2
|
|
|
internal EXTStructuralMetaDataRoot(ModelRoot modelRoot)
|
|
internal EXTStructuralMetaDataRoot(ModelRoot modelRoot)
|
|
|
{
|
|
{
|
|
|
this.modelRoot = modelRoot;
|
|
this.modelRoot = modelRoot;
|
|
|
|
|
+ _propertyTables = new List<PropertyTable>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- internal List<PropertyTable> PropertyTables
|
|
|
|
|
|
|
+ public List<PropertyTable> PropertyTables
|
|
|
{
|
|
{
|
|
|
get { return _propertyTables; }
|
|
get { return _propertyTables; }
|
|
|
- set { if (value == null) { _propertyTables = null; return; } _propertyTables = value; }
|
|
|
|
|
|
|
+ set { _propertyTables = value; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- internal StructuralMetadataSchema Schema
|
|
|
|
|
- {
|
|
|
|
|
- get { return _schema; }
|
|
|
|
|
- set { if (value == null) { _schema = null; return; } _schema = value; }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
protected override void OnValidateContent(ValidationContext validate)
|
|
protected override void OnValidateContent(ValidationContext validate)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- partial class StructuralMetadataSchema
|
|
|
|
|
|
|
+ public partial class PropertyTable
|
|
|
{
|
|
{
|
|
|
- public StructuralMetadataSchema()
|
|
|
|
|
|
|
+ public PropertyTable()
|
|
|
{
|
|
{
|
|
|
- _classes = new Dictionary<string, StructuralMetadataClass>();
|
|
|
|
|
|
|
+ _properties = new Dictionary<string, PropertyTableProperty>();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public Dictionary<string, StructuralMetadataClass> Classes { get; set; }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- partial class PropertyTable
|
|
|
|
|
- {
|
|
|
|
|
- public PropertyTable(string PropertyTableName, int numberOfFeatures)
|
|
|
|
|
|
|
+ public PropertyTable(string PropertyTableName, int NumberOfFeatures): this()
|
|
|
{
|
|
{
|
|
|
_class = PropertyTableName;
|
|
_class = PropertyTableName;
|
|
|
- _count = numberOfFeatures;
|
|
|
|
|
- _properties = new Dictionary<string, PropertyTableProperty>();
|
|
|
|
|
|
|
+ _count = NumberOfFeatures;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- partial class PropertyTableProperty
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- partial class StructuralMetadataClass
|
|
|
|
|
- {
|
|
|
|
|
- public StructuralMetadataClass()
|
|
|
|
|
|
|
+ public string PropertyTableName
|
|
|
{
|
|
{
|
|
|
- _properties = new Dictionary<string, ClassProperty>();
|
|
|
|
|
|
|
+ get { return _class; }
|
|
|
|
|
+ set { _class = value; }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- partial class ClassProperty
|
|
|
|
|
- {
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static class ExtStructuralMetadata
|
|
|
|
|
- {
|
|
|
|
|
- // Creates EXTStructuralMetaData with Schema and 1 PropertyTable
|
|
|
|
|
- public static void InitializeMetadataExtension(this ModelRoot modelRoot, string propertyTableName, int numberOfFeatures)
|
|
|
|
|
|
|
+ public int NumberOfFeatures
|
|
|
{
|
|
{
|
|
|
- if (propertyTableName == null) { modelRoot.RemoveExtensions<EXTStructuralMetaDataRoot>(); return; }
|
|
|
|
|
-
|
|
|
|
|
- var ext = modelRoot.UseExtension<EXTStructuralMetaDataRoot>();
|
|
|
|
|
-
|
|
|
|
|
- var schema = GetInitialSchema(propertyTableName);
|
|
|
|
|
- ext.Schema = schema;
|
|
|
|
|
- var propertyTable = new PropertyTable(propertyTableName, numberOfFeatures);
|
|
|
|
|
- ext.PropertyTables = new List<PropertyTable>() { propertyTable };
|
|
|
|
|
|
|
+ get { return _count; }
|
|
|
|
|
+ set { _count = value; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void AddMetadata<T>(this ModelRoot modelRoot, string fieldname, List<T> values)
|
|
|
|
|
|
|
+ public Dictionary<string, PropertyTableProperty> Properties
|
|
|
{
|
|
{
|
|
|
|
|
+ get { return _properties; }
|
|
|
|
|
+ set { _properties = value; }
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- private static StructuralMetadataSchema GetInitialSchema(string schemaName)
|
|
|
|
|
- {
|
|
|
|
|
- var structuralMetadataSchema = new StructuralMetadataSchema();
|
|
|
|
|
- var structuralMetadataClass = new StructuralMetadataClass();
|
|
|
|
|
-
|
|
|
|
|
- structuralMetadataSchema.Classes = new Dictionary<string, StructuralMetadataClass>
|
|
|
|
|
- {
|
|
|
|
|
- { schemaName , structuralMetadataClass }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- return structuralMetadataSchema;
|
|
|
|
|
|
|
+ public partial class PropertyTableProperty
|
|
|
|
|
+ {
|
|
|
|
|
+ public int Values {
|
|
|
|
|
+ get { return _values; }
|
|
|
|
|
+ set { _values = value; }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|