当前位置: 首页>>代码示例>>C++>>正文


C++ Polyline类代码示例

本文整理汇总了C++中Polyline的典型用法代码示例。如果您正苦于以下问题:C++ Polyline类的具体用法?C++ Polyline怎么用?C++ Polyline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Polyline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Factory

//----------------------------------------------------------------------------
// streaming
//----------------------------------------------------------------------------
Object* Polyline::Factory (Stream& rkStream)
{
    Polyline* pkObject = new Polyline;
    Stream::Link* pkLink = new Stream::Link(pkObject);
    pkObject->Load(rkStream,pkLink);
    return pkObject;
}
开发者ID:Steven0818,项目名称:Deform,代码行数:10,代码来源:WmlPolyline.cpp

示例2:

void
Polygon::equally_spaced_points(double distance, Points* points) const
{
    Polyline polyline;
    this->split_at_first_point(&polyline);
    polyline.equally_spaced_points(distance, points);
}
开发者ID:JoeyKramer1,项目名称:Slic3r,代码行数:7,代码来源:Polygon.cpp

示例3:

Polyline
AvoidCrossingPerimeters::travel_to(GCode &gcodegen, Point point)
{
    if (this->use_external_mp || this->use_external_mp_once) {
        // get current origin set in gcodegen
        // (the one that will be used to translate the G-code coordinates by)
        Point scaled_origin = Point::new_scale(gcodegen.origin.x, gcodegen.origin.y);
        
        // represent last_pos in absolute G-code coordinates
        Point last_pos = gcodegen.last_pos();
        last_pos.translate(scaled_origin);
        
        // represent point in absolute G-code coordinates
        point.translate(scaled_origin);
        
        // calculate path
        Polyline travel = this->_external_mp->shortest_path(last_pos, point);
        
        // translate the path back into the shifted coordinate system that gcodegen
        // is currently using for writing coordinates
        travel.translate(scaled_origin.negative());
        return travel;
    } else {
        return this->_layer_mp->shortest_path(gcodegen.last_pos(), point);
    }
}
开发者ID:BradNagel,项目名称:Slic3r,代码行数:26,代码来源:GCode.cpp

示例4: WmlStaticCast

//----------------------------------------------------------------------------
void GelatinBlob::DoPhysical ()
{
    m_pkModule->Update(GetTimeInSeconds());

    // Update sphere surface.  The particle system and sphere maintain their
    // own copy of the vertices, so this update is necessary.
    Vector3f* akVertex = m_spkSphere->Vertices();
    int i;
    for (i = 0; i < 12; i++)
        akVertex[i] = m_pkModule->Position(i);

    m_spkSphere->UpdateModelBound();

    // update the segments representing the springs
    int iNumSprings = m_pkModule->GetNumSprings();
    for (i = 0; i < iNumSprings; i++)
    {
        int iV0, iV1;
        float fConstant, fLength;
        m_pkModule->GetSpring(i,iV0,iV1,fConstant,fLength);

        Polyline* pkPoly = WmlStaticCast(Polyline,m_spkSegments->GetChild(i));
        Vector3f* akVertex = pkPoly->Vertices();
        akVertex[0] = m_pkModule->Position(iV0);
        akVertex[1] = m_pkModule->Position(iV1);
    }
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:28,代码来源:GelatinBlob.cpp

示例5: N

TriangleMesh*
MeshSweeper::makeBox(
  const vec3& center,
  const vec3& normal,
  const vec3& up,
  const vec3& size,
  const mat4& m)
//[]----------------------------------------------------[]
//|  Make box 1                                          |
//[]----------------------------------------------------[]
{
  Polyline poly;
  vec3 N(normal.versor());
  vec3 U(up.cross(normal).versor());
  vec3 V(N.cross(U));

  N *= size.z * (REAL)0.5;
  U *= size.x * (REAL)0.5;
  V *= size.y * (REAL)0.5;
  poly.mv(center - U - V - N);
  poly.mv(center + U - V - N);
  poly.mv(center + U + V - N);
  poly.mv(center - U + V - N);
  poly.close();
  return makeCylinder(poly, 2 * N, m);
}
开发者ID:UelitonFreitas,项目名称:CG,代码行数:26,代码来源:MeshSweeper.cpp

示例6:

Points
Polygon::equally_spaced_points(double distance) const
{
    Polyline* polyline = this->split_at_first_point();
    Points pts = polyline->equally_spaced_points(distance);
    delete polyline;
    return pts;
}
开发者ID:valterfc,项目名称:Slic3r,代码行数:8,代码来源:Polygon.cpp

示例7: while

void Canvas::load(string path) {

    cout << "load" << endl;

    for (int i = 0; i < lines.size(); i++) {
        lines[i]->release();
        delete lines[i];
    }
    lines.clear();

    while (!joints.empty()) {
        delete joints.back();
        joints.pop_back();
    }

    int lines_n;
    int n;

    ifstream file(path.c_str());
    if (file.is_open()) {

        int i = 0;
        file >> n;
        for (int i = 0; i < n; i++) {
            Joint *v = new Joint();
            v->setupGui();
            file >> v->p.x;
            file >> v->p.y;
            int fixed;
            file >> fixed;
            v->fixed = (bool)fixed;
            *v->fixed_toggle = v->fixed;
            v->joint_type = JOINT_REVOLUTE;
            v->id = i;
            joints.push_back(v);
        }

        file >> lines_n;
        for (int i = 0; i < lines_n; i++) {
            lines.push_back(new Polyline());
            Polyline *l = lines.back();
            l->id = lines.size() - 1;
            file >> n;
            file >> l->closed;
            for (int i = 0; i < n; i++) {
                Vertex v;
                file >> v.p.x;
                file >> v.p.y;
                l->addBack(&v);
            }
            if (l->closed) {
                l->back->next = l->front;
                l->front->prev = l->back;
            }
            l->update();
        }
        file.close();
    }
开发者ID:coolvision,项目名称:simple_cad,代码行数:58,代码来源:Canvas.cpp

示例8: GeoObject

Polyline::Polyline(const Polyline& ply) : GeoObject(), _ply_pnts(ply._ply_pnts)
{
	for (size_t k(0); k < ply.getNumberOfPoints(); ++k)
		_ply_pnt_ids.push_back(ply.getPointID(k));

	if (ply.getNumberOfPoints() > 0)
		for (size_t k(0); k < ply.getNumberOfPoints(); ++k)
			_length.push_back(ply.getLength(k));
}
开发者ID:AkaBlood,项目名称:ogs5,代码行数:9,代码来源:Polyline.cpp

示例9: Polyline

Polyline* ProgressBar::getBorder(int index) {
  int y2 = yy+myHeight;
  Polyline* p = new Polyline(5);
    p->addNextVertex(startX[index],yy,BLACK);
    p->addNextVertex(startX[index]+myWidth/segs,yy,BLACK);
    p->addNextVertex(startX[index]+myWidth/segs,y2,BLACK);
    p->addNextVertex(startX[index],y2,BLACK);
    p->addNextVertex(startX[index],yy,BLACK);
  return p;
}
开发者ID:Calvin-CS,项目名称:TSGL,代码行数:10,代码来源:ProgressBar.cpp

示例10: Polyline

Polyline * Factory::getRandPolyline() {
	Polyline * pl = new Polyline();
	int N = iRand(1, 10);
	for (int i = 0; i < N; i++) {
		Point * p = getRandPoint();
		pl->addPoint(* p);
		delete p;
	}	
	return pl;
}
开发者ID:auzubarev,项目名称:OOPcpp,代码行数:10,代码来源:Factory.cpp

示例11: isLineSegmentIntersecting

bool isLineSegmentIntersecting(const Polyline& ply, GEOLIB::Point const& s0, GEOLIB::Point const& s1)
{
	const size_t n(ply.getNumberOfPoints() - 1);
	bool intersect(false);
	GEOLIB::Point intersection_pnt;
	for (size_t k(0); k < n && !intersect; k++)
	{
		intersect = MathLib::lineSegmentIntersect(*(ply.getPoint(k)), *(ply.getPoint(k + 1)), s0, s1, intersection_pnt);
	}
	return intersect;
}
开发者ID:AkaBlood,项目名称:ogs5,代码行数:11,代码来源:Polyline.cpp

示例12: main

int main() {	
	srand((unsigned) time(NULL));

	try {
		XList<Shape*> list;
		// filling list of figures with random figures of all types.
		int numberOfElements = rand() % 100;
		for(int i = 0; i < numberOfElements; i++) {
			switch (i % 5) {
			case 0:
				list.pushElementToBack(new Point("TestPoint", rand() % 100, rand() % 100));
				break;
			case 1:
				list.pushElementToBack(new Circle("TestCircle", rand() % 100, rand() % 100, rand() % 100));
				break;
			case 2:
				list.pushElementToBack(new Rect("TestRect", rand() % 100, rand() % 100, rand() % 100, rand() % 100));
				break;
			case 3:
				list.pushElementToBack(new Square("TestSquare", rand() % 100, rand() % 100, rand() % 100));
				break;
			case 4:
				Polyline* pol = new Polyline("TestPol");				
				Point p1("pol_point_1", rand() % 100, rand() % 100);
				Point p2("pol_point_2", rand() % 100, rand() % 100);
				Point p3("pol_point_3", rand() % 100, rand() % 100);
				pol->addPoint(p1);
				pol->addPoint(p2);
				pol->addPoint(p3);
				list.pushElementToBack(pol);
				break;
			}
		}

		std::cout << "Number of shapes " << Shape::getNumberOfShapes() << "\n";
		XList<Shape*>::Iterator it = list.begin();
		for(it = list.begin(); it != list.end(); ++it) {
			std::cout << "\n" << **it << "\n";
		}

		std::cout << "Number of shapes " << Shape::getNumberOfShapes() << "\n";
		for(it = list.begin(); it != list.end(); ++it) {
			delete *it;
		}

		// should be zero
		std::cout << "Number of shapes " << Shape::getNumberOfShapes() << "\n";

		return 0;
	} catch (std::exception ex) {
		std::cerr << ex.what();
		return 1;
	}
}
开发者ID:ugliansky,项目名称:oop_cpp,代码行数:54,代码来源:main.cpp

示例13: task3

// this function is what is required by task #3 here: https://sites.google.com/site/kostovoop/tasks
//    Составить и отладить программу:
//    - создать некий XList фигур, наполнить его случайным образом конкретными фигурами всех типов;
//    - вывести в std::cout общее кол-во фигур с помощью Shape::GetCount();
//    - напечатать в std::cout сведения обо всех фигурах, находящихся в списке;
//    - очистить память;
//    - вывести в std::cout общее кол-во фигур с помощью Shape::GetCount() – удостовериться, что там 0;
//    - завершить работу программы.
void task3()
{
    XList<Shape> shapesList;
    // pt, circle, rect, square, polyline
    Point * pt = new Point("a point", 10, 100); // 1
    Circle * circle = new Circle("a circle", 30, Point("circle center", 10, 20)); // 2
    Rect * rect = new Rect("a rect", 10, -30, 10, -100); // 2
    Square * square = new Square("a square", 40, 20, 10); // 2
    Polyline * line = new Polyline("line"); // 1
    
    Point * pt1 = new Point("", 10, 20);
    Point * pt2 = new Point("", 20, 20);
    Point * pt3 = new Point("", 20, 40);
    Point * pt4 = new Point("", 10, 40);

    line->AddPoint(*pt1);
    line->AddPoint(*pt2);
    line->AddPoint(*pt3);
    line->AddPoint(*pt4);

    shapesList.pushBack(pt);
    shapesList.pushBack(circle);
    shapesList.pushBack(rect);
    shapesList.pushBack(square);
    shapesList.pushBack(line);
    
    std::cout << "Total number of shapes is: " << Shape::getCount() << std::endl;
    assert(Shape::getCount() == 16); // 5 figures in list and their copies, 4 points in the polyline, rect's origin, square's origin, circle's center
    
    XList<Shape>::Iterator it = shapesList.begin();
    int l = shapesList.numberOfElements() + 1;
    while(--l > 0){
        Shape * shape = it.currentItem();
        std::cout << *shape << std::endl;
        it.next();
    }
    
    shapesList.clearList();
    // freeing memory
    delete pt;
    delete circle;
    delete square;
    delete rect;
    delete line;
    delete pt1;
    delete pt2;
    delete pt3;
    delete pt4;
    
    std::cout << "Total number of shapes is now: " << Shape::getCount() << std::endl;
    assert(Shape::getCount() == 0);
}
开发者ID:stkhapugin,项目名称:Kostov-OOP,代码行数:60,代码来源:main.cpp

示例14: kCLoc

//----------------------------------------------------------------------------
bool Polylines::OnInitialize ()
{
    if ( !Application::OnInitialize() )
        return false;

    // set up camera
    ms_spkCamera->SetFrustum(1.0f,1000.0f,-0.55f,0.55f,0.4125f,-0.4125f);
    Vector3f kCLoc(4.0f,0.0f,0.0f);
    Vector3f kCLeft(0.0f,-1.0f,0.0f);
    Vector3f kCUp(0.0f,0.0f,1.0f);
    Vector3f kCDir(-1.0f,0.0f,0.0f);
    ms_spkCamera->SetFrame(kCLoc,kCLeft,kCUp,kCDir);

    // set up scene
    m_spkScene = new Node(1);

    int iVertexQuantity = 128;
    Vector3f* akVertex = new Vector3f[iVertexQuantity];
    ColorRGB* akColor = new ColorRGB[iVertexQuantity];
    for (int i = 0; i < iVertexQuantity; i++)
    {
        akVertex[i].X() = Mathf::SymmetricRandom();
        akVertex[i].Y() = Mathf::SymmetricRandom();
        akVertex[i].Z() = Mathf::SymmetricRandom();
        akColor[i].r = Mathf::UnitRandom();
        akColor[i].g = Mathf::UnitRandom();
        akColor[i].b = Mathf::UnitRandom();
    }

    bool bClosed = true;
    bool bContiguous = true;
    Polyline* pkPoints = new Polyline(iVertexQuantity,akVertex,NULL,
        akColor,NULL,bClosed);
    pkPoints->Contiguous() = bContiguous;

    m_spkScene->AttachChild(pkPoints);

    // initial update of objects
    ms_spkCamera->Update();
    m_spkScene->UpdateGS(0.0f);
    m_spkScene->UpdateRS();

    m_spkMotionObject = m_spkScene;
    m_bTurretActive = true;
    SetTurretAxes();
    m_fTrnSpeed = 0.01f;
    m_fRotSpeed = 0.001f;

    return true;
}
开发者ID:Hengplank,项目名称:kucgbowling,代码行数:51,代码来源:Polylines.cpp

示例15: n

bool operator==(Polyline const& lhs, Polyline const& rhs)
{
	if (lhs.getNumberOfPoints() != rhs.getNumberOfPoints())
		return false;

	const size_t n(lhs.getNumberOfPoints());
	for (size_t k(0); k < n; k++)
	{
		if (lhs.getPointID(k) != rhs.getPointID(k))
			return false;
	}

	return true;
}
开发者ID:AkaBlood,项目名称:ogs5,代码行数:14,代码来源:Polyline.cpp


注:本文中的Polyline类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。