osg中的工厂模式(c++)

c++中的工厂模式: http://blog.csdn.net/wuzhekai1985

不过在实际应用中,我们往往不需要使用到上文链接中介绍的那么复杂的继承关系,通常一个普通的类就可以解决问题.

osgearth中也使用到了工厂模式:GeometryFactory,很好的解决了圆形,弧形,椭圆,椭圆弧形,矩形的创建.



namespace osgEarth { namespace Symbology
{
    using namespace osgEarth;

    /**
     * Convenience class for building simple tessellated Geometry shapes.
     */
    class OSGEARTHSYMBOLOGY_EXPORT GeometryFactory
    {
    public:
        /**
         * Constructs the factory.
         * @param srs The spatial reference in which to create the geometry, or NULL to
         *            create simple localized geometry.
         */
        GeometryFactory( const SpatialReference* srs =0L );

        /** dtor */
        virtual ~GeometryFactory() { }

        /**
         * Creates a circle geometry.
         * @param center Center point (must be in map SRS if a map was provided in ctor)
         * @param radius Circle radius
         * @param numSegments Number of circumference segments, or zero to automatically calculate it
         * @param geomToUse Use this geometry instead of creating a Polygon.
         */
        Geometry* createCircle( 
            const osg::Vec3d& center,
            const Distance&   radius,
            unsigned          numSegments =0,
            Geometry*         geomToUse   =0L) const;

        /**
         * Creates an arc geometry.
         * @param center Center point (must be in map SRS if a map was provided in ctor)
         * @param radius Arc radius
         * @param start  Starting angle of the arc
         * @param end    Ending angle of the arc
         * @param numSegments Number of circumference segments, or zero to automatically calculate it
         * @param pie    Indicates to create a pie shape rather than an arc.
         */
        Geometry* createArc(
            const osg::Vec3d& center,
            const Distance&   radius,
            const Angle&      startAngle,
            const Angle&      endAngle,
            unsigned          numSegments =0,
            Geometry*         geomToUse   =0L,
            bool              pie = false) const;

        /**
         * Creates a ellipse geometry.
         * @param center Center point (must be in map SRS if a map was provided in ctor)
         * @param radiusMajor Major radius (X-axis) length
         * @param radiusMinor Minor radius (Y-axis) length
         * @param rotationAngle with respect to the X-axis
         * @param numSegments Number of circumference segments, or zero to automatically calculate it
         * @param geomToUse Use this geometry instead of creating a Polygon.
         */
        Geometry* createEllipse(
            const osg::Vec3d& center,
            const Distance&   radiusMajor,
            const Distance&   radiusMinor,
            const Angle&      rotationAngle,
            unsigned          numSegments =0,
            Geometry*         geomToUse   =0L) const;

        /**
         * Creates a ellipse geometry.
         * @param center Center point (must be in map SRS if a map was provided in ctor)
         * @param radiusMajor Major radius (X-axis) length
         * @param radiusMinor Minor radius (Y-axis) length
         * @param rotationAngle with respect to the X-axis
         * @param start  Starting angle of the arc
         * @param end    Ending angle of the arc
         * @param numSegments Number of circumference segments, or zero to automatically calculate it
         * @param geomToUse Use this geometry instead of creating a Polygon.
         * @param pie    Indicates to create a pie shape rather than an arc.
         */
        Geometry* createEllipticalArc(
            const osg::Vec3d& center,
            const Distance&   radiusMajor,
            const Distance&   radiusMinor,
            const Angle&      rotationAngle,
            const Angle&      startAngle,
            const Angle&      endAngle,
            unsigned          numSegments =0,
            Geometry*         geomToUse   =0L,
            bool              pie = false) const;

        /**
         * Creates a rectangle geometry
         * @param center Center point (must be in map SRS if the map was provided in ctor)
         * @param width The width of the rectangle
         * @param height The height of the rectangle
         */
        Geometry* createRectangle(
            const osg::Vec3d& center,
            const Distance&   width,
            const Distance&   height ) const;

    protected:

        osg::ref_ptr<const SpatialReference> _srs;
    };

} }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值