Пример #1
0
bool MeshBuilder::operator==( const MeshBuilder& other ) const
{
	if ( vertices() != other.vertices() )
		return false;
	
	if ( polygons() != other.polygons() )
		return false;
	
	if ( vertexMaps() != other.vertexMaps() )
		return false;
	
	if ( discontinuousVertexMaps() != other.discontinuousVertexMaps() )
		return false;
	
	for ( int i = 0 ; i < m_this->vertices.size() ; ++i )
		if ( *m_this->vertices[i] != *other.m_this->vertices[i] )
			return false;

	for ( int i = 0 ; i < m_this->polygons.size() ; ++i )
		if ( *m_this->polygons[i] != *other.m_this->polygons[i] )
			return false;

	for ( int i = 0 ; i < m_this->vertexMaps.size() ; ++i )
		if ( *m_this->vertexMaps[i] != *other.m_this->vertexMaps[i] )
			return false;

	for ( int i = 0 ; i < m_this->discontinuousVertexMaps.size() ; ++i )
		if ( *m_this->discontinuousVertexMaps[i] != *other.m_this->discontinuousVertexMaps[i] )
			return false;

	return true;
}
Пример #2
0
json QgsMultiPolygon::asJsonObject( int precision ) const
{
  json polygons( json::array( ) );
  for ( const QgsAbstractGeometry *geom : qgis::as_const( mGeometries ) )
  {
    if ( qgsgeometry_cast<const QgsPolygon *>( geom ) )
    {
      json coordinates( json::array( ) );
      const QgsPolygon *polygon = static_cast<const QgsPolygon *>( geom );

      std::unique_ptr< QgsLineString > exteriorLineString( polygon->exteriorRing()->curveToLine() );
      QgsPointSequence exteriorPts;
      exteriorLineString->points( exteriorPts );
      coordinates.push_back( QgsGeometryUtils::pointsToJson( exteriorPts, precision ) );

      std::unique_ptr< QgsLineString > interiorLineString;
      for ( int i = 0, n = polygon->numInteriorRings(); i < n; ++i )
      {
        interiorLineString.reset( polygon->interiorRing( i )->curveToLine() );
        QgsPointSequence interiorPts;
        interiorLineString->points( interiorPts );
        coordinates.push_back( QgsGeometryUtils::pointsToJson( interiorPts, precision ) );
      }
      polygons.push_back( coordinates );
    }
  }
  return
  {
    { "type", "MultiPolygon" },
    { "coordinates", polygons }
  };
}
Пример #3
0
//--------------------------------------------------------------
void ofApp::draw(){
    

    if (selectedColor.size()==0) {
        
        colorPicker();
    }
   

    //---------POLYGONS---------------------

    if (selectedColor.size()>0) {
        polygons();
        
        for (int i = 0; i < curveVertices.size(); i++){
            
            
            
        }
        
        
        
        
        ///////////maximilian///////
        
        
        /* You can use any of the data from audio received and audiorequested to draw stuff here.
         Importantly, most people just use the input and output arrays defined above.
         Clever people don't do this. This bit of code shows that by default, each signal is going to flip
         between -1 and 1. You need to account for this somehow. Get the absolute value for example.
         */
        
//        ofSetColor(255, 255, 255,255);
//        ofRect(600, 300, sample*150, sample*150); /* audio sigs go between -1 and 1. See?*/
//        ofCircle(200, 300, wave*150);
        


    }
    
    
    //---------COLOR PICKER---------------------
    
//    pickerFbo.draw(ofGetWidth()-ofGetWidth()/6,ofGetHeight() - ofGetHeight()/6);
    
    if (colorPickerRect.inside(mouseX, mouseY)) {
        colorPicker();
        ableClick=false;
        
    }else{
    
        ableClick=true;
    
    }
  

}
Пример #4
0
int msHatchPolygon(imageObj *img, shapeObj *poly, double spacing, double width, double *pattern, int patternlength, double angle, colorObj *color)
{
  assert(MS_RENDERER_PLUGIN(img->format));
  msComputeBounds(poly);

  /* amount we should expand the bounding box by */
  double exp = width * 0.7072;

  /* width and height of the bounding box we will be creating the hatch in */
  int pw=(int)(poly->bounds.maxx-poly->bounds.minx+exp*2)+1;
  int ph=(int)(poly->bounds.maxy-poly->bounds.miny+exp*2)+1;

  /* position of the top-left corner of the bounding box */
  double ox = poly->bounds.minx - exp;
  double oy = poly->bounds.miny - exp;

  //create a rectangular hatch of size pw,ph starting at 0,0
  //the created hatch is of the size of the shape's bounding box
  mapserver::path_storage hatch = createHatch(ox,oy,
                                  img->refpt.x,img->refpt.y,pw,ph,angle,spacing);
  if(hatch.total_vertices()<=0) return MS_SUCCESS;

  //translate the hatch so it overlaps the current shape
  hatch.transform(mapserver::trans_affine_translation(ox,oy));

  polygon_adaptor polygons(poly);



  if(patternlength>1) {
    //dash the hatch and render it clipped by the shape
    mapserver::conv_dash<mapserver::path_storage > dash(hatch);
    mapserver::conv_stroke<mapserver::conv_dash<mapserver::path_storage> > stroke(dash);
    for (int i=0; i<patternlength; i+=2) {
      if (i < patternlength-1) {
        dash.add_dash(pattern[i], pattern[i+1]);
      }
    }
    stroke.width(width);
    stroke.line_cap(mapserver::butt_cap);
    mapserver::conv_clipper<polygon_adaptor,mapserver::conv_stroke<mapserver::conv_dash<mapserver::path_storage> > > clipper(polygons,stroke, mapserver::clipper_and);
    renderPolygonHatches(img,clipper,color);
  } else {
    //render the hatch clipped by the shape
    mapserver::conv_stroke <mapserver::path_storage > stroke(hatch);
    stroke.width(width);
    stroke.line_cap(mapserver::butt_cap);
    mapserver::conv_clipper<polygon_adaptor,mapserver::conv_stroke<mapserver::path_storage> > clipper(polygons,stroke, mapserver::clipper_and);
    renderPolygonHatches(img,clipper,color);
  }


  //assert(prevCmd == mapserver::path_cmd_line_to);
  //delete lines;
  return MS_SUCCESS;
}
Пример #5
0
int agg2RenderPolygon(imageObj *img, shapeObj *p, colorObj * color)
{
  AGG2Renderer *r = AGG_RENDERER(img);
  polygon_adaptor polygons(p);
  r->m_rasterizer_aa_gamma.reset();
  r->m_rasterizer_aa_gamma.filling_rule(mapserver::fill_even_odd);
  r->m_rasterizer_aa_gamma.add_path(polygons);
  r->m_renderer_scanline.color(aggColor(color));
  mapserver::render_scanlines(r->m_rasterizer_aa_gamma, r->sl_poly, r->m_renderer_scanline);
  return MS_SUCCESS;
}
Пример #6
0
SeisHorizonLineItem::SeisHorizonLineItem(const QList<QPointF> &line, QGraphicsItem *parent) :
    QGraphicsItemGroup(parent)
{
    QList<QPolygonF> polygons(splitToPolygons(line));
    foreach (const QPolygonF &polygon, polygons)
    {
        PolylineItem *segmentItem = new PolylineItem(polygon, this);

        QPen oldPen(segmentItem->pen());
        oldPen.setColor(Qt::red);
        segmentItem->setPen(oldPen);

        this->mSegmentItems.append(segmentItem);
        this->addToGroup(segmentItem);
    }
Пример #7
0
/*
 * Function that render polygons into UTFGrid.
 */
int utfgridRenderPolygon(imageObj *img, shapeObj *polygonshape, colorObj *color)
{
  UTFGridRenderer *r = UTFGRID_RENDERER(img);

  /* utfvalue is set to 0 if the shape isn't in the table. */
  if(r->utfvalue == 0) {
    return MS_FAILURE;
  }

  /* Render the polygon */
  polygon_adaptor_utf polygons(polygonshape, r->utfresolution);
  utfgridRenderPath(img, polygons);

  return MS_SUCCESS;
}
 pcl::PointCloud<pcl::tracking::ParticleCuboid>::Ptr PlaneSupportedCuboidEstimator::initParticles()
 {
   pcl::PointCloud<pcl::tracking::ParticleCuboid>::Ptr particles (new pcl::PointCloud<pcl::tracking::ParticleCuboid>);
   particles->points.resize(particle_num_);
   std::vector<Polygon::Ptr> polygons(latest_polygon_msg_->polygons.size());
   for (size_t i = 0; i < latest_polygon_msg_->polygons.size(); i++) {
     Polygon::Ptr polygon = Polygon::fromROSMsgPtr(latest_polygon_msg_->polygons[i].polygon);
     polygons[i] = polygon;
   }
   for (size_t i = 0; i < particle_num_; i++) {
     while (true) {
       pcl::tracking::ParticleCuboid p_local;
       size_t plane_i = chooseUniformRandomPlaneIndex(polygons);
       Polygon::Ptr polygon = polygons[plane_i];
       Eigen::Vector3f v = polygon->randomSampleLocalPoint(random_generator_);
       v[2] = randomUniform(init_local_position_z_min_, init_local_position_z_max_,
                            random_generator_);
       p_local.getVector3fMap() = v;
       p_local.roll = randomGaussian(0, init_local_orientation_roll_variance_, random_generator_);
       p_local.pitch = randomGaussian(0, init_local_orientation_pitch_variance_, random_generator_);
       p_local.yaw = randomGaussian(init_local_orientation_yaw_mean_,
                                    init_local_orientation_yaw_variance_,
                                    random_generator_);
       p_local.dx = randomGaussian(init_dx_mean_, init_dx_variance_, random_generator_);
       p_local.dy = randomGaussian(init_dy_mean_, init_dy_variance_, random_generator_);
       p_local.dz = randomGaussian(init_dz_mean_, init_dz_variance_, random_generator_);
       pcl::tracking::ParticleCuboid p_global =  p_local * polygon->coordinates();
       if (use_init_world_position_z_model_) {
         if (p_global.z < init_world_position_z_min_ ||
             p_global.z > init_world_position_z_max_) {
           continue;
         }
       }
       p_global.plane_index = plane_i;
       if (disable_init_pitch_) {
         p_global.pitch = 0;
       }
       if (disable_init_roll_) {
         p_global.roll = 0;
       }
       particles->points[i] = p_global;
       break;
     }
   }
   return particles;
 }
Пример #9
0
int agg2RenderPolygonTiled(imageObj *img, shapeObj *p, imageObj * tile)
{
  assert(img->format->renderer == tile->format->renderer);

  AGG2Renderer *r = AGG_RENDERER(img);
  AGG2Renderer *tileRenderer = AGG_RENDERER(tile);
  polygon_adaptor polygons(p);
  typedef mapserver::wrap_mode_repeat wrap_type;
  typedef mapserver::image_accessor_wrap<pixel_format,wrap_type,wrap_type> img_source_type;
  typedef mapserver::span_pattern_rgba<img_source_type> span_gen_type;
  mapserver::span_allocator<mapserver::rgba8> sa;
  r->m_rasterizer_aa.reset();
  r->m_rasterizer_aa.filling_rule(mapserver::fill_even_odd);
  img_source_type img_src(tileRenderer->m_pixel_format);
  span_gen_type sg(img_src, 0, 0);
  r->m_rasterizer_aa.add_path(polygons);
  mapserver::render_scanlines_aa(r->m_rasterizer_aa, r->sl_poly, r->m_renderer_base, sa , sg);
  return MS_SUCCESS;
}
Пример #10
0
void MeshBuilder::clear()
{
	removeVertexMaps();
	removeDiscontinuousVertexMaps();

	for ( int index = polygons()-1 ; index >= 0 ; --index )
	{
		Polygon* item = getPolygon( index );
		item->destroy();
		freePolygon( item );
	}
	m_this->polygons.clear();

	for ( int index = vertices()-1 ; index >= 0 ; --index )
	{
		Vertex* item = getVertex( index );
		item->destroy();
		freeVertex( item );
	}
	m_this->vertices.clear();
}
Пример #11
0
void MeshBuilder::removePolygons()
{
	for ( int i = polygons()-1 ; i >= 0 ; --i )
		removePolygon(i);
}