Ejemplo n.º 1
0
void GSRasterizer::DrawTriangleBottom(GSVertexSW* v, const GSVector4i& scissor)
{
	GSVertexSW longest;
	
	longest.p = v[1].p - v[0].p;

	int i = (longest.p > GSVector4::zero()).upl(longest.p == GSVector4::zero()).mask();

	if(i & 2) return;

	i &= 1;

	GSVertexSW& l = v[1 - i];
	GSVector4& r = v[i].p;

	GSVector4i tb(l.p.xyxy(v[2].p).ceil());

	int top = tb.extract32<1>();
	int bottom = tb.extract32<3>();

	if(top < scissor.y) top = scissor.y;
	if(bottom > scissor.w) bottom = scissor.w;
	if(top >= bottom) return;

	longest.t = v[1].t - v[0].t;
	longest.c = v[1].c - v[0].c;

	GSVertexSW dscan = longest * longest.p.xxxx().rcp();

	GSVertexSW vl = v[2] - l;
	GSVector4 vr = v[2].p - r;

	GSVertexSW dl = vl / vl.p.yyyy();
	GSVector4 dr = vr / vr.yyyy();

	float py = (float)top - l.p.y;

	l.p = l.p.upl(r).xyzw(l.p); // r.x => l.y
	dl.p = dl.p.upl(dr).xyzw(dl.p); // dr.x => dl.y

	if(py > 0) l += dl * py;

	(m_ds->*m_dsf.sp)(v, dscan);
	// TODO: (m_dsf.ssp)(v, dscan);

	DrawTriangleSection(top, bottom, l, dl, dscan, scissor);
}
Ejemplo n.º 2
0
bool StreamReader::rwSync()
{
  AVPacket pkt;
  av_init_packet(&pkt);

  int res = ff.read_frame(&pkt);
  if (res >= 0)
    {
      /*copy contents*/
      auto avpkt = std::make_shared<av::Packet> (&pkt);
      av::Rational tb(*ff.get_timebase());
      avpkt->setTimeBase(tb);
      assert(avpkt->getSize() > 0);
      file_pkt_q->writeSync(avpkt);
    }
  return res >= 0;
}
Ejemplo n.º 3
0
std::wstring PyError::get_python_error_description()
{
	std::wstring ret = L"Unfetchable Python error";

	PyObject *type_ptr = NULL, *value_ptr = NULL, *traceback_ptr = NULL;
    PyErr_Fetch(&type_ptr, &value_ptr, &traceback_ptr);
    
	if(type_ptr != NULL)
	{
		py::handle<> h_type(type_ptr);
		py::str type_pstr(h_type);
		py::extract<std::wstring> e_type_pstr(type_pstr);
		if(e_type_pstr.check())
			ret = e_type_pstr();
		else
			ret = L"Unknown exception type";
	}

	if(value_ptr != NULL)
	{
		py::handle<> h_val(value_ptr);
		py::str a(h_val);
		py::extract<std::wstring> returned(a);
		if(returned.check())
			ret +=  L": " + returned();
		else
			ret += L": Unparseable Python error: ";
	}

	if(traceback_ptr != NULL)
	{
		py::handle<> h_tb(traceback_ptr);
		py::object tb(py::import("traceback"));
		py::object fmt_tb(tb.attr("format_tb"));
		py::object tb_list(fmt_tb(h_tb));
		py::object tb_str(py::str("\n").join(tb_list));
		py::extract<std::wstring> returned(tb_str);
		if(returned.check())
			ret += L": " + returned();
		else
			ret += L": Unparseable Python traceback";
	}

	return ret;
}
Ejemplo n.º 4
0
clToolBar* CodeFormatter::CreateToolBar(wxWindow* parent)
{
    clToolBar* tb(NULL);
    if(m_mgr->AllowToolbar()) {
        // support both toolbars icon size
        int size = m_mgr->GetToolbarIconSize();

        tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE_PLUGIN);
        tb->SetToolBitmapSize(wxSize(size, size));

        BitmapLoader* bmpLoader = m_mgr->GetStdIcons();
        tb->AddTool(XRCID("format_source"),
                    _("Format Source"),
                    bmpLoader->LoadBitmap("format", size),
                    _("Format Source Code"));
        tb->AddTool(XRCID("formatter_options"),
                    _("Format Options"),
                    bmpLoader->LoadBitmap("cog", size),
                    _("Source Code Formatter Options..."));
        tb->Realize();
    }

    // Connect the events to us
    m_mgr->GetTheApp()->Connect(XRCID("format_source"),
                                wxEVT_COMMAND_MENU_SELECTED,
                                wxCommandEventHandler(CodeFormatter::OnFormat),
                                NULL,
                                (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(XRCID("formatter_options"),
                                wxEVT_COMMAND_MENU_SELECTED,
                                wxCommandEventHandler(CodeFormatter::OnFormatOptions),
                                NULL,
                                (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(XRCID("format_source"),
                                wxEVT_UPDATE_UI,
                                wxUpdateUIEventHandler(CodeFormatter::OnFormatUI),
                                NULL,
                                (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(XRCID("formatter_options"),
                                wxEVT_UPDATE_UI,
                                wxUpdateUIEventHandler(CodeFormatter::OnFormatOptionsUI),
                                NULL,
                                (wxEvtHandler*)this);
    return tb;
}
Ejemplo n.º 5
0
//Start and end must be local to the modle
bool BasicBlockCoverage::addTranslationBlock(uint64_t ts, uint64_t start, uint64_t end)
{
    Block tb(ts, start, end);
    Blocks::iterator it = m_uniqueTbs.find(tb);

    if (it == m_uniqueTbs.end()) {
        m_uniqueTbs.insert(tb);
        return true;
    }else {
        if ((*it).timeStamp > ts) {
            m_uniqueTbs.erase(*it);
            m_uniqueTbs.insert(tb);
            return true;
        }
    }

    return false;
}
Ejemplo n.º 6
0
clToolBar* DatabaseExplorer::CreateToolBar(wxWindow* parent)
{
    // Create the toolbar to be used by the plugin
    clToolBar* tb(NULL);

    /*
            // You can use the below code a snippet:
            // First, check that CodeLite allows plugin to register plugins
            if (m_mgr->AllowToolbar()) {
                    // Support both toolbars icon size
                    int size = m_mgr->GetToolbarIconSize();

                    // Allocate new toolbar, which will be freed later by CodeLite
                    tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);

                    // Set the toolbar size
                    tb->SetToolBitmapSize(wxSize(size, size));

                    // Add tools to the plugins toolbar. You must provide 2 sets of icons: 24x24 and 16x16
                    if (size == 24) {
                            tb->AddTool(XRCID("new_plugin"), wxT("New CodeLite Plugin Project"),
       wxXmlResource::Get()->LoadBitmap(wxT("plugin24")), wxT("New Plugin Wizard..."));
                            tb->AddTool(XRCID("new_class"), wxT("Create New Class"),
       wxXmlResource::Get()->LoadBitmap(wxT("class24")), wxT("New Class..."));
                            tb->AddTool(XRCID("new_wx_project"), wxT("New wxWidget Project"),
       wxXmlResource::Get()->LoadBitmap(wxT("new_wx_project24")), wxT("New wxWidget Project"));
                    } else {
                            tb->AddTool(XRCID("new_plugin"), wxT("New CodeLite Plugin Project"),
       wxXmlResource::Get()->LoadBitmap(wxT("plugin16")), wxT("New Plugin Wizard..."));
                            tb->AddTool(XRCID("new_class"), wxT("Create New Class"),
       wxXmlResource::Get()->LoadBitmap(wxT("class16")), wxT("New Class..."));
                            tb->AddTool(XRCID("new_wx_project"), wxT("New wxWidget Project"),
       wxXmlResource::Get()->LoadBitmap(wxT("new_wx_project16")), wxT("New wxWidget Project"));
                    }
                    // And finally, we must call 'Realize()'
                    tb->Realize();
            }

            // return the toolbar, it can be NULL if CodeLite does not allow plugins to register toolbars
            // or in case the plugin simply does not require toolbar
    */
    return tb;
}
Ejemplo n.º 7
0
clToolBar *WizardsPlugin::CreateToolBar(wxWindow *parent)
{
    clToolBar *tb(NULL);
//	if (m_mgr->AllowToolbar()) {
//		//support both toolbars icon size
//		int size = m_mgr->GetToolbarIconSize();
//
//
//		tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
//		tb->SetToolBitmapSize(wxSize(size, size));
//
//		if (size == 24) {
//			tb->AddTool(XRCID("gizmos_options"), wxT("Gizmos..."), wxXmlResource::Get()->LoadBitmap(wxT("plugin24")), wxT("Open Gizmos quick menu"));
//		} else {
//			tb->AddTool(XRCID("gizmos_options"), wxT("Gizmos..."), wxXmlResource::Get()->LoadBitmap(wxT("plugin16")), wxT("Open Gizmos quick menu"));
//		}
//
//		// When using AUI, make this toolitem a dropdown button
//#if USE_AUI_TOOLBAR
//		tb->SetToolDropDown(XRCID("gizmos_options"), true);
//		m_mgr->GetTheApp()->Connect(XRCID("gizmos_options"), wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, wxAuiToolBarEventHandler(WizardsPlugin::OnGizmosAUI), NULL, (wxEvtHandler*)this);
//#endif
//		tb->Realize();
//	}
//
    //Connect the events to us
#if !USE_AUI_TOOLBAR
    m_mgr->GetTheApp()->Connect(XRCID("gizmos_options"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WizardsPlugin::OnGizmos   ), NULL, (wxEvtHandler*)this);
#endif
    m_mgr->GetTheApp()->Connect(XRCID("gizmos_options"), wxEVT_UPDATE_UI,             wxUpdateUIEventHandler(WizardsPlugin::OnGizmosUI), NULL, (wxEvtHandler*)this);

    m_mgr->GetTheApp()->Connect(ID_MI_NEW_CODELITE_PLUGIN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WizardsPlugin::OnNewPlugin), NULL, (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(ID_MI_NEW_CODELITE_PLUGIN, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(WizardsPlugin::OnNewPluginUI), NULL, (wxEvtHandler*)this);


    m_mgr->GetTheApp()->Connect(ID_MI_NEW_NEW_CLASS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WizardsPlugin::OnNewClass), NULL, (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(ID_MI_NEW_NEW_CLASS, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(WizardsPlugin::OnNewClassUI), NULL, (wxEvtHandler*)this);

    m_mgr->GetTheApp()->Connect(ID_MI_NEW_WX_PROJECT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WizardsPlugin::OnNewWxProject), NULL, (wxEvtHandler*)this);
    m_mgr->GetTheApp()->Connect(ID_MI_NEW_WX_PROJECT, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(WizardsPlugin::OnNewWxProjectUI), NULL, (wxEvtHandler*)this);
    return tb;
}
Ejemplo n.º 8
0
int CallableData::__getindex(Executor& ewsl,const String& si)
{

	CallableMetatable* metax=GetMetaTable();
	if(metax)
	{
		ewsl.ci1.nbp[StackState1::SBASE_META].reset(this);

		VariantTable& tb(metax->table_meta);
		int id=tb.find1(si);
		if(id>=0)
		{
			(*ewsl.ci1.nsp)=tb.get(id).second;
			return 1;
		}	
	}

	ewsl.kerror(String::Format("getindex FAILED! Class has no index:%s",si));
	return INVALID_CALL;
}
Ejemplo n.º 9
0
static void computeBitmaps(cv::Mat src, cv::Mat& _tb, cv::Mat& _eb)
{
  int histogram[256] = {0};
  cv::Size size = src.size();
  
  for (int i = 0; i < size.height; i++) {
    for (int j = 0; j < size.width; j++) {
      int c = (unsigned int) src.at<uchar>(i, j);
      histogram[c] += 1;
    }
  }
  
  int median_counter = size.height * size.width / 2, threshold = 0;
  for (int i = 0; i < 256; ++i) {
    median_counter += histogram[i];
    if (median_counter - histogram[i] > 0) {
      median_counter -= histogram[i];
    } else {
      threshold = i;
      break;
    }
  }
  
  cv::Mat_<uchar> tb(size);
  for (int i = 0; i < size.height; ++i) {
    for (int j = 0; j < size.width; ++j) {
      bool cond = src.at<uchar>(i, j) <= threshold;
      tb.at<uchar>(i, j) = (cond ? 0 : 1);
    }
  }
  _tb = tb;
  
  cv::Mat_<uchar> eb(size);
  for (int i = 0; i < size.height; ++i) {
    for (int j = 0; j < size.width; ++j) {
      bool cond = std::abs(src.at<uchar>(i, j) - threshold) <= 4;
      eb.at<uchar>(i, j) = (cond ? 0 : 1);
    }
  }
  _eb = eb;
}
Ejemplo n.º 10
0
std::string Volume::getDataInfo() const {
    using P = Document::PathComponent;
    using H = utildoc::TableBuilder::Header;
    Document doc;
    doc.append("b", "Volume", { {"style", "color:white;"} });
    utildoc::TableBuilder tb(doc.handle(), P::end());

    tb(H("Format"), getDataFormat()->getString());
    tb(H("Dimension"), getDimensions());
    tb(H("Data Range"), dataMap_.dataRange);
    tb(H("Value Range"), dataMap_.valueRange);
    tb(H("Unit"), dataMap_.valueUnit);

    if (hasRepresentation<VolumeRAM>()) {
        auto volumeRAM = getRepresentation<VolumeRAM>();
        if (volumeRAM->hasHistograms()) {
            auto histograms = volumeRAM->getHistograms();
            for (size_t i = 0; i < histograms->size(); ++i) {
                std::stringstream ss;
                ss << "Channel " << i << " Min: " << (*histograms)[i].stats_.min
                    << " Mean: " << (*histograms)[i].stats_.mean
                    << " Max: " << (*histograms)[i].stats_.max
                    << " Std: " << (*histograms)[i].stats_.standardDeviation;
                tb(H("Stats"), ss.str());

                std::stringstream ss2;
                ss2 << "(1: " << (*histograms)[i].stats_.percentiles[1]
                    << ", 25: " << (*histograms)[i].stats_.percentiles[25]
                    << ", 50: " << (*histograms)[i].stats_.percentiles[50]
                    << ", 75: " << (*histograms)[i].stats_.percentiles[75]
                    << ", 99: " << (*histograms)[i].stats_.percentiles[99] << ")";
                tb(H("Percentiles"), ss2.str());
            }
        }
    }
    return doc;
}
Ejemplo n.º 11
0
// if pmret is true, the code executed in this frame
// should return to the pm state held on the top of the stack
// ow, it(ie the pm_evaluate loop executing the code) should return to its C caller 
Pm_state2 Pm_stack_push(Pm_stack2 st,Dblock db,int pmret)
{
	Pm_state2 cf,nfr;
	Dblock nfdb;
	char *nf;
	int fsz,nmo,nmi,nmd,dbdsz,nfsz,stsz,numfr;
	nmo = db -> numobs;
	nmi = db -> numints;
	nmd = db -> numdoubles;
	dbdsz = 4 * (nmo+nmi) + 8 * nmd;
    nfsz = sizeof(Pm_state_struct) + dbdsz;
	cf = st -> c_frame;
	numfr = st->num_frames;
    if (numfr)
		nf = ((char*)cf) + (cf->size);
	else
		nf = cf;
    stsz =  nfsz + ((char*)cf)-((char*)st);
	if (stsz > ((st->size)-Pm_stack_overflow_buffer_size)) 
	{
		printf("DBLOCK STACK OVERFLOW\n");
		tb();
		reset_console_stack();
//		um_reset();
	}

    nfr = (Pm_state2)nf;
	nfr -> prev_frame1 = (void*)cf;
	nfr -> return_to_C = !pmret;
	nfr -> size = nfsz;
	nfr -> stack = (void*)st;
	nfr -> pc = 0;
	nfdb = &(nfr->dblock);
	memcpy((char*)nfdb,(char*)db,dbdsz + sizeof(Dblock_struct));
	nfdb -> in_stack = 1;
    st -> c_frame = nfr;
	st -> num_frames = numfr+1;
	return nfr;
}
Ejemplo n.º 12
0
TextureReader::image_::image_( const TextureReader::image_options& o ) : image( &o.filename[0] )
{
    texture.setImage( image );
    material.setTexture( &texture );
    comma::uint32 width = o.pixel_size ? *o.pixel_size * image.width() : o.width;
    comma::uint32 height = o.pixel_size ? *o.pixel_size * image.height() : o.height;
    if( width == 0 ) { COMMA_THROW( comma::exception, "got zero width for image " << o.filename ); }
    if( height == 0 ) { COMMA_THROW( comma::exception, "got zero height for image " << o.filename ); }
    QVector3D a( 0, 0, 0 );
    QVector3D b( width, 0, 0 );
    QVector3D c( width, height, 0 );
    QVector3D d( 0, height, 0 );
    QVector2D ta( 0, 0 );
    QVector2D tb( 1, 0 );
    QVector2D tc( 1, 1 );
    QVector2D td( 0, 1 );
    geometry.appendVertex( a, b, c, d );
    geometry.appendTexCoord(ta, tb, tc, td);
    builder.addQuads( geometry );
    node = builder.finalizedSceneNode();
    node->setMaterial( &material );
}
Ejemplo n.º 13
0
int sc_main(int, char *argv[])
{
	sc_clock			clock("clock");
	DUT					dut("dut");
	sc_rvd<sc_uint<8> >	dut_to_tb;
	sc_rvd<sc_uint<8> >	tb_to_dut;
	sc_signal<bool>		reset;
	TB_DUT				tb("tb");
	sc_trace_file 		*tf;

	dut.m_clk(clock);
	dut.m_reset(reset);
	dut.m_input(tb_to_dut);
	dut.m_output(dut_to_tb);

	tb.m_clk(clock);
	tb.m_reset(reset);
	tb.m_from_dut(dut_to_tb);
	tb.m_to_dut(tb_to_dut);


	tf = sc_create_vcd_trace_file("../results/wave");
	sc_trace(tf, clock, "clk");
	sc_trace(tf, dut_to_tb.m_data, "data_d");
	sc_trace(tf, dut_to_tb.m_ready, "ready_d");
	sc_trace(tf, dut_to_tb.m_valid, "valid_d");
	sc_trace(tf, tb_to_dut.m_data, "data_t");
	sc_trace(tf, tb_to_dut.m_ready, "ready_t");
	sc_trace(tf, tb_to_dut.m_valid, "valid_t");
	
	std::cout << "producer dut consumer" << endl;
	reset = false;
	sc_start(1, SC_NS);
	reset = true;
	sc_start();
	std::cout << "program completed" << endl;

	return 0;
}
Ejemplo n.º 14
0
void testWRDefaultValue(database* db, bool timestampNull)
{
    try
    {
        activeTable tb(db, _T("nulltest"));
        writableRecord& wr = tb.getWritableRecord();
        wr.clear();
        if (timestampNull)
        {
            for (short i = 0 ;i < (short)wr.size(); ++i)
            {
                bool v = true;
                int dv = 0;
                if (i == 0 || i == 5 || i == 6) v = false;
                BOOST_CHECK_MESSAGE(wr[i].isNull() == v, "testWRDefaultValue isNull field num = " << i);
                if (i == 5) dv = -1;
                    
                if (i == 6) dv = -123456;
                BOOST_CHECK_MESSAGE(wr[i].i() == dv, "testWRDefaultValue defaultValue field num = " 
                        << i << " " << wr[i].i());
            }
        }else
        {
            int dfs[13] = {0, 0, 0, 0, 0, -1, -123456, 0, 3, 0, 0, 1, 0};
            for (short i = 1 ;i < (short)wr.size(); ++i)
            {
                BOOST_CHECK_MESSAGE(wr[i].isNull() == (dfs[i] == 0), "testWRDefaultValue isNull field num = " << i);
                if ((dfs[i] < 0))
                    BOOST_CHECK_MESSAGE(wr[i].i() == dfs[i], "testWRDefaultValue isNull field num = " << i);
                else if ((dfs[i]  < 3))
                    BOOST_CHECK_MESSAGE(wr[i].i64() == 0, "testWRDefaultValue isNull field num = " << i);
            }
        }
    }
    catch (bzs::rtl::exception& e)
    {
        _tprintf(_T("Error ! %s\n"), (*getMsg(e)).c_str());
    }
}
Ejemplo n.º 15
0
// Forward Gnuplot error messages to DDD status line
static void SetStatusHP(Agent *, void *client_data, void *call_data)
{
    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;
    DataLength* dl = (DataLength *) call_data;
    string s(dl->data, dl->length);

    (void) plot;		// Use it
#if 0
    if (!plot->active)
    {
	// Probably an invocation problem
	post_gdb_message(s);
	return;
    }
#endif

    if (plot->command != 0)
    {
	string msg = s;
	strip_space(msg);
	MString xmsg = tb(msg);
	XmCommandError(plot->command, xmsg.xmstring());
    }

    while (!s.empty())
    {
	string line;
	if (s.contains('\n'))
	    line = s.before('\n');
	else
	    line = s;
	s = s.after('\n');
	strip_space(line);

	if (!line.empty())
	    set_status(line);
    }
}
Ejemplo n.º 16
0
HTREEITEM COverlayPanel::drawOverlayList(ICompositeOverlay *coll, HTREEITEM parent, const IOverlay *selected, TVINSERTSTRUCT &itvIns)
{
	HTREEITEM selectItem = NULL;

	short max;
	coll->Count(&max);
	for (int i=0; i<max; i++)
	{
		IOverlay *pOverlay;
		coll->Item(CComVariant(i), &pOverlay);
		itvIns.hParent = parent;
		BSTR name;
		pOverlay->get_Name(&name);
		_bstr_t tb(name, false);
		itvIns.itemex.pszText = (char*)tb;
		itvIns.itemex.cchTextMax = strlen(itvIns.itemex.pszText)+1;
		itvIns.itemex.lParam = (LPARAM)pOverlay;
		HTREEITEM h = (HTREEITEM)SendDlgItemMessage(IDC_COMBO_OVERLAY,TVM_INSERTITEM,0,(LPARAM)&itvIns);
		ICompositeOverlay *pCO = NULL;
		HRESULT hr = pOverlay->QueryInterface(__uuidof(ICompositeOverlay), (void **)&pCO);
		if (SUCCEEDED(hr))
		{
			pCO->Release();
			HTREEITEM sel = drawOverlayList((ICompositeOverlay*)pOverlay, h, selected, itvIns);
			if (sel != NULL)
				selectItem = sel;

			SendDlgItemMessage(IDC_COMBO_OVERLAY,TVM_EXPAND,(WPARAM)TVE_EXPAND,(LPARAM)h);
		}

		if (pOverlay == selected)
			selectItem = h;

		pOverlay->Release();
	}

	return selectItem;
}
Ejemplo n.º 17
0
int sc_main(int argc, char* argv[]){

	sc_time PERIOD(10,SC_NS); // NS, SEC, SC
	sc_time DELAY(10,SC_NS);
	sc_clock clock("clock", PERIOD, 0.5, DELAY, true);

	Not_Gate ag1("ag1");
	TestBench tb("tb");

	sc_signal<bool> a_sg, z_sg;

	ag1.a_in(a_sg);
	ag1.z_out(z_sg);

	tb.clk_in(clock);

	tb.a_out(a_sg);
	tb.z_in(z_sg);

	sc_start();

	return 0;
}
Mesh PetitEtageBusiness::generate() const
{
        MeshBuilder mb;
        Mesh pebMesh = mb.generationEtage(this);
        QVector<std::pair<Batiment*,int>> bats;

        ToitBusiness tb(base, hauteur+hauteurEtage, hauteurEtage, hMax, shrinkMax, aireMin);
        EtageBusiness eb(base, hauteur+hauteurEtage, hauteurEtage, hMax-1, shrinkMax, aireMin);
        Division d(base, hauteur+hauteurEtage, hauteurEtage, hMax-1, shrinkMax-1, aireMin);
        bats.append(std::make_pair(&tb, 2));

        if(hMax > 1)
        {
            bats.append(std::make_pair(&eb, 70));
            if(shrinkMax > 0 && d.getPoly1().area()>aireMin && d.getPoly2().area() > aireMin)
            {
                bats.append(std::make_pair(&d, 10));
            }
        }

        pebMesh.merge(getRandomBatiment(bats)->generate());
    return pebMesh;
}
Ejemplo n.º 19
0
void API_Create_Index(IndexStruct I)
{
	Index idx(I.index_name);
	idx.initializeIndex(&I);
	idx.createIndex();

	Table tb(I.table_name);
	tb.getTableInfo();
	//Catalog do
	Tuple tpl(I.table_name);
	Attribute at = tb.getAttr(I.attr_name);
	tpl.FetchAll(at.attr_id);
	int listSize = TupleList_IDX.size();
	IndexInfo idxInfo;
	idxInfo.attr_size = at.attr_len;
	idxInfo.indexname = I.index_name;
	idxInfo.maxKeyNum = (4096 - 4 - INDEX_BLOCK_INFO) / (4+at.attr_len);
	Create_Index(idxInfo);
	cout << "Query OK, " << listSize;
	if (listSize!=1)cout << " rows affected." << endl;
	else cout << " row affected." << endl;
	//Index do
}
Ejemplo n.º 20
0
// demo shows a timed demonstration
void demo(int w, int h, int sec) {
	refcard(w, h);
	sleep(sec);
	rshapes(w, h, 50);
	sleep(sec);
	testpattern(w, h, "OpenVG on RasPi");
	sleep(sec);
	imagetable(w, h);
	sleep(sec);
	rotext(w, h, 30, "Raspi");
	sleep(sec);
	tb(w, h);
	sleep(sec);
	fontrange(w, h);
	sleep(sec);
	sunearth(w, h);
	sleep(sec);
	raspi(w, h, "The Raspberry Pi");
	sleep(sec);
	gradient(w,h);
	sleep(sec);
	advert(w, h);
}
Ejemplo n.º 21
0
clToolBar *CallGraph::CreateToolBar(wxWindow *parent)
{
    //Create the toolbar to be used by the plugin
    clToolBar *tb(NULL);

    // First, check that CodeLite allows plugin to register plugins
    if (m_mgr->AllowToolbar()) {
        // Support both toolbars icon size
        int size = m_mgr->GetToolbarIconSize();

        // Allocate new toolbar, which will be freed later by CodeLite
        tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);

        // Set the toolbar size
        tb->SetToolBitmapSize(wxSize(size, size));

        // Add tools to the plugins toolbar. You must provide 2 sets of icons: 24x24 and 16x16
        BitmapLoader *bmpLoader = m_mgr->GetStdIcons();

        if (size == 24) {
            tb->AddTool(XRCID("cg_show_callgraph"),
                        _("Show call graph"),
                        bmpLoader->LoadBitmap(wxT("callgraph/24/cg")),
                        _("Show call graph for selected/active project"),
                        wxITEM_NORMAL);
        } else {
            tb->AddTool(XRCID("cg_show_callgraph"),
                        _("Show call graph"),
                        bmpLoader->LoadBitmap(wxT("callgraph/16/cg")),
                        _("Show call graph for selected/active project"),
                        wxITEM_NORMAL);
        }
        tb->Realize();
    }
    return tb;
}
Ejemplo n.º 22
0
// Doc in parent
void
SoVRMLIndexedFaceSet::generatePrimitives(SoAction * action)
{
  if (this->coordIndex.getNum() < 3) return;

  SoState * state = action->getState();

  state->push();
  SoVRMLVertexShape::doAction(action);

  Binding mbind = this->findMaterialBinding(state);
  Binding nbind = this->findNormalBinding(state);

  const SoCoordinateElement * coords;
  const SbVec3f * normals;
  const int32_t * cindices;
  int numindices;
  const int32_t * nindices;
  const int32_t * tindices;
  const int32_t * mindices;
  SbBool doTextures;
  SbBool sendNormals;
  SbBool normalCacheUsed;

  sendNormals = TRUE; // always generate normals

  this->getVertexData(state, coords, normals, cindices,
                      nindices, tindices, mindices, numindices,
                      sendNormals, normalCacheUsed);

  if (!sendNormals) {
    nbind = OVERALL;
    normals = NULL;
    nindices = NULL;
  }
  else if (normalCacheUsed && nbind == PER_VERTEX) {
    nbind = PER_VERTEX_INDEXED;
  }
  else if (normalCacheUsed && nbind == PER_FACE_INDEXED) {
    nbind = PER_FACE;
  }

  if (mbind == PER_VERTEX) {
    mbind = PER_VERTEX_INDEXED;
    mindices = cindices;
  }
  if (nbind == PER_VERTEX) {
    nbind = PER_VERTEX_INDEXED;
    nindices = cindices;
  }

  SoTextureCoordinateBundle tb(action, FALSE, FALSE);
  doTextures = tb.needCoordinates();

  Binding tbind = NONE;
  if (doTextures) {
    if (tb.isFunction() && !tb.needIndices()) {
      tbind = NONE;
      tindices = NULL;
    }
    else {
      tbind = PER_VERTEX_INDEXED;
      if (tindices == NULL) tindices = cindices;
    }
  }
  
  SbBool convexcacheused = FALSE;
  if (this->useConvexCache(action, normals, nindices, normalCacheUsed)) {
    cindices = PRIVATE(this)->convexCache->getCoordIndices();
    numindices = PRIVATE(this)->convexCache->getNumCoordIndices();
    mindices = PRIVATE(this)->convexCache->getMaterialIndices();
    nindices = PRIVATE(this)->convexCache->getNormalIndices();
    tindices = PRIVATE(this)->convexCache->getTexIndices();

    if (mbind == PER_VERTEX) mbind = PER_VERTEX_INDEXED;
    else if (mbind == PER_FACE) mbind = PER_FACE_INDEXED;
    if (nbind == PER_VERTEX) nbind = PER_VERTEX_INDEXED;
    else if (nbind == PER_FACE) nbind = PER_FACE_INDEXED;

    if (tbind != NONE) tbind = PER_VERTEX_INDEXED;
    convexcacheused = TRUE;
  }

  int texidx = 0;
  TriangleShape mode = POLYGON;
  TriangleShape newmode;
  const int32_t *viptr = cindices;
  const int32_t *viendptr = viptr + numindices;
  int32_t v1, v2, v3, v4, v5 = 0; // v5 init unnecessary, but kills a compiler warning.

  SoPrimitiveVertex vertex;
  SoPointDetail pointDetail;
  SoFaceDetail faceDetail;

  vertex.setDetail(&pointDetail);

  SbVec3f dummynormal(0,0,1);
  const SbVec3f *currnormal = &dummynormal;
  if (normals) currnormal = normals;
  vertex.setNormal(*currnormal);

  int matnr = 0;
  int normnr = 0;

  while (viptr + 2 < viendptr) {
    v1 = *viptr++;
    v2 = *viptr++;
    v3 = *viptr++;
    assert(v1 >= 0 && v2 >= 0 && v3 >= 0);
    v4 = viptr < viendptr ? *viptr++ : -1;
    if (v4  < 0) newmode = TRIANGLES;
    else {
      v5 = viptr < viendptr ? *viptr++ : -1;
      if (v5 < 0) newmode = QUADS;
      else newmode = POLYGON;
    }
    if (newmode != mode) {
      if (mode != POLYGON) this->endShape();
      mode = newmode;
      this->beginShape(action, mode, &faceDetail);
    }
    else if (mode == POLYGON) this->beginShape(action, POLYGON, &faceDetail);

    // vertex 1 can't use DO_VERTEX
    if (mbind == PER_VERTEX || mbind == PER_FACE) {
      pointDetail.setMaterialIndex(matnr);
      vertex.setMaterialIndex(matnr++);
    }
    else if (mbind == PER_VERTEX_INDEXED || mbind == PER_FACE_INDEXED) {
      pointDetail.setMaterialIndex(*mindices);
      vertex.setMaterialIndex(*mindices++);
    }
    if (nbind == PER_VERTEX || nbind == PER_FACE) {
      pointDetail.setNormalIndex(normnr);
      currnormal = &normals[normnr++];
      vertex.setNormal(*currnormal);
    }
    else if (nbind == PER_FACE_INDEXED || nbind == PER_VERTEX_INDEXED) {
      pointDetail.setNormalIndex(*nindices);
      currnormal = &normals[*nindices++];
      vertex.setNormal(*currnormal);
    }

    if (tb.isFunction()) {
      vertex.setTextureCoords(tb.get(coords->get3(v1), *currnormal));
      if (tb.needIndices()) pointDetail.setTextureCoordIndex(tindices ? *tindices++ : texidx++);
    }
    else if (tbind != NONE) {
      pointDetail.setTextureCoordIndex(tindices ? *tindices : texidx);
      vertex.setTextureCoords(tb.get(tindices ? *tindices++ : texidx++));
    }
    pointDetail.setCoordinateIndex(v1);
    vertex.setPoint(coords->get3(v1));
    this->shapeVertex(&vertex);

    DO_VERTEX(v2);
    DO_VERTEX(v3);

    if (mode != TRIANGLES) {
      DO_VERTEX(v4);
      if (mode == POLYGON) {
        DO_VERTEX(v5);
        v1 = viptr < viendptr ? *viptr++ : -1;
        while (v1 >= 0) {
          DO_VERTEX(v1);
          v1 = viptr < viendptr ? *viptr++ : -1;
        }
        this->endShape();
      }
    }
    faceDetail.incFaceIndex();
    if (mbind == PER_VERTEX_INDEXED) {
      mindices++;
    }
    if (nbind == PER_VERTEX_INDEXED) {
      nindices++;
    }
    if (tindices) tindices++;
  }
  if (mode != POLYGON) this->endShape();

  if (normalCacheUsed) {
    this->readUnlockNormalCache();
  }
  if (convexcacheused) {
    PRIVATE(this)->readUnlockConvexCache();
  }
  state->pop();
}
Ejemplo n.º 23
0
// Doc in parent
void
SoVRMLIndexedFaceSet::GLRender(SoGLRenderAction * action)
{
  if (this->coordIndex.getNum() < 3 || this->coord.getValue() == NULL) return;
  SoState * state = action->getState();

  state->push();
  // update state with coordinates, normals and texture information
  SoVRMLVertexShape::GLRender(action);

  if (!this->shouldGLRender(action)) { 
    state->pop();
    return;
  }

  this->setupShapeHints(state, this->ccw.getValue(), this->solid.getValue());

  Binding mbind = this->findMaterialBinding(state);
  Binding nbind = this->findNormalBinding(state);

  const SoCoordinateElement * coords;
  const SbVec3f * normals;
  const int32_t * cindices;
  int numindices;
  const int32_t * nindices;
  const int32_t * tindices;
  const int32_t * mindices;
  SbBool doTextures;
  SbBool normalCacheUsed;
  SoMaterialBundle mb(action);
  SoTextureCoordinateBundle tb(action, TRUE, FALSE);
  doTextures = tb.needCoordinates();

  SbBool sendNormals = !mb.isColorOnly() || tb.isFunction();

  this->getVertexData(state, coords, normals, cindices,
                      nindices, tindices, mindices, numindices,
                      sendNormals, normalCacheUsed);

  if (!sendNormals) {
    nbind = OVERALL;
    normals = NULL;
    nindices = NULL;
  }
  else if (nbind == OVERALL) {
    if (normals) glNormal3fv(normals[0].getValue());
    else glNormal3f(0.0f, 0.0f, 1.0f);
  }
  else if (normalCacheUsed && nbind == PER_VERTEX) {
    nbind = PER_VERTEX_INDEXED;
  }
  else if (normalCacheUsed && nbind == PER_FACE_INDEXED) {
    nbind = PER_FACE;
  }

  if (mbind == PER_VERTEX) {
    mbind = PER_VERTEX_INDEXED;
    mindices = cindices;
  }
  if (nbind == PER_VERTEX) {
    nbind = PER_VERTEX_INDEXED;
    nindices = cindices;
  }

  Binding tbind = NONE;
  if (doTextures) {
    if (tb.isFunction() && !tb.needIndices()) {
      tbind = NONE;
      tindices = NULL;
    }
    else {
      tbind = PER_VERTEX_INDEXED;
      if (tindices == NULL) tindices = cindices;
    }
  }
  SbBool convexcacheused = FALSE;

  if (this->useConvexCache(action, normals, nindices, normalCacheUsed)) {
    cindices = PRIVATE(this)->convexCache->getCoordIndices();
    numindices = PRIVATE(this)->convexCache->getNumCoordIndices();
    mindices = PRIVATE(this)->convexCache->getMaterialIndices();
    nindices = PRIVATE(this)->convexCache->getNormalIndices();
    tindices = PRIVATE(this)->convexCache->getTexIndices();

    if (mbind == PER_VERTEX) mbind = PER_VERTEX_INDEXED;
    else if (mbind == PER_FACE) mbind = PER_FACE_INDEXED;
    if (nbind == PER_VERTEX) nbind = PER_VERTEX_INDEXED;
    else if (nbind == PER_FACE) nbind = PER_FACE_INDEXED;

    if (tbind != NONE) tbind = PER_VERTEX_INDEXED;
    convexcacheused = TRUE;
  }

  mb.sendFirst(); // make sure we have the correct material

  SoGLLazyElement * lelem = NULL;
  const uint32_t contextid = action->getCacheContext();

  SbBool dova = 
    SoVBO::shouldRenderAsVertexArrays(state, contextid, numindices) &&
    !convexcacheused && !normalCacheUsed &&
    ((nbind == OVERALL) || ((nbind == PER_VERTEX_INDEXED) && ((nindices == cindices) || (nindices == NULL)))) &&
    ((tbind == NONE && !tb.needCoordinates()) || 
     ((tbind == PER_VERTEX_INDEXED) && ((tindices == cindices) || (tindices == NULL)))) &&
    ((mbind == NONE) || ((mbind == PER_VERTEX_INDEXED) && ((mindices == cindices) || (mindices == NULL)))) &&
    SoGLDriverDatabase::isSupported(sogl_glue_instance(state), SO_GL_VERTEX_ARRAY);

  const SoGLVBOElement * vboelem = SoGLVBOElement::getInstance(state);
  SoVBO * colorvbo = NULL;

  if (dova && (mbind != OVERALL)) {
    dova = FALSE;
    if ((mbind == PER_VERTEX_INDEXED) && ((mindices == cindices) || (mindices == NULL))) {
      lelem = (SoGLLazyElement*) SoLazyElement::getInstance(state);
      colorvbo = vboelem->getColorVBO();
      if (colorvbo) dova = TRUE;
      else {
        // we might be able to do VA-rendering, but need to check the
        // diffuse color type first.
        if (!lelem->isPacked() && lelem->getNumTransparencies() <= 1) {
          dova = TRUE;
        }
      }
    }
  }
  SbBool didrenderasvbo = FALSE;
  if (dova) {
    SbBool dovbo = this->startVertexArray(action,
                                          coords,
                                          (nbind != OVERALL) ? normals : NULL,
                                          doTextures,
                                          mbind != OVERALL);
    didrenderasvbo = dovbo;
    LOCK_VAINDEXER(this);
    if (PRIVATE(this)->vaindexer == NULL) {
      SoVertexArrayIndexer * indexer = new SoVertexArrayIndexer;
      int i = 0;
      while (i < numindices) {
        int cnt = 0;
        while (i + cnt < numindices && cindices[i+cnt] >= 0) cnt++;
        
        switch (cnt) {
        case 3:
          indexer->addTriangle(cindices[i],cindices[i+1], cindices[i+2]);
          break;
        case 4:
          indexer->addQuad(cindices[i],cindices[i+1],cindices[i+2],cindices[i+3]);
          break;
        default:
          if (cnt > 4) {
            indexer->beginTarget(GL_POLYGON);
            for (int j = 0; j < cnt; j++) {
              indexer->targetVertex(GL_POLYGON, cindices[i+j]);
            }
            indexer->endTarget(GL_POLYGON);
          }
        }
        i += cnt + 1;
      }
      indexer->close();
      if (indexer->getNumVertices()) {
        PRIVATE(this)->vaindexer = indexer;
      }
      else {
        delete indexer;
      }
#if 0
      fprintf(stderr,"XXX: create VRML VertexArrayIndexer: %d\n", indexer->getNumVertices());
#endif
    }

    if (PRIVATE(this)->vaindexer) {
      PRIVATE(this)->vaindexer->render(sogl_glue_instance(state), dovbo, contextid);
    }
    UNLOCK_VAINDEXER(this);
    this->finishVertexArray(action,
                            dovbo,
                            (nbind != OVERALL),
                            doTextures,
                            mbind != OVERALL);
  }
  else {
    SoVertexAttributeBundle vab(action, TRUE);
    SbBool doattribs = vab.doAttributes();

    SoVertexAttributeBindingElement::Binding attribbind = 
      SoVertexAttributeBindingElement::get(state);

    if (!doattribs) { 
      // for overall attribute binding we check for doattribs before
      // sending anything in SoGL::FaceSet::GLRender
      attribbind = SoVertexAttributeBindingElement::OVERALL;
    }

    sogl_render_faceset((SoGLCoordinateElement *)coords,
                        cindices,
                        numindices,
                        normals,
                        nindices,
                        &mb,
                        mindices,
                        &tb,
                        tindices,
                        &vab,
                        (int)nbind,
                        (int)mbind,
                        (int)attribbind,
                        doTextures ? 1 : 0,
                        doattribs ? 1 : 0);

  }
  if (normalCacheUsed) {
    this->readUnlockNormalCache();
  }

  if (convexcacheused) {
    PRIVATE(this)->readUnlockConvexCache();
  }

  // send approx number of triangles for autocache handling
  sogl_autocache_update(state, this->coordIndex.getNum() / 4, didrenderasvbo);

  state->pop();
}
static std::string parse_python_exception()
{
    PyObject * type_ptr = NULL, *value_ptr = NULL, *traceback_ptr = NULL;
    // Fetch the exception info from the Python C API
    PyErr_Fetch(&type_ptr, &value_ptr, &traceback_ptr);
    // Fallback error
    std::string ret("Unfetchable Python error");

    // If the fetch got a type pointer, parse the type into the exception string
    if (type_ptr != NULL)
    {
        handle<> h_type(type_ptr);
        str type_pstr(h_type);
        // Extract the string from the boost::python object
        extract<std::string> e_type_pstr(type_pstr);

        // If a valid string extraction is available, use it
        // otherwise use fallback
        if (e_type_pstr.check())
        {
            ret = e_type_pstr();
        }

        else
        {
            ret = "Unknown exception type";
        }
    }

    // Do the same for the exception value (the stringification of the exception)
    if (value_ptr != NULL)
    {
        handle<> h_val(value_ptr);
        str a(h_val);
        extract<std::string> returned(a);

        if (returned.check())
        {
            ret += ": " + returned();
        }

        else
        {
            ret += std::string(": Unparseable Python error: ");
        }
    }

    // Parse lines from the traceback using the Python traceback module
    if (traceback_ptr != NULL)
    {
        handle<> h_tb(traceback_ptr);
        // Load the traceback module and the format_tb function
        object tb(import("traceback"));
        object fmt_tb(tb.attr("format_tb"));
        // Call format_tb to get a list of traceback strings
        object tb_list(fmt_tb(h_tb));
        // Join the traceback strings into a single string
        object tb_str(str("\n").join(tb_list));
        // Extract the string, check the extraction, and fallback in necessary
        extract<std::string> returned(tb_str);

        if (returned.check())
        {
            ret += ": " + returned();
        }

        else
        {
            ret += std::string(": Unparseable Python traceback");
        }
    }

    return ret;
}
Ejemplo n.º 25
0
clToolBar* WordCompletionPlugin::CreateToolBar(wxWindow* parent)
{
    wxUnusedVar(parent);
    clToolBar* tb(NULL);
    return tb;
}
Ejemplo n.º 26
0
clToolBar* MemCheckPlugin::CreateToolBar(wxWindow* parent)
{
    clToolBar* tb(NULL);
    return tb;
}
Ejemplo n.º 27
0
PyramidTemplateMatcher::PyramidTemplateMatcher(Mat _source, Mat _target, int levels, float _factor)
: factor(_factor), source(_source), target(_target), lowerPyramid(NULL)
{ 

   TimingBlock tb("PyramidTemplateMatcher()");
   if (source.rows < target.rows || source.cols < target.cols){
      //std:cerr << "PyramidTemplateMatcher: source is smaller than the target" << endl;
      return;
   }
   
   Size sourceSize = source.size();
   Size targetSize = target.size();
   
   
   if (levels > 0){
      
      copyOfSource = source.clone();
      copyOfTarget = target.clone();
      
      
      Mat smallSource;
      Mat smallTarget;

      TimingBlock* t = new TimingBlock("downsampling");
      
#if USE_PYRDOWN
         // Faster
      pyrDown(source, smallSource);
      pyrDown(target, smallTarget);
#endif
#if USE_RESIZE
      resize(source, smallSource, Size(1.0*source.cols/factor,source.rows*1.0/factor),INTER_NEAREST);
      resize(target, smallTarget, Size(1.0*target.cols/factor,target.rows*1.0/factor),INTER_NEAREST);      
#endif
   
      delete t;
      
      /*
      Mat halfTarget;
      if (smallTarget.cols > smallTarget.rows){
         halfTarget = Mat(smallTarget, Range(1,smallTarget.rows/2), Range(1,smallTarget.cols/2));
      }else{
         halfTarget = Mat(smallTarget, Range(1,smallTarget.rows/2),  Range(1,smallTarget.cols/2));
      }
      */
      
      lowerPyramid = new PyramidTemplateMatcher(smallSource, smallTarget, levels - 1, factor);
      
   }else{
      

      lowerPyramid = NULL;
      
      Size resultSize;
      resultSize.width = sourceSize.width - targetSize.width + 1;
      resultSize.height = sourceSize.height - targetSize.height + 1;      
      
      result.create(resultSize,CV_32FC1);
      dout << "[" << sourceSize.width << " x " << sourceSize.height << "] ";
      dout << "[" << targetSize.width << " x " << targetSize.height << "]" << endl;


      TimingBlock* t = new TimingBlock("matching");

#if USE_SQRDIFF_NORMED
      matchTemplate(source,target,result,CV_TM_SQDIFF_NORMED);
      result = Mat::ones(result.size(), CV_32F) - result;
#else
      matchTemplate(source,target,result,CV_TM_CCOEFF_NORMED);
#endif
      delete t;

   
      
   }
};
Ejemplo n.º 28
0
clToolBar* DatabaseExplorer::CreateToolBar(wxWindow* parent)
{
    // Create the toolbar to be used by the plugin
    clToolBar* tb(NULL);
    return tb;
}
Ejemplo n.º 29
0
Term Process::error(Term error_tag, Term reason) {
  term::TupleBuilder tb(get_heap(), 2);
  tb.add(error_tag);
  tb.add(reason);
  return fail(proc::FailType::Error, tb.make_tuple());
}
Ejemplo n.º 30
0
FindResult PyramidTemplateMatcher::next(){
   TimingBlock tb("PyramidTemplateMatcher::next()");
   
   if (source.rows < target.rows || source.cols < target.cols){
      return FindResult(0,0,0,0,-1);
   }
   
   if (lowerPyramid == NULL){
      
      // find the best match location
      double minValue, maxValue;
      Point minLoc, maxLoc;
      minMaxLoc(result, &minValue, &maxValue, &minLoc, &maxLoc);
      
      double detectionScore = maxValue;
      Point detectionLoc = maxLoc;
      
      int xmargin = target.cols/3;
      int ymargin = target.rows/3;
      
      int& x = detectionLoc.x;
      int& y = detectionLoc.y;
      
      int x0 = max(x-xmargin,0);
      int y0 = max(y-ymargin,0);
      int x1 = min(x+xmargin,result.cols);  // no need to blank right and bottom
      int y1 = min(y+ymargin,result.rows);
      
      rectangle(result, Point(x0, y0), Point(x1-1, y1-1), 
              Scalar(0), CV_FILLED);
      
      return FindResult(detectionLoc.x,detectionLoc.y,target.cols,target.rows,detectionScore);;
      
      
   }else{
      
      FindResult match = lowerPyramid->next();
      
      int x = match.x*factor;
      int y = match.y*factor;
      
      // compute the parameter to define the neighborhood rectangle
      int x0 = max(x-(int)factor,0);
      int y0 = max(y-(int)factor,0);
      int x1 = min(x+target.cols+(int)factor,source.cols);
      int y1 = min(y+target.rows+(int)factor,source.rows);
      Rect roi(x0,y0,x1-x0,y1-y0);
      
      
      Mat roiOfSource(copyOfSource, roi);
      Size resultSize;
      resultSize.width = roiOfSource.size().width - target.size().width + 1;
      resultSize.height = roiOfSource.size().height - target.size().height + 1;      
      
      result.create(resultSize, CV_32FC1);
   
      TimingBlock* t = new TimingBlock("matching");
#if USE_SQRDIFF_NORMED
      matchTemplate(roiOfSource,target,result,CV_TM_SQDIFF_NORMED);   
      result = Mat::ones(result.size(), CV_32F) - result;
#else
      matchTemplate(roiOfSource,target,result,CV_TM_CCOEFF_NORMED);
#endif
      delete t;
      
      double minValue, maxValue;
      Point minLoc, maxLoc;
      minMaxLoc(result, &minValue, &maxValue, &minLoc, &maxLoc);
      
      double detectionScore = maxValue;
      Point detectionLoc = maxLoc;

      detectionLoc.x += roi.x;
      detectionLoc.y += roi.y;
      
      
      return FindResult(detectionLoc.x,detectionLoc.y,target.cols,target.rows,detectionScore);
      
   }
   
   
};