-
Notifications
You must be signed in to change notification settings - Fork 2
/
magcollection.h
88 lines (68 loc) · 2.15 KB
/
magcollection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// @(#)magcollection.h 1.1 misha-11may103
//
// Copyright (c) 2003 of Geometrics.
// All rights reserved.
//
// Created: 11may103 by [email protected]
// Version: 11may103 by [email protected]
//
#ifndef MAGCOLLECTION_H
#define MAGCOLLECTION_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <vector>
#include <algorithm>
#include "magobject.h"
using namespace std;
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) (((x) < (y)) ? (y) : (x))
#endif
class CMagCollection {
protected:
int m_iTotalLinearParameters;
int m_iTotalNonLinearParameters;
vector<int> m_vCurrentLinearParams;
vector<int> m_vCurrentNonLinearParams;
vector<CMagObject *> m_vObjects;
vector<int>::iterator m_itLinear;
vector<int>::iterator m_itNonLinear;
vector<CMagObject *>::iterator m_itCurrentObject;
void destroy();
public:
CMagCollection();
~CMagCollection();
int AddMagObject(CMagObject * o);
int ResetPosition();
CMagObject * GetCurrentMagObject(int *nolin_start, int *lin_start);
CMagObject * GetObjectAt(int n);
CMagObject * GetObjectAt(char *name);
int ReplaceObject(CMagObject *p_old, CMagObject *p_new);
int GetTotalLinearParams();
int GetTotalNonLinearParams();
int GetTotalObjects() { return m_vObjects.size(); }
void DumpObjects(FILE * dat);
int GetSetVariables(int is_set, double * vars, int size,
int type, int linear_only, int is_errors);
int ReScanAllObjects(int *total_linear, int * total_non_linear);
// 0 - can do nothing
// 1 - can compute field
// 2 - can compute second derivatives
int GetAbilities(int *linear_ab, int *non_linear_ab);
// min-max
void InitMinMaxForObjects();
void UpdateMinMaxForObjects();
void DumpMinMaxForObjects(FILE * dat);
int RemoveObject(CMagObject * pObject);
virtual void DumpToStream(std::ostream & str, std::string comment="#",
char * close_str="/",char * delimit=",",
std::string offset = " ");
virtual void DumpToXMLStream(std::ostream & str);
};
#endif