Added FinishProxy to collect mesh finishes (to build 'material proxy collection)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Active/Serialise/Package/Wrapper/PackageWrap.h"
|
||||
#include "Active/Serialise/Package/Wrapper/ContainerWrap.h"
|
||||
#include "Active/Serialise/Inventory/Identity.h"
|
||||
#include "Speckle/Serialise/Collection/FinishProxy.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace {
|
||||
vertexID,
|
||||
faceID,
|
||||
colorID,
|
||||
proxyID,
|
||||
};
|
||||
|
||||
///Serialisation field IDs
|
||||
@@ -24,6 +26,7 @@ namespace {
|
||||
Identity{"vertices"},
|
||||
Identity{"faces"},
|
||||
Identity{"colors"},
|
||||
Identity{"proxy"},
|
||||
};
|
||||
|
||||
}
|
||||
@@ -42,6 +45,7 @@ bool Mesh::fillInventory(Inventory& inventory) const {
|
||||
{ fieldID[vertexID], vertexID, element },
|
||||
{ fieldID[faceID], faceID, element },
|
||||
{ fieldID[colorID], colorID, element },
|
||||
{ fieldID[proxyID], proxyID, element },
|
||||
},
|
||||
}.withType(&typeid(Mesh)));
|
||||
return base::fillInventory(inventory);
|
||||
@@ -66,6 +70,9 @@ Cargo::Unique Mesh::getCargo(const Inventory::Item& item) const {
|
||||
return std::make_unique<ContainerWrap<std::vector<int>>>(faces);
|
||||
case colorID:
|
||||
return std::make_unique<ContainerWrap<std::vector<int>>>(colors);
|
||||
case proxyID:
|
||||
return nullptr; //Activate the following line when the mesh material is available to add to the collector
|
||||
//return std::make_unique<FinishProxy>(getBIMID(), material);
|
||||
default:
|
||||
return nullptr; //Requested an unknown index
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "Speckle/Record/Attribute/Finish.h"
|
||||
|
||||
#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
|
||||
#include "Active/Serialise/Management/Management.h"
|
||||
#include "Active/Utility/BufferOut.h"
|
||||
#include "Speckle/Serialise/Collection/FinishCollector.h"
|
||||
#include "Speckle/Utility/Guid.h"
|
||||
|
||||
#ifdef ARCHICAD
|
||||
@@ -11,6 +13,7 @@
|
||||
using namespace active::serialise;
|
||||
using namespace speckle::database;
|
||||
using namespace speckle::record::attribute;
|
||||
using namespace speckle::serialise;
|
||||
using namespace speckle::utility;
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef SPECKLE_SERIALISE_FINISH_PROXY
|
||||
#define SPECKLE_SERIALISE_FINISH_PROXY
|
||||
|
||||
#include "Active/Serialise/Management/Management.h"
|
||||
|
||||
#include "Speckle/Serialise/Collection/FinishCollector.h"
|
||||
|
||||
#ifdef ARCHICAD
|
||||
namespace ModelerAPI {
|
||||
class Material;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace speckle::serialise {
|
||||
|
||||
/*!
|
||||
Proxy cargo for tranporting a mesh finish
|
||||
|
||||
Mesh finishes are currently not serialised with the mesh - instead, they are gathered into a 'material proxy' container that points back to
|
||||
the target meshes. This proxy allows the mesh to inform the finishes collector (acting as a serialisation manager) to link the mesh with
|
||||
its finish so the manager can build the 'material proxies' at the end of the project collection.
|
||||
*/
|
||||
class FinishProxy : public active::serialise::Package {
|
||||
public:
|
||||
FinishProxy(const database::BIMRecordID& meshID, const ModelerAPI::Material& material) : m_objectID{meshID}, m_material{material} {}
|
||||
|
||||
/*!
|
||||
Fill an inventory with the package items
|
||||
@param inventory The inventory to receive the package items
|
||||
@return: True if the package has added items to the inventory
|
||||
*/
|
||||
bool fillInventory(active::serialise::Inventory& inventory) const {
|
||||
//NB: This object only exists to populate the finish collection - it doesn't carry any serialisable content
|
||||
if (management() != nullptr) {
|
||||
if (auto collector = management()->get<FinishCollector>(); collector != nullptr)
|
||||
collector->addMaterialProxy(m_material, m_objectID);
|
||||
}
|
||||
return true;
|
||||
} //DocumentInfo::fillInventory
|
||||
/*!
|
||||
Get the specified cargo
|
||||
@param item The inventory item to retrieve
|
||||
@return The requested cargo (nullptr on failure)
|
||||
*/
|
||||
active::serialise::Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const { return nullptr; } //Empty placeholder
|
||||
|
||||
private:
|
||||
const database::BIMRecordID& m_objectID;
|
||||
const ModelerAPI::Material& m_material;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SPECKLE_SERIALISE_FINISH_PROXY
|
||||
@@ -188,6 +188,7 @@
|
||||
2196F3032CB57E7F00450DFC /* Storey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Storey.cpp; sourceTree = "<group>"; };
|
||||
219712682BE7E2D500D9EF7E /* Serialisation.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Serialisation.md; sourceTree = "<group>"; };
|
||||
21A0FB9F2CB880690023F24E /* FinishCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FinishCollector.h; sourceTree = "<group>"; };
|
||||
21A0FBA92CB9324A0023F24E /* FinishProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FinishProxy.h; sourceTree = "<group>"; };
|
||||
21AEF9B32CA5F7CF000B8681 /* DetachedWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetachedWrap.h; sourceTree = "<group>"; };
|
||||
21AEF9B52CA5FA02000B8681 /* DetachedReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetachedReference.h; sourceTree = "<group>"; };
|
||||
21AEF9B72CA5FCB6000B8681 /* DetachmentManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetachmentManager.h; sourceTree = "<group>"; };
|
||||
@@ -479,6 +480,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
21A0FB9F2CB880690023F24E /* FinishCollector.h */,
|
||||
21A0FBA92CB9324A0023F24E /* FinishProxy.h */,
|
||||
);
|
||||
path = Collection;
|
||||
sourceTree = "<group>";
|
||||
|
||||
Reference in New Issue
Block a user