Exemplo n.º 1
0
void FaceInstance::update_selection_vertex() {
	if (m_vertexSelection.size() == 0) {
		m_selectableVertices.setSelected(false);
	}
	else {
		m_selectableVertices.setSelected(true);

		if (m_vertexSelection.size() == 1) {
				std::size_t index = getFace().getWinding().findAdjacent(*m_vertexSelection.begin());

				if (index != c_brush_maxFaces) {
						update_move_planepts_vertex(index);
					}
			}
		else if (m_vertexSelection.size() == 2) {
				std::size_t index = getFace().getWinding().findAdjacent(*m_vertexSelection.begin());
				std::size_t other = getFace().getWinding().findAdjacent(*(++m_vertexSelection.begin()));

				if (index != c_brush_maxFaces
						&& other != c_brush_maxFaces) {
						update_move_planepts_vertex2(index, other);
					}
			}
	}
}
Exemplo n.º 2
0
void Card::displayCard()
{
	if (getFace().empty())
	{
		cout << "\t" << getValue() << " of " << getSuit() << "\n";
	}
	else
	{
		cout << "\t" << getFace () << " of " << getSuit() << "\n";
	}
}
Exemplo n.º 3
0
double MHexahedron::getInnerRadius()
{
  //Only for vertically aligned elements (not inclined)
  double innerRadius=std::numeric_limits<double>::max();
  for (int i=0; i<getNumFaces(); i++){
    MQuadrangle quad(getFace(i).getVertex(0), getFace(i).getVertex(1),
                     getFace(i).getVertex(2), getFace(i).getVertex(3));
    innerRadius=std::min(innerRadius,quad.getInnerRadius());
  }
  return innerRadius;
}
Exemplo n.º 4
0
void FaceInstance::select_edge(std::size_t index, bool select) {
	if (select) {
		VertexSelection_insert(m_edgeSelection, getFace().getWinding()[index].adjacent);
	}
	else {
		VertexSelection_erase(m_edgeSelection, getFace().getWinding()[index].adjacent);
	}

	SceneChangeNotify();
	update_selection_edge();
}
Exemplo n.º 5
0
void FaceInstance::selectPlane(Selector& selector, const Line& line, PlanesIterator first, PlanesIterator last, const PlaneCallback& selectedPlaneCallback) {
	for (Winding::const_iterator i = getFace().getWinding().begin(); i != getFace().getWinding().end(); ++i) {
		Vector3 v(line.getClosestPoint(i->vertex) - i->vertex);
		float dot = getFace().plane3().normal().dot(v);
		if (dot <= 0) {
				return;
			}
	}

	Selector_add(selector, m_selectable);

	selectedPlaneCallback(getFace().plane3());
}
Exemplo n.º 6
0
BOOST_FIXTURE_TEST_CASE(TestFireInterestFilter, AllStrategiesFixture)
{
  shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));

  getFace()->onReceiveData +=
    bind(&StrategyChoiceManagerFixture::validateControlResponse, this,  _1,
         command->getName(), 400, "Malformed command");

  getFace()->sendInterest(*command);
  g_io.run_one();

  BOOST_REQUIRE(didCallbackFire());
}
Exemplo n.º 7
0
BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>)
{
  shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
  FaceTableFixture::m_faceTable.add(dummy);

  ControlParameters parameters;
  parameters.setFaceId(dummy->getId());

  Block encodedParameters(parameters.wireEncode());

  Name commandName("/localhost/nfd/faces");
  commandName.append("destroy");
  commandName.append(encodedParameters);

  shared_ptr<Interest> command(make_shared<Interest>(commandName));
  generateCommand(*command);

  ndn::nfd::FaceEventNotification expectedFaceEvent;
  expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
                   .setFaceId(dummy->getId())
                   .setRemoteUri(dummy->getRemoteUri().toString())
                   .setLocalUri(dummy->getLocalUri().toString())
                   .setFlags(0);

  getFace()->onReceiveData +=
    bind(&FaceFixture::callbackDispatch, this, _1, command->getName(),
         200, "Success", ref(encodedParameters), expectedFaceEvent);

  destroyFace(*command, parameters);

  BOOST_REQUIRE(didCallbackFire());
  BOOST_REQUIRE(didReceiveNotication());
}
Exemplo n.º 8
0
int main()
{
   FACE *inputFace;
   FACE *faceOn, *faceNeg, *facePos; 
   FACE *faceOn2, *faceNeg2, *facePos2;

   inputFace= getFace(); dumpFace(inputFace,"input");

   /* partition unit square on XY plane about origin */
   partitionFaceWithPlane(1.0,0.0,0.0,0.0,&inputFace, 
			  &faceOn,&faceNeg,&facePos); 
   assert(inputFace == NULL_FACE);
   dumpFace(faceNeg,"negative side"); dumpFace(facePos,"positive side");

   /* now partition positive piece's upper left corner */
   inputFace= facePos;
   partitionFaceWithPlane(0.707,-0.707,0.0,0.0,&inputFace,
			  &faceOn2,&faceNeg2,&facePos2);
   assert(inputFace == NULL_FACE);
   dumpFace(faceNeg2,"negative side"); dumpFace(facePos2,"positive side");

   /* code to free all faces & their vertices goes here */

   return(0); 
} /* main() */
Exemplo n.º 9
0
void LLDrawable::shiftPos(const LLVector3 &shift_vector)
{
	if (isDead())
	{
		llwarns << "Shifting dead drawable" << llendl;
		return;
	}

	if (mParent)
	{
		mXform.setPosition(mVObjp->getPosition());
	}
	else
	{
		mXform.setPosition(mVObjp->getPositionAgent());
	}

	mXform.setRotation(mVObjp->getRotation());
	mXform.setScale(1,1,1);
	mXform.updateMatrix();

	if (isStatic())
	{
		LLVOVolume* volume = getVOVolume();
		if (!volume)
		{
			gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
		}

		for (S32 i = 0; i < getNumFaces(); i++)
		{
			LLFace *facep = getFace(i);
			facep->mCenterAgent += shift_vector;
			facep->mExtents[0] += shift_vector;
			facep->mExtents[1] += shift_vector;
			
			if (!volume && facep->hasGeometry())
			{
				facep->mVertexBuffer = NULL;
				facep->mLastVertexBuffer = NULL;
			}
		}
		
		mExtents[0] += shift_vector;
		mExtents[1] += shift_vector;
		mPositionGroup += LLVector3d(shift_vector);
	}
	else if (mSpatialBridge)
	{
		mSpatialBridge->shiftPos(shift_vector);
	}
	else if (isAvatar())
	{
		mExtents[0] += shift_vector;
		mExtents[1] += shift_vector;
		mPositionGroup += LLVector3d(shift_vector);
	}
	
	mVObjp->onShift(shift_vector);
}
Exemplo n.º 10
0
	void addVertex(std::string fString1, std::map<std::string, GLuint> &indexMap,
		std::vector<position> &inVerts, std::vector<position> &inCoords, std::vector<position> &inNorms,
		std::vector<GLfloat> &verts, std::vector<GLfloat> &texcoords, std::vector<GLfloat> &norms,
		std::vector<GLuint> &indices, int fFormat, int &index) {

		auto itr = indexMap.find(fString1);
		if (itr == indexMap.end()) {
			faceIndex f = getFace(fString1, fFormat);
			verts.push_back(inVerts[f.v].x);
			verts.push_back(inVerts[f.v].y);
			verts.push_back(inVerts[f.v].z);
			if (fFormat < FORMAT_VN) {
				texcoords.push_back(inCoords[f.t].x);
				texcoords.push_back(inCoords[f.t].y);
			}
			if (fFormat > FORMAT_VT) {
				norms.push_back(inNorms[f.n].x);
				norms.push_back(inNorms[f.n].y);
				norms.push_back(inNorms[f.n].z);
			}
			indexMap.insert(std::pair<std::string, GLuint>(fString1, index));
			indices.push_back(index++);
		}
		else {
			indices.push_back(itr->second);
		}
	}
Exemplo n.º 11
0
void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
{
	//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this
	llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this));

	//precondition: groupp MUST be null or groupp MUST contain this
	llassert(!groupp || groupp->hasElement(this));

/*if (mSpatialGroupp && (groupp != mSpatialGroupp))
	{
		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
	}*/

	if (mSpatialGroupp != groupp && getVOVolume())
	{ //NULL out vertex buffer references for volumes on spatial group change to maintain
		//requirement that every face vertex buffer is either NULL or points to a vertex buffer
		//contained by its drawable's spatial group
		for (S32 i = 0; i < getNumFaces(); ++i)
		{
			LLFace* facep = getFace(i);
			if (facep)
			{
				facep->clearVertexBuffer();
			}
		}
	}

	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
	//postcondition: if next group is NOT NULL, binIndex must not be -1
	llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 :
							getBinIndex() != -1);

	mSpatialGroupp = groupp;
}
Exemplo n.º 12
0
Arquivo: VEF.cpp Projeto: Raegon/MARS
bool VEF::vertexManifoldTest(unsigned int index){

    int flag = 0; // if the flag reached 4, the test fails
    std::vector<Edge> edges;
    for (unsigned int i = 0; i < m_adjacentFaces[index].size(); i++){
         Face *f = getFace(m_adjacentFaces[index][i]);

         if ((getEdge(f->getA())->getA() != index) && (getEdge(f->getA())->getB() != index)){ // don't add the edge that doesn't contain index
             edges.push_back(*getEdge(f->getB()));
             edges.push_back(*getEdge(f->getC()));
         }
         else if ((getEdge(f->getB())->getA() != index) && (getEdge(f->getB())->getB() != index)){
             edges.push_back(*getEdge(f->getA()));
             edges.push_back(*getEdge(f->getC()));
         }
         else {
             edges.push_back(*getEdge(f->getA()));
             edges.push_back(*getEdge(f->getB()));
         }
     }
    for (unsigned int j = 0; j < edges.size(); j++){
        for (unsigned int k = 0; k < edges.size(); k++){
            if (edges.at(j) == edges.at(k))
                break;
        }
        flag++;
    }

    if (flag < 4)
        return true;

    return false;
}
GLvoid Heightmap::averageNormals(std::vector<Vertex>& vertices)
{
    for (auto i = 0; i < faces.size(); i++) 
    {
        for (auto b = 0; b < faces.size(); b++)
        {
            const auto face = faces[i][b];

            for (auto z = 0; z < 6; z++)
            { 
                auto normal = face->normal;
                auto vert = face->vertices[z];

                for (auto s = 0; s < 8; s++)
                {
                    const auto next = getFace(HightmapSide(s), i, b, faces.size());
                    
                    if (next != nullptr) 
                    {
                        for (auto& v : next->vertices) 
                        {
                            if (v == vert) 
                            {
                                normal += next->normal;
                                break;
                            }
                        }
                    }
                }

                vn.push_back(normal);
            }
        }
    }
}
Exemplo n.º 14
0
void
ReadHandle::listen(const Name& prefix)
{
  ndn::InterestFilter filter(prefix);
  getFace().setInterestFilter(filter,
                              bind(&ReadHandle::onInterest, this, _1, _2),
                              bind(&ReadHandle::onRegisterFailed, this, _1, _2));
}
Exemplo n.º 15
0
void
ScenarioHelper::addRoutes(std::initializer_list<ScenarioHelper::RouteInfo> routes)
{
  for (auto&& route : routes) {
    FibHelper::AddRoute(getNode(route.node1), route.prefix,
                        getFace(route.node1, route.node2), route.metric);
  }
}
Exemplo n.º 16
0
void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
{
	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
	{
		llwarns << "Attempted to update distance for non-world camera." << llendl;
		return;
	}

	//switch LOD with the spatial group to avoid artifacts
	//LLSpatialGroup* sg = getSpatialGroup();

	LLVector3 pos;

	//if (!sg || sg->changeLOD())
	{
		LLVOVolume* volume = getVOVolume();
		if (volume)
		{
			if (getSpatialGroup())
			{
				pos.set(getPositionGroup().getF32ptr());
			}
			else
			{
				pos = getPositionAgent();
			}
			
			if (isState(LLDrawable::HAS_ALPHA))
			{
				for (S32 i = 0; i < getNumFaces(); i++)
				{
					LLFace* facep = getFace(i);
					if (force_update || facep->getPoolType() == LLDrawPool::POOL_ALPHA)
					{
						LLVector4a box;
						box.setSub(facep->mExtents[1], facep->mExtents[0]);
						box.mul(0.25f);
						LLVector3 v = (facep->mCenterLocal-camera.getOrigin());
						const LLVector3& at = camera.getAtAxis();
						for (U32 j = 0; j < 3; j++)
						{
							v.mV[j] -= box[j] * at.mV[j];
						}
						facep->mDistance = v * camera.getAtAxis();
					}
				}
			}	
		}
		else
		{
			pos = LLVector3(getPositionGroup().getF32ptr());
		}

		pos -= camera.getOrigin();	
		mDistanceWRTCamera = llround(pos.magVec(), 0.01f);
		mVObjp->updateLOD();
	}
}
Exemplo n.º 17
0
void
ReadHandle::onInterest(const Name& prefix, const Interest& interest)
{

  shared_ptr<ndn::Data> data = getStorageHandle().readData(interest);
  if (data != NULL) {
      getFace().put(*data);
  }
}
LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const
{
	LLSD result;
	result[LLTextureEntry::OBJECT_ID_KEY] = getID();
	result[LLMediaEntry::CURRENT_URL_KEY] = mURL;
	result[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)getFace();
	
	return result;
}
Exemplo n.º 19
0
char Edge::isReal() const
{
	Edge *opp = getTwin();
	if(!opp) return 1;
	
	Facet *f0 = (Facet *)getFace();
	Facet *f1 = (Facet *)opp->getFace();

	return f0->getPolygonIndex() != f1->getPolygonIndex();
}
Exemplo n.º 20
0
void LLDrawable::moveUpdatePipeline(BOOL moved)
{
	makeActive();
	
	// Update the face centers.
	for (S32 i = 0; i < getNumFaces(); i++)
	{
		getFace(i)->updateCenterAgent();
	}
}
Exemplo n.º 21
0
inline int16_t Map::getFaceMaterial(MapCoordinates Coordinates, Direction DirectionType) const
{
    Face* TargetFace = getFace(Coordinates, DirectionType);

    if (TargetFace != NULL)
    {
        return TargetFace->MaterialTypeID;
    }
    return -1;
}
Exemplo n.º 22
0
bool
GeometricBrickDecorator::isFaceinVertPlane(int which, double xy, double zmin, double zmax, int whichCrd) 
{
  /*
    which -> which face : look at ::getFace(...)
    whichCrd -> 3 for Z
                2 for Y
		1 for X
  */
  
  int crd = 2;
  if ( (which == 1) || (which == 2) ) {
    crd = 3;
  }
  if ( (which == 3) || (which == 4) ) {
    crd = 1;
  }

  ID face(4);
  ID faceID(4);
  getFace(which, face, faceID);
  
  double maxE = getMinMaxCrds(whichCrd, 1);
  
  double minE = getMinMaxCrds(whichCrd, -1);
  Node** nodes = this->myBrick->getNodePtrs();
  Node* ndptr;
  double d0 = 0.0; 
  ndptr = nodes[faceID(0)];
  if (ndptr == 0 ) 
    opserr << " severe error NULL node ptr GeomDec L.294 \n" ;
  d0 = (ndptr->getCrds())(crd-1);
  double d1 = 0.0; 
  ndptr = nodes[faceID(1)];  
  if (ndptr == 0 ) 
    opserr << " severe error NULL node ptr GeomDec L.299 \n" ;
  d1 = (ndptr->getCrds())(crd-1);
  double d2 = 0.0; 
  ndptr = nodes[faceID(2)];  
  if (ndptr == 0 ) 
    opserr << " severe error NULL node ptr GeomDec L.304 \n" ;
  d2 = (ndptr->getCrds())(crd-1);
  double d3 = 0.0; 
  ndptr = nodes[faceID(3)];  
  if (ndptr == 0 ) 
    opserr << " severe error NULL node ptr GeomDec L.294 \n" ;
  d3 = (ndptr->getCrds())(crd-1);

  return (( d0== xy) && (d1 == xy) && ( d2 == xy) && (d3 == xy) &&
	  (maxE <= zmax) &&
	  (minE >= zmin) 
	  );
    
}
Exemplo n.º 23
0
void Map::setFaceMaterial(MapCoordinates Coordinates, Direction DirectionType, int16_t MaterialID)
{
    Face* TargetFace = getFace(Coordinates, DirectionType);

    if (TargetFace != NULL)
    {
        TargetFace->MaterialTypeID = MaterialID;

        // TODO Set needs draw on Cell??
    }
}
Exemplo n.º 24
0
void Map::setBothFaceSurfaceTypes(MapCoordinates Coordinates, Direction DirectionType, int16_t SurfaceID)
{
    Face* TargetFace = getFace(Coordinates, DirectionType);

    if (TargetFace != NULL)
    {
        TargetFace->NegativeAxisSurfaceTypeID = SurfaceID;
        TargetFace->PositiveAxisSurfaceTypeID = SurfaceID;
        // TODO Set needs draw on Cell??
    }
}
Exemplo n.º 25
0
bool Cell::setFaceSurfaceType(FaceCoordinates TargetCoordinates, int16_t SurfaceTypeID)
{
    Face* TargetFace = getFace(TargetCoordinates);

    if (TargetFace != NULL)
    {
        TargetFace->setFaceSurfaceType(SurfaceTypeID);
        Render->setDirty();
        return true;
    }
    return false;
}
Exemplo n.º 26
0
    // Get pixels for a cubemap face at an eye.
    virtual void* getCurrentCubemapPixels(CubemapFace face, Eye eye) {
        if(!current_cubemap_) return nullptr;

        if(eye >= current_cubemap_->getEyesCount()) return nullptr;
        auto cubemap_eye = current_cubemap_->getEye(eye);

        if(face >= cubemap_eye->getFacesCount()) return nullptr;
        auto cubemap_face = cubemap_eye->getFace(face);

        if(cubemap_face) return cubemap_face->getContent()->getPixels();
        return nullptr;
    }
Exemplo n.º 27
0
bool Cell::setFaceShape(FaceCoordinates TargetCoordinates, FaceShape NewShape)
{
    Face* TargetFace = getFace(TargetCoordinates);

    if (TargetFace != NULL)
    {
        TargetFace->setFaceShapeType(NewShape);
        Render->setDirty();
        return true;
    }
    return false;
}
Exemplo n.º 28
0
	CubeTextureFace CubeTexture::getFace(fm::vec3 normal)
	{
		fm::vec3 n = normal.unsign();

		int index = 0;

		if (n.x >= n.y && n.x >= n.z) index = (normal.x>0 ? 0 : 1);
		if (n.y >= n.z && n.y >= n.x) index = (normal.y>0 ? 2 : 3);
		if (n.z >= n.x && n.z >= n.y) index = (normal.z>0 ? 4 : 5);

		return getFace(index);
	}
Exemplo n.º 29
0
void FaceInstance::addLight(const Matrix4& localToWorld, const RendererLight& light)
{
	const Plane3& facePlane = getFace().plane3();

	Plane3 tmp = Plane3(facePlane.normal(), -facePlane.dist())
                 .transformed(localToWorld);

	if (!tmp.testPoint(light.worldOrigin()) || !tmp.testPoint(light.getLightOrigin()))
    {
		m_lights.addLight(light);
	}
}
Exemplo n.º 30
0
osgText::Font3D* FreeTypeLibrary::getFont3D(const std::string& fontfile, unsigned int index, unsigned int flags)
{
    FT_Face face;
    if (getFace(fontfile, index, face) == false) return (0);

    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(getMutex());
    
    FreeTypeFont3D* font3DImp = new FreeTypeFont3D(fontfile,face,flags);
    osgText::Font3D* font3D = new osgText::Font3D(font3DImp);

    _font3DImplementationSet.insert(font3DImp);
    
    return font3D;
}