MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
resforces.cc File Reference
#include "mbconfig.h"
#include "resforces.h"
#include "dataman.h"
Include dependency graph for resforces.cc:

Go to the source code of this file.

Functions

ResForceSetReadResSet (DataManager *pDM, MBDynParser &HP, unsigned int uL)
 
ResForceSet ** ReadResSets (DataManager *pDM, MBDynParser &HP)
 

Function Documentation

ResForceSet* ReadResSet ( DataManager pDM,
MBDynParser HP,
unsigned int  uL 
)

Definition at line 209 of file resforces.cc.

References HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::IsKeyWord(), ResForceSet::labelSet, MBDYN_EXCEPT_ARGS, DataManager::ReadNode(), SAFEDELETE, SAFENEW, SAFENEWWITHCONSTRUCTOR, and Node::STRUCTURAL.

Referenced by ReadResSets().

210 {
211  ResForceSet *pset = NULL;
212  ResForces *pres = NULL;
213 
214  if (HP.IsKeyWord("external")) {
215  SAFENEW(pres, ExternResForces);
216 
217  } else if (HP.IsKeyWord("node")) {
218  const StructNode *pNode = pDM->ReadNode<const StructNode, Node::STRUCTURAL>(HP);
219 
220  if (HP.IsKeyWord("local")) {
222  LocalNodeResForces(pNode));
223 
224  } else {
226  NodeResForces(pNode));
227  }
228 
229  } else {
230  silent_cerr("unknown force set type at line "
231  << HP.GetLineData() << std::endl);
233  }
234 
235  unsigned int nItems = HP.GetInt();
236  if (nItems < 1) {
237  silent_cerr("illegal number of items " << nItems
238  << " in set at line " << HP.GetLineData() << std::endl);
239  SAFEDELETE(pres);
241  }
242 
244 
245  for (unsigned int i = 0; i < nItems; i++) {
246  unsigned int uLabel = HP.GetInt();
247  std::pair<std::set<unsigned int>::iterator, bool> rc =
248  pset->labelSet.insert(uLabel);
249 
250  if (!rc.second) {
251  silent_cerr("unable to insert item " << uLabel
252  << " in set at line " << HP.GetLineData()
253  << std::endl);
254  SAFEDELETE(pset);
256  }
257  }
258 
259  return pset;
260 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
std::set< unsigned int > labelSet
Definition: resforces.h:107
#define SAFENEW(pnt, item)
Definition: mynewmem.h:695
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710

Here is the call graph for this function:

ResForceSet** ReadResSets ( DataManager pDM,
MBDynParser HP 
)

Definition at line 263 of file resforces.cc.

References HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, ReadResSet(), SAFEDELETE, SAFEDELETEARR, and SAFENEWARR.

Referenced by CyclocopterNoInflow::CyclocopterNoInflow(), CyclocopterPolimi::CyclocopterPolimi(), CyclocopterUniform1D::CyclocopterUniform1D(), CyclocopterUniform2D::CyclocopterUniform2D(), and ReadRotor().

264 {
265  ResForceSet **ppres = NULL;
266 
267  if (HP.IsKeyWord("set")) {
268  int nSets = HP.GetInt();
269 
270  if (nSets < 1) {
271  silent_cerr("Illegal number of sets (" << nSets
272  << ") at line " << HP.GetLineData()
273  << std::endl);
275  }
276 
277  SAFENEWARR(ppres, ResForceSet*, nSets+1);
278  for (unsigned int i = 0; i <= (unsigned int)nSets; i++) {
279  ppres[i] = NULL;
280  }
281 
282  try {
283  for (unsigned int i = 0; i < (unsigned int)nSets; i++) {
284  ppres[i] = ReadResSet(pDM, HP, i+1);
285  }
286 
287  } catch (...) {
288  for (unsigned int i = 0; ppres[i]; i++) {
289  SAFEDELETE(ppres[i]);
290  }
291  SAFEDELETEARR(ppres);
292  }
293  }
294 
295  return ppres;
296 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
ResForceSet * ReadResSet(DataManager *pDM, MBDynParser &HP, unsigned int uL)
Definition: resforces.cc:209
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710

Here is the call graph for this function: