Example #1
0
int main()
{
    Test test;
    std::cout << "decorator(&no_throw_func, 1, 2): " << decorator(&Test::no_throw_func, &test, 1, 2) << std::endl;
    std::cout << "decorator(&throw_func, 1, 2): " << decorator(&Test::throw_func, &test, 1, 2) << std::endl;
    std::cout << "decorator(&no_args_func): " << decorator(&Test::no_args_func, &test) << std::endl;
    decorator(&Test::void_ret_func, &test, 1, 2);
    
    return 0;
}
Example #2
0
  bool try_initialize_more (Ekiga::ServiceCore& core,
			    int* /*argc*/,
			    char** /*argv*/[])
  {
    boost::shared_ptr<Ekiga::ContactCore> contact_core = core.get<Ekiga::ContactCore> ("contact-core");
    boost::shared_ptr<Local::Cluster> cluster = core.get<Local::Cluster> ("local-cluster");

    if (cluster && contact_core) {

      boost::shared_ptr<Local::ContactDecorator> decorator (new Local::ContactDecorator (cluster));
      if (core.add (decorator)) {

	contact_core->add_contact_decorator (decorator);
	result = true;
      }
    }

    return result;
  }
Example #3
0
void test_HalfedgeDS_decorator3() {
    // Simple instantiation of the default halfedge data structure.
    typedef CGAL::HalfedgeDS_default<Dummy_traits_2>  HDS;
    typedef CGAL::HalfedgeDS_decorator<HDS>          Decorator;

    CGAL_USE_TYPE(HDS::Halfedge_handle);
    CGAL_USE_TYPE(HDS::Face_handle);

    HDS hds;

    Build_triangle<HDS> modifier(0,0);
    modifier(hds);
    modifier.x_=33;
    modifier.y_=33;
    modifier(hds);


    Decorator decorator(hds);
    decorator.keep_largest_connected_components(1);

    hds.normalize_border();

    assert( hds.size_of_vertices() == 4);
    assert( hds.size_of_halfedges() == 10);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 4));

    decorator.vertices_erase(hds.vertices_begin());
    decorator.vertices_erase(hds.vertices_begin(), hds.vertices_end());

    decorator.faces_erase(hds.faces_begin());
    decorator.faces_erase(hds.faces_begin(), hds.faces_end());

    assert( hds.size_of_vertices() == 0);
    assert( hds.size_of_halfedges() == 10);
    assert( hds.size_of_faces() == 0);

}
Example #4
0
void test_HalfedgeDS_decorator() {
    // Simple instantiation of the default halfedge data structure.
    typedef CGAL_HALFEDGEDS_DEFAULT<Dummy_traits_2>  HDS;
    typedef CGAL::HalfedgeDS_decorator<HDS>          Decorator;
    typedef HDS::Halfedge_handle                     Halfedge_handle;
    typedef HDS::Face_handle                         Face_handle;
    HDS hds;
    Decorator  decorator(hds);
    // Check create single loop.
    Halfedge_handle h = decorator.create_loop();
    hds.normalize_border();
    assert( hds.size_of_vertices() == 1);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 4));

    // Restart with open segment.
    hds.clear();
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    h = decorator.create_segment();
    assert( hds.size_of_vertices() == 2);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 1);
    assert( decorator.is_valid( false, 4));

    // Create border edge and check normalization.
    decorator.set_face( h->opposite(), Face_handle());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 1);
    assert( hds.size_of_border_edges() == 1);
    assert( decorator.normalized_border_is_valid());
    decorator.set_face( h->opposite(), h->face());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 0);
    assert( hds.size_of_border_edges() == 0);
    assert( decorator.is_valid( false, 4));

    // Extend edge to two triangles.
    Halfedge_handle g = decorator.split_vertex( h, h);
    assert( decorator.is_valid( false, 4));
    assert( h != g);
    assert( h->next()->next() == g);
    assert( h == g->next()->next());
    assert( h->opposite() == g->next());
    assert( g->opposite() == h->next());
    Halfedge_handle g2 = decorator.split_face(h->opposite(),g->opposite());
    assert( decorator.is_valid( false, 4));
    assert( h->opposite()->next() == g2);
    assert( g2->next() == g);
    decorator.split_vertex( g2, g->opposite());
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    Halfedge_handle g3 = 
        decorator.split_face( g2->next()->opposite(), h);
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);
    assert( g3->next() == g->opposite());
    assert( g3->opposite()->next() == g2->opposite());
    assert( g3->opposite() == h->next());

    // Edge flip within the triangle.
    Halfedge_handle g4 = decorator.flip_edge( g3);
    assert( decorator.is_valid( false, 4));
    assert( g4 == g3);
    assert( g3->next()->next() == g2->opposite());
    assert( g3->opposite()->next() == h);
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);

    // Reverse face orientation.
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));

    // Check hole manipulations.
    decorator.make_hole(g);
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 4);
    assert( hds.size_of_border_edges() == 4);
    assert( decorator.is_valid( false, 4));

    // Reverse face orientation, deal also with the hole..
    decorator.inside_out();
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));

    // Check add_face_to_border.
    hds.clear();
    h = decorator.create_loop();
    decorator.make_hole( h->opposite());
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    decorator.add_face_to_border( h->opposite(), h->opposite());
    assert( hds.size_of_halfedges() == 4);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 3));
}
Example #5
0
void test_HalfedgeDS_decorator2() {
    // Instantiation of the halfedge data structure using vector
    // with max-bases for a polyhedral surface.
    typedef CGAL::HalfedgeDS_vector< Dummy_traits_3,
                                           CGAL::Polyhedron_items_3> HDS;
    typedef CGAL::HalfedgeDS_decorator<HDS> Decorator;
    typedef HDS::Halfedge_handle            Halfedge_handle;
    typedef HDS::Face_handle                Face_handle;
    HDS hds(4,10,3);
    Decorator  decorator(hds);
    // Check create single loop.
    Halfedge_handle h = decorator.create_loop();
    hds.normalize_border();
    assert( hds.size_of_vertices() == 1);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 2);
    assert( decorator.is_valid( false, 4));

    // Restart with open segment.
    hds.clear();
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    h = decorator.create_segment();
    assert( hds.size_of_vertices() == 2);
    assert( hds.size_of_halfedges() == 2);
    assert( hds.size_of_faces() == 1);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));

    // Create border edge and check normalization.
    decorator.set_face( h->opposite(), Face_handle());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 1);
    assert( hds.size_of_border_edges() == 1);
    assert( decorator.normalized_border_is_valid());
    decorator.set_face( h->opposite(), h->face());
    hds.normalize_border();
    assert( hds.size_of_border_halfedges() == 0);
    assert( hds.size_of_border_edges() == 0);
    assert( decorator.is_valid( false, 4));

    // Extend edge to two triangles.
    Halfedge_handle g = decorator.split_vertex( h, h);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( h != g);
    assert( h->next()->next() == g);
    assert( h == g->next()->next());
    assert( h->opposite() == g->next());
    assert( g->opposite() == h->next());
    Halfedge_handle g2 = decorator.split_face(h->opposite(),g->opposite());
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( h->opposite()->next() == g2);
    assert( g2->next() == g);
    decorator.split_vertex( g2, g->opposite());
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    Halfedge_handle g3 = 
        decorator.split_face( g2->next()->opposite(), h);
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);
    assert( g3->next() == g->opposite());
    assert( g3->opposite()->next() == g2->opposite());
    assert( g3->opposite() == h->next());

    // Edge flip within the triangle.
    Halfedge_handle g4 = decorator.flip_edge( g3);
    assert( decorator.is_valid( false, 3));
    hds.normalize_border();
    assert( decorator.is_valid( false, 4));
    assert( g4 == g3);
    assert( g3->next()->next() == g2->opposite());
    assert( g3->opposite()->next() == h);
    assert( g->next()->next()->next()->next() == g);
    assert( h->next()->next()->next() == h);
    assert( g3->next()->next()->next() == g3);

    // Reverse face orientation.
    decorator.inside_out();
    assert( decorator.is_valid( false, 4));
}
Example #6
0
int main(int argc, char *argv[]) {
    
    std::signal(SIGINT, sigHandler);

    // The image source to which the viewer will be attached
    std::vector<std::string> position_sources;
    std::string frame_source;
    std::string frame_sink;
    bool print_region = false;
    bool print_timestamp = false;
    bool print_sample_number = false;
    bool encode_sample_number = false;

    try {

        po::options_description options("INFO");
        options.add_options()
                ("help", "Produce help message.")
                ("version,v", "Print version information.")
                ;

        po::options_description configuration("CONFIGURATION");
        configuration.add_options()
                ("position-sources,p", po::value< std::vector<std::string> >()->multitoken(),
                "The name of position SOURCE(s) used to draw object position markers.\n")
                ("timestamp,t", "Write the current date and time on each frame.\n")
                ("sample,s", "Write the frame sample number on each frame.\n")
                ("sample-code,S", "Write the binary encoded sample on the corner of each frame.\n")
                ("region,R", "Write region information on each frame "
                "if there is a position stream that contains it.\n")
                ;

        po::options_description hidden("POSITIONAL OPTIONS");
        hidden.add_options() ("framesource", po::value<std::string>(&frame_source),
                "The name of the server that supplies images to decorate."
                "The server must be of type SMServer<SharedCVMatHeader>\n")
                ("framesink", po::value<std::string>(&frame_sink),
                "The name of the sink to which decorated images will be published."
                "The server must be of type SMServer<SharedCVMatHeader>\n")
                ;

        po::positional_options_description positional_options;

        // If not overridden by explicit --imagesource or --sink, 
        // last positional arguments are imagesource and sink in that order
        positional_options.add("framesource", 1);
        positional_options.add("framesink", 1);

        po::options_description visible_options("OPTIONS");
        visible_options.add(options).add(configuration);

        po::options_description all_options("ALL OPTIONS");
        all_options.add(visible_options).add(hidden);

        po::variables_map variable_map;
        po::store(po::command_line_parser(argc, argv)
                .options(all_options)
                .positional(positional_options)
                .run(),
                variable_map);
        po::notify(variable_map);

        // Use the parsed options
        if (variable_map.count("help")) {
            printUsage(visible_options);
            return 0;
        }

        if (variable_map.count("version")) {
            std::cout << "Oat Decorator, version " 
                      << Oat_VERSION_MAJOR
                      << "." 
                      << Oat_VERSION_MINOR 
                      << "\n";
            std::cout << "Written by Jonathan P. Newman in the MWL@MIT.\n";
            std::cout << "Licensed under the GPL3.0.\n";
            return 0;
        }

        if (!variable_map.count("framesource")) {
            printUsage(visible_options);
            std::cout <<  oat::Error("At least a single FRAME_SOURCE must be specified. \n");
            return -1;
        }

        if (!variable_map.count("framesink")) {
            printUsage(visible_options);
            std::cout <<  oat::Error("At least a single FRAME_SINK must be specified.\n");
            return -1;
        }
        
        if (variable_map.count("position-sources")) {
            position_sources = variable_map["position-sources"].as< std::vector<std::string> >();
        }

        if (variable_map.count("timestamp")) {
            print_timestamp = true;
        }

        if (variable_map.count("sample")) {
            print_sample_number = true;
        }

        if (variable_map.count("samplecode")) {
            encode_sample_number = true;
        }
        
        if (variable_map.count("region")) {
            print_region = true;
        }

    } catch (std::exception& e) {
        std::cerr << oat::Error(e.what()) << "\n";
        return -1;
    } catch (...) {
        std::cerr << oat::Error("Exception of unknown type.\n");
        return -1;
    }

    // Make the decorator
    Decorator decorator(position_sources, frame_source, frame_sink);
    decorator.set_print_timestamp(print_timestamp);
    decorator.set_print_sample_number(print_sample_number);
    decorator.set_encode_sample_number(encode_sample_number);
    decorator.set_print_region(print_region);
    
     // Tell user
    std::cout << oat::whoMessage(decorator.get_name(),
            "Listening to source " + oat::sourceText(frame_source) + ".\n")
            << oat::whoMessage(decorator.get_name(),
            "Steaming to sink " + oat::sinkText(frame_sink) + ".\n")
            << oat::whoMessage(decorator.get_name(),
            "Press CTRL+C to exit.\n");

    try {
        
        // Infinite loop until ctrl-c or end of stream signal
        run(&decorator);

        // Tell user
        std::cout << oat::whoMessage(decorator.get_name(), "Exiting.\n");

        // Exit
        return 0;

    } catch (const std::runtime_error ex) {
        std::cerr << oat::whoError(decorator.get_name(), ex.what()) << "\n";
    } catch (const cv::Exception ex) {
        std::cerr << oat::whoError(decorator.get_name(), ex.what()) << "\n";
    } catch (...) {
        std::cerr << oat::whoError(decorator.get_name(), "Unknown exception.\n");
    }

    // Exit failure
    return -1;
}
TEST_F(QueryDecoratorTest, IsExecWithLeadingSpaces)
{
    QueryDecorator decorator(kExecWithLeadingSpaces);
    EXPECT_FALSE(decorator.IsSelectQuery());
    EXPECT_TRUE(decorator.IsExecQuery());
}
TEST_F(QueryDecoratorTest, IsExec)
{
    QueryDecorator decorator(kExec);
    EXPECT_FALSE(decorator.IsSelectQuery());
    EXPECT_TRUE(decorator.IsExecQuery());
}
TEST_F(QueryDecoratorTest, Delete)
{
    QueryDecorator decorator(kDelete);
    EXPECT_STREQ(kDelete, decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, ExecWithoutLimit)
{
    QueryDecorator decorator(kExec);
    EXPECT_STREQ(kExec, decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, SelectWithZeroLimitAndNonZeroOffset)
{
    QueryDecorator decorator(kSelect, 0, 10, true);
    EXPECT_STREQ(L"SELECT TOP 0 * from Table", decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, SelectWithLimitAndLeadingSpaces)
{
    QueryDecorator decorator(kSelectWithLeadingSpaces, 10, 0, true);
    EXPECT_STREQ(L"SELECT TOP 10 * from Table", decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, SelectWithoutLimit)
{
    QueryDecorator decorator(kSelect);
    EXPECT_STREQ(kSelect, decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, DeleteWithLimitAndOffset)
{
    QueryDecorator decorator(kDelete, 10, 10, true);
    EXPECT_STREQ(kDelete, decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, IsNotExecAndNotSelect)
{
    QueryDecorator decorator(kDelete);
    EXPECT_FALSE(decorator.IsSelectQuery());
    EXPECT_FALSE(decorator.IsExecQuery());
}
TEST_F(QueryDecoratorTest, ExecWithoutLimitWithLeadingSpaces)
{
    QueryDecorator decorator(kExecWithLeadingSpaces);
    EXPECT_STREQ(kExec, decorator.GetQuery());
}
TEST_F(QueryDecoratorTest, ExecWithLimitAndOffset)
{
    QueryDecorator decorator(kExec, 10, 10, true);
    EXPECT_STREQ(kExec, decorator.GetQuery());
}