void CTrajectory::BuildLine( const Ogre::Vector3& Start, const Ogre::Vector3& End, const Ogre::ColourValue& Colour, float Alpha ) { mLineVertices.push_back( VertexPair( Start, Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mLineVertices.push_back( VertexPair( End, Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); }
void CTrajectory::BuildQuad( const Ogre::Vector3* Vertices, const Ogre::ColourValue& Colour, float Alpha ) { for (int i = 0; i < 4; ++i) { mLineVertices.push_back( VertexPair( Vertices[i], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mLineVertices.push_back( VertexPair( Vertices[(i + 1) % 4], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); } }
GraphIF::GraphIF(GraphIF * graph) { EdgeIF* edge { }; EdgeCount edgeIdx { 0 }; IteratorId vertexIterator = graph->getVertexIteratorId(); IteratorId edgeIterator = graph->getEdgeIteratorId(); this->vertexSet = new VertexSetImpl { graph->getNumberOfVertices() }; graph->beginVertex(vertexIterator); while (graph->hasNextVertex(vertexIterator)) { this->vertexSet->push_back( new VertexImpl { graph->nextVertex(vertexIterator) }); } this->edgeSet = new EdgeSetImpl { graph->getNumberOfEdges() }; graph->beginEdge(edgeIterator); while (graph->hasNextEdge(edgeIterator)) { edge = graph->nextEdge(edgeIterator); this->edgeSet->push_back( new EdgeImpl { edgeIdx, VertexPair( vertexSet->getElementAt( edge->getSourceVertex()->getVertexIdx()), vertexSet->getElementAt( edge->getTargetVertex()->getVertexIdx())), edge->getEdgeCost(), edge->getConnectionType(), edge->getVisibility() }); edgeIdx += 1; } graph->removeVertexIterator(vertexIterator); graph->removeEdgeIterator(edgeIterator); }
EdgeIF::EdgeIF(EdgeIF * edge) : EdgeIF(edge->getEdgeIdx(), VertexPair(edge->getSourceVertex(), edge->getTargetVertex()), edge->getEdgeCost(), edge->getConnectionType(), edge->getVisibility()) { }
int IcoSphere::addToVertices(std::list<VertexPair> *target, const Ogre::Vector3 &position, const Ogre::ColourValue &colour, float scale) { Ogre::Matrix4 transform = Ogre::Matrix4::IDENTITY; transform.setTrans(position); transform.setScale(Ogre::Vector3(scale, scale, scale)); for (int i = 0; i < (int)vertices.size(); i++) target->push_back(VertexPair(transform * vertices[i], colour)); return vertices.size(); }
void CTrajectory::BuildFilledQuad( const Ogre::Vector3* Vertices, const Ogre::ColourValue& Colour, float Alpha ) { mQuadVertices.push_back( VertexPair( Vertices[0], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mQuadVertices.push_back( VertexPair( Vertices[1], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mQuadVertices.push_back( VertexPair( Vertices[2], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mQuadVertices.push_back( VertexPair( Vertices[0], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mQuadVertices.push_back( VertexPair( Vertices[2], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); mQuadVertices.push_back( VertexPair( Vertices[3], Ogre::ColourValue( Colour.r, Colour.g, Colour.b, Alpha ) ) ); }
int DebugDrawer::addTriangleVertex(const Ogre::Vector3 &vertex, const Ogre::ColourValue &colour) { triangleVertices.push_back(VertexPair(vertex, colour)); return trianglesIndex++; }
TEST ( MST_2_TEST, SMALL ) { VertexIF* v1 = new VertexImpl { 0 }; VertexIF* v2 = new VertexImpl { 1 }; VertexIF* v3 = new VertexImpl { 2 }; VertexSetIF* vSet = new VertexSetImpl { 3 }; std::cout << v1->toString() << std::endl; std::cout << v2->toString() << std::endl; std::cout << v3->toString() << std::endl; EdgeIF* e1 = new EdgeImpl { 0, VertexPair(v1, v2), 3 }; EdgeIF* e2 = new EdgeImpl { 1, VertexPair(v2, v3), 4 }; EdgeIF* e3 = new EdgeImpl { 2, VertexPair(v3, v1), 5 }; EdgeSetIF* eSet = new EdgeSetImpl { 3 }; // std::cout << e1->toString() << std::endl; // std::cout << e2->toString() << std::endl; // std::cout << e3->toString() << std::endl; // // std::cout << v1->inputEdgesToString() << std::endl; // std::cout << v1->outputEdgesToString() << std::endl; // // std::cout << v2->inputEdgesToString() << std::endl; // std::cout << v2->outputEdgesToString() << std::endl; // // std::cout << v3->inputEdgesToString() << std::endl; // std::cout << v3->outputEdgesToString() << std::endl; GraphIF* g = new GraphImpl(vSet, eSet); MSTSolverIF* p = new PrimeHeap(g); vSet->push_back(v1); vSet->push_back(v2); vSet->push_back(v3); eSet->push_back(e1); eSet->push_back(e2); eSet->push_back(e3); // std::cout << v1->toJSONString(JSONFormat::NONE, 9) << std::endl; // std::cout << v2->toJSONString(JSONFormat::NONE, 9) << std::endl; // std::cout << v3->toJSONString(JSONFormat::NONE, 9) << std::endl; // // std::cout << e1->toJSONString(JSONFormat::NONE, 9) << std::endl; // std::cout << e2->toJSONString(JSONFormat::NONE, 9) << std::endl; // std::cout << e3->toJSONString(JSONFormat::NONE, 9) << std::endl; // // std::cout << vSet->toJSONString(JSONFormat::NONE, 9) << std::endl; // // std::cout << eSet->toJSONString(JSONFormat::NONE, 9) << std::endl; // // std::cout << g->toJSONString(JSONFormat::PRETTY, 3) << std::endl; EdgeSetIF* mst = p->getMST(); // std::cout << mst->toString() << std::endl; // // std::cout << eSet->toString() << std::endl; // // std::cout << vSet->toString() << std::endl; MemoryUtils::removeCollection(mst, false); MemoryUtils::removeGraph(g); delete p; }