コード例 #1
0
ファイル: BOP_Mesh.cpp プロジェクト: nttputus/blensor
/**
 * 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;
}
コード例 #2
0
ファイル: Brush.cpp プロジェクト: WakaLakaLake/TrenchBroom
        bool Brush::canMoveBoundary(const Face& face, const Vec3f& delta) const {

            const Mat4f pointTransform = translationMatrix(delta);
            BrushGeometry testGeometry(m_worldBounds);

            Face testFace(face);
            testFace.transform(pointTransform, Mat4f::Identity, false, false);

            FaceSet droppedFaces;
            FaceList::const_iterator it, end;
            for (it = m_faces.begin(), end = m_faces.end(); it != end; ++it) {
                Face* otherFace = *it;
                if (otherFace != &face)
                    testGeometry.addFace(*otherFace, droppedFaces);
            }

            BrushGeometry::CutResult result = testGeometry.addFace(testFace, droppedFaces);
            bool inWorldBounds = m_worldBounds.contains(testGeometry.bounds);

            m_geometry->restoreFaceSides();

            return inWorldBounds && result == BrushGeometry::Split && droppedFaces.empty();
        }
コード例 #3
0
void IsoSurfacePolygonizer::polygonize(const Point3D &start
                                      ,double         cellSize
                                      ,const Cube3D  &boundingBox
                                      ,bool           tetrahedralMode
                                      ,bool           tetraOptimize4
                                      ,bool           adaptiveCellSize
                                      ) {

  const double startTime = getThreadTime();

  m_cellSize         = cellSize;
  m_boundingBox      = boundingBox;
  m_delta            = cellSize/(double)(RES*RES);
  m_tetrahedralMode  = tetrahedralMode;
  m_tetraOptimize4   = tetraOptimize4;
  m_adaptiveCellSize = adaptiveCellSize;

  m_statistics.clear();
  resetTables();

#ifdef _DEBUG
  _standardRandomGenerator->setSeed(87);
#else
  randomize();
#endif // _DEBUG

  m_start = start;
  for(int i = 0; i < 10; i++) {
    m_start = findStartPoint(m_start);
    if(putInitialCube()) {
      break;
    }
  }

  m_vertexArray.setCapacity( HASHSIZE);
  m_cubesDoneSet.setCapacity(HASHSIZE);
  m_edgeMap.setCapacity(     HASHSIZE);
  m_currentLevel = 0;
  while(hasActiveCubes()) {
    while(hasActiveCubes()) { // process active cubes until none left
      const StackedCube cube = getActiveCube();
#ifdef DEBUG_POLYGONIZER
      m_eval.markCurrentCube(cube);
#endif // DEBUG_POLYGONIZER
      const bool done = addSurfaceVertices(cube);

      if(cube.getLevel() == 0) {
        // test six face directions, maybe add to stack:
        testFace(cube.m_key.i-1 , cube.m_key.j   , cube.m_key.k   , cube, LFACE, LBN, LBF, LTN, LTF);
        testFace(cube.m_key.i+1 , cube.m_key.j   , cube.m_key.k   , cube, RFACE, RBN, RBF, RTN, RTF);
        testFace(cube.m_key.i   , cube.m_key.j-1 , cube.m_key.k   , cube, BFACE, LBN, LBF, RBN, RBF);
        testFace(cube.m_key.i   , cube.m_key.j+1 , cube.m_key.k   , cube, TFACE, LTN, LTF, RTN, RTF);
        testFace(cube.m_key.i   , cube.m_key.j   , cube.m_key.k-1 , cube, NFACE, LBN, LTN, RBN, RTN);
        testFace(cube.m_key.i   , cube.m_key.j   , cube.m_key.k+1 , cube, FFACE, LBF, LTF, RBF, RTF);
      }
      if(!done) {
        splitCube(cube);
      }
    }
    m_faceCount[m_currentLevel] = (UINT)m_faceArray.size();
    if(m_currentLevel>0) m_faceCount[m_currentLevel] -= m_faceCount[m_currentLevel-1];
    prepareNextLevel();
    m_currentLevel++;
  }
  saveStatistics(startTime);
  flushFaceArray();

#ifdef  DUMP_STATISTICS
  debugLog(_T("%s\n"), m_statistics.toString().cstr());
#endif
#ifdef DUMP_CORNERMAP
  dumpCornerMap();
#endif
#ifdef DUMP_EDGEMAP
  dumpEdgeMap();
#endif
#ifdef DUMP_VERTEXARRAY
  dumpVertexArray();
#endif
#ifdef DUMP_FACEARRAY
  dumpFaceArray();
#endif
}