Exemplo n.º 1
0
    std::unique_ptr<ImageIO::Base> MRtrix::create (Header& H) const
    {
      File::OFStream out (H.name(), std::ios::out | std::ios::binary);

      out << "mrtrix image\n";

      write_mrtrix_header (H, out);

      bool single_file = Path::has_suffix (H.name(), ".mif");

      int64_t offset = 0;
      out << "file: ";
      if (single_file) {
        offset = out.tellp() + int64_t(18);
        offset += ((4 - (offset % 4)) % 4);
        out << ". " << offset << "\nEND\n";
      }
      else out << Path::basename (H.name().substr (0, H.name().size()-4) + ".dat") << "\n";

      out.close();

      std::unique_ptr<ImageIO::Base> io_handler (new ImageIO::Default (H));
      if (single_file) {
        File::resize (H.name(), offset + footprint(H));
        io_handler->files.push_back (File::Entry (H.name(), offset));
      }
      else {
        std::string data_file (H.name().substr (0, H.name().size()-4) + ".dat");
        File::create (data_file, footprint(H));
        io_handler->files.push_back (File::Entry (data_file));
      }

      return io_handler;
    }
Exemplo n.º 2
0
    std::unique_ptr<ImageIO::Base> MRtrix_sparse::create (Header& H) const
    {

      const auto name_it = H.keyval().find (Sparse::name_key);
      if (name_it == H.keyval().end())
        throw Exception ("Cannot create sparse image " + H.name() + "; no knowledge of underlying data class type");

      const auto size_it = H.keyval().find (Sparse::size_key);
      if (size_it == H.keyval().end())
        throw Exception ("Cannot create sparse image " + H.name() + "; no knowledge of underlying data class size");

      H.datatype() = DataType::UInt64;
      H.datatype().set_byte_order_native();

      File::OFStream out (H.name(), std::ios::out | std::ios::binary);

      out << "mrtrix sparse image\n";

      write_mrtrix_header (H, out);

      bool single_file = Path::has_suffix (H.name(), ".msf");

      int64_t image_offset = 0, sparse_offset = 0;
      std::string image_path, sparse_path;
      if (single_file) {

        image_offset = out.tellp() + int64_t(54);
        image_offset += ((4 - (image_offset % 4)) % 4);
        sparse_offset = image_offset + footprint(H);

        out << "file: . " << image_offset << "\nsparse_file: . " << sparse_offset << "\nEND\n";

        File::resize (H.name(), sparse_offset);
        image_path = H.name();
        sparse_path = H.name();

      } else {

        image_path  = Path::basename (H.name().substr (0, H.name().size()-4) + ".dat");
        sparse_path = Path::basename (H.name().substr (0, H.name().size()-4) + ".sdat");

        out << "file: " << image_path << "\nsparse_file: " << sparse_path << "\nEND\n";

        File::create (image_path, footprint(H));
        File::create (sparse_path);

      }

      std::unique_ptr<ImageIO::Sparse> io_handler (new ImageIO::Sparse (H, name_it->second, to<size_t>(size_it->second), File::Entry (sparse_path, sparse_offset)));
      io_handler->files.push_back (File::Entry (image_path, image_offset));

      return std::move (io_handler);
    }
Exemplo n.º 3
0
bool Factory_System::can_spawn(Spec spec, Location loc) const {
  for (auto& pair : footprint(spec, loc)) {
    if (!spatial.is_open(pair.second))
      return false;
  }
  return true;
}
Exemplo n.º 4
0
Bscript::BObjectImp* UMulti::get_script_member_id( const int id ) const ///id test
{
    Bscript::BObjectImp* imp = base::get_script_member_id( id );
    if ( imp )
        return imp;

    switch ( id )
    {
    case Bscript::MBR_FOOTPRINT:
        return footprint( );
        break;
    default:
        return NULL;
    }
}
Exemplo n.º 5
0
int zoupath(seat go,seat end)
{
    hehe*f ;
    fist(&f);
    //printf("%d\n",f);
    int step = 1;
    DD e;
    seat pos = go;
    do{
        if(pass(pos))
        {
            footprint(pos);
            e.i = step;
            e.di = 1;
            e.xy = pos;
            push(f,e);
            if(pos.x == end.x&&pos.y ==end.y)
            {
                return 1;
            }
            pos = next(pos ,1);
            step++;
        }
        else
        {
            if(!iszore(f))
            {
                pop(f,&e);
                printf("%d   %d\n",e.xy.y,e.xy.x);
                while(e.di == 4&&!iszore(f))
                {
                    makeprint(e.xy); pop(f,&e);
                    printf("%d   %d\n",e.xy.y,e.xy.x);
                }   
                if(e.di<4)
                {
                    e.di++; push(f,e);
                    pos = next(e.xy,e.di);
                }
            }
        }
    }while(!iszore(f));
    return 0;
}
Exemplo n.º 6
0
vtBuilding *vtStructureArray::AddBuildingFromLineString(OGRLineString *pLineString)
{
	int num_points = pLineString->getNumPoints();
	int j;

	// Ignore last point if it is the same as the first
	DPoint2 p1(pLineString->getX(0), pLineString->getY(0));
	DPoint2 p2(pLineString->getX(num_points - 1), pLineString->getY(num_points - 1));
	if (p1 == p2)
		num_points--;

	// Copy from OGR
	DLine2 footprint(num_points);
	for (j = 0; j < num_points; j++)
		footprint.SetAt(j, DPoint2(pLineString->getX(j), pLineString->getY(j)));

	PolyChecker PolyChecker;

	// Remove redundant points
	double dEpsilon = 1;
	for (j = 0; j < num_points && num_points > 2; j++)
	{
		DPoint2 p0 = footprint.GetSafePoint(j-1);
		DPoint2 p1 = footprint.GetSafePoint(j);
		DPoint2 p2 = footprint.GetSafePoint(j+1);
		if (PolyChecker.AreaSign(p0, p1, p2, dEpsilon) == 0)
		{
			footprint.RemoveAt(j);
			num_points--;
			j--;
		}
	}

	if (num_points < 3)
		return NULL;

	// Force footprint anticlockwise
	if (PolyChecker.IsClockwisePolygon(footprint))
		footprint.ReverseOrder();

	vtBuilding *bld = AddNewBuilding();
	bld->SetFootprint(0, footprint);
	return bld;
}