当前位置: 首页>>代码示例>>C++>>正文


C++ GeometryCollection类代码示例

本文整理汇总了C++中GeometryCollection的典型用法代码示例。如果您正苦于以下问题:C++ GeometryCollection类的具体用法?C++ GeometryCollection怎么用?C++ GeometryCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GeometryCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetTransform

void
GeometryGroup::Draw (cairo_t *cr)
{
	Transform *transform = GetTransform ();
	cairo_matrix_t saved;
	cairo_get_matrix (cr, &saved);

	if (transform) {
		cairo_matrix_t matrix;
		transform->GetTransform (&matrix);
		cairo_transform (cr, &matrix);
	}
	
	GeometryCollection *children = GetChildren ();
	Geometry *geometry;

	// GeometryGroup is used for Clip (as a Geometry) so Fill (normally setting the fill rule) is never called
	cairo_set_fill_rule (cr, convert_fill_rule (GetFillRule ()));
	
	int children_count = children->GetCount ();
	for (int i = 0; i < children_count; i++) {
		geometry = children->GetValueAt (i)->AsGeometry ();
		
		geometry->Draw (cr);
	}
	
	cairo_set_matrix (cr, &saved);
}
开发者ID:kangaroo,项目名称:moon,代码行数:28,代码来源:geometry.cpp

示例2: collect

	std::auto_ptr<Geometry> collect( const Geometry& ga, const Geometry& gb )
	{
		if ( ga.geometryTypeId() == gb.geometryTypeId() ) {
			if ( ga.geometryTypeId() == TYPE_POINT ) {
				MultiPoint *mp = new MultiPoint;
				mp->addGeometry( ga );
				mp->addGeometry( gb );
				return std::auto_ptr<Geometry>(mp);
			}
			else if ( ga.geometryTypeId() == TYPE_LINESTRING ) {
				MultiLineString *mls = new MultiLineString();
				mls->addGeometry(ga);
				mls->addGeometry(gb);
				return std::auto_ptr<Geometry>( mls );
			}
			else if ( ga.geometryTypeId() == TYPE_POLYGON ) {
				MultiPolygon *mp = new MultiPolygon();
				mp->addGeometry(ga);
				mp->addGeometry(gb);
				return std::auto_ptr<Geometry>( mp );
			}
			else if ( ga.geometryTypeId() == TYPE_SOLID ) {
				MultiSolid *mp = new MultiSolid();
				mp->addGeometry(ga);
				mp->addGeometry(gb);
				return std::auto_ptr<Geometry>( mp );
			}
		}

		// else
		GeometryCollection* coll = new GeometryCollection();
		coll->addGeometry(ga);
		coll->addGeometry(gb);
		return std::auto_ptr<Geometry>( coll );
	}
开发者ID:amutu,项目名称:SFCGAL,代码行数:35,代码来源:collect.cpp

示例3: offsetLine

optional<GeometryCollection> offsetLine(const GeometryCollection& rings, const double offset) {
    if (offset == 0) return {};

    GeometryCollection newRings;
    Point<double> zero(0, 0);
    for (const auto& ring : rings) {
        newRings.emplace_back();
        auto& newRing = newRings.back();

        for (auto i = ring.begin(); i != ring.end(); i++) {
            auto& p = *i;

            Point<double> aToB = i == ring.begin() ?
                zero :
                util::perp(util::unit(convertPoint<double>(p - *(i - 1))));
            Point<double> bToC = i + 1 == ring.end() ?
                zero :
                util::perp(util::unit(convertPoint<double>(*(i + 1) - p)));
            Point<double> extrude = util::unit(aToB + bToC);

            const double cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y;
            extrude *= (1.0 / cosHalfAngle);

            newRing.push_back(convertPoint<int16_t>(extrude * offset) + p);
        }
    }

    return newRings;
}
开发者ID:Budroid,项目名称:mapbox-gl-native,代码行数:29,代码来源:line_layer_impl.cpp

示例4: downsizeGeometry

/**
 * Tiles the geometry up until all the cells have less than given number of points.
 */
void downsizeGeometry(Geometry* geometry, const SpatialReference* featureSRS, unsigned int maxPoints, GeometryCollection& out)
{
    // If the geometyr is greater than the maximum number of points, we need to tile it up further.
    if (geometry->size() > maxPoints)
    {
        OE_NOTICE << "Downsizing geometry of size " << geometry->size() << std::endl;
        // Tile the geometry.
        GeometryCollection tmp;
        tileGeometry(geometry, featureSRS, 2, 2, tmp );
        
        for (unsigned int i = 0; i < tmp.size(); i++)
        {
            Geometry* g = tmp[i].get();

            // If the generated geometry still has too many points, continue to downsample it recursively.
            if (g->size() > maxPoints)
            {
                // We pass "out" as the destination here since downsizeGeometry will only append tiles that are less than the max size.
                downsizeGeometry( g, featureSRS, maxPoints, out );
            }
            else
            {
                // Append the geometry to the output list.
                out.push_back( g );
            }
        }
    }
    else
    {
        // The geometry is valid, so add it to the output list.
        out.push_back( geometry );
    }
}
开发者ID:makemefriendanshu,项目名称:osgearth,代码行数:36,代码来源:BuildGeometryFilter.cpp

示例5: edit

GeometryCollection*
GeometryEditor::editGeometryCollection(const GeometryCollection *collection, GeometryEditorOperation *operation)
{
	GeometryCollection *newCollection = (GeometryCollection*) operation->edit(collection,factory);
	vector<Geometry*> *geometries = new vector<Geometry*>();
	for (int i = 0; i < newCollection->getNumGeometries(); i++) {
		Geometry *geometry = edit(newCollection->getGeometryN(i),
			operation);
		if (geometry->isEmpty()) {
			delete geometry;
			continue;
		}
		geometries->push_back(geometry);
	}

	if (typeid(*newCollection)==typeid(MultiPoint)) {
		delete newCollection;
		return factory->createMultiPoint(geometries);
	}
	else if (typeid(*newCollection)==typeid(MultiLineString)) {
		delete newCollection;
		return factory->createMultiLineString(geometries);
	}
	else if (typeid(*newCollection)==typeid(MultiPolygon)) {
		delete newCollection;
		return factory->createMultiPolygon(geometries);
	}
	else {
		delete newCollection;
		return factory->createGeometryCollection(geometries);
	}
}
开发者ID:kanbang,项目名称:Colt,代码行数:32,代码来源:GeometryEditor.cpp

示例6: translateVec

optional<GeometryCollection> FeatureIndex::translateQueryGeometry(
        const GeometryCollection& queryGeometry,
        const std::array<float, 2>& translate,
        const TranslateAnchorType anchorType,
        const float bearing,
        const float pixelsToTileUnits) {

    if (translate[0] == 0 && translate[1] == 0) return {};

    GeometryCoordinate translateVec(translate[0] * pixelsToTileUnits, translate[1] * pixelsToTileUnits);

    if (anchorType == TranslateAnchorType::Viewport) {
        translateVec = util::rotate(translateVec, -bearing);
    }

    GeometryCollection translated;
    for (auto& ring : queryGeometry) {
        translated.emplace_back();
        auto& translatedRing = translated.back();
        for (auto& p : ring) {
            translatedRing.push_back(p - translateVec);
        }
    }
    return translated;
}
开发者ID:digideskio,项目名称:mapbox-gl-native,代码行数:25,代码来源:feature_index.cpp

示例7: visit

void ForceValidityVisitor::visit( GeometryCollection& g )
{
    g.forceValidityFlag( valid_ );
    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
        g.geometryN( i ).accept( *this );
    }
}
开发者ID:Ezio47,项目名称:SFCGAL,代码行数:7,代码来源:ForceValidityVisitor.cpp

示例8: triangulatePolygon3D

void triangulatePolygon3D(
    const GeometryCollection& g,
    TriangulatedSurface& triangulatedSurface
)
{
    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
        triangulatePolygon3D( g.geometryN( i ), triangulatedSurface );
    }
}
开发者ID:HEShuang,项目名称:SFCGAL,代码行数:9,代码来源:triangulatePolygon.cpp

示例9: limitHoles

void limitHoles(GeometryCollection& polygon, uint32_t maxHoles) {
    if (polygon.size() > 1 + maxHoles) {
        std::nth_element(polygon.begin() + 1,
                         polygon.begin() + 1 + maxHoles,
                         polygon.end(),
                         [] (const auto& a, const auto& b) {
                             return signedArea(a) > signedArea(b);
                         });
        polygon.resize(1 + maxHoles);
    }
}
开发者ID:calendreco,项目名称:mapbox-gl-native,代码行数:11,代码来源:geometry_tile.cpp

示例10: operator

 GeometryCollection operator()(const mapbox::geometry::multi_line_string<int16_t>& geom) const {
     GeometryCollection collection;
     collection.reserve(geom.size());
     for (const auto& ring : geom) {
         GeometryCoordinates coordinates;
         coordinates.reserve(ring.size());
         for (const auto& point : ring) {
             coordinates.emplace_back(point);
         }
         collection.push_back(std::move(coordinates));
     }
     return collection;
 }
开发者ID:Budroid,项目名称:mapbox-gl-native,代码行数:13,代码来源:geometry_tile_data.hpp

示例11: write

void WktWriter::write( const GeometryCollection & g )
{
	_s << "GEOMETRYCOLLECTION" ;
	if ( g.isEmpty() ){
		_s << " EMPTY" ;
		return ;
	}

	_s << "(" ;
	for ( size_t i = 0 ; i < g.numGeometries(); i++ ){
		if ( i != 0 )
			_s << ",";
		write( g.geometryN(i) );
	}
	_s << ")" ;
}
开发者ID:mborne,项目名称:sfcgal-with-postgis,代码行数:16,代码来源:WktWriter.cpp

示例12: GetChildren

Rect
GeometryGroup::ComputePathBounds ()
{
	GeometryCollection *children = GetChildren ();
	Rect bounds = Rect (0.0, 0.0, 0.0, 0.0);
	Geometry *geometry;
	int children_count = children->GetCount ();

	for (int i = 0; i < children_count; i++) {
		geometry = children->GetValueAt (i)->AsGeometry ();
		
		bounds = bounds.Union (geometry->GetBounds (), true);
	}
	
	//g_warning ("GeometryGroup::ComputeBounds - x %g y %g w %g h %g", bounds.x, bounds.y, bounds.w, bounds.h);
	return bounds;
}
开发者ID:kangaroo,项目名称:moon,代码行数:17,代码来源:geometry.cpp

示例13: processPolynodeBranch

static void processPolynodeBranch(ClipperLib::PolyNode* polynode, GeometryCollection& rings) {
    // Exterior ring.
    rings.push_back(fromClipperPath(polynode->Contour));
    assert(signedArea(rings.back()) > 0);

    // Interior rings.
    for (auto * ring : polynode->Childs) {
        rings.push_back(fromClipperPath(ring->Contour));
        assert(signedArea(rings.back()) < 0);
    }

    // PolyNodes may be nested in the case of a polygon inside a hole.
    for (auto * ring : polynode->Childs) {
        for (auto * subRing : ring->Childs) {
            processPolynodeBranch(subRing, rings);
        }
    }
}
开发者ID:calendreco,项目名称:mapbox-gl-native,代码行数:18,代码来源:geometry_tile.cpp

示例14: clipLines

GeometryCollection clipLines(const GeometryCollection &lines,
        const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2) {

    GeometryCollection clippedLines;

    for (auto& line : lines) {

        if (line.empty())
            continue;

        auto end = line.end() - 1;
        for (auto it = line.begin(); it != end; it++) {
            GeometryCoordinate p0 = *(it);
            GeometryCoordinate p1 = *(it + 1);

            if (p0.x < x1 && p1.x < x1) {
                continue;
            } else if (p0.x < x1) {
                p0 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
            } else if (p1.x < x1) {
                p1 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
            }

            if (p0.y < y1 && p1.y < y1) {
                continue;
            } else if (p0.y < y1) {
                p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
            } else if (p1.y < y1) {
                p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
            }

            if (p0.x >= x2 && p1.x >= x2) {
                continue;
            } else if (p0.x >= x2) {
                p0 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
            } else if (p1.x >= x2) {
                p1 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
            }

            if (p0.y >= y2 && p1.y >= y2) {
                continue;
            } else if (p0.y >= y2) {
                p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
            } else if (p1.y >= y2) {
                p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
            }

            if (clippedLines.empty() || (!clippedLines.back().empty() && !(p0 == clippedLines.back().back()))) {
                clippedLines.emplace_back();
                clippedLines.back().push_back(p0);
            }

            clippedLines.back().push_back(p1);
        }
    }

    return clippedLines;
}
开发者ID:1SpatialGroupLtd,项目名称:mapbox-gl-native,代码行数:58,代码来源:clip_lines.cpp

示例15: tileGeometry

/**
 * Tiles the Geometry into the given number of columns and rows
 */
void tileGeometry(Geometry* geometry, const SpatialReference* featureSRS, unsigned int numCols, unsigned int numRows, GeometryCollection& out)
{
    // Clear the output list.
    out.clear();

    Bounds b = geometry->getBounds();
    double tw = b.width() / (double)numCols;
    double th = b.height() / (double)numRows;

    // Get the average Z, since GEOS will set teh Z of new verts to that of the cropping polygon,
    // which is stupid but that's how it is.
    double z = 0.0;
    for(unsigned i=0; i<geometry->size(); ++i)
        z += geometry->at(i).z();
    z /= geometry->size();

    osg::ref_ptr<Polygon> poly = new Polygon;
    poly->resize( 4 );        

    for(int x=0; x<(int)numCols; ++x)
    {
        for(int y=0; y<(int)numRows; ++y)
        {
            (*poly)[0].set( b.xMin() + tw*(double)x,     b.yMin() + th*(double)y,     z );
            (*poly)[1].set( b.xMin() + tw*(double)(x+1), b.yMin() + th*(double)y,     z );
            (*poly)[2].set( b.xMin() + tw*(double)(x+1), b.yMin() + th*(double)(y+1), z );
            (*poly)[3].set( b.xMin() + tw*(double)x,     b.yMin() + th*(double)(y+1), z );

            osg::ref_ptr<Geometry> ringTile;
            if ( geometry->crop(poly.get(), ringTile) )
            {
                // Use an iterator since crop could return a multi-polygon
                GeometryIterator gi( ringTile.get(), false );
                while( gi.hasMore() )
                {
                    Geometry* geom = gi.next();
                    out.push_back( geom );                                                
                }
            }
        }
    }
}
开发者ID:makemefriendanshu,项目名称:osgearth,代码行数:45,代码来源:BuildGeometryFilter.cpp


注:本文中的GeometryCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。