GUIDOLib  1.7.7
Guido Engine Internal Documentation
GRSpaceForceFunction.h
1 /*
2  GUIDO Library
3  Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
4  Copyright (C) 2002-2017 Grame
5 
6  This Source Code Form is subject to the terms of the Mozilla Public
7  License, v. 2.0. If a copy of the MPL was not distributed with this
8  file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
11  research@grame.fr
12 
13 */
14 
15 #ifndef __GRSPF_H
16 #define __GRSPF_H
17 
18 #ifdef OLDSPFACTIVE
19 
65 // for the hash-table.
66 #include "KR_Hash.h"
67 #include "KF_IList.h"
68 #include "GRSpring.h"
69 
70 
71 // already defined in GRSpringForceIndex.h
72 // const float optimumforce = 600;
73 
75 class GRConstraint;
76 
78  ConstraintList;
79 
80 class ofstream;
81 
82 class GRConstraint
83 {
84 public:
85  int start;
86  int end;
87  double value;
88  GRConstraint(int pstart,int pend,double pvalue)
89  {
90  start = pstart;
91  end = pend;
92  value = pvalue;
93  }
94  GRConstraint(const GRConstraint &ct)
95  {
96  start = ct.start;
97  end = ct.end;
98  value = ct.value;
99  }
100  int operator==(const GRConstraint &ct)
101  {
102  if (start == ct.start
103  && end == ct.end
104  && value == ct.value)
105  return 1;
106  return 0;
107  }
108 };
109 
114 class GRSpaceForceFunction
115 {
116 public:
117 
118  class GRHashEntry
119  {
120 
121  friend class GRSpaceForceFunction;
122  float extent;
123  SpringList *sprlst;
124 
125  public:
126  GRHashEntry()
127  {
128  sprlst = new SpringList(0);
129  }
130  virtual ~GRHashEntry()
131  {
132  delete sprlst;
133  }
134 
135  GRHashEntry & operator=(const GRHashEntry &he)
136  {
137  delete sprlst;
138  extent = he.extent;
139  sprlst = new SpringList(*he.sprlst,0);
140 
141  return *this;
142  }
143 
144 
145  // the copy-constructor
146  GRHashEntry(const GRHashEntry &he)
147 
148  {
149  extent = he.extent;
150  sprlst = new SpringList(*he.sprlst,0);
151  }
152  };
153 
154 public:
155  GRSpring *getGRSpring(int id);
156  int addConstraint(int start,int end,double value);
157  int getMatrixRealSize();
158  int getMatrixMemSize();
159  double * getMatrix();
160  double * resizeMatrix(int newrealsize);
161 
162  int getMSCMatrixRealSize();
163  int getMSCMatrixMemSize();
164  double * getMSCMatrix();
165 
166  double getMSCMatrix(int i,int j) const;
167  void setMSCMatrix(int i,int j,double value);
168 
169  double * resizeMSCMatrix(int newrealsize);
170 
171  float zconstdenom;
172  GRSpaceForceFunction(const GRSpaceForceFunction &spf);
173  float EvaluateBreak(float extent);
174  float getOptimumForce(float sprconst);
175  void UnfreezeSpring(GRSpring *spr);
176  void FreezeSpring(GRSpring *spr);
177  void ResetSprings();
178  void CopySPFWithoutSprings(const GRSpaceForceFunction &spf);
179  void addSPF(const GRSpaceForceFunction &spf);
180 
181  GRSpaceForceFunction();
182  virtual ~GRSpaceForceFunction();
183 
184  void addSpring(GRSpring *spr);
185  void deleteSpring(GRSpring *spr);
186  void changeSpringForce(GRSpring *spr,float newforce);
187  float getExtent(float force) const;
188  float getForce(float extent,
189  ofstream *springlog = NULL);
190 
191 private:
192 
194 
195 
196 
197 protected:
198  float forceret;
199  float forceextent;
200  float evalextent;
201  float evalret;
202  float zconstnum;
203  // the freezeoffset is a number
204  // that must be used to calculate
205  // the extent/force, when
206  // some springs in the Space-Force-Function
207  // are frozen.
208  // it offsets the base-coordinate-point
209  // by the amount of the spring-extent.
210  float freezeoffset;
211 
212  int matmemsize;
213  int matrealsize;
214  double *mat;
215 
216  int mscmatmemsize;
217  int mscmatrealsize;
218  double *mscmat;
219 
220 
221  // this is for QP-Programming (solving the
222  // spring-equation as energy-minimizing)
223  ConstraintList cl;
224 
225 };
226 
227 #endif // ifdef OLDSPFACTIVE
228 
229 #endif
230 
operator==
bool operator==(const TimeSegment &ts) const
GRSpring
Used with rods and space fore functions.
Definition: GRSpring.h:38
KF_IPointerList
Definition: ARMusicalVoiceState.h:33
KR_HashTable
Definition: kr_hash.h:22

Guido Project Copyright © 2019 Grame-CNCM