mbsim  4.0.0
MBSim Kernel
spatial_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 _SPATIAL_NURBS_CONTOUR_H_
21#define _SPATIAL_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_surface.h"
27#include <openmbvcppinterface/nurbssurface.h>
28
29namespace MBSim {
30
36 public:
37 enum Interpolation {
38 equallySpaced = 0,
39 chordLength,
40 none,
41 unknown
42 };
43
48 SpatialNurbsContour(const std::string &name="", Frame *R=nullptr) : RigidContour(name,R) { }
49
53 ~SpatialNurbsContour() 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 evalParDer1Ks(const fmatvec::Vec2 &zeta) override;
64 fmatvec::Vec3 evalParDer2Ks(const fmatvec::Vec2 &zeta) override;
65 fmatvec::Vec3 evalParDer1Kt(const fmatvec::Vec2 &zeta) override;
66 fmatvec::Vec3 evalParDer2Kt(const fmatvec::Vec2 &zeta) override;
67 /***************************************************/
68
69 /* GETTER / SETTER */
70 void setInterpolation(Interpolation interpolation_) { interpolation = interpolation_; }
71 void setControlPoints(const fmatvec::MatVx4 &cp_) { cp <<= cp_; }
72 void setControlPoints(const fmatvec::MatVx3 &cp_);
73 void setControlPoints(const std::vector<std::vector<fmatvec::Vec4>> &cp_);
74 void setControlPoints(const std::vector<std::vector<fmatvec::Vec3>> &cp_);
75 void setNumberOfEtaControlPoints(int nu_) { nu = nu_; }
76 void setNumberOfXiControlPoints(int nv_) { nv = nv_; }
77 void setEtaKnotVector(const fmatvec::VecV &uKnot_) { uKnot <<= uKnot_; }
78 void setXiKnotVector(const fmatvec::VecV &vKnot_) { vKnot <<= vKnot_; }
79 void setEtaDegree(int etaDegree_) { etaDegree = etaDegree_; }
80 void setXiDegree(int xiDegree_) { xiDegree = xiDegree_; }
81 /***************************************************/
82
83 BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (diffuseColor,(const fmatvec::Vec3&),fmatvec::Vec3(std::vector<double>{-1,1,1}))(transparency,(double),0)(pointSize,(double),0)(lineWidth,(double),0))) {
84 OpenMBVColoredBody ombv(diffuseColor,transparency,pointSize,lineWidth);
85 openMBVRigidBody=ombv.createOpenMBV<OpenMBV::NurbsSurface>();
86 }
87
88 void initializeUsingXML(xercesc::DOMElement *element) override;
89
90 bool isZetaOutside(const fmatvec::Vec2 &zeta) override;
91
92 void setOpenEta(bool openEta_) { openEta = openEta_; }
93 void setOpenXi(bool openXi_) { openXi = openXi_; }
94
95 protected:
96 void updateHessianMatrix(const fmatvec::Vec2 &zeta);
97 const fmatvec::GeneralMatrix<fmatvec::Vec4>& evalHessianMatrix(const fmatvec::Vec2 &zeta){ if(fabs(zeta(0)-zetaOld(0))>1e-13 or fabs(zeta(1)-zetaOld(1))>1e-13) updateHessianMatrix(zeta); return hess; }
98
99 Interpolation interpolation{none};
100 fmatvec::MatVx4 cp;
101 int nu{0};
102 int nv{0};
103 fmatvec::VecV uKnot, vKnot;
104 int etaDegree{3};
105 int xiDegree{3};
106 bool openEta{false};
107 bool openXi{false};
108 NurbsSurface srf;
109 fmatvec::Vec2 zetaOld;
110 fmatvec::GeneralMatrix<fmatvec::Vec4> hess;
111 };
112
113}
114
115#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
basic class for rigid contours
Definition: rigid_contour.h:37
Frame * R
coordinate system of contour
Definition: rigid_contour.h:135
nurbs surface
Definition: spatial_nurbs_contour.h:35
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: spatial_nurbs_contour.cc:83
~SpatialNurbsContour() override=default
destructor
SpatialNurbsContour(const std::string &name="", Frame *R=nullptr)
constructor
Definition: spatial_nurbs_contour.h:48
namespace MBSim
Definition: bilateral_constraint.cc:30