Skip to content

Commit

Permalink
tests are satisfied
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemann16 committed Feb 1, 2021
1 parent 15946ed commit f6f01af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
22 changes: 5 additions & 17 deletions plugins/draco/io/DracoWriter.cpp
Expand Up @@ -160,7 +160,7 @@ DracoWriter::DimensionInfo *DracoWriter::findDimInfo(Dimension::Id pt) {
void DracoWriter::parseDimensions()
{
if(!m_userDimJson.is_object()) {
if (std::string(m_userQuant.type_name()) == "null") return;
if (std::string(m_userDimJson.type_name()) == "null") return;
throw pdal_error("Option 'dimensions' must be a JSON object, not a " +
std::string(m_userDimJson.type_name()));
}
Expand Down Expand Up @@ -282,16 +282,8 @@ void DracoWriter::addGeneric(Dimension::Id pt)
m_pc->AddAttributeMetadata(attId, std::move(metaPtr));

//update attribute id
for (auto &dimInfo: m_dims) {
if (dimInfo.dracoAtt == draco::GeometryAttribute::GENERIC) {
for (auto &dimType: dimInfo.pdalDims) {
if (dimType.m_id == pt) {
dimInfo.attId = attId;
return;
}
}
}
}
DimensionInfo *dimInfo = findDimInfo(pt);
dimInfo->attId = attId;
}

void DracoWriter::addAttribute(draco::GeometryAttribute::Type t, int n)
Expand Down Expand Up @@ -319,12 +311,8 @@ void DracoWriter::addAttribute(draco::GeometryAttribute::Type t, int n)
int attId = m_pc->AddAttribute(ga, true, m_pc->num_points());

//update attribute id
for (auto &dimInfo: m_dims) {
if (dimInfo.dracoAtt == t) {
dimInfo.attId = attId;
return;
}
}
DimensionInfo *dimInfo = findDimInfo(t);
dimInfo->attId = attId;
}

void DracoWriter::initPointCloud(point_count_t size)
Expand Down
27 changes: 14 additions & 13 deletions plugins/draco/test/DracoWriterTest.cpp
Expand Up @@ -198,7 +198,7 @@ namespace pdal
Options readerOptions;
readerOptions.add("filename", inFile);
readerOptions.add("count", 1065);
FauxReader reader;
LasReader reader;
reader.setOptions(readerOptions);

Options options;
Expand All @@ -220,29 +220,22 @@ namespace pdal
{
NL::json dims;
//test position
dims = { {"X", "uint16"}, {"Y", "uint16"}, {"Z", "float"} };
dims = { {"X", "float"}, {"Y", "float"}, {"Z", "double"} };
testDimensions(dims, false);
dims = { {"X", "uint16"} };
dims = { {"X", "float"} };
testDimensions(dims, false);
dims = { {"X", "uint16"}, {"Y", "uint16"}, {"Z", "uint16"} };
dims = { {"X", "float"}, {"Y", "float"}, {"Z", "float"} };
testDimensions(dims, true);


//test RGB
dims = { {"Red", "double"}, {"Green", "double"}, {"Blue", "double"} };
testDimensions(dims, true);
dims = { {"Red", "double"}, {"Green", "double"}, {"Blue", "uint16"} };
testDimensions(dims, false);
dims = { {"Red", "double"} };
testDimensions(dims, false);
dims = { {"Red", "double"}, {"Green", "double"}, {"Blue", "double"} };
testDimensions(dims, true);

// test textures
dims = { {"TextureU", "double"}, {"TextureV", "double"}, {"TextureW", "float"} };
testDimensions(dims, false);
dims = { {"TextureU", "double"} };
testDimensions(dims, false);
dims = { {"TextureU", "double"}, {"TextureV", "double"}, {"TextureW", "double"} };
testDimensions(dims, true);

//test file doesn't currently use these types
//test normals
Expand All @@ -253,6 +246,14 @@ namespace pdal
// dims = { {"NormalX", "double"}, {"NormalY", "double"}, {"NormalZ", "double"} };
// testDimensions(dims, true);

// // test textures
// dims = { {"TextureU", "double"}, {"TextureV", "double"}, {"TextureW", "float"} };
// testDimensions(dims, false);
// dims = { {"TextureU", "double"} };
// testDimensions(dims, false);
// dims = { {"TextureU", "double"}, {"TextureV", "double"}, {"TextureW", "double"} };
// testDimensions(dims, true);


}

Expand Down

0 comments on commit f6f01af

Please sign in to comment.