Ejemplo n.º 1
0
sf::FloatRect NSpriteComponent::getBounds() const
{
    sf::FloatRect r = getFinalTransform().transformRect(mSprite.getLocalBounds());
    r.left -= getOrigin().x;
    r.top -= getOrigin().y;
    return r;
}
Ejemplo n.º 2
0
float Obstacle::getDistanceFromObject(Obstacle testObj)
{
	float distance = ( sqrt( (testObj.getOrigin().x-getOrigin().x)*(testObj.getOrigin().x-getOrigin().x) +
			 (testObj.getOrigin().y-getOrigin().y)*(testObj.getOrigin().y-getOrigin().y) +
			  (testObj.getOrigin().z-getOrigin().z)*(testObj.getOrigin().z-getOrigin().z) ));
	return distance;
}
Ejemplo n.º 3
0
unsigned long myPlacement::getHPWL(myNet* net) {
	unsigned long total = 0.0;
	unsigned long pinsNum = net->getNumTerms();
	vector<InstTerm>& instTerm = net->getTerms();
	if (instTerm.size() < 2) {
		return 0;
	}

	myPoint origin1 = getOrigin(instTerm[0]);
	long minX = origin1.coordX();
	long minY = origin1.coordY();
	long maxX = minX;
	long maxY = minY;

	for (unsigned long tId = 1; tId < pinsNum; tId++) {
		myPoint origin = getOrigin(instTerm[tId]);
		if (origin.coordX() > maxX) {
			maxX = origin.coordX();
		}
		if (origin.coordX() <= minX) {
			minX = origin.coordX();
		}
		if (origin.coordY() > maxY) {
			maxY = origin.coordY();
		}
		if (origin.coordY() <= minY) {
			minY = origin.coordY();
		}
	}
	total = (maxX + maxY - minX - minY);

	return total;
}
Ejemplo n.º 4
0
DECLARE_EXPORT ItemDistribution::~ItemDistribution()
{
  // Delete the association from the related objects
  if (getOrigin())
    getOrigin()->origins.erase(this);
  if (getDestination())
    getDestination()->destinations.erase(this);

  // Delete all owned distribution operations
  while (firstOperation)
    delete firstOperation;

  // Unlink from previous item
  if (it)
  {
    if (it->firstItemDistribution == this)
      // Remove from head
      it->firstItemDistribution = next;
    else
    {
      // Remove from middle
      ItemDistribution *j = it->firstItemDistribution;
      while (j->next && j->next != this)
        j = j->next;
      if (j)
        j->next = next;
      else
        throw LogicException("Corrupted ItemDistribution list");
    }
  }

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Ejemplo n.º 5
0
LLVector3 LLViewerCamera::roundToPixel(const LLVector3 &pos_agent)
{
	F32 dist = (pos_agent - getOrigin()).magVec();
	// Convert to screen space and back, preserving the depth.
	LLCoordGL screen_point;
	if (!projectPosAgentToScreen(pos_agent, screen_point, FALSE))
	{
		// Off the screen, just return the original position.
		return pos_agent;
	}

	LLVector3 ray_dir;

	projectScreenToPosAgent(screen_point.mX, screen_point.mY, &ray_dir);
	ray_dir -= getOrigin();
	ray_dir.normVec();

	LLVector3 pos_agent_rounded = getOrigin() + ray_dir*dist;

	/*
	LLVector3 pixel_x, pixel_y;
	getPixelVectors(pos_agent_rounded, pixel_y, pixel_x);
	pos_agent_rounded += 0.5f*pixel_x, 0.5f*pixel_y;
	*/
	return pos_agent_rounded;
}
Ejemplo n.º 6
0
		int	intersect( const gtl::Vec3<Type>& V0, const gtl::Vec3<Type>& V1, const gtl::Vec3<Type>& V2, gtl::Vec3<Type>& I ) const
		{
			Vec3<Type>    u, v, n;             // triangle vectors
			Vec3<Type>    dir, w0, w;          // ray vectors
			Type     r, a, b;             // params to calc ray-plane intersect

			// get triangle edge vectors and plane normal
			u = V1 - V0;
			v = V2 - V0;
			n = u.cross(v);

			if (n == Vec3<Type>(0, 0, 0))            // triangle is degenerate
				return -1;                 // do not deal with this case

			dir = getDirection();             // ray direction vector
			w0 = getOrigin() - V0;

			a = -( n.dot(w0) );
			b = n.dot(dir);

			if (fabs(b) < 0.00000001) {     // ray is parallel to triangle plane
				if (a == 0)                // ray lies in triangle plane
					return 2;
				else return 0;             // ray disjoint from plane
			}

			// get intersect point of ray with triangle plane
			r = a / b;
			if (r < 0.0)                   // ray goes away from triangle
				return 0;                  // => no intersect
			// for a segment, also test if (r > 1.0) => no intersect

			I = getOrigin() + r * dir;           // intersect point of ray and plane

			//// is I inside T?
			Type    uu, uv, vv, wu, wv, D;

			uu = u.dot(u);
			uv = u.dot(v);
			vv = v.dot(v);
			w = I - V0;
			wu = w.dot(u);
			wv = w.dot(v);
			D = uv * uv - uu * vv;

			// get and test parametric coords
			Type s, t;
			s = (uv * wv - vv * wu) / D;
			if (s < 0.0 || s > 1.0)        // I is outside T
				return 0;
			t = (uv * wu - uu * wv) / D;
			if (t < 0.0 || (s + t) > 1.0)  // I is outside T
				return 0;

			return 1;                      // I is in T
		}
Ejemplo n.º 7
0
Vector3 Ray::planeIntersect()
{
    float s   = -getOrigin().z / getDirection().z;
    Vector3 worldPos(0, 0, 0);
    worldPos.x = getOrigin().x + getDirection().x*s;
    worldPos.y = getOrigin().y + getDirection().y*s;
    worldPos.z = 0;

    return worldPos;
}
Ejemplo n.º 8
0
Rect Shape::getWorldRect(void)	
{
	Rect r = mBoundingBox;

	r.left += getOrigin().x;
	r.right += getOrigin().x;
	r.top += getOrigin().y;
	r.bottom += getOrigin().y;

	return r;
}
Ejemplo n.º 9
0
void SnowMountain::display(GLuint texture)
{
    glPushMatrix();
    glTranslatef(getOrigin().x,getOrigin().y,getOrigin().z);
    glBindTexture(GL_2D_TEXTURE,texture);
    glBegin(GL_POLYGON);//build path
    glEnd();

    glPopMatrix();

}
Ejemplo n.º 10
0
TEST_F(LensTest, parallel_rays_should_pass_through_the_focal_point)
{
    Ray rays[]{Ray{{1, 2, 0}, DIR_Z}, Ray{{-3, 4, 1}, DIR_Z}, Ray{{4, 1, -3}, DIR_Z}};
    for (auto& ray : rays)
    {
        auto refracted = lens.refract(ray);
        EXPECT_THAT(refracted, RayPassesThrough(FOCAL_POINT, EPS));
        EXPECT_NEAR(ray.getOrigin()[0], refracted.getOrigin()[0], EPS);
        EXPECT_NEAR(ray.getOrigin()[1], refracted.getOrigin()[1], EPS);
        EXPECT_NEAR(Z_DISTANCE, refracted.getOrigin()[2], EPS);
    }
}
Ejemplo n.º 11
0
void randomiseCoordinates(int coordinates[])
{
	int originX = getOrigin(WIDTH), originY = getOrigin(HEIGHT), i;

	for (i = 0; coordinates[i] != ENDOFCOORDINATES; i++)
	{
		if (i%2)
		{
			coordinates[i] += originX;
		} else {
			coordinates[i] += originY;
		}
	}

}
Ejemplo n.º 12
0
void SPlaneSlicer::applySliceTranslation(vtkSmartPointer<vtkMatrix4x4> vtkMat) const
{
    auto image = this->getInput< ::fwData::Image >(s_EXTENT_IN);

    ::fwData::Object::sptr index;
    switch (m_orientation)
    {
        case ::fwDataTools::helper::MedicalImageAdaptor::Orientation::X_AXIS:
            index = image->getField(::fwDataTools::fieldHelper::Image::m_sagittalSliceIndexId);
            break;
        case ::fwDataTools::helper::MedicalImageAdaptor::Orientation::Y_AXIS:
            index = image->getField(::fwDataTools::fieldHelper::Image::m_frontalSliceIndexId);
            break;
        case ::fwDataTools::helper::MedicalImageAdaptor::Orientation::Z_AXIS:
            index = image->getField(::fwDataTools::fieldHelper::Image::m_axialSliceIndexId);
            break;
    }

    const int idx = ::fwData::Integer::dynamicCast(index)->value();

    const auto& spacing = image->getSpacing();
    const auto& origin  = image->getOrigin();

    const std::uint8_t axis = static_cast<std::uint8_t>(m_orientation);

    const double trans = spacing[axis] * static_cast<double>(idx) + origin[axis];

    vtkSmartPointer<vtkMatrix4x4> transMat = vtkSmartPointer<vtkMatrix4x4>::New();
    transMat->Identity();
    transMat->SetElement(axis, 3, trans);

    vtkMatrix4x4::Multiply4x4(vtkMat, transMat, vtkMat);
}
Ejemplo n.º 13
0
void CCPrimitiveObj::moveVerticesToOrigin()
{
    if( movedToOrigin == false )
    {
        const CCVector3 origin = getOrigin();

        mmX.reset();
        mmY.reset();
        mmZ.reset();

        for( uint i=0; i<vertexCount; ++i )
        {
            const uint index = i*3;
            float &x = vertices[index+0];
            float &y = vertices[index+1];
            float &z = vertices[index+2];

            x -= origin.x;
            y -= origin.y;
            z -= origin.z;

            mmX.consider( x );
            mmY.consider( y );
            mmZ.consider( z );
        }

        movedToOrigin = true;
    }
}
Ejemplo n.º 14
0
void RBlock::print(QDebug dbg) const {
    dbg.nospace() << "RBlock(";
    RObject::print(dbg);
    dbg.nospace() << ", name: " << getName()
            << ", origin: " << getOrigin()
            << ")";
}
Ejemplo n.º 15
0
sf::FloatRect
Animation::getLocalBounds() const {
    return sf::FloatRect(
        getOrigin(),
        static_cast<sf::Vector2f>( GetFrameSize() )
    );
}
Ejemplo n.º 16
0
bool OccupancyGrid::writeOccupancyGridToBagFile(std::string bag_filename, std::string topic_name)
{
  arm_navigation_msgs::CollisionMap map;
  arm_navigation_msgs::OrientedBoundingBox box;
  std::vector<double> dim(3,0), origin(3,0);
  getOrigin(origin[0], origin[1], origin[2]);
  getWorldSize(dim[0], dim[1], dim[2]);

  map.header.frame_id = reference_frame_;
  box.angle = 0.0;
  box.extents.x = grid_->getResolution();
  box.extents.y = grid_->getResolution();
  box.extents.z = grid_->getResolution();
 
  for(double x=origin[0]; x<=origin[0]+dim[0]; x+=grid_->getResolution())
  {
    for(double y=origin[1]; y<=origin[1]+dim[1]; y+=grid_->getResolution())
    {
      for(double z=origin[2]; z<=origin[2]+dim[2]; z+=grid_->getResolution())
      {
        if(getDistanceFromPoint(x,y,z) == 0)
        {
          box.center.x = x;
          box.center.y = y;
          box.center.z = z;
          map.boxes.push_back(box);
        }
      }
    }
  }
  return writeCollisionMapToBagFile(map, bag_filename, topic_name);
}
Ejemplo n.º 17
0
void CClient :: autoEventWaypoint ( int iType, float fRadius, bool bAtOtherOrigin, int iTeam, Vector vOrigin, bool bIgnoreTeam, bool bAutoType )
{
	m_iAutoEventWaypoint = iType;
	m_fAutoEventWaypointRadius = fRadius;

	CBotMod *pMod = CBotGlobals::getCurrentMod();

	m_bAutoEventWaypointAutoType = bAutoType;

	if ( bAtOtherOrigin )
	{
		m_vAutoEventWaypointOrigin = vOrigin;
	}
	else
	{
		m_vAutoEventWaypointOrigin = getOrigin();
		iTeam = CClassInterface::getTeam(m_pPlayer);
	}

	if ( bIgnoreTeam )
		m_iAutoEventWaypointTeam = 0;
	else
	{
		pMod->getTeamOnlyWaypointFlags(iTeam,&m_iAutoEventWaypointTeamOn,&m_iAutoEventWaypointTeamOff);
		m_iAutoEventWaypointTeam = iTeam;
	}	
}
Ejemplo n.º 18
0
TEST_F(LensTest, central_ray_should_pass_through)
{
    Ray central{{0, 0, 0}, DIR_Z};
    auto refracted = lens.refract(central);
    ASSERT_THAT(refracted, RayPassesThrough(FOCAL_POINT, EPS));
    ASSERT_THAT(central, RayPassesThrough(refracted.getOrigin(), EPS));
}
Ejemplo n.º 19
0
Math::CVecR3 WaveguideRectangular::getWeight(
        const Math::CVecR3& pos) const {
    // Return normalized weights for electric field components.
    static const Math::Real pi = acos(-1.0);
    Math::CVecR3 res;
    Math::CVecR3 rPos = pos - getOrigin();
    const Math::Real m = pi * getMode().first / getWidth();
    const Math::Real n = pi * getMode().second / getHeight();
    Math::Real normFactor = m;
    if (n > m) {
        normFactor = n;
    }
    //const Math::Real betaC = sqrt(pow(m,2) + pow(n,2));
    if (getExcitationMode() == Waveguide::TE) {
        res(Math::Constants::x) =   n * cos(m * rPos(Math::Constants::x)) *
                                        sin(n * rPos(Math::Constants::y)) /
                                        normFactor;
        res(Math::Constants::y) = - m * sin(m * rPos(Math::Constants::x)) *
                                        cos(n * rPos(Math::Constants::y)) /
                                        normFactor;
        res(Math::Constants::z) = (Math::Real) 0.0;
    } else {
        res(Math::Constants::x) = - m * cos(m * rPos(Math::Constants::x)) *
                                        sin(n * rPos(Math::Constants::y)) /
                                        normFactor;
        res(Math::Constants::y) = - m * sin(m * rPos(Math::Constants::x)) *
                                        cos(n * rPos(Math::Constants::y)) /
                                        normFactor;
        res(Math::Constants::z) = (Math::Real) 0.0;
    }
    return res;
}
Ejemplo n.º 20
0
void SPlaneSlicer::updating()
{
    this->setReslicerExtent();
    this->setReslicerAxes();

    auto image                           = this->getInput< ::fwData::Image >(s_IMAGE_IN);
    vtkSmartPointer<vtkImageData> vtkimg = vtkSmartPointer<vtkImageData>::New();

    ::fwVtkIO::toVTKImage(image, vtkimg.Get());

    m_reslicer->SetInputData(vtkimg);
    m_reslicer->Update();

    auto slice = this->getInOut< ::fwData::Image >(s_SLICE_OUT);

    ::fwVtkIO::fromVTKImage(m_reslicer->GetOutput(), slice);

    // HACK: Make output slice three-dimensional.
    // We need to do so in order to visualize it with ::visuVTKAdaptor::SImageSlice.
    // This is because the adaptor uses a vtkImageActor which doesn't handle 2d images.
    auto size = slice->getSize();
    slice->setSize({{size[0], size[1], 1}});
    auto spacing = slice->getSpacing();
    slice->setSpacing({{spacing[0], spacing[1], 0 }});
    auto origin = slice->getOrigin();
    slice->setOrigin({{origin[0], origin[1], 0}});

    auto sig = slice->signal< ::fwData::Image::ModifiedSignalType >(::fwData::Image::s_MODIFIED_SIG);

    sig->asyncEmit();
}
Ejemplo n.º 21
0
std::ostream& CodeLocation::printTo(std::ostream& out) const {
	// start with the address ...
	if (address.isValid()) {
		out << address;
	} else {
		out << "<unknown>";
	}

	// ... followed by the annotation path ...
	if (!annotationPath.empty()) {
		out << " / " << join(" / ", annotationPath, [](std::ostream& out, const std::pair<insieme::utils::AnnotationKeyPtr, insieme::core::NodeAddress>& cur) {
			out << *cur.first << ":" << cur.second;
		});
	}

	// ... and finish with a source location if present
	auto origin = getOrigin();
	if (origin.isValid()) {
		if (auto loc = annotations::getLocation(origin)) {
			out << " - " << *loc;
		}
	}

	return out;
}
Ejemplo n.º 22
0
TEST_F(LensTest, rays_passing_though_the_focal_point_should_become_parallel)
{
    Point destinationPoints[]{
        {1, 2, Z_DISTANCE},
        {-3, 4, Z_DISTANCE},
        {4, 1, Z_DISTANCE}};
    for (auto& to : destinationPoints)
    {
        auto ray = rayFromTo(FOCAL_POINT, to);
        auto refracted = lens.refract(ray);
        EXPECT_THAT(refracted, RayHasDirection(-DIR_Z, EPS));
        EXPECT_NEAR(to[0], refracted.getOrigin()[0], EPS);
        EXPECT_NEAR(to[1], refracted.getOrigin()[1], EPS);
        EXPECT_NEAR(to[2], refracted.getOrigin()[2], EPS);
    }
}
Ejemplo n.º 23
0
void EnemyLog::update(float deltaTime   , Background *bg) {
    _aliveTimer += deltaTime;
    if(!_destroying && _aliveTimer > 5) {
        //_alive = false;
        _index = 0;
        _destroying = true;
        _animTimer.restart();
        move(-31, -31);
    }

    if(_spawning){
        updateSprite(true);
        return;
    }
    if(_destroying){
        updateSprite(false);
        return;
    }

    setTexture(*_texture, true);
    if(getOrigin().x == 0){
        setPosition(getPosition().x + getLocalBounds().width/2+32, getPosition().y + getLocalBounds().height/2+32);
        setOrigin( getLocalBounds().width/2, getLocalBounds().height/2);
    }

    movement(deltaTime, bg);

}
Ejemplo n.º 24
0
// Will be called from subclasses, as is virtual function
//----------------------------------------------------------------------------------------------------------------------  
void Muscle::toXml(ci::XmlTree& muscle)
{
  // XMLTree muscle provided by subclass   //ci::XmlTree muscle("Muscle", "");
  muscle.setAttribute("Name", getName());
  muscle.setAttribute("IsFlexor", isFlexor());
  muscle.setAttribute("IsMono", isMonoArticulate());
    
  ci::XmlTree attach("Attachment",""); 
  attach.setAttribute("Origin", getOrigin()); 
  attach.setAttribute("Insertion", getInsertion());   
  muscle.push_back(attach);
  
  double Fmax = getForceMax();
  ci::XmlTree maxForce("MaxIsoForce", toString(Fmax));
  muscle.push_back(maxForce);
  
  double Vmax = getVelocityMax();
  ci::XmlTree maxVel("MaxVelocity", toString(Vmax));
  muscle.push_back(maxVel);  
  
  ci::XmlTree length("Length",""); 
  length.setAttribute("Optimal", getOptimalLength()); 
  length.setAttribute("Min", m_lengthMin); 
  length.setAttribute("Max", m_lengthMax); 
  muscle.push_back(length);
  
  ci::XmlTree hillParams("HillParameters",""); 
  hillParams.setAttribute("Shortening", m_hillSh); 
  hillParams.setAttribute("Lengthening", m_hillLn); 
  hillParams.setAttribute("Asymptote", m_hillMax); 
  hillParams.setAttribute("Slope", m_hillSlope); 
  muscle.push_back(hillParams);
}
Ejemplo n.º 25
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TestFilter::writeFilterParameters(AbstractFilterParametersWriter* writer)

{
 /* Place code that will write the inputs values into a file. reference the
   AbstractFilterParametersWriter class for the proper API to use. */
  writer->writeValue("StlFilePrefix", getStlFilePrefix() );
  writer->writeValue("MaxIterations", getMaxIterations() );
  writer->writeValue("MisorientationTolerance", getMisorientationTolerance() );
  writer->writeValue("InputFile", getInputFile() );
  writer->writeValue("InputPath", getInputPath() );
  writer->writeValue("OutputFile", getOutputFile() );
  writer->writeValue("OutputPath", getOutputPath() );
  writer->writeValue("WriteAlignmentShifts", getWriteAlignmentShifts() );
  writer->writeValue("ConversionType", getConversionType() );
  writer->writeValue("SelectedCellArrayName", getSelectedCellArrayName() );
  writer->writeValue("SelectedFieldArrayName", getSelectedFieldArrayName() );
  writer->writeValue("SelectedEnsembleArrayName", getSelectedEnsembleArrayName() );
  writer->writeValue("SurfaceMeshPointArrayName", getSurfaceMeshPointArrayName() );
  writer->writeValue("SurfaceMeshFaceArrayName", getSurfaceMeshFaceArrayName() );
  writer->writeValue("SurfaceMeshEdgeArrayName", getSurfaceMeshEdgeArrayName() );
  writer->writeValue("SolidMeshPointArrayName", getSolidMeshPointArrayName() );
  writer->writeValue("SolidMeshFaceArrayName", getSolidMeshFaceArrayName() );
  writer->writeValue("SolidMeshEdgeArrayName", getSolidMeshEdgeArrayName() );
  writer->writeValue("Dimensions", getDimensions() );
  writer->writeValue("Origin", getOrigin() );

  writer->writeValue("CellComparisonInputs", m_CellComparisonInputs);
  writer->writeValue("AxisAngleRotations", m_AxisAngleRotations);
}
Ejemplo n.º 26
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void GenericExample::readFilterParameters(AbstractFilterParametersReader* reader, int index)
{
/* FILTER_WIDGETCODEGEN_AUTO_GENERATED_CODE BEGIN*/

  reader->openFilterGroup(this, index);
  setStlFilePrefix( reader->readValue("StlFilePrefix", getStlFilePrefix()) );
  setMaxIterations( reader->readValue("MaxIterations", getMaxIterations()) );
  setMisorientationTolerance( reader->readValue("MisorientationTolerance", getMisorientationTolerance()) );
  setInputFile( reader->readValue("InputFile", getInputFile()) );
  setInputPath( reader->readValue("InputPath", getInputPath()) );
  setOutputFile( reader->readValue("OutputFile", getOutputFile()) );
  setOutputPath( reader->readValue("OutputPath", getOutputPath()) );
  setWriteAlignmentShifts( reader->readValue("WriteAlignmentShifts", getWriteAlignmentShifts()) );
  setConversionType( reader->readValue("ConversionType", getConversionType()) );
  setDimensions( reader->readValue("Dimensions", getDimensions()) );
  setOrigin( reader->readValue("Origin", getOrigin()) );
  setCrystalSymmetryRotations( reader->readValue("CrystalSymmetryRotations", getCrystalSymmetryRotations()) );

  setSelectedVoxelCellArrayName( reader->readValue("SelectedVoxelCellArrayName", getSelectedVoxelCellArrayName()) );
  setSelectedVoxelFieldArrayName( reader->readValue("SelectedVoxelFieldArrayName", getSelectedVoxelFieldArrayName()) );
  setSelectedVoxelEnsembleArrayName( reader->readValue("SelectedVoxelEnsembleArrayName", getSelectedVoxelEnsembleArrayName()) );
  setSelectedSurfaceMeshPointArrayName( reader->readValue("SelectedSurfaceMeshPointArrayName", getSelectedSurfaceMeshPointArrayName()) );
  setSelectedSurfaceMeshFaceArrayName( reader->readValue("SelectedSurfaceMeshFaceArrayName", getSelectedSurfaceMeshFaceArrayName()) );
  setSelectedSurfaceMeshEdgeArrayName( reader->readValue("SelectedSurfaceMeshEdgeArrayName", getSelectedSurfaceMeshEdgeArrayName()) );
  setSelectedSolidMeshPointArrayName( reader->readValue("SelectedSolidMeshPointArrayName", getSelectedSolidMeshPointArrayName()) );
  setSelectedSolidMeshFaceArrayName( reader->readValue("SelectedSolidMeshFaceArrayName", getSelectedSolidMeshFaceArrayName()) );
  setSelectedSolidMeshEdgeArrayName( reader->readValue("SelectedSolidMeshEdgeArrayName", getSelectedSolidMeshEdgeArrayName()) );


  setStrVector( reader->readValue("StrVector", getStrVector() ) );
  reader->closeFilterGroup();
}
Ejemplo n.º 27
0
visualization_msgs::MarkerArray OccupancyGrid::getVisualization(std::string type)
{
  visualization_msgs::MarkerArray ma;

  if(type.compare("bounds") == 0)
  {
    double dimx, dimy, dimz, originx, originy, originz;
    std::vector<geometry_msgs::Point> pts(10);
    getOrigin(originx, originy, originz);
    getWorldSize(dimx,dimy,dimz);
    pts[0].x = originx;      pts[0].y = originy;      pts[0].z = originz;
    pts[1].x = originx+dimx; pts[1].y = originy;      pts[1].z = originz;
    pts[2].x = originx+dimx; pts[2].y = originy+dimy; pts[2].z = originz;
    pts[3].x = originx;      pts[3].y = originy+dimy; pts[3].z = originz;
    pts[4].x = originx;      pts[4].y = originy;      pts[4].z = originz;
    pts[5].x = originx;      pts[5].y = originy;      pts[5].z = originz+dimz;
    pts[6].x = originx+dimx; pts[6].y = originy;      pts[6].z = originz+dimz;
    pts[7].x = originx+dimx; pts[7].y = originy+dimy; pts[7].z = originz+dimz;
    pts[8].x = originx;      pts[8].y = originy+dimy; pts[8].z = originz+dimz;
    pts[9].x = originx;      pts[9].y = originy;      pts[9].z = originz+dimz;

    ma.markers.resize(1);
    ma.markers[0] = viz::getLineMarker(pts, 0.05, 10, getReferenceFrame(), "collision_space_bounds", 0);
  }
  else if(type.compare("distance_field") == 0)
  {
    visualization_msgs::Marker m;
    // grid_->getIsoSurfaceMarkers(0.01, 0.03, getReferenceFrame(), ros::Time::now(),  Eigen::Affine3d::Identity(), m);
    //grid_->getIsoSurfaceMarkers(0.01, 0.08, getReferenceFrame(), ros::Time::now(), tf::Transform(tf::createIdentityQuaternion(), tf::Vector3(0,0,0)), m);
    grid_->getIsoSurfaceMarkers(0.01, 0.02, getReferenceFrame(), ros::Time::now(), m);
    m.color.a +=0.2;
    ma.markers.push_back(m);
  }
  else if(type.compare("occupied_voxels") == 0)
  {
    visualization_msgs::Marker marker;
    std::vector<geometry_msgs::Point> voxels;
    getOccupiedVoxels(voxels);
    marker.header.seq = 0;
    marker.header.stamp = ros::Time::now();
    marker.header.frame_id = getReferenceFrame();
    marker.ns = "occupied_voxels";
    marker.id = 1;
    marker.type = visualization_msgs::Marker::POINTS;
    marker.action = visualization_msgs::Marker::ADD;
    marker.lifetime = ros::Duration(0.0);
    marker.scale.x = grid_->getResolution() / 2.0;
    marker.scale.y = grid_->getResolution() / 2.0;
    marker.scale.z = grid_->getResolution() / 2.0;
    marker.color.r = 0.8;
    marker.color.g = 0.3;
    marker.color.b = 0.5;
    marker.color.a = 1;
    marker.points = voxels;
    ma.markers.push_back(marker);
  }
  else
    ROS_ERROR("No visualization found of type '%s'.", type.c_str());
  return ma;
}
Ejemplo n.º 28
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int GenericExample::writeFilterParameters(AbstractFilterParametersWriter* writer, int index)
{
  writer->openFilterGroup(this, index);
  /* Place code that will write the inputs values into a file. reference the
   AbstractFilterParametersWriter class for the proper API to use. */
  writer->writeValue("StlFilePrefix", getStlFilePrefix());
  writer->writeValue("MaxIterations", getMaxIterations());
  writer->writeValue("MisorientationTolerance", getMisorientationTolerance());
  writer->writeValue("InputFile", getInputFile());
  writer->writeValue("InputPath", getInputPath());
  writer->writeValue("OutputFile", getOutputFile());
  writer->writeValue("OutputPath", getOutputPath());
  writer->writeValue("WriteAlignmentShifts", getWriteAlignmentShifts());
  writer->writeValue("ConversionType", getConversionType());
  writer->writeValue("Dimensions", getDimensions());
  writer->writeValue("Origin", getOrigin());
  writer->writeValue("CrystalSymmetryRotations", getCrystalSymmetryRotations());

  writer->writeValue("SelectedVoxelCellArrayName", getSelectedVoxelCellArrayName());
  writer->writeValue("SelectedVoxelFieldArrayName", getSelectedVoxelFieldArrayName());
  writer->writeValue("SelectedVoxelEnsembleArrayName", getSelectedVoxelEnsembleArrayName());
  writer->writeValue("SelectedSurfaceMeshPointArrayName", getSelectedSurfaceMeshPointArrayName());
  writer->writeValue("SelectedSurfaceMeshFaceArrayName", getSelectedSurfaceMeshFaceArrayName());
  writer->writeValue("SelectedSurfaceMeshEdgeArrayName", getSelectedSurfaceMeshEdgeArrayName());
  writer->writeValue("SelectedSolidMeshPointArrayName", getSelectedSolidMeshPointArrayName());
  writer->writeValue("SelectedSolidMeshFaceArrayName", getSelectedSolidMeshFaceArrayName());
  writer->writeValue("SelectedSolidMeshEdgeArrayName", getSelectedSolidMeshEdgeArrayName());

  writer->writeValue("StrVector", getStrVector());

  writer->closeFilterGroup();
  return ++index;
}
Ejemplo n.º 29
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DxReader::writeFilterParameters(AbstractFilterParametersWriter* writer)

{
  writer->writeValue("InputFile", getInputFile() );
  writer->writeValue("Origin", getOrigin() );
  writer->writeValue("Resolution", getResolution() );
}
Ejemplo n.º 30
0
void BitmapText::draw(Vectorf parentPos, float parentRot, Vectorf parentOri,
                      Camera const& cam)
{
    Vectorf pos = getPos();
    float rot = getRotation();
    Vectorf ori = getOrigin();
    if (isRelativeToParent()) {
        pos += parentPos;
        rot += parentRot;
        ori += parentOri;
    }

    for (std::size_t stringIndex = 0; text_[stringIndex] != '\0';
         ++stringIndex) {
        auto clipIndex =
                static_cast<unsigned int>(text_[stringIndex] - asciiOffset_);
        clip_.x = (clipIndex % rowWidth_) * glyphDims_.x;
        clip_.y = (clipIndex / rowWidth_) * glyphDims_.y;

        const float rads = 3.14159265 * rot / 180.f;
        const float distance = stringIndex * glyphDims_.x;
        Vectorf displacement;
        displacement.x = distance * std::cos(rads);
        displacement.y = distance * std::sin(rads);

        font_.setClip(clip_);
        font_.setPos(displacement);

        font_.draw(pos, rot, ori, cam);
    }
}