<commit_before>#include "Element.h"

#include <iostream>

using namespace Eigen;
using namespace std;

namespace DrakeCollision {
Element::Element(const Isometry3d& T_element_to_local,
                 const RigidBody* const body)
    : DrakeShapes::Element(T_element_to_local), body_(body) {
  id = (ElementId) this;
}

Element::Element(const DrakeShapes::Geometry& geometry,
                 const Isometry3d& T_element_to_local,
                 const RigidBody* const body)
    : DrakeShapes::Element(geometry, T_element_to_local), body_(body) {
  id = (ElementId) this;
}

Element::Element(const Element& other)
    : DrakeShapes::Element(other), id((ElementId) this), body_(other.body_) {}

Element* Element::clone() const { return new Element(*this); }

ElementId Element::getId() const { return id; }

const RigidBody& Element::getBody() const { return *body_; }

bool Element::CollidesWith(const Element* other) const {
  // Do not collide with self
  if(this == other) return false;

  // If collision_groups_.size() = N and other->collision_groups_.size() = M
  // The worst case (no intersection) is O(N+M).
  return !have_intersection(collision_groups_.begin(), collision_groups_.end(),
                            other->collision_groups_.begin(),
                            other->collision_groups_.end());
}

// Order(N) insertion.
// Member CollisionElement::collision_groups_ is sorted so that checking if two
// collision elements belong to a same group can be performed in order N.
// See CollisionElement::CollidesWith
void Element::add_to_collision_group(int group_id) {
  auto it = std::lower_bound(collision_groups_.begin(), collision_groups_.end(), group_id);
  if (it == collision_groups_.end() || group_id < *it)
    collision_groups_.insert(it, group_id);
}

ostream& operator<<(ostream& out, const Element& ee) {
  out << "DrakeCollision::Element:\n"
      << "  - id = " << ee.id << "\n"
      << "  - T_element_to_world =\n" << ee.T_element_to_world.matrix() << "\n"
      << "  - T_element_to_local =\n" << ee.T_element_to_local.matrix() << "\n"
      << "  - geometry = " << *ee.geometry << std::endl;
  return out;
}

}  // namespace DrakeCollision
<commit_msg>Updated Element copy constructor to copy collision_elements_<commit_after>#include "Element.h"

#include <iostream>

using namespace Eigen;
using namespace std;

namespace DrakeCollision {
Element::Element(const Isometry3d& T_element_to_local,
                 const RigidBody* const body)
    : DrakeShapes::Element(T_element_to_local), body_(body) {
  id = (ElementId) this;
}

Element::Element(const DrakeShapes::Geometry& geometry,
                 const Isometry3d& T_element_to_local,
                 const RigidBody* const body)
    : DrakeShapes::Element(geometry, T_element_to_local), body_(body) {
  id = (ElementId) this;
}

Element::Element(const Element& other)
    : DrakeShapes::Element(other), id((ElementId) this), body_(other.body_),
      collision_groups_(other.collision_groups_) {}

Element* Element::clone() const { return new Element(*this); }

ElementId Element::getId() const { return id; }

const RigidBody& Element::getBody() const { return *body_; }

bool Element::CollidesWith(const Element* other) const {
  // Do not collide with self
  if(this == other) return false;

  // If collision_groups_.size() = N and other->collision_groups_.size() = M
  // The worst case (no intersection) is O(N+M).
  return !have_intersection(collision_groups_.begin(), collision_groups_.end(),
                            other->collision_groups_.begin(),
                            other->collision_groups_.end());
}

// Order(N) insertion.
// Member CollisionElement::collision_groups_ is sorted so that checking if two
// collision elements belong to a same group can be performed in order N.
// See CollisionElement::CollidesWith
void Element::add_to_collision_group(int group_id) {
  auto it = std::lower_bound(collision_groups_.begin(), collision_groups_.end(), group_id);
  if (it == collision_groups_.end() || group_id < *it)
    collision_groups_.insert(it, group_id);
}

ostream& operator<<(ostream& out, const Element& ee) {
  out << "DrakeCollision::Element:\n"
      << "  - id = " << ee.id << "\n"
      << "  - T_element_to_world =\n" << ee.T_element_to_world.matrix() << "\n"
      << "  - T_element_to_local =\n" << ee.T_element_to_local.matrix() << "\n"
      << "  - geometry = " << *ee.geometry << std::endl;
  return out;
}

}  // namespace DrakeCollision

{'fraction_non_alphanumeric': 0.1363332590777456, 'fraction_numerical': 0.0008910670527957229, 'mean_word_length': 3.7613997879109227, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4615123', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1394, 'n_words': 333}