コード例 #1
0
ファイル: Triangle.cpp プロジェクト: filipkunc/MeshMaker
VertexEdgeNode *Triangle2::nextEdgeInQuadLoop(const VertexEdge &edge) const
{
    if (!isQuad())
        return NULL;
    
    for (unsigned int i = 0; i < count(); i++)
    {
        VertexEdgeNode *edgeNode = vertexEdge(i);
        VertexNode *sharedVertex = edgeNode->data().sharedVertex(edge);
        
        if (!sharedVertex)
            return edgeNode;
    }
    
    return NULL;
}
コード例 #2
0
ファイル: Triangle.cpp プロジェクト: filipkunc/MeshMaker
VertexEdgeNode *Triangle2::findSecondSplitEdgeNode(const VertexEdge &firstEdge) const
{
    for (unsigned int i = 0; i < count(); i++)
    {
        VertexEdgeNode *secondEdgeNode = vertexEdge(i);
        VertexEdge &secondEdge = secondEdgeNode->data();
        if (firstEdge.half != secondEdge.half && secondEdge.selected)
        {
            if (isQuad() && secondEdgeNode->data().sharedVertex(firstEdge) != NULL)
            {
                return NULL;
            }
            
            return secondEdgeNode;
        }
    }
    return NULL;
}
コード例 #3
0
string AstVar::vlArgType(bool named, bool forReturn, bool forFunc) const {
    if (forReturn) named=false;
    if (forReturn) v3fatalSrc("verilator internal data is never passed as return, but as first argument");
    string arg;
    if (isWide() && isInOnly()) arg += "const ";
    AstBasicDType* bdtypep = basicp();
    bool strtype = bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::STRING;
    if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::CHARPTR) {
	arg += "const char*";
    } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::SCOPEPTR) {
	arg += "const VerilatedScope*";
    } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::DOUBLE) {
	arg += "double";
    } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::FLOAT) {
	arg += "float";
    } else if (strtype) {
	if (isInOnly()) arg += "const ";
	arg += "string";
    } else if (widthMin() <= 8) {
	arg += "CData";
    } else if (widthMin() <= 16) {
	arg += "SData";
    } else if (widthMin() <= VL_WORDSIZE) {
	arg += "IData";
    } else if (isQuad()) {
	arg += "QData";
    } else if (isWide()) {
	arg += "WData";  // []'s added later
    }
    if (isWide() && !strtype) {
	arg += " (& "+name();
	arg += ")["+cvtToStr(widthWords())+"]";
    } else {
	if (forFunc && (isOutput() || (strtype && isInput()))) arg += "&";
	if (named) arg += " "+name();
    }
    return arg;
}
コード例 #4
0
string AstVar::vlEnumType() const {
    string arg;
    AstBasicDType* bdtypep = basicp();
    bool strtype = bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::STRING;
    if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::CHARPTR) {
	return "VLVT_PTR";
    } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::SCOPEPTR) {
	return "VLVT_PTR";
    } else if (strtype) {
	arg += "VLVT_STRING";
    } else if (widthMin() <= 8) {
	arg += "VLVT_UINT8";
    } else if (widthMin() <= 16) {
	arg += "VLVT_UINT16";
    } else if (widthMin() <= VL_WORDSIZE) {
	arg += "VLVT_UINT32";
    } else if (isQuad()) {
	arg += "VLVT_UINT64";
    } else if (isWide()) {
	arg += "VLVT_WDATA";
    }
    // else return "VLVT_UNKNOWN"
    return arg;
}
コード例 #5
0
int AstNodeClassDType::widthTotalBytes() const {
    if (width()<=8) return 1;
    else if (width()<=16) return 2;
    else if (isQuad()) return 8;
    else return widthWords()*(VL_WORDSIZE/8);
}
コード例 #6
0
int AstBasicDType::widthAlignBytes() const {
    if (width()<=8) return 1;
    else if (width()<=16) return 2;
    else if (isQuad()) return 8;
    else return 4;
}
コード例 #7
0
bool AstVar::isScQuad() const {
    return (isSc() && isQuad() && !isScBv() && !isScBigUint());
}
コード例 #8
0
VOID D3dDisplayList::optimize(D3dCtx *d3dCtx)
{

    D3dVertexBufferVector vCloneBufferVec;
    D3dVertexBuffer **r = &(*vBufferVec.begin());

    for (; r != &(*vBufferVec.end()); r++) {
	vCloneBufferVec.push_back(*r);

    }

    vBufferVec.erase(vBufferVec.begin(),  vBufferVec.end());

    D3dVertexBuffer **vbegin = &(*vCloneBufferVec.begin());
    D3dVertexBuffer **vend = &(*vCloneBufferVec.end());
    D3dVertexBuffer **q = vbegin;
    D3dVertexBuffer **p;
    int primitiveType, vcounts, climit;
    int indexCounts = 0;
    BOOL merge;
    LPD3DVERTEXBUFFER mergedVB;
    BOOL isPointFlagUsed;
    DWORD vertexFormat;
    BOOL isIndexPrimitive;
    BOOL quadFlag;

    while (q != vend) {
	primitiveType = (*q)->primitiveType;
	climit = (*q)->maxVertexLimit;
	vcounts = (*q)->vcount;
	isPointFlagUsed = (*q)->isPointFlagUsed;
	vertexFormat = (*q)->vertexFormat;
	isIndexPrimitive = (*q)->isIndexPrimitive;
	quadFlag = isQuad(*q);

	if ((*q)->indexBuffer != NULL) {
	    indexCounts = (*q)->indexCount;
	}
	merge = false;
	p = q + 1;

	while (p != vend) {
	    if (((*p)->primitiveType == primitiveType) &&
		((*p)->vertexFormat == vertexFormat) &&
		((*p)->isIndexPrimitive == isIndexPrimitive) &&
		(isQuad(*p) == quadFlag) &&
		((*p)->isPointFlagUsed == isPointFlagUsed) &&
		// This means Mutliple VBs already use
		((*p)->totalVertexCount == (*p)->vcount)) {
		vcounts += (*p)->totalVertexCount;
		if ((*p)->indexBuffer != NULL) {
		    indexCounts += (*p)->totalIndexCount;
		}
		if ((vcounts > climit) || (indexCounts > climit)) {
		    break;
		}
		p++;
		merge = true;
	    } else {
		break;
	    }
	}

	if (merge) {
	    mergedVB = createMergedVB(d3dCtx, q, p, vcounts, indexCounts);
	    if (mergedVB != NULL) {
		for (r = q; r != p; r++) {
		    SafeDelete(*r);
		}
		vBufferVec.push_back(mergedVB);
	    } else {
		for (r = q; r != p; r++) {
		    vBufferVec.push_back(*r);
		}
	    }
	} else {
	    vBufferVec.push_back(*q);
	}
	q = p;
    }

    vCloneBufferVec.erase(vCloneBufferVec.begin(),  vCloneBufferVec.end());
}
コード例 #9
0
ファイル: QrDetectorMod.cpp プロジェクト: GKaterbarg/QRcode
// Main execute funcion---------------------------------------------------------------------------------
vector<FP> QrDetectorMod::find() {
	Mat gray = Mat(image.rows, image.cols, CV_8UC1);
	Mat edges(image.size(), CV_MAKETYPE(image.depth(), 1));
	cvtColor(image, gray, CV_BGR2GRAY);
	Canny(gray, edges, 100, 200, 3);
	//imshow("edges", edges);
	vector<vector<Point>> contours;
	vector<Point> approx;

	//findContours(edges, contours, RETR_LIST, CHAIN_APPROX_NONE); 
	uchar** arr = matToArr(edges); /* trik use pointers for images*/ findContours_(arr, &contours);
	/*for (int i = 0; i < contours.size() - 1; i++){
		vector<Point> fst = contours[i];
		for (int j = i + 1; j < contours.size() - 1; j++){
			vector<Point> scd = contours[j];
			double endbeg = dist(fst[fst.size() - 1], scd[0]);
			double endend = dist(fst[fst.size() - 1], scd[scd.size() - 1]);
			double begbeg = dist(fst[0], scd[0]);
			double begend = dist(fst[0], scd[scd.size() - 1]);
			
			if (endbeg < 2){
				fst.insert(fst.end(), scd.begin(), scd.end());
				contours[i] = fst;
				contours.erase(contours.begin() + j);
			}
			if (begbeg < 2){
				reverse(fst.begin(), fst.end());
				fst.insert(fst.end(), scd.begin(), scd.end());
				contours[i] = fst;
				contours.erase(contours.begin() + j);
			}
			else
			if (endend < 2){
				fst.insert(fst.end(), scd.begin(), scd.end());
				contours[i] = fst;
				contours.erase(contours.begin() + j);
			}
			else
			if (begend < 2){
				scd.insert(scd.end(), fst.begin(), fst.end());
				contours[j] = scd;
				contours.erase(contours.begin() + i);
			}

		}
	}*/
	/*RNG rng(12345);
	for each (vector<Point> c in contours){
		Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));
		for each(Point p in c) circle(image, p, 1, color, -1);
	}*/

	for (int i = 0; i < contours.size(); i++)
	{
		approx = approximate(contours[i]);
		//for each (Point p in approx) circle(image, Point(p.x, p.y), 1, Scalar(0, 0, 255), -1); // for degug
		if (approx.size() == 4){
			//drawContours(image, contours, i, Scalar(255, 0, 0), CV_FILLED); //for debug
			if (isQuad(&approx) && abs(area(approx)) > 10){
				if (!inOtherContour(&approx)){
					quadList.push_back(vector<Point>(approx));
				}
			}
		}
	}

	if (quadList.size() < 2){
		return vector<FP>();
	}
	vector<FP> fps;
	for each(vector<Point> quad in quadList){

		Point min = minCoord(quad);
		Point max = maxCoord(quad);
		int x = min.x - 0.7*(max.x - min.x),
			y = min.y - 0.7*(max.y - min.y);
		if (x < 0) x = 0; if (y < 0) y = 0;
			
		int	w = 2.8 * (max.x - min.x),
			h = 2.8 * (max.y - min.y);
		if (h > 0.7*image.rows || w > 0.7*image.cols) continue;
		if (x + w > gray.cols) w = gray.cols - x - 1;
		if (h + y > gray.rows) h = gray.rows - y - 1;

		Mat partImg = gray(Rect(x, y, w, h));
		threshold(partImg, partImg, 128, 255, THRESH_OTSU); 
		int dif = quad[4].y - y;
		if (dif >= h || dif <= 0) continue;
		if (singleHorizontalCheck(partImg, dif)) {
			fps.push_back(FP(quad[4].x, quad[4].y, module));
			}
		else {
			if (fullHorizontalCheck(partImg)) {
				fps.push_back(FP(quad[4].x, quad[4].y, module));				}
		}
			//imshow("Parts", partImg);//for debug
			//waitKey(1200);//for debug
		}