MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
PiecewiseConstShape1D Class Reference

#include <shape_impl.h>

Inheritance diagram for PiecewiseConstShape1D:
Collaboration diagram for PiecewiseConstShape1D:

Public Member Functions

 PiecewiseConstShape1D (int n, doublereal *x, doublereal *v)
 
 ~PiecewiseConstShape1D (void)
 
doublereal dGet (doublereal d, doublereal=0.) const
 
std::ostream & Restart (std::ostream &out) const
 
- Public Member Functions inherited from Shape1D
virtual ~Shape1D (void)
 
- Public Member Functions inherited from Shape
virtual ~Shape (void)
 

Protected Attributes

int nPoints
 
doublerealpdX
 
doublerealpdV
 

Detailed Description

Definition at line 45 of file shape_impl.h.

Constructor & Destructor Documentation

PiecewiseConstShape1D::PiecewiseConstShape1D ( int  n,
doublereal x,
doublereal v 
)

Definition at line 105 of file shape.cc.

References ASSERT, nPoints, pdV, and pdX.

107 : nPoints(n), pdX(x), pdV(v)
108 {
109  ASSERT(nPoints > 0);
110  ASSERT(pdX != NULL);
111  ASSERT(pdV != NULL);
112 }
doublereal * pdX
Definition: shape_impl.h:48
#define ASSERT(expression)
Definition: colamd.c:977
doublereal * pdV
Definition: shape_impl.h:49
PiecewiseConstShape1D::~PiecewiseConstShape1D ( void  )

Definition at line 114 of file shape.cc.

References pdV, pdX, and SAFEDELETEARR.

115 {
118 }
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdX
Definition: shape_impl.h:48
doublereal * pdV
Definition: shape_impl.h:49

Member Function Documentation

doublereal PiecewiseConstShape1D::dGet ( doublereal  d,
doublereal  = 0. 
) const
virtual

Implements Shape.

Definition at line 121 of file shape.cc.

References nPoints, pdV, and pdX.

122 {
123  if (d <= pdX[0]) {
124  return pdV[0];
125  }
126 
127  for (int i = 1; i < nPoints; i++) {
128  if (d < pdX[i]) {
129  return pdV[i - 1];
130  }
131  }
132 
133  return pdV[nPoints - 1];
134 }
doublereal * pdX
Definition: shape_impl.h:48
doublereal * pdV
Definition: shape_impl.h:49
std::ostream & PiecewiseConstShape1D::Restart ( std::ostream &  out) const
virtual

Implements Shape.

Definition at line 137 of file shape.cc.

References nPoints, pdV, and pdX.

138 {
139  out << "piecewise const, " << nPoints;
140 
141  for (int i = 0; i < nPoints; i++) {
142  out << ", " << pdX[i] << ", " << pdV[i];
143  }
144 
145  return out;
146 }
doublereal * pdX
Definition: shape_impl.h:48
doublereal * pdV
Definition: shape_impl.h:49

Member Data Documentation

int PiecewiseConstShape1D::nPoints
protected

Definition at line 47 of file shape_impl.h.

Referenced by dGet(), PiecewiseConstShape1D(), and Restart().

doublereal* PiecewiseConstShape1D::pdV
protected

Definition at line 49 of file shape_impl.h.

Referenced by dGet(), PiecewiseConstShape1D(), Restart(), and ~PiecewiseConstShape1D().

doublereal* PiecewiseConstShape1D::pdX
protected

Definition at line 48 of file shape_impl.h.

Referenced by dGet(), PiecewiseConstShape1D(), Restart(), and ~PiecewiseConstShape1D().


The documentation for this class was generated from the following files: