Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Sources   Namespace Members   Compound Members   File Members  

MapDataDocument.h

This is the verbatim text of the MapDataDocument.h include file.
//$Header: /home/ben/Mapper/include/RCS/MapDataDocument.h,v 6.9 2002/07/09 22:50:56 ben Exp $
#ifndef MAPDATADOCUMENT_H
#define MAPDATADOCUMENT_H
// Copyright Benedict Adamson 2002.
// This file is part of Mapper.

// Mapper is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.

// Mapper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Mapper; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#include <string>
#include <map>
#include <set>
#include <vector>

#include <dom/DOM_Document.hpp>
#include <dom/DOM_Element.hpp>

#include "error.h"
#include "vector2.h"

class ostream;

class InputSource;
class MapperErrorHandler;
class constraint;
class curve;
   

class order_vector2 {
   public:
      
      bool operator() (
         const vector2 &a,
         const vector2 &b
         ) const
      {
         if( a.x == b.x ){
            return a.y < b.y;
         }else{
            return a.x < b.x;
         };
      }
};



class MapDataDocument
{
   public: //constructors and destructor
      
      MapDataDocument(void);

      virtual ~MapDataDocument(void);

   public: //attributes

      inline const vector2 &origin(void) const
      {
         return this->origin_;
      };

      inline double height(void) const
      {
         return this->height_;
      };

      inline double width(void) const
      {
         return this->width_;
      };


   public: //associations

      inline const map< string, vector2 * > &named_points(void) const
      {
         return this->named_points_;
      };
      
      inline const vector< vector2 * > &anon_points(void) const
      {
         return this->anon_points_;
      };

      inline const map< string, curve * > &curves(void) const
      {
         return this->curves_;
      };

      inline const set< vector2 * > &fixed_points(void) const
      {
         return this->fixed_points_;
      };

      inline const vector< constraint * > &constraints(void) const
      {
        return this->constraints_;
      };

      set< vector2 * > all_points(void) const;

      unsigned precision;


   public: //messages
   
      
      void read(
         InputSource &source,
         MapperErrorHandler &err_handler
         );


      void write(
         ostream &out,
         const double tol
         );

   private: //Helper functions
      
      static void get_attribute(
         string &x, //output
         const DOM_Element &elem,
         const char *attr
         )
         throw(
            error::attribute_error
            );
      

      
      static void get_attribute(
         double &x, //output
         const DOM_Element &elem,
         const char *attr
         )
         throw(
            error::attribute_error
            );
      


      static void get_attribute(
         unsigned &x, //output
         const DOM_Element &elem,
         const char *attr
         )
         throw(
            error::attribute_error
            );
      


      void get_attribute(
         vector2 *&p, //output
         const DOM_Element &elem,
         const char *attr
         ) const
         throw(
            error::attribute_error
            );
      
      

      void get_attribute(
         curve *&c, //output
         const DOM_Element &elem,
         const char *attr
         ) const
         throw(
            error::attribute_error
            );



      static bool has_attribute(
         const DOM_Element &node,
         const char *attr
         );



      inline static bool has_attribute(
         const DOM_Element &node,
         const string &attr
         )
      {
         return has_attribute( node, attr.c_str() );
      };



      inline static void require_attribute(
         const DOM_Element &elem,
         const char *attr
         )
         throw(
            error::attribute_error //if attribute absent
            )
      {
         if( !has_attribute( elem, attr ) )
            throw error::attribute_error( elem, "absent", attr );
         ;
      };



      void read_Tracing(
         DOM_Element &elem,
         MapperErrorHandler &err_handler
         )
         throw(
            error::attribute_error
            );
      
      void convert_Angle(
         DOM_Element &elem,
         const double default_uncertainty
         )
         throw(
            error::attribute_error
            );

      void convert_Bearing(
         DOM_Element &elem, //input
         const double default_uncertainty
         )
         throw(
            error::attribute_error
            );

      void convert_Distance(
         DOM_Element &elem, //input
         const double default_uncertainty_0,
         const double default_uncertainty_1
         )
         throw(
            error::attribute_error
            );

      void convert_Through(
         DOM_Element &elem,
         const double default_uncertainty
         )
         throw(
            error::attribute_error
            );

      void convert_Vector(
         DOM_Element &elem, //input
         const double default_uncertainty_0,
         const double default_uncertainty_1
         )
         throw(
            error::attribute_error
            );

      void convert_Constraint_group(
         DOM_Element &elem, //input
         MapperErrorHandler &err_handler
         )
         throw(
            error::attribute_error
            );

      void convert_Curve(
         DOM_Element &elem, //input
         MapperErrorHandler &err_handler
         )
         throw(
            error::attribute_error
            );

      void convert_Fixed_point(
         DOM_Element &elem //input
         )
         throw(
            error::attribute_error
            );

      void convert_Point(
         DOM_Element &elem //input
         )
         throw(
            error::attribute_error
            );

      void convert_Point_alias(
         DOM_Element &elem //input
         )
         throw(
            error::attribute_error
            );

      void convert_pointrefs(
         DOM_Element &elem, //input
         const char *tag,
         MapperErrorHandler &err_handler
         );

      void convert_Curve_segments(
         DOM_Element &elem, //input
         MapperErrorHandler &err_handler
         );

      void convert(
         MapperErrorHandler &err_handler //input
         );

      vector2 random_position(void) const;

      void convert_Traced_point(
         map< vector2, vector2 *, order_vector2 > &traced_points, //input, output
         map< vector2, double, order_vector2 > &point_uncertainties, //input, output
         DOM_Element &elem, //input
         const double tracing_width,
         const double tracing_height,
         const double default_uncertainty
         )
         throw(
            error::element_error
            );

      void add_angle_constraint(
         const vector2 &vf, //local coordinates
         const vector2 &va,
         const vector2 &vt,
         vector2 *pf, //points, input
         vector2 *pa,
         vector2 *pt,
         const double uf, //uncertainties
         const double ua,
         const double ut
         );

      void convert_Tracing(
         DOM_Element &elem,
         MapperErrorHandler &err_handler
         )
         throw(
            error::attribute_error
            );

      static void set_attribute(
         DOM_Element &elem, //input, output
         const string &attr,
         const double x,
         const unsigned precision
         );

      void update_points(
         const DOM_NodeList &nodes, //input, output
         unsigned &n_points, //input, output
         double &left, //input, output
         double &right, //input, output
         double & top, //input, output
         double &bottom //input, output
         );

      void update_constraints(
         const double tol,
         const DOM_NodeList &nodes //input, output
         );

      void update_child_Coord(
         DOM_Document &doc, //input
         DOM_Element &elem, //input
         DOM_Node &child, //input, output
         const vector2 &p
         );

      void update_curve_segments(
         const DOM_NodeList &nodes //input
         );

      void update(
         const double tol
         );
      
   private: //state
      map< string, vector2 * > named_points_;
      vector< vector2 * > anon_points_;
      map< string, curve * > curves_;
      set< vector2 * > fixed_points_;
      vector< constraint * > constraints_;
      DOM_Document doc;
      vector2 origin_;
      double height_;
      double width_;
      
};

#endif

Generated at Sun Jul 14 20:38:15 2002 for Mapper by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999