Exemplo n.º 1
0
void Cell::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if(!stitch())
        return;

    QColor clr = bgColor();
    if(!clr.isValid())
        clr = QColor(Qt::white);

    if(clr != Qt::white)
        painter->fillRect(option->rect, clr);
    if(mHighlight)
        painter->fillRect(option->rect, option->palette.highlight());

    if(stitch()->isSvg()) {
        QGraphicsSvgItem::paint(painter, option, widget);
    } else {
        painter->drawPixmap(option->rect.x(), option->rect.y(), *(stitch()->renderPixmap()));

         if(option->state & QStyle::State_Selected) {
            painter->setPen(Qt::DashLine);
            painter->drawRect(option->rect);
            painter->setPen(Qt::SolidLine);
        }
    }
}
Exemplo n.º 2
0
QRectF Cell::boundingRect() const
{
    if(!stitch())
        return QRectF(0,0,32,32);

    if(stitch()->isSvg()) {
		QRectF r = QGraphicsSvgItem::boundingRect();
        return r;
    } else
        return stitch()->renderPixmap()->rect();
}
Exemplo n.º 3
0
/*
** Change a help window to display a new topic.  (Help window data is stored
** and indexed by topic so if a given topic is already displayed or has been
** positioned by the user, it can be found and popped back up in the same
** place.)  To change the topic displayed, the stored data has to be relocated.
*/
static void changeWindowTopic(int existingTopic, enum HelpTopic newTopic)
{
    char *helpText, *styleData;
    
    /* Relocate the window/widget/buffer information */
    if (newTopic != existingTopic)
    {
        HelpWindows[newTopic] = HelpWindows[existingTopic];
        HelpWindows[existingTopic] = NULL;
        HelpStyleBuffers[newTopic] = HelpStyleBuffers[existingTopic];
        HelpStyleBuffers[existingTopic] = NULL;
        HelpTextPanes[newTopic] = HelpTextPanes[existingTopic];
        HelpTextPanes[existingTopic] = NULL;
        setHelpWinTitle(HelpWindows[newTopic], newTopic);
    } 
    
    /* Set the existing text widget to display the new text.  Because it's
       highlighted, we have to turn off highlighting before changing the
       displayed text to prevent the text widget from trying to apply the
       old, mismatched, highlighting to the new text */
    helpText = stitch(HelpTextPanes[newTopic], HelpText[newTopic], &styleData);
    TextDAttachHighlightData(((TextWidget)HelpTextPanes[newTopic])->text.textD,
            NULL, NULL, 0, '\0', NULL, NULL);
    BufSetAll(TextGetBuffer(HelpTextPanes[newTopic]), helpText);
    XtFree(helpText);
    BufSetAll(HelpStyleBuffers[newTopic], styleData);
    XtFree(styleData);
    TextDAttachHighlightData(((TextWidget)HelpTextPanes[newTopic])->text.textD,
            HelpStyleBuffers[newTopic], HelpStyleInfo, N_STYLES, '\0', NULL,
            NULL);
}
Exemplo n.º 4
0
InputIterator stitch(Out & out, const node & tree, InputIterator word_it, StateList & states)
{
  // don't output boundary
  if (tree.state == consts::boundary_state)
    return word_it;

  out << '(';
  if (states[tree.state].basic_category().empty() && tree.children.empty())
      out << *word_it;
  else
      out << states[tree.state].basic_category();
  out << ' ';

  if ( tree.children.empty() ) {
    out << *word_it++;
  }
  else
  {
    for (std::vector< boost::shared_ptr< node > >::const_iterator it = tree.children.begin(); it != tree.children.end(); ++it)
    {
      word_it = stitch(out, **it, word_it, states);
      if (it != tree.children.end() - 1)
        out << ' '; // give some space to lists
    }
  }
  out << ')';
  return word_it;
}
Exemplo n.º 5
0
static REPF(jtrepzdx){A p,q,x;P*wp;
 RZ(a&&w);
 if(SPARSE&AT(w)){wp=PAV(w); x=SPA(wp,e);}
 else x=jt->fill&&AN(jt->fill)?jt->fill:filler(w);
 RZ(p=repeat(ravel(rect(a)),ravel(stitch(IX(wcr?*(wf+AS(w)):1),num[-1]))));
 RZ(q=irs2(w,x,0L,wcr,0L,jtover));
 R irs2(p,q,0L,1L,wcr+!wcr,jtfrom);
}    /* (dense complex) # (dense or sparse) */
Exemplo n.º 6
0
/*
** Search the help text.  If allSections is true, searches all of the help
** text, otherwise searches only in parentTopic.
*/
static void searchHelpText(Widget parent, int parentTopic,
        const char *searchFor, int allSections, int startPos, int startTopic)
{    
    int topic, beginMatch, endMatch;
    int found = False;
    char * helpText  = NULL;
    
    /* Search for the string */
    for (topic=startTopic; topic<NUM_TOPICS; topic++)
    {
        if (!allSections && topic != parentTopic)
            continue;
        helpText = stitch(parent, HelpText[topic], NULL);

        if (SearchString(helpText, searchFor, SEARCH_FORWARD, SEARCH_LITERAL,
                False, topic == startTopic ? startPos : 0, &beginMatch,
                &endMatch, NULL, NULL, GetPrefDelimiters()))
        {
            found = True;
            XtFree(helpText);
            break;
        }
        XtFree(helpText);
    }

    if (!found)
    {
        if (startPos != 0 || (allSections && startTopic != 0))
        {
            /* Wrap search */
            searchHelpText(parent, parentTopic, searchFor, allSections, 0, 0);
            return;
        }
        DialogF(DF_INF, parent, 1, "String Not Found", "String Not Found", "OK");
        return;
    }
    
    /* update navigation history */  
    if (parentTopic != topic)
    {
        navHistForw[parentTopic]= topic;
        navHistBack[topic]= parentTopic;
    }
    
    /* If the appropriate window is already up, bring it to the top, if not,
       make the parent window become this topic */
    changeTopicOrRaise(parentTopic, topic);
    BufSelect(TextGetBuffer(HelpTextPanes[topic]), beginMatch, endMatch);
    TextSetCursorPos(HelpTextPanes[topic], endMatch);
    
    /* Save the search information for search-again */
    strcpy(LastSearchString, searchFor);
    LastSearchTopic = topic;
    LastSearchPos = endMatch;
    LastSearchWasAllTopics = allSections;
}
Exemplo n.º 7
0
void displayImageStitch(const char* windowName, const std::vector<cv::Mat*> images, int cc, int rc)
{
	if(disableAllDisplay) return;
	if(images.size() == 0) return;

	// get dimensions.
	int w = images[0]->cols;
	int h = images[0]->rows;

	int num = std::max((int)setting_maxFrames, (int)images.size());

	// get optimal dimensions.
	int bestCC = 0;
	float bestLoss = 1e10;
	for(int cc=1;cc<10;cc++)
	{
		int ww = w * cc;
		int hh = h * ((num+cc-1)/cc);


		float wLoss = ww/16.0f;
		float hLoss = hh/10.0f;
		float loss = std::max(wLoss, hLoss);

		if(loss < bestLoss)
		{
			bestLoss = loss;
			bestCC = cc;
		}
	}

	int bestRC = ((num+bestCC-1)/bestCC);
	if(cc != 0)
	{
		bestCC = cc;
		bestRC= rc;
	}
	cv::Mat stitch = cv::Mat(bestRC*h, bestCC*w, images[0]->type());
	stitch.setTo(0);
	for(int i=0;i<(int)images.size() && i < bestCC*bestRC;i++)
	{
		int c = i%bestCC;
		int r = i/bestCC;

		cv::Mat roi = stitch(cv::Rect(c*w, r*h, w,h));
		images[i]->copyTo(roi);
	}
	displayImage(windowName, stitch, false);
}
Exemplo n.º 8
0
void Cell::setColor(QColor c)
{

    if(mColor != c) {
        QString old = "";
        if(mColor.isValid())
            old = mColor.name();
        mColor = c;

        QSvgRenderer *r = stitch()->renderSvg(c);
        if(r)
            setSharedRenderer(r);

        emit colorChanged(old, c.name());
        update();
    }

}
Exemplo n.º 9
0
void Surface::addVRow(){
    float spacing = (seed.shapeSize/(seed.numCols-1));
    int vecSize = vboMesh.getVertices().size();
    vector<ofVec3f> verts = vboMesh.getVertices();
    for (int i = seed.numCols; i > 0; i--) {
        //add vertex
        ofVec3f temp = verts[vecSize-i];
        temp = ofVec3f(temp.x, temp.y + spacing, temp.z);
        vboMesh.addVertex(setNoiseHeight(temp));
        vboMesh.addNormal(ofVec3f(0,0,1));
    }
    
    for (int i = 0; i < seed.numCols; i++){
        vboMesh.removeVertex(0);
    }
    
    //stitch new verts into the mesh
    stitch();
}
Exemplo n.º 10
0
void Pipeline::optimizePipeline() {
    SourceContainer optimizedSources;

    SourceContainer::iterator itr = _sources.begin();

    while (itr != _sources.end() && std::next(itr) != _sources.end()) {
        invariant((*itr).get());
        itr = (*itr).get()->optimizeAt(itr, &_sources);
    }

    // Once we have reached our final number of stages, optimize each individually.
    for (auto&& source : _sources) {
        if (auto out = source->optimize()) {
            optimizedSources.push_back(out);
        }
    }
    _sources.swap(optimizedSources);
    stitch();
}
Exemplo n.º 11
0
Cell* Cell::copy(Cell *cell)
{
    Cell *c = 0;
    if(!cell)
        c = new Cell();
    else
        c = cell;

    c->setStitch(stitch());
    c->setBgColor(bgColor());
    c->setColor(c->color());
    c->setTransformOriginPoint(transformOriginPoint());
    c->setRotation(0);
    c->setTransform(QTransform());
	c->setTransformations(ChartItemTools::cloneGraphicsTransformations(this));
	foreach (QGraphicsTransform* t, transformations())
		t->setParent(parentObject());

    return c;
}
Exemplo n.º 12
0
int main(int argc, const char * argv[]) {
    
    std::vector< cv::Mat > vImg = {
        cv::imread( "1.jpg" ),
        cv::imread( "2.jpg" ),
        cv::imread( "3.jpg" ),
        cv::imread( "4.jpg" ),
    };
    // create a Stitcher object
    auto stitcher = cv::Stitcher::createDefault();
    // Mat to store the output pano image
    cv::Mat rImg;
    // stitch the input images together
    cv::Stitcher::Status status = stitcher.stitch(vImg, rImg);
    
    if (status != cv::Stitcher::OK)
    {
        std::cout << "Can't stitch images, error code = " << int(status) << std::endl;
        return -1;
    }
    // write the result to the output image
    imwrite(OUTPUT_FILE, rImg);
    return 0;
}
Exemplo n.º 13
0
/*
** Create a new help window displaying a given subject, "topic"
**
** Important hint: If this widget is restructured or the name of the text
** subwidget is changed don't forget to adapt the default translations of the
** help text. They are located in nedit.c, look for 
**   static char *fallbackResources 
**   (currently:  nedit.helpForm.sw.helpText*translations...)
*/
static Widget createHelpPanel(enum HelpTopic topic)
{
    Arg al[50];
    int ac;
    Widget appShell, btn, closeBtn, form, btnFW;
    Widget sw, hScrollBar, vScrollBar;
    XmString st1;
    char * helpText  = NULL;
    char * styleData = NULL;

    ac = 0;
    XtSetArg(al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
    appShell = CreateWidget(TheAppShell, "help",
            topLevelShellWidgetClass, al, ac);
    AddSmallIcon(appShell);
    /* With openmotif 2.1.30, a crash may occur when the text widget of the
       help window is (slowly) resized to a zero width. By imposing a 
       minimum _window_ width, we can work around this problem. The minimum 
       width should be larger than the width of the scrollbar. 50 is probably 
       a safe value; this leaves room for a few characters */
    XtVaSetValues(appShell, XtNminWidth, 50, NULL);
    form = XtVaCreateManagedWidget("helpForm", xmFormWidgetClass, appShell,
            NULL);
    XtVaSetValues(form, XmNshadowThickness, 0, NULL);
    
    /* Create the bottom row of buttons */
    btn = XtVaCreateManagedWidget("find", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Find..."),
            XmNmnemonic, 'F',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 3,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 25,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, searchHelpCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("findAgain", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Find Again"),
            XmNmnemonic, 'A',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 27,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 49,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, searchHelpAgainCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("print", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Print..."),
            XmNmnemonic, 'P',
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 51,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 73,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, printCB, appShell);
    XmStringFree(st1);

    closeBtn = XtVaCreateManagedWidget("close",
            xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Close"),
            XmNbottomAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 75,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 97,
            NULL);
    XtAddCallback(closeBtn, XmNactivateCallback, closeCB, appShell);
    XmStringFree(st1);
            
    /* Create the next row of buttons (for navigation) */
    btn = XtVaCreateManagedWidget("prevTopic", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("<< Browse"),
            XmNmnemonic, 'o', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 51,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 73,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, prevTopicCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("nextTopic", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Browse >>"),
            XmNmnemonic, 'e', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 75, 
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 97,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, nextTopicCB, appShell);
    XmStringFree(st1);

    btn = XtVaCreateManagedWidget("histBack", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Back"),
            XmNmnemonic, 'B', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 3,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 25,
            NULL);
    XtAddCallback(btn, XmNactivateCallback, bwHistoryCB, appShell);
    XmStringFree(st1);

    btnFW = XtVaCreateManagedWidget("histForw", xmPushButtonWidgetClass, form,
            XmNlabelString, st1=XmStringCreateSimple("Forward"),
            XmNmnemonic, 'w', 
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, closeBtn,
            XmNleftAttachment, XmATTACH_POSITION,
            XmNleftPosition, 27,
            XmNrightAttachment, XmATTACH_POSITION,
            XmNrightPosition, 49,
            NULL);
    XtAddCallback(btnFW, XmNactivateCallback, fwHistoryCB, appShell);
    XmStringFree(st1);
    
    /* Create a text widget inside of a scrolled window widget */
    sw = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, form,
            XmNshadowThickness, 2,
            XmNtopAttachment, XmATTACH_FORM,
            XmNleftAttachment, XmATTACH_FORM,
            XmNrightAttachment, XmATTACH_FORM,
            XmNbottomAttachment, XmATTACH_WIDGET,
            XmNbottomWidget, btnFW,
            NULL);
    hScrollBar = XtVaCreateManagedWidget("hScrollBar",
            xmScrollBarWidgetClass, sw,
            XmNorientation, XmHORIZONTAL, 
            XmNrepeatDelay, 10,
            NULL);
    vScrollBar = XtVaCreateManagedWidget("vScrollBar",
            xmScrollBarWidgetClass, sw,
            XmNorientation, XmVERTICAL,
            XmNrepeatDelay, 10,
            NULL);
    /* Make sure the fixed size help font is loaded, such that we can base
       our text widget size calculation on it. */
    loadFontsAndColors(sw, 'A');
    HelpTextPanes[topic] = XtVaCreateManagedWidget("helpText",
            textWidgetClass, sw,
            textNfont, HelpStyleInfo[0].font, /* MUST correspond to 'A' above */
            textNrows, 30,
            textNcolumns, 65,
            textNbacklightCharTypes, NULL,
            textNhScrollBar, hScrollBar,
            textNvScrollBar, vScrollBar,
            textNreadOnly, True,
            textNcontinuousWrap, True,
            textNautoShowInsertPos, True,
            NULL);
    XtVaSetValues(sw, XmNworkWindow, HelpTextPanes[topic],
            XmNhorizontalScrollBar, hScrollBar,
            XmNverticalScrollBar, vScrollBar,
            NULL);
    
    /* Initialize help style information, if it hasn't already been init'd */
    initHelpStyles (HelpTextPanes[topic]);
    
    /* Put together the text to display and separate it into parallel text
       and style data for display by the widget */
    helpText = stitch (HelpTextPanes[topic], HelpText[topic], &styleData);
    
    /* Stuff the text into the widget's text buffer */
    BufSetAll (TextGetBuffer (HelpTextPanes[topic]) , helpText);
    XtFree (helpText);
    
    /* Create a style buffer for the text widget and fill it with the style
       data which was generated along with the text content */
    HelpStyleBuffers[topic] = BufCreate(); 
    BufSetAll(HelpStyleBuffers[topic], styleData);
    XtFree (styleData);
    TextDAttachHighlightData(((TextWidget)HelpTextPanes[topic])->text.textD,
            HelpStyleBuffers[topic], HelpStyleInfo, N_STYLES, '\0', NULL, NULL);
    
    /* This shouldn't be necessary (what's wrong in text.c?) */
    HandleXSelections(HelpTextPanes[topic]);
    
    /* Process dialog mnemonic keys */
    AddDialogMnemonicHandler(form, FALSE);
    
    /* Set the default button */
    XtVaSetValues(form, XmNdefaultButton, closeBtn, NULL);
    XtVaSetValues(form, XmNcancelButton, closeBtn, NULL);
    
    /* realize all of the widgets in the new window */
    RealizeWithoutForcingPosition(appShell);
    
    /* Give the text pane the initial focus */
    XmProcessTraversal(HelpTextPanes[topic], XmTRAVERSE_CURRENT);

    /* Make close command in window menu gracefully prompt for close */
    AddMotifCloseCallback(appShell, (XtCallbackProc)closeCB, appShell);
    
    /* Initialize navigation information, if it hasn't already been init'd */
    initNavigationHistory();
    
    /* Set the window title */
    setHelpWinTitle(appShell, topic);
    
    
#ifdef EDITRES
    XtAddEventHandler (appShell, (EventMask)0, True,
            (XtEventHandler)_XEditResCheckMessages, NULL);
#endif /* EDITRES */
    
    return appShell;
}
Exemplo n.º 14
0
int main(int argc, char** argv )
{
	//读入input.png
	cout << "which data set do you wana test ? (1 or 2 :" << endl;
	int dataSet;
	cin >> dataSet;
	cout << "please input the start number and end number of images : " << endl;
	int start, end;
	cin >> start >> end;

	/*~~~~~~~~~~~~~~~~~~从两端开始拼接~~~~~~~~~~~~~~~~~~*/
	string name1, name2;
	name1 = Name(dataSet, start);
	name2 = Name(dataSet, end);
	Mat image1 = imread(name1.data(), -1);
	Mat image2 = imread(name2.data(), -1);
	if (dataSet != 1) {
		image1 = pre_processing(image1);
		image2 = pre_processing(image2);
	}
	image1 = Cylinder_projection(image1);
	image2 = Cylinder_projection(image2);
	Mat result;
	cout << name1 << endl;
	cout << name2 << endl;

	while (start != end - 1 && start != end) {
		Mat temp1;
		start ++;
		name1 = Name(dataSet, start);
		cout << name1 << endl;
		temp1 = imread(name1.data(), -1);
		if (dataSet != 1) {
			temp1 = pre_processing(temp1);
		}
		temp1 = Cylinder_projection(temp1);
		image1 = (stitch(image1, temp1)).clone();

		if (start == end - 1 || start == end)break;
		else {
			Mat temp2;
			end --;
			name2 = Name(dataSet, end);
			cout << name2 << endl;
			temp2 = imread(name2.data(), -1);
			if (dataSet != 1) {
				temp2 = pre_processing(temp2);
			}
			temp2 = Cylinder_projection(temp2);
			image2 = (stitch(temp2, image2)).clone();
		}
	}
	result = stitch(image1, image2);
	
	/*~~~~~~~~~~~~~~~从左到右,单张拼接~~~~~~~~~~~~~~~~`*/
	/*
	Mat image1, image2;
	string name;
	Mat result;
	if (dataSet == 1)
		result = imread("images/pano1_00" + turnIntoStr(start) + ".bmp", -1);
	else {
		result = imread("images/100NIKON-DSCN00" + turnIntoStr(start) + "_DSCN00" + turnIntoStr(start) + ".JPG", -1);
		result = pre_processing(result);
	}

	result = Cylinder_projection(result);
	
	for (int i = start + 1; i <= end; i ++) {
		image1 = result.clone();
		if (dataSet == 1) {
			name = "images/pano1_00" + turnIntoStr(i) + ".bmp";
			image2 = imread(name.data(), -1);
		}
		else {
			name = "images/100NIKON-DSCN00" + turnIntoStr(i) + "_DSCN00" + turnIntoStr(i) + ".JPG";
			image2 = imread(name.data(), -1);
			image2 = pre_processing(image2);
		}
		if ( !image1.data || !image2.data) {
			printf("No image data \n");
			return -1;
		}
		image2 = Cylinder_projection(image2);
		if (dataSet == 1)
			result = (stitch(image1, image2)).clone();
		else
			result = (stitch(image1, image2)).clone();
	}
	*/
	if (dataSet == 1)
		imwrite("images/result1.bmp", result);
	else 
		imwrite("images/result2.JPG", result);

    	waitKey(0);
  	return 0;
}
Exemplo n.º 15
0
Stitcher::Status Stitcher::stitch(InputArrayOfArrays images, OutputArray pano)
{
    return stitch(images, noArray(), pano);
}
Exemplo n.º 16
0
int main(int ac, char** av) {
	
	if(ac != 2) {
		std::cout << "usage: " << av[0] << " <run number>" << std::endl;
		return 1;
	}

	// thomas's data
	size_t run_index = atoi(av[1]);
	real T_in_pipe[]  = {152.9, 203.6, 415.1};
	real T_in_head[]  = {203.5, 291.8, 487.8};
	real T_in_flux[]  = {227.7, 315.7, 504.7};
	real T_out_flux[] = {244.6, 346.9, 522.5};
	real T_out_head[] = {250.8, 355.7, 538.0};
	real T_out_pipe[] = {229.3, 332.6, 512.8};

	real* T_ym = new real[3];

	const char* prob_names[] = {"opt2_run1","opt2_run2","opt2_run3"};
	
	// convert to kelvin
	for(size_t i = 0; i < 3; ++i) {
		T_in_pipe[i]  += 273.15;
		T_in_head[i]  += 273.15;
		T_in_flux[i]  += 273.15;
		T_out_flux[i] += 273.15;
		T_out_head[i] += 273.15;
		T_out_pipe[i] += 273.15;

		T_ym[i] = (T_in_flux[i] + T_out_flux[i]) * 0.5;
	}

	// solve

	// dimensions
	real w_total = 	6.00e-2;
	real w_irrad = 	2.00e-2;
	real pipe = 	6.35e-3;

	real l_total = 	4.00e-2;
	real l_irrad = 	2.00e-2;

	// calculations
	real l_1 = (l_total - l_irrad) / 2.0;
	real l_3 = l_irrad - pipe * 2.0;

	real w_ends = (w_total - w_irrad) / 2.0;
	real w_1 = (w_ends - pipe) / 2.0;


	// lists
	auto xd = math::make_array_1<real,1>({0, w_1, pipe, w_1, w_irrad, w_1, pipe, w_1});

	auto yd = math::make_array_1<real,1>({0, 1e-2, 5e-2});

	auto zd = math::make_array_1<real,1>({0, l_1, pipe, l_3*0.5, l_3*0.5, pipe, l_1});

	real nom_size = 5e-4;

	auto nx = xd->sub({1},{-1})->divide(nom_size)->ceil<size_t>();
	auto ny = yd->sub({1},{-1})->divide(nom_size)->ceil<size_t>();
	auto nz = zd->sub({1},{-1})->divide(nom_size)->ceil<size_t>();

	auto x = xd->cumsum();
	auto y = yd->cumsum();
	auto z = zd->cumsum();

	coor_type X({x,y,z});

	cell_count_type n({nx,ny,nz});

	//=================================================================

	real s = 1.0e10;


	//nx = [10, 10, 10, 50, 10, 10, 10];
	//ny = [50, 50];
	//nz = [10, 10, 30, 10, 10];

	// the default boundary for solve source is const = 1.0
	auto const_bou(std::make_shared<boundary_single>(1.0));

	auto T_bou_i(std::make_shared<boundary_single>(T_in_pipe[run_index]));
	auto T_bou_o(std::make_shared<boundary_single>(T_out_pipe[run_index]));

	patch_v_bou_vec_type v_bou_s_def({
			{{const_bou},{const_bou}},
			{{const_bou},{const_bou}}
			});



	patch_v_bou_vec_type v_bou_T_i({
			{{T_bou_i},{T_bou_i}},
			{{T_bou_i},{T_bou_i}}
			});

	patch_v_bou_vec_type v_bou_T_o({
			{{T_bou_o},{T_bou_o}},
			{{T_bou_o},{T_bou_o}}
			});

	patch_v_bou_type v_bou_def({{"s",v_bou_s_def}});



	patch_v_bou_type v_bou_i({{"s",v_bou_s_def},{"T",v_bou_T_i}});
	patch_v_bou_type v_bou_o({{"s",v_bou_s_def},{"T",v_bou_T_o}});


	// create patch groups;

	point pt_xz(
			x->get(0),
			(y->get(0) + y->get(1)) / 2.0,
			(z->get(2) + z->get(3)) / 2.0);

	point pt_ym(
			(x->get(2) + x->get(5)) / 2.0,
			0.0,
			z->get(3));

	point pt_h_in(
			(x->get(3) + x->get(4)) / 2.0,
			y->get(1),
			(z->get(1) + z->get(2)) / 2.0);

	point pt_h_out(
			(x->get(3) + x->get(4)) / 2.0,
			y->get(1),
			(z->get(4) + z->get(5)) / 2.0);

	point pt_in(
			x->get(2),
			(y->get(1) + y->get(2)) / 2.0,
			(z->get(1) + z->get(2)) / 2.0);

	point pt_out(
			x->get(5),
			(y->get(1) + y->get(2)) / 2.0,
			(z->get(4) + z->get(5)) / 2.0);

	//==============================================================

	auto prob = std::make_shared<Prob>(prob_names[run_index], X, n, 2E4, 2E4);

	prob->create_equation("T", 10.0, 1.5, 1.5);
	prob->create_equation("s", 10.0, 1.5, 1.5);

	auto g_xyz		= prob->create_patch_group("xyz",		{{"T",0.0},		{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_xz);
	auto g_h_in		= prob->create_patch_group("h_in",		{{"T",0.0},		{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_h_in);
	auto g_h_out		= prob->create_patch_group("h_out",		{{"T",0.0},		{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_h_out);
	auto g_in		= prob->create_patch_group("in",		{{"T",0.0},		{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_in);
	auto g_out		= prob->create_patch_group("out",		{{"T",0.0},		{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_out);
	auto g_ym		= prob->create_patch_group("out",		{{"T",T_ym[run_index]},	{"s",2.0}}, {{"T",0.0},{"s",s}}, pt_ym);

	// create patches

	auto p_in_xm	= g_in->create_patch("p_in_xm",		-1,	{1},		{1,2},	{1,2},		v_bou_i);
	auto p_in_xp	= g_in->create_patch("p_in_xp",		1,	{2},		{1,2},	{1,2},		v_bou_i);
	auto p_in_zm	= g_in->create_patch("p_in_zm",		-3,	{1,2},		{1,2},	{1},		v_bou_i);
	auto p_in_zp	= g_in->create_patch("p_in_zp",		3,	{1,2},		{1,2},	{2},		v_bou_i);

	auto p_out_xm	= g_out->create_patch("p_out_xm",	-1,	{5},		{1,2},	{4,5},		v_bou_o);
	auto p_out_xp	= g_out->create_patch("p_out_xp",	1,	{6},		{1,2},	{4,5},		v_bou_o);
	auto p_out_zm	= g_out->create_patch("p_out_zm",	-3,	{5,6},		{1,2},	{4},		v_bou_o);
	auto p_out_zp	= g_out->create_patch("p_out_zp",	3,	{5,6},		{1,2},	{5},		v_bou_o);


	// ym
	auto p_ym_0_0	= g_ym->create_patch("p_ym_0_0",	-2,	{0,1,2,3},	{0},	{0,1},		v_bou_def);
	auto p_ym_0_1	= g_ym->create_patch("p_ym_0_1",	-2,	{0,1,2,3},	{0},	{1,2,3,4,5},	v_bou_def);
	auto p_ym_0_2	= g_ym->create_patch("p_ym_0_2",	-2,	{0,1,2,3},	{0},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},	"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_ym_1_0	= g_ym->create_patch("p_ym_1_0",	-2,	{3,4},		{0},	{0,1},		v_bou_def);
	auto p_ym_1_1	= g_ym->create_patch("p_ym_1_1",	-2,	{3,4},		{0},	{1,2,3,4,5},	v_bou_def);
	auto p_ym_1_2	= g_ym->create_patch("p_ym_1_2",	-2,	{3,4},		{0},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,T_irr_zp}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_ym_2_0	= g_ym->create_patch("p_ym_2_0",	-2,	{4,5,6,7},	{0},	{0,1},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},	"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_ym_2_1	= g_ym->create_patch("p_ym_2_1",	-2,	{4,5,6,7},	{0},	{1,2,3,4,5},	v_bou_def);// = {"T":{{0.0,T_irr_xp},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_ym_2_2	= g_ym->create_patch("p_ym_2_2",	-2,	{4,5,6,7},	{0},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},	"s":{{1.0,1.0},{1.0,1.0}}});

	// yp
	auto p_yp_0_0	= g_in->create_patch("p_yp_0_0",	2,	{0,1,2,3},	{1},	{0,1},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_0_1_0	= g_in->create_patch("p_yp_0_1_0",	2,	{0,1},		{1},	{1,2,3},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_0_1_1	= g_in->create_patch("p_yp_0_1_1",	2,	{1,2},		{1},	{2,3},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_0_1_2	= g_in->create_patch("p_yp_0_1_2",	2,	{2,3},		{1},	{1,2,3},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_0_2	= g_h_out->create_patch("p_yp_0_2",	2,	{0,1,2,3},	{1},	{3,4,5},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_0_3	= g_h_out->create_patch("p_yp_0_3",	2,	{0,1,2,3},	{1},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_1_0	= g_h_in->create_patch("p_yp_1_0",	2,	{3,4},		{1},	{0,1},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_1_1	= g_h_in->create_patch("p_yp_1_1",	2,	{3,4},		{1},	{1,2,3},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_1_2	= g_h_out->create_patch("p_yp_1_2",	2,	{3,4},		{1},	{3,4,5},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_1_3	= g_h_out->create_patch("p_yp_1_3",	2,	{3,4},		{1},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_2_0	= g_h_in->create_patch("p_yp_2_0",	2,	{4,5,6,7},	{1},	{0,1},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_2_1	= g_h_in->create_patch("p_yp_2_1",	2,	{4,5,6,7},	{1},	{1,2,3},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_2_2_0	= g_out->create_patch("p_yp_2_2_0",	2,	{4,5},		{1},	{3,4,5},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_2_2_1	= g_out->create_patch("p_yp_2_2_1",	2,	{5,6},		{1},	{3,4},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_yp_2_2_2	= g_out->create_patch("p_yp_2_2_2",	2,	{6,7},		{1},	{3,4,5},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_yp_2_3	= g_out->create_patch("p_yp_2_3",	2,	{4,5,6,7},	{1},	{5,6},		v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	// xp
	auto p_xm	= g_xyz->create_patch("p_xm",		-1,	{0},			{0,1},		{0,1,2,3,4,5,6},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_xp	= g_xyz->create_patch("p_xp",		1,	{7},			{0,1},		{0,1,2,3,4,5,6},	v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});

	auto p_zm	= g_xyz->create_patch("p_zm",		-3,	{0,1,2,3,4,5,6,7},	{0,1},		{0},			v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});
	auto p_zp	= g_xyz->create_patch("p_zp",		3,	{0,1,2,3,4,5,6,7},	{0,1},		{6},			v_bou_def);// = {"T":{{0.0,0.0},{0.0,0.0}},"s":{{1.0,1.0},{1.0,1.0}}});


	// stitching

	// in xm
	stitch(p_in_xm,		p_in_zm);
	stitch(p_in_xm,		p_in_zp);
	stitch(p_in_xm,		p_yp_0_1_0);

	// in xp
	stitch(p_in_xp,		p_in_zm);
	stitch(p_in_xp,		p_in_zp);
	stitch(p_in_xp,		p_yp_0_1_2);

	// in z
	stitch(p_in_zm,		p_yp_0_0);
	stitch(p_in_zp,		p_yp_0_1_1);

	// out xm
	stitch(p_out_xm,	p_out_zm);
	stitch(p_out_xm,	p_out_zp);
	stitch(p_out_xm,	p_yp_2_2_0);

	// out xp
	stitch(p_out_xp,	p_out_zm);
	stitch(p_out_xp,	p_out_zp);
	stitch(p_out_xp,	p_yp_2_2_2);

	// out z
	stitch(p_out_zp,	p_yp_2_3);
	stitch(p_out_zm,	p_yp_2_2_1);



	// xm
	stitch(p_xm,p_ym_0_0);
	stitch(p_xm,p_ym_0_1);
	stitch(p_xm,p_ym_0_2);

	stitch(p_xm,p_yp_0_0);
	stitch(p_xm,p_yp_0_1_0);
	stitch(p_xm,p_yp_0_2);
	stitch(p_xm,p_yp_0_3);

	stitch(p_xm,p_zm);
	stitch(p_xm,p_zp);

	// xp
	stitch(p_xp,p_ym_2_0);
	stitch(p_xp,p_ym_2_1);;
	stitch(p_xp,p_ym_2_2);

	stitch(p_xp,p_yp_2_0);
	stitch(p_xp,p_yp_2_1);
	stitch(p_xp,p_yp_2_2_2);
	stitch(p_xp,p_yp_2_3);

	stitch(p_xp,p_zm);
	stitch(p_xp,p_zp);

	//zm;
	stitch(p_zm,p_ym_0_0);
	stitch(p_zm,p_ym_1_0);
	stitch(p_zm,p_ym_2_0);

	stitch(p_zm,p_yp_0_0);
	stitch(p_zm,p_yp_1_0);
	stitch(p_zm,p_yp_2_0);

	// zp;
	stitch(p_zp,p_ym_0_2);
	stitch(p_zp,p_ym_1_2);
	stitch(p_zp,p_ym_2_2);

	stitch(p_zp,p_yp_0_3);
	stitch(p_zp,p_yp_1_3);
	stitch(p_zp,p_yp_2_3);

	// yp
	// row 0
	stitch(p_yp_0_0,	p_yp_1_0);
	stitch(p_yp_0_0,	p_yp_0_1_0);
	stitch(p_yp_0_0,	p_yp_0_1_2);

	stitch(p_yp_1_0,	p_yp_1_1);
	stitch(p_yp_1_0,	p_yp_2_0);

	stitch(p_yp_2_0,	p_yp_2_1);

	// row 1
	stitch(p_yp_0_1_0,	p_yp_0_1_1);
	stitch(p_yp_0_1_0,	p_yp_0_2);

	stitch(p_yp_0_1_1,	p_yp_0_1_2);
	stitch(p_yp_0_1_1,	p_yp_0_2);

	stitch(p_yp_0_1_2,	p_yp_1_1);
	stitch(p_yp_0_1_2,	p_yp_0_2);

	stitch(p_yp_1_1,	p_yp_2_1);
	stitch(p_yp_1_1,	p_yp_1_2);

	stitch(p_yp_2_1,	p_yp_2_2_0);
	stitch(p_yp_2_1,	p_yp_2_2_1);
	stitch(p_yp_2_1,	p_yp_2_2_2);


	// row 2
	stitch(p_yp_0_2,	p_yp_1_2);
	stitch(p_yp_0_2,	p_yp_0_3);

	stitch(p_yp_1_2,	p_yp_2_2_0);
	stitch(p_yp_1_2,	p_yp_1_3);

	stitch(p_yp_2_2_0,	p_yp_2_2_1);
	stitch(p_yp_2_2_0,	p_yp_2_3);

	stitch(p_yp_2_2_1,	p_yp_2_2_2);

	stitch(p_yp_2_2_2,	p_yp_2_3);

	// row 3
	stitch(p_yp_0_3,	p_yp_1_3);

	stitch(p_yp_1_3,	p_yp_2_3);

	// ym;
	stitch(p_ym_0_0,	p_ym_0_1);
	stitch(p_ym_0_0,	p_ym_1_0);

	stitch(p_ym_1_0,	p_ym_1_1);
	stitch(p_ym_1_0,	p_ym_2_0);
	
	stitch(p_ym_2_0,	p_ym_2_1);

	stitch(p_ym_0_1,	p_ym_1_1);
	stitch(p_ym_0_1,	p_ym_0_2);

	stitch(p_ym_1_1,	p_ym_2_1);
	stitch(p_ym_1_1,	p_ym_1_2);

	stitch(p_ym_2_1,	p_ym_2_2);

	stitch(p_ym_0_2,	p_ym_1_2);

	stitch(p_ym_1_2,	p_ym_2_2);


	for(auto g : prob->patch_groups_) {
		g->get_value_of_interest_residual("T");
	}	

	// solve;

	prob->connection_info();

	solve_with_source(prob);
	//solve_source(prob);
	//solve_temp(prob);

	prob->value_stats("T");

};
Exemplo n.º 17
0
int main(int argc, char *argv[])
{
    SegmentStitching stitch(argc, argv);
}
Exemplo n.º 18
0
int
main(int argc, char* argv[])
{
    // cv::CommandLineParserに渡すオプションの書式
    // 以下の順に記述する。
    // 省略名 (-hの形式) | 完全名 (--helpの形式) | デフォルト値 (省略可能) | 説明
    const char* option_keys =
        "{h| help| false| show help message}"
        "{o| out| out.png| output file name}"
        "{s| show| false| show output in window}"
        "{l| imagelist| | imagelist filename}"
        "{i| images| | image filenames separated with comma}";

    cv::CommandLineParser parser(argc, argv, option_keys);

    auto options = get_options(parser);

    if(options.show_help)
    {
        std::cout << "This program is sample code of cv::Stitcher." << std::endl;

        // cv::CommandLineParser::printParams() はオプションの概説を std::cout に出力する。
        parser.printParams();
        return 0;
    }

    // imagelist に記述されたファイル名を取得
    auto imagelist = read_imagelist(options.imagelist_filename);

    // コマンドライン引数で渡されたファイル名と結合
    imagelist.insert(imagelist.end(),
                     options.filenames.begin(), options.filenames.end());

    // 全画像ファイルを読み込み
    auto images = read_images(imagelist);

    if( images.empty() )
    {
        std::cout << "no image read" << std::endl;
        return -1;
    }

    if( images.size() != imagelist.size() )
    {
        std::cout << "some images are not able to be loaded" << std::endl;
    }

    cv::Mat panorama;

    auto stitcher = cv::Stitcher::createDefault(false);

    // cv::Stitcher::stitch() のみでスティッチングを行える。
    auto status = stitcher.stitch(images, panorama);

    if( status != cv::Stitcher::OK )
    {
        std::cout << "stitching failed" << std::endl;
        return -1;
    }

    if(options.show_result)
    {
        cv::namedWindow("image", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
        cv::imshow("image", panorama);
        cv::waitKey();
    }

    cv::imwrite(options.output_filename, panorama);

    return 0;
}