Skip to content

Commit

Permalink
ISSUE #391 Merge branch 'staging' into ISSUE_391
Browse files Browse the repository at this point in the history
  • Loading branch information
haroon-haider committed Nov 6, 2020
2 parents 53bd97a + 73e86a8 commit 505fa8c
Show file tree
Hide file tree
Showing 60 changed files with 2,030 additions and 3,454 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ before_install:
- ls teighaLinuxGCC5.3/Kernel/Include
- echo ============ SYNCHRO INSTALL =============
- sudo apt-get install zlib1g-dev libssl-dev libxft-dev
- tar -zxf testData/bouncer/ext_libs/xenial/thrift-0.11.0.tgz
- tar -zxf testData/bouncer/ext_libs/xenial/synchro.tgz
- tar -zxf testData/bouncer/ext_libs/xenial/3drepoSynchroReader.tgz
- tar -zxf testData/bouncer/ext_libs/xenial/synchro_6.2/thrift-0.12.0.tgz
- tar -zxf testData/bouncer/ext_libs/xenial/synchro_6.2/synchro.tgz
- tar -zxf testData/bouncer/ext_libs/xenial/synchro_6.2/3drepoSynchroReader.tgz

install:
- sudo pip install cpp-coveralls
Expand All @@ -64,7 +64,7 @@ before_script:
- export OCCT_ROOT=$PWD/../OCCT
- export IFCOPENSHELL_ROOT=$PWD/../IfcOpenShell
- export ODA_ROOT=$PWD/../teighaLinuxGCC5.3
- export THRIFT_ROOT=$PWD/../thrift-0.11.0
- export THRIFT_ROOT=$PWD/../thrift-0.12.0
- export SYNCHRO_ROOT=$PWD/../synchro
- export SYNCHRO_READER_ROOT=$PWD/../3drepoSynchroReader
- export ODA_LIB_DIR=$ODA_ROOT/lib/lnxX64_5.3dll/
Expand Down
2 changes: 1 addition & 1 deletion bouncer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
add_subdirectory(src)

set(VERSION_MAJOR 4)
set(VERSION_MINOR 10_1)
set(VERSION_MINOR 11_1)

include_directories(${Boost_INCLUDE_DIRS} ${MONGO_INCLUDE_DIR} ${ASSIMP_INCLUDE_DIR} ${OCCT_INCLUDE_DIR} ${IFCOPENSHELL_INCLUDE_DIR} ${ODA_INCLUDE_DIR} ${SYNCHRO_READER_INCLUDE_DIR} ${AWSSDK_INCLUDE_DIR} src)
add_definitions(-DREPO_API_LIBRARY)
Expand Down
66 changes: 23 additions & 43 deletions bouncer/src/repo/core/model/bson/repo_bson_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ MetadataNode RepoBSONFactory::makeMetaDataNode(
return MetadataNode(builder.obj());
}


static bool keyCheck(const char &c)
{
return c == '$' || c == '.';
Expand Down Expand Up @@ -230,15 +229,15 @@ MetadataNode RepoBSONFactory::makeMetaDataNode(
{
//Check if it is a number, if it is, store it as a number

try{
try {
long long valueInt = boost::lexical_cast<long long>(value);
metaBuilder.append(key, valueInt);
}
catch (boost::bad_lexical_cast &)
{
//not an int, try a double

try{
try {
double valueFloat = boost::lexical_cast<double>(value);
metaBuilder.append(key, valueFloat);
}
Expand Down Expand Up @@ -272,7 +271,6 @@ MetadataNode RepoBSONFactory::makeMetaDataNode(
std::string key = sanitiseKey(entry.first);
std::string value = entry.second;


if (!key.empty() && !value.empty())
{
//Check if it is a number, if it is, store it as a number
Expand Down Expand Up @@ -382,7 +380,7 @@ MeshNode RepoBSONFactory::makeMeshNode(
REPO_NODE_MESH_LABEL_VERTICES,
&vertices[0],
vertices.size() * sizeof(vertices[0])
);
);
bytesize += verticesByteCount;
}
}
Expand All @@ -396,7 +394,7 @@ MeshNode RepoBSONFactory::makeMeshNode(
std::vector<repo_face_t>::iterator faceIt;

std::vector<uint32_t> facesLevel1;
for (auto &face : faces){
for (auto &face : faces) {
auto nIndices = face.size();
if (!nIndices)
{
Expand Down Expand Up @@ -428,7 +426,7 @@ MeshNode RepoBSONFactory::makeMeshNode(
REPO_NODE_MESH_LABEL_FACES,
&facesLevel1[0],
facesLevel1.size() * sizeof(facesLevel1[0])
);
);

bytesize += facesByteCount;
}
Expand Down Expand Up @@ -609,7 +607,7 @@ RepoRole RepoBSONFactory::makeRepoRole(
const std::string &database,
const std::vector<RepoPermission> &permissions,
const RepoRole &oldRole
)
)
{
RepoRole updatedOldRole = oldRole.cloneAndUpdatePermissions(permissions);
return _makeRepoRole(roleName,
Expand All @@ -623,7 +621,7 @@ RepoRole RepoBSONFactory::_makeRepoRole(
const std::string &database,
const std::vector<RepoPrivilege> &privileges,
const std::vector<std::pair<std::string, std::string> > &inheritedRoles
)
)
{
RepoBSONBuilder builder;
builder.append(REPO_LABEL_ID, database + "." + roleName);
Expand Down Expand Up @@ -668,7 +666,7 @@ RepoRole RepoBSONFactory::_makeRepoRole(
RepoBSON parentRole = BSON(
REPO_ROLE_LABEL_ROLE << inheritedRoles[i].second
<< REPO_ROLE_LABEL_DATABASE << inheritedRoles[i].first
);
);

inheritedRolesBuilder.append(std::to_string(i), parentRole);
}
Expand All @@ -684,7 +682,6 @@ RepoRef RepoBSONFactory::makeRepoRef(
const RepoRef::RefType &type,
const std::string &link,
const uint32_t size) {

repo::core::model::RepoBSONBuilder builder;
builder.append(REPO_LABEL_ID, fileName);
builder.append(REPO_REF_LABEL_TYPE, RepoRef::convertTypeAsString(type));
Expand Down Expand Up @@ -833,7 +830,7 @@ RevisionNode RepoBSONFactory::makeRevisionNode(
const std::string &message,
const std::string &tag,
const int &apiLevel
)
)
{
RepoBSONBuilder builder;
repo::lib::RepoUUID uniqueID = repo::lib::RepoUUID::createUUID();
Expand Down Expand Up @@ -899,7 +896,9 @@ TextureNode RepoBSONFactory::makeTextureNode(
const int &apiLevel)
{
RepoBSONBuilder builder;
auto defaults = appendDefaults(REPO_NODE_TYPE_TEXTURE, apiLevel, repo::lib::RepoUUID::createUUID(), name);
repo::lib::RepoUUID uniqueID = repo::lib::RepoUUID::createUUID();
std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> binMapping;
auto defaults = appendDefaults(REPO_NODE_TYPE_TEXTURE, apiLevel, uniqueID, name);
builder.appendElements(defaults);
//
// Width
Expand All @@ -925,17 +924,20 @@ TextureNode RepoBSONFactory::makeTextureNode(
// Data
//

if (data && byteCount)
builder.appendBinary(
REPO_LABEL_DATA,
data,
byteCount);
if (data && byteCount) {
std::string bName = uniqueID.toString() + "_data";
//inclusion of this binary exceeds the maximum, store separately
binMapping[REPO_LABEL_DATA] =
std::pair<std::string, std::vector<uint8_t>>(bName, std::vector<uint8_t>());
binMapping[REPO_LABEL_DATA].second.resize(byteCount); //uint8_t will ensure it is a byte addrressing
memcpy(binMapping[REPO_LABEL_DATA].second.data(), data, byteCount);
}
else
{
repoWarning << " Creating a texture node with no texture!";
}

return TextureNode(builder.obj());
return TextureNode(builder.obj(), binMapping);
}

TransformationNode RepoBSONFactory::makeTransformationNode(
Expand Down Expand Up @@ -976,7 +978,6 @@ RepoTask RepoBSONFactory::makeTask(
std::string key = sanitiseKey(entry.first);
std::string value = entry.second;


if (!key.empty() && !value.empty())
{
//Check if it is a number, if it is, store it as a number
Expand Down Expand Up @@ -1007,42 +1008,21 @@ RepoTask RepoBSONFactory::makeTask(
return builder.obj();
}

std::vector<RepoBSON> RepoBSONFactory::buildSequenceTasksBSON(
const std::unordered_map<std::string, std::shared_ptr<repo::core::model::RepoSequence::Task>> &tasks) {

std::vector<RepoBSON> taskBsons;
for (const auto &taskEntry : tasks) {
RepoBSONBuilder taskBuilder;
taskBuilder.append(REPO_LABEL_ID, taskEntry.second->id);
taskBuilder.append(REPO_SEQUENCE_LABEL_NAME, taskEntry.second->name);
taskBuilder.append(REPO_SEQUENCE_LABEL_TASK_START, mongo::Date_t(taskEntry.second->startTime * 1000));
taskBuilder.append(REPO_SEQUENCE_LABEL_TASK_END, mongo::Date_t(taskEntry.second->endTime * 1000));
if (taskEntry.second->childTasks.size()) {
taskBuilder.appendArray(REPO_SEQUENCE_LABEL_TASKS, buildSequenceTasksBSON(taskEntry.second->childTasks));
}
taskBsons.push_back(taskBuilder.obj());
}

return taskBsons;
}

RepoSequence RepoBSONFactory::makeSequence(
const std::vector<repo::core::model::RepoSequence::FrameData> &frameData,
const std::string &name
) {
RepoBSONBuilder builder;
builder.append(REPO_LABEL_ID, repo::lib::RepoUUID::createUUID());
builder.append(REPO_SEQUENCE_LABEL_NAME, name);

std::vector<RepoBSON> frames;

for (const auto &frameEntry : frameData) {
RepoBSONBuilder bsonBuilder;
bsonBuilder.append(REPO_SEQUENCE_LABEL_DATE, mongo::Date_t(frameEntry.timestamp*1000));
bsonBuilder.append(REPO_SEQUENCE_LABEL_DATE, mongo::Date_t(frameEntry.timestamp * 1000));
bsonBuilder.append(REPO_SEQUENCE_LABEL_STATE, frameEntry.ref);

bsonBuilder.appendArray(REPO_SEQUENCE_LABEL_TASKS, frameEntry.currentTasks);

frames.push_back(bsonBuilder.obj());
}

Expand Down
13 changes: 3 additions & 10 deletions bouncer/src/repo/core/model/bson/repo_bson_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ namespace repo {
const std::vector<RepoPrivilege> &privileges,
const std::vector<std::pair<std::string, std::string>> &inheritedRoles
= std::vector<std::pair<std::string, std::string>>()
);
);

/**
* Create a user BSON
* @param userName username
Expand Down Expand Up @@ -233,7 +233,6 @@ namespace repo {
const std::vector<repo::lib::RepoUUID> &parents = std::vector<repo::lib::RepoUUID>(),
const int &apiLevel = REPO_NODE_API_LEVEL_1);


/**
* Create a Metadata Node
* @param keys labels for the fields
Expand Down Expand Up @@ -263,7 +262,6 @@ namespace repo {
const std::string &name = std::string(),
const std::vector<repo::lib::RepoUUID> &parents = std::vector<repo::lib::RepoUUID>(),
const int &apiLevel = REPO_NODE_API_LEVEL_1);


/**
* Create a Mesh Node
Expand Down Expand Up @@ -296,7 +294,6 @@ namespace repo {
const std::vector<repo::lib::RepoVector3D> &normals,
const std::vector<std::vector<float>> &boundingBox,
const std::vector<repo::lib::RepoUUID> &parents) {

return makeMeshNode(vertices, faces, normals, boundingBox,
std::vector<std::vector<repo::lib::RepoVector2D>>(),
std::vector<repo_color4d_t>(),
Expand Down Expand Up @@ -354,7 +351,7 @@ namespace repo {
const std::string &message = std::string(),
const std::string &tag = std::string(),
const int &apiLevel = REPO_NODE_API_LEVEL_1
);
);

/**
* Create a Texture Node
Expand Down Expand Up @@ -393,17 +390,13 @@ namespace repo {
const std::string &name
);

static std::vector<RepoBSON> buildSequenceTasksBSON(
const std::unordered_map<std::string, std::shared_ptr<repo::core::model::RepoSequence::Task>> &tasks);

static RepoTask makeTask(
const std::string &name,
const std::unordered_map<std::string, std::string> &data,
const std::vector<repo::lib::RepoUUID> &resources,
const std::vector<repo::lib::RepoUUID> &parents = std::vector<repo::lib::RepoUUID>(),
const repo::lib::RepoUUID &id = repo::lib::RepoUUID::createUUID()
);

};
} //namespace model
} //namespace core
Expand Down
27 changes: 8 additions & 19 deletions bouncer/src/repo/core/model/bson/repo_bson_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,28 @@ namespace repo {
// Fields specific to ref only
//
//------------------------------------------------------------------------------
#define REPO_SEQUENCE_LABEL_REV_ID "rev_id"
#define REPO_SEQUENCE_LABEL_NAME "name"
#define REPO_SEQUENCE_LABEL_FRAMES "frames"
#define REPO_SEQUENCE_LABEL_DATE "dateTime"
#define REPO_SEQUENCE_LABEL_STATE "state"
#define REPO_SEQUENCE_LABEL_TASKS "tasks"
#define REPO_SEQUENCE_LABEL_TASK_START "startDate"
#define REPO_SEQUENCE_LABEL_TASK_END "endDate"
#define REPO_SEQUENCE_LABEL_REV_ID "rev_id"
#define REPO_SEQUENCE_LABEL_NAME "name"
#define REPO_SEQUENCE_LABEL_FRAMES "frames"
#define REPO_SEQUENCE_LABEL_DATE "dateTime"
#define REPO_SEQUENCE_LABEL_STATE "state"

class REPO_API_EXPORT RepoSequence : public RepoBSON
{
public:
public:

struct Task {
std::string name;
uint64_t startTime, endTime;
repo::lib::RepoUUID id;
std::unordered_map<std::string, std::shared_ptr<Task>> childTasks;
};
struct FrameData {
uint64_t timestamp;
std::string ref;
std::vector<RepoBSON> currentTasks;
};

RepoSequence() : RepoBSON() {}

RepoSequence(RepoBSON bson) : RepoBSON(bson){}
RepoSequence(RepoBSON bson) : RepoBSON(bson) {}

RepoSequence cloneAndAddRevision(const repo::lib::RepoUUID &rid) const;

~RepoSequence() {}

~RepoSequence() {}
};
}// end namespace model
} // end namespace core
Expand Down
Loading

0 comments on commit 505fa8c

Please sign in to comment.