int main(int argc, char** argv) {
  init(argc, argv);

  std::string tracks_format = argv[1];
  std::string merged_file = argv[2];

  bool ok;

  // Load tracks from every frame.
  TrackListList track_lists;
  ok = loadAllTracks(tracks_format, track_lists);
  CHECK(ok) << "Could not load all tracks";
  LOG(INFO) << "Loaded " << track_lists.size() << " lists of tracks";

  // Now combine all tracks.
  // TODO: Get number of views from first non-empty list?
  int num_views = track_lists.front().numViews();
  TrackList merged(num_views);

  for (TrackListList::const_iterator tracks = track_lists.begin();
       tracks != track_lists.end();
       ++tracks) {
    // Add each track to the full list.
    TrackList::const_iterator track;
    for (track = tracks->begin(); track != tracks->end(); ++track) {
      merged.push_back(*track);
    }
  }

  SiftPositionWriter feature_writer;
  ok = saveMultiviewTrackList(merged_file, merged, feature_writer);
  CHECK(ok) << "Could not save tracks";

  return 0;
}
Exemplo n.º 2
0
void ICCVTutorial<FeatureType>::reconstructSurface ()
{
  cout << "surface reconstruction..." << std::flush;
  // merge the transformed and the target point cloud
  pcl::PointCloud<pcl::PointXYZRGB>::Ptr merged (new pcl::PointCloud<pcl::PointXYZRGB>);
  *merged = *source_transformed_;
  *merged += *target_segmented_;
  
  // apply grid filtering to reduce amount of points as well as to make them uniform distributed
  pcl::VoxelGrid<pcl::PointXYZRGB> voxel_grid;
  voxel_grid.setInputCloud(merged);
  voxel_grid.setLeafSize(0.002, 0.002, 0.002);
  voxel_grid.setDownsampleAllData(true);
  voxel_grid.filter(*merged);

  pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr vertices (new pcl::PointCloud<pcl::PointXYZRGBNormal>);
  pcl::copyPointCloud(*merged, *vertices);

  pcl::NormalEstimation<pcl::PointXYZRGB, pcl::PointXYZRGBNormal> normal_estimation;
  normal_estimation.setSearchMethod (pcl::search::Search<pcl::PointXYZRGB>::Ptr (new pcl::search::KdTree<pcl::PointXYZRGB>));
  normal_estimation.setRadiusSearch (0.01);
  normal_estimation.setInputCloud (merged);
  normal_estimation.compute (*vertices);
  
  pcl::search::KdTree<pcl::PointXYZRGBNormal>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZRGBNormal>);
  tree->setInputCloud (vertices);

  surface_reconstructor_->setSearchMethod(tree);
  surface_reconstructor_->setInputCloud(vertices);
  surface_reconstructor_->reconstruct(surface_);
  cout << "OK" << endl;
}
Exemplo n.º 3
0
void
MultiSelection::addSelection(const Selection &selection)
{
    m_selections.insert(selection);

    // Cope with a sitation where the new selection overlaps one or
    // more existing ones.  This is a terribly inefficient way to do
    // this, but that probably isn't significant in real life.

    // It's essential for the correct operation of
    // getContainingSelection that the selections do not overlap, so
    // this is not just a frill.

    for (SelectionList::iterator i = m_selections.begin();
	 i != m_selections.end(); ) {
	
	SelectionList::iterator j = i;
	if (++j == m_selections.end()) break;

	if (i->getEndFrame() >= j->getStartFrame()) {
	    Selection merged(i->getStartFrame(),
			     std::max(i->getEndFrame(), j->getEndFrame()));
	    m_selections.erase(i);
	    m_selections.erase(j);
	    m_selections.insert(merged);
	    i = m_selections.begin();
	} else {
	    ++i;
	}
    }
}
Exemplo n.º 4
0
xlw::CellMatrix xlw::MergeCellMatrices(const CellMatrix& Top, const CellMatrix& Bottom)
{
    size_t cols = maxi(Top.ColumnsInStructure(), Bottom.ColumnsInStructure());
    size_t rows = Top.RowsInStructure()+Bottom.RowsInStructure();

    CellMatrix merged(rows,cols);

    {for (size_t i=0; i < Top.ColumnsInStructure(); i++)
        for (size_t j=0; j < Top.RowsInStructure(); j++)
            merged(j,i) = Top(j,i);}

    for (size_t i=0; i < Bottom.ColumnsInStructure(); i++)
        for (size_t j=0; j < Bottom.RowsInStructure(); j++)
            merged(j+Top.RowsInStructure(),i) = Bottom(j,i);

    return merged;
}
Exemplo n.º 5
0
CellMatrix MergeCellMatrices(const CellMatrix& Top, const CellMatrix& Bottom)
{
	unsigned long cols = maxi(Top.ColumnsInStructure(), Bottom.ColumnsInStructure());
	unsigned long rows = Top.RowsInStructure()+Bottom.RowsInStructure();

	CellMatrix merged(rows,cols);

	{for (unsigned long i=0; i < Top.ColumnsInStructure(); i++)
		for (unsigned long j=0; j < Top.RowsInStructure(); j++)
			merged(j,i) = Top(j,i);}

	for (unsigned long i=0; i < Bottom.ColumnsInStructure(); i++)
		for (unsigned long j=0; j < Bottom.RowsInStructure(); j++)
			merged(j+Top.RowsInStructure(),i) = Bottom(j,i);


	return merged;
}
Exemplo n.º 6
0
TmpPdfFile *Project::createTmpPdfFile()
{
    TmpPdfFile *res = new TmpPdfFile(mJobs, this);

    connect(res, SIGNAL(progress(int,int)),
            this, SLOT(tmpFileProgress(int,int)));

    connect(res, SIGNAL(merged()),
            this, SLOT(tmpFileMerged()));

    return res;
}
Exemplo n.º 7
0
void
MergedTransactionTest::testMerge()
{
    auto first = initTransFirst(conn);
    first->begin();
    first->addConsoleOutputLine(1, "Foo");
    first->finish(true);

    auto second = initTransSecond(conn);
    second->begin();
    second->addConsoleOutputLine(1, "Bar");
    second->finish(false);

    MergedTransaction merged(first);
    merged.merge(second);

    CPPUNIT_ASSERT_EQUAL((int64_t)1, merged.listIds().at(0));
    CPPUNIT_ASSERT_EQUAL((int64_t)2, merged.listIds().at(1));

    CPPUNIT_ASSERT_EQUAL((uint32_t)1000, merged.listUserIds().at(0));
    CPPUNIT_ASSERT_EQUAL((uint32_t)1001, merged.listUserIds().at(1));

    CPPUNIT_ASSERT_EQUAL(std::string("dnf install foo"), merged.listCmdlines().at(0));
    CPPUNIT_ASSERT_EQUAL(std::string("dnf install bar"), merged.listCmdlines().at(1));

    CPPUNIT_ASSERT_EQUAL(true, (bool)merged.listDone().at(0));
    CPPUNIT_ASSERT_EQUAL(false, (bool)merged.listDone().at(1));

    CPPUNIT_ASSERT_EQUAL((int64_t)1, merged.getDtBegin());
    CPPUNIT_ASSERT_EQUAL((int64_t)4, merged.getDtEnd());

    CPPUNIT_ASSERT_EQUAL(std::string("begin 1"), merged.getRpmdbVersionBegin());
    CPPUNIT_ASSERT_EQUAL(std::string("end 2"), merged.getRpmdbVersionEnd());

    auto output = merged.getConsoleOutput();
    CPPUNIT_ASSERT_EQUAL(1, output.at(0).first);
    CPPUNIT_ASSERT_EQUAL(std::string("Foo"), output.at(0).second);

    CPPUNIT_ASSERT_EQUAL(1, output.at(1).first);
    CPPUNIT_ASSERT_EQUAL(std::string("Bar"), output.at(1).second);

    auto software = merged.getSoftwarePerformedWith();
    std::set< std::string > names = {"rpm", "dnf"};

    CPPUNIT_ASSERT(names.size() == 2);

    for (auto s : software) {
        const std::string &name = s->getName();
        CPPUNIT_ASSERT_MESSAGE("Name: " + name, names.find(name) != names.end());
        names.erase(name);
    }
}
Exemplo n.º 8
0
cv::Mat fisheyeTest::mergeRectification(const cv::Mat& l, const cv::Mat& r)
{
    CV_Assert(l.type() == r.type() && l.size() == r.size());
    cv::Mat merged(l.rows, l.cols * 2, l.type());
    cv::Mat lpart = merged.colRange(0, l.cols);
    cv::Mat rpart = merged.colRange(l.cols, merged.cols);
    l.copyTo(lpart);
    r.copyTo(rpart);

    for(int i = 0; i < l.rows; i+=20)
        cv::line(merged, cv::Point(0, i), cv::Point(merged.cols, i), cv::Scalar(0, 255, 0));

    return merged;
}
Exemplo n.º 9
0
    CloudMapper::Cloud::Ptr CloudMapper::GetMergedCloud()
    {
        CloudMapper::Clouds alignedClouds = AlignAll(m_pointClouds, m_landmarks);
        CloudMapper::Cloud::Ptr merged(new CloudMapper::Cloud);
        auto it = alignedClouds.begin();
        do
        {
            auto current = (*it);
            *merged += *current;
            ++it;
        }
        while (it != alignedClouds.end());

        return merged;
    }
Exemplo n.º 10
0
Foam::spatialTransform Foam::RBD::rigidBodyMotion::X00
(
    const label bodyId
) const
{
    if (merged(bodyId))
    {
        const subBody& mBody = mergedBody(bodyId);
        return mBody.masterXT() & X00_[mBody.masterID()];
    }
    else
    {
        return X00_[bodyId];
    }
}
Exemplo n.º 11
0
void testOrdLst()
{
	OrdList<char> lst0;
	auto lst1 = lst0.inserted('m');
	print(lst1);
	auto lst2 = lst1.inserted('p');
	print(lst2);
	auto lst3 = lst2.inserted('c');
	auto lst4 = lst1.inserted('d');
	auto lst5 = lst1.inserted('e');
	std::cout << "Merging\n";
	print(lst3);
	print(lst5);
	auto lst = merged(lst3, lst5);
	print(lst);
}
Exemplo n.º 12
0
MojErr MojDb::mergeInto(MojObject& dest, const MojObject& obj, const MojObject& prev)
{
	MojLogTrace(s_log);

	// TODO: support field deletion
	// TODO: move merge fn out of db
	MojErr err;
	MojObject::ConstIterator objIter = obj.begin();
	MojObject::ConstIterator prevIter = prev.begin();
	while (objIter != obj.end() || prevIter != prev.end()) {
		// compare keys from two iters
		int comp;
		if (objIter == obj.end()) {
			comp = 1;
		} else if (prevIter == prev.end()) {
			comp = -1;
		} else {
			comp = objIter.key().compare(prevIter.key());
		}
		// put the appropriate value into dest
		if (comp > 0) {
			err = dest.put(prevIter.key(), prevIter.value());
			MojErrCheck(err);
			++prevIter;
		} else if (comp < 0) {
			err = dest.put(objIter.key(), objIter.value());
			MojErrCheck(err);
			++objIter;
		} else {
			MojObject::Type newType = objIter.value().type();
			MojObject::Type prevType = prevIter.value().type();
			if (newType == MojObject::TypeObject && prevType == MojObject::TypeObject) {
				MojObject merged(MojObject::TypeObject);
				err = mergeInto(merged, objIter.value(), prevIter.value());
				MojErrCheck(err);
				err = dest.put(objIter.key(), merged);
				MojErrCheck(err);
			} else {
				err = dest.put(objIter.key(), objIter.value());
				MojErrCheck(err);
			}
			++prevIter;
			++objIter;
		}
	}
	return MojErrNone;
}
Exemplo n.º 13
0
void
MergedTransactionTest::test_add_obsoleted_installed()
{
    return;
    /*
    def test_add_obsoleted_installed(self):
        """Test add with an obsoleted NEVRA which was installed before."""
        ops = dnf.history.NEVRAOperations()
        ops.add('Install', 'lotus-0:3-16.x86_64')
        ops.add('Install', 'tour-0:4.6-1.noarch', obsoleted_nevras=('lotus-0:3-16.x86_64',))

        self.assertCountEqual(
            ops,
            (('Install', 'tour-0:4.6-1.noarch', None, set()),))
    */

    auto trans1 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans1_lotus = trans1->addItem(
        nevraToRPMItem(conn, "lotus-0:3-16.x86_64"),
        "repo1",
        TransactionItemAction::INSTALL,
        TransactionItemReason::DEPENDENCY
    );

    auto trans2 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans2_tour = trans2->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo2",
        TransactionItemAction::INSTALL,
        TransactionItemReason::USER
    );
    auto trans2_lotus = trans2->addItem(nevraToRPMItem(conn, "lotus-0:3-16.x86_64"), "repo1", TransactionItemAction::OBSOLETED, TransactionItemReason::DEPENDENCY);

    trans2_lotus->addReplacedBy(trans2_tour);

    MergedTransaction merged(trans1);
    merged.merge(trans2);

    auto items = merged.getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());

    auto item = items.at(0);
    CPPUNIT_ASSERT_EQUAL(std::string("repo2"), item->getRepoid());
    CPPUNIT_ASSERT_EQUAL(TransactionItemAction::INSTALL, item->getAction());
    CPPUNIT_ASSERT_EQUAL(TransactionItemReason::USER, item->getReason());
}
Exemplo n.º 14
0
/*
 * Add obj to mon's inventory.  If obj is able to merge with something already
 * in the inventory, then the passed obj is deleted and 1 is returned.
 * Otherwise 0 is returned.
 */
int add_to_minv(struct monst *mon, struct obj *obj)
{
    struct obj *otmp;

    if (obj->where != OBJ_FREE)
	panic("add_to_minv: obj not free");

    /* merge if possible */
    for (otmp = mon->minvent; otmp; otmp = otmp->nobj)
	if (merged(&otmp, &obj))
	    return 1;	/* obj merged and then free'd */
    /* else insert; don't bother forcing it to end of chain */
    obj->where = OBJ_MINVENT;
    obj->ocarry = mon;
    obj->nobj = mon->minvent;
    mon->minvent = obj;
    return 0;	/* obj on mon's inventory chain */
}
Exemplo n.º 15
0
/*
 * Add obj to container, make sure obj is "free".  Returns (merged) obj.
 * The input obj may be deleted in the process.
 */
struct obj *add_to_container(struct obj *container, struct obj *obj)
{
    struct obj *otmp;

    if (obj->where != OBJ_FREE)
	panic("add_to_container: obj not free");
    if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT)
	obj_no_longer_held(obj);

    /* merge if possible */
    for (otmp = container->cobj; otmp; otmp = otmp->nobj)
	if (merged(&otmp, &obj)) return otmp;

    obj->where = OBJ_CONTAINED;
    obj->ocontainer = container;
    obj->nobj = container->cobj;
    container->cobj = obj;
    return obj;
}
Exemplo n.º 16
0
void
MergedTransactionTest::test_add_install_removed()
{
    return;
    /*
    def test_add_install_removed(self):
        """Test add with an install of NEVRA which was removed before."""
        ops = dnf.history.NEVRAOperations()
        ops.add('Erase', 'tour-0:4.6-1.noarch')
        ops.add('Install', 'tour-0:4.6-1.noarch')

        self.assertCountEqual(
            ops,
            (('Reinstall', 'tour-0:4.6-1.noarch', 'tour-0:4.6-1.noarch', set()),))

    */
    auto trans1 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans1_tour = trans1->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo1",
        TransactionItemAction::REMOVE,
        TransactionItemReason::DEPENDENCY
    );

    auto trans2 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans2_tour = trans2->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo2",
        TransactionItemAction::INSTALL,
        TransactionItemReason::USER
    );

    MergedTransaction merged(trans1);
    merged.merge(trans2);

    auto items = merged.getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());

    auto item = items.at(0);
    CPPUNIT_ASSERT_EQUAL(std::string("repo2"), item->getRepoid());
    CPPUNIT_ASSERT_EQUAL(TransactionItemAction::REINSTALL, item->getAction());
    CPPUNIT_ASSERT_EQUAL(TransactionItemReason::USER, item->getReason());
}
Exemplo n.º 17
0
void
MergedTransactionTest::test_add_remove_removed()
{
    return;
    /*
    def test_add_erase_removed(self):
        """Test add with an erasure of NEVRA which was removed before."""
        ops = dnf.history.NEVRAOperations()
        ops.add('Erase', 'tour-0:4.6-1.noarch')

        self.assertRaises(
            ValueError,
            ops.add, 'Erase', 'tour-0:4.6-1.noarch')
    */

    auto trans1 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans1_tour = trans1->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo1",
        TransactionItemAction::REMOVE,
        TransactionItemReason::USER
    );

    auto trans2 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans2_tour = trans2->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo2",
        TransactionItemAction::REMOVE,
        TransactionItemReason::DEPENDENCY
    );

    MergedTransaction merged(trans1);
    merged.merge(trans2);

    auto items = merged.getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());

    // TODO: different reasons, repos
}
Exemplo n.º 18
0
void
MergedTransactionTest::test_add_remove_installed()
{
    /*
    def test_add_erase_installed(self):
        """Test add with an erasure of NEVRA which was installed before."""
        ops = dnf.history.NEVRAOperations()
        ops.add('Install', 'tour-0:4.6-1.noarch', obsoleted_nevras=('lotus-0:3-16.x86_64',))
        ops.add('Erase', 'tour-0:4.6-1.noarch')

        self.assertCountEqual(
            ops,
            (('Erase', 'lotus-0:3-16.x86_64', None, set()),))
    */

    auto trans1 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans1_tour = trans1->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo1",
        TransactionItemAction::INSTALL,
        TransactionItemReason::USER
    );

    auto trans2 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans2_tour = trans2->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo2",
        TransactionItemAction::REMOVE,
        TransactionItemReason::DEPENDENCY
    );

    MergedTransaction merged(trans1);
    merged.merge(trans2);

    auto items = merged.getItems();
    //CPPUNIT_ASSERT_EQUAL(1, (int)items.size());
    // TODO
}
Exemplo n.º 19
0
void
MergedTransactionTest::test_add_install_installed()
{
    return;
    /*
    def test_add_install_installed(self):
        """Test add with two installs of the same NEVRA."""
        ops = dnf.history.NEVRAOperations()
        ops.add('Install', 'tour-0:4.6-1.noarch')

        self.assertRaises(
            ValueError,
            ops.add, 'Install', 'tour-0:4.6-1.noarch')
    */

    auto trans1 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans1_tour = trans1->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo1",
        TransactionItemAction::INSTALL,
        TransactionItemReason::USER
    );

    auto trans2 = std::make_shared< SwdbPrivate::Transaction >(conn);
    auto trans2_tour = trans2->addItem(
        nevraToRPMItem(conn, "tour-0:4.6-1.noarch"),
        "repo2",
        TransactionItemAction::INSTALL,
        TransactionItemReason::GROUP
    );

    MergedTransaction merged(trans1);
    merged.merge(trans2);

    auto items = merged.getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());
}
Exemplo n.º 20
0
 void visitBlock(Block *curr) {
   bool more = true;
   while (more) {
     more = false;
     for (size_t i = 0; i < curr->list.size(); i++) {
       Block* child = curr->list[i]->dynCast<Block>();
       if (!child) continue;
       if (child->name.is()) continue; // named blocks can have breaks to them (and certainly do, if we ran RemoveUnusedNames and RemoveUnusedBrs)
       ExpressionList merged(getModule()->allocator);
       for (size_t j = 0; j < i; j++) {
         merged.push_back(curr->list[j]);
       }
       for (auto item : child->list) {
         merged.push_back(item);
       }
       for (size_t j = i + 1; j < curr->list.size(); j++) {
         merged.push_back(curr->list[j]);
       }
       curr->list = merged;
       more = true;
       break;
     }
   }
 }
Exemplo n.º 21
0
int main()
{
    int n, m, l;
    while (scanf("%d%d%d", &n, &m, &l) == 3) {
        std::vector<std::vector<int>> graph(n);
        for (int i = 0, a, b; i < m; ++ i) {
            scanf("%d%d", &a, &b);
            a --, b --;
            graph[a].push_back(b);
            graph[b].push_back(a);
        }
        if (l == 1) {
            puts("1");
            continue;
        }
        l --;
        std::vector<std::vector<Info>> dp(1 << l, std::vector<Info>(n, Info { m + 1, 0 })),
            merged(n, std::vector<Info>(1 << l, Info { m + 1, 0 }));
        int root = l;
        for (int i = 0; i < l; ++ i) {
            dp[1 << i][i] = { 0, 1 };
        }
        for (int msk = 0; msk < 1 << l; ++ msk) {
            for (int u = 0; u < n; ++ u) {
                auto& ref = merged.at(u);
                for (int subset = msk; subset > 0; subset = subset - 1 & msk) {
                    if (lowbit(subset) == lowbit(msk)) {
                        update(ref.at(msk), add(dp.at(subset).at(u), ref.at(msk ^ subset)));
                    }
                }
            }
            for (int u = 0; u < n; ++ u) {
                for (int v : graph[u]) {
                    update(dp.at(msk).at(v), add(merged.at(u).at(msk), ONE));
                }
            }
            auto& ref = dp.at(msk);
            PQ<std::pair<int, int>> pq;
            for (int u = 0; u < n; ++ u) {
                pq.emplace(ref.at(u).first, u);
            }
            while (!pq.empty()) {
                auto top = pq.top();
                pq.pop();
                int u = top.second;
                if (top.first == ref.at(u).first) {
                    for (int v : graph.at(u)) {
                        Info todo = add(ref.at(u), ONE);
                        if (todo.first < ref.at(v).first) {
                            pq.emplace(todo.first, v);
                        }
                        update(ref.at(v), todo);
                    }
                }
            }
            for (int u = 0; u < n; ++ u) {
                update(merged.at(u).at(msk), dp.at(msk).at(u));
// fprintf(stderr, "%s %d %d %d\n", std::bitset<3>(msk).to_string().c_str(), u, dp.at(msk).at(u).first, dp.at(msk).at(u).second);
            }
        }
        printf("%d\n", merged.at(root).at((1 << l) - 1).second);
    }
}
Exemplo n.º 22
0
/*static*/ void
initialize_default_env () {
  if (N(default_env) != 0) return;
  hashmap<string,tree>& env= default_env;

  tree identity_m (MACRO, "x", tree (ARG, "x"));
  tree tabular_m (MACRO, "x", tree (TFORMAT, tree (ARG, "x")));
  tree the_page (MACRO, compound ("page-nr"));

  tree gr_geometry (TUPLE, "geometry", "1par", "0.6par", "center");
  tree gr_frame (TUPLE, "scale", "1cm", tree (TUPLE, "0.5gw", "0.5gh"));

  tree gr_grid ("");
  tree gr_edit_grid ("");
  tree gr_grid_aspect (TUPLE,
		       tuple ("axes", "#808080"),
		       tuple ("1", "#c0c0c0"),
		       tuple ("10", "#e0e0ff"));

  tree gr_transf (TUPLE,
                  tuple ("1.0", "0.0", "0.0", "0.0"),
                  tuple ("0.0", "1.0", "0.0", "0.0"),
                  tuple ("0.0", "0.0", "1.0", "0.0"),
                  tuple ("0.0", "0.0", "0.0", "1.0"));         

  env (DPI)              = "600";       // resolution in dots per inch
  env (ZOOM_FACTOR)      = "1";         // zoom factor on screen
  env (PREAMBLE)         = "false";     // preamble mode ?
  env (SAVE_AUX)         = "true";      // save auxiliary data on disk ?
  env (MODE)             = "text";      // typesetting mode
  env (INFO_FLAG)        = "minimal";   // information about labels, etc.
  env (WINDOW_BARS)      = "auto";      // override menu/icon bar settings
  env (SCROLL_BARS)      = "true";      // allow scroll bars around canvas?
  env (IDENTITY)         = identity_m;  // identity macro
  env (TABULAR)          = tabular_m;   // tabular macro
  env (THE_LABEL)        = "?";         // value of the next label
  env (THE_TAGS)         = tree(TUPLE); // current tags
  env (THE_MODULES)      = tree(TUPLE); // necessary modules and plug-ins
  env (WARN_MISSING)     = "true";      // warn about missing references
  env (GLOBAL_TITLE)     = "";          // global document title
  env (GLOBAL_AUTHOR)    = "";          // global document author
  env (GLOBAL_SUBJECT)   = "";          // global document subject

  env (FONT)             = "roman";     // the font name in text mode
  env (FONT_FAMILY)      = "rm";        // the font family in text mode
  env (FONT_SERIES)      = "medium";    // the font series in text mode
  env (FONT_SHAPE)       = "right";     // the font shape in text mode
  env (FONT_SIZE)        = "1";         // the font size multiplier
  env (FONT_BASE_SIZE)   = "10";        // the font base size
  env (MAGNIFICATION)    = "1";         // magnification (slides for instance)
  env (COLOR)            = "black";     // the color
  env (OPACITY)          = "100%";      // the opacity
  env (BG_COLOR)         = "white";     // the background color
  env (LOCUS_COLOR)      = "global";    // the color of loci
  env (VISITED_COLOR)    = "global";    // the color of visited loci
  env (NO_PATTERNS)      = "false";     // disable background patterns
  env (LANGUAGE)         = "english";   // the language
  env (ATOM_DECORATIONS) = DATOMS;      // dots, underline, hyperlinks?, etc.
  env (LINE_DECORATIONS) = DLINES;      // boxed pars, nested envs, etc.
  env (PAGE_DECORATIONS) = DPAGES;      // future headers, footers, etc.
  env (XOFF_DECORATIONS) = "0tmpt";     // hor. placement of decorations
  env (YOFF_DECORATIONS) = "0tmpt";     // vert. placement of decorations

  env (MATH_LANGUAGE)    = "std-math";  // the default mathematical language
  env (MATH_FONT)        = "roman";     // the font name in math mode
  env (MATH_FONT_FAMILY) = "mr";        // the font family in math mode
  env (MATH_FONT_SERIES) = "medium";    // the font series in math mode
  env (MATH_FONT_SHAPE)  = "normal";    // the font shape in math mode
  env (MATH_LEVEL)       = "0";         // the index level (0, 1 or 2)
  env (MATH_DISPLAY)     = "false";     // true if we are in display style
  env (MATH_CONDENSED)   = "false";     // ignore spaces between operators ?
  env (MATH_VPOS)        = "0";         // used in fractions (-1, 0 or 1)
  env (MATH_NESTING_MODE)= "off";       // color nested brackets?
  env (MATH_NESTING_LEVEL)= "0";        // nesting level inside brackets

  env (PROG_LANGUAGE)    = "scheme";    // the default programming language
  env (PROG_SCRIPTS)     = "scheme";    // the scripting language
  env (PROG_FONT)        = "roman";     // the font name in prog mode
  env (PROG_FONT_FAMILY) = "tt";        // the font family in prog mode
  env (PROG_FONT_SERIES) = "medium";    // the font series in prog mode
  env (PROG_FONT_SHAPE)  = "right";     // the font shape in prog mode
  env (PROG_SESSION)     = "default";   // computer algebra session name

  env (PAR_MODE)         = "justify";   // outline method
  env (PAR_FLEXIBILITY)  = "1000";      // threshold for switching to ragged
  env (PAR_HYPHEN)       = "professional"; // quality of hyphenation
  env (PAR_SPACING)      = "plain";     // spacing mode (for CJK)
  env (PAR_KERNING_STRETCH)= "auto";    // extra kerning around characters
  env (PAR_KERNING_MARGIN) = "false";   // use marginal kerning (protrusion)
  env (PAR_WIDTH)        = "auto";      // width of paragraph
  env (PAR_LEFT)         = "0cm";       // left indentation
  env (PAR_RIGHT)        = "0cm";       // right indentation
  env (PAR_FIRST)        = "1.5fn";     // extra first indentation
  env (PAR_NO_FIRST)     = "false";     // no extra first indent. on next line
  env (PAR_SEP)          = "0.2fn";     // extra space between paragraph lines
  env (PAR_HOR_SEP)      = "0.5fn";     // min. hor. spc. between ink for shove
  env (PAR_VER_SEP)      = "0.2fn";     // min. ver. spc. between ink
  env (PAR_LINE_SEP)     = "0.025fns";  // extra (small) space between lines
  env (PAR_PAR_SEP)      = "0.5fns";    // extra space between paragraphs
  env (PAR_FNOTE_SEP)    = "0.2fn";     // min space between diff footnotes
  env (PAR_COLUMNS)      = "1";         // number of columns
  env (PAR_COLUMNS_SEP)  = "2fn";       // separation between columns

  env (PAGE_MEDIUM)      = "papyrus";   // paper medium: paper, papyrus, auto
  env (PAGE_PRINTED)     = "false";     // printed version?
  env (PAGE_TYPE)        = "a4";        // paper type (-> width & height)
  env (PAGE_ORIENTATION) = "portrait";  // paper orientation
  env (PAGE_WIDTH_MARGIN)  = "false";   // compute margins from par-width?
  env (PAGE_HEIGHT_MARGIN) = "false";   // compute margins from par-width?
  env (PAGE_SCREEN_MARGIN) = "true";    // special margins for screen editing?
  env (PAGE_BREAKING)    = "professional";  // quality of page breaking
  env (PAGE_FLEXIBILITY) = "1";         // flexibility factor of stretch
  env (PAGE_NR)          = "0";         // the page number
  env (PAGE_THE_PAGE)    = the_page;    // the page number as text
  env (PAGE_WIDTH)       = "auto";      // physical width of pages
  env (PAGE_HEIGHT)      = "auto";      // physical height of pages
  env (PAGE_ODD)         = "auto";      // left margin on odd pages
  env (PAGE_EVEN)        = "auto";      // left margin on even pages
  env (PAGE_RIGHT)       = "auto";      // right margin in auto mode
  env (PAGE_TOP)         = "auto";      // top margin
  env (PAGE_BOT)         = "auto";      // bottom margin
  env (PAGE_USER_HEIGHT) = "522pt";     // height of principal text
  env (PAGE_ODD_SHIFT)   = "0mm";       // odd page marginal shift wrt center
  env (PAGE_EVEN_SHIFT)  = "0mm";       // even page marginal shift wrt center
  env (PAGE_SHRINK)      = "1fn";       // emergency page length shrinking
  env (PAGE_EXTEND)      = "0fn";       // emergency page length extension
  env (PAGE_HEAD_SEP)    = "8mm";       // separation between header and text
  env (PAGE_FOOT_SEP)    = "8mm";       // separation between footer and text
  env (PAGE_ODD_HEADER)  = "";          // header on odd pages
  env (PAGE_ODD_FOOTER)  = "";          // footer on odd pages
  env (PAGE_EVEN_HEADER) = "";          // header on even pages
  env (PAGE_EVEN_FOOTER) = "";          // footer on even pages
  env (PAGE_SCREEN_WIDTH)  = "10cm";    // width of current window (for auto)
  env (PAGE_SCREEN_HEIGHT) = "10cm";    // height of current window (for auto)
  env (PAGE_SCREEN_LEFT) = "5mm";       // left margin for screen editing
  env (PAGE_SCREEN_RIGHT)= "5mm";       // right margin for screen editing
  env (PAGE_SCREEN_TOP)  = "15mm";      // top margin for screen editing
  env (PAGE_SCREEN_BOT)  = "15mm";      // bottom margin for screen editing
  env (PAGE_SHOW_HF)     = "true";      // show header and footer
  env (PAGE_FNOTE_SEP)   = "1.0fn";     // space between text & footnotes
  env (PAGE_FNOTE_BARLEN)= "7.5fn";     // length of footnote separating bar
  env (PAGE_FLOAT_SEP)   = "1.5fn";     // space between text & floats
  env (PAGE_MNOTE_SEP)   = "5mm";       // space between text & marginal notes
  env (PAGE_MNOTE_WIDTH) = "15mm";      // width of marginal notes

  env (TABLE_WIDTH)      = "";          // width of table
  env (TABLE_HEIGHT)     = "";          // height of table
  env (TABLE_HMODE)      = "auto";      // width determination mode
  env (TABLE_VMODE)      = "auto";      // height determination mode
  env (TABLE_HALIGN)     = "l";         // horizontal alignment
  env (TABLE_VALIGN)     = "f";         // vertical alignment (fraction height)
  env (TABLE_ROW_ORIGIN) = "0";         // row origin
  env (TABLE_COL_ORIGIN) = "0";         // column origin
  env (TABLE_LSEP)       = "0fn";       // left padding around table
  env (TABLE_RSEP)       = "0fn";       // right padding around table
  env (TABLE_BSEP)       = "0fn";       // bottom padding around table
  env (TABLE_TSEP)       = "0fn";       // top padding around table
  env (TABLE_LBORDER)    = "0ln";       // left table border width
  env (TABLE_RBORDER)    = "0ln";       // right table border width
  env (TABLE_BBORDER)    = "0ln";       // bottom table border width
  env (TABLE_TBORDER)    = "0ln";       // top table border width
  env (TABLE_HYPHEN)     = "n";         // vertical hyphenation
  env (TABLE_MIN_ROWS)   = "";          // suggested minimal number of rows
  env (TABLE_MIN_COLS)   = "";          // suggested minimal number of columns
  env (TABLE_MAX_ROWS)   = "";          // suggested maximal number of rows
  env (TABLE_MAX_COLS)   = "";          // suggested maximal number of columns

  env (CELL_DECORATION)  = "";          // decorating table of cell
  env (CELL_FORMAT)      = TFORMAT;     // format of cell
  env (CELL_BACKGROUND)  = "";          // background color of cell
  env (CELL_ORIENTATION) = "portrait";  // orientation of cell  
  env (CELL_WIDTH)       = "";          // width of cell
  env (CELL_HEIGHT)      = "";          // height of cell
  env (CELL_HPART)       = "";          // take part of unused horizontal space
  env (CELL_VPART)       = "";          // take part of unused vertical space
  env (CELL_HMODE)       = "auto";      // width determination mode
  env (CELL_VMODE)       = "auto";      // height determination mode
  env (CELL_HALIGN)      = "l";         // horizontal alignment
  env (CELL_VALIGN)      = "B";         // vertical alignment
  env (CELL_LSEP)        = "0fn";       // left cell padding
  env (CELL_RSEP)        = "0fn";       // right cell padding
  env (CELL_BSEP)        = "0fn";       // bottom cell padding
  env (CELL_TSEP)        = "0fn";       // top cell padding
  env (CELL_LBORDER)     = "0ln";       // left cell border width
  env (CELL_RBORDER)     = "0ln";       // right cell border width
  env (CELL_BBORDER)     = "0ln";       // bottom cell border width
  env (CELL_TBORDER)     = "0ln";       // top cell border width
  env (CELL_VCORRECT)    = "a";         // vertical limits correction
  env (CELL_HYPHEN)      = "n";         // horizontal hyphenation
  env (CELL_BLOCK)       = "auto";      // cell contains block content?
  env (CELL_ROW_SPAN)    = "1";         // row span of cell
  env (CELL_COL_SPAN)    = "1";         // column span of cell
  env (CELL_ROW_NR)      = "1";         // row coordinate of cell
  env (CELL_COL_NR)      = "1";         // column coordinate of cell

  env (GR_GEOMETRY)         = gr_geometry;    // geometry of graphics
  env (GR_FRAME)            = gr_frame;       // coordinate frame for graphics
  env (GR_MODE)             = "line";         // graphical mode
  env (GR_AUTO_CROP)        = "false";        // auto crop graphics
  env (GR_CROP_PADDING)     = "1spc";         // padding when auto cropping
  env (GR_GRID)             = gr_grid;        // grid for graphics
  env (GR_GRID_ASPECT)      = gr_grid_aspect; // grid aspect
  env (GR_EDIT_GRID)        = gr_edit_grid;   // edit grid
  env (GR_EDIT_GRID_ASPECT) = gr_grid_aspect; // edit grid (subdivisions)
  env (GR_TRANSFORMATION)   = gr_transf;      // 3D transformation

  env (GR_MAGNIFY)       = "default";   // magnify of new objects
  env (GR_OPACITY)       = "default";   // opacity of new objects
  env (GR_COLOR)         = "default";   // color of new objects
  env (GR_POINT_STYLE)   = "default";   // point style of new objects
  env (GR_LINE_WIDTH)    = "default";   // line width for new objects
  env (GR_LINE_JOIN)     = "default";   // line join for new objects
  env (GR_LINE_CAPS)     = "default";   // line caps for new objects
  env (GR_LINE_EFFECTS)    = "default";   // line effects for new objects
  env (GR_DASH_STYLE)      = "default";   // dash style for new objects
  env (GR_DASH_STYLE_UNIT) = "default";   // dash style unit for new objects
  env (GR_ARROW_BEGIN)     = "default";   // arrow begin for new objects
  env (GR_ARROW_END)       = "default";   // arrow end for new objects
  env (GR_ARROW_LENGTH)    = "default";   // arrow length for new objects
  env (GR_ARROW_HEIGHT)    = "default";   // arrow height for new objects
  env (GR_FILL_COLOR)      = "default";   // fill color for new objects
  env (GR_FILL_STYLE)      = "default";   // fill style for new objects
  env (GR_TEXT_AT_HALIGN)  = "default";   // horiz. alignment for new text-ats
  env (GR_TEXT_AT_VALIGN)  = "default";   // vert. alignment for new text-ats
  env (GR_TEXT_AT_MARGIN)  = "default";   // margins for new text-ats

  env (GID)              = "default";   // graphical identifier
  env (MAGNIFY)          = "1";         // magnification for graphical objects
  env (POINT_STYLE)      = "disk";      // point style (square, circle...)
  env (LINE_WIDTH)       = "1ln";       // line width in graphics
  env (LINE_JOIN)        = "normal";    // junctions in multilines
  env (LINE_CAPS)        = "normal";    // caps at ends
  env (LINE_EFFECTS)     = "none";      // effects to be applied on line
  env (DASH_STYLE)       = "none";      // dash style
  env (DASH_STYLE_UNIT)  = "5ln";       // dash style unit
  env (ARROW_BEGIN)      = "none";      // arrow at beginning of line
  env (ARROW_END)        = "none";      // arrow at end of line
  env (ARROW_LENGTH)     = "5ln";       // longitudal length of arrow
  env (ARROW_HEIGHT)     = "5ln";       // transverse height of arrow
  env (FILL_COLOR)       = "none";      // fill color
  env (FILL_STYLE)       = "plain";     // fill style
  env (TEXT_AT_HALIGN)   = "left";      // horizontal text-at alignment
  env (TEXT_AT_VALIGN)   = "base";      // vertical text-at alignment
  env (TEXT_AT_MARGIN)   = "base";      // margin for smart guides

  env (SRC_STYLE)        = "angular";   // style for "source" tags
  env (SRC_SPECIAL)      = "normal";    // special treatment of certain tags
  env (SRC_COMPACT)      = "normal";    // compact inline/multi-paragraph tags?
  env (SRC_CLOSE)        = "compact";   // how to close long tags

  env (CANVAS_TYPE)           = "plain";        // which kind of scrollbars
  env (CANVAS_COLOR)          = "white";        // canvas colour
  env (CANVAS_HPADDING)       = "0px";          // horizontal canvas padding
  env (CANVAS_VPADDING)       = "0px";          // vertical canvas padding
  env (CANVAS_BAR_WIDTH)      = "1em";          // width of scroll bars
  env (CANVAS_BAR_PADDING)    = "0.25em";       // distance of scrollbars
  env (CANVAS_BAR_COLOR)      = "grey";         // color of bar
  env (ORNAMENT_SHAPE)        = "classic";      // shape of the ornament
  env (ORNAMENT_TITLE_STYLE)  = "classic";      // title style
  env (ORNAMENT_BORDER)       = "1ln";          // border width
  env (ORNAMENT_SWELL)        = "0.5";          // border swell
  env (ORNAMENT_HPADDING)     = "1spc";         // horizontal padding of body
  env (ORNAMENT_VPADDING)     = "1spc";         // vertical padding of body
  env (ORNAMENT_COLOR)        = "";             // background color
  env (ORNAMENT_EXTRA_COLOR)  = "white";        // background color for titles
  env (ORNAMENT_SUNNY_COLOR)  = "black";        // sunny color
  env (ORNAMENT_SHADOW_COLOR) = "black";        // shadow color

  /* hiding and showing content */
  env ("shown")= identity_m;
  env ("ignore")=
    tree (MACRO, "body", tree (HIDDEN, tree (ARG, "body")));

  /* linking macros */
  tree src_id (ID, tree (HARD_ID, tree (ARG, "body")));
  tree ref_id (ID, tree (HARD_ID, tree (ARG, "Id")));
  tree dest_url (URL, tree (ARG, "destination"));
  tree dest_script (SCRIPT, tree (ARG, "destination"), tree (ARG, "where"));
  tree dest_ref (URL, tree (MERGE, "#", tree (ARG, "Id")));
  tree anchor (ID, tree (MERGE, "#", tree (ARG, "Id")));
  tree ln1 (LINK, "hyperlink", copy (src_id), copy (dest_url));
  tree ln2 (LINK, "action", copy (src_id), copy (dest_script));
  tree ln3 (LINK, "hyperlink", copy (ref_id), copy (dest_ref));
  tree ln4 (LINK, "anchor", anchor);
  tree labflag (FLAG, tree (ARG, "Id"), "blue", "Id");
  tree labtxt (SET_BINDING, tree (ARG, "Id"), tree (VALUE, THE_LABEL));
  tree merged (MERGE, tree (VALUE, THE_TAGS), tuple (tree (ARG, "Id")));
  tree tagflag (FLAG, tree (ARG, "Id"), "blue", "Id");
  tree reftxt (GET_BINDING, tree (ARG, "Id"));
  tree preftxt (GET_BINDING, tree (ARG, "Id"), "1");
  tree act_id (ID, tree (HARD_ID, tree (ARG, "args", "0")));
  tree act_script (MAP_ARGS, "find-accessible", "script", "args", "1");
  tree act_ln (LINK, "action", copy (act_id), copy (act_script));
  env ("hlink")= tree (MACRO, "body", "destination",
		       tree (LOCUS, copy (src_id), ln1,
                             tree (ARG, "body")));
  env ("action")= tree (XMACRO, "args",
			tree (LOCUS, copy (act_id), copy (act_ln),
                              tree (ARG, "args", "0")));
  env ("label")= tree (MACRO, "Id", 
		       tree (LOCUS, copy (ref_id), ln4,
			     tree (CONCAT, labflag, labtxt)));
  env ("tag")= tree (MACRO, "Id", "body",
		     tree (WITH, "the-tags", merged,
			   tree (SURROUND, tagflag, "",
                                 tree (ARG, "body"))));
  env ("reference")= tree (MACRO, "Id",
			   tree (LOCUS, copy (ref_id), ln3, reftxt));
  env ("pageref")= tree (MACRO, "Id",
			 tree (LOCUS, copy (ref_id), copy (ln3), preftxt));

  /* further standard macros */
  env ("error")=
    tree (MACRO, "message",
          tree (REWRITE_INACTIVE, tree (ARG, "message"), "error"));
  env ("style-only")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("style-only*")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("active")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("active*")=
    tree (MACRO, "body", tree (ARG, "body"));
  env ("inactive")=
    tree (MACRO, "body",
          tree (REWRITE_INACTIVE, tree (ARG, "body"), "once"));
  env ("inactive*")=
    tree (MACRO, "body",
          tree (REWRITE_INACTIVE, tree (ARG, "body"), "recurse"));
  env ("right-flush")=
    tree (MACRO, tree (HTAB, "0fn", "first"));
  env ("indent*")=
    tree (MACRO, "body",
	  tree (WITH, PAR_LEFT, tree (PLUS, tree (VALUE, PAR_LEFT), "1.5fn"),
		tree (ARG, "body")));
  env ("indent")=
    tree (MACRO, "body",
	  tree (SURROUND, "", compound ("right-flush"),
		compound ("indent*", tree (ARG, "body"))));
  env ("math")=
    tree (MACRO, "body", tree (WITH, MODE, "math", tree (ARG, "body")));
  env ("text")=
    tree (MACRO, "body", tree (WITH, MODE, "text", tree (ARG, "body")));
  env ("pre-edit")=
    tree (MACRO, "body", tree (WITH, COLOR, "#4040c0", tree (ARG, "body")));
  env ("mutator")=
    tree (MACRO, "body", "y", tree (ARG, "body"));

  /* syntactic highlighting */
  env ("src-regular")=
    tree (MACRO, "body", tree (WITH, COLOR, "black", tree (ARG, "body")));
  env ("src-macro")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "blue",
                               FONT_FAMILY, "ss", tree (ARG, "body")));
  env ("src-var")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "dark green",
                               FONT_SHAPE, "italic", tree (ARG, "body")));
  env ("src-arg")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "brown",
                               FONT_SHAPE, "italic", tree (ARG, "body")));
  env ("src-tt")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#228",
                               FONT_FAMILY, "tt", tree (ARG, "body")));
  env ("src-numeric")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#848",
                               tree (ARG, "body")));
  env ("src-textual")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "black",
                               tree (ARG, "body")));
  env ("src-length")=
    tree (MACRO, "body", tree (WITH, MODE, "src", COLOR, "#288",
                               tree (ARG, "body")));
  env ("src-unknown")=
    tree (MACRO, "body", tree (WITH, COLOR, "#C68", tree (ARG, "body")));
  env ("src-error")=
    tree (MACRO, "body", tree (WITH, COLOR, "red", tree (ARG, "body")));

  /* for correct importation of style files and packages */
  env ("src-title")= identity_m;
  env ("src-style-file")=
    tree (MACRO, "style", "version",
	  tree (ASSIGN,
		tree (MERGE, tree (ARG, "style"), "-style"),
		tree (ARG, "version")));
  env ("src-package")=
    tree (MACRO, "package", "version",
	  tree (CONCAT,
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-package"),
		      tree (ARG, "version")),
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-dtd"),
		      tree (ARG, "version"))));
  env ("src-package-dtd")=
    tree (MACRO, "package", "version", "drd", "drd-version",
	  tree (CONCAT,
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "package"), "-package"),
		      tree (ARG, "version")),
		tree (ASSIGN,
		      tree (MERGE, tree (ARG, "drd"), "-dtd"),
		      tree (ARG, "drd-version"))));
}