Loading ...
Sorry, an error occurred while loading the content.

output API

Expand Messages
  • Masatake YAMATO
    During developing frontline, I found some points to improve splines data type of autotrace. I have to access each fields directly to traverse spline elements.
    Message 1 of 3 , May 6, 2002
    • 0 Attachment
      During developing frontline, I found some points to improve
      splines data type of autotrace. I have to access each fields
      directly to traverse spline elements. I think we have to
      provide APIs to traverse and get each fields. Even the APIs
      are so simple, it is better than direct accessing.

      I'd like to do this before releasing 0.31.0 and use the new
      spline APIs in frontline 0.3.1. Martin, is it ok?
      or should I do in 0.32.0?

      Masatake YAMATO
    • Masatake YAMATO
      I ll add following macros and functions to output.h. And macros in spline.h use output.h. I ll use these output API in frontline. Comments are welcome.
      Message 2 of 3 , May 9, 2002
      • 0 Attachment
        I'll add following macros and functions to output.h.
        And macros in spline.h use output.h.

        I'll use these output API in frontline.

        Comments are welcome.

        Masatake
        /* output.h: output routines

        Copyright (C) 1999, 2000, 2001, 2002 Bernhard Herzog.

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

        This library 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
        Lesser General Public License for more details.

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

        #ifndef OUTPUT_H
        #define OUTPUT_H
        #include <stdio.h>
        #include "autotrace.h"
        #include "types.h"
        #include "exception.h"

        /* Data struct hierarchy:
        spline_list_array (splines)
        -> spline_list...
        --> spline */

        /* Accessors to the Data member */
        #define AT_SPLINE_START_POINT_VALUE(spl) ((spl).v[0])
        #define AT_SPLINE_CONTROL1_VALUE(spl) ((spl).v[1])
        #define AT_SPLINE_CONTROL2_VALUE(spl) ((spl).v[2])
        #define AT_SPLINE_END_POINT_VALUE(spl) ((spl).v[3])
        #define AT_SPLINE_DEGREE_VALUE(spl) ((spl).degree)

        #define AT_SPLINE_START_POINT(spl) &AT_SPLINE_START_POINT_VALUE(*(spl))
        #define AT_SPLINE_CONTROL1(spl) &AT_SPLINE_CONTROL1_VALUE(*(spl))
        #define AT_SPLINE_CONTROL2(spl) &AT_SPLINE_CONTROL2_VALUE(*(spl))
        #define AT_SPLINE_END_POINT(spl) &AT_SPLINE_END_POINT_VALUE(*(spl))
        #define AT_SPLINE_DEGREE(spl) AT_SPLINE_DEGREE_VALUE(*(spl))

        #define AT_SPLINE_LIST_LENGTH_VALUE(spll) ((spll).length)
        #define AT_SPLINE_LIST_LENGTH(spll) AT_SPLINE_LIST_LENGTH_VALUE(*(spll))
        #define AT_SPLINE_LIST_DATA_VALUE(spll) ((spll).data)
        #define AT_SPLINE_LIST_DATA(spll) AT_SPLINE_LIST_DATA_VALUE((*spll))
        #define AT_SPLINE_LIST_ELT_VALUE(spll,index) AT_SPLINE_LIST_DATA_VALUE(spll)[(index)]
        #define AT_SPLINE_LIST_ELT(spll,index) &(AT_SPLINE_LIST_ELT_VALUE((*spll), (index)))
        #define AT_SPLINE_LIST_COLOR_VALUE(spll) ((spll).color)
        #define AT_SPLINE_LIST_COLOR(spll) &(AT_SPLINE_LIST_COLOR_VALUE(*spll))
        #define AT_SPLINE_LIST_IS_OPENED_VALUE(spll) ((spll).open)
        #define AT_SPLINE_LIST_IS_OPENED(spll) AT_SPLINE_LIST_IS_OPENED_VALUE(*(spll))

        #define AT_SPLINE_LIST_ARRAY_LENGTH_VALUE AT_SPLINE_LIST_LENGTH_VALUE
        #define AT_SPLINE_LIST_ARRAY_LENGTH AT_SPLINE_LIST_LENGTH
        #define AT_SPLINE_LIST_ARRAY_ELT_VALUE AT_SPLINE_LIST_ELT_VALUE
        #define AT_SPLINE_LIST_ARRAY_ELT AT_SPLINE_LIST_ELT

        #define AT_SPLINE_LIST_ARRAY_IS_CENTERLINE_VALUE(splla) ((splla).centerline)
        #define AT_SPLINE_LIST_ARRAY_IS_CENTERLINE(splla) AT_SPLINE_LIST_ARRAY_IS_CENTERLINE_VALUE(*(splla))

        /*
        * Glib style traversing
        */
        typedef void (* AtSplineListForeachFunc) (at_spline_list_type * spline_list,
        at_spline_type * spline,
        int index,
        at_address user_data);
        typedef void (* AtSplineListArrayForeachFunc) (at_spline_list_array_type * spline_list_array,
        at_spline_list_type * spline_list,
        int index,
        at_address user_data);

        void at_spline_list_foreach (at_spline_list_type *,
        AtSplineListForeachFunc func,
        at_address user_data);
        void at_spline_list_array_foreach (at_spline_list_array_type *,
        AtSplineListArrayForeachFunc func,
        at_address user_data);

        #endif /* not OUTPUT_H */


        /* spline.h: manipulate the spline representation.
        Some of macrs are only renamed macros in output.h. */

        #ifndef SPLINE_H
        #define SPLINE_H

        #include <stdio.h>
        #include "autotrace.h"
        #include "output.h"

        typedef at_polynomial_degree polynomial_degree;
        typedef at_spline_type spline_type;

        #define LINEARTYPE AT_LINEARTYPE
        #define QUADRATICTYPE AT_QUADRATICTYPE
        #define CUBICTYPE AT_CUBICTYPE
        #define PARALLELELLIPSETYPE AT_PARALLELELLIPSETYPE
        #define ELLIPSETYPE AT_ELLIPSETYPE
        #define CIRCLETYPE AT_CIRCLETYPE

        #define START_POINT AT_SPLINE_START_POINT_VALUE
        #define CONTROL1 AT_SPLINE_CONTROL1_VALUE
        #define CONTROL2 AT_SPLINE_CONTROL2_VALUE
        #define END_POINT AT_SPLINE_END_POINT_VALUE
        #define SPLINE_DEGREE AT_SPLINE_DEGREE_VALUE
        #define SPLINE_LINEARITY(spl) ((spl).linearity)

        #ifndef _IMPORTING
        /* Print a spline on the given file. */
        extern void print_spline (FILE *, spline_type);

        /* Evaluate SPLINE at the given T value. */
        extern at_real_coord evaluate_spline (spline_type spline, at_real t);
        #endif

        /* Each outline in a character is typically represented by many
        splines. So, here is a list structure for that: */
        typedef at_spline_list_type spline_list_type;


        /* An empty list will have length zero (and null data). */
        #define SPLINE_LIST_LENGTH AT_SPLINE_LIST_LENGTH_VALUE

        /* The address of the beginning of the array of data. */
        #define SPLINE_LIST_DATA AT_SPLINE_LIST_DATA_VALUE

        /* The element INDEX in S_L. */
        #define SPLINE_LIST_ELT AT_SPLINE_LIST_ELT_VALUE

        /* The last element in S_L. */
        #define LAST_SPLINE_LIST_ELT(s_l) \
        (SPLINE_LIST_DATA (s_l)[SPLINE_LIST_LENGTH (s_l) - 1])

        /* The previous and next elements to INDEX in S_L. */
        #define NEXT_SPLINE_LIST_ELT(s_l, index) \
        SPLINE_LIST_ELT (s_l, ((index) + 1) % SPLINE_LIST_LENGTH (s_l))
        #define PREV_SPLINE_LIST_ELT(s_l, index) \
        SPLINE_LIST_ELT (s_l, index == 0 \
        ? SPLINE_LIST_LENGTH (s_l) - 1 \
        : index - 1)

        #ifndef _IMPORTING
        /* Construct and destroy new `spline_list_type' objects. */
        extern spline_list_type *new_spline_list (void);
        extern spline_list_type *init_spline_list (spline_type);
        extern void free_spline_list (spline_list_type);

        /* Append the spline S to the list S_LIST. */
        extern void append_spline (spline_list_type *s_list, spline_type s);

        /* Append the elements in list S2 to S1, changing S1. */
        extern void concat_spline_lists (spline_list_type *s1, spline_list_type s2);
        #endif

        typedef at_spline_list_array_type spline_list_array_type;

        /* Turns out we can use the same definitions for lists of lists as for
        just lists. But we define the usual names, just in case. */
        #define SPLINE_LIST_ARRAY_LENGTH AT_SPLINE_LIST_ARRAY_LENGTH_VALUE
        #define SPLINE_LIST_ARRAY_DATA SPLINE_LIST_DATA
        #define SPLINE_LIST_ARRAY_ELT AT_SPLINE_LIST_ARRAY_ELT_VALUE
        #define LAST_SPLINE_LIST_ARRAY_ELT LAST_SPLINE_LIST_ELT

        #ifndef _IMPORTING
        /* The usual routines. */
        extern spline_list_array_type new_spline_list_array (void);
        extern void append_spline_list (spline_list_array_type *, spline_list_type);
        #endif

        #ifdef _EXPORTING
        extern void __declspec(dllexport) __stdcall free_spline_list_array (spline_list_array_type *);
        #elif _IMPORTING
        extern void __declspec(dllimport) __stdcall free_spline_list_array (spline_list_array_type *);
        #else
        extern void free_spline_list_array (spline_list_array_type *);
        #endif

        #endif /* not SPLINE_H */
      • Masatake YAMATO
        I ve commited output.h and spline.h. Martin gave me a private mail that said function names in the output.h are too long. So I ll chanage the names soon.
        Message 3 of 3 , May 11, 2002
        • 0 Attachment
          I've commited output.h and spline.h.
          Martin gave me a private mail that said function names
          in the output.h are too long. So I'll chanage the names
          soon.

          Masatake YAMATO
        Your message has been successfully submitted and would be delivered to recipients shortly.