KiCad PCB EDA Suite
Loading...
Searching...
No Matches
constraint_system_2d.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef CONSTRAINT_SYSTEM_2D_H_
21#define CONSTRAINT_SYSTEM_2D_H_
22
23#include <cstddef>
24#include <deque>
25#include <memory>
26#include <vector>
27
28#include <math/vector2d.h>
29
30
31namespace GCS
32{
33class System;
34}
35
36
38{
39public:
40 using SNAPSHOT = std::vector<double>;
41
44
47
48 void SetCoordinateFrame( const VECTOR2I& aOrigin, double aScale );
49
50 double NormalizeX( int aIU ) const;
51 double NormalizeY( int aIU ) const;
52 double DenormalizeX( double aNormalized ) const;
53 double DenormalizeY( double aNormalized ) const;
54
55 int AddParameter( double aValue );
56 double& Parameter( int aIndex );
57 const double& Parameter( int aIndex ) const;
58 double* ParameterPointer( int aIndex );
59 std::size_t ParameterCount() const { return m_parameters.size(); }
60 std::deque<double>& ParameterStorage() { return m_parameters; }
61
62 SNAPSHOT Snapshot() const;
63 bool Restore( const SNAPSHOT& aSnapshot );
64 bool RestorePrefix( const SNAPSHOT& aSnapshot );
65 void Clear();
66
67 GCS::System& Solver();
68 const GCS::System& Solver() const;
69
70private:
71 std::unique_ptr<GCS::System> m_solver;
72 std::deque<double> m_parameters;
73 double m_originX = 0.0;
74 double m_originY = 0.0;
75 double m_scale = 1.0;
76 double m_inverseScale = 1.0;
77};
78
79#endif
std::size_t ParameterCount() const
bool RestorePrefix(const SNAPSHOT &aSnapshot)
double DenormalizeY(double aNormalized) const
double NormalizeY(int aIU) const
bool Restore(const SNAPSHOT &aSnapshot)
void SetCoordinateFrame(const VECTOR2I &aOrigin, double aScale)
double NormalizeX(int aIU) const
std::vector< double > SNAPSHOT
CONSTRAINT_SYSTEM_2D & operator=(const CONSTRAINT_SYSTEM_2D &)=delete
double & Parameter(int aIndex)
std::deque< double > & ParameterStorage()
CONSTRAINT_SYSTEM_2D(const CONSTRAINT_SYSTEM_2D &)=delete
int AddParameter(double aValue)
double DenormalizeX(double aNormalized) const
std::deque< double > m_parameters
std::unique_ptr< GCS::System > m_solver
double * ParameterPointer(int aIndex)
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683