コード例 #1
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;
}
コード例 #2
0
std::vector<repo_vector_t> MeshNode::getBoundingBox(RepoBSON &bbArr)
{
	std::vector<repo_vector_t> bbox;
	if (!bbArr.isEmpty() && bbArr.couldBeArray())
	{
		size_t nVec = bbArr.nFields();
		bbox.reserve(nVec);
		for (uint32_t i = 0; i < nVec; ++i)
		{
			auto bbVectorBson = bbArr.getObjectField(std::to_string(i));
			if (!bbVectorBson.isEmpty() && bbVectorBson.couldBeArray())
			{
				int32_t nFields = bbVectorBson.nFields();

				if (nFields >= 3)
				{
					repo_vector_t vector;
					vector.x = bbVectorBson.getField("0").Double();
					vector.y = bbVectorBson.getField("1").Double();
					vector.z = bbVectorBson.getField("2").Double();

					bbox.push_back(vector);
				}
				else
				{
					repoError << "Insufficient amount of elements within bounding box! #fields: " << nFields;
				}
			}
			else
			{
				repoError << "Failed to get a vector for bounding box!";
			}
		}
	}
	else
	{
		repoError << "Failed to fetch bounding box from Mesh Node!";
	}

	return bbox;
}