mbsimflexiblebody  3.0.0
nurbs_curve_1s.h
1 /* Copyright (C) 2004-2012 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: thorsten.schindler@mytum.de
18  */
19 
20 #ifndef NURBSCURVE1S_H_
21 #define NURBSCURVE1S_H_
22 
23 #include "fmatvec.h"
24 #include "mbsim/mbsim_event.h"
25 #include "mbsim/contours/contour1s.h"
26 
27 #ifdef HAVE_NURBS
28 #define MY_PACKAGE_BUGREPORT PACKAGE_BUGREPORT
29 #define MY_PACKAGE_NAME PACKAGE_NAME
30 #define MY_PACKAGE_VERSION PACKAGE_VERSION
31 #define MY_PACKAGE_TARNAME PACKAGE_TARNAME
32 #define MY_PACKAGE_STRING PACKAGE_STRING
33 #undef PACKAGE_BUGREPORT
34 #undef PACKAGE_NAME
35 #undef PACKAGE_VERSION
36 #undef PACKAGE_TARNAME
37 #undef PACKAGE_STRING
38 #include "nurbs.h"
39 #undef PACKAGE_BUGREPORT
40 #undef PACKAGE_NAME
41 #undef PACKAGE_VERSION
42 #undef PACKAGE_TARNAME
43 #undef PACKAGE_STRING
44 #include "nurbsS.h"
45 #undef PACKAGE_BUGREPORT
46 #undef PACKAGE_NAME
47 #undef PACKAGE_VERSION
48 #undef PACKAGE_TARNAME
49 #undef PACKAGE_STRING
50 #include "vector.h"
51 #define PACKAGE_BUGREPORT MY_PACKAGE_BUGREPORT
52 #define PACKAGE_NAME MY_PACKAGE_NAME
53 #define PACKAGE_VERSION MY_PACKAGE_VERSION
54 #define PACKAGE_TARNAME MY_PACKAGE_TARNAME
55 #define PACKAGE_STRING MY_PACKAGE_STRING
56 #endif
57 
58 namespace MBSimFlexibleBody {
59 
66  class NurbsCurve1s : public MBSim::Contour1s {
67  public:
72  NurbsCurve1s(const std::string &name);
73 
77  virtual ~NurbsCurve1s();
78 
79  /* INHERITED INTERFACE OF ELEMENT */
80  virtual std::string getType() const { return "NurbsCurve1s"; }
81  /***************************************************/
82 
83  /* INHERITED INTERFACE OF CONTOURCONTINUUM */
84  virtual void computeRootFunctionPosition(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsCurve1s::computeRootFunctionPosition): Not implemented!"); }
85  virtual void computeRootFunctionFirstTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsCurve1s::computeRootFunctionFirstTangent): Not implemented!"); }
86  virtual void computeRootFunctionNormal(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsCurve1s::computeRootFunctionNormal): Not implemented!"); }
87  virtual void computeRootFunctionSecondTangent(MBSim::ContourPointData &cp) { throw MBSim::MBSimError("ERROR(NurbsCurve1s::computeRootFunctionSecondTangent): Not implemented!"); }
88  /***************************************************/
89 
90  /* INHERITED INTERFACE OF CONTOUR */
91  virtual void updateKinematicsForFrame(MBSim::ContourPointData &cp, MBSim::FrameFeature ff);
92  virtual void updateJacobiansForFrame(MBSim::ContourPointData &cp, int j=0);
93  virtual MBSim::ContactKinematics *findContactPairingWith(std::string type0, std::string type1) { throw MBSim::MBSimError("ERROR(NurbsCurve1s::findContactPairingWith): Not implemented!"); }
94  /***************************************************/
95 
96  /* GETTER / SETTER */
97 #ifdef HAVE_NURBS
98  void setNormalRotationGrid(fmatvec::Vec normal_) { normalRotationGrid.x() = normal_(0), normalRotationGrid.y() = normal_(1),normalRotationGrid.z() = normal_(2); }
99 #endif
100  /***************************************************/
101 
102 #ifdef HAVE_NURBS
103 
107  void initContourFromBody(MBSim::InitStage stage);
108 #endif
109 
110 
111 #ifdef HAVE_NURBS
112 
116  void computeUVector(const int NbPts);
117 #endif
118 
119 #ifdef HAVE_NURBS
120 
123  void computeCurveTranslations();
124 #endif
125 
126 #ifdef HAVE_NURBS
127 
130  void computeCurveVelocities();
131 #endif
132 
133 #ifdef HAVE_NURBS
134 
137  void computeCurveAngularVelocities();
138 #endif
139 
140 #ifdef HAVE_NURBS
141 
144  void computeCurveJacobians();
145 #endif
146 
147  protected:
151  int Elements;
152 
156  int qSize;
157 
162 
166  double L;
167 
171  int degU;
172 
173 #ifdef HAVE_NURBS
174 
177  PlNurbsCurved *curveTranslations;
178 
182  PlNurbsCurved *curveVelocities;
183 
187  PlNurbsCurved *curveAngularVelocities;
188 
192  PLib::Point3Dd normalRotationGrid;
193 
197  std::vector<MBSim::ContourPointData> jacobiansTrans; // size = number of interpolation points
198 
202  std::vector<MBSim::ContourPointData> jacobiansRot; // size = number of interpolation points
203 
207  std::vector<PlNurbsCurved> CurveJacobiansOfTranslation; // size = number of generalized coordinates
208 
212  std::vector<PlNurbsCurved> CurveJacobiansOfRotation; // size = number of generalized coordinates
213 
217  PLib::Vector<double> *uvec; // nurbs++ needs this vector
218  PLib::Vector<double> *uVec; // knot-vector
219 #endif
220  };
221 
222 }
223 
224 #endif /* NURBSCURVE1S_H_ */
225