Example #1
0
 void visit(Face& face) const
 {
   if(!m_done)
   {
     m_done = true;
     FaceTexdef_getTexdef(face.getTexdef(), m_projection);
   }
 }
Example #2
0
 void visit(Face& face) const
 {
   if(!m_done)
   {
     m_done = true;
     FaceShader_getFlags(face.getShader(), m_flags);
   }
 }
Example #3
0
 void visit(Face& face) const
 {
   if(!m_done)
   {
     m_done = true;
     m_shader = face.getShader().getShader();
   }
 }
Example #4
0
void
Forwarder::onDataUnsolicited(Face& inFace, const Data& data)
{
  // accept to cache?
  bool acceptToCache = inFace.isLocal();
  if (acceptToCache) {
    // CS insert
    if (m_csFromNdnSim == nullptr)
      m_cs.insert(data, true);
    else
      m_csFromNdnSim->Add(data.shared_from_this());
  }

  NFD_LOG_DEBUG("onDataUnsolicited face=" << inFace.getId() <<
                " data=" << data.getName() <<
                (acceptToCache ? " cached" : " not cached"));
}
// Morph two faces
// --morphfaces <targa filename1> <targa filename2> <eigenfaces filename> <distance (0.0=first, 1.0=second, in between is a morph)> <outfile name>
void Main::morphFaces()
{
	std::string filename1=args.nextArg();
	std::string filename2=args.nextArg();
	std::string eigfilename=args.nextArg();
	double distance = args.nextFloat();
	std::string outfilename=args.nextArg();
	EigFaces eigenfaces;
	eigenfaces.load(eigfilename);
	Face face1(eigenfaces.getWidth(), eigenfaces.getHeight());
	Face face2(eigenfaces.getWidth(), eigenfaces.getHeight());
	Face result;
	face1.loadTarga(filename1);
	face2.loadTarga(filename2);
	eigenfaces.morphFaces(face1, face2, distance, result);
	result.saveTarga(outfilename);
}
Example #6
0
	Delaunay(float* points, int pointslen) {
		this->points = points;
		this->pointslen = pointslen;
		//查找点集最大最小值
		float xa, xi, ya, yi;
		xa = points[0];
		xi = points[0];
		ya = points[1];
		yi = points[1];
		for (int i = 0; i < pointslen; i++) {
			float x = points[i * 2];
			float y = points[i * 2 + 1];
			xa = xa < x ? x : xa;
			xi = xi > x ? x : xi;
			ya = ya < y ? y : ya;
			yi = yi > y ? y : yi;
		}
		//构造初始三角网
		Face* fistA = new Face();
		Face* fistB = new Face();
		faceList = fistA;
		fistA->next = fistB;
		fistA->setPoint0(xi, yi); //-1
		fistA->setPoint1(xa, yi); //-2
		fistA->setPoint2(xi, ya); //-3
		fistB->setPoint0(xa, yi); //-2
		fistB->setPoint1(xi, ya); //-3
		fistB->setPoint2(xa, ya); //-4
		fistB->next = 0;
		fistA->pointindex[0] = -1;
		fistA->pointindex[1] = -2;
		fistA->pointindex[2] = -3;
		fistB->pointindex[0] = -2;
		fistB->pointindex[1] = -3;
		fistB->pointindex[2] = -4;
		//初始化lop条件
		fistA->edgeFaces[1] = new EdgeFace(fistB, 2);
		fistB->edgeFaces[0] = new EdgeFace(fistA, 0);
		fistA->lop();
		fistB->lop();
		for(int i=0;i<pointslen;i++){
			float* fp=&points[i*2];
			insert(fp);
		}
	}
Example #7
0
	void lop() {
		//前提条件,三点顺序在所有三角形中都是顺时针
		//提供的两个三角形必须相邻,且index必须已经被赋值
		for (int i = 0; i < 3; i++) {
			if (edgeFaces[i] == 0)
				continue;
			if (!isInCircle(edgeFaces[i]->getOtherPoint()))
				continue;
			//需要进行变换
			Face* b = edgeFaces[i]->face;
			int bo = edgeFaces[i]->otherPointIndex; //b中的外点
			Face* a = this;
			int ao = i - 1 >= 0 ? i - 1 : 2; //a中的外点
			int la1 = i; //a共线端点
			int la2 = i + 1 >= 3 ? 0 : i + 1; //a共线端点
			int lb1 = bo + 1 >= 3 ? 0 : bo + 1; //b共线端点
			int lb2 = lb1 + 1 >= 3 ? 0 : lb1 + 1; //b共线端点
			a->setPoint(la2, b->getPoint(bo));
			b->setPoint(lb2, a->getPoint(ao));
			a->edgeFaces[la1]->set(b->edgeFaces[lb2]);
			a->edgeFaces[la1]->updateOtherFaceForMyEdgeFaceInfo(ao, a);
			b->edgeFaces[lb1]->set(a->edgeFaces[la2]);
			b->edgeFaces[lb1]->updateOtherFaceForMyEdgeFaceInfo(bo, b);
			a->edgeFaces[la2]->face = b;
			a->edgeFaces[la2]->otherPointIndex = lb1;
			b->edgeFaces[lb2]->face = a;
			b->edgeFaces[lb2]->otherPointIndex = la1;
			//变换结束后,原三角形的la1不变
			i = 0; //重新处理,直到所有相邻三角形都满足lop
			b->lop();
		}
	}
Example #8
0
File: Mesh.cpp Project: GFHund/LII
void Mesh::calculateVII(float radius)
{
	for(std::set<Vertex*>::iterator j=this->mVertices.begin();j!=this->mVertices.end();j++)
	{
		Vertex* vertex = *j;
		float Br = (4/3)*PI*radius;  
		float Vl = 0.0f;
		float Vp = 0.0f;	
		std::set<Face*> catA,catB,catC;
		viiRelatedFaces(vertex,radius,catA,catB,catC);
		
		//Vp ungenau momentan. toDo: genauer
		for(std::set<Face*>::iterator i = catA.begin();i!=catA.end();i++)
		{
			Face* face = *i;
			Vector3 vecA = face->getA()->getPosition();
			Vector3 vecB = face->getB()->getPosition();
			Vector3 vecC = face->getC()->getPosition();
			vecA.setY(0);
			vecB.setY(0);
			vecC.setY(0);
			Vector3 area = (vecB-vecA).crossProduct(vecC-vecA);
			float aj = area.getLength() / 2;
			Vector3 s = face->getA()->getPosition() + face->getB()->getPosition() + face->getC()->getPosition();
			s /= 3;
			
			Vp += s.getY() * aj;
			
			//Vp += s.getY();
		}
		
		float volumeIntegralInvariant = Vl+Vp+(Br/2);
	}
}
Example #9
0
 void Mesh::collapse(Vertex* v1, Vertex* v2)
 {
     std::vector<Face*>::iterator i;
     for (i = v1->adjacentFaces().begin(); i != v1->adjacentFaces().end(); ++i){
         Face* f = *i;
         if (f->hasVertex(v2)) {
             removeFace(f);
             // delete f;
         }
     }
     
     Vector3 position1 = v1->position();
     int weight1 = v1->weight();
     Vector3 position2 = v2->position();
     int weight2 = v2->weight();
     
     Vector3 newPosition = (position1 * weight1 + position2 * weight2) / (weight1 + weight2);
     
     v2->setPosition(newPosition);
     v2->setWeight(v1->weight() + v2->weight());
     
     for (i = v1->adjacentFaces().begin(); i != v1->adjacentFaces().end(); ++i){
         Face* f = *i;
         f->changeVertex(v1, v2);
         f->calculateNormal();
     }
     
     std::vector<Vertex*>::iterator j;
     for (j = v1->adjacentVertices().begin(); j != v1->adjacentVertices().end(); ++j){
         Vertex* v = *j;
         v->removeAdjacentVertex(v1);
         v->addAdjacentVertex(v2);
         Edge* e = getEdge(v1, v);
         if (e) {
             if (e->hasVertex(v2)) {
                 removeEdge(e);
                 //delete e; // FIXME: pointer being freed was not allocated
             } else {
                 e->changeVertex(v1, v2);
             }
         } else {
             std::cerr << "missing edge" << v1->index() << "/" << v->index() << "\n";
         }
     }
 }
Example #10
0
        Vec3f Brush::splitFace(const FaceInfo& faceInfo, const Vec3f& delta) {
            FaceSet newFaces;
            FaceSet droppedFaces;

            Vec3f newVertexPosition = m_geometry->splitFace(m_worldBounds, faceInfo, delta, newFaces, droppedFaces);

            for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
                Face* dropFace = *it;
                dropFace->setBrush(NULL);
                m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), dropFace), m_faces.end());
                delete dropFace;
            }

            for (FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it) {
                Face* face = *it;
                face->invalidateTexAxes();
                face->invalidateVertexCache();
            }

            for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
                Face* newFace = *it;
                newFace->setBrush(this);
                m_faces.push_back(newFace);
            }

            setNeedsRebuild(true);
            
            return newVertexPosition;
        }
Example #11
0
	int superMi::assign_kuv_to_edge(Solid* mesh)
	{
		for (SolidEdgeIterator seiter(mesh); !seiter.end(); ++seiter){
			Edge* se = *seiter;
			se->kuv_h() = 0.0;
			//Point p1 = mesh->edgeVertex1(se)->point();
			//Point p3 = mesh->edgeVertex2(se)->point();

			//HalfEdge* he2 = se->halfedge(0)->ccw_rotate_about_source();
			//HalfEdge* he4 = se->halfedge(0)->clw_rotate_about_source();

			//Point p2 = he2->target()->point();
			//Point p4 = he4->target()->point();

			//double alpha =  ((p3 - p2)*(p1 - p2) / ((p3 - p2) ^ (p1 - p2)).norm()) / 2.0;
			//double beta =  ((p3 - p4)*(p1 - p4) / ((p3 - p4) ^ (p1 - p4)).norm()) / 2.0;

			//se->kuv_h() = alpha + beta;

			HalfEdge* he = se->halfedge(0);
			HalfEdge* nhe = he->he_next();
			HalfEdge* phe = he->he_prev();
			Face* hef = he->face();

			double nhel = (nhe->target()->point() - nhe->source()->point()).norm();
			double phel = (phe->target()->point() - phe->source()->point()).norm();
			double hel = (he->target()->point() - he->source()->point()).norm();

			se->kuv_h() += (nhel*nhel + phel*phel - hel*hel) / hef->area() / 8.0;

			he = se->halfedge(1);
			nhe = he->he_next();
			phe = he->he_prev();
			hef = he->face();
			nhel = (nhe->target()->point() - nhe->source()->point()).norm();
			phel = (phe->target()->point() - phe->source()->point()).norm();

			se->kuv_h() += (nhel*nhel + phel*phel - hel*hel) / hef->area() / 8.0;

			se->kuv_t() = 1.0;
			//std::cout << se->kuv() << std::endl;
		}

		return 0;
	}
Example #12
0
        FaceInfoList Brush::moveFaces(const FaceInfoList& faceInfos, const Vec3f& delta) {
            FaceSet newFaces;
            FaceSet droppedFaces;

            const FaceInfoList newFaceInfos = m_geometry->moveFaces(m_worldBounds, faceInfos, delta, newFaces, droppedFaces);

            for (FaceSet::iterator it = droppedFaces.begin(); it != droppedFaces.end(); ++it) {
                Face* face = *it;
                face->setBrush(NULL);
                m_faces.erase(std::remove(m_faces.begin(), m_faces.end(), face), m_faces.end());
                delete face;
            }

            for (FaceList::iterator it = m_faces.begin(); it != m_faces.end(); ++it) {
                Face* face = *it;
                face->invalidateTexAxes();
                face->invalidateVertexCache();
            }

            for (FaceSet::iterator it = newFaces.begin(); it != newFaces.end(); ++it) {
                Face* face = *it;
                face->setBrush(this);
                m_faces.push_back(face);
            }
            
            setNeedsRebuild(true);

            return newFaceInfos;
        }
Example #13
0
Face *Carriers::listen(const Contact& address) {
    // for now, only TcpFace exists - otherwise would need to manage
    // multiple possibilities
    //YARP_DEBUG(carriersLog,"listen called");
    Face *face = NULL;
    if (address.getCarrier() == "fake") {
        face = new FakeFace();
    }
    if (face == NULL) {
        face = new TcpFace();
    }
    bool ok = face->open(address);
    if (!ok) {
        delete face;
        face = NULL;
    }
    return face;
}
Example #14
0
bool do_tesselate_face( const Face &F, tesscb_estimator* cb_E, int &max_id )
{
	if (F.CalcArea()<EPS_L)	
		return false;//continue;
	max_id				= cb_E(&F);
	if		(max_id<0)		
		return false;//continue;	// nothing selected
	return true;
}
Example #15
0
 virtual void
 sendInterest(const shared_ptr<pit::Entry>& pitEntry,
              Face& outFace,
              bool wantNewNonce = false) override
 {
   sendInterestHistory.push_back({pitEntry->getInterest(), outFace.getId(), wantNewNonce});
   pitEntry->insertOrUpdateOutRecord(outFace, pitEntry->getInterest());
   afterAction();
 }
Example #16
0
void
Forwarder::onInterestLoop(Face& inFace, const Interest& interest,
                          shared_ptr<pit::Entry> pitEntry)
{
  NFD_LOG_DEBUG("onInterestLoop face=" << inFace.getId() <<
                " interest=" << interest.getName());

  // (drop)
}
Example #17
0
void
Strategy::afterContentStoreHit(const shared_ptr<pit::Entry>& pitEntry,
                               const Face& inFace, const Data& data)
{
  NFD_LOG_DEBUG("afterContentStoreHit pitEntry=" << pitEntry->getName() <<
                " inFace=" << inFace.getId() << " data=" << data.getName());

  this->sendData(pitEntry, data, inFace);
}
int main(int argc, char** argv)
{
  try {
    Name prefix("/nfd/edu/ucla/remap/test");
    // Route to aleph.ndn.ucla.edu.  Have to use the canonical name with
    // an IP address and port.
    string uri = "udp4://128.97.98.7:6363";

    // The default Face connects to the local NFD.
    Face face;

    // Use the system default key chain and certificate name to sign commands.
    KeyChain keyChain;
    face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());

    // Create the /localhost/nfd/faces/query command interest, including the
    // FaceQueryFilter. Construct the FaceQueryFilter using the structure in
    // face-query-filter.pb.h which was produced by protoc.
    ndn_message::FaceQueryFilterMessage message;
    ndn_message::FaceQueryFilterMessage_FaceQueryFilter* filter =
      message.add_face_query_filter();
    filter->set_uri(uri);
    Blob encodedFilter = ProtobufTlv::encode(message);

    Interest interest(Name("/localhost/nfd/faces/query"));
    interest.getName().append(encodedFilter);

    bool enabled = true;
    SegmentFetcher::fetch
      (face, interest, SegmentFetcher::DontVerifySegment,
       bind(&processFaceStatus, _1, prefix, uri, &face, &enabled),
       bind(&onError, _1, _2, &enabled));

    // Loop calling processEvents until a callback sets enabled = false.
    while (enabled) {
      face.processEvents();
      // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
      usleep(10000);
    }
  } catch (std::exception& e) {
    cout << "exception: " << e.what() << endl;
  }
  return 0;
}
Example #19
0
void
AsfStrategy::sendNoRouteNack(const Face& inFace, const Interest& interest,
                             const shared_ptr<pit::Entry>& pitEntry)
{
  NFD_LOG_DEBUG(interest << " from=" << inFace.getId() << " noNextHop");

  lp::NackHeader nackHeader;
  nackHeader.setReason(lp::NackReason::NO_ROUTE);
  this->sendNack(pitEntry, inFace, nackHeader);
}
Example #20
0
static ControlParameters
makeUpdateFaceResponse(const Face& face)
{
  ControlParameters params;
  params.setFaceId(face.getId())
        .setFacePersistency(face.getPersistency());

  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
  if (linkService != nullptr) {
    const auto& options = linkService->getOptions();
    params.setBaseCongestionMarkingInterval(options.baseCongestionMarkingInterval)
          .setDefaultCongestionThreshold(options.defaultCongestionThreshold)
          .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields, false)
          .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, options.reliabilityOptions.isEnabled, false)
          .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, options.allowCongestionMarking, false);
  }

  return params;
}
Example #21
0
bool Calc::interceptaFace(vector<float> pontoInter, Face face){
    vector<float> aresta1, aresta2, aresta3;
    vector<float> normal1, normal2, normal3;

    aresta1 =  face.getVertice1().getPos();
    aresta2 =  face.getVertice2().getPos();
    aresta3 =  face.getVertice3().getPos();

    normal1 = produtoVetorial(aresta2, aresta1);
    normal2 = produtoVetorial(aresta3, aresta2);
    normal3 = produtoVetorial(aresta1, aresta3);

    if((produtoEscalar(pontoInter, normal1) < 0) ||
            (produtoEscalar(pontoInter, normal2) < 0) ||
            (produtoEscalar(pontoInter, normal3) < 0))
        return false;

    return true;
}
Example #22
0
void Object::make_face ( char **words, int nwords, int currentMaterial )
{
    Face face;
    for (int i = 0; i < nwords; i++) 
    {
        int vindex;
        int nindex;
        int tindex;

        if ((words[i][0]>='0')&&(words[i][0]<='9'))
        {
            get_indices (words[i], &vindex, &tindex, &nindex);

#if 0
            printf ("vtn: %d %d %d\n", vindex, tindex, nindex);
#endif

            /* store the vertex index */

            if (vindex > 0)       /* indices are from one, not zero */
                face.addVertexIndex(vindex - 1);
            else if (vindex < 0)  /* negative indices mean count backwards */
                face.addVertexIndex(pvertices.size() + vindex);
            else 
            {
	      fprintf (stderr, "Zero indices not allowed: '%s'\n", str_orig);
                exit (-1);
            }

            /*
            if ((tindex != 0 || nindex != 0) && warning == 0) {
            fprintf (stderr, "\n");
            fprintf (stderr, "Warning: textures and normals currently ignored.\n");
            fprintf (stderr, "\n");
            warning = 1;
            }
            */
        }
    }
    face.setMaterialIndex(currentMaterial);

    pfaces.push_back(face);
}
Example #23
0
/*
 1.4 ~CreateBorderFaces~ creates a list of Faces representing the region at
 the start (or the end, depending on the parameter ~src~) of the time
 interval.
 
*/
vector<Face> MFaces::CreateBorderFaces(bool src) {
    vector<Face> ret;

    for (unsigned int i = 0; i < faces.size(); i++) {
        Face f = faces[i].CreateBorderFace(src);
        if (!f.isEmpty()) {
            bool merged = false;
            for (unsigned int j = 0; j < ret.size(); j++) {
                merged = ret[j].Merge(f);
                if (merged)
                    break;
            }
            if (!merged)
                ret.push_back(f);
        }
    }

    return ret;
}
void LaplacianOperator::initAdjacentMatrix()
{	
	ObjEntity* objMesh = (ObjEntity*)mMesh;

	
	adjacentMatrix.resize(mMeshVertexCount,mMeshVertexCount);	
	adjacentMatrix.reserve(Eigen::VectorXi::Constant(mMeshVertexCount,10));
	degreeMatrix.resize(mMeshVertexCount);
	degreeMatrix.setZero();
	//std::vector<T> tripletList;


	std::vector<Face*>* faceContainer = objMesh->m_faceList;
	for (int i = 0; i < faceContainer->size(); i++)
	{
		Face* face = faceContainer->at(i);
		int faceVertexCount = face->getVertexNum();
		for (int j = 0; j < faceVertexCount; j++)
		{
			int verIndex = face->v.at(j)-1;
			int adj = (j+1)%faceVertexCount;
			//tripletList.push_back(T(verIndex,face->v.at(adj)-1,1));
			Eigen::SparseMatrix<double>::Scalar val = adjacentMatrix.coeff(verIndex,face->v.at(adj)-1);			
			if(fabs(val-1) > 0.001f)
			{
				adjacentMatrix.insert(verIndex,face->v.at(adj)-1) = 1;
				degreeMatrix(verIndex) += 1;
			}
			adj = j - 1;
			if(adj < 0)
				adj += faceVertexCount;			
			//tripletList.push_back(T(verIndex,face->v.at(adj)-1,1));
			val = adjacentMatrix.coeff(verIndex,face->v.at(adj)-1);
			if(fabs(val-1) > 0.001f)
			{
				adjacentMatrix.insert(verIndex,face->v.at(adj)-1) = 1;
				degreeMatrix(verIndex) += 1;
			}
		}
	}	
	//adjacentMatrix.setFromTriplets(tripletList.begin(),tripletList.end());
	//_initDegreeMatrix();
}
Example #25
0
 bool Brush::clip(Face& face) {
     try {
         face.setBrush(this);
         m_faces.push_back(&face);
         rebuildGeometry();
         return !m_faces.empty() && closed();
     } catch (GeometryException&) {
         return false;
     }
 }
Example #26
0
void	TestEdge			(Vertex *V1, Vertex *V2, Face* parent)
{
	Face*	found	= 0;
	int		f_count = 0;

	for (vecFaceIt I=V1->adjacent.begin(); I!=V1->adjacent.end(); I++)	{
		Face* test = *I;
		if (test == parent) continue;
		if (test->VContains(V2)) {
			f_count++;
			found = test;
		}
	}
	if (f_count>1) {
		bCriticalErrCnt	++;
		pBuild->err_multiedge.w_fvector3(V1->P);
		pBuild->err_multiedge.w_fvector3(V2->P);
	}
}
Example #27
0
// ------------------------------
void Moustachizer::process(Mat frame) {
	
	//circle(frame, Point(300,300), 300, Scalar(255,0,0), 3);
	Mat grayFrame = frame.clone();
	cvtColor(frame, grayFrame, CV_RGB2GRAY);
	equalizeHist(grayFrame, grayFrame);
	imshow("grayFrame", grayFrame);
	faceTracker.search( grayFrame );
	
	
	
	for(int i=0; i<faceTracker.faces.size(); i++)
	{
		Face face = faceTracker.faces[i];
		face.draw( frame );
		
		float scale =  (float)face.boundingBox.width / stache.size().width;
		
		Mat stache_resized;
		Mat mask_resized;
		resize(stache, stache_resized, Size(), scale, scale);
		resize(mask, mask_resized, Size(), scale, scale);
		
		float xpos = face.boundingBox.x;
		float ypos = face.boundingBox.y + (face.boundingBox.height * .60);
		Rect pos = Rect(xpos, ypos, stache_resized.size().width, stache_resized.size().height);
		
		/*
		 Rect frame = Rect(0, 0, input.size().width, input.size().height);
		 Rect intersection = pos & frame;
		 Mat fg = stache_resized(Rect(0,0,intersection.width,intersection.height));
		 Mat bg = input(Rect(xpos,ypos,intersection.width,intersection.height));
		 */
		
		Mat bg = frame(pos);
		stache_resized.copyTo(bg, mask_resized);	
	}
	
	//cvtColor(input, input, CV_GRAY2RGB);
	imshow("preview", frame);
	
	cvWaitKey(1);
}
Example #28
0
void MadmStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry, const Face& inFace,
    const Data& data)
{
  InterfaceEstimation& prefixInfo = faceInfoTable[inFace.getId()];

  prefixInfo.addSatisfiedInterest(data.getContent().value_size(), data.getName().toUri());
  costMap[inFace.getId()].addToTraffic(data.getContent().size());

  // Interest is already satisfied by another upstream
  pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(inFace);
  if (pitEntry->getInRecords().empty() || outRecord == pitEntry->getOutRecords().end()) {
    // Do nothing else
  }
  // There is an in and outrecord: Update RTT value!
  else {
    time::steady_clock::Duration rtt = time::steady_clock::now() - outRecord->getLastRenewed();
    prefixInfo.addRttMeasurement(time::duration_cast < time::microseconds > (rtt));
  }
}
Example #29
0
void solve()
{
	borderSquares[xFace]->clear();
	borderSquares[yFace]->clear();
	borderSquares[zFace]->clear();

	for (vector<Face*>::iterator iter = faces.begin(); iter != faces.end(); iter++)
	{
		// derive all Squares of this face
		Face* f = *iter;
//		unsigned int startTime = getMicroSecs();
//		cout << "deriveSquares: ";
		f->deriveSquares();
//		cout << (getMicroSecs() - startTime) << endl;

		// put all squares of faces with the same orientation together
		VectorSet* squares = borderSquares[f->orientation];
		for(VectorSet::iterator iter = f->squares.begin(); iter != f->squares.end(); iter++)
		{
			Vertex v = *iter;
			squares->insert(v);
		}
	}

	VectorSet::iterator iter = borderSquares[zFace]->begin();
	Vertex min = *iter;
	while(iter != borderSquares[zFace]->end())
	{
		if(*iter < min)
			min = *iter;
		iter++;
	}

	blocks.clear();
	blocks.insert(min);
//	unsigned int startTime = getMicroSecs();
//		cout << "collectBlocks: ";
		collectBlocks(min);
//		cout << (getMicroSecs() - startTime) << endl;

	
	cout << "The bulk is composed of " << blocks.size() << " units.\n";
}
Example #30
0
/**
 * Add all the outgoing edges from the vertex v to the horizon edges.
 * Also, update the conflict graph for the newly added faces.
 */
void addCone(Arrangement &arr, Vertex *v, Edges &horizon, Vertices &vertices)
{
	int n = horizon.size();

	Edges spokes1;
	Edges spokes2;
	for (int i = 0; i < n; ++i) {
		Edge *e0 = horizon[i];

		Edge *e1 = arr.addHalfEdge(e0->tail, NULL, NULL, false);
		e1->id = edge_id++;
		Edge *e2 = arr.addHalfEdge(v, NULL, NULL, false);
		e2->id = edge_id++;
		e1->twin = e2;
		e2->twin = e1;
		spokes1.push_back(e1);
		spokes2.push_back(e2);
	}

	// order the edges around the vertex, i.e. set the next pointer correctly
	for (int i = 0; i < n; ++i) {
		Edge *e = horizon[i];
		e->twin->next = spokes1[(i + 1) % n];
		spokes1[i]->next = e;
		spokes2[i]->next = spokes2[(i - 1 + n) % n];
	}

	// Add the corresponding faces
	for (int i = 0; i < n; ++i) {
		Face *f = new Face;
		arr.faces.push_back(f);
		f->id = face_id++;
		arr.addBoundary(horizon[i], f);

		// Also, update the conflict graph for added faces.
		for (int j = 0; j < vertices.size(); ++j) {
			if (f->visible(vertices[j])) {
				f->visibleVertices.push_back(vertices[j]);
				vertices[j]->visibleFaces.push_back(f);
			}
		}
	}
}