Fix generate-3d-tiles and generate-quantized-mesh-terrain

This commit is contained in:
Ashley Rogers 2024-11-15 15:41:48 -05:00
parent 7fd9590e95
commit aa11cca7e5
51 changed files with 661 additions and 41 deletions

View File

@ -27,5 +27,23 @@ struct CESIUM3DTILES_API Asset final : public CesiumUtility::ExtensibleObject {
* existing tileset is updated.
*/
std::optional<std::string> tilesetVersion;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Asset);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->version.capacity() * sizeof(char);
if (this->tilesetVersion) {
accum += this->tilesetVersion->capacity() * sizeof(char);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -49,5 +49,20 @@ struct CESIUM3DTILES_API Availability final
*
*/
std::optional<int32_t> constant;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Availability);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -47,5 +47,22 @@ struct CESIUM3DTILES_API BoundingVolume final
* shall not be negative.
*/
std::vector<double> sphere;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(BoundingVolume);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(double) * this->box.capacity();
accum += sizeof(double) * this->region.capacity();
accum += sizeof(double) * this->sphere.capacity();
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -37,6 +37,26 @@ struct CESIUM3DTILES_API BufferSpec : public CesiumUtility::ExtensibleObject {
*/
std::optional<std::string> name;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(BufferSpec);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->uri) {
accum += this->uri->capacity() * sizeof(char);
}
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
return accum;
}
private:
/**
* @brief This class is not meant to be instantiated directly. Use {@link Buffer} instead.

View File

@ -37,5 +37,22 @@ struct CESIUM3DTILES_API BufferView final
* @brief The name of the `bufferView`.
*/
std::optional<std::string> name;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(BufferView);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -34,5 +34,31 @@ struct CESIUM3DTILES_API Class final : public CesiumUtility::ExtensibleObject {
* identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::unordered_map<std::string, Cesium3DTiles::ClassProperty> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Class);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::ClassProperty));
for (const auto& [k, v] : this->properties) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::ClassProperty);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -189,5 +189,31 @@ struct CESIUM3DTILES_API ClassProperty final
* interpreted. The semantic cannot be used by other properties in the class.
*/
std::optional<std::string> semantic;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(ClassProperty);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
if (this->enumType) {
accum += this->enumType->capacity() * sizeof(char);
}
if (this->semantic) {
accum += this->semantic->capacity() * sizeof(char);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -31,5 +31,25 @@ struct CESIUM3DTILES_API ClassStatistics final
* statistics about property values.
*/
std::unordered_map<std::string, Cesium3DTiles::PropertyStatistics> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(ClassStatistics);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::PropertyStatistics));
for (const auto& [k, v] : this->properties) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::PropertyStatistics);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -44,5 +44,28 @@ struct CESIUM3DTILES_API Content final
* array of `groups` that is defined for the containing tileset.
*/
std::optional<int64_t> group;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Content);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->boundingVolume) {
accum += this->boundingVolume->getSizeBytes() -
sizeof(Cesium3DTiles::BoundingVolume);
}
accum += this->uri.capacity() * sizeof(char);
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
sizeof(Cesium3DTiles::MetadataEntity);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -62,5 +62,29 @@ struct CESIUM3DTILES_API Enum final : public CesiumUtility::ExtensibleObject {
* are not allowed.
*/
std::vector<Cesium3DTiles::EnumValue> values;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Enum);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
accum += sizeof(Cesium3DTiles::EnumValue) * this->values.capacity();
for (const Cesium3DTiles::EnumValue& value : this->values) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::EnumValue);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -32,5 +32,23 @@ struct CESIUM3DTILES_API EnumValue final
* @brief The integer enum value.
*/
int64_t value = int64_t();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(EnumValue);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->name.capacity() * sizeof(char);
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -37,5 +37,20 @@ struct CESIUM3DTILES_API Extension3dTilesBoundingVolumeS2 final
* the WGS84 ellipsoid.
*/
double maximumHeight = double();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Extension3dTilesBoundingVolumeS2);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->token.capacity() * sizeof(char);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -11,5 +11,19 @@ namespace Cesium3DTiles {
*/
struct CESIUM3DTILES_API GroupMetadata final : public MetadataEntity {
static inline constexpr const char* TypeName = "GroupMetadata";
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(GroupMetadata);
accum += MetadataEntity::getSizeBytes() - sizeof(MetadataEntity);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -54,5 +54,20 @@ struct CESIUM3DTILES_API ImplicitTiling final
* @brief An object describing the location of subtree files.
*/
Cesium3DTiles::Subtrees subtrees;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(ImplicitTiling);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->subtrees.getSizeBytes() - sizeof(Cesium3DTiles::Subtrees);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -36,5 +36,26 @@ struct CESIUM3DTILES_API MetadataEntity
* in this dictionary.
*/
std::unordered_map<std::string, CesiumUtility::JsonValue> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(MetadataEntity);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->classProperty.capacity() * sizeof(char);
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumUtility::JsonValue));
for (const auto& [k, v] : this->properties) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += sizeof(CesiumUtility::JsonValue);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -25,5 +25,20 @@ struct CESIUM3DTILES_API Properties final
* tileset. The maximum value shall not be smaller than the minimum value.
*/
double minimum = double();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Properties);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -81,5 +81,25 @@ struct CESIUM3DTILES_API PropertyStatistics final
* component-wise occurrences.
*/
std::unordered_map<std::string, CesiumUtility::JsonValue> occurrences;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(PropertyStatistics);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->occurrences.bucket_count() *
(sizeof(std::string) + sizeof(CesiumUtility::JsonValue));
for (const auto& [k, v] : this->occurrences) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += sizeof(CesiumUtility::JsonValue);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -45,5 +45,30 @@ struct CESIUM3DTILES_API PropertyTable final
*/
std::unordered_map<std::string, Cesium3DTiles::PropertyTableProperty>
properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(PropertyTable);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
accum += this->classProperty.capacity() * sizeof(char);
accum +=
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::PropertyTableProperty));
for (const auto& [k, v] : this->properties) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::PropertyTableProperty);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -135,5 +135,20 @@ struct CESIUM3DTILES_API PropertyTableProperty final
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> min;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(PropertyTableProperty);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -53,5 +53,41 @@ struct CESIUM3DTILES_API Schema final : public CesiumUtility::ExtensibleObject {
* identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::unordered_map<std::string, Cesium3DTiles::Enum> enums;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Schema);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->id.capacity() * sizeof(char);
if (this->name) {
accum += this->name->capacity() * sizeof(char);
}
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
if (this->version) {
accum += this->version->capacity() * sizeof(char);
}
accum += this->classes.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Class));
for (const auto& [k, v] : this->classes) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::Class);
}
accum += this->enums.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Enum));
for (const auto& [k, v] : this->enums) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::Enum);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -24,5 +24,25 @@ struct CESIUM3DTILES_API Statistics final
* statistics about entities that conform to the class.
*/
std::unordered_map<std::string, Cesium3DTiles::ClassStatistics> classes;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Statistics);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->classes.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::ClassStatistics));
for (const auto& [k, v] : this->classes) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::ClassStatistics);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -99,5 +99,46 @@ struct CESIUM3DTILES_API Subtree final
* @brief Subtree metadata encoded in JSON.
*/
std::optional<Cesium3DTiles::MetadataEntity> subtreeMetadata;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Subtree);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(Cesium3DTiles::Buffer) * this->buffers.capacity();
for (const Cesium3DTiles::Buffer& value : this->buffers) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::Buffer);
}
accum += sizeof(Cesium3DTiles::BufferView) * this->bufferViews.capacity();
for (const Cesium3DTiles::BufferView& value : this->bufferViews) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::BufferView);
}
accum +=
sizeof(Cesium3DTiles::PropertyTable) * this->propertyTables.capacity();
for (const Cesium3DTiles::PropertyTable& value : this->propertyTables) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::PropertyTable);
}
accum += this->tileAvailability.getSizeBytes() -
sizeof(Cesium3DTiles::Availability);
accum += sizeof(Cesium3DTiles::Availability) *
this->contentAvailability.capacity();
for (const Cesium3DTiles::Availability& value : this->contentAvailability) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::Availability);
}
accum += this->childSubtreeAvailability.getSizeBytes() -
sizeof(Cesium3DTiles::Availability);
accum += sizeof(int64_t) * this->contentMetadata.capacity();
if (this->subtreeMetadata) {
accum += this->subtreeMetadata->getSizeBytes() -
sizeof(Cesium3DTiles::MetadataEntity);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -20,5 +20,20 @@ struct CESIUM3DTILES_API Subtrees final
* @brief A URI with embedded expressions that describes the resource that is associated with an implicit tile in an implicit tileset. Allowed expressions are `{level}`, `{x}`, `{y}`, and `{z}`. `{level}` is substituted with the level of the node, `{x}` is substituted with the x index of the node within the level, and `{y}` is substituted with the y index of the node within the level. `{z}` may only be given when the subdivision scheme is `OCTREE`, and it is substituted with the z index of the node within the level.
*/
std::string uri;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Subtrees);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->uri.capacity() * sizeof(char);
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -107,5 +107,45 @@ struct CESIUM3DTILES_API Tile final : public CesiumUtility::ExtensibleObject {
* tiles, there are no children, and this property may not be defined.
*/
std::vector<Cesium3DTiles::Tile> children;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Tile);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->boundingVolume.getSizeBytes() -
sizeof(Cesium3DTiles::BoundingVolume);
if (this->viewerRequestVolume) {
accum += this->viewerRequestVolume->getSizeBytes() -
sizeof(Cesium3DTiles::BoundingVolume);
}
accum += sizeof(double) * this->transform.capacity();
if (this->content) {
accum += this->content->getSizeBytes() - sizeof(Cesium3DTiles::Content);
}
accum += sizeof(Cesium3DTiles::Content) * this->contents.capacity();
for (const Cesium3DTiles::Content& value : this->contents) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::Content);
}
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
sizeof(Cesium3DTiles::MetadataEntity);
}
if (this->implicitTiling) {
accum += this->implicitTiling->getSizeBytes() -
sizeof(Cesium3DTiles::ImplicitTiling);
}
accum += sizeof(Cesium3DTiles::Tile) * this->children.capacity();
for (const Cesium3DTiles::Tile& value : this->children) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::Tile);
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -87,5 +87,47 @@ struct CESIUM3DTILES_API Tileset final
* Each element of this array shall also be contained in `extensionsUsed`.
*/
std::vector<std::string> extensionsRequired;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(Tileset);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->asset.getSizeBytes() - sizeof(Cesium3DTiles::Asset);
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Properties));
for (const auto& [k, v] : this->properties) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(Cesium3DTiles::Properties);
}
if (this->schema) {
accum += this->schema->getSizeBytes() - sizeof(Cesium3DTiles::Schema);
}
if (this->schemaUri) {
accum += this->schemaUri->capacity() * sizeof(char);
}
if (this->statistics) {
accum +=
this->statistics->getSizeBytes() - sizeof(Cesium3DTiles::Statistics);
}
accum += sizeof(Cesium3DTiles::GroupMetadata) * this->groups.capacity();
for (const Cesium3DTiles::GroupMetadata& value : this->groups) {
accum += value.getSizeBytes() - sizeof(Cesium3DTiles::GroupMetadata);
}
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
sizeof(Cesium3DTiles::MetadataEntity);
}
accum += this->root.getSizeBytes() - sizeof(Cesium3DTiles::Tile);
accum += sizeof(std::string) * this->extensionsUsed.capacity();
accum += sizeof(std::string) * this->extensionsRequired.capacity();
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -32,6 +32,7 @@
#include <CesiumJsonWriter/JsonObjectWriter.h>
#include <CesiumJsonWriter/JsonWriter.h>
#include <CesiumJsonWriter/writeJsonExtensions.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <CesiumUtility/JsonValue.h>
namespace Cesium3DTilesWriter {
@ -171,6 +172,14 @@ template <typename T>
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context);
template <typename T>
[[maybe_unused]] void writeJson(
const CesiumUtility::IntrusivePointer<T>& ptr,
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context) {
writeJson(*ptr, jsonWriter, context);
}
[[maybe_unused]] void writeJson(
const std::string& str,
CesiumJsonWriter::JsonWriter& jsonWriter,
@ -279,6 +288,14 @@ void writeExtensibleObject(
}
}
template <typename T>
void writeSharedAsset(
const T& obj,
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context) {
writeExtensibleObject(obj, jsonWriter, context);
}
template <typename T>
void writeNamedObject(
const T& obj,

View File

@ -41,12 +41,10 @@ struct CESIUMGLTF_API Animation final : public CesiumGltf::NamedObject {
accum += sizeof(Animation);
accum += CesiumGltf::NamedObject::getSizeBytes() -
sizeof(CesiumGltf::NamedObject);
accum += sizeof(CesiumGltf::AnimationChannel) * this->channels.capacity();
for (const CesiumGltf::AnimationChannel& value : this->channels) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::AnimationChannel);
}
accum += sizeof(CesiumGltf::AnimationSampler) * this->samplers.capacity();
for (const CesiumGltf::AnimationSampler& value : this->samplers) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::AnimationSampler);

View File

@ -52,7 +52,6 @@ struct CESIUMGLTF_API Class final : public CesiumUtility::ExtensibleObject {
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::ClassProperty));
for (const auto& [k, v] : this->properties) {

View File

@ -80,7 +80,6 @@ struct CESIUMGLTF_API Enum final : public CesiumUtility::ExtensibleObject {
if (this->description) {
accum += this->description->capacity() * sizeof(char);
}
accum += sizeof(CesiumGltf::EnumValue) * this->values.capacity();
for (const CesiumGltf::EnumValue& value : this->values) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::EnumValue);

View File

@ -34,7 +34,6 @@ struct CESIUMGLTF_API ExtensionExtInstanceFeatures final
accum += sizeof(ExtensionExtInstanceFeatures);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(CesiumGltf::ExtensionExtInstanceFeaturesFeatureId) *
this->featureIds.capacity();
for (const CesiumGltf::ExtensionExtInstanceFeaturesFeatureId& value :

View File

@ -34,7 +34,6 @@ struct CESIUMGLTF_API ExtensionExtMeshFeatures final
accum += sizeof(ExtensionExtMeshFeatures);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(CesiumGltf::FeatureId) * this->featureIds.capacity();
for (const CesiumGltf::FeatureId& value : this->featureIds) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::FeatureId);

View File

@ -43,7 +43,6 @@ struct CESIUMGLTF_API ExtensionExtMeshGpuInstancing final
accum += sizeof(ExtensionExtMeshGpuInstancing);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->attributes.bucket_count() *
(sizeof(std::string) + sizeof(int32_t));
for (const auto& [k, v] : this->attributes) {

View File

@ -42,7 +42,6 @@ struct CESIUMGLTF_API ExtensionKhrDracoMeshCompression final
accum += sizeof(ExtensionKhrDracoMeshCompression);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->attributes.bucket_count() *
(sizeof(std::string) + sizeof(int32_t));
for (const auto& [k, v] : this->attributes) {

View File

@ -40,7 +40,6 @@ struct CESIUMGLTF_API ExtensionMeshPrimitiveKhrMaterialsVariants final
accum += sizeof(ExtensionMeshPrimitiveKhrMaterialsVariants);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum +=
sizeof(CesiumGltf::
ExtensionMeshPrimitiveKhrMaterialsVariantsMappingsValue) *

View File

@ -69,19 +69,16 @@ struct CESIUMGLTF_API ExtensionModelExtStructuralMetadata final
if (this->schemaUri) {
accum += this->schemaUri->capacity() * sizeof(char);
}
accum +=
sizeof(CesiumGltf::PropertyTable) * this->propertyTables.capacity();
for (const CesiumGltf::PropertyTable& value : this->propertyTables) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::PropertyTable);
}
accum +=
sizeof(CesiumGltf::PropertyTexture) * this->propertyTextures.capacity();
for (const CesiumGltf::PropertyTexture& value : this->propertyTextures) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::PropertyTexture);
}
accum += sizeof(CesiumGltf::PropertyAttribute) *
this->propertyAttributes.capacity();
for (const CesiumGltf::PropertyAttribute& value :

View File

@ -35,7 +35,6 @@ struct CESIUMGLTF_API ExtensionModelKhrMaterialsVariants final
accum += sizeof(ExtensionModelKhrMaterialsVariants);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(CesiumGltf::ExtensionModelKhrMaterialsVariantsValue) *
this->variants.capacity();
for (const CesiumGltf::ExtensionModelKhrMaterialsVariantsValue& value :

View File

@ -43,7 +43,6 @@ struct CESIUMGLTF_API ExtensionModelMaxarMeshVariants final
accum += sizeof(ExtensionModelMaxarMeshVariants);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(CesiumGltf::ExtensionModelMaxarMeshVariantsValue) *
this->variants.capacity();
for (const CesiumGltf::ExtensionModelMaxarMeshVariantsValue& value :

View File

@ -35,7 +35,6 @@ struct CESIUMGLTF_API ExtensionNodeMaxarMeshVariants final
accum += sizeof(ExtensionNodeMaxarMeshVariants);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(CesiumGltf::ExtensionNodeMaxarMeshVariantsMappingsValue) *
this->mappings.capacity();
for (const CesiumGltf::ExtensionNodeMaxarMeshVariantsMappingsValue& value :

View File

@ -38,7 +38,6 @@ struct CESIUMGLTF_API Mesh final : public CesiumGltf::NamedObject {
accum += sizeof(Mesh);
accum += CesiumGltf::NamedObject::getSizeBytes() -
sizeof(CesiumGltf::NamedObject);
accum += sizeof(CesiumGltf::MeshPrimitive) * this->primitives.capacity();
for (const CesiumGltf::MeshPrimitive& value : this->primitives) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::MeshPrimitive);

View File

@ -82,7 +82,6 @@ struct CESIUMGLTF_API MeshPrimitive final
accum += sizeof(MeshPrimitive);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->attributes.bucket_count() *
(sizeof(std::string) + sizeof(int32_t));
for (const auto& [k, v] : this->attributes) {

View File

@ -150,68 +150,55 @@ struct CESIUMGLTF_API ModelSpec : public CesiumUtility::ExtensibleObject {
sizeof(CesiumUtility::ExtensibleObject);
accum += sizeof(std::string) * this->extensionsUsed.capacity();
accum += sizeof(std::string) * this->extensionsRequired.capacity();
accum += sizeof(CesiumGltf::Accessor) * this->accessors.capacity();
for (const CesiumGltf::Accessor& value : this->accessors) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Accessor);
}
accum += sizeof(CesiumGltf::Animation) * this->animations.capacity();
for (const CesiumGltf::Animation& value : this->animations) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Animation);
}
accum += this->asset.getSizeBytes() - sizeof(CesiumGltf::Asset);
accum += sizeof(CesiumGltf::Buffer) * this->buffers.capacity();
for (const CesiumGltf::Buffer& value : this->buffers) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Buffer);
}
accum += sizeof(CesiumGltf::BufferView) * this->bufferViews.capacity();
for (const CesiumGltf::BufferView& value : this->bufferViews) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::BufferView);
}
accum += sizeof(CesiumGltf::Camera) * this->cameras.capacity();
for (const CesiumGltf::Camera& value : this->cameras) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Camera);
}
accum += sizeof(CesiumGltf::Image) * this->images.capacity();
for (const CesiumGltf::Image& value : this->images) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Image);
}
accum += sizeof(CesiumGltf::Material) * this->materials.capacity();
for (const CesiumGltf::Material& value : this->materials) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Material);
}
accum += sizeof(CesiumGltf::Mesh) * this->meshes.capacity();
for (const CesiumGltf::Mesh& value : this->meshes) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Mesh);
}
accum += sizeof(CesiumGltf::Node) * this->nodes.capacity();
for (const CesiumGltf::Node& value : this->nodes) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Node);
}
accum += sizeof(CesiumGltf::Sampler) * this->samplers.capacity();
for (const CesiumGltf::Sampler& value : this->samplers) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Sampler);
}
accum += sizeof(CesiumGltf::Scene) * this->scenes.capacity();
for (const CesiumGltf::Scene& value : this->scenes) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Scene);
}
accum += sizeof(CesiumGltf::Skin) * this->skins.capacity();
for (const CesiumGltf::Skin& value : this->skins) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Skin);
}
accum += sizeof(CesiumGltf::Texture) * this->textures.capacity();
for (const CesiumGltf::Texture& value : this->textures) {
accum += value.getSizeBytes() - sizeof(CesiumGltf::Texture);

View File

@ -55,7 +55,6 @@ struct CESIUMGLTF_API PropertyAttribute final
accum += this->name->capacity() * sizeof(char);
}
accum += this->classProperty.capacity() * sizeof(char);
accum +=
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::PropertyAttributeProperty));

View File

@ -60,7 +60,6 @@ struct CESIUMGLTF_API PropertyTable final
accum += this->name->capacity() * sizeof(char);
}
accum += this->classProperty.capacity() * sizeof(char);
accum += this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::PropertyTableProperty));
for (const auto& [k, v] : this->properties) {

View File

@ -55,7 +55,6 @@ struct CESIUMGLTF_API PropertyTexture final
accum += this->name->capacity() * sizeof(char);
}
accum += this->classProperty.capacity() * sizeof(char);
accum +=
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::PropertyTextureProperty));

View File

@ -75,14 +75,12 @@ struct CESIUMGLTF_API Schema final : public CesiumUtility::SharedAsset<Schema> {
if (this->version) {
accum += this->version->capacity() * sizeof(char);
}
accum += this->classes.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::Class));
for (const auto& [k, v] : this->classes) {
accum += k.capacity() * sizeof(char) - sizeof(std::string);
accum += v.getSizeBytes() - sizeof(CesiumGltf::Class);
}
accum += this->enums.bucket_count() *
(sizeof(std::string) + sizeof(CesiumGltf::Enum));
for (const auto& [k, v] : this->enums) {

View File

@ -72,6 +72,7 @@
#include <CesiumJsonWriter/JsonObjectWriter.h>
#include <CesiumJsonWriter/JsonWriter.h>
#include <CesiumJsonWriter/writeJsonExtensions.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <CesiumUtility/JsonValue.h>
namespace CesiumGltfWriter {

View File

@ -35,5 +35,20 @@ struct CESIUMQUANTIZEDMESHTERRAIN_API AvailabilityRectangle final
* @brief The index of the end tile in the Y direction.
*/
int64_t endY = int64_t();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(AvailabilityRectangle);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
return accum;
}
};
} // namespace CesiumQuantizedMeshTerrain

View File

@ -102,6 +102,46 @@ struct CESIUMQUANTIZEDMESHTERRAIN_API LayerSpec
*/
std::string version = "1.0.0";
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += sizeof(LayerSpec);
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
sizeof(CesiumUtility::ExtensibleObject);
accum += this->attribution.capacity() * sizeof(char);
accum +=
sizeof(std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>) *
this->available.capacity();
for (const std::vector<CesiumQuantizedMeshTerrain::AvailabilityRectangle>&
valueOuter : this->available) {
accum += sizeof(CesiumQuantizedMeshTerrain::AvailabilityRectangle) *
valueOuter.capacity();
for (const CesiumQuantizedMeshTerrain::AvailabilityRectangle& value :
valueOuter) {
accum += value.getSizeBytes() -
sizeof(CesiumQuantizedMeshTerrain::AvailabilityRectangle);
}
}
accum += sizeof(double) * this->bounds.capacity();
accum += this->description.capacity() * sizeof(char);
accum += sizeof(std::string) * this->extensionsProperty.capacity();
accum += this->format.capacity() * sizeof(char);
accum += this->name.capacity() * sizeof(char);
if (this->parentUrl) {
accum += this->parentUrl->capacity() * sizeof(char);
}
accum += this->projection.capacity() * sizeof(char);
accum += this->scheme.capacity() * sizeof(char);
accum += sizeof(std::string) * this->tiles.capacity();
accum += this->version.capacity() * sizeof(char);
return accum;
}
private:
/**
* @brief This class is not meant to be instantiated directly. Use {@link Layer} instead.

View File

@ -9,6 +9,7 @@
#include <CesiumJsonWriter/writeJsonExtensions.h>
#include <CesiumQuantizedMeshTerrain/AvailabilityRectangle.h>
#include <CesiumQuantizedMeshTerrain/Layer.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <CesiumUtility/JsonValue.h>
namespace CesiumQuantizedMeshTerrain {
@ -33,6 +34,14 @@ template <typename T>
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context);
template <typename T>
[[maybe_unused]] void writeJson(
const CesiumUtility::IntrusivePointer<T>& ptr,
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context) {
writeJson(*ptr, jsonWriter, context);
}
[[maybe_unused]] void writeJson(
const std::string& str,
CesiumJsonWriter::JsonWriter& jsonWriter,
@ -141,6 +150,14 @@ void writeExtensibleObject(
}
}
template <typename T>
void writeSharedAsset(
const T& obj,
CesiumJsonWriter::JsonWriter& jsonWriter,
const CesiumJsonWriter::ExtensionWriterContext& context) {
writeExtensibleObject(obj, jsonWriter, context);
}
template <typename T>
void writeNamedObject(
const T& obj,

View File

@ -53,6 +53,7 @@ function generateCombinedWriter(options) {
#include "${name}JsonWriter.h"
#include <CesiumUtility/JsonValue.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <CesiumJsonWriter/ExtensionWriterContext.h>
#include <CesiumJsonWriter/writeJsonExtensions.h>
#include <CesiumJsonWriter/JsonObjectWriter.h>

View File

@ -413,10 +413,17 @@ function resolveArray(
return `${accumName} += sizeof(${itemProperty.type}) * ${propertyName}.capacity();`;
}
return `
${accumName} += sizeof(${itemProperty.type}) * ${propertyName}.capacity();
for(const ${itemProperty.type}& value : ${propertyName}) {
${resolveSizeOfForProperty(itemProperty, "value", accumName)}
// We need to change the name of the variable we're iterating with if the contents are also a vector,
// as it will otherwise also generate code with `value` and cause a "hides previous local declaration" error.
// TODO: support more than two nested loops
let iterName = "value";
if (itemProperty.type.indexOf("std::vector") == 0) {
iterName = "valueOuter";
}
return `${accumName} += sizeof(${itemProperty.type}) * ${propertyName}.capacity();
for(const ${itemProperty.type}& ${iterName} : ${propertyName}) {
${resolveSizeOfForProperty(itemProperty, iterName, accumName)}
}`;
}
};
@ -466,8 +473,7 @@ function resolveDictionary(
],
readerType: `CesiumJsonReader::DictionaryJsonHandler<${additional.type}, ${additional.readerType}>`,
sizeOfFormatter: (propertyName, accumName) => {
return `
${accumName} += ${propertyName}.bucket_count() * (sizeof(std::string) + sizeof(${additional.type}));
return `${accumName} += ${propertyName}.bucket_count() * (sizeof(std::string) + sizeof(${additional.type}));
for(const auto& [k, v] : ${propertyName}) {
${accumName} += k.capacity() * sizeof(char) - sizeof(std::string);
${resolveSizeOfForProperty(additional, "v", accumName) || `${accumName} += sizeof(${additional.type});`}