Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9d669c4dd | |||
| e4e31314d6 | |||
| 82bd96de61 | |||
| 51ed951d7d | |||
| cc6c884f47 | |||
| 4afed92ba9 | |||
| ca2df4c020 | |||
| 764b548900 | |||
| 71dac48830 | |||
| 5684364119 |
@@ -105,6 +105,7 @@
|
|||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationName.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationName.cpp" />
|
||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationVersion.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationVersion.cpp" />
|
||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.cpp" />
|
||||||
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.cpp" />
|
||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\RemoveModel.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\RemoveModel.cpp" />
|
||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\UpdateModel.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\UpdateModel.cpp" />
|
||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.cpp" />
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.cpp" />
|
||||||
@@ -161,6 +162,7 @@
|
|||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationName.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationName.h" />
|
||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationVersion.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\GetSourceApplicationVersion.h" />
|
||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.h" />
|
||||||
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.h" />
|
||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\RemoveModel.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\RemoveModel.h" />
|
||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\UpdateModel.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\UpdateModel.h" />
|
||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.h" />
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.h" />
|
||||||
|
|||||||
@@ -246,6 +246,9 @@
|
|||||||
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.cpp">
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.cpp">
|
||||||
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.cpp">
|
||||||
|
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Connector\ConnectorResource.h">
|
<ClInclude Include="Connector\ConnectorResource.h">
|
||||||
@@ -417,5 +420,8 @@
|
|||||||
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.h">
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.h">
|
||||||
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.h">
|
||||||
|
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
210CC8832C80E6A300610F58 /* TriggerEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 210CC8812C80E6A300610F58 /* TriggerEvent.cpp */; };
|
210CC8832C80E6A300610F58 /* TriggerEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 210CC8812C80E6A300610F58 /* TriggerEvent.cpp */; };
|
||||||
|
21384BCD2CD2EE7400D4602B /* OpenUrl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BC92CD2EE7400D4602B /* OpenUrl.cpp */; };
|
||||||
213CC39C2B1101F500088049 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2151077C2AEDB9070022CD24 /* Cocoa.framework */; };
|
213CC39C2B1101F500088049 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2151077C2AEDB9070022CD24 /* Cocoa.framework */; };
|
||||||
214B7A372C764BCD00D586C1 /* UpdateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69FBD2C7630B3008B6A06 /* UpdateConfig.cpp */; };
|
214B7A372C764BCD00D586C1 /* UpdateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69FBD2C7630B3008B6A06 /* UpdateConfig.cpp */; };
|
||||||
215F082A2C947F4400CD343B /* CardMover.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08262C947F4400CD343B /* CardMover.cpp */; };
|
215F082A2C947F4400CD343B /* CardMover.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08262C947F4400CD343B /* CardMover.cpp */; };
|
||||||
@@ -296,6 +297,8 @@
|
|||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
210CC8812C80E6A300610F58 /* TriggerEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerEvent.cpp; sourceTree = "<group>"; };
|
210CC8812C80E6A300610F58 /* TriggerEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TriggerEvent.cpp; sourceTree = "<group>"; };
|
||||||
210CC8822C80E6A300610F58 /* TriggerEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerEvent.h; sourceTree = "<group>"; };
|
210CC8822C80E6A300610F58 /* TriggerEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TriggerEvent.h; sourceTree = "<group>"; };
|
||||||
|
21384BC92CD2EE7400D4602B /* OpenUrl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OpenUrl.cpp; sourceTree = "<group>"; };
|
||||||
|
21384BCC2CD2EE7400D4602B /* OpenUrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenUrl.h; sourceTree = "<group>"; };
|
||||||
213CC3A52B1101F500088049 /* Speckle Connector.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Speckle Connector.bundle"; sourceTree = BUILT_PRODUCTS_DIR; };
|
213CC3A52B1101F500088049 /* Speckle Connector.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Speckle Connector.bundle"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
2151077C2AEDB9070022CD24 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
2151077C2AEDB9070022CD24 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
|
||||||
215F08262C947F4400CD343B /* CardMover.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CardMover.cpp; sourceTree = "<group>"; };
|
215F08262C947F4400CD343B /* CardMover.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CardMover.cpp; sourceTree = "<group>"; };
|
||||||
@@ -1031,6 +1034,8 @@
|
|||||||
21B67CAA2C77329800FD64FC /* GetSourceApplicationVersion.h */,
|
21B67CAA2C77329800FD64FC /* GetSourceApplicationVersion.h */,
|
||||||
21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */,
|
21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */,
|
||||||
21A79EC82CCDA45C001754E4 /* HighlightModel.h */,
|
21A79EC82CCDA45C001754E4 /* HighlightModel.h */,
|
||||||
|
21384BC92CD2EE7400D4602B /* OpenUrl.cpp */,
|
||||||
|
21384BCC2CD2EE7400D4602B /* OpenUrl.h */,
|
||||||
21D0BDD52C935DAE0077E104 /* RemoveModel.cpp */,
|
21D0BDD52C935DAE0077E104 /* RemoveModel.cpp */,
|
||||||
21D0BDD62C935DAE0077E104 /* RemoveModel.h */,
|
21D0BDD62C935DAE0077E104 /* RemoveModel.h */,
|
||||||
21D0BDD22C935D1A0077E104 /* UpdateModel.cpp */,
|
21D0BDD22C935D1A0077E104 /* UpdateModel.cpp */,
|
||||||
@@ -1526,6 +1531,7 @@
|
|||||||
21D0BDD72C935DAE0077E104 /* RemoveModel.cpp in Sources */,
|
21D0BDD72C935DAE0077E104 /* RemoveModel.cpp in Sources */,
|
||||||
21A890BC2CC15C540087E732 /* SelectionInfo.cpp in Sources */,
|
21A890BC2CC15C540087E732 /* SelectionInfo.cpp in Sources */,
|
||||||
21AEF9EF2CAB5720000B8681 /* SendObject.cpp in Sources */,
|
21AEF9EF2CAB5720000B8681 /* SendObject.cpp in Sources */,
|
||||||
|
21384BCD2CD2EE7400D4602B /* OpenUrl.cpp in Sources */,
|
||||||
21B67CDC2C78C88000FD64FC /* SayHi.cpp in Sources */,
|
21B67CDC2C78C88000FD64FC /* SayHi.cpp in Sources */,
|
||||||
215F082E2C94C5C000CD343B /* FilterMover.cpp in Sources */,
|
215F082E2C94C5C000CD343B /* FilterMover.cpp in Sources */,
|
||||||
21F69F122C677BC0008B6A06 /* ConnectorMenu.cpp in Sources */,
|
21F69F122C677BC0008B6A06 /* ConnectorMenu.cpp in Sources */,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Connector/Interface/Browser/Bridge/Base/RemoveModel.h"
|
#include "Connector/Interface/Browser/Bridge/Base/RemoveModel.h"
|
||||||
#include "Connector/Interface/Browser/Bridge/Base/UpdateModel.h"
|
#include "Connector/Interface/Browser/Bridge/Base/UpdateModel.h"
|
||||||
#include "Connector/Interface/Browser/Bridge/Base/HighlightModel.h"
|
#include "Connector/Interface/Browser/Bridge/Base/HighlightModel.h"
|
||||||
|
#include "Connector/Interface/Browser/Bridge/Base/OpenUrl.h"
|
||||||
#include "Speckle/Event/Type/ProjectEvent.h"
|
#include "Speckle/Event/Type/ProjectEvent.h"
|
||||||
|
|
||||||
using namespace connector::interfac::browser::bridge;
|
using namespace connector::interfac::browser::bridge;
|
||||||
@@ -26,6 +27,7 @@ BaseBridge::BaseBridge() : BrowserBridge{"baseBinding"} {
|
|||||||
addMethod<RemoveModel>();
|
addMethod<RemoveModel>();
|
||||||
addMethod<UpdateModel>();
|
addMethod<UpdateModel>();
|
||||||
addMethod<HighlightModel>();
|
addMethod<HighlightModel>();
|
||||||
|
addMethod<OpenUrl>();
|
||||||
} //BaseBridge::BaseBridge
|
} //BaseBridge::BaseBridge
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "Connector/Interface/Browser/Bridge/Base/OpenUrl.h"
|
||||||
|
|
||||||
|
#include "Speckle/Environment/Platform.h"
|
||||||
|
|
||||||
|
using namespace connector::interfac::browser::bridge;
|
||||||
|
using namespace speckle::environment;
|
||||||
|
using namespace speckle::utility;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Default constructor
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
OpenUrl::OpenUrl() : BridgeMethod{"OpenUrl", [&](const SendArgs& args) {
|
||||||
|
run(args);
|
||||||
|
}} {}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Opens an url
|
||||||
|
|
||||||
|
url: The URL to open
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
void OpenUrl::run(const String& url) const {
|
||||||
|
platform()->openURL(url);
|
||||||
|
} //OpenUrl::run
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef CONNECTOR_INTERFACE_BRIDGE_OPEN_URL
|
||||||
|
#define CONNECTOR_INTERFACE_BRIDGE_OPEN_URL
|
||||||
|
|
||||||
|
#include "Active/Serialise/CargoHold.h"
|
||||||
|
#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
|
||||||
|
#include "Speckle/Interface/Browser/Bridge/BridgeMethod.h"
|
||||||
|
|
||||||
|
namespace connector::interfac::browser::bridge {
|
||||||
|
|
||||||
|
class ConnectorConfig;
|
||||||
|
|
||||||
|
///Argument parameter for a string
|
||||||
|
using StringHold = active::serialise::CargoHold<active::serialise::ValueWrap<speckle::utility::String>, speckle::utility::String>;
|
||||||
|
///Argument type for this method
|
||||||
|
using SendArgs = speckle::interfac::browser::bridge::JSArgType<StringHold>;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
JS Function class to highlight elements from the selected model card in the open document
|
||||||
|
*/
|
||||||
|
class OpenUrl : public speckle::interfac::browser::bridge::BridgeMethod<SendArgs, void> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
// MARK: - Constructors
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
OpenUrl();
|
||||||
|
|
||||||
|
// MARK: - Functions (const)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Opens an url
|
||||||
|
@param url The URL to open
|
||||||
|
*/
|
||||||
|
void run(const speckle::utility::String& url) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //CONNECTOR_INTERFACE_BRIDGE_OPEN_URL
|
||||||
@@ -48,6 +48,7 @@ SendBridge::SendBridge() : BrowserBridge{"sendBinding"} {
|
|||||||
#endif
|
#endif
|
||||||
} //SendBridge::SendBridge
|
} //SendBridge::SendBridge
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
Handle an element change
|
Handle an element change
|
||||||
|
|
||||||
@@ -56,23 +57,20 @@ SendBridge::SendBridge() : BrowserBridge{"sendBinding"} {
|
|||||||
return: True if the event should be closed
|
return: True if the event should be closed
|
||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
bool SendBridge::handle(const ElementEvent& event) {
|
bool SendBridge::handle(const ElementEvent& event) {
|
||||||
|
using enum ElementEvent::Type;
|
||||||
auto eventType = event.getEventType();
|
auto eventType = event.getEventType();
|
||||||
switch (eventType)
|
switch (eventType) {
|
||||||
{
|
case begin:
|
||||||
case ElementEvent::EventType::Begin: {
|
|
||||||
m_changedElements.clear();
|
m_changedElements.clear();
|
||||||
} break;
|
break;
|
||||||
case ElementEvent::EventType::End: {
|
case end: {
|
||||||
auto modelCardDatabase = connector()->getModelCardDatabase();
|
auto modelCardDatabase = connector()->getModelCardDatabase();
|
||||||
auto modelCards = modelCardDatabase->getCards();
|
auto modelCards = modelCardDatabase->getCards();
|
||||||
|
|
||||||
// POC: this is probably not efficient, should test, review and refactor it
|
// POC: this is probably not efficient, should test, review and refactor it
|
||||||
RecordIDList expiredModelCardIds;
|
RecordIDList expiredModelCardIds;
|
||||||
for (const auto& modelCard : modelCards) {
|
for (const auto& modelCard : modelCards) {
|
||||||
if (auto senderCard = dynamic_cast<SenderModelCard*>(modelCard.get())) {
|
if (auto senderCard = dynamic_cast<SenderModelCard*>(modelCard.get())) {
|
||||||
auto modelCardSelection = senderCard->getFilter().getElementIDs();
|
auto modelCardSelection = senderCard->getFilter().getElementIDs();
|
||||||
|
|
||||||
for (const auto& elemId : modelCardSelection) {
|
for (const auto& elemId : modelCardSelection) {
|
||||||
if (std::find(m_changedElements.begin(), m_changedElements.end(), elemId) != m_changedElements.end()) {
|
if (std::find(m_changedElements.begin(), m_changedElements.end(), elemId) != m_changedElements.end()) {
|
||||||
expiredModelCardIds.push_back(modelCard->getID());
|
expiredModelCardIds.push_back(modelCard->getID());
|
||||||
@@ -81,18 +79,17 @@ bool SendBridge::handle(const ElementEvent& event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expiredModelCardIds.empty()) {
|
if (!expiredModelCardIds.empty()) {
|
||||||
auto wrapped = std::make_unique<CargoHold<ContainerWrap<RecordIDList>, RecordIDList>>(std::move(expiredModelCardIds));
|
auto wrapped = std::make_unique<CargoHold<ContainerWrap<RecordIDList>, RecordIDList>>(std::move(expiredModelCardIds));
|
||||||
sendEvent("setModelsExpired", std::move(wrapped));
|
sendEvent("setModelsExpired", std::move(wrapped));
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
case ElementEvent::EventType::Change:
|
}
|
||||||
case ElementEvent::EventType::Edit:
|
case changeElem: case editElem: case deleteElem: {
|
||||||
case ElementEvent::EventType::Delete: {
|
if (event.getElmentID())
|
||||||
auto changedElement = event.getChangedElement();
|
m_changedElements.push_back(*event.getElmentID());
|
||||||
m_changedElements.push_back(changedElement);
|
break;
|
||||||
} break;
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Connector/Record/Collection/FinishProxy.h"
|
#include "Connector/Record/Collection/FinishProxy.h"
|
||||||
#include "Speckle/Database/BIMAttributeDatabase.h"
|
#include "Speckle/Database/BIMAttributeDatabase.h"
|
||||||
#include "Speckle/Database/BIMElementDatabase.h"
|
#include "Speckle/Database/BIMElementDatabase.h"
|
||||||
|
#include "Speckle/Record/Attribute/Finish.h"
|
||||||
#include "Speckle/Record/Element/Element.h"
|
#include "Speckle/Record/Element/Element.h"
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
@@ -24,7 +25,7 @@ using namespace speckle::utility;
|
|||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
namespace connector::record {
|
namespace connector::record {
|
||||||
class ProjectCollection::FinishCache : public std::unordered_map<active::utility::Guid, Finish::Unique> {};
|
class ProjectCollection::FinishCache : public std::unordered_map<active::utility::Guid, Finish> {};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -131,14 +132,11 @@ bool ProjectCollection::addMaterialProxy(const speckle::database::BIMIndex& mate
|
|||||||
|
|
||||||
return: True if the material proxy was added (false typically means the record already exists)
|
return: True if the material proxy was added (false typically means the record already exists)
|
||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
bool ProjectCollection::addMaterialProxy(const ModelerAPI::Material& material, const speckle::database::BIMRecordID& objectID) {
|
bool ProjectCollection::addMaterialProxy(const Finish& finish, const speckle::database::BIMRecordID& objectID) {
|
||||||
auto finishID = Guid::fromInt(material.GenerateHashValue());
|
auto iter = m_finishes->find(finish.getBIMID());
|
||||||
auto iter = m_finishes->find(finishID);
|
if (iter == m_finishes->end())
|
||||||
if (iter == m_finishes->end()) {
|
iter = m_finishes->insert({finish.getBIMID(), finish}).first;
|
||||||
auto finish = std::make_unique<Finish>(material);
|
return addMaterialProxy(speckle::database::BIMIndex{finish.getBIMID()}, objectID);
|
||||||
iter = m_finishes->insert({ finishID, std::move(finish) }).first;
|
|
||||||
}
|
|
||||||
return addMaterialProxy(finishID, objectID);
|
|
||||||
} //ProjectCollection::addMaterialProxy
|
} //ProjectCollection::addMaterialProxy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -181,7 +179,7 @@ Cargo::Unique ProjectCollection::getCargo(const Inventory::Item& item) const {
|
|||||||
std::advance(iter, item.available);
|
std::advance(iter, item.available);
|
||||||
const Finish* finish = nullptr;
|
const Finish* finish = nullptr;
|
||||||
if (auto fin = m_finishes->find(iter->first); fin != m_finishes->end())
|
if (auto fin = m_finishes->find(iter->first); fin != m_finishes->end())
|
||||||
finish = fin->second.get();
|
finish = &fin->second;
|
||||||
else if (auto attribute = m_project->getAttributeDatabase()->getAttribute(iter->first, iter->first.tableID); attribute)
|
else if (auto attribute = m_project->getAttributeDatabase()->getAttribute(iter->first, iter->first.tableID); attribute)
|
||||||
finish = dynamic_cast<const Finish*>(attribute.get());
|
finish = dynamic_cast<const Finish*>(attribute.get());
|
||||||
if (finish != nullptr) {
|
if (finish != nullptr) {
|
||||||
|
|||||||
@@ -70,15 +70,13 @@ namespace connector::record {
|
|||||||
@return True if the material proxy was added (false typically means the record already exists)
|
@return True if the material proxy was added (false typically means the record already exists)
|
||||||
*/
|
*/
|
||||||
bool addMaterialProxy(const speckle::database::BIMIndex& materialIndex, const speckle::database::BIMRecordID& objectID) override;
|
bool addMaterialProxy(const speckle::database::BIMIndex& materialIndex, const speckle::database::BIMRecordID& objectID) override;
|
||||||
#ifdef ARCHICAD
|
|
||||||
/*!
|
/*!
|
||||||
Add a ModelerAPI material to the collection (NB: These are not persistent so need to be captured by this method)
|
Add a ModelerAPI material to the collection (NB: These are not persistent so need to be captured by this method)
|
||||||
@param material A material
|
@param finish A finish
|
||||||
@param objectID The object the material is applied to
|
@param objectID The object the material is applied to
|
||||||
@return True if the material proxy was added (false typically means the record already exists)
|
@return True if the material proxy was added (false typically means the record already exists)
|
||||||
*/
|
*/
|
||||||
bool addMaterialProxy(const ModelerAPI::Material& material, const speckle::database::BIMRecordID& objectID) override;
|
bool addMaterialProxy(const speckle::record::attribute::Finish& finish, const speckle::database::BIMRecordID& objectID) override;
|
||||||
#endif
|
|
||||||
|
|
||||||
// MARK: - Serialisation
|
// MARK: - Serialisation
|
||||||
|
|
||||||
@@ -101,11 +99,9 @@ namespace connector::record {
|
|||||||
std::unique_ptr<active::serialise::Management> m_management;
|
std::unique_ptr<active::serialise::Management> m_management;
|
||||||
///Finish proxies accumulated from meshes generated from the collection elements
|
///Finish proxies accumulated from meshes generated from the collection elements
|
||||||
FinishProxies m_finishProxies;
|
FinishProxies m_finishProxies;
|
||||||
#ifdef ARCHICAD
|
|
||||||
class FinishCache;
|
class FinishCache;
|
||||||
///Finishes cached from ModelerAPI materials
|
///Finishes cache
|
||||||
std::unique_ptr<FinishCache> m_finishes;
|
std::unique_ptr<FinishCache> m_finishes;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ BIMLinkList ArchicadElementDBaseEngine::getSelection() const {
|
|||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
void ArchicadElementDBaseEngine::setSelection(const BIMLinkList& elementIDs) const {
|
void ArchicadElementDBaseEngine::setSelection(const BIMLinkList& elementIDs) const {
|
||||||
GS::Array<API_Neig> selNeigs;
|
GS::Array<API_Neig> selNeigs;
|
||||||
for (const auto elemID : elementIDs) {
|
for (const auto& elemID : elementIDs) {
|
||||||
API_Neig neig(elemID);
|
API_Neig neig(elemID);
|
||||||
selNeigs.Push(neig);
|
selNeigs.Push(neig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ std::weak_ptr<Project> Addon::getActiveProject() const {
|
|||||||
void Addon::publishExternal(const active::event::Event& event) {
|
void Addon::publishExternal(const active::event::Event& event) {
|
||||||
if (!logCallback())
|
if (!logCallback())
|
||||||
return;
|
return;
|
||||||
|
++m_sessionCount;
|
||||||
try {
|
try {
|
||||||
preprocessEvent(event);
|
preprocessEvent(event);
|
||||||
publish(event);
|
publish(event);
|
||||||
@@ -165,7 +166,7 @@ bool Addon::logCallback(bool initialise) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} //Addon::publishExternalEvent
|
} //Addon::logCallback
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ namespace speckle::environment {
|
|||||||
@return The active project (nullptr = no open project)
|
@return The active project (nullptr = no open project)
|
||||||
*/
|
*/
|
||||||
std::weak_ptr<Project> getActiveProject() const;
|
std::weak_ptr<Project> getActiveProject() const;
|
||||||
|
/*!
|
||||||
|
Get the session index
|
||||||
|
@return The session index (non-recursive entries into the add-on)
|
||||||
|
*/
|
||||||
|
uint32_t getSession() const { return m_sessionCount; }
|
||||||
|
|
||||||
// MARK: - Functions (mutating)
|
// MARK: - Functions (mutating)
|
||||||
|
|
||||||
@@ -103,6 +108,8 @@ namespace speckle::environment {
|
|||||||
std::shared_ptr<Project> m_activeProject;
|
std::shared_ptr<Project> m_activeProject;
|
||||||
///The depth of nested callbacks - the root call starts at depth 0 (important for some entry-point initialisation)
|
///The depth of nested callbacks - the root call starts at depth 0 (important for some entry-point initialisation)
|
||||||
uint32_t m_callDepth = 0;
|
uint32_t m_callDepth = 0;
|
||||||
|
///The index of the active session (non-recursive entries into the add-on)
|
||||||
|
uint32_t m_sessionCount = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,22 @@ void Platform::writeToConsole(const active::utility::String& message) {
|
|||||||
} //Platform::writeToConsole
|
} //Platform::writeToConsole
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Open a URL
|
||||||
|
|
||||||
|
URL: The URL to open
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
void Platform::openURL(const active::utility::String& URL) {
|
||||||
|
#if WINDOWS
|
||||||
|
std::system((String{"start "} + URL).data());
|
||||||
|
#elif __APPLE__
|
||||||
|
std::system((String{"open "} + URL).data());
|
||||||
|
#elif __linux__
|
||||||
|
std::system((String{"xdg-open"} + url).data());
|
||||||
|
#endif
|
||||||
|
} //Platform::openURL
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
Get an object representing the parent process/application
|
Get an object representing the parent process/application
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ namespace speckle::environment {
|
|||||||
@param message The message to write
|
@param message The message to write
|
||||||
*/
|
*/
|
||||||
void writeToConsole(const active::utility::String& message);
|
void writeToConsole(const active::utility::String& message);
|
||||||
|
/*!
|
||||||
|
Open a URL
|
||||||
|
@param URL The URL to open
|
||||||
|
*/
|
||||||
|
void openURL(const active::utility::String& URL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ using namespace speckle::event;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using enum ElementEvent::Type;
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
/*!
|
/*!
|
||||||
Callback for an Archicad element change
|
Callback for an Archicad element change
|
||||||
@@ -30,22 +32,22 @@ namespace {
|
|||||||
{
|
{
|
||||||
case APINotifyElement_New: {
|
case APINotifyElement_New: {
|
||||||
ACAPI_Element_AttachObserver(elemType->elemHead.guid);
|
ACAPI_Element_AttachObserver(elemType->elemHead.guid);
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{ elemType->elemHead.guid }, ElementEvent::EventType::New });
|
addon()->publishExternal(ElementEvent{newElem, ElementID{elemType->elemHead.guid}});
|
||||||
} break;
|
} break;
|
||||||
case APINotifyElement_Change: {
|
case APINotifyElement_Change: {
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{ elemType->elemHead.guid }, ElementEvent::EventType::Change });
|
addon()->publishExternal(ElementEvent{changeElem, ElementID{elemType->elemHead.guid}});
|
||||||
} break;
|
} break;
|
||||||
case APINotifyElement_Edit: {
|
case APINotifyElement_Edit: {
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{ elemType->elemHead.guid }, ElementEvent::EventType::Edit });
|
addon()->publishExternal(ElementEvent{editElem, ElementID{elemType->elemHead.guid}});
|
||||||
} break;
|
} break;
|
||||||
case APINotifyElement_Delete: {
|
case APINotifyElement_Delete: {
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{ elemType->elemHead.guid }, ElementEvent::EventType::Delete });
|
addon()->publishExternal(ElementEvent{deleteElem, ElementID{ elemType->elemHead.guid}});
|
||||||
} break;
|
} break;
|
||||||
case APINotifyElement_BeginEvents:
|
case APINotifyElement_BeginEvents:
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{}, ElementEvent::EventType::Begin });
|
addon()->publishExternal(ElementEvent{begin});
|
||||||
break;
|
break;
|
||||||
case APINotifyElement_EndEvents: {
|
case APINotifyElement_EndEvents: {
|
||||||
addon()->publishExternal(ElementEvent{ ElementID{}, ElementEvent::EventType::End });
|
addon()->publishExternal(ElementEvent{end});
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -9,23 +9,31 @@
|
|||||||
namespace speckle::event {
|
namespace speckle::event {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Class representing a selection change event
|
Class representing an event signaling a database transaction operating on a BIM element, e.g. adding, editing, deleting etc
|
||||||
*/
|
*/
|
||||||
class ElementEvent : public active::event::Event {
|
class ElementEvent : public active::event::Event {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum EventType { New, Begin, End, Change, Edit, Delete };
|
enum Type {
|
||||||
|
newElem, ///<A new element has been created
|
||||||
|
begin, ///<An element database transaction has started - subsequent events will detail specific actions
|
||||||
|
end, ///<The current element database transaction has ended - any handling based on the transaction events should be fone now
|
||||||
|
changeElem, ///<An element has been changed
|
||||||
|
editElem, ///<An element has been edited
|
||||||
|
deleteElem ///<An element has been deleted
|
||||||
|
};
|
||||||
|
|
||||||
static const inline active::utility::NameID ID{active::utility::String{"element change"},
|
static const inline active::utility::NameID ID{active::utility::String{"element transaction"},
|
||||||
active::utility::Guid{active::utility::String{"ac9366d5-90fd-497e-b7f7-a7b4c8d97c91"}}};
|
active::utility::Guid{active::utility::String{"ac9366d5-90fd-497e-b7f7-a7b4c8d97c91"}}};
|
||||||
|
|
||||||
// MARK: - Constructors
|
// MARK: - Constructors
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructor
|
Constructor
|
||||||
@param selected A link to a selected element (nullopt if the selection is empty)
|
@param eventType An event type identifier
|
||||||
|
@param targetID The ID of the element targeted by the database transaction (nullopt = undefined, e.g. for a begin/end event)
|
||||||
*/
|
*/
|
||||||
ElementEvent(speckle::database::ElementID changed, EventType eventType) : Event{ ID }, m_changedElement{ changed }, m_eventType{ eventType } {}
|
ElementEvent(Type eventType, database::ElementID::Option targetID = std::nullopt) : Event{ID}, m_elementID{targetID}, m_eventType{eventType} {}
|
||||||
/*!
|
/*!
|
||||||
Copy constructor
|
Copy constructor
|
||||||
@param source The object to copy
|
@param source The object to copy
|
||||||
@@ -39,20 +47,17 @@ namespace speckle::event {
|
|||||||
// MARK: - Functions (const)
|
// MARK: - Functions (const)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Determine if the event selection is empty
|
Get the ID of the database transaction target element
|
||||||
@return True if the event selection is empty
|
@return The target element ID (nullopt = no target, e.g. a begin/end event)
|
||||||
*/
|
*/
|
||||||
bool empty() const { return m_changedElement.empty(); }
|
database::ElementID::Option getElmentID() const { return m_elementID; }
|
||||||
/*!
|
Type getEventType() const { return m_eventType; }
|
||||||
Get a link to the last selected element
|
|
||||||
@return A link to the last selected element (nullopt if the event selection is empty)
|
|
||||||
*/
|
|
||||||
speckle::database::ElementID getChangedElement() const { return m_changedElement; }
|
|
||||||
EventType getEventType() const { return m_eventType; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
speckle::database::ElementID m_changedElement;
|
///The ID of the target element (nullopt = undefined)
|
||||||
EventType m_eventType;
|
database::ElementID::Option m_elementID;
|
||||||
|
///The specific database operation performed
|
||||||
|
Type m_eventType;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Active/Serialise/JSON/JSONTransport.h"
|
#include "Active/Serialise/JSON/JSONTransport.h"
|
||||||
#include "Active/Utility/BufferOut.h"
|
#include "Active/Utility/BufferOut.h"
|
||||||
#include "Speckle/Interface/Browser/Bridge/BrowserBridge.h"
|
#include "Speckle/Interface/Browser/Bridge/BrowserBridge.h"
|
||||||
|
#include "Speckle/Record/Element/ModelElement.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -45,5 +46,6 @@ std::unique_ptr<WrappedResultArg> GetCallResult::getResult(const WrappedResultAr
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
String jsonOutput;
|
String jsonOutput;
|
||||||
JSONTransport().send(std::forward<Cargo&&>(*item), Identity{}, jsonOutput);
|
JSONTransport().send(std::forward<Cargo&&>(*item), Identity{}, jsonOutput);
|
||||||
|
record::element::ModelElement::resetCache();
|
||||||
return std::make_unique<WrappedResultArg>(jsonOutput);
|
return std::make_unique<WrappedResultArg>(jsonOutput);
|
||||||
} //GetCallResult::getResult
|
} //GetCallResult::getResult
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ namespace {
|
|||||||
vertexID,
|
vertexID,
|
||||||
faceID,
|
faceID,
|
||||||
colorID,
|
colorID,
|
||||||
|
pointID,
|
||||||
|
closedID,
|
||||||
|
lengthID,
|
||||||
|
areaID,
|
||||||
};
|
};
|
||||||
|
|
||||||
///Serialisation field IDs
|
///Serialisation field IDs
|
||||||
@@ -26,6 +30,10 @@ namespace {
|
|||||||
Identity{"vertices"},
|
Identity{"vertices"},
|
||||||
Identity{"faces"},
|
Identity{"faces"},
|
||||||
Identity{"colors"},
|
Identity{"colors"},
|
||||||
|
Identity{"value"},
|
||||||
|
Identity{"closed"},
|
||||||
|
Identity{"length"},
|
||||||
|
Identity{"area"},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -53,6 +61,13 @@ void Mesh::appendFace(const std::vector<double>& vertices) {
|
|||||||
return: True if the package has added items to the inventory
|
return: True if the package has added items to the inventory
|
||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
bool Mesh::fillInventory(Inventory& inventory) const {
|
bool Mesh::fillInventory(Inventory& inventory) const {
|
||||||
|
if (isPolyline)
|
||||||
|
return fillInventoryPolyline(inventory);
|
||||||
|
else
|
||||||
|
return fillInventoryMesh(inventory);
|
||||||
|
} //Mesh::fillInventory
|
||||||
|
|
||||||
|
bool Mesh::fillInventoryMesh(Inventory& inventory) const {
|
||||||
using enum Entry::Type;
|
using enum Entry::Type;
|
||||||
inventory.merge(Inventory{
|
inventory.merge(Inventory{
|
||||||
{
|
{
|
||||||
@@ -60,9 +75,22 @@ bool Mesh::fillInventory(Inventory& inventory) const {
|
|||||||
{ fieldID[faceID], faceID, element },
|
{ fieldID[faceID], faceID, element },
|
||||||
{ fieldID[colorID], colorID, element },
|
{ fieldID[colorID], colorID, element },
|
||||||
},
|
},
|
||||||
}.withType(&typeid(Mesh)));
|
}.withType(&typeid(Mesh)));
|
||||||
return base::fillInventory(inventory);
|
return base::fillInventory(inventory);
|
||||||
} //Mesh::fillInventory
|
}
|
||||||
|
|
||||||
|
bool Mesh::fillInventoryPolyline(Inventory& inventory) const {
|
||||||
|
using enum Entry::Type;
|
||||||
|
inventory.merge(Inventory{
|
||||||
|
{
|
||||||
|
{ fieldID[pointID], pointID, element },
|
||||||
|
{ fieldID[closedID], closedID, element },
|
||||||
|
{ fieldID[lengthID], lengthID, element },
|
||||||
|
{ fieldID[areaID], areaID, element },
|
||||||
|
},
|
||||||
|
}.withType(&typeid(Mesh)));
|
||||||
|
return base::fillInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
@@ -73,20 +101,46 @@ bool Mesh::fillInventory(Inventory& inventory) const {
|
|||||||
return: The requested cargo (nullptr on failure)
|
return: The requested cargo (nullptr on failure)
|
||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
Cargo::Unique Mesh::getCargo(const Inventory::Item& item) const {
|
Cargo::Unique Mesh::getCargo(const Inventory::Item& item) const {
|
||||||
|
if (isPolyline)
|
||||||
|
return getCargoPolyline(item);
|
||||||
|
else
|
||||||
|
return getCargoMesh(item);
|
||||||
|
|
||||||
|
} //Mesh::getCargo
|
||||||
|
|
||||||
|
Cargo::Unique Mesh::getCargoMesh(const Inventory::Item& item) const {
|
||||||
if (item.ownerType != &typeid(Mesh))
|
if (item.ownerType != &typeid(Mesh))
|
||||||
return base::getCargo(item);
|
return base::getCargo(item);
|
||||||
using namespace active::serialise;
|
using namespace active::serialise;
|
||||||
switch (item.index) {
|
switch (item.index) {
|
||||||
case vertexID:
|
case vertexID:
|
||||||
return std::make_unique<ContainerWrap<std::vector<double>>>(m_vertices);
|
return std::make_unique<ContainerWrap<std::vector<double>>>(m_vertices);
|
||||||
case faceID:
|
case faceID:
|
||||||
return std::make_unique<ContainerWrap<std::vector<int>>>(m_faces);
|
return std::make_unique<ContainerWrap<std::vector<int>>>(m_faces);
|
||||||
case colorID:
|
case colorID:
|
||||||
return std::make_unique<ContainerWrap<std::vector<int>>>(m_colors);
|
return std::make_unique<ContainerWrap<std::vector<int>>>(m_colors);
|
||||||
default:
|
default:
|
||||||
return nullptr; //Requested an unknown index
|
return nullptr; //Requested an unknown index
|
||||||
}
|
}
|
||||||
} //Mesh::getCargo
|
}
|
||||||
|
|
||||||
|
Cargo::Unique Mesh::getCargoPolyline(const Inventory::Item& item) const {
|
||||||
|
if (item.ownerType != &typeid(Mesh))
|
||||||
|
return base::getCargo(item);
|
||||||
|
using namespace active::serialise;
|
||||||
|
switch (item.index) {
|
||||||
|
case pointID:
|
||||||
|
return std::make_unique<ContainerWrap<std::vector<double>>>(m_points);
|
||||||
|
case closedID:
|
||||||
|
return std::make_unique<ValueWrap<bool>>(isClosed);
|
||||||
|
case lengthID:
|
||||||
|
return std::make_unique<ValueWrap<double>>(length);
|
||||||
|
case areaID:
|
||||||
|
return std::make_unique<ValueWrap<double>>(area);
|
||||||
|
default:
|
||||||
|
return nullptr; //Requested an unknown index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
@@ -98,6 +152,6 @@ void Mesh::useManagement(Management* management) const {
|
|||||||
//NB: This object only exists to populate the finish collection - it doesn't carry any serialisable content
|
//NB: This object only exists to populate the finish collection - it doesn't carry any serialisable content
|
||||||
if (management != nullptr) {
|
if (management != nullptr) {
|
||||||
if (auto collector = management->get<FinishCollector>(); collector != nullptr)
|
if (auto collector = management->get<FinishCollector>(); collector != nullptr)
|
||||||
collector->addMaterialProxy(m_material, getBIMID());
|
collector->addMaterialProxy(m_finish, getBIMID());
|
||||||
}
|
}
|
||||||
} //Mesh::useManagement
|
} //Mesh::useManagement
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
#include "Speckle/Database/Content/BIMRecord.h"
|
#include "Speckle/Database/Content/BIMRecord.h"
|
||||||
#include "Speckle/Utility/String.h"
|
#include "Speckle/Utility/String.h"
|
||||||
|
#include "Speckle/Record/Attribute/Finish.h"
|
||||||
#ifdef ARCHICAD
|
|
||||||
#include "ModelMaterial.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace speckle::primitive {
|
namespace speckle::primitive {
|
||||||
|
|
||||||
@@ -30,30 +27,40 @@ namespace speckle::primitive {
|
|||||||
/*!
|
/*!
|
||||||
Constructor
|
Constructor
|
||||||
@param unit The mesh unit type
|
@param unit The mesh unit type
|
||||||
@param material The mesh material
|
@param finish The mesh finish
|
||||||
*/
|
*/
|
||||||
Mesh(const ModelerAPI::Material& material,
|
Mesh(const record::attribute::Finish& finish,
|
||||||
active::measure::LengthType unit = active::measure::LengthType::metre) :
|
active::measure::LengthType unit = active::measure::LengthType::metre) :
|
||||||
base{ utility::Guid{true}, utility::Guid{}, unit }, m_material{ material } {}
|
base{ utility::Guid{true}, utility::Guid{}, unit }, m_finish{ finish } {}
|
||||||
/*!
|
/*!
|
||||||
Constructor
|
Constructor
|
||||||
@param unit The mesh unit type
|
|
||||||
@param vertices The mesh vertices
|
@param vertices The mesh vertices
|
||||||
@param faces The mesh faces (the number of indices in the face followed by the vertex indices)
|
@param faces The mesh faces (the number of indices in the face followed by the vertex indices)
|
||||||
@param colors The mesh face colours
|
@param colors The mesh face colours
|
||||||
@param material The mesh material
|
@param finish The mesh material
|
||||||
|
@param unit The mesh unit type
|
||||||
*/
|
*/
|
||||||
Mesh(std::vector<double>&& vertices, std::vector<int>&& faces, std::vector<int>&& colors, const ModelerAPI::Material& material,
|
Mesh(std::vector<double>&& vertices, std::vector<int>&& faces, std::vector<int>&& colors, const record::attribute::Finish& finish,
|
||||||
active::measure::LengthType unit = active::measure::LengthType::metre) :
|
active::measure::LengthType unit = active::measure::LengthType::metre) :
|
||||||
base{utility::Guid{true}, utility::Guid{}, unit}, m_vertices{std::move(vertices)}, m_faces{std::move(faces)}, m_colors{std::move(colors)}, m_material{material} {}
|
base{utility::Guid{true}, utility::Guid{}, unit}, m_vertices{std::move(vertices)}, m_faces{std::move(faces)}, m_colors{std::move(colors)}, m_finish{finish} {}
|
||||||
|
|
||||||
|
Mesh(std::vector<double>&& points, const record::attribute::Finish& finish,
|
||||||
|
active::measure::LengthType unit = active::measure::LengthType::metre) :
|
||||||
|
base{ utility::Guid{true}, utility::Guid{}, unit }, m_points{ std::move(points) }, m_finish{ finish } {}
|
||||||
|
|
||||||
// MARK: - Functions (const)
|
// MARK: - Functions (const)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Get the speckle type identifier
|
Get the speckle type identifier
|
||||||
@return The speckle type (relevant objects should override as required)
|
@return The speckle type (relevant objects should override as required)
|
||||||
*/
|
*/
|
||||||
speckle::utility::String getSpeckleType() const override { return "Objects.Geometry.Mesh"; }
|
speckle::utility::String getSpeckleType() const override
|
||||||
|
{
|
||||||
|
if (isPolyline)
|
||||||
|
return "Objects.Geometry.Polyline";
|
||||||
|
else
|
||||||
|
return "Objects.Geometry.Mesh";
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Append a single face to the Mesh given by the vertices
|
Append a single face to the Mesh given by the vertices
|
||||||
@@ -69,25 +76,35 @@ namespace speckle::primitive {
|
|||||||
@return True if the package has added items to the inventory
|
@return True if the package has added items to the inventory
|
||||||
*/
|
*/
|
||||||
bool fillInventory(active::serialise::Inventory& inventory) const override;
|
bool fillInventory(active::serialise::Inventory& inventory) const override;
|
||||||
|
bool fillInventoryMesh(active::serialise::Inventory& inventory) const;
|
||||||
|
bool fillInventoryPolyline(active::serialise::Inventory& inventory) const;
|
||||||
/*!
|
/*!
|
||||||
Get the specified cargo
|
Get the specified cargo
|
||||||
@param item The inventory item to retrieve
|
@param item The inventory item to retrieve
|
||||||
@return The requested cargo (nullptr on failure)
|
@return The requested cargo (nullptr on failure)
|
||||||
*/
|
*/
|
||||||
active::serialise::Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override;
|
active::serialise::Cargo::Unique getCargo(const active::serialise::Inventory::Item& item) const override;
|
||||||
|
active::serialise::Cargo::Unique getCargoMesh(const active::serialise::Inventory::Item& item) const;
|
||||||
|
active::serialise::Cargo::Unique getCargoPolyline(const active::serialise::Inventory::Item& item) const;
|
||||||
/*!
|
/*!
|
||||||
Use a manager in (de)serialisation processes
|
Use a manager in (de)serialisation processes
|
||||||
@param management The management to use
|
@param management The management to use
|
||||||
*/
|
*/
|
||||||
void useManagement(active::serialise::Management* management) const override;
|
void useManagement(active::serialise::Management* management) const override;
|
||||||
|
|
||||||
|
void setToPolyline() { isPolyline = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<double> m_vertices;
|
std::vector<double> m_vertices;
|
||||||
|
std::vector<double> m_points;
|
||||||
std::vector<int> m_faces;
|
std::vector<int> m_faces;
|
||||||
std::vector<int> m_colors;
|
std::vector<int> m_colors;
|
||||||
#ifdef ARCHICAD
|
record::attribute::Finish m_finish;
|
||||||
ModelerAPI::Material m_material;
|
|
||||||
#endif
|
bool isPolyline = false;
|
||||||
|
bool isClosed = false;
|
||||||
|
double length = 2.0;
|
||||||
|
double area = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,22 @@ Finish::Finish(const Finish& source) : base{source} {
|
|||||||
Finish::~Finish() {}
|
Finish::~Finish() {}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Assignment operator
|
||||||
|
|
||||||
|
source: The object to assign
|
||||||
|
|
||||||
|
return: A reference to this
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
Finish& Finish::operator=(const Finish& source) {
|
||||||
|
if (this != &source) {
|
||||||
|
base::operator=(source);
|
||||||
|
m_data = source.m_data ? std::make_unique<Data>(*source.m_data) : nullptr;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
} //Finish::operator=
|
||||||
|
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
Get the (immutable) API attribute header data
|
Get the (immutable) API attribute header data
|
||||||
|
|||||||
@@ -77,7 +77,15 @@ namespace speckle::record::attribute {
|
|||||||
@return A clone of this object
|
@return A clone of this object
|
||||||
*/
|
*/
|
||||||
Finish* clonePtr() const override { return new Finish{*this}; }
|
Finish* clonePtr() const override { return new Finish{*this}; }
|
||||||
|
|
||||||
|
// MARK: - Operators
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Assignment operator
|
||||||
|
@param source The object to assign
|
||||||
|
@return A reference to this
|
||||||
|
*/
|
||||||
|
Finish& operator=(const Finish& source);
|
||||||
|
|
||||||
// MARK: - Functions (const)
|
// MARK: - Functions (const)
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,20 @@
|
|||||||
#include "Speckle/Utility/Guid.h"
|
#include "Speckle/Utility/Guid.h"
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
#include <Sight.hpp>
|
|
||||||
#include <Model.hpp>
|
|
||||||
#include <ModelMaterial.hpp>
|
|
||||||
#include <ModelElement.hpp>
|
|
||||||
#include <exp.h>
|
#include <exp.h>
|
||||||
#include <ModelMeshBody.hpp>
|
#include <AttributeIndex.hpp>
|
||||||
#include <ConvexPolygon.hpp>
|
#include <ConvexPolygon.hpp>
|
||||||
|
#include <Model.hpp>
|
||||||
|
#include <ModelElement.hpp>
|
||||||
|
#include <ModelMaterial.hpp>
|
||||||
|
#include <ModelMeshBody.hpp>
|
||||||
|
#include <ModelEdge.hpp>
|
||||||
|
#include <Sight.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace active::measure;
|
using namespace active::measure;
|
||||||
using namespace active::serialise;
|
using namespace active::serialise;
|
||||||
|
using namespace speckle::database;
|
||||||
using namespace speckle::environment;
|
using namespace speckle::environment;
|
||||||
using namespace speckle::record::attribute;
|
using namespace speckle::record::attribute;
|
||||||
using namespace speckle::record::element;
|
using namespace speckle::record::element;
|
||||||
@@ -30,6 +33,8 @@ using namespace speckle::utility;
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
namespace speckle::record::element {
|
namespace speckle::record::element {
|
||||||
|
|
||||||
class ModelElement::Data {
|
class ModelElement::Data {
|
||||||
@@ -45,6 +50,39 @@ namespace speckle::record::element {
|
|||||||
std::unique_ptr<ModelElement::Body> m_cache;
|
std::unique_ptr<ModelElement::Body> m_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Cache for materials in Archicad
|
||||||
|
|
||||||
|
NB: This has been implemented because looking up materials through the API is very slow (can easily triple processing time)
|
||||||
|
This can be eliminated in future if this problem is remedied
|
||||||
|
*/
|
||||||
|
class ModelElement::FinishCache : public std::unordered_map<Guid, Finish> {
|
||||||
|
public:
|
||||||
|
using base = std::unordered_map<Guid, Finish>;
|
||||||
|
using base::base;
|
||||||
|
|
||||||
|
FinishCache() : base{} { activeSession = addon()->getSession(); }
|
||||||
|
|
||||||
|
///The active session value when the cache was created - enables the content to be reset between sessions
|
||||||
|
uint32_t activeSession = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Validate the cache (ensure matches the active session)
|
||||||
|
@return True if the content is valid
|
||||||
|
*/
|
||||||
|
bool validate() {
|
||||||
|
if (activeSession != addon()->getSession()) {
|
||||||
|
m_finishCache.reset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<ModelElement::FinishCache> ModelElement::m_finishCache;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -60,7 +98,7 @@ namespace {
|
|||||||
Identity{"displayValue"},
|
Identity{"displayValue"},
|
||||||
Identity{"properties"},
|
Identity{"properties"},
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void getSubElementIds(T* ptr, std::set<API_Guid>& subIds)
|
void getSubElementIds(T* ptr, std::set<API_Guid>& subIds)
|
||||||
@@ -76,7 +114,7 @@ namespace {
|
|||||||
elem.header.guid = elemId;
|
elem.header.guid = elemId;
|
||||||
ACAPI_Element_Get(&elem);
|
ACAPI_Element_Get(&elem);
|
||||||
API_ElementMemo memo{};
|
API_ElementMemo memo{};
|
||||||
GSErrCode err = ACAPI_Element_GetMemo(elemId, &memo);
|
ACAPI_Element_GetMemo(elemId, &memo);
|
||||||
|
|
||||||
std::set<API_Guid> subIds{};
|
std::set<API_Guid> subIds{};
|
||||||
subIds.insert(elemId);
|
subIds.insert(elemId);
|
||||||
@@ -161,6 +199,43 @@ ModelElement::ModelElement(const ModelElement& source) : base{source}, Classifie
|
|||||||
ModelElement::~ModelElement() {}
|
ModelElement::~ModelElement() {}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Get mesh finish from the cache
|
||||||
|
|
||||||
|
finishID: The finish ID
|
||||||
|
|
||||||
|
return: A pointer to the requested material (nullptr on failure)
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
Finish* ModelElement::getFinish(const Guid& finishID) {
|
||||||
|
if (!m_finishCache || !m_finishCache->validate())
|
||||||
|
return nullptr;
|
||||||
|
if (auto iter = m_finishCache->find(finishID); iter != m_finishCache->end())
|
||||||
|
return &iter->second;
|
||||||
|
return nullptr;
|
||||||
|
} //ModelElement::getFinish
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Add a mesh finish to the cache
|
||||||
|
|
||||||
|
finishID: The finish ID
|
||||||
|
finish: The mesh finish
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
Finish* ModelElement::cacheFinish(const Guid& finishID, const Finish& finish) {
|
||||||
|
if (!m_finishCache || !m_finishCache->validate())
|
||||||
|
m_finishCache = std::make_unique<ModelElement::FinishCache>();
|
||||||
|
return &m_finishCache->insert({finishID, finish}).first->second;
|
||||||
|
} //ModelElement::cacheFinish
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------
|
||||||
|
Reset the Archicad material cache
|
||||||
|
--------------------------------------------------------------------*/
|
||||||
|
void ModelElement::resetCache() {
|
||||||
|
m_finishCache.reset();
|
||||||
|
} //ModelElement::resetCache
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------
|
/*--------------------------------------------------------------------
|
||||||
Get the element body as a list of faces or Meshes
|
Get the element body as a list of faces or Meshes
|
||||||
|
|
||||||
@@ -168,93 +243,131 @@ ModelElement::~ModelElement() {}
|
|||||||
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
||||||
ModelElement::Body* ModelElement::getBody() const {
|
ModelElement::Body* ModelElement::getBody() const {
|
||||||
#ifdef ARCHICAD
|
#ifdef ARCHICAD
|
||||||
if (m_data && m_data->m_cache) {
|
ModelerAPI::Material tmpmat{};
|
||||||
return m_data->m_cache.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (m_data && m_data->m_cache)
|
||||||
|
return m_data->m_cache.get();
|
||||||
void* dummy = nullptr;
|
void* dummy = nullptr;
|
||||||
GSErrCode err = ACAPI_Sight_GetCurrentWindowSight(&dummy);
|
GSErrCode err = ACAPI_Sight_GetCurrentWindowSight(&dummy);
|
||||||
if (err != NoError)
|
if (err != NoError) {
|
||||||
{
|
|
||||||
// TODO: should this throw?
|
// TODO: should this throw?
|
||||||
}
|
}
|
||||||
|
|
||||||
Modeler::SightPtr currentSightPtr((Modeler::Sight*)dummy); // init the shared ptr with the raw pointer
|
Modeler::SightPtr currentSightPtr((Modeler::Sight*)dummy); // init the shared ptr with the raw pointer
|
||||||
ModelerAPI::Model acModel;
|
ModelerAPI::Model acModel;
|
||||||
Modeler::IAttributeReader* attrReader = ACAPI_Attribute_GetCurrentAttributeSetReader();
|
Modeler::IAttributeReader* attrReader = ACAPI_Attribute_GetCurrentAttributeSetReader();
|
||||||
|
|
||||||
err = EXPGetModel(currentSightPtr, &acModel, attrReader);
|
err = EXPGetModel(currentSightPtr, &acModel, attrReader);
|
||||||
if (err != NoError)
|
if (err != NoError) {
|
||||||
{
|
|
||||||
// TODO: should this throw?
|
// TODO: should this throw?
|
||||||
}
|
}
|
||||||
|
|
||||||
auto elementBody = new ModelElement::Body();
|
auto elementBody = new ModelElement::Body();
|
||||||
|
|
||||||
// Map to collect meshes per material name
|
// Map to collect meshes per material name
|
||||||
std::map<GS::UniString, primitive::Mesh> materialMeshMap;
|
std::unordered_map<String, primitive::Mesh> materialMeshMap;
|
||||||
|
auto subIds = collectSubIds(getHead().guid);
|
||||||
auto subIds = collectSubIds(getHead().guid);
|
|
||||||
|
|
||||||
Int32 nElements = acModel.GetElementCount();
|
Int32 nElements = acModel.GetElementCount();
|
||||||
for (Int32 iElement = 1; iElement <= nElements; iElement++)
|
for (Int32 iElement = 1; iElement <= nElements; iElement++) {
|
||||||
{
|
|
||||||
ModelerAPI::Element elem{};
|
ModelerAPI::Element elem{};
|
||||||
acModel.GetElement(iElement, &elem);
|
acModel.GetElement(iElement, &elem);
|
||||||
|
API_Guid apiGuid{GSGuid2APIGuid(elem.GetElemGuid())};
|
||||||
auto apiGuid = reinterpret_cast<const API_Guid&> (elem.GetElemGuid());
|
|
||||||
if (subIds.find(apiGuid) == subIds.end())
|
if (subIds.find(apiGuid) == subIds.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Int32 nBodies = elem.GetTessellatedBodyCount();
|
Int32 nBodies = elem.GetTessellatedBodyCount();
|
||||||
for (Int32 bodyIndex = 1; bodyIndex <= nBodies; ++bodyIndex)
|
ModelerAPI::Material material{};
|
||||||
{
|
for (Int32 bodyIndex = 1; bodyIndex <= nBodies; ++bodyIndex) {
|
||||||
ModelerAPI::MeshBody body{};
|
ModelerAPI::MeshBody body{};
|
||||||
elem.GetTessellatedBody(bodyIndex, &body);
|
elem.GetTessellatedBody(bodyIndex, &body);
|
||||||
|
|
||||||
Int32 polyCount = body.GetPolygonCount();
|
Int32 polyCount = body.GetPolygonCount();
|
||||||
for (Int32 polyIndex = 1; polyIndex <= polyCount; ++polyIndex)
|
|
||||||
|
if (polyCount == 0)
|
||||||
{
|
{
|
||||||
|
std::vector<int> vertexIndices;
|
||||||
|
|
||||||
|
Int32 edgeCount = body.GetEdgeCount();
|
||||||
|
ModelerAPI::Edge edge{};
|
||||||
|
for (Int32 edgeIndex = 1; edgeIndex <= edgeCount; ++edgeIndex)
|
||||||
|
{
|
||||||
|
body.GetEdge(edgeIndex, &edge);
|
||||||
|
vertexIndices.push_back(edge.GetVertexIndex1());
|
||||||
|
vertexIndices.push_back(edge.GetVertexIndex2());
|
||||||
|
}
|
||||||
|
vertexIndices.push_back(edge.GetVertexIndex2());
|
||||||
|
vertexIndices.push_back(edge.GetVertexIndex2());
|
||||||
|
|
||||||
|
for (int i = 0; i < vertexIndices.size(); i += 2) {
|
||||||
|
ModelerAPI::Vertex v1{};
|
||||||
|
ModelerAPI::Vertex v2{};
|
||||||
|
body.GetVertex(vertexIndices[i], &v1);
|
||||||
|
body.GetVertex(vertexIndices[i + 1], &v2);
|
||||||
|
|
||||||
|
std::vector<double> points{};
|
||||||
|
|
||||||
|
points.push_back(v1.x);
|
||||||
|
points.push_back(v1.y);
|
||||||
|
points.push_back(v1.z);
|
||||||
|
|
||||||
|
points.push_back(v2.x);
|
||||||
|
points.push_back(v2.y);
|
||||||
|
points.push_back(v2.z);
|
||||||
|
|
||||||
|
points.push_back(v2.x);
|
||||||
|
points.push_back(v2.y);
|
||||||
|
points.push_back(v2.z);
|
||||||
|
|
||||||
|
record::attribute::Finish f(tmpmat);
|
||||||
|
primitive::Mesh mesh(std::move(points), f);
|
||||||
|
mesh.setToPolyline();
|
||||||
|
elementBody->push_back(mesh);
|
||||||
|
|
||||||
|
points.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (Int32 polyIndex = 1; polyIndex <= polyCount; ++polyIndex) {
|
||||||
ModelerAPI::Polygon polygon{};
|
ModelerAPI::Polygon polygon{};
|
||||||
body.GetPolygon(polyIndex, &polygon);
|
body.GetPolygon(polyIndex, &polygon);
|
||||||
|
ModelerAPI::AttributeIndex attrIndex{};
|
||||||
ModelerAPI::Material material{};
|
polygon.GetMaterialIndex(attrIndex);
|
||||||
polygon.GetMaterial(&material);
|
Guid finishID{Guid::fromInt(attrIndex.GetIndex())};
|
||||||
auto materialName = material.GetName();
|
auto faceFinish = ModelElement::getFinish(finishID);
|
||||||
if (materialMeshMap.find(materialName) == materialMeshMap.end()) {
|
if (faceFinish == nullptr) {
|
||||||
materialMeshMap[materialName] = primitive::Mesh(material);
|
ModelerAPI::Material material{};
|
||||||
|
polygon.GetMaterial(&material);
|
||||||
|
///
|
||||||
|
tmpmat = material;
|
||||||
|
Finish finish{material};
|
||||||
|
faceFinish = ModelElement::cacheFinish(finishID, finish);
|
||||||
}
|
}
|
||||||
|
auto materialName = faceFinish->getName();
|
||||||
|
if (materialMeshMap.find(materialName) == materialMeshMap.end())
|
||||||
|
materialMeshMap[materialName] = primitive::Mesh(*faceFinish);
|
||||||
Int32 convexPolyCount = polygon.GetConvexPolygonCount();
|
Int32 convexPolyCount = polygon.GetConvexPolygonCount();
|
||||||
|
for (Int32 convPolyIndex = 1; convPolyIndex <= convexPolyCount; ++convPolyIndex) {
|
||||||
for (Int32 convPolyIndex = 1; convPolyIndex <= convexPolyCount; ++convPolyIndex)
|
|
||||||
{
|
|
||||||
std::vector<double> vertices;
|
std::vector<double> vertices;
|
||||||
ModelerAPI::ConvexPolygon convexPolygon{};
|
ModelerAPI::ConvexPolygon convexPolygon{};
|
||||||
polygon.GetConvexPolygon(convPolyIndex, &convexPolygon);
|
polygon.GetConvexPolygon(convPolyIndex, &convexPolygon);
|
||||||
Int32 vertexCount = convexPolygon.GetVertexCount();
|
Int32 vertexCount = convexPolygon.GetVertexCount();
|
||||||
|
for (Int32 vertexIndex = 1; vertexIndex <= vertexCount; ++vertexIndex) {
|
||||||
for (Int32 vertexIndex = 1; vertexIndex <= vertexCount; ++vertexIndex)
|
|
||||||
{
|
|
||||||
ModelerAPI::Vertex vertex{};
|
ModelerAPI::Vertex vertex{};
|
||||||
body.GetVertex(convexPolygon.GetVertexIndex(vertexIndex), &vertex);
|
body.GetVertex(convexPolygon.GetVertexIndex(vertexIndex), &vertex);
|
||||||
|
// Collect vertices (as doubles for now, but should be changed to Vertex type)
|
||||||
// Collect vertices (as doubles for now, but should be changed to Vertex type)
|
|
||||||
vertices.push_back(vertex.x);
|
vertices.push_back(vertex.x);
|
||||||
vertices.push_back(vertex.y);
|
vertices.push_back(vertex.y);
|
||||||
vertices.push_back(vertex.z);
|
vertices.push_back(vertex.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
materialMeshMap[materialName].appendFace(std::move(vertices));
|
materialMeshMap[materialName].appendFace(std::move(vertices));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto& [materialName, mesh] : materialMeshMap)
|
||||||
for (auto& [materialName, mesh] : materialMeshMap)
|
|
||||||
{
|
|
||||||
elementBody->push_back(std::move(mesh));
|
elementBody->push_back(std::move(mesh));
|
||||||
}
|
|
||||||
|
/*std::vector<double> points = {0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0};
|
||||||
|
record::attribute::Finish f(tmpmat);
|
||||||
|
primitive::Mesh mesh(std::move(points), f);
|
||||||
|
mesh.setToPolyline();
|
||||||
|
elementBody->push_back(mesh);*/
|
||||||
|
|
||||||
m_data = std::make_unique<Data>();
|
m_data = std::make_unique<Data>();
|
||||||
m_data->m_cache.reset(elementBody);
|
m_data->m_cache.reset(elementBody);
|
||||||
return m_data->m_cache.get();
|
return m_data->m_cache.get();
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include "Speckle/Record/Element/Element.h"
|
#include "Speckle/Record/Element/Element.h"
|
||||||
#include "Speckle/Record/Property/Propertied.h"
|
#include "Speckle/Record/Property/Propertied.h"
|
||||||
|
|
||||||
|
namespace speckle::record::attribute {
|
||||||
|
class Finish;
|
||||||
|
}
|
||||||
|
|
||||||
namespace speckle::record::element {
|
namespace speckle::record::element {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -25,7 +29,27 @@ namespace speckle::record::element {
|
|||||||
using Option = std::optional<ModelElement>;
|
using Option = std::optional<ModelElement>;
|
||||||
///A model element 3D body primitive
|
///A model element 3D body primitive
|
||||||
using Body = std::vector<primitive::Mesh>;
|
using Body = std::vector<primitive::Mesh>;
|
||||||
|
|
||||||
|
// MARK: - Constructors
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Get a mesh finish from the cache
|
||||||
|
@param finishID A finish ID
|
||||||
|
@return A pointer to the requested finish (nullptr on failure)
|
||||||
|
*/
|
||||||
|
static record::attribute::Finish* getFinish(const utility::Guid& finishID);
|
||||||
|
/*!
|
||||||
|
Add a mesh finish to the cache
|
||||||
|
@param finishID A finish ID
|
||||||
|
@param finish The mesh finish
|
||||||
|
@return A pointer to the cached finish
|
||||||
|
*/
|
||||||
|
static record::attribute::Finish* cacheFinish(const utility::Guid& finishID, const record::attribute::Finish& finish);
|
||||||
|
/*!
|
||||||
|
Reset the Archicad material cache
|
||||||
|
*/
|
||||||
|
static void resetCache();
|
||||||
|
|
||||||
// MARK: - Constructors
|
// MARK: - Constructors
|
||||||
|
|
||||||
using base::base;
|
using base::base;
|
||||||
@@ -87,6 +111,9 @@ namespace speckle::record::element {
|
|||||||
class Data;
|
class Data;
|
||||||
///The element data
|
///The element data
|
||||||
mutable std::unique_ptr<Data> m_data;
|
mutable std::unique_ptr<Data> m_data;
|
||||||
|
class FinishCache;
|
||||||
|
///Cached finishes (API lookup is very slow)
|
||||||
|
static std::unique_ptr<FinishCache> m_finishCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,9 @@
|
|||||||
|
|
||||||
#include "Active/Serialise/Management/Manager.h"
|
#include "Active/Serialise/Management/Manager.h"
|
||||||
|
|
||||||
#ifdef ARCHICAD
|
namespace speckle::record::attribute {
|
||||||
namespace ModelerAPI {
|
class Finish;
|
||||||
class Material;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace speckle::serialise {
|
namespace speckle::serialise {
|
||||||
|
|
||||||
@@ -32,15 +30,13 @@ namespace speckle::serialise {
|
|||||||
@return True if the material proxy was added (false typically means the record already exists)
|
@return True if the material proxy was added (false typically means the record already exists)
|
||||||
*/
|
*/
|
||||||
virtual bool addMaterialProxy(const speckle::database::BIMIndex& materialIndex, const speckle::database::BIMRecordID& objectID) = 0;
|
virtual bool addMaterialProxy(const speckle::database::BIMIndex& materialIndex, const speckle::database::BIMRecordID& objectID) = 0;
|
||||||
#ifdef ARCHICAD
|
|
||||||
/*!
|
/*!
|
||||||
Add a ModelerAPI material to the collection (NB: These are not persistent so need to be captured by this method)
|
Add a ModelerAPI material to the collection (NB: These are not persistent so need to be captured by this method)
|
||||||
@param material A material
|
@param finish A finish
|
||||||
@param objectID The object the material is applied to
|
@param objectID The object the material is applied to
|
||||||
@return True if the material proxy was added (false typically means the record already exists)
|
@return True if the material proxy was added (false typically means the record already exists)
|
||||||
*/
|
*/
|
||||||
virtual bool addMaterialProxy(const ModelerAPI::Material& material, const speckle::database::BIMRecordID& objectID) = 0;
|
virtual bool addMaterialProxy(const record::attribute::Finish& finish, const speckle::database::BIMRecordID& objectID) = 0;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
212A88132AE48821001EAFE7 /* libArchicad27.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 21379E082AE47A6400A1584C /* libArchicad27.a */; platformFilters = (macos, ); };
|
212A88132AE48821001EAFE7 /* libArchicad27.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 21379E082AE47A6400A1584C /* libArchicad27.a */; platformFilters = (macos, ); };
|
||||||
21384BAB2CCDA9B400D4602B /* Host.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BA92CCDA9B400D4602B /* Host.h */; };
|
21384BAB2CCDA9B400D4602B /* Host.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BA92CCDA9B400D4602B /* Host.h */; };
|
||||||
21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BAA2CCDA9B400D4602B /* Host.cpp */; };
|
21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BAA2CCDA9B400D4602B /* Host.cpp */; };
|
||||||
|
21384BC52CD24AB200D4602B /* ElementSubscriber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BC12CD24AB200D4602B /* ElementSubscriber.cpp */; };
|
||||||
|
21384BC62CD24AB200D4602B /* ElementSubscriber.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BC42CD24AB200D4602B /* ElementSubscriber.h */; };
|
||||||
|
21384BC82CD24ADC00D4602B /* ElementEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BC72CD24ADC00D4602B /* ElementEvent.h */; };
|
||||||
215F08552C99DA8D00CD343B /* Project.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08512C99DA8D00CD343B /* Project.cpp */; };
|
215F08552C99DA8D00CD343B /* Project.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08512C99DA8D00CD343B /* Project.cpp */; };
|
||||||
215F08562C99DA8D00CD343B /* Project.h in Headers */ = {isa = PBXBuildFile; fileRef = 215F08542C99DA8D00CD343B /* Project.h */; };
|
215F08562C99DA8D00CD343B /* Project.h in Headers */ = {isa = PBXBuildFile; fileRef = 215F08542C99DA8D00CD343B /* Project.h */; };
|
||||||
215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08652C9B006700CD343B /* ProjectEvent.cpp */; };
|
215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08652C9B006700CD343B /* ProjectEvent.cpp */; };
|
||||||
@@ -200,6 +203,9 @@
|
|||||||
21379E082AE47A6400A1584C /* libArchicad27.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libArchicad27.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
21379E082AE47A6400A1584C /* libArchicad27.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libArchicad27.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
21384BA92CCDA9B400D4602B /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Host.h; sourceTree = "<group>"; };
|
21384BA92CCDA9B400D4602B /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Host.h; sourceTree = "<group>"; };
|
||||||
21384BAA2CCDA9B400D4602B /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; };
|
21384BAA2CCDA9B400D4602B /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = "<group>"; };
|
||||||
|
21384BC12CD24AB200D4602B /* ElementSubscriber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ElementSubscriber.cpp; sourceTree = "<group>"; };
|
||||||
|
21384BC42CD24AB200D4602B /* ElementSubscriber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementSubscriber.h; sourceTree = "<group>"; };
|
||||||
|
21384BC72CD24ADC00D4602B /* ElementEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementEvent.h; sourceTree = "<group>"; };
|
||||||
214EA4C52BA374FD008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
214EA4C52BA374FD008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
|
||||||
214EA4C62BA3762D008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = SOURCE_ROOT; };
|
214EA4C62BA3762D008E5358 /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = SOURCE_ROOT; };
|
||||||
215F08512C99DA8D00CD343B /* Project.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Project.cpp; sourceTree = "<group>"; };
|
215F08512C99DA8D00CD343B /* Project.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Project.cpp; sourceTree = "<group>"; };
|
||||||
@@ -537,6 +543,8 @@
|
|||||||
children = (
|
children = (
|
||||||
21D0BDBB2C90F2830077E104 /* DocStoreSubscriber.cpp */,
|
21D0BDBB2C90F2830077E104 /* DocStoreSubscriber.cpp */,
|
||||||
21D0BDBA2C90F2830077E104 /* DocStoreSubscriber.h */,
|
21D0BDBA2C90F2830077E104 /* DocStoreSubscriber.h */,
|
||||||
|
21384BC12CD24AB200D4602B /* ElementSubscriber.cpp */,
|
||||||
|
21384BC42CD24AB200D4602B /* ElementSubscriber.h */,
|
||||||
219351782C624FC100E5A69C /* MenuSubscriber.cpp */,
|
219351782C624FC100E5A69C /* MenuSubscriber.cpp */,
|
||||||
219351792C624FC100E5A69C /* MenuSubscriber.h */,
|
219351792C624FC100E5A69C /* MenuSubscriber.h */,
|
||||||
21D0BDC22C9241940077E104 /* ProjectSubscriber.cpp */,
|
21D0BDC22C9241940077E104 /* ProjectSubscriber.cpp */,
|
||||||
@@ -551,6 +559,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
21D0BDBE2C90F36B0077E104 /* DocStoreMergeEvent.h */,
|
21D0BDBE2C90F36B0077E104 /* DocStoreMergeEvent.h */,
|
||||||
|
21384BC72CD24ADC00D4602B /* ElementEvent.h */,
|
||||||
219351892C62655700E5A69C /* MenuEvent.h */,
|
219351892C62655700E5A69C /* MenuEvent.h */,
|
||||||
215F08652C9B006700CD343B /* ProjectEvent.cpp */,
|
215F08652C9B006700CD343B /* ProjectEvent.cpp */,
|
||||||
21D0BDC62C9245E40077E104 /* ProjectEvent.h */,
|
21D0BDC62C9245E40077E104 /* ProjectEvent.h */,
|
||||||
@@ -955,6 +964,7 @@
|
|||||||
21AE19802CC7D265004DBCFC /* PropertiedWrapper.h in Headers */,
|
21AE19802CC7D265004DBCFC /* PropertiedWrapper.h in Headers */,
|
||||||
21A0FC0B2CBE5E220023F24E /* Segment.h in Headers */,
|
21A0FC0B2CBE5E220023F24E /* Segment.h in Headers */,
|
||||||
215F088D2CA195EC00CD343B /* ArchicadElementDBaseEngine.h in Headers */,
|
215F088D2CA195EC00CD343B /* ArchicadElementDBaseEngine.h in Headers */,
|
||||||
|
21384BC82CD24ADC00D4602B /* ElementEvent.h in Headers */,
|
||||||
2196F2F42CB483D600450DFC /* Finish.h in Headers */,
|
2196F2F42CB483D600450DFC /* Finish.h in Headers */,
|
||||||
21A0FBED2CBD6B1A0023F24E /* Part.h in Headers */,
|
21A0FBED2CBD6B1A0023F24E /* Part.h in Headers */,
|
||||||
21B67D002C7CE15100FD64FC /* Exception.h in Headers */,
|
21B67D002C7CE15100FD64FC /* Exception.h in Headers */,
|
||||||
@@ -988,6 +998,7 @@
|
|||||||
21AE196A2CC57832004DBCFC /* Propertied.h in Headers */,
|
21AE196A2CC57832004DBCFC /* Propertied.h in Headers */,
|
||||||
2196F2EC2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.h in Headers */,
|
2196F2EC2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.h in Headers */,
|
||||||
21AE19582CC27DB3004DBCFC /* Value.h in Headers */,
|
21AE19582CC27DB3004DBCFC /* Value.h in Headers */,
|
||||||
|
21384BC62CD24AB200D4602B /* ElementSubscriber.h in Headers */,
|
||||||
21D0BD312C86FE090077E104 /* Index.h in Headers */,
|
21D0BD312C86FE090077E104 /* Index.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -1174,6 +1185,7 @@
|
|||||||
215F08552C99DA8D00CD343B /* Project.cpp in Sources */,
|
215F08552C99DA8D00CD343B /* Project.cpp in Sources */,
|
||||||
21AE19882CC7FF5F004DBCFC /* Group.cpp in Sources */,
|
21AE19882CC7FF5F004DBCFC /* Group.cpp in Sources */,
|
||||||
21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */,
|
21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */,
|
||||||
|
21384BC52CD24AB200D4602B /* ElementSubscriber.cpp in Sources */,
|
||||||
2196F2EB2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.cpp in Sources */,
|
2196F2EB2CB4816B00450DFC /* ArchicadAttributeDBaseEngine.cpp in Sources */,
|
||||||
21AE19532CC273F1004DBCFC /* Template.cpp in Sources */,
|
21AE19532CC273F1004DBCFC /* Template.cpp in Sources */,
|
||||||
21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */,
|
21384BAC2CCDA9B400D4602B /* Host.cpp in Sources */,
|
||||||
|
|||||||
@@ -48,7 +48,6 @@
|
|||||||
<ClInclude Include="Speckle\Event\Subscriber\ProjectSubscriber.h" />
|
<ClInclude Include="Speckle\Event\Subscriber\ProjectSubscriber.h" />
|
||||||
<ClInclude Include="Speckle\Event\Subscriber\SelectionSubscriber.h" />
|
<ClInclude Include="Speckle\Event\Subscriber\SelectionSubscriber.h" />
|
||||||
<ClInclude Include="Speckle\Event\Type\DocStoreMergeEvent.h" />
|
<ClInclude Include="Speckle\Event\Type\DocStoreMergeEvent.h" />
|
||||||
<ClInclude Include="Speckle\Event\Type\ElementEvent.h" />
|
|
||||||
<ClInclude Include="Speckle\Event\Type\MenuEvent.h" />
|
<ClInclude Include="Speckle\Event\Type\MenuEvent.h" />
|
||||||
<ClInclude Include="Speckle\Event\Type\ProjectEvent.h" />
|
<ClInclude Include="Speckle\Event\Type\ProjectEvent.h" />
|
||||||
<ClInclude Include="Speckle\Event\Type\SelectionEvent.h" />
|
<ClInclude Include="Speckle\Event\Type\SelectionEvent.h" />
|
||||||
|
|||||||
@@ -415,13 +415,12 @@
|
|||||||
<ClInclude Include="Speckle\Record\Element\BeamSegment.h">
|
<ClInclude Include="Speckle\Record\Element\BeamSegment.h">
|
||||||
<Filter>Speckle\Record\Element</Filter>
|
<Filter>Speckle\Record\Element</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Speckle\Event\Subscriber\ElementSubscriber.h">
|
|
||||||
<Filter>Speckle\Event\Subscriber</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Speckle\Event\Type\ElementEvent.h" />
|
|
||||||
<ClInclude Include="Speckle\Environment\Host.h">
|
<ClInclude Include="Speckle\Environment\Host.h">
|
||||||
<Filter>Speckle\Environment</Filter>
|
<Filter>Speckle\Environment</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Speckle\Event\Subscriber\ElementSubscriber.h">
|
||||||
|
<Filter>Speckle\Event\Subscriber</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Speckle\Environment\Addon.cpp">
|
<ClCompile Include="Speckle\Environment\Addon.cpp">
|
||||||
@@ -637,11 +636,12 @@
|
|||||||
<ClCompile Include="Speckle\Record\Element\BeamSegment.cpp">
|
<ClCompile Include="Speckle\Record\Element\BeamSegment.cpp">
|
||||||
<Filter>Speckle\Record\Element</Filter>
|
<Filter>Speckle\Record\Element</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Speckle\Event\Subscriber\ElementSubscriber.cpp">
|
|
||||||
<Filter>Speckle\Event\Subscriber</Filter>
|
|
||||||
<ClCompile Include="Speckle\Environment\Host.cpp">
|
<ClCompile Include="Speckle\Environment\Host.cpp">
|
||||||
<Filter>Speckle\Environment</Filter>
|
<Filter>Speckle\Environment</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Speckle\Event\Subscriber\ElementSubscriber.cpp">
|
||||||
|
<Filter>Speckle\Event\Subscriber</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="Speckle\CMakeLists.txt">
|
<Text Include="Speckle\CMakeLists.txt">
|
||||||
|
|||||||
Reference in New Issue
Block a user