FlowEngine 8.011
Photogrammetry Software Development Kit
Loading...
Searching...
No Matches
CommonDef.h
Go to the documentation of this file.
1/*
2 *
3 * C@@o ____ _____ __ _
4 * oC8@@@@@@@o |___ \| __ \ / _| |
5 * o@@@@@@@@@@@@O __) | | | | |_| | _____ __
6 * O@O 8@@@@@@@@@O |__ <| | | | _| |/ _ \ \ /\ / /
7 * o@@@@@@@O OOOOOCo ___) | |__| | | | | (_) \ V V /
8 * C@@@@@@@@@@@@Oo |____/|_____/|_| |_|\___/ \_/\_/
9 * o8@@@@@@@@@@@@@@@@8OOCCCC
10 * oO@@@@@@@@@@@@@@@@@@@o 3Dflow s.r.l. - www.3dflow.net
11 * oO8@@@@@@@@@@@@o Copyright 2022
12 * oO88@@@@@@@@8OCo All Rights Reserved
13 * O@@@@@@@@@@@@@@@@@@@@@@@@@8OCCoooooooCCo
14 * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O
15 * @@@Oo oO8@@@@@@@@@@@@@@@@8
16 *
17 */
18
19#ifndef FLOWENGINECOMMONDEF_H
20#define FLOWENGINECOMMONDEF_H
21
22#pragma once
23
24#if defined( WIN32 )
25#define FLE_DLL __declspec( dllexport )
26#elif defined( __LINUX__ )
27#define FLE_DLL __attribute__( ( visibility( "default" ) ) )
28#else
29#error "FlowEngine not supported on this platform!"
30#endif
31
32#define FLOWENGINE_FACTORY extern "C" FLE_DLL
33
34#include <cstddef>
35#include <cstdint>
36#include <cstring>
37#include <string>
38#include <vector>
39#include <cassert>
40
41namespace FlowEngine
42{
44 enum class Result : std::size_t
45 {
47 Success = 0,
48
51
54
57
60
63
67
70
73
76
82
85
88
97 };
98
100 using Index = std::ptrdiff_t;
101
103 using Size = std::size_t;
104
106 using ColorComponent = std::uint8_t;
107
109 using ColorComponent32 = float;
110
112 using ReconstructionID = unsigned int;
113
116 template< typename T >
117 struct Buffer
118 {
120 T *data = nullptr;
121
124
126 Buffer() = default;
127
129 Buffer( T *d, Size s )
130 : data( d )
131 , count( s )
132 { }
133
135 template< std::size_t N >
136 Buffer( T( &fixedSizeArray )[ N ] )
137 : data( fixedSizeArray )
138 , count( N )
139 { }
140
142 Buffer( std::vector< T > &v )
143 : data( v.empty() ? nullptr : v.data() )
144 , count( v.empty() ? 0 : v.size() )
145 { }
146
148 Buffer( std::vector< T > &&v ) = delete;
149
151 explicit operator bool() const
152 {
153 return data != nullptr && count != 0;
154 }
155
157 T *begin()
158 {
159 assert( data );
160 return data;
161 }
162
164 T *end()
165 {
166 assert( data );
167 return data + count;
168 }
169
171 T &operator []( std::size_t index )
172 {
173 assert( data );
174 assert( index < count );
175 return data[ index ];
176 }
177
179 const T &operator []( std::size_t index ) const
180 {
181 assert( data );
182 assert( index < count );
183 return data[ index ];
184 }
185 };
186
189 template< typename T >
191 {
193 const T *data = nullptr;
194
197
199 ConstBuffer() = default;
200
202 ConstBuffer( const T *d, Size s )
203 : data( d )
204 , count( s )
205 { }
206
208 template< std::size_t N >
209 ConstBuffer( const T( &fixedSizeArray )[ N ] )
210 : data( fixedSizeArray )
211 , count( N )
212 { }
213
215 ConstBuffer( const std::vector< T > &v )
216 : data( v.empty() ? nullptr : v.data() )
217 , count( v.empty() ? 0 : v.size() )
218 { }
219
221 ConstBuffer( std::vector< T > &&v ) = delete;
222
224 explicit operator bool() const
225 {
226 return data != nullptr;
227 }
228
230 const T *begin() const
231 {
232 assert( data );
233 return data;
234 }
235
237 const T *end() const
238 {
239 assert( data );
240 return data + count;
241 }
242
244 const T &operator []( std::size_t index ) const
245 {
246 assert( data );
247 assert( index < count );
248 return data[ index ];
249 }
250 };
251
253 template< >
254 struct Buffer< char >
255 {
257 char *data = nullptr;
258
261
263 Buffer() = default;
264
266 Buffer( std::string &str )
267 : data( &str[ 0 ] )
268 , count( str.size() )
269 { }
270
273 : data( data )
274 , count( count )
275 { }
276
278 Buffer( std::vector< char > &v )
279 : data( v.empty() ? nullptr : v.data() )
280 , count( v.empty() ? 0 : v.size() )
281 { }
282
284 Buffer( std::string &&str ) = delete;
285
287 explicit operator bool() const
288 {
289 return data != nullptr && count != 0;
290 }
291 };
292
294 template< >
295 struct ConstBuffer< char >
296 {
298 const char *data = nullptr;
299
302
304 ConstBuffer() = default;
305
307 ConstBuffer( const std::string &str )
308 : data( str.data() )
309 , count( str.size() )
310 { }
311
313 ConstBuffer( std::string &&str ) = delete;
314
316 ConstBuffer( const char *str )
317 : data( str )
318 , count( std::strlen( str ) )
319 { }
320
322 ConstBuffer( const char *data, Size count )
323 : data( data )
324 , count( count )
325 { }
326
328 ConstBuffer( const std::vector< char > &v )
329 : data( v.empty() ? nullptr : v.data() )
330 , count( v.empty() ? 0 : v.size() )
331 { }
332
334 explicit operator bool() const
335 {
336 return data != nullptr && count != 0;
337 }
338 };
339
344
346 struct Version final
347 {
349 int major = 0;
350
352 int minor = 0;
353
355 inline bool isSameAs( const Version &other ) const
356 {
357 return major == other.major && minor == other.minor;
358 }
359
361 inline bool isOlderThan( const Version &other ) const
362 {
363 if ( major < other.major )
364 return true;
365
366 if ( major > other.major )
367 return false;
368
369 return minor < other.minor;
370 }
371 };
372
374 struct Point3
375 {
377 double x = 0;
378
380 double y = 0;
381
383 double z = 0;
384 };
385
387 struct Point2
388 {
390 double x = 0;
391
393 double y = 0;
394 };
395
397 struct Normal
398 {
400 float x = 0;
401
403 float y = 0;
404
406 float z = 0;
407 };
408
410 struct Color
411 {
414
417
420 };
421
424 {
427
430
433 };
434
437
441 struct Triangle
442 {
445
448
451 };
452
456 {
458 float u = 0;
459
461 float v = 0;
462 };
463
467 {
470
472 double angle = 0;
473 };
474
478 struct Image
479 {
481 int width = 0;
482
484 int height = 0;
485
488 };
489
491 enum class StandardAxis
492 {
494 X,
495
497 Y,
498
500 Z,
501 };
502
504 template< typename T, typename S >
505 struct Pair
506 {
509 };
510
512 struct DateTime
513 {
515 int year = 0;
516
518 int month = 0;
519
521 int day = 0;
522
524 int hour = 0;
525
527 int minute = 0;
528
530 int second = 0;
531 };
532
534 struct Vector3
535 {
536 double data[ 3 ] = { };
537
538 double x() const { return data[ 0 ]; }
539 double y() const { return data[ 1 ]; }
540 double z() const { return data[ 2 ]; }
541
542 double &x() { return data[ 0 ]; }
543 double &y() { return data[ 1 ]; }
544 double &z() { return data[ 2 ]; }
545
547 double &operator ()( int index ) { return data[ index ]; }
548
550 const double &operator ()( int index ) const { return data[ index ]; }
551 };
552
555 {
556 double data[ 9 ] = { };
557
559 double &operator ()( int row, int col ) { return data[ row * 3 + col ]; }
560
562 const double &operator ()( int row, int col ) const { return data[ row * 3 + col ]; }
563 };
564
567 {
568 int bus = -1;
569 int idx = -1;
570
572 operator bool() const
573 {
574 return bus >= 0 && idx >= 0;
575 }
576 };
577
580 {
581 Invalid = 0,
582 CUDA = 1,
583 OpenCL = 2,
584 };
585
588 {
591 int idx = -1;
592 int bus = -1;
593 char name[ 512 ] = { };
594 long long physicalMemoryMB = 0;
595 bool isIntegrated = false;
596 };
597
599 {
603 };
604
606 {
611 };
612
614}
615
616#endif
Definition: BoundingBoxInterface.cpp:26
int PointClassification
Definition: CommonDef.h:613
std::ptrdiff_t Index
Index type.
Definition: CommonDef.h:100
float ColorComponent32
Color component (32 bits) type.
Definition: CommonDef.h:109
PointClassificationAttributes
Definition: CommonDef.h:599
@ PointClassificationFlag_IsGround
Definition: CommonDef.h:602
PointClassificationCategory
Definition: CommonDef.h:606
@ PointClassificationCategory_Unknown
Definition: CommonDef.h:607
@ PointClassificationCategory_Trees
Definition: CommonDef.h:610
@ PointClassificationCategory_Buildings
Definition: CommonDef.h:609
@ PointClassificationCategory_Roads
Definition: CommonDef.h:608
std::uint8_t ColorComponent
Color component (8 bits) type.
Definition: CommonDef.h:106
StandardAxis
enumerates the standard axes
Definition: CommonDef.h:492
GraphicsDevicePlatform
The platform of a GPU device.
Definition: CommonDef.h:580
std::size_t Size
Size type.
Definition: CommonDef.h:103
unsigned int ReconstructionID
Unique identification number in a group of cameras.
Definition: CommonDef.h:112
Result
Enumerates possible results generated by FlowEngine.
Definition: CommonDef.h:45
@ UnsupportedVersion
The version of the loading 3DK is not supported or did not match the minimum requirements.
@ InvalidArgument
One or more supplied arguments are invalid.
@ FileNotFound
File not found.
@ PreconditionNotMet
One or more preconditions were not met.
@ Success
Everything went ok.
@ OutOfMemoryError
An out of RAM memory error has been received.
@ NewVersionAvailable
A New SDK version is available to download.
@ BufferTooSmall
The provided buffer is too small to complete the operation.
@ GenericError
Something went wrong. Usually the log contains more detailed information.
@ FeatureNotAvailable
This feature is not available in this version of FlowEngine.
@ ProcessNotRunning
An abort or pause signal has been emitted, but no process is running.
Specialization for a Buffer of characters.
Definition: CommonDef.h:255
Buffer(char *data, Size count)
Construction from an arbitrary buffer and size.
Definition: CommonDef.h:272
Buffer(std::string &&str)=delete
Prohibit conversion from a temporary string.
Buffer(std::vector< char > &v)
Implicit conversion from a std::vector.
Definition: CommonDef.h:278
Buffer(std::string &str)
Implicit conversion from a std::string.
Definition: CommonDef.h:266
Buffer()=default
Represents an empty C string literal.
Holds a (mutable) non_owning pointer and a size Used to marshal memory buffers as arguments in a safe...
Definition: CommonDef.h:118
T * end()
Iteration support.
Definition: CommonDef.h:164
Buffer()=default
Represents an empty buffer.
T * begin()
Iteration support.
Definition: CommonDef.h:157
T * data
Pointer to the (mutable) data.
Definition: CommonDef.h:120
T & operator[](std::size_t index)
Indexed access.
Definition: CommonDef.h:171
Buffer(std::vector< T > &v)
Implicit conversion from a std::vector.
Definition: CommonDef.h:142
Buffer(std::vector< T > &&v)=delete
Prohibits implicit conversion from a temporary std::vector.
Buffer(T *d, Size s)
Construct a buffer from a (mutable) pointer and a size.
Definition: CommonDef.h:129
Buffer(T(&fixedSizeArray)[N])
Implicit conversion from a fixed-size array.
Definition: CommonDef.h:136
Size count
Number of elements the pointer points to.
Definition: CommonDef.h:123
a packed RGB color
Definition: CommonDef.h:411
ColorComponent r
red component
Definition: CommonDef.h:413
ColorComponent g
green component
Definition: CommonDef.h:416
ColorComponent b
blue component
Definition: CommonDef.h:419
Specialization for a const buffer characters.
Definition: CommonDef.h:296
ConstBuffer(std::string &&str)=delete
Prohibits conversion from a temporary std::string.
ConstBuffer(const std::vector< char > &v)
Implicit conversion from a std::vector.
Definition: CommonDef.h:328
ConstBuffer(const char *str)
Implicit conversion from a C string literal.
Definition: CommonDef.h:316
ConstBuffer(const std::string &str)
Implicit conversion from a std::string.
Definition: CommonDef.h:307
ConstBuffer()=default
Creates an empty string buffer.
ConstBuffer(const char *data, Size count)
Construction from an arbitrary buffer and size.
Definition: CommonDef.h:322
Holds a (non mutable) non_owning pointer and a count Used to marshal memory buffers as arguments in a...
Definition: CommonDef.h:191
ConstBuffer(const std::vector< T > &v)
Implicit conversion from a std::vector.
Definition: CommonDef.h:215
Size count
Number of elements the pointer points to.
Definition: CommonDef.h:196
const T & operator[](std::size_t index) const
Indexed access.
Definition: CommonDef.h:244
const T * end() const
Iteration support.
Definition: CommonDef.h:237
const T * begin() const
Iteration support.
Definition: CommonDef.h:230
ConstBuffer()=default
Creates an empty buffer.
const T * data
Pointer to the (immutable) data.
Definition: CommonDef.h:193
ConstBuffer(std::vector< T > &&v)=delete
Prohibits implicit conversion from a temporary std::vector.
ConstBuffer(const T *d, Size s)
Creates a const buffer with a const pointer and a size.
Definition: CommonDef.h:202
ConstBuffer(const T(&fixedSizeArray)[N])
Implicit conversion from a fixed-size array.
Definition: CommonDef.h:209
Represents a moment in time.
Definition: CommonDef.h:513
int second
the second in the range (0-59)
Definition: CommonDef.h:530
int year
the year (e.g. 2019)
Definition: CommonDef.h:515
int hour
the hour in the range (0-23)
Definition: CommonDef.h:524
int day
the day in the range 1-31
Definition: CommonDef.h:521
int month
the month in the range 1-12
Definition: CommonDef.h:518
int minute
the minute in the range (0-59)
Definition: CommonDef.h:527
Represents a logical graphics device.
Definition: CommonDef.h:567
int idx
Definition: CommonDef.h:569
int bus
Definition: CommonDef.h:568
Basic information about a GPU device.
Definition: CommonDef.h:588
char name[512]
Definition: CommonDef.h:593
GraphicsDevicePlatform platform
Definition: CommonDef.h:590
int bus
Definition: CommonDef.h:592
bool isIntegrated
Definition: CommonDef.h:595
long long physicalMemoryMB
Definition: CommonDef.h:594
int idx
Definition: CommonDef.h:591
GraphicsDeviceID id
Definition: CommonDef.h:589
a Quaternion Holds information about a raw image Data is not owned
Definition: CommonDef.h:479
Buffer< Color32 > data
the image color data stored as 3 floating-point values
Definition: CommonDef.h:487
int width
the image width in pixels
Definition: CommonDef.h:481
int height
the image height in pixels
Definition: CommonDef.h:484
a 3x3 matrix
Definition: CommonDef.h:555
double & operator()(int row, int col)
Definition: CommonDef.h:559
double data[9]
Definition: CommonDef.h:556
a normal
Definition: CommonDef.h:398
float y
y component
Definition: CommonDef.h:403
float x
x component
Definition: CommonDef.h:400
float z
z component
Definition: CommonDef.h:406
Bound 2 values together.
Definition: CommonDef.h:506
S second
Definition: CommonDef.h:508
T first
Definition: CommonDef.h:507
a 2 dimensional point
Definition: CommonDef.h:388
double y
y coordinate
Definition: CommonDef.h:393
double x
x coordinate
Definition: CommonDef.h:390
a three dimensional point
Definition: CommonDef.h:375
double z
z coordinate
Definition: CommonDef.h:383
double y
y coordinate
Definition: CommonDef.h:380
double x
x coordinate
Definition: CommonDef.h:377
a floating-point color
Definition: CommonDef.h:424
ColorComponent32 b
blue component
Definition: CommonDef.h:432
ColorComponent32 r
red component
Definition: CommonDef.h:426
ColorComponent32 g
green component
Definition: CommonDef.h:429
a Quaternion Holds an axis and an angle
Definition: CommonDef.h:467
double angle
the angle
Definition: CommonDef.h:472
Point3 axis
the axis
Definition: CommonDef.h:469
a texture coordinate Holds a couple of floats representing texture coordinates
Definition: CommonDef.h:456
float v
the v component
Definition: CommonDef.h:461
float u
the u component
Definition: CommonDef.h:458
a triangle. Holds 3 indexes to points. Triangles are specified in counter-clockwise order
Definition: CommonDef.h:442
Index idx1
the second index
Definition: CommonDef.h:447
Index idx0
the first index
Definition: CommonDef.h:444
Index idx2
the third index
Definition: CommonDef.h:450
a 3d vector
Definition: CommonDef.h:535
double z() const
Definition: CommonDef.h:540
double & x()
Definition: CommonDef.h:542
double & operator()(int index)
Definition: CommonDef.h:547
double & y()
Definition: CommonDef.h:543
double data[3]
Definition: CommonDef.h:536
double y() const
Definition: CommonDef.h:539
double x() const
Definition: CommonDef.h:538
double & z()
Definition: CommonDef.h:544
Represents a version in the major.minor categories format.
Definition: CommonDef.h:347
int major
the major category of this version
Definition: CommonDef.h:349
bool isOlderThan(const Version &other) const
Definition: CommonDef.h:361
int minor
the minor category of this version
Definition: CommonDef.h:352
bool isSameAs(const Version &other) const
Definition: CommonDef.h:355