Compare commits

..

2 Commits

Author SHA1 Message Date
Ralph Wessel 0420001239 Updated Primitive3D and associated classes 2024-10-31 09:47:40 +00:00
David Kekesi 519869e705 WIP, does not build - added Primitive3D, Primitive3DMover Polyline 2024-10-30 18:37:58 +01:00
22 changed files with 369 additions and 260 deletions
-2
View File
@@ -105,7 +105,6 @@
<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\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\UpdateModel.cpp" />
<ClCompile Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.cpp" />
@@ -162,7 +161,6 @@
<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\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\UpdateModel.h" />
<ClInclude Include="Connector\Interface\Browser\Bridge\Config\Arg\ConnectorConfig.h" />
@@ -246,9 +246,6 @@
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.cpp">
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
</ClCompile>
<ClCompile Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.cpp">
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Connector\ConnectorResource.h">
@@ -420,8 +417,5 @@
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\HighlightModel.h">
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
</ClInclude>
<ClInclude Include="Connector\Interface\Browser\Bridge\Base\OpenUrl.h">
<Filter>Connector\Interface\Browser\Bridge\Base</Filter>
</ClInclude>
</ItemGroup>
</Project>
@@ -23,7 +23,6 @@
/* Begin PBXBuildFile section */
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 */; };
214B7A372C764BCD00D586C1 /* UpdateConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21F69FBD2C7630B3008B6A06 /* UpdateConfig.cpp */; };
215F082A2C947F4400CD343B /* CardMover.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08262C947F4400CD343B /* CardMover.cpp */; };
@@ -297,8 +296,6 @@
/* Begin PBXFileReference section */
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>"; };
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; };
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>"; };
@@ -1034,8 +1031,6 @@
21B67CAA2C77329800FD64FC /* GetSourceApplicationVersion.h */,
21A79EC52CCDA45C001754E4 /* HighlightModel.cpp */,
21A79EC82CCDA45C001754E4 /* HighlightModel.h */,
21384BC92CD2EE7400D4602B /* OpenUrl.cpp */,
21384BCC2CD2EE7400D4602B /* OpenUrl.h */,
21D0BDD52C935DAE0077E104 /* RemoveModel.cpp */,
21D0BDD62C935DAE0077E104 /* RemoveModel.h */,
21D0BDD22C935D1A0077E104 /* UpdateModel.cpp */,
@@ -1531,7 +1526,6 @@
21D0BDD72C935DAE0077E104 /* RemoveModel.cpp in Sources */,
21A890BC2CC15C540087E732 /* SelectionInfo.cpp in Sources */,
21AEF9EF2CAB5720000B8681 /* SendObject.cpp in Sources */,
21384BCD2CD2EE7400D4602B /* OpenUrl.cpp in Sources */,
21B67CDC2C78C88000FD64FC /* SayHi.cpp in Sources */,
215F082E2C94C5C000CD343B /* FilterMover.cpp in Sources */,
21F69F122C677BC0008B6A06 /* ConnectorMenu.cpp in Sources */,
@@ -8,7 +8,6 @@
#include "Connector/Interface/Browser/Bridge/Base/RemoveModel.h"
#include "Connector/Interface/Browser/Bridge/Base/UpdateModel.h"
#include "Connector/Interface/Browser/Bridge/Base/HighlightModel.h"
#include "Connector/Interface/Browser/Bridge/Base/OpenUrl.h"
#include "Speckle/Event/Type/ProjectEvent.h"
using namespace connector::interfac::browser::bridge;
@@ -27,7 +26,6 @@ BaseBridge::BaseBridge() : BrowserBridge{"baseBinding"} {
addMethod<RemoveModel>();
addMethod<UpdateModel>();
addMethod<HighlightModel>();
addMethod<OpenUrl>();
} //BaseBridge::BaseBridge
/*--------------------------------------------------------------------
@@ -1,24 +0,0 @@
#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
@@ -1,41 +0,0 @@
#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
@@ -100,7 +100,7 @@ namespace connector::record {
///Finish proxies accumulated from meshes generated from the collection elements
FinishProxies m_finishProxies;
class FinishCache;
///Finishes cache
///Finishes cached from ModelerAPI materials
std::unique_ptr<FinishCache> m_finishes;
};
@@ -27,22 +27,6 @@ void Platform::writeToConsole(const active::utility::String& message) {
} //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
@@ -18,11 +18,6 @@ namespace speckle::environment {
@param message The message to write
*/
void writeToConsole(const active::utility::String& message);
/*!
Open a URL
@param URL The URL to open
*/
void openURL(const active::utility::String& URL);
};
+10 -64
View File
@@ -19,10 +19,6 @@ namespace {
vertexID,
faceID,
colorID,
pointID,
closedID,
lengthID,
areaID,
};
///Serialisation field IDs
@@ -30,10 +26,6 @@ namespace {
Identity{"vertices"},
Identity{"faces"},
Identity{"colors"},
Identity{"value"},
Identity{"closed"},
Identity{"length"},
Identity{"area"},
};
}
@@ -61,13 +53,6 @@ void Mesh::appendFace(const std::vector<double>& vertices) {
return: True if the package has added items to the inventory
--------------------------------------------------------------------*/
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;
inventory.merge(Inventory{
{
@@ -75,22 +60,9 @@ bool Mesh::fillInventoryMesh(Inventory& inventory) const {
{ fieldID[faceID], faceID, element },
{ fieldID[colorID], colorID, element },
},
}.withType(&typeid(Mesh)));
}.withType(&typeid(Mesh)));
return base::fillInventory(inventory);
}
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);
}
} //Mesh::fillInventory
/*--------------------------------------------------------------------
@@ -101,46 +73,20 @@ bool Mesh::fillInventoryPolyline(Inventory& inventory) const {
return: The requested cargo (nullptr on failure)
--------------------------------------------------------------------*/
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))
return base::getCargo(item);
using namespace active::serialise;
switch (item.index) {
case vertexID:
return std::make_unique<ContainerWrap<std::vector<double>>>(m_vertices);
case faceID:
return std::make_unique<ContainerWrap<std::vector<int>>>(m_faces);
case colorID:
return std::make_unique<ContainerWrap<std::vector<int>>>(m_colors);
default:
return nullptr; //Requested an unknown index
return std::make_unique<ContainerWrap<std::vector<double>>>(m_vertices);
case faceID:
return std::make_unique<ContainerWrap<std::vector<int>>>(m_faces);
case colorID:
return std::make_unique<ContainerWrap<std::vector<int>>>(m_colors);
default:
return nullptr; //Requested an unknown index
}
}
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
}
}
} //Mesh::getCargo
/*--------------------------------------------------------------------
+12 -27
View File
@@ -1,6 +1,7 @@
#ifndef SPECKLE_PRIMITIVE_MESH
#define SPECKLE_PRIMITIVE_MESH
#include "Speckle/Primitive/Primitive3D.h"
#include "Speckle/Database/Content/BIMRecord.h"
#include "Speckle/Utility/String.h"
#include "Speckle/Record/Attribute/Finish.h"
@@ -10,12 +11,12 @@ namespace speckle::primitive {
/*!
Class for a 3D mesh
*/
class Mesh : public speckle::database::BIMRecord {
class Mesh : public Primitive3D {
public:
// MARK: - Types
using base = speckle::database::BIMRecord;
using base = Primitive3D;
// MARK: - Constructors
@@ -23,7 +24,7 @@ namespace speckle::primitive {
Default constructor
@param unit The mesh unit type
*/
Mesh(active::measure::LengthType unit = active::measure::LengthType::metre) : base{utility::Guid{true}, utility::Guid{}, unit} {}
Mesh(active::measure::LengthType unit = active::measure::LengthType::metre) : base{ utility::Guid{true}, utility::Guid{}, unit } {}
/*!
Constructor
@param unit The mesh unit type
@@ -41,12 +42,14 @@ namespace speckle::primitive {
@param unit The mesh unit type
*/
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) :
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 } {}
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 } {}
/*!
Object cloning
@return A clone of this object
*/
virtual Mesh* clonePtr() const override { return new Mesh{*this}; }
// MARK: - Functions (const)
@@ -54,13 +57,7 @@ namespace speckle::primitive {
Get the speckle type identifier
@return The speckle type (relevant objects should override as required)
*/
speckle::utility::String getSpeckleType() const override
{
if (isPolyline)
return "Objects.Geometry.Polyline";
else
return "Objects.Geometry.Mesh";
}
speckle::utility::String getSpeckleType() const override { return "Objects.Geometry.Mesh"; }
/*!
Append a single face to the Mesh given by the vertices
@@ -76,35 +73,23 @@ namespace speckle::primitive {
@return True if the package has added items to the inventory
*/
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
@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 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
@param management The management to use
*/
void useManagement(active::serialise::Management* management) const override;
void setToPolyline() { isPolyline = true; }
private:
std::vector<double> m_vertices;
std::vector<double> m_points;
std::vector<int> m_faces;
std::vector<int> m_colors;
record::attribute::Finish m_finish;
bool isPolyline = false;
bool isClosed = false;
double length = 2.0;
double area = 0.0;
};
}
@@ -0,0 +1,73 @@
#include "Speckle/Primitive/Polyline/Polyline.h"
#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
#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>
using namespace active::serialise;
using namespace speckle::primitive;
using namespace speckle::serialise;
namespace {
///Serialisation fields
enum FieldIndex {
pointsID,
};
///Serialisation field IDs
static std::array fieldID = {
Identity{"values"},
};
}
/*--------------------------------------------------------------------
Fill an inventory with the package items
inventory: The inventory to receive the package items
return: True if the package has added items to the inventory
--------------------------------------------------------------------*/
bool Polyline::fillInventory(Inventory& inventory) const {
using enum Entry::Type;
inventory.merge(Inventory{
{
{ fieldID[pointsID], pointsID, element },
},
}.withType(&typeid(Polyline)));
return base::fillInventory(inventory);
} //Polyline::fillInventory
/*--------------------------------------------------------------------
Get the specified cargo
item: The inventory item to retrieve
return: The requested cargo (nullptr on failure)
--------------------------------------------------------------------*/
Cargo::Unique Polyline::getCargo(const Inventory::Item& item) const {
if (item.ownerType != &typeid(Polyline))
return base::getCargo(item);
using namespace active::serialise;
switch (item.index) {
case pointsID:
return std::make_unique<ContainerWrap<std::vector<double>>>(m_points);
default:
return nullptr; //Requested an unknown index
}
} //Polyline::getCargo
/*--------------------------------------------------------------------
Use a manager in (de)serialisation processes
management: The management to use
--------------------------------------------------------------------*/
void Polyline::useManagement(Management* management) const {
} //Polyline::useManagement
@@ -0,0 +1,74 @@
#ifndef SPECKLE_PRIMITIVE_POLYLINE
#define SPECKLE_PRIMITIVE_POLYLINE
#include "Speckle/Primitive/Primitive3D.h"
#include "Speckle/Record/Attribute/Finish.h"
namespace speckle::primitive {
/*!
Class for a 3D polyline
*/
class Polyline : public Primitive3D {
public:
// MARK: - Types
using base = Primitive3D;
// MARK: - Constructors
/*!
Default constructor
@param unit The polyline unit type
*/
Polyline(active::measure::LengthType unit = active::measure::LengthType::metre) : base{ utility::Guid{true}, utility::Guid{}, unit } {}
/*!
Constructor
@param points The polyline vertices
@param unit The polyline unit type
*/
Polyline(std::vector<double>&& points, active::measure::LengthType unit = active::measure::LengthType::metre) :
base{ utility::Guid{true}, utility::Guid{}, unit }, m_points{ std::move(points) } {}
/*!
Object cloning
@return A clone of this object
*/
virtual Polyline* clonePtr() const override { return new Polyline{*this}; }
// MARK: - Functions (const)
/*!
Get the speckle type identifier
@return The speckle type (relevant objects should override as required)
*/
speckle::utility::String getSpeckleType() const override { return "Objects.Geometry.Polyline"; }
// MARK: - Serialisation
/*!
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 override;
/*!
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 override;
/*!
Use a manager in (de)serialisation processes
@param management The management to use
*/
void useManagement(active::serialise::Management* management) const override;
private:
std::vector<double> m_points;
};
}
#endif //SPECKLE_PRIMITIVE_POLYLINE
@@ -0,0 +1,39 @@
#ifndef SPECKLE_PRIMITIVE_3D
#define SPECKLE_PRIMITIVE_3D
#include "Speckle/Database/Content/BIMRecord.h"
namespace speckle::primitive {
/*!
Interface for all 3D primitives
*/
class Primitive3D : public speckle::database::BIMRecord {
public:
using base = speckle::database::BIMRecord;
/*!
Default constructor
@param unit The recordc unit type
*/
Primitive3D(active::measure::LengthType unit = active::measure::LengthType::metre) : base{unit} {}
/*!
Constructor
@param ID The record ID
@param tableID The parent table ID
@param unit The record unit type
*/
Primitive3D(const speckle::utility::Guid& ID, const speckle::utility::Guid& tableID,
std::optional<active::measure::LengthType> unit = active::measure::LengthType::metre) : base{ID, tableID, unit} {}
/*!
Object cloning
@return A clone of this object
*/
Primitive3D* clonePtr() const override = 0;
};
}
#endif //SPECKLE_PRIMITIVE_3D
@@ -0,0 +1,54 @@
#include "Speckle/Primitive/Primitive3DMover.h"
#include "Speckle/Primitive/Primitive3D.h"
#include "Speckle/Primitive/Mesh/Mesh.h"
#include "Speckle/Primitive/Polyline/Polyline.h"
using namespace active::serialise;
using namespace speckle::primitive;
namespace {
///The tag used to identify a Speckle type name value
const char* attributeTag = "speckle_type";
///Identity for a Mesh
const char* meshTypeName = "Objects.Geometry.Mesh";
///Identity for a Polyline
const char* polylineTypeName = "Objects.Geometry.Polyline";
/*--------------------------------------------------------------------
Ensure the handler is populated
handler: The card handler to validate
return: A reference to the handler
--------------------------------------------------------------------*/
std::shared_ptr<active::serialise::Handler>& validateHandler(std::shared_ptr<active::serialise::Handler>& handler) {
if (!handler->empty())
return handler;
handler->add<speckle::primitive::Polyline>(polylineTypeName);
handler->add<Mesh>(meshTypeName);
return handler;
}
}
///The handler for 3D primitive packages
std::shared_ptr<Handler> Primitive3DMover::m_handler = std::make_shared<Handler>(attributeTag);
/*--------------------------------------------------------------------
Constructor (for deserialisation)
handler: A package handler to reconstruct incoming packages
--------------------------------------------------------------------*/
Primitive3DMover::Primitive3DMover() : Mover{validateHandler(m_handler)} {
} //CardMover::CardMover
/*--------------------------------------------------------------------
Constructor (for serialisation)
outgoing: An outgoing package
--------------------------------------------------------------------*/
Primitive3DMover::Primitive3DMover(const active::serialise::Package& outgoing) : Mover{outgoing, validateHandler(m_handler)} {
} //CardMover::CardMover
@@ -0,0 +1,36 @@
#ifndef CONNECTOR_MODEL_PRIMITIVE3D_MOVER
#define CONNECTOR_MODEL_PRIMITIVE3D_MOVER
#include "Active/Serialise/Package/Wrapper/Mover.h"
namespace speckle::primitive {
/*!
Wrapper to box/unbox 3D primitives during (de)serialisation
Primitives are polymorphic - this class ensures the type information is included when a primitive is serialised
and the correct object type is constructed on deserialisation
*/
class Primitive3DMover : public active::serialise::Mover {
public:
// MARK: - Constructors
/*!
Default constructor
*/
Primitive3DMover();
/*!
Constructor (for serialisation)
@param outgoing An outgoing package
*/
Primitive3DMover(const active::serialise::Package& outgoing);
private:
///The handler for model card packages
static std::shared_ptr<active::serialise::Handler> m_handler;
};
}
#endif //CONNECTOR_MODEL_PRIMITIVE3D_MOVER
@@ -3,6 +3,7 @@
#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
#include "Active/Serialise/Package/Wrapper/PackageWrap.h"
#include "Active/Serialise/Package/Wrapper/ContainerWrap.h"
#include "Active/Container/HashMap.h"
#include "Speckle/Environment/Addon.h"
#include "Speckle/Primitive/Mesh/Mesh.h"
#include "Speckle/Record/Property/Wrapper/PropertiedWrapper.h"
@@ -17,7 +18,6 @@
#include <ModelElement.hpp>
#include <ModelMaterial.hpp>
#include <ModelMeshBody.hpp>
#include <ModelEdge.hpp>
#include <Sight.hpp>
#endif
@@ -33,8 +33,6 @@ using namespace speckle::utility;
#include <array>
#include <memory>
#include <stack>
namespace speckle::record::element {
class ModelElement::Data {
@@ -243,8 +241,6 @@ void ModelElement::resetCache() {
--------------------------------------------------------------------*/
ModelElement::Body* ModelElement::getBody() const {
#ifdef ARCHICAD
ModelerAPI::Material tmpmat{};
if (m_data && m_data->m_cache)
return m_data->m_cache.get();
void* dummy = nullptr;
@@ -261,7 +257,7 @@ ModelElement::Body* ModelElement::getBody() const {
}
auto elementBody = new ModelElement::Body();
// Map to collect meshes per material name
std::unordered_map<String, primitive::Mesh> materialMeshMap;
active::container::HashMap<String, primitive::Mesh> materialMeshMap;
auto subIds = collectSubIds(getHead().guid);
Int32 nElements = acModel.GetElementCount();
for (Int32 iElement = 1; iElement <= nElements; iElement++) {
@@ -276,52 +272,6 @@ ModelElement::Body* ModelElement::getBody() const {
ModelerAPI::MeshBody body{};
elem.GetTessellatedBody(bodyIndex, &body);
Int32 polyCount = body.GetPolygonCount();
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{};
body.GetPolygon(polyIndex, &polygon);
@@ -332,14 +282,12 @@ ModelElement::Body* ModelElement::getBody() const {
if (faceFinish == nullptr) {
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);
materialMeshMap[materialName] = std::make_unique<primitive::Mesh>(*faceFinish);
Int32 convexPolyCount = polygon.GetConvexPolygonCount();
for (Int32 convPolyIndex = 1; convPolyIndex <= convexPolyCount; ++convPolyIndex) {
std::vector<double> vertices;
@@ -354,20 +302,13 @@ ModelElement::Body* ModelElement::getBody() const {
vertices.push_back(vertex.y);
vertices.push_back(vertex.z);
}
materialMeshMap[materialName].appendFace(std::move(vertices));
materialMeshMap[materialName]->appendFace(std::move(vertices));
}
}
}
}
for (auto& [materialName, mesh] : materialMeshMap)
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);*/
for (auto& mesh : materialMeshMap)
elementBody->emplace_back(std::move(mesh.second));
m_data = std::make_unique<Data>();
m_data->m_cache.reset(elementBody);
return m_data->m_cache.get();
@@ -1,6 +1,7 @@
#ifndef SPECKLE_RECORD_MODEL_ELEMENT
#define SPECKLE_RECORD_MODEL_ELEMENT
#include "Speckle/Primitive/Primitive3D.h"
#include "Speckle/Record/Classification/Classified.h"
#include "Speckle/Record/Element/Element.h"
#include "Speckle/Record/Element/Element.h"
@@ -28,7 +29,7 @@ namespace speckle::record::element {
///Optional
using Option = std::optional<ModelElement>;
///A model element 3D body primitive
using Body = std::vector<primitive::Mesh>;
using Body = active::container::Vector<speckle::primitive::Primitive3D>;
// MARK: - Constructors
@@ -20,6 +20,12 @@
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 */; };
21384BDA2CD37C8C00D4602B /* Polyline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BD12CD37C8C00D4602B /* Polyline.cpp */; };
21384BDB2CD37C8C00D4602B /* Polyline.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BD22CD37C8C00D4602B /* Polyline.h */; };
21384BDC2CD37C8C00D4602B /* Primitive3DMover.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BD62CD37C8C00D4602B /* Primitive3DMover.cpp */; };
21384BDD2CD37C8C00D4602B /* Primitive3DMover.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BD72CD37C8C00D4602B /* Primitive3DMover.h */; };
21384BDE2CD37C8C00D4602B /* Primitive3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 21384BD82CD37C8C00D4602B /* Primitive3D.h */; };
21384BDF2CD37C8C00D4602B /* Primitive3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 21384BD92CD37C8C00D4602B /* Primitive3D.cpp */; };
215F08552C99DA8D00CD343B /* Project.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08512C99DA8D00CD343B /* Project.cpp */; };
215F08562C99DA8D00CD343B /* Project.h in Headers */ = {isa = PBXBuildFile; fileRef = 215F08542C99DA8D00CD343B /* Project.h */; };
215F08662C9B006800CD343B /* ProjectEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 215F08652C9B006700CD343B /* ProjectEvent.cpp */; };
@@ -206,6 +212,12 @@
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>"; };
21384BD12CD37C8C00D4602B /* Polyline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Polyline.cpp; sourceTree = "<group>"; };
21384BD22CD37C8C00D4602B /* Polyline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Polyline.h; sourceTree = "<group>"; };
21384BD62CD37C8C00D4602B /* Primitive3DMover.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Primitive3DMover.cpp; path = Speckle/Primitive/Primitive3DMover.cpp; sourceTree = SOURCE_ROOT; };
21384BD72CD37C8C00D4602B /* Primitive3DMover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Primitive3DMover.h; path = Speckle/Primitive/Primitive3DMover.h; sourceTree = SOURCE_ROOT; };
21384BD82CD37C8C00D4602B /* Primitive3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Primitive3D.h; path = Speckle/Primitive/Primitive3D.h; sourceTree = SOURCE_ROOT; };
21384BD92CD37C8C00D4602B /* Primitive3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Primitive3D.cpp; path = Speckle/Primitive/Primitive3D.cpp; sourceTree = SOURCE_ROOT; };
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; };
215F08512C99DA8D00CD343B /* Project.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Project.cpp; sourceTree = "<group>"; };
@@ -455,6 +467,16 @@
name = Products;
sourceTree = "<group>";
};
21384BD32CD37C8C00D4602B /* Polyline */ = {
isa = PBXGroup;
children = (
21384BD12CD37C8C00D4602B /* Polyline.cpp */,
21384BD22CD37C8C00D4602B /* Polyline.h */,
);
name = Polyline;
path = Speckle/Primitive/Polyline;
sourceTree = SOURCE_ROOT;
};
215F08612C9AE3D200CD343B /* RINT */ = {
isa = PBXGroup;
children = (
@@ -524,6 +546,11 @@
219246112CA34DCE00CF5703 /* Primitive */ = {
isa = PBXGroup;
children = (
21384BD32CD37C8C00D4602B /* Polyline */,
21384BD92CD37C8C00D4602B /* Primitive3D.cpp */,
21384BD82CD37C8C00D4602B /* Primitive3D.h */,
21384BD62CD37C8C00D4602B /* Primitive3DMover.cpp */,
21384BD72CD37C8C00D4602B /* Primitive3DMover.h */,
219246102CA34DCE00CF5703 /* Mesh */,
);
path = Primitive;
@@ -942,6 +969,7 @@
21A0FBB52CBA5E380023F24E /* Str256.h in Headers */,
210CC86F2C7E879700610F58 /* ArgumentBase.h in Headers */,
21AE19872CC7FF5F004DBCFC /* Group.h in Headers */,
21384BDB2CD37C8C00D4602B /* Polyline.h in Headers */,
210CC8A02C81E34400610F58 /* Platform.h in Headers */,
219246132CA34DCE00CF5703 /* Mesh.h in Headers */,
21A890CF2CC1B87C0087E732 /* GenericDrawingElement.h in Headers */,
@@ -950,6 +978,7 @@
21AE19A92CC8F1F8004DBCFC /* Beam.h in Headers */,
215F08962CA19AF800CD343B /* BIMElementDatabase.h in Headers */,
2196F2F12CB4823C00450DFC /* Attribute.h in Headers */,
21384BDD2CD37C8C00D4602B /* Primitive3DMover.h in Headers */,
21D0BD332C86FE090077E104 /* Link.h in Headers */,
21AE19612CC2D358004DBCFC /* Setting.h in Headers */,
21D0BD5A2C8910400077E104 /* UserInfo.h in Headers */,
@@ -987,6 +1016,7 @@
21AE19942CC82866004DBCFC /* BIMGroupDatabase.h in Headers */,
21AE19542CC273F1004DBCFC /* Template.h in Headers */,
21A0FBBC2CBBC04C0023F24E /* ArchicadRGB.h in Headers */,
21384BDE2CD37C8C00D4602B /* Primitive3D.h in Headers */,
21AE19842CC7D517004DBCFC /* PropertyWrapper.h in Headers */,
21A0FC052CBE59A80023F24E /* SegmentedColumn.h in Headers */,
21A0FC0F2CBE92F10023F24E /* ModelElement.h in Headers */,
@@ -1156,6 +1186,7 @@
21AE19572CC27DB3004DBCFC /* Value.cpp in Sources */,
21AE19A82CC8F1F8004DBCFC /* BeamSegment.cpp in Sources */,
21AEF9BE2CA6FDA4000B8681 /* DetachedWrap.cpp in Sources */,
21384BDF2CD37C8C00D4602B /* Primitive3D.cpp in Sources */,
21A0FC062CBE59A80023F24E /* Path.cpp in Sources */,
2196F2F52CB483D600450DFC /* Finish.cpp in Sources */,
21A0FBEA2CBD6B1A0023F24E /* ColumnSegment.cpp in Sources */,
@@ -1164,6 +1195,7 @@
219246042CA2CE2700CF5703 /* BIMLink.cpp in Sources */,
21A890CE2CC1B87C0087E732 /* GenericDrawingElement.cpp in Sources */,
215F08952CA19AF800CD343B /* BIMElementDatabase.cpp in Sources */,
21384BDC2CD37C8C00D4602B /* Primitive3DMover.cpp in Sources */,
21A0FC0E2CBE92F10023F24E /* ModelElement.cpp in Sources */,
219246122CA34DCE00CF5703 /* Mesh.cpp in Sources */,
21A0FBF02CBD6B1A0023F24E /* Column.cpp in Sources */,
@@ -1183,6 +1215,7 @@
21A890D12CC1B87C0087E732 /* GenericModelElement.cpp in Sources */,
21AEF9BC2CA6DF84000B8681 /* DetachmentManager.cpp in Sources */,
215F08552C99DA8D00CD343B /* Project.cpp in Sources */,
21384BDA2CD37C8C00D4602B /* Polyline.cpp in Sources */,
21AE19882CC7FF5F004DBCFC /* Group.cpp in Sources */,
21F69F3B2C6B880C008B6A06 /* JSBaseTransport.cpp in Sources */,
21384BC52CD24AB200D4602B /* ElementSubscriber.cpp in Sources */,
+7
View File
@@ -48,6 +48,7 @@
<ClInclude Include="Speckle\Event\Subscriber\ProjectSubscriber.h" />
<ClInclude Include="Speckle\Event\Subscriber\SelectionSubscriber.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\ProjectEvent.h" />
<ClInclude Include="Speckle\Event\Type\SelectionEvent.h" />
@@ -70,6 +71,9 @@
<ClInclude Include="Speckle\Interface\Browser\NamedFunction.h" />
<ClInclude Include="Speckle\Interface\Browser\PlatformBinding.h" />
<ClInclude Include="Speckle\Primitive\Mesh\Mesh.h" />
<ClInclude Include="Speckle\Primitive\Polyline\Polyline.h" />
<ClInclude Include="Speckle\Primitive\Primitive3D.h" />
<ClInclude Include="Speckle\Primitive\Primitive3DMover.h" />
<ClInclude Include="Speckle\Record\Attribute\Attribute.h" />
<ClInclude Include="Speckle\Record\Attribute\Finish.h" />
<ClInclude Include="Speckle\Record\Attribute\Storey.h" />
@@ -154,6 +158,9 @@
<ClCompile Include="Speckle\Interface\Browser\Bridge\Functions\GetCallResult.cpp" />
<ClCompile Include="Speckle\Interface\Browser\Bridge\Functions\RunMethod.cpp" />
<ClCompile Include="Speckle\Primitive\Mesh\Mesh.cpp" />
<ClCompile Include="Speckle\Primitive\Polyline\Polyline.cpp" />
<ClCompile Include="Speckle\Primitive\Primitive3D.cpp" />
<ClCompile Include="Speckle\Primitive\Primitive3DMover.cpp" />
<ClCompile Include="Speckle\Record\Attribute\Attribute.cpp" />
<ClCompile Include="Speckle\Record\Attribute\Finish.cpp" />
<ClCompile Include="Speckle\Record\Attribute\Storey.cpp" />
+22
View File
@@ -116,6 +116,9 @@
<Filter Include="Speckle\Database\Storage\ArchicadDBase\Property">
<UniqueIdentifier>{f9b0554b-d0a5-40c0-ac20-22032dc8f30c}</UniqueIdentifier>
</Filter>
<Filter Include="Speckle\Primitive\Polyline">
<UniqueIdentifier>{25953cb1-f6c3-4db2-80f7-ea3cbc5ad16a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Speckle\Environment\Addon.h">
@@ -421,6 +424,16 @@
<ClInclude Include="Speckle\Event\Subscriber\ElementSubscriber.h">
<Filter>Speckle\Event\Subscriber</Filter>
</ClInclude>
<ClInclude Include="Speckle\Event\Type\ElementEvent.h" />
<ClInclude Include="Speckle\Primitive\Primitive3D.h">
<Filter>Speckle\Primitive</Filter>
</ClInclude>
<ClInclude Include="Speckle\Primitive\Polyline\Polyline.h">
<Filter>Speckle\Primitive\Polyline</Filter>
</ClInclude>
<ClInclude Include="Speckle\Primitive\Primitive3DMover.h">
<Filter>Speckle\Primitive</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Speckle\Environment\Addon.cpp">
@@ -642,6 +655,15 @@
<ClCompile Include="Speckle\Event\Subscriber\ElementSubscriber.cpp">
<Filter>Speckle\Event\Subscriber</Filter>
</ClCompile>
<ClCompile Include="Speckle\Primitive\Primitive3D.cpp">
<Filter>Speckle\Primitive</Filter>
</ClCompile>
<ClCompile Include="Speckle\Primitive\Polyline\Polyline.cpp">
<Filter>Speckle\Primitive\Polyline</Filter>
</ClCompile>
<ClCompile Include="Speckle\Primitive\Primitive3DMover.cpp">
<Filter>Speckle\Primitive</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="Speckle\CMakeLists.txt">