20#ifndef _OPENMBV_UTILS_H_
21#define _OPENMBV_UTILS_H_
23#include <fmatvec/fmatvec.h>
24#include <openmbvcppinterface/objectfactory.h>
28 class DynamicColoredBody;
44 void initializeUsingXML(xercesc::DOMElement *element);
46 void initializeObject(
const std::shared_ptr<OpenMBV::Body> &
object);
54 OpenMBVColoredBody(
const fmatvec::Vec3 &dc_=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp_=0,
double ps_=0,
double lw_=0) : dc(dc_), tp(tp_), ps(ps_), lw(lw_) { }
55 void initializeUsingXML(xercesc::DOMElement *element);
57 std::shared_ptr<T> createOpenMBV() {
58 std::shared_ptr<T>
object = OpenMBV::ObjectFactory::create<T>();
59 initializeObject(
object);
63 void initializeObject(
const std::shared_ptr<OpenMBV::DynamicColoredBody> &
object);
69 double minCol, maxCol;
70 std::vector<std::string> cRL;
72 OpenMBVDynamicColoredBody(
unsigned cR_=0,
double minCol_=0,
double maxCol_=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVColoredBody(dc,tp,ps,lw), cR(cR_), minCol(minCol_), maxCol(maxCol_), cRL(1,
"none") { }
73 void initializeUsingXML(xercesc::DOMElement *element);
74 unsigned int getColorRepresentation()
const {
return cR; }
76 void initializeObject(
const std::shared_ptr<OpenMBV::DynamicColoredBody> &
object);
100 enum ColorRepresentation {
106 OpenMBVArrow::Type type;
107 OpenMBVArrow::Components components;
108 OpenMBVArrow::ReferencePoint refPoint;
109 bool createLocalFrame;
111 OpenMBVArrow(
double sL_=1,
double sS_=1,
const OpenMBVArrow::Type &type_=OpenMBVArrow::toHead,
const OpenMBVArrow::ReferencePoint &refPoint_=OpenMBVArrow::fromPoint,
unsigned int cR=0,
double minCol=0,
double maxCol=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0,
const OpenMBVArrow::Components &components_=OpenMBVArrow::vectorForm,
bool createLocalFrame_=
false);
112 void initializeUsingXML(xercesc::DOMElement *element);
113 std::shared_ptr<OpenMBV::Arrow> createOpenMBV();
114 double getsL()
const {
return sL; }
116 void initializeObject(
const std::shared_ptr<OpenMBV::Arrow> &
object);
121 enum SideOfInteraction {
129 OpenMBVInteractionArrow(
unsigned int sI_=0,
double sL=1,
double sS=1,
const OpenMBVArrow::Type &type=OpenMBVArrow::toHead,
const OpenMBVArrow::ReferencePoint &refPoint=OpenMBVArrow::fromPoint,
unsigned int cR=0,
double minCol=0,
double maxCol=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0,
const OpenMBVArrow::Components &components=OpenMBVArrow::vectorForm,
bool createLocalFrame_=
false);
130 void initializeUsingXML(xercesc::DOMElement *element);
131 unsigned int getSideOfInteraction()
const {
return sI; }
133 void initializeObject(
const std::shared_ptr<OpenMBV::Arrow> &
object);
138 enum ColorRepresentation {
144 OpenMBVFrictionArrow(
unsigned int sI=0,
double sL=1,
double sS=1,
const OpenMBVArrow::Type &type=OpenMBVArrow::toHead,
const OpenMBVArrow::ReferencePoint &refPoint=OpenMBVArrow::fromPoint,
unsigned int cR=0,
double minCol=0,
double maxCol=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0,
const OpenMBVArrow::Components &components=OpenMBVArrow::vectorForm,
bool createLocalFrame_=
false);
151 OpenMBVRigidBody(
bool path_=
false,
const fmatvec::Vec3 &dc_=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp_=0,
double ps_=0,
double lw_=0) :
153 void initializeUsingXML(xercesc::DOMElement *element);
155 void initializeObject(
const std::shared_ptr<OpenMBV::RigidBody> &
object);
162 OpenMBVFrame(
double size_=1,
double offset_=1,
bool path=
false,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVRigidBody(path, dc,tp,ps,lw), size(size_), offset(offset_) { }
163 void initializeUsingXML(xercesc::DOMElement *element);
164 std::shared_ptr<OpenMBV::Frame> createOpenMBV();
166 void initializeObject(
const std::shared_ptr<OpenMBV::Frame> &
object);
173 OpenMBVLine(
double l_=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVColoredBody(dc,tp,ps,lw), l(l_) { }
174 void initializeUsingXML(xercesc::DOMElement *element);
175 std::shared_ptr<OpenMBV::IndexedLineSet> createOpenMBV();
177 void initializeObject(
const std::shared_ptr<OpenMBV::IndexedLineSet> &
object);
184 OpenMBVPlane(
const fmatvec::Vec2 &l_=fmatvec::Vec2(fmatvec::INIT,1.),
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVColoredBody(dc,tp,ps,lw), l(l_) { }
185 void initializeUsingXML(xercesc::DOMElement *element);
186 std::shared_ptr<OpenMBV::Cuboid> createOpenMBV();
188 void initializeObject(
const std::shared_ptr<OpenMBV::Cuboid> &
object);
199 enum ColorRepresentation {
207 double r, cr, sf, n, l;
208 OpenMBVCoilSpring::Type type { tube };
210 OpenMBVCoilSpring(
double r_=1,
double cr_=-1,
double sf_=1,
double n_=3,
double l_=-1, OpenMBVCoilSpring::Type type_=OpenMBVCoilSpring::tube,
unsigned int cR=0,
double minCol=0,
double maxCol=1,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0);
211 void initializeUsingXML(xercesc::DOMElement *element);
212 std::shared_ptr<OpenMBV::CoilSpring> createOpenMBV();
214 void initializeObject(
const std::shared_ptr<OpenMBV::CoilSpring> &
object);
219 std::vector<double> nodes;
222 OpenMBVPlanarContour(
const std::vector<double> &nodes_=std::vector<double>(),
bool filled_=
false,
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVColoredBody(dc,tp,ps,lw), nodes(nodes_), filled(filled_) { }
223 std::shared_ptr<OpenMBV::RigidBody> createOpenMBV();
224 void initializeUsingXML(xercesc::DOMElement *element);
225 const std::vector<double>& getNodes()
const {
return nodes; }
226 bool getFilled()
const {
return filled; }
231 std::vector<double> etaNodes, xiNodes;
233 OpenMBVSpatialContour(
const std::vector<double> &etaNodes_=std::vector<double>(),
const std::vector<double> &xiNodes_=std::vector<double>(),
const fmatvec::Vec3 &dc=fmatvec::Vec3(std::vector<double>{-1,1,1}),
double tp=0,
double ps=0,
double lw=0) :
OpenMBVColoredBody(dc,tp,ps,lw), etaNodes(etaNodes_), xiNodes(xiNodes_) { }
234 std::shared_ptr<OpenMBV::RigidBody> createOpenMBV();
235 void initializeUsingXML(xercesc::DOMElement *element);
236 const std::vector<double>& getEtaNodes()
const {
return etaNodes; }
237 const std::vector<double>& getXiNodes()
const {
return xiNodes; }
Definition: openmbv_utils.h:79
Definition: openmbv_utils.h:39
Definition: openmbv_utils.h:191
Definition: openmbv_utils.h:49
Definition: openmbv_utils.h:66
Definition: openmbv_utils.h:158
Definition: openmbv_utils.h:136
Definition: openmbv_utils.h:119
Definition: openmbv_utils.h:169
Definition: openmbv_utils.h:217
Definition: openmbv_utils.h:180
Definition: openmbv_utils.h:147
Definition: openmbv_utils.h:229
namespace MBSim
Definition: bilateral_constraint.cc:30