mbsim  4.0.0
MBSim Kernel
planar_nurbs_contour.h
1/* Copyright (C) 2004-2018 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: martin.o.foerg@googlemail.com
18 */
19
20#ifndef _PLANAR_NURBS_CONTOUR_H_
21#define _PLANAR_NURBS_CONTOUR_H_
22
23#include "mbsim/contours/rigid_contour.h"
24#include "mbsim/utils/boost_parameters.h"
25#include "mbsim/utils/openmbv_utils.h"
26#include "mbsim/numerics/nurbs/nurbs_curve.h"
27#include <openmbvcppinterface/nurbscurve.h>
28
29namespace MBSim {
30
36 public:
37 enum Interpolation {
38 equallySpaced = 0,
39 chordLength,
40 none,
41 unknown
42 };
43
48 PlanarNurbsContour(const std::string &name="", Frame *R=nullptr) : RigidContour(name,R) { }
49
53 ~PlanarNurbsContour() override = default;
54
55 /* INHERITED INTERFACE OF ELEMENT */
56 /***************************************************/
57
58 /* INHERITED INTERFACE OF CONTOUR */
59 void init(InitStage stage, const InitConfigSet &config) override;
60 fmatvec::Vec3 evalKrPS(const fmatvec::Vec2 &zeta) override;
61 fmatvec::Vec3 evalKs(const fmatvec::Vec2 &zeta) override;
62 fmatvec::Vec3 evalKt(const fmatvec::Vec2 &zeta) override;
63 fmatvec::Vec3 evalKn(const fmatvec::Vec2 &zeta) override;
64 fmatvec::Vec3 evalParDer1Ks(const fmatvec::Vec2 &zeta) override;
65 /***************************************************/
66
67 /* GETTER / SETTER */
68 void setInterpolation(Interpolation interpolation_) { interpolation = interpolation_; }
69 void setControlPoints(const fmatvec::MatVx4 &cp_) { cp <<= cp_; }
70 void setControlPoints(const fmatvec::MatVx3 &cp_);
71 void setControlPoints(const std::vector<fmatvec::Vec4> &cp_);
72 void setControlPoints(const std::vector<fmatvec::Vec3> &cp_);
73 void setNumberOfControlPoints(int n_) { n = n_; }
74 void setKnotVector(const fmatvec::VecV &knot_) { knot <<= knot_; }
75 void setDegree(int degree_) { degree = degree_; }
76 /***************************************************/
77
78 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (nodes,(const std::vector<double>&),std::vector<double>())(diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
79 OpenMBVColoredBody ombv(diffuseColor,transparency,pointSize,lineWidth);
80 openMBVRigidBody=ombv.createOpenMBV<OpenMBV::NurbsCurve>();
81 }
82
83 void initializeUsingXML(xercesc::DOMElement *element) override;
84
85 bool isZetaOutside(const fmatvec::Vec2 &zeta) override { return open and (zeta(0) < etaNodes[0] or zeta(0) > etaNodes[etaNodes.size()-1]); }
86
87 void setOpen(bool open_=true) { open = open_; }
88
89 protected:
90 void updateHessianMatrix(double eta);
91 const fmatvec::MatVx4& evalHessianMatrix(double eta){ if(fabs(eta-etaOld)>1e-13) updateHessianMatrix(eta); return hess; }
92
93 Interpolation interpolation{none};
94 fmatvec::MatVx4 cp;
95 int n{0};
96 fmatvec::VecV knot;
97 int degree{3};
98 bool open{false};
99 NurbsCurve crv;
100 double etaOld{0};
101 fmatvec::MatVx4 hess;
102 };
103
104}
105
106#endif
InitStage
The stages of the initialization.
Definition: element.h:62
std::string name
name of element
Definition: element.h:260
cartesian frame on bodies used for application of e.g. links and loads
Definition: frame.h:39
nurbs curve
Definition: planar_nurbs_contour.h:35
~PlanarNurbsContour() override=default
destructor
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: planar_nurbs_contour.cc:61
PlanarNurbsContour(const std::string &name="", Frame *R=nullptr)
constructor
Definition: planar_nurbs_contour.h:48
basic class for rigid contours
Definition: rigid_contour.h:37
Frame * R
coordinate system of contour
Definition: rigid_contour.h:135
namespace MBSim
Definition: bilateral_constraint.cc:30