Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 10, 2024
1 parent 1812ccb commit 48097eb
Show file tree
Hide file tree
Showing 54 changed files with 936 additions and 213 deletions.
87 changes: 85 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,8 +1,91 @@
---
Checks:
- "-*"
- "misc-include-cleaner"
- "bugprone-implicit-widening-of-multiplication-result"
# - "misc-include-cleaner"
# - "bugprone-argument-comment"
# - "bugprone-assert-side-effect"
# - "bugprone-assignment-in-if-condition"
# - "bugprone-bad-signal-to-kill-thread"
# - "bugprone-bool-pointer-implicit-conversion"
# - "bugprone-branch-clone"
# - "bugprone-casting-through-void"
# - "bugprone-chained-comparison"
# - "bugprone-compare-pointer-to-member-virtual-function"
# - "bugprone-copy-constructor-init"
# - "bugprone-crtp-constructor-accessibility"
# - "bugprone-dangling-handle"
# - "bugprone-dynamic-static-initializers"
# - "-bugprone-easily-swappable-parameters"
# - "bugprone-empty-catch"
# - "-bugprone-exception-escape" # For now
# - "bugprone-fold-init-type"
# - "bugprone-forward-declaration-namespace"
# - "bugprone-forwarding-reference-overload"
# - "bugprone-implicit-widening-of-multiplication-result"
# - "bugprone-inaccurate-erase"
# - "bugprone-inc-dec-in-conditions"
# - "bugprone-incorrect-enable-if"
# - "bugprone-incorrect-roundings"
# - "bugprone-infinite-loop"
# - "bugprone-unhandled-self-assignment"
- "bugprone-unchecked-optional-access"

# - "bugprone-integer-division"
# - "bugprone-lambda-function-name"
# - "bugprone-macro-parentheses"
# - "bugprone-macro-repeated-side-effects"
# - "bugprone-misplaced-operator-in-strlen-in-alloc"
# - "bugprone-misplaced-pointer-arithmetic-in-alloc"
# - "bugprone-misplaced-widening-cast"
# - "bugprone-move-forwarding-reference"
# - "bugprone-multi-level-implicit-pointer-conversion"
# - "bugprone-multiple-new-in-one-expression"
# - "bugprone-multiple-statement-macro"
# - "bugprone-no-escape"
# - "bugprone-non-zero-enum-to-bool-conversion"
# - "bugprone-not-null-terminated-result"
# - "bugprone-optional-value-conversion"
# - "bugprone-parent-virtual-call"
# - "bugprone-pointer-arithmetic-on-polymorphic-object"
# - "bugprone-posix-return"
# - "bugprone-redundant-branch-condition"
# - "bugprone-reserved-identifier"
# - "bugprone-return-const-ref-from-parameter"
# - "bugprone-shared-ptr-array-mismatch"
# - "bugprone-signal-handler"
# - "bugprone-signed-char-misuse"
# - "bugprone-sizeof-container"
# - "bugprone-sizeof-expression"
# - "bugprone-spuriously-wake-up-functions"
# - "bugprone-standalone-empty"
# - "bugprone-string-constructor"
# - "bugprone-string-integer-assignment"
# - "bugprone-string-literal-with-embedded-nul"
# - "bugprone-stringview-nullptr"
# - "bugprone-suspicious-enum-usage"
# - "bugprone-suspicious-include"
# - "bugprone-suspicious-memory-comparison"
# - "bugprone-suspicious-memset-usage"
# - "bugprone-suspicious-missing-comma"
# - "bugprone-suspicious-realloc-usage"
# - "bugprone-suspicious-semicolon"
# - "bugprone-suspicious-string-compare"
# - "bugprone-suspicious-stringview-data-usage"
# - "bugprone-swapped-arguments"
# - "bugprone-switch-missing-default-case"
# - "bugprone-terminating-continue"
# - "bugprone-throw-keyword-missing"
# - "bugprone-too-small-loop-variable"
# - "bugprone-undefined-memory-manipulation"
# - "bugprone-undelegated-constructor"
# - "bugprone-unhandled-exception-at-new"
# - "bugprone-unique-ptr-array-mismatch"
# - "bugprone-unsafe-functions"
# - "bugprone-unused-local-non-trivial-variable"
# - "bugprone-unused-raii"
# - "bugprone-unused-return-value"
# - "bugprone-use-after-move"
# - "bugprone-virtual-near-miss"

WarningsAsErrors: "*"
FormatStyle: none
Expand Down
3 changes: 3 additions & 0 deletions Cesium3DTiles/test/TestMetadataQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ TEST_CASE("MetadataQuery") {
withSemantic,
"SOME_SEMANTIC");
REQUIRE(foundProperty2);
if (!foundProperty2) {
return;
}
CHECK(foundProperty2->classIdentifier == "someClass");
CHECK(&foundProperty2->classDefinition == &classDefinition);
CHECK(foundProperty2->propertyIdentifier == "somePropertyWithSemantic");
Expand Down
30 changes: 16 additions & 14 deletions Cesium3DTilesContent/src/B3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,22 @@ rapidjson::Document parseFeatureTableJsonData(
return document;
}

const auto rtcIt = document.FindMember("RTC_CENTER");
if (rtcIt != document.MemberEnd() && rtcIt->value.IsArray() &&
rtcIt->value.Size() == 3 && rtcIt->value[0].IsNumber() &&
rtcIt->value[1].IsNumber() && rtcIt->value[2].IsNumber()) {
// Add the RTC_CENTER value to the glTF as a CESIUM_RTC extension.
rapidjson::Value& rtcValue = rtcIt->value;
auto& cesiumRTC =
result.model->addExtension<CesiumGltf::ExtensionCesiumRTC>();
result.model->addExtensionRequired(
CesiumGltf::ExtensionCesiumRTC::ExtensionName);
cesiumRTC.center = {
rtcValue[0].GetDouble(),
rtcValue[1].GetDouble(),
rtcValue[2].GetDouble()};
if (result.model) {
const auto rtcIt = document.FindMember("RTC_CENTER");
if (rtcIt != document.MemberEnd() && rtcIt->value.IsArray() &&
rtcIt->value.Size() == 3 && rtcIt->value[0].IsNumber() &&
rtcIt->value[1].IsNumber() && rtcIt->value[2].IsNumber()) {
// Add the RTC_CENTER value to the glTF as a CESIUM_RTC extension.
rapidjson::Value& rtcValue = rtcIt->value;
auto& cesiumRTC =
result.model->addExtension<CesiumGltf::ExtensionCesiumRTC>();
result.model->addExtensionRequired(
CesiumGltf::ExtensionCesiumRTC::ExtensionName);
cesiumRTC.center = {
rtcValue[0].GetDouble(),
rtcValue[1].GetDouble(),
rtcValue[2].GetDouble()};
}
}

return document;
Expand Down
17 changes: 9 additions & 8 deletions Cesium3DTilesContent/src/BatchTableToGltfStructuralMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct MaskedType {
bool isFloat64;
bool isBool;

MaskedType() : MaskedType(true){};
MaskedType() : MaskedType(true) {};

MaskedType(bool defaultValue)
: isInt8(defaultValue),
Expand Down Expand Up @@ -123,12 +123,12 @@ struct MaskedArrayType {
uint32_t minArrayCount;
uint32_t maxArrayCount;

MaskedArrayType() : MaskedArrayType(true){};
MaskedArrayType() : MaskedArrayType(true) {};

MaskedArrayType(bool defaultValue)
: elementType(defaultValue),
minArrayCount(std::numeric_limits<uint32_t>::max()),
maxArrayCount(std::numeric_limits<uint32_t>::min()){};
maxArrayCount(std::numeric_limits<uint32_t>::min()) {};

MaskedArrayType(
MaskedType inElementType,
Expand Down Expand Up @@ -197,10 +197,10 @@ struct CompatibleTypes {
bool _canUseNullStringSentinel = true;

public:
CompatibleTypes() : _type(){};
CompatibleTypes(const MaskedType& maskedType) : _type(maskedType){};
CompatibleTypes() : _type() {};
CompatibleTypes(const MaskedType& maskedType) : _type(maskedType) {};
CompatibleTypes(const MaskedArrayType& maskedArrayType)
: _type(maskedArrayType){};
: _type(maskedArrayType) {};

/**
* Whether this is exclusively compatible with array types. This indicates an
Expand Down Expand Up @@ -732,7 +732,8 @@ void updateExtensionWithJsonStringProperty(
// Because serialized string json will add double quotations in the
// buffer which is not needed by us, we will manually add the string to
// the buffer
const auto& rapidjsonStr = it->IsNull() ? *noDataValue : it->GetString();
const auto& rapidjsonStr =
it->IsNull() && noDataValue ? *noDataValue : it->GetString();
rapidjsonStrBuffer.Reserve(it->GetStringLength());
for (rapidjson::SizeType j = 0; j < it->GetStringLength(); ++j) {
rapidjsonStrBuffer.PutUnsafe(rapidjsonStr[j]);
Expand Down Expand Up @@ -814,7 +815,7 @@ void updateExtensionWithJsonScalarProperty(
}

for (int64_t i = 0; i < propertyTable.count; ++i, ++p, ++it) {
if (it->IsNull()) {
if (it->IsNull() && noDataValue) {
*p = *noDataValue;
} else {
*p = static_cast<T>(it->template Get<TRapidJson>());
Expand Down
2 changes: 1 addition & 1 deletion Cesium3DTilesContent/src/I3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ CesiumAsync::Future<ConvertedI3dm> convertI3dmContent(
pBinaryData + *parsedContent.position),
numInstances);
decodedInstances.positions.assign(rawPositions.begin(), rawPositions.end());
} else {
} else if (parsedContent.positionQuantized) {
gsl::span<const uint16_t[3]> rawQuantizedPositions(
reinterpret_cast<const uint16_t(*)[3]>(
pBinaryData + *parsedContent.positionQuantized),
Expand Down
7 changes: 7 additions & 0 deletions Cesium3DTilesContent/src/PntsToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,10 @@ void parsePositionsFromFeatureTableBinary(
featureTableBinaryData.data() + parsedContent.position.byteOffset),
pointsLength);

// NOLINTBEGIN(bugprone-unchecked-optional-access)
const glm::vec3 quantizedVolumeScale(*parsedContent.quantizedVolumeScale);
const glm::vec3 quantizedVolumeOffset(*parsedContent.quantizedVolumeOffset);
// NOLINTEND(bugprone-unchecked-optional-access)

const glm::vec3 quantizedPositionScalar = quantizedVolumeScale / 65535.0f;

Expand Down Expand Up @@ -1186,6 +1188,7 @@ void parsePositionsFromFeatureTableBinary(
void parseColorsFromFeatureTableBinary(
const gsl::span<const std::byte>& featureTableBinaryData,
PntsContent& parsedContent) {
CESIUM_ASSERT(parsedContent.color);
PntsSemantic& color = *parsedContent.color;
std::vector<std::byte>& colorData = color.data;
if (colorData.size() > 0) {
Expand Down Expand Up @@ -1248,6 +1251,7 @@ void parseColorsFromFeatureTableBinary(
void parseNormalsFromFeatureTableBinary(
const gsl::span<const std::byte>& featureTableBinaryData,
PntsContent& parsedContent) {
CESIUM_ASSERT(parsedContent.normal);
PntsSemantic& normal = *parsedContent.normal;
std::vector<std::byte>& normalData = normal.data;
if (normalData.size() > 0) {
Expand Down Expand Up @@ -1287,6 +1291,7 @@ void parseNormalsFromFeatureTableBinary(
void parseBatchIdsFromFeatureTableBinary(
const gsl::span<const std::byte>& featureTableBinaryData,
PntsContent& parsedContent) {
CESIUM_ASSERT(parsedContent.batchId);
PntsSemantic& batchId = *parsedContent.batchId;
std::vector<std::byte>& batchIdData = batchId.data;
if (batchIdData.size() > 0) {
Expand Down Expand Up @@ -1410,6 +1415,7 @@ void addPositionsToGltf(PntsContent& parsedContent, Model& gltf) {
}

void addColorsToGltf(PntsContent& parsedContent, Model& gltf) {
CESIUM_ASSERT(parsedContent.color);
PntsSemantic& color = *parsedContent.color;

const int64_t count = static_cast<int64_t>(parsedContent.pointsLength);
Expand Down Expand Up @@ -1445,6 +1451,7 @@ void addColorsToGltf(PntsContent& parsedContent, Model& gltf) {
}

void addNormalsToGltf(PntsContent& parsedContent, Model& gltf) {
CESIUM_ASSERT(parsedContent.normal);
PntsSemantic& normal = *parsedContent.normal;

const int64_t count = static_cast<int64_t>(parsedContent.pointsLength);
Expand Down
6 changes: 6 additions & 0 deletions Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ TEST_CASE("B3dmToGltfConverter") {
GltfConverterResult result = ConvertTileToGltf::fromB3dm(testFilePath);

REQUIRE(result.model);
if (!result.model) {
return;
}

Model& gltf = *result.model;
REQUIRE(gltf.getExtension<ExtensionCesiumRTC>() != nullptr);
Expand All @@ -38,6 +41,9 @@ TEST_CASE("B3dmToGltfConverter") {

GltfConverterResult result = ConvertTileToGltf::fromB3dm(testFilePath);
REQUIRE(result.model);
if (!result.model) {
return;
}

Model& gltf = *result.model;
CHECK(!gltf.meshes.empty());
Expand Down
6 changes: 6 additions & 0 deletions Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ TEST_CASE("I3dmToGltfConverter") {
GltfConverterResult result = ConvertTileToGltf::fromI3dm(testFilePath);

REQUIRE(result.model);
if (!result.model) {
return;
}
CHECK(result.model->isExtensionUsed(
ExtensionExtMeshGpuInstancing::ExtensionName));
CHECK(result.model->isExtensionRequired(
Expand All @@ -48,6 +51,9 @@ TEST_CASE("I3dmToGltfConverter") {
GltfConverterResult result = ConvertTileToGltf::fromI3dm(testFilePath);

REQUIRE(result.model);
if (!result.model) {
return;
}
CHECK(result.model->isExtensionUsed(
ExtensionExtMeshGpuInstancing::ExtensionName));
CHECK(result.model->isExtensionRequired(
Expand Down
30 changes: 30 additions & 0 deletions Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
std::optional<OrientedBoundingBox> maybeBox =
TileBoundingVolumes::getOrientedBoundingBox(l1x0y0);
REQUIRE(maybeBox);

if (!maybeBox) {
return;
}

CHECK(maybeBox->getCenter() == glm::dvec3(-4.0, -3.0, 3.0));
CHECK(maybeBox->getLengths() == glm::dvec3(10.0, 10.0, 20.0));

Expand All @@ -502,6 +507,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
std::optional<BoundingRegion> maybeRegion =
TileBoundingVolumes::getBoundingRegion(l1x1y0, Ellipsoid::WGS84);
REQUIRE(maybeRegion);

if (!maybeRegion) {
return;
}

CHECK(maybeRegion->getRectangle().getWest() == 2.0);
CHECK(maybeRegion->getRectangle().getSouth() == 2.0);
CHECK(maybeRegion->getRectangle().getEast() == 3.0);
Expand All @@ -518,6 +528,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
l1x0y1,
Ellipsoid::WGS84);
REQUIRE(maybeS2);

if (!maybeS2) {
return;
}

CHECK(maybeS2->getCellID().getFace() == 1);
CHECK(
maybeS2->getCellID().getID() ==
Expand Down Expand Up @@ -554,6 +569,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
std::optional<OrientedBoundingBox> maybeBox =
TileBoundingVolumes::getOrientedBoundingBox(l1x0y0);
REQUIRE(maybeBox);

if (!maybeBox) {
return;
}

CHECK(maybeBox->getCenter() == glm::dvec3(-4.0, -3.0, -2.0));
CHECK(maybeBox->getLengths() == glm::dvec3(10.0, 10.0, 10.0));

Expand All @@ -564,6 +584,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
std::optional<BoundingRegion> maybeRegion =
TileBoundingVolumes::getBoundingRegion(l1x1y0, Ellipsoid::WGS84);
REQUIRE(maybeRegion);

if (!maybeRegion) {
return;
}

CHECK(maybeRegion->getRectangle().getWest() == 2.0);
CHECK(maybeRegion->getRectangle().getSouth() == 2.0);
CHECK(maybeRegion->getRectangle().getEast() == 3.0);
Expand All @@ -580,6 +605,11 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
l1x0y1,
Ellipsoid::WGS84);
REQUIRE(maybeS2);

if (!maybeS2) {
return;
}

CHECK(maybeS2->getCellID().getFace() == 1);
CHECK(
maybeS2->getCellID().getID() ==
Expand Down
Loading

0 comments on commit 48097eb

Please sign in to comment.