Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LiangliangNan committed Feb 10, 2025
1 parent c77133f commit 5db119c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
33 changes: 26 additions & 7 deletions easy3d/core/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ namespace easy3d {
return idx_ < _rhs.idx_;
}

/// helper structure to be able to use std::unordered_map
/// Helper structure to be able to use std::unordered_map
struct Hash {
/// Hash function, which is simply the index.
std::size_t operator()(const BaseHandle& h) const { return h.idx(); }
};

Expand All @@ -130,6 +131,11 @@ namespace easy3d {
* \param _idx The index of the vertex.
*/
explicit Vertex(int _idx = -1) : BaseHandle(_idx) {}
/**
* \brief Output operator.
* \param os The output stream.
* \return The output stream.
*/
std::ostream& operator<<(std::ostream& os) const { return os << 'v' << idx(); }
};

Expand Down Expand Up @@ -180,9 +186,12 @@ namespace easy3d {
template <class T> class VertexProperty : public Property<T>
{
public:

/// default constructor
/// Default constructor
explicit VertexProperty() = default;
/**
* \brief Constructor with a property.
* \param p The property.
*/
explicit VertexProperty(Property<T> p) : Property<T>(p) {}

/**
Expand Down Expand Up @@ -215,9 +224,12 @@ namespace easy3d {
template <class T> class EdgeProperty : public Property<T>
{
public:

/// default constructor
/// Default constructor
explicit EdgeProperty() = default;
/**
* \brief Constructor with a property.
* \param p The property.
*/
explicit EdgeProperty(Property<T> p) : Property<T>(p) {}

/**
Expand Down Expand Up @@ -249,9 +261,12 @@ namespace easy3d {
template <class T> class ModelProperty : public Property<T>
{
public:

/// default constructor
/// Default constructor
explicit ModelProperty() = default;
/**
* \brief Constructor with a property.
* \param p The property.
*/
explicit ModelProperty(Property<T> p) : Property<T>(p) {}

/**
Expand Down Expand Up @@ -439,7 +454,9 @@ namespace easy3d {
* \param _end The end iterator.
*/
VertexContainer(VertexIterator _begin, VertexIterator _end) : begin_(_begin), end_(_end) {}
/// Returns the begin iterator.
VertexIterator begin() const { return begin_; }
/// Returns the end iterator.
VertexIterator end() const { return end_; }
private:
VertexIterator begin_, end_;
Expand All @@ -458,7 +475,9 @@ namespace easy3d {
* \param _end The end iterator.
*/
EdgeContainer(EdgeIterator _begin, EdgeIterator _end) : begin_(_begin), end_(_end) {}
/// Returns the begin iterator.
EdgeIterator begin() const { return begin_; }
/// Returns the end iterator.
EdgeIterator end() const { return end_; }
private:
EdgeIterator begin_, end_;
Expand Down
29 changes: 29 additions & 0 deletions easy3d/viewer/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,25 @@ namespace easy3d {
* @related add_model(const std::string&, bool).
*/
Model* add_model(std::shared_ptr<Model> model, bool create_default_drawables = true);
/**
* @brief Add an existing model to the viewer to be visualized. On success, the viewer will
* be in charge of the memory management of the model.
* @details This method adds a model into the viewer. It allows the user to control if
* default drawables will be created. The default drawables are
* - for point clouds: "vertices".
* - for surface meshes: "faces", "vertices", "edges", "borders", and "locks".
* - for graphs: "vertices" and "edges".
* - polyhedral meshes: "faces:border", "faces:interior", "vertices", and "edges".
* These drawables are usually sufficient for basic rendering of the model. In case
* the default drawables don't meet the particular visualization purpose, you can
* set 'create_default_drawables' to false and create your needed drawables by
* calling model->renderer()->add_[type]_drawable(). Here the [type] must be one of
* "points", "lines", and "triangles'.
* @param model The pointer to the model.
* @param create_default_drawables If true, the default drawables will be created.
* @return The pointer to the model added to the viewer (nullptr if failed).
* @sa add_model(const std::string&, bool).
*/
Model* add_model(Model* model, bool create_default_drawables = true);

/**
Expand Down Expand Up @@ -292,6 +311,16 @@ namespace easy3d {
* @return The pointer of the drawable added to the viewer.
*/
Drawable* add_drawable(std::shared_ptr<Drawable> drawable);
/**
* @brief Add a drawable to the viewer to be visualized. On success, the viewer will be in
* charge of the memory management of the drawable
* @details The use of drawables for visualization is quite flexible. Drawables are
* typically created for rendering 3D models (e.g., point clouds, meshes, graphs)
* and a 3D model is usually loaded from a file or generated by an algorithm. This
* method allows the user to visualize drawables without defining a 3D model.
* @param drawable The pointer to the drawable.
* @return The pointer of the drawable added to the viewer.
*/
Drawable* add_drawable(Drawable* drawable);

/**
Expand Down

0 comments on commit 5db119c

Please sign in to comment.