Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions rviz_mesh_tools_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ find_package(Boost REQUIRED COMPONENTS system filesystem)
find_package(HDF5 REQUIRED COMPONENTS C CXX HL)
# find_package(assimp REQUIRED)

# This needs to be optional for non CL devices
# find_package(OpenCL 2 REQUIRED)

# include_directories(${ASSIMP_INCLUDE_DIRS})

# LVR2 includes HighFive that we need here
Expand All @@ -57,7 +54,6 @@ include_directories(
${LVR2_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${OpenCL_INCLUDE_DIRS}
)

set(SOURCE_FILES
Expand All @@ -84,7 +80,6 @@ set(MOC_HEADER_FILES
include/rviz_mesh_tools_plugins/MeshDisplay.hpp
include/rviz_mesh_tools_plugins/MeshVisual.hpp
include/rviz_mesh_tools_plugins/ClusterLabelTool.hpp
include/rviz_mesh_tools_plugins/CLUtil.hpp
include/rviz_mesh_tools_plugins/RvizFileProperty.hpp
include/rviz_mesh_tools_plugins/MeshPoseTool.hpp
include/rviz_mesh_tools_plugins/MeshGoalTool.hpp
Expand Down Expand Up @@ -116,7 +111,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
target_link_libraries(${PROJECT_NAME} PRIVATE
${HDF5_LIBRARIES}
${HDF5_HL_LIBRARIES}
${OpenCL_LIBRARIES}
)

target_compile_definitions(${PROJECT_NAME} PRIVATE "RVIZ_MESH_TOOLS_PLUGINS_BUILDING_LIBRARY")#
Expand Down
476 changes: 0 additions & 476 deletions rviz_mesh_tools_plugins/include/rviz_mesh_tools_plugins/CLUtil.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public Q_SLOTS: // not sure wether any of those actually need to be q slots ...
*/
void setData(shared_ptr<Geometry> geometry, vector<Cluster> clusters);

/**
* @brief Slot for changing the culling mode used in the LabelTool, and the LabelVisuals
*/
void setCullingMode(Ogre::CullingMode mode);

private Q_SLOTS:

/**
Expand Down Expand Up @@ -232,9 +237,12 @@ private Q_SLOTS:
void onInitialize();

/**
* @brief Programmatically create an instance of the label tool from this package
* @brief Find the instance of the ClusterLabelTool or create one.
*
* We cannot store a pointer to the tool because RViz could sometimes replaces
* the Tool instance, and that would invalidate our pointer.
*/
void initializeLabelTool();
ClusterLabelTool* getOrCreateLabelTool();

/**
* @brief Create visuals for each cluster in the list
Expand Down Expand Up @@ -266,9 +274,6 @@ private Q_SLOTS:
/// Cluster data
vector<Cluster> m_clusterList;

/// Label tool
ClusterLabelTool* m_tool;

/// Property for the current active visual
rviz_common::properties::EnumProperty* m_activeVisualProperty;

Expand All @@ -293,6 +298,9 @@ private Q_SLOTS:
/// A variable that will be set to true, once the initial data has arrived
bool has_data = false;

/// Current Culling Mode
Ogre::CullingMode m_cullingMode;


};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,7 @@

#include <rviz_mesh_tools_plugins/Types.hpp>

// TODO: Make CL optional
// enable exceptions for OpenCL
// #define CL_HPP_TARGET_OPENCL_VERSION 120
// #define CL_HPP_MINIMUM_OPENCL_VERSION 110
// #define CL_HPP_ENABLE_EXCEPTIONS
// #include <CL/cl2.hpp>

#include <vector>
#include <map>
#include <memory>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
Expand Down Expand Up @@ -136,6 +128,10 @@ class ClusterLabelTool : public rviz_common::Tool
{
Q_OBJECT
public:
// Constants
static constexpr float MIN_BRUSH_SIZE = 20.0f;
static constexpr float MOUSE_WHEEL_BRUSH_SIZE_STEP = 10;

/**
* @brief Constructor
*/
Expand Down Expand Up @@ -181,10 +177,15 @@ class ClusterLabelTool : public rviz_common::Tool
void setVisual(std::shared_ptr<ClusterLabelVisual> visual);

/**
* @brief Adjust the sphere size for the brush tool
* @param size The sphere size
* @brief Adjust the circle size for the brush tool
* @param size The circle diameter in screen Pixels
*/
void setBrushSize(float size);

/**
* @brief Set the culling mode for selection to match the MeshVisual
*/
void setSphereSize(float size);
void setCullingMode(Ogre::CullingMode mode);

public Q_SLOTS:

Expand Down Expand Up @@ -213,71 +214,70 @@ public Q_SLOTS:
private:
std::vector<uint32_t> m_selectedFaces;
std::vector<bool> m_faceSelectedArray;
bool m_displayInitialized;
ClusterLabelDisplay* m_display;
std::shared_ptr<ClusterLabelVisual> m_visual;
std::shared_ptr<Geometry> m_meshGeometry;
float m_sphereSize = 1.0f;
float m_brushSize;

// Selection Box
rviz_common::DisplayContext* m_displayContext;
Ogre::SceneNode* m_sceneNode;
Ogre::ManualObject* m_selectionBox;
Ogre::MaterialPtr m_selectionBoxMaterial;

// rviz_common::ViewportMouseEvent m_evt_start;
// rviz_common::ViewportMouseEvent m_evt_stop;

// Selection Circle
Ogre::ManualObject* m_selectionCircle;
Ogre::SceneNode* m_selectionCircleNode;

int m_bb_x1;
int m_bb_y1;
int m_bb_x2;
int m_bb_y2;

rviz_common::RenderPanel* m_evt_panel;


// Selection Modes
bool m_multipleSelect = false;
bool m_singleSelect = false;
bool m_singleDeselect = false;
bool m_circleSelect = false;
// Select = true Deselect = false
bool m_selectionMode = false;

std::vector<Ogre::Vector3> m_vertexPositions;

void initSelectionCircle();
void updateSelectionCircle(rviz_common::ViewportMouseEvent& event);
void updateSelectionBox();
void selectionBoxStart(rviz_common::ViewportMouseEvent& event);
void selectionBoxMove(rviz_common::ViewportMouseEvent& event);
void selectMultipleFaces(rviz_common::ViewportMouseEvent& event, bool selectMode);
void selectFacesInBoxParallel(Ogre::PlaneBoundedVolume& volume, bool selectMode);
void selectSingleFace(rviz_common::ViewportMouseEvent& event, bool selectMode);
void selectSingleFaceParallel(Ogre::Ray& ray, bool selectMode);
void selectSphereFaces(rviz_common::ViewportMouseEvent& event, bool selectMode);
void selectSphereFacesParallel(Ogre::Ray& ray, bool selectMode);
boost::optional<std::pair<uint32_t, float>> getClosestIntersectedFaceParallel(Ogre::Ray& ray);
void selectCircleFaces(rviz_common::ViewportMouseEvent& event, bool selectMode);

rclcpp::Publisher<mesh_msgs::msg::MeshFaceClusterStamped>::SharedPtr m_labelPublisher;

std::vector<float> m_vertexData;
std::array<float, 6> m_rayData;
std::array<float, 4> m_sphereData;
std::array<float, 3> m_startNormalData;
std::vector<float> m_boxData;
std::vector<float> m_resultDistances;

// OpenCL
// cl::Device m_clDevice;
// cl::Context m_clContext;
// cl::Program::Sources m_clProgramSources;
// cl::Program m_clProgram;
// cl::CommandQueue m_clQueue;
// cl::Buffer m_clVertexBuffer;
// cl::Buffer m_clResultBuffer;
// cl::Buffer m_clRayBuffer;
// cl::Buffer m_clSphereBuffer;
// cl::Buffer m_clBoxBuffer;
// cl::Buffer m_clStartNormalBuffer;
// cl::Kernel m_clKernelSingleRay;
// cl::Kernel m_clKernelSphere;
// cl::Kernel m_clKernelBox;
// cl::Kernel m_clKernelDirAndDist;
/**
* @brief Renders the current Mesh to an Offscreen Buffer using the FaceIDs as colors.
*
* The resulting Image can be used to determine which faces are visible from the Camera.
*
* @return The rendered Image.
*/
Ogre::Image renderMeshWithFaceID();

/**
* @brief Setup the Selection Mesh from the current geometry
*/
void updateSelectionMesh();

// Accelerated area picking via Ogre render pass
Ogre::TexturePtr m_selectionTexture;
Ogre::MaterialPtr m_selectionMaterial;
Ogre::ManualObject* m_selectionMesh;
Ogre::SceneNode* m_selectionSceneNode;
// Used to render only the selectionMesh to the offscreen Texture
uint32_t m_selectionVisibilityBit;
Ogre::CullingMode m_cullingMode;
};
} // end namespace rviz_mesh_tools_plugins

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ class ClusterLabelVisual
return m_faces;
};

/**
* @brief Set the culling mode to match the MeshDisplay/MeshVisual
*/
void setCullingMode(Ogre::CullingMode mode);

private:
void initMaterial();

Expand All @@ -179,4 +184,4 @@ class ClusterLabelVisual

} // end namespace rviz_mesh_tools_plugins

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ class MeshDisplay : public rviz_common::Display
*/
void setPose(Ogre::Vector3& position, Ogre::Quaternion& orientation);

signals:
/**
* @brief Signals that the Culling Mode of the MeshDisplay was set.
*/
void signalCullingModeChanged(Ogre::CullingMode mode);

private Q_SLOTS:
void transformerChangedCallback();

Expand Down
Loading