void testApp::generateVBOs() { // If the meshes have already been generated once, we need to clear their data vboMeshOriginal.clear(); vboMeshMirrored.clear(); // Shorthand to make the equations more readable // r is the radius of a circle that is inscribed by the display window // a is the current angle heading we will use to sample the image // da is half the span of the triangle float r = minWindowDimension/2.0; float a = ofDegToRad(imageSectionHeading); float da = ofDegToRad(triangleAngularWidth/2); // Define the vertices of the triangular face ofVec3f triangleBottom(0, 0, 0); ofVec3f triangleLeft(r*cos(a+da), -r*sin(a+da), 0); // Flip because of drawing ofVec3f triangleRight(r*cos(a-da), -r*sin(a-da), 0); // Flip because of drawing float cx = imageSectionCenter.x; float cy = imageSectionCenter.y; r = minImageDimension/2.0; // Define the triangular section of the image that we want to draw on the face ofVec2f textureBottom(cx, cy); ofVec2f textureLeft(cx+r*cos(a+da), cy-r*sin(a+da)); ofVec2f textureRight(cx+r*cos(a-da), cy-r*sin(a-da)); // Add the vertices to the VBO mesh to form a triangle addFace(vboMeshOriginal, triangleBottom, triangleLeft, triangleRight); addFace(vboMeshMirrored, triangleBottom, triangleLeft, triangleRight); // Add the texture coordinates to the mesh addTexture(vboMeshOriginal, textureBottom, textureLeft, textureRight); addTexture(vboMeshMirrored, textureBottom, textureRight, textureLeft); }
/** * Adds a new face. * @param face mesh face * @return mesh face index */ BOP_Index BOP_Mesh::addFace(BOP_Face *face) { if (face->size()==3) return addFace((BOP_Face3 *)face); else return addFace((BOP_Face4 *)face); }
void Particle::draw() { // ofCircle(pos, radius); // // ofPoint velNormal = vel; // velNormal.normalize(); // // ofVec2f velPerp; // velPerp.x = -velNormal.y; // velPerp.y = velNormal.x; // // ofLine(pos.x, pos.y, pos.x + velNormal.x*10, pos.y + velNormal.y*10); float sc = radius; ofPushStyle(); ofMesh mesh; mesh.setMode(OF_PRIMITIVE_TRIANGLES); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,-2*sc,0)); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,0,2*sc)); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,0,2*sc), ofVec3f(-3*sc,-2*sc,0)); addFace(mesh, ofVec3f(-3*sc,0,2*sc), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,-2*sc,0)); ofPushMatrix(); ofTranslate(pos); ofRotateY(ofRadToDeg(atan2(-vel.z,vel.x))); ofRotateZ(ofRadToDeg(asin(vel.y/vel.length()))); mesh.drawFaces(); ofPopMatrix(); ofPopStyle(); }
void mesh::makeFlatGeom(PtexTexture* r) { int numfaces = r->numFaces(); triangles = r->meshType()==Ptex::mt_triangle; float x=0, y=0; verts.clear(); polys.clear(); if (triangles) { int rowlen = (int)sqrt(numfaces); for (int i=0; i<numfaces; i++) { verts.push_back(Vec3f(x,y,0)); verts.push_back(Vec3f(x+1,y,0)); verts.push_back(Vec3f(x+0.5,y+0.866025404,0)); polygon q; q.indices[0] = verts.size()-3; q.indices[1] = verts.size()-2; q.indices[2] = verts.size()-1; q.indices[3] = -1; addFace(q); x+=1/0.866025404; if (x>rowlen/0.866025404) { x = 0; y += 1; } } } else { int rs = (numfaces<2) ? 2 : (int)ceil(sqrt(numfaces))+1; for (int i=0; i<numfaces; i++) { x = i%(rs-1); y = i/(rs-1); polygon q; q.indices[0] = y*rs+x; q.indices[1] = y*rs+x+1; q.indices[2] = (y+1)*rs+x+1; q.indices[3] = (y+1)*rs+x; addFace(q); if ((int)verts.size()<=q.indices[2]) verts.resize(q.indices[2]+1); verts[q.indices[0]] = Vec3f(x,y,0); verts[q.indices[1]] = Vec3f(x+1,y,0); verts[q.indices[2]] = Vec3f(x+1,y+1,0); verts[q.indices[3]] = Vec3f(x,y+1,0); } } }
//-------------------------------------------------------------- void addFace(ofMesh& mesh, ofVec3f a, ofFloatColor aC, ofVec3f b, ofFloatColor bC, ofVec3f c, ofFloatColor cC, ofVec3f d, ofFloatColor dC) { addFace(mesh, a, aC, b, bC, c, cC); addFace(mesh, a, aC, c, cC, d, dC); }
//-------------------------------------------------------------- void Page::addFace(ofMesh& mesh, vectorFace& _face) { addFace(mesh, _face.A, _face.B, _face.C); mesh.addTexCoord(_face.a); mesh.addTexCoord(_face.b); mesh.addTexCoord(_face.c); addFace(mesh, _face.A, _face.C, _face.D); mesh.addTexCoord(_face.a); mesh.addTexCoord(_face.c); mesh.addTexCoord(_face.d); }
int LightWaveParser::parsePolygons() { int size = readIntBE(in); int count = 4; string type = readChunkID(in, 4); count += 4; int vsize; while(count < size) { short pointCnt = readShortBE(in); count += 2; if(pointCnt == 3) { int i1 = readVariableIntBE(in, vsize); count += vsize; int i2 = readVariableIntBE(in, vsize); count += vsize; int i3 = readVariableIntBE(in, vsize); count += vsize; addFace(i1, i2, i3); } else { printf("count = %d\n", pointCnt); } } return count; }
Standard_Boolean ShHealOper_FillHoles::Fill(const TopTools_SequenceOfShape& theFillShapes) { myDone = Standard_False; myErrorStatus = ShHealOper_NotError; if(myInitShape.IsNull()) { myErrorStatus = ShHealOper_InvalidParameters; return myDone; } if(!theFillShapes.Length()) { return myDone; } Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape; if(!prepareWires(theFillShapes,aSeqWires)) { myErrorStatus = ShHealOper_InvalidParameters; return myDone; } myResultShape = myInitShape; Standard_Integer i =1; for( ; i <= aSeqWires->Length(); i++) { TopoDS_Wire aWire = TopoDS::Wire(aSeqWires->Value(i)); Handle(TColGeom2d_HArray1OfCurve) aCurves2d; Handle(TColStd_HArray1OfInteger) aOrders; Handle(TColStd_HArray1OfInteger) aSenses; Handle(Geom_Surface) aSurf = buildSurface(aWire,aCurves2d,aOrders,aSenses); if(aSurf.IsNull()) myErrorStatus = ShHealOper_ErrorExecution; else myDone = (addFace(aSurf,aWire,aCurves2d,aOrders,aSenses) || myDone); } if(myDone) myResultShape = myContext->Apply(myResultShape); return myDone; }
void ofApp::setup() { ofSetVerticalSync(true); ofImage img; img.loadImage("linzer.png"); mesh.setMode(OF_PRIMITIVE_TRIANGLES); int skip = 4; int width = img.getWidth(); int height = img.getHeight(); ofVec3f zero(0, 0, 0); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { ofVec3f nw = getVertexFromImg(img, x, y); ofVec3f ne = getVertexFromImg(img, x + skip, y); ofVec3f sw = getVertexFromImg(img, x, y + skip); ofVec3f se = getVertexFromImg(img, x + skip, y + skip); if(nw != zero && ne != zero && sw != zero && se != zero) { addFace(mesh, nw, ne, se, sw); } } } light.enable(); light.setPosition(500, 0, 0); glEnable(GL_DEPTH_TEST); }
void ofxMesh::addFace(ofRectangle r) { ofVec2f lt(r.x,r.y); ofVec2f rt(r.x+r.width,r.y); ofVec2f rb(r.x+r.width,r.y+r.height); ofVec2f lb(r.x,r.y+r.height); addFace(lt,lb,rb,rt); }
//-------------------------------------------------------------- void testApp::createSkin(int _width){ int width = _width; int height = points.size() / width; float scale = 5.0f; mesh.clear(); for(int y = 0; y < height - 1; y ++) { for(int x = 0; x < width - 1; x ++) { ofVec3f nw = points[ x + y * width]; ofFloatColor nwC = ofFloatColor( 0.5 + averages[y][x] * 0.5); ofVec3f ne = points[ (x+1) + y * width]; ofFloatColor neC = ofFloatColor( 0.5 + averages[y][x] * 0.5); ofVec3f sw = points[ x + (y+1) * width]; ofFloatColor swC = ofFloatColor( 0.5 + averages[y][x] * 0.5); ofVec3f se = points[ (x+1) + (y+1) * width]; ofFloatColor seC = ofFloatColor( 0.5 + averages[y][x] * 0.5); addFace(mesh, nw, nwC, ne, neC, se, seC, sw, swC); } } }
//-------------------------------------------------------------- void ofApp::setup() { #ifdef TARGET_OPENGLES // While this will will work on normal OpenGL as well, it is // required for OpenGL ES because ARB textures are not supported. // If this IS set, then we conditionally normalize our // texture coordinates below. ofEnableNormalizedTexCoords(); #endif img.load("linzer.png"); // OF_PRIMITIVE_TRIANGLES means every three vertices create a triangle mesh.setMode(OF_PRIMITIVE_TRIANGLES); int skip = 10; // this controls the resolution of the mesh int width = img.getWidth(); int height = img.getHeight(); ofVec2f imageSize(width,height); ofVec3f zero(0, 0, 0); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { /* To construct a mesh, we have to build a collection of quads made up of the current pixel, the one to the right, to the bottom right, and beneath. These are called nw, ne, se and sw. To get the texture coords we need to use the actual image indices. */ ofVec3f nw = getVertexFromImg(img, x, y); ofVec3f ne = getVertexFromImg(img, x + skip, y); ofVec3f sw = getVertexFromImg(img, x, y + skip); ofVec3f se = getVertexFromImg(img, x + skip, y + skip); ofVec2f nwi(x, y); ofVec2f nei(x + skip, y); ofVec2f swi(x, y + skip); ofVec2f sei(x + skip, y + skip); // ignore any zero-data (where there is no depth info) if(nw != zero && ne != zero && sw != zero && se != zero) { addFace(mesh, nw, ne, se, sw); // Normalize our texture coordinates if normalized // texture coordinates are currently enabled. if(ofGetUsingNormalizedTexCoords()) { nwi /= imageSize; nei /= imageSize; sei /= imageSize; swi /= imageSize; } addTexCoords(mesh, nwi, nei, sei, swi); } } } vboMesh = mesh; }
VertexList<Vertex>* Mesh::build(bool normalize) { if (normalize) normalizeSize(buildScale); VertexList<Vertex>* vertexList = (VertexList<Vertex>*) CreateVertexList<Vertex>(TRIANGLE_LIST, numberOfTriangles()); for (unsigned i=0; i<faces.size(); ++i) addFace(vertexList, faces[i]); vertexList->calcAABB(); cachedMesh = vertexList; return vertexList; }
Geometry& Geometry::operator+= (const Geometry& geom) { for (const sf::Vector2f& vertex: geom.vertices) { addVertex(vertex); } for (const Face& face: geom.faces) { addFace(face[0], face[1], face[2]); } return *this; }
void FaceSetPart::readFromStream(Stream& stream) { SolidEntity::readFromStream(stream); int num; stream>>num; for(int i=0;i<num;i++){ Face aux; aux.readFromStream(stream); addFace(aux); } }
void FontContext::addFont(const FontDescription& _ft, alfons::InputSource _source) { // NB: Synchronize for calls from download thread std::lock_guard<std::mutex> lock(m_fontMutex); for (size_t i = 0; i < s_fontRasterSizes.size(); i++) { auto font = m_alfons.getFont(_ft.alias, s_fontRasterSizes[i]); font->addFace(m_alfons.addFontFace(_source, s_fontRasterSizes[i])); // add fallbacks from default font font->addFaces(*m_font[i]); } }
void MeditParser::readTriangles(int count, ifstream& fp) { int idx, idx1, idx2, idx3; for (int i = 0; i < count; i++) { fp >> idx1 >> idx2 >> idx3; // Skip last number fp >> idx; idx1--; idx2--; idx3--; addFace(idx1, idx2, idx3); } }
void CMesh::mergeMesh(_In_opt_ CMesh * pMesh, _In_ NMATRIX3 mMatrix) { if (!pMesh) throw CNMRException(NMR_ERROR_INVALIDPARAM); nfInt32 nIdx, nNodeCount, nFaceCount, j; MESHNODE * pNode; MESHFACE * pFace; MESHNODE * pFaceNodes[3]; // Copy Mesh Information CMeshInformationHandler * pOtherMeshInformationHandler = pMesh->getMeshInformationHandler(); if (pOtherMeshInformationHandler) { createMeshInformationHandler(); m_pMeshInformationHandler->addInfoTableFrom(pOtherMeshInformationHandler, getFaceCount ()); } nNodeCount = pMesh->getNodeCount(); nFaceCount = pMesh->getFaceCount(); if (nNodeCount > 0) { std::vector<MESHNODE *> aNewNodes; aNewNodes.resize(nNodeCount); for (nIdx = 0; nIdx < nNodeCount; nIdx++) { pNode = pMesh->getNode(nIdx); NVEC3 vPosition = fnMATRIX3_apply(mMatrix, pNode->m_position); aNewNodes[nIdx] = addNode(vPosition); } if (nFaceCount > 0) { for (nIdx = 0; nIdx < nFaceCount; nIdx++) { pFace = pMesh->getFace(nIdx); for (j = 0; j < 3; j++) { if ((pFace->m_nodeindices[j] < 0) || (pFace->m_nodeindices[j] >= nNodeCount)) throw CNMRException(NMR_ERROR_INVALIDNODEINDEX); pFaceNodes[j] = aNewNodes[pFace->m_nodeindices[j]]; } MESHFACE * pNewFace = addFace(pFaceNodes[0], pFaceNodes[1], pFaceNodes[2]); if (m_pMeshInformationHandler && pOtherMeshInformationHandler) { m_pMeshInformationHandler->cloneFaceInfosFrom(pNewFace->m_index, pOtherMeshInformationHandler, pFace->m_index); } } } else throw CNMRException(NMR_ERROR_INVALIDMESHTOPOLOGY); } }
void Boid::draw() { ofPushStyle(); ofSetColor(color); ofMesh mesh; mesh.setMode(OF_PRIMITIVE_TRIANGLES); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,-2*sc,0)); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,0,2*sc)); addFace(mesh, ofVec3f(3*sc,0,0), ofVec3f(-3*sc,0,2*sc), ofVec3f(-3*sc,-2*sc,0)); addFace(mesh, ofVec3f(-3*sc,0,2*sc), ofVec3f(-3*sc,2*sc,0), ofVec3f(-3*sc,-2*sc,0)); ofPushMatrix(); ofTranslate(*this); ofRotateY(ofRadToDeg(atan2(-vel.z,vel.x))); ofRotateZ(ofRadToDeg(asin(vel.y/vel.length()))); mesh.drawFaces(); ofPopMatrix(); ofPopStyle(); }
void updateFile(ObjFile* file, const char* line) { // counts the number of groups, objectes, faces, positions, normals, // texcoords // TODO: trim [line] if (line[0] == 'v' && line[1] == ' ') { addPosition(file, line); return; } if (line[0] == 'v' && line[1] == 'n' && line[2] == ' ') { addNormal(file, line); return; } if (line[0] == 'v' && line[1] == 't' && line[2] == ' ') { addTexCoord(file, line); return; } if (line[0] == 'o' && line[1] == ' ') { addObject(file, line); return; } if (line[0] == 'g' && line[1] == ' ') { addGroup(file, line); return; } if (line[0] == 'f' && line[1] == ' ') { addFace(file, line); return; } if (strstr(line, "usemtl") == line) { setCurrentMaterial(file, line); return; } }
void LLModel::appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat) { S32 rindex = getNumVolumeFaces()-1; if (rindex == -1 || mVolumeFaces[rindex].mNumVertices + src_face.mNumVertices >= 65536) { //empty or overflow will occur, append new face LLVolumeFace cur_face; cur_face.appendFace(src_face, mat, norm_mat); addFace(cur_face); mMaterialList.push_back(src_material); } else { //append to existing end face mVolumeFaces.rbegin()->appendFace(src_face, mat, norm_mat); } }
void testApp::setup(){ //set up img mesh ofSetVerticalSync(true); //????? ofImage img; img.loadImage("out8.png"); meshImg.setMode(OF_PRIMITIVE_TRIANGLES); int skip = 3; int width = img.getWidth(); int height = img.getHeight(); ofVec3f zero(0, 0, 0); for(int y = 0; y < height - skip; y += skip) { for(int x = 0; x < width - skip; x += skip) { ofVec3f nw = getVertexFromImg(img, x, y); ofVec3f ne = getVertexFromImg(img, x + skip, y); ofVec3f sw = getVertexFromImg(img, x, y + skip); ofVec3f se = getVertexFromImg(img, x + skip, y + skip); if(nw != zero && ne != zero && sw != zero && se != zero) { addFace(meshImg, nw, ne, se, sw); } } } // even points can overlap with each other, let's avoid that glEnable(GL_DEPTH_TEST); //------------------------------------------------------------------ //set up network mesh meshNetwork.setMode(OF_PRIMITIVE_POINTS); numPoints=100; numLoops = 100; counter=0; phase = PI*2; points.resize(numPoints); //do this to initiate the vector array //initiate the points for (int i=0; i< numPoints; i++) { points[i] = getVertexFromImg(img, ofRandom(width), ofRandom(height)); } //cout << ofToString(points) << endl; }
int Mesh::splitFace(Face *f, Vertex *p1, Vertex *p2) { // Find halfedges pointing to p1 and p2 HalfEdge *he_p1 = p1->halfEdge; while(he_p1->vertex != p1) he_p1 = he_p1->next; HalfEdge *he_p2 = he_p1; while(he_p2->vertex != p2) he_p2 = he_p2->next; // Create two new halfedges on the split line int he1 = addHalfEdge(p2, he_p2->next, 0, 0); int he2 = addHalfEdge(p1, he_p1->next, 0, 0); HalfEdge *pHE1 = getHalfEdge(he1); HalfEdge *pHE2 = getHalfEdge(he2); // Create a new face int newFace = addFace(pHE1, f->normal); Face *pNewFace = getFace(newFace); // Point he1 to the new face, and he2 to the old one pHE1->face = pNewFace; pHE2->face = f; // Point the new face to he1, and the old face to he2 pNewFace->halfEdge = pHE1; f->halfEdge = pHE2; // Point p1 to he1 and p2 to he2 p1->halfEdge = pHE1; p2->halfEdge = pHE2; // Fix the next pointers for he_p1 and he_p2 he_p1->next = pHE1; he_p2->next = pHE2; // he1 and he2 are symmetric to each other pHE1->sym = pHE2; pHE2->sym = pHE1; // We *should* be done now (assuming I remembered all the pointers! :-)) - return the index of the new face return newFace; }
// for consistency, we assume that he1 start at v1, he2 start at v2 // v1 will be the insert vertex Face* Solid::mef(Loop *oldl, Vertex *v1, Vertex *v2) { HalfEdge *he1 = new HalfEdge(oldl); HalfEdge *he2 = new HalfEdge(oldl); // look for the halfedge which starts at v2 and the one which ends at v2 HalfEdge *hep = oldl->he; while (hep->v != v2) { hep = hep->nxt; if (hep == oldl->he) break; // in case of infinite loop } // add the pair of halfedges to the old loop oldl->addHalfEdgePair(v1, he1, he2); he1->v = v1; he2->v = v2; // generate a new face and a new loop Face *newf = new Face(this); addFace(newf); Loop *newl = new Loop(); newf->addLoop(newl); // split the old loop // modify the joint of v2 he1->nxt = hep; he2->pre = hep->pre; hep->pre->nxt = he2; hep->pre = he1; // newl->he = he2; he2->l = newl; newf->l = newl; // stupid mistake, rectified at 2011-11-3 20:34:06 I forget to modify the he of oldl oldl->he = he1->nxt; return newf; }
void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { if (newFaces <= (S32)mFaces.size() && newFaces >= (S32)mFaces.size()/2) { return; } else if (newFaces < (S32)mFaces.size()) { std::for_each(mFaces.begin() + newFaces, mFaces.end(), DeletePointer()); mFaces.erase(mFaces.begin() + newFaces, mFaces.end()); } else // (newFaces > mFaces.size()) { mFaces.reserve(newFaces); for (int i = mFaces.size(); i<newFaces; i++) { addFace(poolp, texturep); } } llassert_always(mFaces.size() == newFaces) ; }
void ofxShadowedTerrain::loadMapFromImage(string _filename){ heightmapimg.loadImage(_filename); mesh.setMode(OF_PRIMITIVE_TRIANGLES); gridw = heightmapimg.getWidth(); gridh = heightmapimg.getHeight(); int rawindex=0; heightmapdataobj.ncols=heightmapimg.getWidth(); heightmapdataobj.nrows=heightmapimg.getHeight(); for(int y = 0; y < gridh; y += 1) { for(int x = 0; x < gridw ; x += 1) { rawindex=x+y*gridw; heightmapdataobj.mydata.push_back(getValueFromImagePos(heightmapimg, x, y)); } } triangles.clear(); for(int y = 0; y < gridh - skipy; y += skipy) { for(int x = 0; x < gridw - skipx; x += skipx) { ofVec3f nw = getVertexFromImg(heightmapimg, x, y); ofVec3f ne = getVertexFromImg(heightmapimg, x + skipx, y); ofVec3f sw = getVertexFromImg(heightmapimg, x, y + skipy); ofVec3f se = getVertexFromImg(heightmapimg, x + skipx, y + skipy); addFace(mesh, nw, ne, se, sw); } } mesh.setFromTriangles(triangles); prepareForShadows(); }
void Mesh::setHash(Hash* hash) { if(hash->contains("material")) { setupMaterial(hash->getValue("material")->getHash()); } if(hash->contains("verticies")) { Array* verts = hash->getValue("verticies")->getArray(); for(unsigned int i = 0; i < verts->size(); i++) { Array* vert = verts->at(i)->getArray(); addPoint(new Point3D(vert->at(0)->getDouble(), vert->at(1)->getDouble(), vert->at(2)->getDouble())); } } if(hash->contains("faces")) { Array* faces = hash->getValue("faces")->getArray(); for(unsigned int i = 0; i < faces->size(); i++) { Array* f = faces->at(i)->getArray(); addFace(f->at(0)->getInteger(), f->at(1)->getInteger(), f->at(2)->getInteger()); } calculateNormals(); } }
void ofxShadowedTerrain::loadMapFromTextfile(string _filename){ loadHeightmapData(_filename); mesh.setMode(OF_PRIMITIVE_TRIANGLES); gridw = heightmapdataobj.ncols; gridh = heightmapdataobj.nrows; triangles.clear(); for(int y = 0; y < gridh - skipy; y += skipy) { for(int x = 0; x < gridw - skipx; x += skipx) { ofVec3f nw= heightmapdataobj.getVertexAt(x, y); ofVec3f ne=heightmapdataobj.getVertexAt(x+skipx, y); ofVec3f sw=heightmapdataobj.getVertexAt(x, y+skipy); ofVec3f se=heightmapdataobj.getVertexAt(x+skipy, y+skipy); addFace(mesh, nw, ne, se, sw); } } mesh.setFromTriangles(triangles); prepareForShadows(); }
void Interface::adicionaVerticeDentro(QPointF p){ QVector<QPointF> pontos; Face *f = getFaceNear(p); HalfEdge *primeira, *atual, *prox; atual = f->getOuterComp(); primeira = f->getOuterComp(); prox = atual->getProx(); do { pontos.clear(); pontos.push_back(p); pontos.push_back(atual->getOrigem()->getPoint()); pontos.push_back(atual->getProx()->getOrigem()->getPoint()); addFace(pontos); atual = prox; prox = atual->getProx(); } while(atual != primeira); removeFaceFromCollection(f); /* qDebug() << "Faces restantes "; for (int i=0; i<faces.size(); i++) qDebug() << faces[i]; qDebug() << "Face externa " << faceExterna; qDebug() << "Half-edges "; for (int i=0; i<map.values().size(); i++){ HalfEdge *h = map.values().at(i); qDebug() << h->getDestino()->getPoint().x() << " " << h->getDestino()->getPoint().y() << " " << h->getFace(); } */ }
FindPersonDialog::FindPersonDialog( QWidget *parent /* = NULL */ ) : QDialog( parent ) { findImage = NULL; faceLabel = new QLabel( tr( "人脸" ), this ); faceLineEdit = new QLineEdit; faceLineEdit->setReadOnly( true ); faceLabel->setBuddy( faceLineEdit ); browsePushButton = new QPushButton( tr( "浏览..." ) ); findPushButton = new QPushButton( tr( "识别" ) ); cancelPushButton = new QPushButton( tr( "取消" ) ); connect( browsePushButton, SIGNAL( clicked() ), this, SLOT( addFace() ) ); connect( findPushButton, SIGNAL( clicked() ), this, SLOT( recognize() ) ); connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( close() ) ); QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget( faceLabel ); topLayout->addWidget( faceLineEdit ); topLayout->addWidget( browsePushButton ); QHBoxLayout *bottomLayout = new QHBoxLayout; bottomLayout->addStretch(); bottomLayout->addWidget( findPushButton ); bottomLayout->addWidget( cancelPushButton ); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout( topLayout ); mainLayout->addLayout( bottomLayout ); setLayout( mainLayout ); setWindowTitle( tr( "识别人脸" ) ); }