[Synopsis-changes] Synopsis/Synopsis/doc/Tutorial/examples/Paths Bezier.h,NONE,1.1 Makefile,NONE,1.1 Nurbs.h,NONE,1.1 Path.h,NONE,1.1 Polyline.h,NONE,1.1

Stefan Seefeld stefan at synopsis.fresco.org
Wed Dec 10 05:25:21 UTC 2003


Update of /cvs/synopsis/Synopsis/doc/Tutorial/examples/Paths
In directory frida:/tmp/cvs-serv4415/doc/Tutorial/examples/Paths

Added Files:
	Bezier.h Makefile Nurbs.h Path.h Polyline.h 
Log Message:
more work on tutorial

--- NEW FILE: Bezier.h ---
#ifndef _Bezier_h
#define _Bezier_h

#include "Path.h"
#include <vector>

namespace Paths
{

//.
//. The Bezier class. It implements a bezier curve
//. for the given order.
//.
template <size_t Order>
class Bezier : public Path
{
public:
  //. Create a new Bezier.
  Bezier();

  //. @group Manipulators {

  //. Add a new control point.
  void add_control_point(const Vertex &);

  //. Remove the control point at index i.
  void remove_control_point(size_t i);
  //. }
  virtual void draw();
private:
  //. The data...
  std::vector<Vertex> _controls;
};

}

#endif

--- NEW FILE: Makefile ---
synopsis:= ../../../../bin/synopsis

src	:= Path.h Polyline.h Bezier.h Nurbs.h
syn	:= $(patsubst %.h, %.syn, $(src))

Paths: Paths.syn
	$(synopsis) -f HTML --javadoc -o $@ $<

Paths.syn: $(syn)
	$(synopsis) -l Grouper1 -o $@ $^

Path.syn: Path.h
	$(synopsis) -p Cxx -l SSDComments,Previous -o $@ $<

Polyline.syn: Polyline.h
	$(synopsis) -p Cxx -l SSComments -o $@ $<

Bezier.syn: Bezier.h
	$(synopsis) -p Cxx -l SSDComments -o $@ $<

Nurbs.syn: Nurbs.h
	$(synopsis) -p Cxx -l JavaComments,JavaTags -o $@ $<

clean:
	rm -rf *.syn

distclean: clean
	rm -rf Paths
--- NEW FILE: Nurbs.h ---
#ifndef _Nurbs_h
#define _Nurbs_h

#include "Path.h"
#include <vector>

namespace Paths
{

/**
 * The Nurbs class. It implements a nurbs curve
 * for the given order. It is a very powerful
 * and flexible curve representation. For simpler
 * cases you may prefer to use a @see Bezier curve.
 */
template <size_t Order>
class Nurbs : public Path
{
public:
  /**
   * Create a new Nurbs curve.
   */
  Nurbs();
  /**
   * Inserts a control point with the given weight.
   * The knot value determines the position in the sequence.
   * @param knot the parameter value at which to insert a new knot
   * @param vertex the control point
   * @param weight the weight of the control point
   */
  void insert_control_point(double knot, const Vertex &vertex,
                            double weight);
  virtual void draw();
private:
  /**
   * The data...
   */
  std::vector<Vertex> _controls;
  std::vector<double> _weights;
  std::vector<double> _knots;
};

}

#endif

--- NEW FILE: Path.h ---
#ifndef _Path_h
#define _Path_h

//. A Vertex is a 2D point.
struct Vertex
{
  double x; //.< the x coordinate
  double y; //.< the y coordinate
};

//. Path is the basic abstraction
//. used for drawing (curved) paths.
class Path
{
public:
  virtual ~Path() {}
  //. Draw this path.
  virtual void draw() = 0;
  // temporarily commented out...
  // void intersects(const Path &);
private:
};

#endif

--- NEW FILE: Polyline.h ---
#ifndef _Polyline_h
#define _Polyline_h

#include "Path.h"
#include <vector>

namespace Paths
{

// The Polyline class. It is an ordered set of
// connected line segments.
class Polyline : public Path
{
public:
  // Create a new Polyline.
  //
  Polyline();
  // @group Manipulators {

  // Add a new vertex.
  void add_vertex(const Vertex &);
  // Remove the vertex at index i.
  void remove_vertex(size_t i);
  // }
  virtual void draw();
private:
  // The data...
  std::vector<Vertex> _vertices;
};

}

#endif





More information about the Synopsis-changes mailing list