示例#1
0
graph* makeGraphFromArray(int arr[],int size,int board[])
{
	graph* gr;
	int i,j;
	int k;
	gr= createGraph(101);
	gr->num=101;
	for(i=0;i<size;i++)
	{
		for(j=i+1;j<size;j++)
		{
			k = getMaxMoves(arr[i],arr[j],board);
		#ifdef DEBUG
			printf("addVertice: %d->%d: %d\n",arr[i],arr[j],k);
		#endif
			addVertices(gr,arr[i],arr[j],1,k);
		}

	}
#ifdef DEBUG
//	printGraph(gr);
#endif
	return gr;

}
示例#2
0
void STDRenderer::draw(const Color& clr, const RectF& srcRect, const RectF& destRect)
{
    Color color = clr;
    if (_blend == blend_premultiplied_alpha)
        color = color.premultiplied();

    vertexPCT2 v[4];
    fillQuadT(v, srcRect, destRect, _transform, color.rgba());


#ifdef OXYGINE_DEBUG_T2P
    if (_base != white && _showTexel2PixelErrors)
    {
        Rect viewport;
        _driver->getViewport(viewport);

        bool t = checkT2P(viewport, _vp, &v[0], &v[3], _base->getWidth(), _base->getHeight());
        if (!t)
        {
            float c = (sinf((float)getTimeMS() / 200 + v[0].x * v[0].y) + 1) / 2.0f;
            Color b = lerp(Color(rand() % 255, rand() % 255, rand() % 255, 255), color, c);
            fillQuadT(v, srcRect, destRect, _transform, b.rgba());
        }
    }
#endif

    addVertices(v, sizeof(v));
}
示例#3
0
/**
 * Convert an Image
 * into a Graph
 *
 * @param graph			The graph pointer
 * @param img			The Source image
 * @param neighboursWeight	Neighbours influence
 * @param windowSize	Neighbours range
 *
 *
 * @return Updates the graph
 */
void GRAPHCUT::img2graph(GCGraph<float>& graph, Mat& img, float neighboursWeight, int windowSize)
{
	cvtColor(img, img, CV_BGR2GRAY);
	normalize(img, img, 0, 1, NORM_MINMAX, CV_32F);

	addVertices(graph, img);
	addEdges(graph, img, neighboursWeight, windowSize);
}
示例#4
0
void StreamLines::process() {
    auto mesh = std::make_shared<BasicMesh>();
    mesh->setModelMatrix(sampler_.getData()->getModelMatrix());
    mesh->setWorldMatrix(sampler_.getData()->getWorldMatrix());

    auto m = streamLineProperties_.getSeedPointTransformationMatrix(
        sampler_.getData()->getCoordinateTransformer());


    ImageSampler tf(tf_.get().getData());

    float maxVelocity = 0;
    StreamLineTracer tracer(sampler_.getData(), streamLineProperties_);

    std::vector<BasicMesh::Vertex> vertices;

    for (const auto &seeds : seedPoints_) {
        for (auto &p : (*seeds)) {
            vec4 P = m * vec4(p, 1.0f);
            auto line = tracer.traceFrom(P.xyz());

            auto position = line.getPositions().begin();
            auto velocity = line.getMetaData("velocity").begin();

            auto size = line.getPositions().size();
            if (size == 0) continue;

            auto indexBuffer =
                mesh->addIndexBuffer(DrawType::Lines, ConnectivityType::StripAdjacency);

            indexBuffer->add(0);

            for (size_t i = 0; i < size; i++) {
                vec3 pos(*position);
                vec3 v(*velocity);

                float l = glm::length(vec3(*velocity));
                float d = glm::clamp(l / velocityScale_.get(), 0.0f, 1.0f);
                maxVelocity = std::max(maxVelocity, l);
                auto c = vec4(tf.sample(dvec2(d, 0.0)));

                indexBuffer->add(static_cast<std::uint32_t>(vertices.size()));

                vertices.push_back({pos, glm::normalize(v), pos, c});

                position++;
                velocity++;
            }
            indexBuffer->add(static_cast<std::uint32_t>(vertices.size() - 1));
        }
    }

    mesh->addVertices(vertices);

    linesStripsMesh_.setData(mesh);
    maxVelocity_.set(toString(maxVelocity));
}
示例#5
0
BoxPrimitive::BoxPrimitive(GLfloat width, GLfloat height, GLfloat depth): scale(width/2, height/2, depth/2)
{
    auto mesh = std::make_unique<Mesh>(3, Mesh::RenderMode::triangles);

    mesh->addVertices(::vertex);
    mesh->setTransform(glm::mat4());
    mesh->upload();
    addChild(std::move(mesh));
}
示例#6
0
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button) {

	if(breakupIntoTriangles) {

		// This is the manual way to triangulate the shape
		// you can then add many little triangles

		// first simplify the shape
		shape.simplify();

		// save the outline of the shape
		ofPolyline outline = shape;

		// resample shape
		ofPolyline resampled = shape.getResampledBySpacing(25);

		// trangleate the shape, return am array of traingles
		vector <TriangleShape> tris = triangulatePolygonWithOutline(resampled, outline);

		// add some random points inside
		addRandomPointsInside(shape, 255);

		// now loop through all the trainles and make a box2d triangle
		for(int i=0; i<tris.size(); i++) {

			auto triangle = std::make_shared<ofxBox2dPolygon>();
			triangle->addTriangle(ofDefaultVertexType(tris[i].a.x,
																								tris[i].a.y,
																								0),
														ofDefaultVertexType(tris[i].b.x,
																								tris[i].b.y,
																								0),
														ofDefaultVertexType(tris[i].c.x,
																								tris[i].c.y,
																								0));
			triangle->setPhysics(1.0, 0.3, 0.3);
			triangle->create(box2d.getWorld());

			polyShapes.push_back(triangle);
		}

	}
	else {
		auto poly = std::make_shared<ofxBox2dPolygon>();
		poly->addVertices(shape.getVertices());
		poly->setPhysics(1.0, 0.3, 0.3);
		poly->triangulatePoly();
		poly->create(box2d.getWorld());
		polyShapes.push_back(poly);
	}

	// done with shape clear it now
	shape.clear();
}
示例#7
0
void STDRenderer::drawElement(const spNativeTexture& texture, unsigned int color, const RectF& src, const RectF& dest)
{
    if (_base != texture)
    {
        drawBatch();
        _base = texture;
    }

    vertexPCT2 v[4];
    fillQuadT(v, src, dest, _transform, color);
    addVertices(v, sizeof(v));
}
示例#8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void GeometryBuilder::addTriangleByVertices(const Vec3f& v0, const Vec3f& v1, const Vec3f& v2)
{
    Vec3fArray verts;
    verts.resize(3);
    verts[0] = v0;
    verts[1] = v1;
    verts[2] = v2;

    uint firstVertexIdx = addVertices(verts);

    addTriangle(firstVertexIdx, firstVertexIdx + 1, firstVertexIdx + 2);
}
示例#9
0
// IP cust --- IBEGIN
void PlnrExpWgbendneg::vertices(
			DbsPlnr* dbsplnr
			, const ubigint x1RefPlnrMDesign
			, const ubigint refPlnrMDevice
			, const unsigned int modpar
			, const double phistart
			, const double phistop
			, const double r
			, const double ridgew
			, const double clr
			, ListPlnrMVertex& vtxs
		) {
	ostringstream str;

	vector<string> vsrefs;
	vector<double> vxs;
	vector<double> vys;

	double sphistart, cphistart;
	double sphistop, cphistop;

	// center vertex
	if (x1RefPlnrMDesign == 0) addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v0", 0.0, 0.0, vtxs);

	// - connector vertices
	sphistart = sin(2.0*pi*phistart/360.0);
	cphistart = cos(2.0*pi*phistart/360.0);
	sphistop = sin(2.0*pi*phistop/360.0);
	cphistop = cos(2.0*pi*phistop/360.0);

	// x,y positions
	vsrefs.push_back("v3"); vxs.push_back((r-0.5*ridgew-clr)*cphistart); vys.push_back((r-0.5*ridgew-clr)*sphistart);
	vsrefs.push_back("vsw"); vxs.push_back((r-0.5*ridgew)*cphistart); vys.push_back((r-0.5*ridgew)*sphistart);
	vsrefs.push_back("vsc"); vxs.push_back(r*cphistart); vys.push_back(r*sphistart);
	vsrefs.push_back("vse"); vxs.push_back((r+0.5*ridgew)*cphistart); vys.push_back((r+0.5*ridgew)*sphistart);
	vsrefs.push_back("v4"); vxs.push_back((r+0.5*ridgew+clr)*cphistart); vys.push_back((r+0.5*ridgew+clr)*sphistart);
	vsrefs.push_back("v1"); vxs.push_back((r-0.5*ridgew-clr)*cphistop); vys.push_back((r-0.5*ridgew-clr)*sphistop);
	vsrefs.push_back("vnw"); vxs.push_back((r-0.5*ridgew)*cphistop); vys.push_back((r-0.5*ridgew)*sphistop);
	vsrefs.push_back("vnc"); vxs.push_back(r*cphistop); vys.push_back(r*sphistop);
	vsrefs.push_back("vne"); vxs.push_back((r+0.5*ridgew)*cphistop); vys.push_back((r+0.5*ridgew)*sphistop);
	vsrefs.push_back("v2"); vxs.push_back((r+0.5*ridgew+clr)*cphistop); vys.push_back((r+0.5*ridgew+clr)*sphistop);

	if (x1RefPlnrMDesign == 0) {
		addVertices(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);

	} else {
		for (unsigned int i=1;i<=10;i++) {
			if ( (modpar & _R) || ((modpar & _PHISTART) && (i >= 1) && (i <= 5)) || ((modpar & _PHISTOP) && (i >= 6) && (i <= 10))
						|| ((modpar & _RIDGEW) && (i != 3) && (i != 8)) || ((modpar & _CLR) && (i == 1) && (i == 5) && (i == 6) && (i == 10)) ) 
				addVertexXYByVsref(dbsplnr, vsrefs[i-1], x1RefPlnrMDesign, vxs[i-1], vys[i-1], vtxs);
		};
	};
};
示例#10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void GeometryBuilder::addQuadByVertices(const Vec3f& v0, const Vec3f& v1, const Vec3f& v2, const Vec3f& v3)
{
    Vec3fArray verts;
    verts.resize(4);
    verts[0] = v0;
    verts[1] = v1;
    verts[2] = v2;
    verts[3] = v3;

    uint firstVertexIdx = addVertices(verts);

    addQuad(firstVertexIdx, firstVertexIdx + 1, firstVertexIdx + 2, firstVertexIdx + 3);
}
示例#11
0
//--------------------------------------------------------------
void ofxFatLine::setFromPolyline(ofPolyline & poly){
//	ofxFatLine();
	setGlobalColor(ofGetStyle().color);
	setGlobalWidth(ofGetStyle().lineWidth);
	if (!poly.getVertices().empty()){
		addVertices(poly.getVertices());
	for (int i = 0; i <getVertices().size(); i++) {
		addColor(globalColor);
		addWeight(globalWidth);
	}
	update();
	//*/
	}		
}
示例#12
0
ofxMesh &ofxMesh::addMesh(ofMesh b) {

    int numVertices = getNumVertices();
    int numIndices = getNumIndices();

    //add b
    addVertices(b.getVertices());
    addNormals(b.getNormals());
    addIndices(b.getIndices());

    //shift indices for b
    for (int i=0; i<b.getNumIndices(); i++) {
        getIndices()[numIndices+i] += numVertices;
    }

    return *this;
}
示例#13
0
std::shared_ptr<Mesh> Mandelbrot::getMesh()
{
	auto mesh = std::make_shared<Mesh>();

	std::cout << "Assembling Mandelbrot (" << (RESOLUTION * RESOLUTION) << "), making: ";

	std::cout << "vertices... ";
	addVertices(mesh);

	std::cout << "triangles... ";
	addIndices(mesh);

	std::cout << "normals... ";
	mesh->calcNormalsMWE();

	std::cout << "done" << std::endl;
	return mesh;
}
int main()
{
    unsigned int T = 0;
    unsigned int N = 0;
    unsigned int M = 0;
    unsigned int * S = NULL;
    unsigned int i = 0,j=0,k=0;
    unsigned int x = 0;
    unsigned int y = 0;
    unsigned int r = 0;

    graph ** gr = NULL;


    scanf("%d",&T);

    gr = (graph**)malloc(T*sizeof(graph));
    S = (unsigned int *)malloc(T*sizeof(unsigned int));

    for(i = 0;i<T;i++)
    {
        
        scanf("%d %d",&N,&M);
	gr[i]=(graph*)createGraph(N);
	for(j=0;j<M;j++)
	{
             scanf("%d %d %d",&x,&y,&r);
	     addVertices(gr[i],x-1,y-1,0,r);
	}
    
        scanf("%d",&S[i]);
//	printGraph(gr[i]);
//	dijkstra_ex(gr[i],S[i]-1);
    
    }


    for(i = 0;i<T;i++)
    {
	dijkstra_ex(gr[i],S[i]-1);

    }
	return 0;
}
示例#15
0
void ACIS_Internals::loadSAT(std::string fileName, GModel *gm)
{
  FILE *f = Fopen (fileName.c_str(), "r");
  if (!f){
    return;
  }
  outcome prout = api_restore_entity_list(f,1,entities);
  if (!prout.ok()){
    Msg::Error("Unable to load ACIS FILE %d",fileName.c_str());
    fclose(f);
    return;
  }
  Msg::Info("ACIS FILE %d Loaded",fileName.c_str());

  ENTITY *e;
  entities.init();
  while((e = entities.next())){
    //    printf("an entity\n");
    if (is_VERTEX(e)){
      //      printf("VERTEX FOUND\n");
    }
    if (is_BODY(e)){
      api_split_periodic_faces(e);
      {
	ENTITY_LIST vertex_list;
	outcome prout = api_get_vertices (e,vertex_list);
	addVertices (gm,vertex_list);
	printf("BODY COUNT %d !\n",vertex_list.count());
      }
      {
	ENTITY_LIST edge_list;
	outcome prout = api_get_edges (e,edge_list);
	addEdges (gm,edge_list);
	printf("BODY COUNT %d !\n",edge_list.count());
      }
      {
	ENTITY_LIST face_list;
	outcome prout = api_get_faces(e,face_list);
	addFaces (gm,face_list);
	printf("BODY COUNT %d !\n",face_list.count());
      }
    }
  }
}
示例#16
0
    deliberation::Draw createDraw()
    {
        auto program = context().createProgram({
                                                 deliberation::dataPath("Data/Examples/BasicSceneExample.vert"),
                                                 deliberation::dataPath("Data/Examples/BasicSceneExample.frag")
                                             });

        deliberation::UVSphere sphere(7, 7);
        auto mesh = sphere.generateMesh();

        deliberation::MeshCompiler compiler;
        auto compilation = compiler.compile(mesh);

        auto draw = context().createDraw(program, gl::GL_TRIANGLES);
        draw.addVertices(compilation.vertices);
        draw.setIndices(compilation.indices);

        return draw;
    }
示例#17
0
//--------------------------------------------------------------
void ofApp::setup() {

	ofDisableAntiAliasing();
	ofBackgroundHex(0xfdefc2);
	ofSetLogLevel(OF_LOG_NOTICE);
	ofSetVerticalSync(true);

	// Box2d
	box2d.init();
	box2d.setGravity(0, 10);
	box2d.createGround();
	box2d.setFPS(30.0);

	breakupIntoTriangles = true;

	// load the shape we saved...
	auto pts = loadPoints("shape.dat");
	auto poly = std::make_shared<ofxBox2dPolygon>();
	poly->addVertices(pts);
	poly->setPhysics(1.0, 0.3, 0.3);
	poly->triangulatePoly();
	poly->create(box2d.getWorld());
	polyShapes.push_back(poly);
}
void DrawStreamlinesImplementation::drawStreamline(
    Vec2D<float> point, float dir, const Grid<Vec2D<float>>& vector_field,
    const Grid<float>& scalar_field, float z) {
  Vec2D<float> gridpoint{point.x * (vector_field.x() - 1),
                         point.y * (vector_field.y() - 1)};

  vector<float> vertices;
  vector<float> colors;

  Vec2D<float> v1 = interpolate(vector_field, point);

  v1 *= dir;
  addVertices(vertices, colors, gridpoint, v1,
              getColorAtPoint(vector_field, scalar_field, point), z);

  Vec2D<float> last_point = gridpoint;

  bool early_exit = false;
  for (size_t i = 0; i < vector_field.x() * 3 && early_exit == false; i++) {
    Vec2D<float> v1 =
        interpolate(vector_field, {gridpoint.x / (vector_field.x() - 1),
                                   gridpoint.y / (vector_field.y() - 1)});
    v1 *= dir;

    // Calculate the predictor point and get the direction at that point.
    Vec2D<float> predictor = step(gridpoint, v1);
    Vec2D<float> v2 =
        interpolate(vector_field, {predictor.x / (vector_field.x() - 1),
                                   predictor.y / (vector_field.y() - 1)});

    v2 *= dir;

    v1 = (v1 + v2) / 2.0;
    if (v1.x * v1.x + v1.y * v1.y < 0.0000001) early_exit = true;

    gridpoint = step(gridpoint, v1);

    if (gridpoint.x < BORDER_PADDING) {
      gridpoint.x = BORDER_PADDING;
      early_exit = true;
    }
    if (gridpoint.x > vector_field.x() - BORDER_PADDING) {
      gridpoint.x = vector_field.x() - BORDER_PADDING;
      early_exit = true;
    }
    if (gridpoint.y < BORDER_PADDING ||
        gridpoint.y > vector_field.y() - BORDER_PADDING)
      early_exit = true;

    auto point = Vec2D<float>{gridpoint.x / (vector_field.x() - 1),
                              gridpoint.y / (vector_field.y() - 1)};

    v1 = interpolate(vector_field, point);
    v1 = v1.normalize();
    v1 *= dir;
    if (early_exit || (gridpoint - last_point).normalize() * v1 < 0.99999999) {
      addVertices(vertices, colors, gridpoint, v1,
                  getColorAtPoint(vector_field, scalar_field, point), z);
      last_point = gridpoint;
    }
  }

  glEnableClientState(GL_COLOR_ARRAY);
  glEnableClientState(GL_VERTEX_ARRAY);

  glVertexPointer(3, GL_FLOAT, 0, (float*)vertices.data());
  glColorPointer(4, GL_FLOAT, 0, (float*)colors.data());

  glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices.size() / 3);

  glDisableClientState(GL_VERTEX_ARRAY);
  glDisableClientState(GL_COLOR_ARRAY);
}
示例#19
0
//--------------------------------------------------------------
void ofxFatLine::add(const vector<ofVec3f> &thePoints, const vector<ofFloatColor> &theColors, const vector<double> &theWeights){
    addVertices(thePoints);
    addColors(theColors);
    addWeights(theWeights);
    update();
}
示例#20
0
文件: graph.cpp 项目: ntamas/igraphpp
void Graph::addVertex() { addVertices(1); }
示例#21
0
// IP cust --- IBEGIN
void PlnrExpRtresneg::vertices(
			DbsPlnr* dbsplnr
			, const ubigint x1RefPlnrMDesign
			, const ubigint refPlnrMDevice
			, const unsigned int modpar
			, const double ridgew
			, const double r
			, const double cpllen
			, const double dist
			, const double clr
			, ListPlnrMVertex& vtxs
		) {
	ostringstream str;

	vector<string> vsrefs;
	vector<double> vxs;
	vector<double> vys;

	// center vertex
	if (x1RefPlnrMDesign == 0) addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "vctr", 0.0, 0.0, vtxs);

	// - w center line vertices (e are flipped copies of w)
	vsrefs.push_back("v1"); vxs.push_back(-(r+0.5*ridgew+clr)); vys.push_back(0.0);
	vsrefs.push_back("v2"); vxs.push_back(-(r+0.5*ridgew+dist)); vys.push_back(0.0);
	vsrefs.push_back("v3"); vxs.push_back(-(r+0.5*ridgew)); vys.push_back(0.0);
	vsrefs.push_back("v4"); vxs.push_back(-(r-0.5*ridgew)); vys.push_back(0.0);
	vsrefs.push_back("v5"); vxs.push_back(-(r-0.5*ridgew-clr)); vys.push_back(0.0);

	if (x1RefPlnrMDesign == 0) {
		addVertices(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);

	} else {
		for (unsigned int i=1;i<=5;i++) {
			if ( (((i == 1) || (i == 5))  && (modpar & (_R + _RIDGEW + _CLR)))
							|| ((i == 2)  && (modpar & (_R + _RIDGEW + _DIST)))
							|| (((i == 3) || (i == 4)) && (modpar & (_R + _RIDGEW))) )
				addVertexXYByVsref(dbsplnr, vsrefs[i-1], x1RefPlnrMDesign, vxs[i-1], vys[i-1], vtxs);
		};
	};

	// e (w /x)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=1;i<=5;i++) {
			str.str(""); str << "v" << (i+5);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), -vxs[i-1], 0.0, vtxs);
		};

	} else {
		for (unsigned int i=1;i<=5;i++) {
			str.str(""); str << "v" << (i+5);
			if ( (((i == 1) || (i == 5))  && (modpar & (_R + _RIDGEW + _CLR)))
							|| ((i == 2)  && (modpar & (_R + _RIDGEW + _DIST)))
							|| (((i == 3) || (i == 4)) && (modpar & (_R + _RIDGEW))) )
				addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, -vxs[i-1], 0.0, vtxs);
		};
	};

	// - arc center vertices
	if (x1RefPlnrMDesign == 0) {
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v11", 0.0, 0.5*cpllen, vtxs);
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v12", 0.0, -0.5*cpllen, vtxs);

	} else {
		if (modpar & _CPLLEN) {
			addVertexXYByVsref(dbsplnr, "v11", x1RefPlnrMDesign, 0.0, 0.5*cpllen, vtxs);
			addVertexXYByVsref(dbsplnr, "v12", x1RefPlnrMDesign, 0.0, -0.5*cpllen, vtxs);
		};
	};

	// - nw vertices
	vsrefs.resize(0);
	vxs.resize(0);
	vys.resize(0);

	vsrefs.push_back("v13"); vxs.push_back(-(r+0.5*ridgew+clr)); vys.push_back(0.5*cpllen);
	vsrefs.push_back("v14"); vxs.push_back(-(r+0.5*ridgew)); vys.push_back(0.5*cpllen);
	vsrefs.push_back("v15"); vxs.push_back(-(r-0.5*ridgew)); vys.push_back(0.5*cpllen);
	vsrefs.push_back("v16"); vxs.push_back(-(r-0.5*ridgew-clr)); vys.push_back(0.5*cpllen);
	vsrefs.push_back("v17"); vxs.push_back(-(r+0.5*ridgew+dist)); vys.push_back(0.5*cpllen+sqrt( (r+0.5*ridgew+clr)*(r+0.5*ridgew+clr) - (r+0.5*ridgew+dist)*(r+0.5*ridgew+dist) ));
	vsrefs.push_back("v18"); vxs.push_back(-(r+0.5*ridgew+dist-clr)); vys.push_back(0.5*cpllen+sqrt( (r+0.5*ridgew+clr)*(r+0.5*ridgew+clr) - (-(r+0.5*ridgew+dist)+clr)*(-(r+0.5*ridgew+dist)+clr) ));
	vsrefs.push_back("v19"); vxs.push_back(-(r+0.5*ridgew+dist-clr)); vys.push_back(0.5*cpllen+r+0.5*ridgew+clr);
	vsrefs.push_back("v20"); vxs.push_back(-(r+0.5*ridgew+dist+ridgew+clr)); vys.push_back(0.5*cpllen+r+0.5*ridgew+clr);

	if (x1RefPlnrMDesign == 0) {
		addVertices(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);

	} else {
		for (unsigned int i=13;i<=20;i++) {
			if ( (((i == 13) || (i == 16))  && (modpar & (_R + _RIDGEW + _CLR + _CPLLEN)))
							|| (((i == 14) || (i == 15))  && (modpar & (_R + _RIDGEW + _CPLLEN)))
							|| ((i == 17) || (i == 18) || (i == 19) || (i == 20)) )
				addVertexXYByVsref(dbsplnr, vsrefs[i-13], x1RefPlnrMDesign, vxs[i-13], vys[i-13], vtxs);
		};
	};

	// ne (nw /x)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+8);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), -vxs[i-13], vys[i-13], vtxs);
		};

	} else {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+8);
			if ( (((i == 13) || (i == 16))  && (modpar & (_R + _RIDGEW + _CLR + _CPLLEN)))
							|| (((i == 14) || (i == 15))  && (modpar & (_R + _RIDGEW + _CPLLEN)))
							|| ((i == 17) || (i == 18) || (i == 19) || (i == 20)) )
				addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, -vxs[i-13], vys[i-13], vtxs);
		};
	};

	// sw (nw /y)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+16);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), vxs[i-13], -vys[i-13], vtxs);
		};

	} else {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+16);
			if ( (((i == 13) || (i == 16))  && (modpar & (_R + _RIDGEW + _CLR + _CPLLEN)))
							|| (((i == 14) || (i == 15))  && (modpar & (_R + _RIDGEW + _CPLLEN)))
							|| ((i == 17) || (i == 18) || (i == 19) || (i == 20)) )
				addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, vxs[i-13], -vys[i-13], vtxs);
		};
	};

	// se (nw /x/y)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+24);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), -vxs[i-13], -vys[i-13], vtxs);
		};

	} else {
		for (unsigned int i=13;i<=20;i++) {
			str.str(""); str << "v" << (i+24);
			if ( (((i == 13) || (i == 16))  && (modpar & (_R + _RIDGEW + _CLR + _CPLLEN)))
							|| (((i == 14) || (i == 15))  && (modpar & (_R + _RIDGEW + _CPLLEN)))
							|| ((i == 17) || (i == 18) || (i == 19) || (i == 20)) )
				addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, -vxs[i-13], -vys[i-13], vtxs);
		};
	};

	// - waveguide connector vertices
	vsrefs.resize(0);
	vxs.resize(0);
	vys.resize(0);

	vsrefs.push_back("vwg1nw"); vxs.push_back(-(r+0.5*ridgew+dist+ridgew)); vys.push_back(0.5*cpllen+r+0.5*ridgew+clr);
	vsrefs.push_back("vwg1nc"); vxs.push_back(-(r+0.5*ridgew+dist+0.5*ridgew)); vys.push_back(0.5*cpllen+r+0.5*ridgew+clr);
	vsrefs.push_back("vwg1ne"); vxs.push_back(-(r+0.5*ridgew+dist)); vys.push_back(0.5*cpllen+r+0.5*ridgew+clr);

	// wg2n (wg1n /x)
	vsrefs.push_back("vwg2ne"); vxs.push_back(-vxs[0]); vys.push_back(vys[0]);
	vsrefs.push_back("vwg2nc"); vxs.push_back(-vxs[1]); vys.push_back(vys[1]);
	vsrefs.push_back("vwg2nw"); vxs.push_back(-vxs[2]); vys.push_back(vys[2]);

	// wg1s (wg1n /y)
	vsrefs.push_back("vwg1sw"); vxs.push_back(vxs[0]); vys.push_back(-vys[0]);
	vsrefs.push_back("vwg1sc"); vxs.push_back(vxs[1]); vys.push_back(-vys[1]);
	vsrefs.push_back("vwg1se"); vxs.push_back(vxs[2]); vys.push_back(-vys[2]);

	// wg2s (wg1n /x/y)
	vsrefs.push_back("vwg2se"); vxs.push_back(-vxs[0]); vys.push_back(-vys[0]);
	vsrefs.push_back("vwg2sc"); vxs.push_back(-vxs[1]); vys.push_back(-vys[1]);
	vsrefs.push_back("vwg2sw"); vxs.push_back(-vxs[2]); vys.push_back(-vys[2]);

	if (x1RefPlnrMDesign == 0) {
		addVertices(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);
	} else {
		addVertexXYs(dbsplnr, vsrefs, x1RefPlnrMDesign, vxs, vys, vtxs);
	};
};
示例#22
0
//----------------------------------------------------------
ofPolyline::ofPolyline(const vector<ofPoint>& verts){
    setRightVector();
	clear();
	addVertices(verts);
}
示例#23
0
// IP cust --- IBEGIN
void PlnrExpVanderpauw::vertices(
			DbsPlnr* dbsplnr
			, const ubigint x1RefPlnrMDesign
			, const ubigint refPlnrMDevice
			, const unsigned int modpar
			, const double crsl
			, const double crsw
			, const double size
			, ListPlnrMVertex& vtxs
		) {
	ostringstream str;

	vector<string> vsrefs;
	vector<double> vxs;
	vector<double> vys;

	// center vertex
	if (x1RefPlnrMDesign == 0) addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "vctr", 0.0, 0.0, vtxs);

	// -- nw vertices (ne, sw and se are flipped copies of nw)

	// x,y positions
	vsrefs.push_back("v1"); vxs.push_back(-0.5*size); vys.push_back(0.5*crsw);
	vsrefs.push_back("v2"); vxs.push_back(-0.5*crsl); vys.push_back(0.5*crsw);
	vsrefs.push_back("v3"); vxs.push_back(-0.5*crsw); vys.push_back(0.5*crsl);
	vsrefs.push_back("v4"); vxs.push_back(-0.5*crsw); vys.push_back(0.5*size);

	if (x1RefPlnrMDesign == 0) {
		addVertices(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);

	} else {
		for (unsigned int i=1;i<=4;i++) {
			if ( (((i == 1) || (i == 4)) && (modpar & (_SIZE + _CRSW))) 
						|| (((i == 2) || (i == 3)) && (modpar & (_CRSL + _CRSW))) ) addVertexXYByVsref(dbsplnr, vsrefs[i-1], x1RefPlnrMDesign, vxs[i-1], vys[i-1], vtxs);
		};
	};

	// -- ne (nw /x)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+4);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), -vxs[i-1], vys[i-1], vtxs);
		};

	} else {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+4);
			if ( (((i == 1) || (i == 4)) && (modpar & (_SIZE + _CRSW))) 
						|| (((i == 2) || (i == 3)) && (modpar & (_CRSL + _CRSW))) ) addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, -vxs[i-1], vys[i-1], vtxs);
		};
	};

	// -- sw (nw /y)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+8);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), vxs[i-1], -vys[i-1], vtxs);
		};

	} else {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+8);
			if ( (((i == 1) || (i == 4)) && (modpar & (_SIZE + _CRSW))) 
						|| (((i == 2) || (i == 3)) && (modpar & (_CRSL + _CRSW))) ) addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, vxs[i-1], -vys[i-1], vtxs);
		};
	};

	// -- se (nw /x/y)
	if (x1RefPlnrMDesign == 0) {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+12);
			addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, str.str(), -vxs[i-1], -vys[i-1], vtxs);
		};

	} else {
		for (unsigned int i=1;i<=4;i++) {
			str.str(""); str << "v" << (i+12);
			if ( (((i == 1) || (i == 4)) && (modpar & (_SIZE + _CRSW))) 
						|| (((i == 2) || (i == 3)) && (modpar & (_CRSL + _CRSW))) ) addVertexXYByVsref(dbsplnr, str.str(), x1RefPlnrMDesign, -vxs[i-1], -vys[i-1], vtxs);
		};
	};

	// -- arc center vertices
	if (x1RefPlnrMDesign == 0) {
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v17", -0.5*crsw, 0.5*crsw, vtxs);
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v18", 0.5*crsw, 0.5*crsw, vtxs);
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v19", -0.5*crsw, -0.5*crsw, vtxs);
		addVertex(dbsplnr, 0, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v20", 0.5*crsw, -0.5*crsw, vtxs);

	} else if ((x1RefPlnrMDesign != 0) && (modpar & _CRSW)) {
		addVertexXYByVsref(dbsplnr, "v17", x1RefPlnrMDesign, -0.5*crsw, 0.5*crsw, vtxs);
		addVertexXYByVsref(dbsplnr, "v18", x1RefPlnrMDesign, 0.5*crsw, 0.5*crsw, vtxs);
		addVertexXYByVsref(dbsplnr, "v19", x1RefPlnrMDesign, -0.5*crsw, -0.5*crsw, vtxs);
		addVertexXYByVsref(dbsplnr, "v20", x1RefPlnrMDesign, 0.5*crsw, -0.5*crsw, vtxs);
	};
};
示例#24
0
TextBuffer::TextBuffer(std::shared_ptr<VertexLayout> _vertexLayout)
    : LabelMesh(_vertexLayout, GL_TRIANGLES) {
    addVertices({}, {});
}
示例#25
0
TextBuffer::TextBuffer(std::shared_ptr<VertexLayout> _vertexLayout)
    : LabelMesh(_vertexLayout, GL_TRIANGLES) {

    m_dirtyTransform = false;
    addVertices({}, {});
}
示例#26
0
	template <class R> void CMatrix<R>::addVertices(int a, int b, R factor) {
		addVertices(a, b, factor, 0);
	}
示例#27
0
void Vbo::addVertex(GLbyte* _vertex) {
    addVertices(_vertex, 1);
}
示例#28
0
// IP cust --- IBEGIN
void PlnrExpCorner::vertices(
			DbsPlnr* dbsplnr
			, const ubigint x1RefPlnrMDesign
			, const ubigint refPlnrMDevice
			, const unsigned int modpar
			, const double size
			,	const double w
			,	const bool sq
			, const double alnclr
			, const double sprclr
			, ListPlnrMVertex& vtxs
		) {
	vector<string> vsrefs;
	vector<double> vxs;
	vector<double> vys;

	double xy0, a;

	// initial vertex
	if ((x1RefPlnrMDesign == 0) || (modpar & _SQ)) addVertex(dbsplnr, x1RefPlnrMDesign, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, "v0", 0.0, 0.0, vtxs);

	// remaining vertices (x,y positions)
	vsrefs.push_back("v1"); vxs.push_back(size-sprclr-alnclr); vys.push_back(0.0);
	vsrefs.push_back("v2"); vxs.push_back(size-sprclr-alnclr); vys.push_back(w);
	vsrefs.push_back("v3"); vxs.push_back(w); vys.push_back(w);
	vsrefs.push_back("v4"); vxs.push_back(w); vys.push_back(size-sprclr-alnclr);
	vsrefs.push_back("v5"); vxs.push_back(0.0); vys.push_back(size-sprclr-alnclr);

	vsrefs.push_back("v6"); vxs.push_back(size-sprclr); vys.push_back(0.0);
	vsrefs.push_back("v7"); vxs.push_back(size-sprclr); vys.push_back(w+2.0*alnclr);
	vsrefs.push_back("v8"); vxs.push_back(0.5*((w+alnclr) + (size-sprclr))); vys.push_back(w+2.0*alnclr);
	vsrefs.push_back("v9"); vxs.push_back(0.5*((w+alnclr) + (size-sprclr))); vys.push_back(w+alnclr);
	vsrefs.push_back("v10"); vxs.push_back(w+alnclr); vys.push_back(w+alnclr);
	vsrefs.push_back("v11"); vxs.push_back(w+alnclr); vys.push_back(0.5*((w+alnclr) + (size-sprclr)));
	vsrefs.push_back("v12"); vxs.push_back(w+2.0*alnclr); vys.push_back(0.5*((w+alnclr) + (size-sprclr)));
	vsrefs.push_back("v13"); vxs.push_back(w+2.0*alnclr); vys.push_back(size-sprclr);
	vsrefs.push_back("v14"); vxs.push_back(0.0); vys.push_back(size-sprclr);

	vsrefs.push_back("v15"); vxs.push_back(size); vys.push_back(0.0);
	vsrefs.push_back("v16"); vxs.push_back(size); vys.push_back(w+2.0*alnclr+sprclr);
	vsrefs.push_back("v17"); vxs.push_back(w+2.0*alnclr+sprclr); vys.push_back(w+2.0*alnclr+sprclr);
	vsrefs.push_back("v18"); vxs.push_back(w+2.0*alnclr+sprclr); vys.push_back(size);
	vsrefs.push_back("v19"); vxs.push_back(0.0); vys.push_back(size);

	vsrefs.push_back("v23"); vxs.push_back(size); vys.push_back(size);

	if (sq) {
		xy0 = size-(w+alnclr+sprclr);

		a = 2.0*(w+alnclr+sprclr);
		vsrefs.push_back("v20"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v21"); vxs.push_back(xy0); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v22"); vxs.push_back(xy0+0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v24"); vxs.push_back(xy0); vys.push_back(xy0+0.5*a);
		vsrefs.push_back("v25"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0+0.5*a);

		a = 2.0*(w+alnclr);
		vsrefs.push_back("v26"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v27"); vxs.push_back(xy0); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v28"); vxs.push_back(xy0+0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v29"); vxs.push_back(xy0+0.5*a); vys.push_back(xy0+0.5*a);
		vsrefs.push_back("v30"); vxs.push_back(xy0); vys.push_back(xy0+0.5*a);
		vsrefs.push_back("v31"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0+0.5*a);

		a = 2.0*w;
		vsrefs.push_back("v32"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v33"); vxs.push_back(xy0); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v34"); vxs.push_back(xy0+0.5*a); vys.push_back(xy0-0.5*a);
		vsrefs.push_back("v35"); vxs.push_back(xy0+0.5*a); vys.push_back(xy0+0.5*a);
		vsrefs.push_back("v36"); vxs.push_back(xy0); vys.push_back(xy0+0.5*a);
		vsrefs.push_back("v37"); vxs.push_back(xy0-0.5*a); vys.push_back(xy0+0.5*a);
	};

	if ((x1RefPlnrMDesign == 0) || (modpar & _SQ)) {
		addVertices(dbsplnr, x1RefPlnrMDesign, VecPlnrVMVertexHkTbl::DEV, refPlnrMDevice, vsrefs, vxs, vys, vtxs);
	} else {
		addVertexXYs(dbsplnr, vsrefs, x1RefPlnrMDesign, vxs, vys, vtxs);
	};
};
//--------------------------------------------------------------
ofMesh::ofMesh(ofPrimitiveMode mode, const vector<ofVec3f>& verts){
	setMode(mode);
	addVertices(verts);
}
示例#30
0
int main()
{
    /* test */
	int i,j,k,l,m,n;
	int exit = 1;
	int dir = 0;
	graph* gr=NULL;
	myQueue * q = NULL;
	while(exit)
	{
		printf("\nTEST MENU\n");
		printf("*********\n");
		printf("1.Create and print a graph\n");
		printf("2.DFS\n");
		printf("5.Exit\n");
		scanf("%d",&m);
		switch(m)
		{
			case 1:
				printf("Enter no of nodes\n");
				scanf("%d",&k);
				printf("Enter 0:UnDirected 1:Directed\n");
				scanf("%d",&dir);
				gr=(graph*)createGraph(k);
	//			addVertices(gr,0,1,dir,1);
				addVertices(gr,0,4,dir,4);
				addVertices(gr,1,2,dir,2);
				addVertices(gr,1,3,dir,3);
				addVertices(gr,1,4,dir,4);
				addVertices(gr,2,3,dir,3);
				addVertices(gr,3,4,dir,4);
				printGraph(gr);
				break;
			case 2:
				graph_DFS(gr,0);
				break;
			case 3:
				q = createQ(10);
				enQ(q,1);
				enQ(q,3);
				enQ(q,5);
				deQ(q);
				enQ(q,7);
				enQ(q,9);
				enQ(q,11);
				deQ(q);
				deQ(q);
				deQ(q);


				break;
			case 5:
				exit = 0;
				break;
		}

	}


    return 0;
}