Skip to content

Commit

Permalink
[dataflow] remove dependency from stduuid external
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasPaulin committed Feb 27, 2023
1 parent 2ecc7b1 commit aae1e1d
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 302 deletions.
6 changes: 1 addition & 5 deletions doc/basics/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Radium relies on several external libraries to load files or to represent some d
* [Engine] glm, globjects, glbindings, tinyEXR
* [IO] Assimp
* [Gui] Qt Core, Qt Widgets and Qt OpenGL v5.5+ (5.14 at least, Qt6 support is experimental), PowerSlider
* [Dataflow] stduuid, RadiumNodeEditor
* [Dataflow] RadiumNodeEditor
* [doc] Doxygen-awesome-css
* stb_image

Expand Down Expand Up @@ -101,7 +101,6 @@ set(tinyEXR_DIR "/path/to/external/install/share/tinyEXR/cmake/" CACHE PATH "My
set(assimp_DIR "/path/to/external/install/lib/cmake/assimp-5.0/" CACHE PATH "My assimp location")
set(tinyply_DIR "/path/to/external/install/lib/cmake/tinyply/" CACHE PATH "My tinyply location")
set(PowerSlider_DIR "/path/to/external/install/lib/cmake/PowerSlider/" CACHE PATH "My PowerSlider location")
set(stduuid_DIR "/path/to/external/install/lib/cmake/stduuid/" CACHE PATH "My stduuid")
set(RadiumNodeEditor_DIR "/path/to/external/install/lib/cmake/RadiumNodeEditor/" CACHE PATH "My NodeEditor")
set(RADIUM_IO_ASSIMP ON CACHE BOOL "Radium uses assimp io")
set(RADIUM_IO_TINYPLY ON CACHE BOOL "Radium uses tinyply io")
Expand All @@ -125,7 +124,6 @@ To this end, just provide the corresponding '*_DIR' to cmake at configuration ti
Currently supported (note that these paths must refer to the installation directory of the corresponding library):
<!-- (generated running ../script/list_dep.py from Radium-Engine/external directory) -->

* `stduuid_DIR`
* `RadiumNodeEditor_DIR`
* `assimp_DIR`
* `tinyply_DIR`
Expand All @@ -142,8 +140,6 @@ Currently supported (note that these paths must refer to the installation direct

Radium is compiled and tested with specific version of dependencies, as given in the external's folder CMakeLists.txt and state here for the record

* stduuid: https://github.com/mariusbancila/stduuid, [3afe7193facd5d674de709fccc44d5055e144d7a],
* with options `-DUUID_BUILD_TESTS=OFF -DUUID_ENABLE_INSTALL=ON`
* RadiumNodeEditor: https://github.com/MathiasPaulin/RadiumQtNodeEditor.git, [main],
* with options `None`
* assimp: https://github.com/assimp/assimp.git, [tags/v5.0.1],
Expand Down
141 changes: 68 additions & 73 deletions doc/concepts/dataflow/HelloGraph.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,71 @@
{
"id": "{c1c08892-9064-4484-b1f6-1c7da3bb56f8}",
"model": {
"graph": {
"connections": [
{
"in_id": "{daa522ef-9242-436d-a57d-487bc8d850f1}",
"in_index": 0,
"out_id": "{eef7a427-c725-42d1-adb3-29d5112597d6}",
"out_index": 0
},
{
"in_id": "{daa522ef-9242-436d-a57d-487bc8d850f1}",
"in_index": 1,
"out_id": "{ef56ef16-569c-48e7-ae42-91e130088737}",
"out_index": 0
},
{
"in_id": "{41d4e5df-fbfe-482f-ab5e-10c7941ffd60}",
"in_index": 0,
"out_id": "{daa522ef-9242-436d-a57d-487bc8d850f1}",
"out_index": 0
}
],
"factories": [],
"nodes": [
{
"id": "{eef7a427-c725-42d1-adb3-29d5112597d6}",
"model": {
"instance": "Source",
"name": "Source<RaVector<float>>"
},
"position": {
"x": -23.0,
"y": 88.0
}
},
{
"id": "{ef56ef16-569c-48e7-ae42-91e130088737}",
"model": {
"instance": "Selector",
"name": "Source<function<bool (float const&)>>"
},
"position": {
"x": -112.0,
"y": 239.0
}
},
{
"id": "{daa522ef-9242-436d-a57d-487bc8d850f1}",
"model": {
"instance": "Filter",
"name": "Filter<RaVector<float>>"
},
"position": {
"x": 310.0,
"y": 158.0
}
},
{
"id": "{41d4e5df-fbfe-482f-ab5e-10c7941ffd60}",
"model": {
"instance": "Sink",
"name": "Sink<RaVector<float>>"
},
"position": {
"x": 609.0,
"y": 238.0
}
}
]
"instance": "helloGraph",
"model": {
"graph": {
"connections": [
{
"in_node": "Filter",
"in_port": "in",
"out_node": "Source",
"out_port": "to"
},
"instance": "helloGraph",
"name": "Core DataflowGraph"
}
{
"in_node": "Filter",
"in_port": "f",
"out_node": "Selector",
"out_port": "f"
},
{
"in_node": "Sink",
"in_port": "from",
"out_node": "Filter",
"out_port": "out"
}
],
"factories": [],
"nodes": [
{
"instance": "Source",
"model": {
"name": "Source<RaVector<float>>"
},
"position": {
"x": -195.0,
"y": -82.0
}
},
{
"instance": "Selector",
"model": {
"name": "Source<function<bool (float const&)>>"
},
"position": {
"x": -279.0,
"y": 35.0
}
},
{
"instance": "Filter",
"model": {
"name": "Filter<RaVector<float>>"
},
"position": {
"x": 44.0,
"y": -45.0
}
},
{
"instance": "Sink",
"model": {
"name": "Sink<RaVector<float>>"
},
"position": {
"x": 267.0,
"y": 12.0
}
}
]
},
"name": "Core DataflowGraph"
}
}
2 changes: 1 addition & 1 deletion doc/concepts/nodesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Output ports (1) are :

### 2. Compiling the graph and getting input/output accessors

In order to use the graph as a function actiing on its input, it should be first compiled by
In order to use the graph as a function acting on its input, it should be first compiled by
\snippet examples/DataflowExamples/HelloGraph/main.cpp Verifying the graph can be compiled

If the compilation success the accessors for the input data and the output result might be fetched from the graph
Expand Down
Binary file modified doc/images/HelloGraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions examples/DataflowExamples/FunctionalsGraph/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <Dataflow/Core/Nodes/Sources/FunctionSource.hpp>
#include <Dataflow/Core/Nodes/Sources/SingleDataSourceNode.hpp>

#include <random>

using namespace Ra::Dataflow::Core;

/* ----------------------------------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions examples/DataflowExamples/GraphSerialization/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <Core/Containers/VectorArray.hpp>

#include <random>

using namespace Ra::Dataflow::Core;

/* ----------------------------------------------------------------------------------- */
Expand Down
21 changes: 0 additions & 21 deletions external/Dataflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_custom_target(DataflowExternals ALL)

if(NOT DEFINED stduuid_DIR)
check_externals_prerequisite()
status_message("" "stduuid" "remote git")
ExternalProject_Add(
stduuid
GIT_TAG 3afe7193facd5d674de709fccc44d5055e144d7a
GIT_REPOSITORY https://github.com/mariusbancila/stduuid
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
PATCH_COMMAND git reset --hard && git apply -v --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/patches/stduuid.patch"
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
CMAKE_ARGS ${RADIUM_EXTERNAL_CMAKE_OPTIONS} -DUUID_BUILD_TESTS=OFF -DUUID_ENABLE_INSTALL=ON
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> "-DCMAKE_MESSAGE_INDENT=${indent_string}\;"
)
set_external_dir(stduuid "lib/cmake/stduuid/")
add_dependencies(DataflowExternals stduuid)
else()
status_message("" "stduuid" ${stduuid_DIR})
endif()

if(NOT DEFINED RadiumNodeEditor_DIR)
check_externals_prerequisite()
status_message("" "RadiumNodeEditor" "remote git")
Expand Down
24 changes: 0 additions & 24 deletions external/Dataflow/patches/stduuid.patch

This file was deleted.

4 changes: 1 addition & 3 deletions src/Dataflow/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ add_library(
${dataflow_core_private}
)

find_package(stduuid REQUIRED NO_DEFAULT_PATH)

# This one should be extracted directly from parent project properties.
target_compile_definitions(${ra_dataflowcore_target} PRIVATE RA_DATAFLOW_EXPORTS)

Expand All @@ -21,7 +19,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
endif()

add_dependencies(${ra_dataflowcore_target} Core)
target_link_libraries(${ra_dataflowcore_target} PUBLIC Core stduuid)
target_link_libraries(${ra_dataflowcore_target} PUBLIC Core)

message(STATUS "Configuring library ${ra_dataflowcore_target} with standard settings")
configure_radium_target(${ra_dataflowcore_target})
Expand Down
3 changes: 0 additions & 3 deletions src/Dataflow/Core/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ if (DataflowCore_FOUND AND NOT TARGET DataflowCore)
endif()

if(Configure_DataflowCore)
# Theses paths reflect the paths founds in RadiumEngine/external/Dataflow/package
set(stduuid_DIR "@stduuid_DIR@")
find_dependency(stduuid REQUIRED NO_DEFAULT_PATH)
include("${CMAKE_CURRENT_LIST_DIR}/../Dataflow/Core/DataflowCoreTargets.cmake")
endif()
44 changes: 9 additions & 35 deletions src/Dataflow/Core/DataflowGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,13 @@ bool DataflowGraph::loadFromJson( const std::string& jsonFilePath ) {

std::pair<Node*, std::string> getLinkInfo( const std::string& which,
const nlohmann::json& linkData,
const std::unordered_map<std::string, Node*>& nodeById,
const std::map<std::string, Node*>& nodeByName ) {
std::string field = which + "_node";
Node* node { nullptr };
if ( linkData.contains( field ) ) {
auto itNode = nodeByName.find( linkData[field] );
if ( itNode != nodeByName.end() ) { node = itNode->second; }
}

auto itNode = nodeByName.find( linkData[field] );
if ( itNode != nodeByName.end() ) { node = itNode->second; }
else {
// try to find the node by id
field = which + "_id";
if ( linkData.contains( field ) ) {
auto itNode = nodeById.find( linkData[field] );
if ( itNode != nodeById.end() ) { node = itNode->second; }
}
}
if ( node == nullptr ) {
// Error, could not find the node
std::string msg =
std::string { "Node " } + which + " not found in cache " + " : " + linkData.dump();
Expand Down Expand Up @@ -192,7 +182,6 @@ bool DataflowGraph::fromJsonInternal( const nlohmann::json& data ) {
}
}
}
std::unordered_map<std::string, Node*> nodeById;
std::map<std::string, Node*> nodeByName;
auto nodes = data["graph"]["nodes"];
for ( auto& n : nodes ) {
Expand All @@ -202,17 +191,10 @@ bool DataflowGraph::fromJsonInternal( const nlohmann::json& data ) {
return false;
}
std::string nodeTypeName = n["model"]["name"];
std::string instanceName, id;
bool nodeIsIdentified = false;
if ( n.contains( "instance" ) ) {
instanceName = n["instance"];
nodeIsIdentified = true;
}
if ( n.contains( "id" ) ) {
id = n["id"];
nodeIsIdentified = true;
}
if ( !nodeIsIdentified ) {
std::string instanceName;

if ( n.contains( "instance" ) ) { instanceName = n["instance"]; }
else {
LOG( logERROR ) << "Found a node of type " << nodeTypeName
<< " without identification ";
return false;
Expand All @@ -227,14 +209,6 @@ bool DataflowGraph::fromJsonInternal( const nlohmann::json& data ) {
return false;
}
}
if ( !id.empty() ) {
auto [it, inserted] = nodeById.insert( { id, newNode } );
if ( !inserted ) {
LOG( logERROR )
<< "DataflowGraph::loadFromJson : duplicated node uuid " << id;
return false;
}
}
}
else {
LOG( logERROR ) << "Unable to create the node " << nodeTypeName;
Expand All @@ -243,14 +217,14 @@ bool DataflowGraph::fromJsonInternal( const nlohmann::json& data ) {
}
auto links = data["graph"]["connections"];
for ( auto& l : links ) {
auto [nodeFrom, fromOutput] = getLinkInfo( "out", l, nodeById, nodeByName );
auto [nodeFrom, fromOutput] = getLinkInfo( "out", l, nodeByName );
if ( nodeFrom == nullptr ) {
LOG( logERROR ) << "DataflowGraph::loadFromJson: error when parsing JSON."
<< " Could not find the link source (" << fromOutput
<< "). Link not added.";
return false;
}
auto [nodeTo, toInput] = getLinkInfo( "in", l, nodeById, nodeByName );
auto [nodeTo, toInput] = getLinkInfo( "in", l, nodeByName );
if ( nodeTo == nullptr ) {
LOG( logERROR ) << "DataflowGraph::loadFromJson: error when parsing JSON."
<< " Could not find the link source (" << toInput
Expand Down
Loading

0 comments on commit aae1e1d

Please sign in to comment.