contact_point.cpp
Go to the documentation of this file.
00001 #include "../include/contact_point.h"
00002 #include "../include/debug.h"
00003 
00004 namespace ICR
00005 {
00006 //--------------------------------------------------------------------
00007 //--------------------------------------------------------------------
00008 ContactPoint::ContactPoint() : id_(0){neighbors_.clear();}
00009 //--------------------------------------------------------------------
00010 ContactPoint::ContactPoint(double const vertex[3]) : vertex_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex))),id_(0){neighbors_.clear();}
00011 //--------------------------------------------------------------------
00012 ContactPoint::ContactPoint(Eigen::Vector3d const& vertex) : vertex_(vertex),id_(0) {neighbors_.clear();}
00013 //--------------------------------------------------------------------
00014 ContactPoint::ContactPoint(double const vertex[3],uint id) : vertex_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex))),id_(id){neighbors_.clear();}
00015 //--------------------------------------------------------------------
00016 ContactPoint::ContactPoint(Eigen::Vector3d const& vertex,uint id) : vertex_(vertex),id_(id) {neighbors_.clear();}
00017 //--------------------------------------------------------------------
00018 ContactPoint::ContactPoint(double const vertex[3],double const vertex_normal[3],uint id) : vertex_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex))), vertex_normal_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex_normal))),id_(id)
00019 {
00020   neighbors_.clear();
00021 }
00022 //--------------------------------------------------------------------
00023 ContactPoint::ContactPoint(Eigen::Vector3d const& vertex, Eigen::Vector3d const& vertex_normal,uint id) : vertex_(vertex), vertex_normal_(vertex_normal),id_(id)
00024 {
00025   neighbors_.clear();
00026 }
00027 //--------------------------------------------------------------------
00028 ContactPoint::ContactPoint(double const vertex[3],double const vertex_normal[3], IndexList const& neighbors,uint id) : vertex_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex))), vertex_normal_(Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex_normal))),
00029                                                                                                  neighbors_(neighbors),id_(id) {}
00030 //--------------------------------------------------------------------
00031 ContactPoint::ContactPoint(Eigen::Vector3d const& vertex,Eigen::Vector3d const& vertex_normal, IndexList const& neighbors,uint id) :  vertex_(vertex), vertex_normal_(vertex_normal), neighbors_(neighbors),id_(id) {}
00032 //--------------------------------------------------------------------
00033 ContactPoint::ContactPoint(ContactPoint const& src) : vertex_(src.vertex_), vertex_normal_(src.vertex_normal_),neighbors_(src.neighbors_), id_(src.id_) {}
00034 //--------------------------------------------------------------------
00035 ContactPoint& ContactPoint::operator=(ContactPoint const& src)            
00036 {
00037   if (this !=&src)
00038     {
00039       vertex_=src.vertex_;
00040       vertex_normal_=src.vertex_normal_;
00041       neighbors_=src.neighbors_;
00042       id_=src.id_;
00043     }
00044 
00045   return *this;
00046 }
00047 //--------------------------------------------------------------------
00048 std::ostream& operator<<(std::ostream& stream, ContactPoint const& cp)
00049 {
00050   stream <<'\n'<<"CONTACT POINT: "<<'\n'
00051          <<"Id: "<<cp.id_<<'\n'
00052          <<"Vertex: ";
00053 
00054   for(uint i=0; i < 3; i++)
00055     stream<<cp.vertex_(i)<<" ";
00056 
00057   stream<<'\n'<<"Vertex normal: ";
00058 
00059   for(uint i=0; i < 3; i++)
00060     stream<<cp.vertex_normal_(i)<<" ";
00061 
00062   stream<<'\n'<<"Neighbor ids: ";
00063 
00064   for(ConstIndexListIterator it = cp.neighbors_.begin(); it != cp.neighbors_.end();it++)
00065     stream<< *it<<" ";
00066 
00067   stream<<'\n'<<'\n';
00068 
00069   return stream;
00070 }
00071 //--------------------------------------------------------------------
00072 ContactPoint::~ContactPoint() {}
00073 //--------------------------------------------------------------------
00074 Eigen::Vector3d* ContactPoint::getVertex(){return &vertex_;}
00075 //--------------------------------------------------------------------
00076 Eigen::Vector3d const* ContactPoint::getVertex()const{return &vertex_;}
00077 //--------------------------------------------------------------------
00078 Eigen::Vector3d* ContactPoint::getVertexNormal(){return &vertex_normal_;}
00079 //--------------------------------------------------------------------
00080 Eigen::Vector3d const* ContactPoint::getVertexNormal()const{return &vertex_normal_;}
00081 //--------------------------------------------------------------------
00082 void ContactPoint::setVertex(Eigen::Vector3d const& vertex){vertex_=vertex;}
00083 //--------------------------------------------------------------------
00084 void ContactPoint::setVertex(double const vertex[3]){vertex_=Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex));}
00085 //--------------------------------------------------------------------
00086 void ContactPoint::setVertexNormal(Eigen::Vector3d const& vertex_normal){vertex_normal_=vertex_normal;}
00087 //--------------------------------------------------------------------
00088 void ContactPoint::setVertexNormal(double const vertex_normal[3]){vertex_normal_=Eigen::Map<Eigen::Vector3d >(const_cast<double*>(vertex_normal));}
00089 //--------------------------------------------------------------------
00090 void ContactPoint::addNeighbor(uint neighbor){neighbors_.push_back(neighbor);}
00091 //--------------------------------------------------------------------
00092 ConstIndexListIterator ContactPoint::getNeighborItBegin()const{return neighbors_.begin();}
00093 //--------------------------------------------------------------------
00094 ConstIndexListIterator ContactPoint::getNeighborItEnd()const{return neighbors_.end();}
00095 //--------------------------------------------------------------------
00096 IndexList* ContactPoint::getNeighbors(){return &neighbors_;}
00097 //--------------------------------------------------------------------
00098 IndexList const* ContactPoint::getNeighbors()const{return &neighbors_;}
00099 //--------------------------------------------------------------------
00100 void ContactPoint::filterDuplicateNeighbors()
00101 {
00102   neighbors_.sort();
00103   neighbors_.unique();
00104 }
00105 //--------------------------------------------------------------------
00106 uint ContactPoint::getId()const{return id_;}
00107 //--------------------------------------------------------------------
00108 void ContactPoint::setId(uint id){id_=id;}
00109 //--------------------------------------------------------------------
00110 uint ContactPoint::getNumNeighbors()const{return neighbors_.size();}
00111 //---------------------------------------------------------------------------------
00112 //---------------------------------------------------------------------------------
00113 }//namespace ICR


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:36