1 /* GTS - Library for the manipulation of triangulated surfaces
2 * Copyright (C) 1999 Stéphane Popinet
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 static void nvertex_read (GtsObject
** po
, GtsFile
* fp
)
25 if ((*po
)->klass
->parent_class
->read
)
26 (* (*po
)->klass
->parent_class
->read
) (po
, fp
);
28 if (fp
->type
!= '\n' && fp
->type
!= GTS_ERROR
) {
29 strncpy (GTS_NVERTEX (*po
)->name
, fp
->token
->str
, GTS_NAME_LENGTH
);
30 gts_file_next_token (fp
);
34 static void nvertex_write (GtsObject
* o
, FILE * fptr
)
36 GtsNVertex
* nv
= GTS_NVERTEX (o
);
38 (* o
->klass
->parent_class
->write
) (o
, fptr
);
39 if (nv
->name
[0] != '\0')
40 fprintf (fptr
, " %s", nv
->name
);
43 static void nvertex_class_init (GtsNVertexClass
* klass
)
45 GTS_OBJECT_CLASS (klass
)->read
= nvertex_read
;
46 GTS_OBJECT_CLASS (klass
)->write
= nvertex_write
;
49 static void nvertex_init (GtsNVertex
* nvertex
)
51 nvertex
->name
[0] = '\0';
57 * Returns: the #GtsNVertexClass.
59 GtsNVertexClass
* gts_nvertex_class (void)
61 static GtsNVertexClass
* klass
= NULL
;
64 GtsObjectClassInfo nvertex_info
= {
67 sizeof (GtsNVertexClass
),
68 (GtsObjectClassInitFunc
) nvertex_class_init
,
69 (GtsObjectInitFunc
) nvertex_init
,
73 klass
= gts_object_class_new (GTS_OBJECT_CLASS (gts_vertex_class ()),
80 static void nedge_read (GtsObject
** po
, GtsFile
* fp
)
82 if (fp
->type
!= GTS_STRING
) {
83 gts_file_error (fp
, "expecting a string (name)");
86 strncpy (GTS_NEDGE (*po
)->name
, fp
->token
->str
, GTS_NAME_LENGTH
);
87 gts_file_next_token (fp
);
90 static void nedge_write (GtsObject
* o
, FILE * fptr
)
92 GtsNEdge
* ne
= GTS_NEDGE (o
);
94 if (ne
->name
[0] != '\0')
95 fprintf (fptr
, " %s", ne
->name
);
98 static void nedge_class_init (GtsNEdgeClass
* klass
)
100 GTS_OBJECT_CLASS (klass
)->read
= nedge_read
;
101 GTS_OBJECT_CLASS (klass
)->write
= nedge_write
;
104 static void nedge_init (GtsNEdge
* nedge
)
106 nedge
->name
[0] = '\0';
112 * Returns: the #GtsNEdgeClass.
114 GtsNEdgeClass
* gts_nedge_class (void)
116 static GtsNEdgeClass
* klass
= NULL
;
119 GtsObjectClassInfo nedge_info
= {
122 sizeof (GtsNEdgeClass
),
123 (GtsObjectClassInitFunc
) nedge_class_init
,
124 (GtsObjectInitFunc
) nedge_init
,
125 (GtsArgSetFunc
) NULL
,
128 klass
= gts_object_class_new (GTS_OBJECT_CLASS (gts_edge_class ()),
135 static void nface_read (GtsObject
** po
, GtsFile
* fp
)
137 if (fp
->type
!= GTS_STRING
) {
138 gts_file_error (fp
, "expecting a string (name)");
141 strncpy (GTS_NFACE (*po
)->name
, fp
->token
->str
, GTS_NAME_LENGTH
);
142 gts_file_next_token (fp
);
145 static void nface_write (GtsObject
* o
, FILE * fptr
)
147 GtsNFace
* nf
= GTS_NFACE (o
);
149 if (nf
->name
[0] != '\0')
150 fprintf (fptr
, " %s", GTS_NFACE (o
)->name
);
153 static void nface_class_init (GtsNFaceClass
* klass
)
155 GTS_OBJECT_CLASS (klass
)->read
= nface_read
;
156 GTS_OBJECT_CLASS (klass
)->write
= nface_write
;
159 static void nface_init (GtsNFace
* nface
)
161 nface
->name
[0] = '\0';
167 * Returns: the #GtsNFaceClass.
169 GtsNFaceClass
* gts_nface_class (void)
171 static GtsNFaceClass
* klass
= NULL
;
174 GtsObjectClassInfo nface_info
= {
177 sizeof (GtsNFaceClass
),
178 (GtsObjectClassInitFunc
) nface_class_init
,
179 (GtsObjectInitFunc
) nface_init
,
180 (GtsArgSetFunc
) NULL
,
183 klass
= gts_object_class_new (GTS_OBJECT_CLASS (gts_face_class ()),