示例#1
0
MeshNode MeshNode::cloneAndUpdateMeshMapping(
	const std::vector<repo_mesh_mapping_t> &vec,
	const bool                             &overwrite)
{
	RepoBSONBuilder builder, mapbuilder;
	uint32_t index = 0;
	std::vector<repo_mesh_mapping_t> mappings;
	RepoBSON mapArray = getObjectField(REPO_NODE_MESH_LABEL_MERGE_MAP);
	if (!overwrite && !mapArray.isEmpty())
	{
		//if map array isn't empty, find the next index it needs to slot in
		std::set<std::string> fields;
		mapArray.getFieldNames(fields);
		index = fields.size();
	}

	for (uint32_t i = 0; i < vec.size(); ++i)
	{
		mapbuilder << std::to_string(index + i) << meshMappingAsBSON(vec[i]);
	}
	//append the rest of the array onto this new map bson
	if (!overwrite) mapbuilder.appendElementsUnique(mapArray);

	builder.appendArray(REPO_NODE_MESH_LABEL_MERGE_MAP, mapbuilder.obj());

	//append the rest of the mesh onto this new bson
	builder.appendElementsUnique(*this);

	return MeshNode(builder.obj(), bigFiles);
}
示例#2
0
std::vector<repoUUID> RepoBSON::getUUIDFieldArray(const std::string &label) const{
	std::vector<repoUUID> results;

	if (hasField(label))
	{
		RepoBSON array = getObjectField(label);

		if (!array.isEmpty())
		{
			std::set<std::string> fields;
			array.getFieldNames(fields);

			std::set<std::string>::iterator it;
			for (it = fields.begin(); it != fields.end(); ++it)
				results.push_back(array.getUUIDField(*it));
		}
		else
		{
			repoError << "getUUIDFieldArray: field " << label << " is an empty bson or wrong type!";
		}


	}
	
	return results;
}
示例#3
0
std::vector<std::pair<std::string, std::string>> RepoBSON::getFileList() const
{
	std::vector<std::pair<std::string, std::string>> fileList;
	if (hasField(REPO_LABEL_OVERSIZED_FILES))
	{
		RepoBSON extRefbson = getObjectField(REPO_LABEL_OVERSIZED_FILES);

		std::set<std::string> fieldNames;
		extRefbson.getFieldNames(fieldNames);
		for (const auto &name : fieldNames)
		{
			fileList.push_back(std::pair<std::string, std::string>(name, extRefbson.getStringField(name)));
		}
	}

	return fileList;
}
std::vector<std::string> RevisionNode::getOrgFiles() const
{
	std::vector<std::string> fileList;
	if (hasField(REPO_NODE_REVISION_LABEL_REF_FILE))
	{
		RepoBSON arraybson = getObjectField(REPO_NODE_REVISION_LABEL_REF_FILE);

		std::set<std::string> fields;
		arraybson.getFieldNames(fields);

		for (const auto &field : fields)
		{
			fileList.push_back(arraybson.getStringField(field));
		}
	}

	return fileList;
}
示例#5
0
std::vector<repo_mesh_mapping_t> MeshNode::getMeshMapping() const
{
	std::vector<repo_mesh_mapping_t> mappings;
	RepoBSON mapArray = getObjectField(REPO_NODE_MESH_LABEL_MERGE_MAP);
	if (!mapArray.isEmpty())
	{
		std::set<std::string> fields;
		mapArray.getFieldNames(fields);
		mappings.resize(fields.size());
		for (const auto &name : fields)
		{
			repo_mesh_mapping_t mapping;
			RepoBSON mappingObj = mapArray.getObjectField(name);

			mapping.mesh_id = mappingObj.getUUIDField(REPO_NODE_MESH_LABEL_MAP_ID);
			mapping.material_id = mappingObj.getUUIDField(REPO_NODE_MESH_LABEL_MATERIAL_ID);
			mapping.vertFrom = mappingObj.getField(REPO_NODE_MESH_LABEL_VERTEX_FROM).Int();
			mapping.vertTo = mappingObj.getField(REPO_NODE_MESH_LABEL_VERTEX_TO).Int();
			mapping.triFrom = mappingObj.getField(REPO_NODE_MESH_LABEL_TRIANGLE_FROM).Int();
			mapping.triTo = mappingObj.getField(REPO_NODE_MESH_LABEL_TRIANGLE_TO).Int();

			RepoBSON boundingBox = mappingObj.getObjectField(REPO_NODE_MESH_LABEL_BOUNDING_BOX);

			std::vector<repo_vector_t> bboxVec = getBoundingBox(boundingBox);
			mapping.min.x = bboxVec[0].x;
			mapping.min.y = bboxVec[0].y;
			mapping.min.z = bboxVec[0].z;

			mapping.max.x = bboxVec[1].x;
			mapping.max.y = bboxVec[1].y;
			mapping.max.z = bboxVec[1].z;

			mappings[std::stoi(name)] = mapping;
		}
	}
	return mappings;
}
示例#6
0
std::vector<float> RepoBSON::getFloatArray(const std::string &label) const
{
	std::vector<float> results;
	if (hasField(label))
	{
		RepoBSON array = getObjectField(label);
		if (!array.isEmpty())
		{
			std::set<std::string> fields;
			array.getFieldNames(fields);

            // Pre allocate memory to speed up copying
            results.reserve(fields.size());
			for (auto field : fields)
				results.push_back(array.getField(field).numberDouble());
		}
		else
		{
			repoError << "getFloatArray: field " << label << " is an empty bson or wrong type!";
		}

	}
	return results;
}