本文整理汇总了C++中BOP_Indexs::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ BOP_Indexs::begin方法的具体用法?C++ BOP_Indexs::begin怎么用?C++ BOP_Indexs::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOP_Indexs
的用法示例。
在下文中一共展示了BOP_Indexs::begin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteFace
static void deleteFace(BOP_Mesh *m, BOP_Face *face)
{
BOP_Index l2 = face->getVertex(0);
BOP_Faces faces = m->getFaces();
for(int i = face->size(); i-- ; ) {
BOP_Indexs edges = m->getVertex(l2)->getEdges();
BOP_Index l1 = face->getVertex(i);
for(BOP_IT_Indexs it1 = edges.begin(); it1 != edges.end(); ++it1 ) {
BOP_Edge *edge = m->getEdge(*it1);
if( ( edge->getVertex1() == l1 && edge->getVertex2() == l2 ) ||
( edge->getVertex1() == l2 && edge->getVertex2() == l1 ) ) {
BOP_Indexs ef = edge->getFaces();
for(BOP_IT_Indexs it = ef.begin(); it != ef.end(); ++it ) {
if( m->getFace(*it) == face) {
edge->removeFace(*it);
break;
}
}
break;
}
}
l2 = l1;
}
face->setTAG(BROKEN);
}
示例2:
/**
* Creates a list of lists L1, L2, ... LN where
* LX = mesh faces with vertex v that come from the same original face
* and without any of the vertices that appear before v in vertices
* @param facesByOriginalFace list of faces lists
* @param vertices vector with vertices indexs that contains v
* @param v vertex index
*/
void BOP_Merge2::getFaces(BOP_LFaces &facesByOriginalFace, BOP_Indexs vertices, BOP_Index v)
{
// Get edges with vertex v
BOP_Indexs edgeIndexs = m_mesh->getVertex(v)->getEdges();
const BOP_IT_Indexs edgeEnd = edgeIndexs.end();
for(BOP_IT_Indexs edgeIndex = edgeIndexs.begin();edgeIndex != edgeEnd;edgeIndex++) {
// Foreach edge, add its no broken faces to the output list
BOP_Edge* edge = m_mesh->getEdge(*edgeIndex);
BOP_Indexs faceIndexs = edge->getFaces();
const BOP_IT_Indexs faceEnd = faceIndexs.end();
for(BOP_IT_Indexs faceIndex=faceIndexs.begin();faceIndex!=faceEnd;faceIndex++) {
BOP_Face* face = m_mesh->getFace(*faceIndex);
if (face->getTAG() != BROKEN) {
// Search if the face contains any of the forbidden vertices
bool found = false;
for(BOP_IT_Indexs vertex = vertices.begin();*vertex!= v;vertex++) {
if (face->containsVertex(*vertex)) {
// face contains a forbidden vertex!
found = true;
break;
}
}
if (!found) {
// Search if we already have created a list with the
// faces that come from the same original face
const BOP_IT_LFaces lfEnd = facesByOriginalFace.end();
for(BOP_IT_LFaces facesByOriginalFaceX=facesByOriginalFace.begin();
facesByOriginalFaceX!=lfEnd; facesByOriginalFaceX++) {
if (((*facesByOriginalFaceX)[0])->getOriginalFace() == face->getOriginalFace()) {
// Search that the face has not been added to the list before
for(unsigned int i = 0;i<(*facesByOriginalFaceX).size();i++) {
if ((*facesByOriginalFaceX)[i] == face) {
found = true;
break;
}
}
if (!found) {
// Add face to the list
if (face->getTAG()==OVERLAPPED) facesByOriginalFaceX->insert(facesByOriginalFaceX->begin(),face);
else facesByOriginalFaceX->push_back(face);
found = true;
}
break;
}
}
if (!found) {
// Create a new list and add the current face
BOP_Faces facesByOriginalFaceX;
facesByOriginalFaceX.push_back(face);
facesByOriginalFace.push_back(facesByOriginalFaceX);
}
}
}
}
}
}
示例3: removeBrokenFaces
static void removeBrokenFaces( BOP_Edge *edge, BOP_Mesh *mesh )
{
BOP_Faces m_faces = mesh->getFaces();
BOP_Indexs edgeFaces = edge->getFaces();
const BOP_IT_Indexs edgeFacesEnd = edgeFaces.end();
for(BOP_IT_Indexs idxFace=edgeFaces.begin();idxFace!=edgeFacesEnd;
idxFace++)
m_faces[*idxFace]->setTAG(BROKEN);
}
示例4: testMesh
/**
* testMesh
*/
void BOP_Mesh::testMesh()
{
BOP_Face* cares[10];
unsigned int nedges=0,i;
for(i=0;i<m_edges.size();i++) {
BOP_Edge *edge = m_edges[i];
BOP_Indexs faces = edge->getFaces();
unsigned int count = 0;
const BOP_IT_Indexs facesEnd = faces.end();
for(BOP_IT_Indexs it = faces.begin();it!=facesEnd;it++) {
if (m_faces[*it]->getTAG()!=BROKEN) {
cares[count] = m_faces[*it];
count++;
}
}
if ((count%2)!=0) nedges++;
}
if (nedges)
cout << nedges << " wrong edges." << endl;
else
cout << "well edges." << endl;
unsigned int duplFaces = 0;
unsigned int wrongFaces = 0;
for(i=0;i<m_faces.size();i++){
BOP_Face *faceI = m_faces[i];
if (faceI->getTAG()==BROKEN)
continue;
if (testFace(faceI)){
wrongFaces++;
cout << "Wrong Face: " << faceI << endl;
}
for(unsigned int j=i+1;j<m_faces.size();j++){
BOP_Face *faceJ = m_faces[j];
if (faceJ->getTAG()==BROKEN)
continue;
if (testFaces(faceI,faceJ)){
duplFaces++;
cout << "Duplicate FaceI: " << faceI << endl;
cout << "Duplicate FaceJ: " << faceJ << endl;
}
}
}
cout << duplFaces << " duplicate faces." << endl;
cout << wrongFaces << " wrong faces." << endl;
}
示例5: isClosedMesh
bool BOP_Mesh::isClosedMesh()
{
for(unsigned int i=0; i<m_edges.size(); i++) {
BOP_Edge *edge = m_edges[i];
BOP_Indexs faces = edge->getFaces();
unsigned int count = 0;
const BOP_IT_Indexs facesEnd = faces.end();
for(BOP_IT_Indexs it = faces.begin();it!=facesEnd;it++) {
if (m_faces[*it]->getTAG()!=BROKEN)
count++;
}
if ((count%2)!=0) return false;
}
return true;
}
示例6: testEdges
/**
* testEdges
*/
bool BOP_Mesh::testEdges(BOP_Faces *facesObj)
{
for(unsigned int i=0;i<m_edges.size();i++) {
BOP_Edge *edge = m_edges[i];
BOP_Indexs faces = edge->getFaces();
unsigned int count = 0;
const BOP_IT_Indexs facesEnd = faces.end();
for(BOP_IT_Indexs it = faces.begin();it!=facesEnd;it++) {
if ((m_faces[*it]->getTAG()!=BROKEN) && containsFace(facesObj,m_faces[*it]))
count++;
}
if ((count%2)!=0) {
return false;
}
}
return true;
}
示例7:
/**
* Returns the first face of faces that shares the input edge of face.
* @param mesh mesh that contains the faces, edges and vertices
* @param faces set of faces
* @param face input face
* @param edge face's edge
* @return first face that shares the edge of input face
*/
BOP_Face *BOP_getOppositeFace(BOP_Mesh* mesh,
BOP_Faces* faces,
BOP_Face* face,
BOP_Edge* edge)
{
if (edge == NULL)
return NULL;
BOP_Indexs auxfaces = edge->getFaces();
const BOP_IT_Indexs auxfacesEnd = auxfaces.end();
for(BOP_IT_Indexs it = auxfaces.begin(); it != auxfacesEnd; it++) {
BOP_Face *auxface = mesh->getFace(*it);
if ((auxface != face) && (auxface->getTAG()!=BROKEN) &&
BOP_containsFace(faces,auxface)) {
return auxface;
}
}
return NULL;
}
示例8: dumpmesh
void dumpmesh ( BOP_Mesh *m, bool force )
{
unsigned int nonmanifold = 0;
{
BOP_Edges edges = m->getEdges();
int count = 0;
for (BOP_IT_Edges edge = edges.begin(); edge != edges.end();
++count, ++edge) {
if (!(*edge)->getUsed() && (*edge)->getFaces().size() == 0 ) continue;
BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1());
BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2());
if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) {
int fcount = 0;
BOP_Indexs faces = (*edge)->getFaces();
for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) {
BOP_Face *f = m->getFace(*face);
if(f->getTAG()== UNCLASSIFIED) ++fcount;
}
if(fcount !=0 && fcount !=2 ) {
++nonmanifold;
}
}
}
if (!force && nonmanifold == 0) return;
}
if( nonmanifold )
cout << nonmanifold << " edges detected" << endl;
#ifdef BOP_DEBUG
cout << "---------------------------" << endl;
BOP_Edges edges = m->getEdges();
int count = 0;
for (BOP_IT_Edges edge = edges.begin(); edge != edges.end();
++count, ++edge) {
BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1());
BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2());
if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) {
int fcount = 0;
BOP_Indexs faces = (*edge)->getFaces();
cout << count << ", " << (*edge) << ", " << faces.size() << endl;
for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) {
BOP_Face *f = m->getFace(*face);
if(f->getTAG()== UNCLASSIFIED) ++fcount;
cout << " face " << f << endl;
}
if(fcount !=0 && fcount !=2 )
cout << " NON-MANIFOLD" << endl;
}
}
BOP_Faces faces = m->getFaces();
count = 0;
for (BOP_IT_Faces face = faces.begin(); face != faces.end(); face++) {
if( count < 12*2 || (*face)->getTAG() != BROKEN ) {
cout << count << ", " << *face << endl;
}
++count;
}
BOP_Vertexs verts = m->getVertexs();
count = 0;
for (BOP_IT_Vertexs vert = verts.begin(); vert != verts.end(); vert++) {
cout << count++ << ", " << *vert << " " << (*vert)->getNumEdges() << endl;
BOP_Indexs edges = (*vert)->getEdges();
for( BOP_IT_Indexs it = edges.begin(); it != edges.end(); ++it) {
BOP_Edge *edge = m->getEdge(*it);
cout << " " << edge << endl;
}
}
cout << "===========================" << endl;
#endif
}
示例9: clean_nonmanifold
void clean_nonmanifold( BOP_Mesh *m )
{
return;
BOP_Edges nme;
BOP_Edges e = m->getEdges();
for( BOP_IT_Edges it = e.begin(); it != e.end(); ++it ) {
BOP_Indexs faces = (*it)->getFaces();
if( faces.size() & ~2 )
nme.push_back(*it);
}
if (nme.size() == 0) return;
for( BOP_IT_Edges it = nme.begin(); it != nme.end(); ++it ) {
if( (*it)->getFaces().size() > 1 ) {
BOP_Indexs faces = (*it)->getFaces();
for( BOP_IT_Indexs face = faces.begin(); face != faces.end(); ++face ) {
MT_Point3 vertex1 = m->getVertex(m->getFace(*face)->getVertex(0))->getPoint();
MT_Point3 vertex2 = m->getVertex(m->getFace(*face)->getVertex(1))->getPoint();
MT_Point3 vertex3 = m->getVertex(m->getFace(*face)->getVertex(2))->getPoint();
if (BOP_collinear(vertex1,vertex2,vertex3)) // collinear triangle
deleteFace(m,m->getFace(*face));
}
continue;
}
BOP_Face *oface1 = m->getFace((*it)->getFaces().front());
BOP_Face *oface2, *tmpface;
BOP_Index first =(*it)->getVertex1();
BOP_Index next =(*it)->getVertex2();
BOP_Index last = first;
unsigned short facecount = 0;
bool found = false;
BOP_Indexs vertList;
#ifdef BOP_DEBUG
cout << " first edge is " << (*it) << endl;
#endif
vertList.push_back(first);
BOP_Edge *edge;
while(true) {
BOP_Vertex *vert = m->getVertex(next);
BOP_Indexs edges = vert->getEdges();
edge = NULL;
for( BOP_IT_Indexs eit = edges.begin(); eit != edges.end(); ++eit) {
edge = m->getEdge(*eit);
if( edge->getFaces().size() > 1) {
edge = NULL;
continue;
}
if( edge->getVertex1() == next && edge->getVertex2() != last ) {
last = next;
next = edge->getVertex2();
break;
}
if( edge->getVertex2() == next && edge->getVertex1() != last ) {
last = next;
next = edge->getVertex1();
break;
}
edge = NULL;
}
if( !edge ) break;
#ifdef BOP_DEBUG
cout << " next edge is " << edge << endl;
#endif
tmpface = m->getFace(edge->getFaces().front());
if( oface1->getOriginalFace() != tmpface->getOriginalFace() )
oface2 = tmpface;
else
++facecount;
vertList.push_back(last);
if( vertList.size() > 3 ) break;
if( next == first ) {
found = true;
break;
}
}
if(found) {
edge = *it;
#ifdef BOP_DEBUG
cout << " --> found a loop" << endl;
#endif
if( vertList.size() == 3 ) {
BOP_Face3 *face = (BOP_Face3 *)m->getFace(edge->getFaces().front());
face->getNeighbours(first,last,next);
} else if( vertList.size() == 4 ) {
BOP_Face4 *face = (BOP_Face4 *)m->getFace(edge->getFaces().front());
face->getNeighbours(first,last,next,last);
} else {
#ifdef BOP_DEBUG
cout << "loop has " << vertList.size() << "verts";
#endif
continue;
}
if(facecount == 1) oface1 = oface2;
next = vertList[1];
last = vertList[2];
if( edge->getVertex2() == next ) {
BOP_Face3 *f = new BOP_Face3(next,first,last,
oface1->getPlane(),oface1->getOriginalFace());
m->addFace( f );
#ifdef BOP_DEBUG
//.........这里部分代码省略.........
示例10: replaceVertexIndex
/**
* Replaces a vertex index.
* @param oldIndex old vertex index
* @param newIndex new vertex index
*/
BOP_Index BOP_Mesh::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
{
BOP_IT_Indexs oldEdgeIndex;
if (oldIndex==newIndex) return newIndex;
// Update faces, edges and vertices
BOP_Vertex *oldVertex = m_vertexs[oldIndex];
BOP_Vertex *newVertex = m_vertexs[newIndex];
BOP_Indexs oldEdges = oldVertex->getEdges();
// Update faces to the newIndex
BOP_IT_Indexs oldEdgesEnd = oldEdges.end();
for(oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
oldEdgeIndex++) {
BOP_Edge *edge = m_edges[*oldEdgeIndex];
if ((edge->getVertex1()==oldIndex && edge->getVertex2()==newIndex) ||
(edge->getVertex2()==oldIndex && edge->getVertex1()==newIndex)) {
// Remove old edge ==> set edge faces to BROKEN
removeBrokenFaces( edge, this );
oldVertex->removeEdge(*oldEdgeIndex);
newVertex->removeEdge(*oldEdgeIndex);
}
else {
BOP_Indexs faces = edge->getFaces();
const BOP_IT_Indexs facesEnd = faces.end();
for(BOP_IT_Indexs face=faces.begin();face!=facesEnd;face++) {
if (m_faces[*face]->getTAG()!=BROKEN)
m_faces[*face]->replaceVertexIndex(oldIndex,newIndex);
}
}
}
oldEdgesEnd = oldEdges.end();
for(oldEdgeIndex=oldEdges.begin();oldEdgeIndex!=oldEdgesEnd;
oldEdgeIndex++) {
BOP_Edge * edge = m_edges[*oldEdgeIndex];
BOP_Edge * edge2;
BOP_Index v1 = edge->getVertex1();
v1 = (v1==oldIndex?edge->getVertex2():v1);
if ((edge2 = getEdge(newIndex,v1)) == NULL) {
edge->replaceVertexIndex(oldIndex,newIndex);
if ( edge->getVertex1() == edge->getVertex2() ) {
removeBrokenFaces( edge, this );
oldVertex->removeEdge(*oldEdgeIndex);
}
#ifdef HASH
rehashVertex(oldIndex,newIndex,v1);
#endif
newVertex->addEdge(*oldEdgeIndex);
}
else {
BOP_Indexs faces = edge->getFaces();
const BOP_IT_Indexs facesEnd = faces.end();
for(BOP_IT_Indexs f=faces.begin();f!=facesEnd;f++) {
if (m_faces[*f]->getTAG()!=BROKEN)
edge2->addFace(*f);
}
BOP_Vertex *oppositeVertex = m_vertexs[v1];
oppositeVertex->removeEdge(*oldEdgeIndex);
edge->replaceVertexIndex(oldIndex,newIndex);
if ( edge->getVertex1() == edge->getVertex2() ) {
removeBrokenFaces( edge, this );
oldVertex->removeEdge(*oldEdgeIndex);
newVertex->removeEdge(*oldEdgeIndex);
}
#ifdef HASH
rehashVertex(oldIndex,newIndex,v1);
#endif
}
}
oldVertex->setTAG(BROKEN);
return newIndex;
}
示例11: mergeFaces
/**
* Simplifies a mesh, merging the faces with the specified vertices.
* @param mergeVertices vertices to test
* @return true if a face merge was performed
*/
bool BOP_Merge::mergeFaces(BOP_Indexs &mergeVertices)
{
// Check size > 0!
if (mergeVertices.size() == 0) return false;
// New faces added by merge
BOP_Faces newFaces;
// Old faces removed by merge
BOP_Faces oldFaces;
// Get the first vertex index and add it to
// the current pending vertices to merge
BOP_Index v = mergeVertices[0];
BOP_Indexs pendingVertices;
pendingVertices.push_back(v);
// Get faces with index v that come from the same original face
BOP_LFaces facesByOriginalFace;
getFaces(facesByOriginalFace,v);
bool merged = true;
// Check it has any unbroken face
if (facesByOriginalFace.size()==0) {
// v has not any unbroken face (so it's a new BROKEN vertex)
(m_mesh->getVertex(v))->setTAG(BROKEN);
merged = false;
}
// Merge vertex faces
const BOP_IT_LFaces facesEnd = facesByOriginalFace.end();
for(BOP_IT_LFaces facesByOriginalFaceX = facesByOriginalFace.begin();
(facesByOriginalFaceX != facesEnd)&&merged;
facesByOriginalFaceX++) {
merged = mergeFaces((*facesByOriginalFaceX),oldFaces,newFaces,pendingVertices,v);
}
// Check if the are some pendingVertices to merge
if (pendingVertices.size() > 1 && merged) {
// There are pending vertices that we need to merge in order to merge v ...
for(unsigned int i=1;i<pendingVertices.size() && merged;i++)
merged = mergeFaces(oldFaces,newFaces,pendingVertices,pendingVertices[i]);
}
// If merge was succesful ...
if (merged) {
// Set old faces to BROKEN...
const BOP_IT_Faces oldFacesEnd = oldFaces.end();
for(BOP_IT_Faces face=oldFaces.begin();face!=oldFacesEnd;face++)
(*face)->setTAG(BROKEN);
// ... and add merged faces (that are the new merged faces without pending vertices)
const BOP_IT_Faces newFacesEnd = newFaces.end();
for(BOP_IT_Faces newFace=newFaces.begin();newFace!=newFacesEnd;newFace++) {
m_mesh->addFace(*newFace);
// Also, add new face vertices to the queue of vertices to merge if they weren't
for(BOP_Index i = 0;i<(*newFace)->size();i++) {
BOP_Index vertexIndex = (*newFace)->getVertex(i);
if (vertexIndex >= m_firstVertex && !containsIndex(mergeVertices,vertexIndex))
mergeVertices.push_back(vertexIndex);
}
}
// Set the merged vertices to BROKEN ...
const BOP_IT_Indexs pendingEnd = pendingVertices.end();
for(BOP_IT_Indexs pendingVertex = pendingVertices.begin(); pendingVertex != pendingEnd;pendingVertex++) {
BOP_Index pV = *pendingVertex;
m_mesh->getVertex(pV)->setTAG(BROKEN);
// ... and remove them from mergeVertices queue
const BOP_IT_Indexs mergeEnd = mergeVertices.end();
for(BOP_IT_Indexs mergeVertex = mergeVertices.begin(); mergeVertex != mergeEnd;mergeVertex++) {
BOP_Index mV = *mergeVertex;
if (mV == pV) {
mergeVertices.erase(mergeVertex);
break;
}
}
}
}
else {
// The merge was not succesful, remove the vertex frome merge vertices queue
mergeVertices.erase(mergeVertices.begin());
// free the not used newfaces
const BOP_IT_Faces newFacesEnd = newFaces.end();
for(BOP_IT_Faces newFace=newFaces.begin();newFace!=newFacesEnd;newFace++) {
delete (*newFace);
}
}
// Invoke mergeFaces and return the merge result
return (mergeFaces(mergeVertices) || merged);
}