Cumulia Illustrator Rendering Engine v1.1.0
A Rendering engine for industrial CAD/CAE model and optimized for greatest performance
 
Loading...
Searching...
No Matches
minmax.h
1//##################################################################################################
2//
3// Copyright (c) 2024 Beijing Qiongqi Tech Co.,Ltd. All rights reserved.
4
5// This source code is confidential and proprietary to Beijing Qiongqi Tech Co.,Ltd(The Holder).
6// Any unauthorized use, copying, modification, or distribution of the code is strictly prohibited.
7// Any user shall obtain authorizaition from the Holder before modifying the source code. And the user shall not
8// sublicense, sell, distribute, or transfer the source code, whether in original or modified form, to any third party
9// without the prior written consent of the Holder.
10
11// This copyright notice and permission grant shall be included in all copies or substantial portions of the source code.
12
13// Author Cumulia Illustrator
14// Date 2024-10-31
15// Version V1.1.0
16//##################################################################################################
17
18#pragma once
19
20// bitten by these ancient macros. They can't remove them, that would break old code.
21// https://stackoverflow.com/questions/6884093/warning-c4003-not-enough-actual-parameters-for-macro-max-visual-studio-2010
22#undef min
23#undef max
24
25#include "tuple.h"
26
27namespace cil
28{
30 class MinMax final : public Tuple<float>
31 {
32 public:
34 MinMax(float min, float max);
35 MinMax(const MinMax& other);
36
38 const float& operator[](int index) const;
40 float& operator[](int index);
42 MinMax& operator+=(const MinMax& other);
44 MinMax& operator+=(float value);
45
47 void set(float min, float max);
49 float min() const;
51 void setMin(float min);
53 float max() const;
55 void setMax(float max);
57 bool isValid() const;
58 float center() const;
59 float length() const;
60 bool inRange(float value) const;
61 };
62
63 using minmax = MinMax;
64}
The MinMax class inherits from Tuple, specilizing the template parameters to float for element type.
Definition minmax.h:31
bool isValid() const
Check if the MinMax is valid, which means that the minimum value should be less than or equal to the ...
float center() const
Gets the mean value of the minimum and maximum values.
void setMin(float min)
Sets the min value.
MinMax(const MinMax &other)
float length() const
Gets the extent of this MinMax.
MinMax & operator+=(const MinMax &other)
Expands the current MinMax to emcompass the minimum and maximum value of the other MinMax.
const float & operator[](int index) const
Provides read-only access to the element at a specific index(position) within the MinMax object.
float min() const
Gets the min value.
void set(float min, float max)
Sets the min and max value of this MinMax object.
float max() const
Gets the max value.
bool inRange(float value) const
Check if a value is in the range of the MinMax.
float & operator[](int index)
Provides read-write access to the element at a specific index(position) within the MinMax object.
void setMax(float max)
Sets the max value.
MinMax(float min, float max)
Constructs a MinMax object which holds two value (min, max), and initializes the min value as the low...
MinMax & operator+=(float value)
Expands the current MinMax to emcompass the given value.
The Tuple is a templated class inheriting from the most basic class Variant.
Definition tuple.h:27
Definition decal.h:23