mesh_client.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020, Sebastian Pütz
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * authors:
34  * Sebastian Pütz <spuetz@uni-osnabrueck.de>
35  *
36  */
37 
38 #ifndef MESH_CLIENT_H_
39 #define MESH_CLIENT_H_
40 
41 // #define CPPHTTPLIB_OPENSSL_SUPPORT
42 
43 #include <string>
44 #include <array>
48 #include <jsoncpp/json/json.h>
49 
50 namespace mesh_client
51 {
53 {
54 public:
59  MeshClient(const std::string& srv_url, const std::string& server_username, const std::string& server_password,
60  const std::string& mesh_layer);
61 
65  void setBoundingBox(float min_x, float min_y, float min_z, const float max_x, const float max_y, const float max_z);
66  void addFilter(std::string channel, float min_value, float max_value);
67 
75  std::string buildJson(const std::string& attribute_name);
76 
80  enum Type : char
81  {
82  UINT = 0,
83  FLOAT = 1,
84  UCHAR = 2
85  };
86 
92 
98 
103  bool addVertices(const lvr2::FloatChannel& channel_ptr);
104 
109  bool addIndices(const lvr2::IndexChannel& channel_ptr);
110 
118  bool getChannel(const std::string group, const std::string name, lvr2::FloatChannelOptional& channel);
119 
127  bool getChannel(const std::string group, const std::string name, lvr2::IndexChannelOptional& channel);
128 
136  bool getChannel(const std::string group, const std::string name, lvr2::UCharChannelOptional& channel);
137 
145  bool addChannel(const std::string group, const std::string name, const lvr2::FloatChannel& channel);
146 
154  bool addChannel(const std::string group, const std::string name, const lvr2::IndexChannel& channel);
155 
163  bool addChannel(const std::string group, const std::string name, const lvr2::UCharChannel& channel);
164 
165 private:
166  std::unique_ptr<std::string> requestChannel(std::string channel);
167 
168  std::map<std::string, lvr2::UCharChannel> uchar_channels;
169  std::map<std::string, lvr2::IndexChannel> index_channels;
170  std::map<std::string, lvr2::FloatChannel> float_channels;
171 
172  std::string server_url_;
173  std::string server_username_;
174  std::string server_password_;
175 
176  std::string mesh_layer_;
177  std::array<float, 6> bounding_box_;
178  std::map<std::string, std::pair<float, float>> mesh_filters_;
179 };
180 
181 size_t writeFunction(void* ptr, size_t size, size_t nmemb, std::string* data)
182 {
183  data->append((char*)ptr, size * nmemb);
184  return size * nmemb;
185 }
186 
187 } // namespace mesh_client
188 
189 #endif // MESH_CLIENT_H_
mesh_client::MeshClient::float_channels
std::map< std::string, lvr2::FloatChannel > float_channels
Definition: mesh_client.h:170
lvr2::IndexChannelOptional
IndexChannel::Optional IndexChannelOptional
mesh_client::MeshClient::uchar_channels
std::map< std::string, lvr2::UCharChannel > uchar_channels
Definition: mesh_client.h:168
lvr2::UCharChannelOptional
UCharChannel::Optional UCharChannelOptional
mesh_client::MeshClient::setBoundingBox
void setBoundingBox(float min_x, float min_y, float min_z, const float max_x, const float max_y, const float max_z)
sets the Bounding box for the query which is send to the server
Definition: mesh_client.cpp:53
mesh_client::MeshClient::addIndices
bool addIndices(const lvr2::IndexChannel &channel_ptr)
Persistence layer interface, Writes the face indices of the mesh to the persistence layer.
Definition: mesh_client.cpp:189
mesh_client::MeshClient::requestChannel
std::unique_ptr< std::string > requestChannel(std::string channel)
Definition: mesh_client.cpp:304
mesh_client::MeshClient::mesh_filters_
std::map< std::string, std::pair< float, float > > mesh_filters_
Definition: mesh_client.h:178
mesh_client::MeshClient::server_password_
std::string server_password_
Definition: mesh_client.h:174
mesh_client::MeshClient::Type
Type
Defines the data type of the transferred channel to decode the byte buffer.
Definition: mesh_client.h:80
mesh_client::MeshClient::FLOAT
@ FLOAT
Definition: mesh_client.h:83
mesh_client::MeshClient::server_url_
std::string server_url_
Definition: mesh_client.h:172
mesh_client::MeshClient::UINT
@ UINT
Definition: mesh_client.h:82
mesh_client::MeshClient::UCHAR
@ UCHAR
Definition: mesh_client.h:84
lvr2::FloatChannelOptional
FloatChannel::Optional FloatChannelOptional
BaseVector.hpp
lvr2::AttributeMeshIOBase
BoundingBox.hpp
mesh_client::MeshClient::getIndices
lvr2::IndexChannelOptional getIndices()
Persistence layer interface, Accesses the face indices of the mesh in the persistence layer.
Definition: mesh_client.cpp:153
AttributeMeshIOBase.hpp
mesh_client::MeshClient::addChannel
bool addChannel(const std::string group, const std::string name, const lvr2::FloatChannel &channel)
addChannel Writes a float attribute channel from the given group with the given name
Definition: mesh_client.cpp:286
mesh_client::MeshClient::buildJson
std::string buildJson(const std::string &attribute_name)
Builds a JSON string containing the set bounding box and the attribute name and the attribute group.
Definition: mesh_client.cpp:69
mesh_client::MeshClient::mesh_layer_
std::string mesh_layer_
Definition: mesh_client.h:176
mesh_client::MeshClient::MeshClient
MeshClient(const std::string &srv_url, const std::string &server_username, const std::string &server_password, const std::string &mesh_layer)
Constructs a mesh client which receaves.
Definition: mesh_client.cpp:44
mesh_client::MeshClient::bounding_box_
std::array< float, 6 > bounding_box_
Definition: mesh_client.h:177
mesh_client::MeshClient::server_username_
std::string server_username_
Definition: mesh_client.h:173
mesh_client::MeshClient::getVertices
lvr2::FloatChannelOptional getVertices()
Persistence layer interface, Accesses the vertices of the mesh in the persistence layer.
Definition: mesh_client.cpp:123
Channel< float >
mesh_client::MeshClient::addVertices
bool addVertices(const lvr2::FloatChannel &channel_ptr)
Persistence layer interface, Writes the vertices of the mesh to the persistence layer.
Definition: mesh_client.cpp:183
mesh_client::MeshClient::getChannel
bool getChannel(const std::string group, const std::string name, lvr2::FloatChannelOptional &channel)
getChannel Reads a float attribute channel in the given group with the given name
Definition: mesh_client.cpp:195
mesh_client::MeshClient::addFilter
void addFilter(std::string channel, float min_value, float max_value)
Definition: mesh_client.cpp:64
mesh_client
Definition: mesh_client.h:50
mesh_client::writeFunction
size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string *data)
Definition: mesh_client.h:181
mesh_client::MeshClient::index_channels
std::map< std::string, lvr2::IndexChannel > index_channels
Definition: mesh_client.h:169
mesh_client::MeshClient
Definition: mesh_client.h:52


mesh_client
Author(s): Sebastian Pütz , Malte kl. Piening
autogenerated on Thu Jan 25 2024 03:42:42