Exemplo n.º 1
0
        Element( const id_type id )
            : i_( id & 0x00000000ffffffff )
            , c_( ( id & 0xffffffff00000000 ) >> 32 )
        {}
        Element( int i, int c ) : i_( i ), c_( c ) {}
        Element( const Element& x ) : i_( x.i_ ), c_( x.c_ ) {}
        Element( const Element& x, int c ) : i_( x.i_ ), c_( c ) {}
        ~Element() {}

        id_type operator()() const
        {
            return ( static_cast< id_type >( c_ ) << 32 ) | ( static_cast< id_type >( i_ ) );
        }
        int color() const {
            return c_;
        }

        bool operator<( const Element& x ) const
        {
            if ( c_ == x.c_ ) return i_ < x.i_;
            return c_ < x.c_;
        }
        bool operator==( const Element& x ) const {
            return i_ == x.i_ && c_ == x.c_;
        }
    };
Exemplo n.º 2
0
core::MonteCarloMoverResult TransformMover::do_propose() {
  IMP_OBJECT_LOG;

  
  xyzs_.resize(pixyzs_.size());
  rbts_.resize(pirbs_.size());  
  
  //xyzc=bb....;
  
  //get_rotation_about_point(const Vector3D &point,
  //                                               const Rotation3D &rotation)
  
  algebra::Vector3D xyzc=get_center(); //check the correct type from algebra::get_unit_sphere_d<3>()
  algebra::Transformation3D c_(xyzc);
  
  algebra::Vector3D translation = algebra::get_random_vector_in(
      algebra::Sphere3D(algebra::get_zero_vector_d<3>(), max_translation_));
  if (constr_==0){
  axis_=algebra::get_random_vector_on(algebra::get_unit_sphere_d<3>());}
  ::boost::uniform_real<> rand(-max_angle_, max_angle_);
  Float angle = rand(random_number_generator);
  algebra::Rotation3D r = algebra::get_rotation_about_axis(axis_, angle);
  algebra::Transformation3D t_(r, translation); 
  
  algebra::Transformation3D tt = c_*t_*c_.get_inverse();

  
  for (unsigned int i=0;i<pixyzs_.size();i++) {
       core::XYZ d(get_model(), pixyzs_[i]);
       xyzs_[i]=d.get_coordinates();
       core::transform(d,tt);
  }

  for (unsigned int i=0;i<pirbs_.size();i++){
      core::RigidBody d(get_model(), pirbs_[i]);
       rbts_[i]=d.get_reference_frame().get_transformation_to();
       core::transform(d,tt);
  }

  //for (unsigned int i=0;i<pirbs_.size();i++){
  //       RigidBody d(get_model(), pirbs_[i]);
  //       last_transformation_[i] = d.get_reference_frame().get_transformation_to();
  //    algebra::Rotation3D rc =
  //    r * d.get_reference_frame().get_transformation_to().get_rotation();
  //    algebra::Transformation3D t(rc, translation);  
         
  //IMP_LOG_VERBOSE("proposed move " << t_ << std::endl);
  //IMP_USAGE_CHECK(
  //    d.get_coordinates_are_optimized(),
  //    "Rigid body passed to TransformMover"
  //        << " must be set to be optimized. particle: " << d->get_name());
  //d.set_reference_frame(algebra::ReferenceFrame3D(t));

  return core::MonteCarloMoverResult(pis_, 1.0);
}
Exemplo n.º 3
0
int main()
//try
{
	const std::string x_socket_path = "/tmp/.X11-unix/X0";

	asio::io_service io_service;

	asio::local::stream_protocol::socket s( io_service );

	boost::system::error_code error;
	s.connect( asio::local::stream_protocol::endpoint( x_socket_path ), error );
	if( error )
	{
		std::cerr << error.message() << "\n";
		return error.value();
	}

	xcppb::connection
	<
		asio::local::stream_protocol::socket
	> c( s );

	std::cerr << c;

	xcppb::atom a( "NAME497" );
	xcppb::atom b( "NAME498" );
	xcppb::atom c_( "NAME499" );
	xcppb::cookie< xcppb::atom > cookie1( c.request( a ) );
	xcppb::cookie< xcppb::atom > cookie2( c.request( b ) );
	xcppb::cookie< xcppb::atom > cookie3( c.request( c_ ) );

	c.reply( cookie2 );
	c.reply( cookie1 );
	c.reply( cookie3 );

	std::cout << "\n";
	std::cout << "atom: " << a.id() << "\n";
	std::cout << "atom: " << b.id() << "\n";
	std::cout << "atom: " << c_.id() << "\n";
	
	return 0;
}
Exemplo n.º 4
0
void Mesher::remove_dupes()
{
    std::map<std::array<float, 3>, size_t> verts;
    std::set<std::array<size_t, 3>> tris;
    size_t vertex_id = 0;

    for (auto itr=triangles.begin(); itr != triangles.end(); ++itr)
    {
        std::array<size_t, 3> t;
        int i=0;
        // For each vertex, find whether it's already in our vertex
        // set.  Create an array t with vertex indicies.
        for (auto v : {itr->a_(), itr->b_(), itr->c_()})
        {
            auto k = verts.find(v);
            if (k != verts.end())
            {
                t[i++] = k->second;
            }
            else
            {
                verts[v] = vertex_id;
                t[i++] = vertex_id;
                vertex_id++;
            }
        }

        // Check to see if there are any other triangles that use these
        // three vertices; if so, delete this triangle.
        std::sort(t.begin(), t.end());
        if (tris.count(t))
        {
            itr = triangles.erase(itr);
            itr--;
        }
        else
        {
            tris.insert(t);
        }
    }
}
Exemplo n.º 5
0
 bool operator()( const Actual& actual ) const
 {
     return ! c_( actual );
 }
Exemplo n.º 6
0
 void visit( leaf & l)
 { c_( l); }
Exemplo n.º 7
0
std::list<Vec3f> Mesher::get_contour()
{
    // Find all of the singular edges in this fan
    // (edges that aren't shared between multiple triangles).
    std::set<std::array<float, 6>> valid_edges;
    for (auto itr=voxel_start; itr != voxel_end; ++itr)
    {
        if (valid_edges.count(itr->ba_()))
            valid_edges.erase(itr->ba_());
        else
            valid_edges.insert(itr->ab_());

        if (valid_edges.count(itr->cb_()))
            valid_edges.erase(itr->cb_());
        else
            valid_edges.insert(itr->bc_());

        if (valid_edges.count(itr->ac_()))
            valid_edges.erase(itr->ac_());
        else
            valid_edges.insert(itr->ca_());
    }

    std::set<std::array<float, 3>> in_fan;

    std::list<Vec3f> contour = {voxel_start->a};
    in_fan.insert(voxel_start->a_());
    in_fan.insert(voxel_start->b_());
    in_fan.insert(voxel_start->c_());

    fan_start = voxel_start;
    voxel_start++;

    while (contour.size() == 1 || contour.front() != contour.back())
    {
        std::list<Triangle>::iterator itr;
        for (itr=fan_start; itr != voxel_end; ++itr)
        {
            const auto& t = *itr;
            if (contour.back() == t.a && valid_edges.count(t.ab_()))
            {
                contour.push_back(t.b);
                break;
            }

            if (contour.back() == t.b && valid_edges.count(t.bc_()))
            {
                contour.push_back(t.c);
                break;
            }

            if (contour.back() == t.c && valid_edges.count(t.ca_()))
            {
                contour.push_back(t.a);
                break;
            }
        }
        // If we broke out of the loop (meaning itr is pointing to a relevant
        // triangle which should be moved forward to before voxel_start), then
        // push the list around and update iterators appropriately.
        if (itr != voxel_end)
        {
            in_fan.insert(itr->a_());
            in_fan.insert(itr->b_());
            in_fan.insert(itr->c_());

            if (itr == voxel_start)
            {
                voxel_start++;
            }
            else if (itr != fan_start)
            {
                const Triangle t = *itr;
                triangles.insert(voxel_start, t);
                itr = triangles.erase(itr);
                itr--;
            }
        }
    }

    // Special case to catch triangles that are part of a particular fan but
    // don't have any edges in the contour (which can happen!).
    for (auto itr=voxel_start;  itr != voxel_end; ++itr)
    {
        if (in_fan.count(itr->a_()) &&
            in_fan.count(itr->b_()) &&
            in_fan.count(itr->c_()))
        {
            if (itr == voxel_start)
            {
                voxel_start++;
            }
            else if (itr != fan_start)
            {
                const Triangle t = *itr;
                triangles.insert(voxel_start, t);
                itr = triangles.erase(itr);
                itr--;
            }
        }
    }

    // Remove the last point of the contour, since it's a closed loop.
    contour.pop_back();
    return contour;
}
Exemplo n.º 8
0
 void check( bool f ) { checked_ = f ; c_( f ) ; }
Exemplo n.º 9
0
 virtual bool operator()( Actual actual )
 {
     return c_( actual );
 }