plastimatch
Loading...
Searching...
No Matches
pointset.h
Go to the documentation of this file.
1/* -----------------------------------------------------------------------
2 See COPYRIGHT.TXT and LICENSE.TXT for copyright and license information
3 ----------------------------------------------------------------------- */
4#ifndef _pointset_h_
5#define _pointset_h_
6
7#include "plmbase_config.h"
8#include <string>
9#include <vector>
10#include "compiler_warnings.h"
11#include "smart_pointer.h"
12
13class Pstring;
14
16public:
17 Point () {}
18 Point (const std::string& label, float x, float y, float z) {
19 UNUSED_VARIABLE (label);
20 p[0] = x;
21 p[1] = y;
22 p[2] = z;
23 }
24 Point (float x, float y, float z) {
25 p[0] = x;
26 p[1] = y;
27 p[2] = z;
28 }
29public:
30 float p[3];
31public:
32 void set_label (const char* s) {
34 }
35 std::string get_label (void) const {
36 return "";
37 }
38};
39
41public:
43 Labeled_point (const std::string& label, float x, float y, float z) {
44 this->label = label;
45 p[0] = x;
46 p[1] = y;
47 p[2] = z;
48 }
49public:
50 std::string label;
51 float p[3];
52public:
53 void set_label (const char* s) {
54 this->label = s;
55 }
56 const std::string& get_label (void) const {
57 return this->label;
58 }
59};
60
61template<class T>
63public:
65public:
66 Pointset();
67 Pointset(const std::string& s);
68 ~Pointset();
69public:
70 std::vector<T> point_list;
71public:
72 void load (const std::string& s);
73 void load (const char *fn);
74 void load_txt (const char *fn);
75 void load_fcsv (const char *fn);
76 void save (const char *fn);
77 void save_fcsv (const char *fn);
78 void save_fcsv (const std::string& fn);
79 void save_txt (const char *fn);
80
81 /* Insert a list of points of the form "x,y,z;x,y,z;..." */
82 void insert_ras (const std::string& p);
83
84 /* Insert single points */
85 void insert_lps (const std::string& label, float x, float y, float z);
86 void insert_lps (const float* xyz);
87 void insert_lps (const std::string& label, const float* xyz);
88 void insert_ras (const std::string& label, float x, float y, float z);
89 void insert_ras (const float* xyz);
90
91 /* Return reference to a point */
92 const T& point (int idx) const {
93 return point_list[idx];
94 }
95 /* Return coordinate of point */
96 float point (int idx, int dim) const {
97 return point_list[idx].p[dim];
98 }
99
100 /* Return the number of points */
101 size_t get_count (void) const;
102
103 /* Truncate points at the end of the list */
104 void truncate (size_t new_length);
105
106 void debug () const;
107private:
108 Pointset (const Pointset&);
110};
111
114
115#endif
Definition pointset.h:40
void set_label(const char *s)
Definition pointset.h:53
const std::string & get_label(void) const
Definition pointset.h:56
Labeled_point(const std::string &label, float x, float y, float z)
Definition pointset.h:43
std::string label
Definition pointset.h:50
Labeled_point()
Definition pointset.h:42
Definition pointset.h:15
Point(const std::string &label, float x, float y, float z)
Definition pointset.h:18
Point(float x, float y, float z)
Definition pointset.h:24
std::string get_label(void) const
Definition pointset.h:35
float p[3]
Definition pointset.h:30
Point()
Definition pointset.h:17
void set_label(const char *s)
Definition pointset.h:32
Definition pointset.h:62
const T & point(int idx) const
Definition pointset.h:92
std::vector< T > point_list
Definition pointset.h:70
SMART_POINTER_SUPPORT(Pointset)
float point(int idx, int dim) const
Definition pointset.h:96
void load(const std::string &s)
#define UNUSED_VARIABLE(a)
Definition compiler_warnings.h:7
#define PLMBASE_API
Definition plmbase_config.h:19
Pointset< Point > Unlabeled_pointset
Definition pointset.h:113
Pointset< Labeled_point > Labeled_pointset
Definition pointset.h:112