1 #include <asn.h>
2 
3 #define NLM_GENERATED_CODE_PROTO
4 
5 #include <mapcn3d.h>
6 #include <objcn3d.h>
7 
8 static Boolean loaded = FALSE;
9 
10 #include <cn3d.h>
11 
12 #ifndef NLM_EXTERN_LOADS
13 #define NLM_EXTERN_LOADS {}
14 #endif
15 
16 NLM_EXTERN Boolean LIBCALL
objcn3dAsnLoad(void)17 objcn3dAsnLoad(void)
18 {
19 
20    if ( ! loaded) {
21       NLM_EXTERN_LOADS
22 
23       if ( ! AsnLoad ())
24       return FALSE;
25       loaded = TRUE;
26    }
27 
28    return TRUE;
29 }
30 
31 
32 
33 /**************************************************
34 *    Generated object loaders for Module NCBI-Cn3d
35 *    Generated using ASNCODE Revision: 6.14 at Jan 27, 2003  4:24 PM
36 *
37 **************************************************/
38 
39 
40 /**************************************************
41 *
42 *    Cn3dStyleDictionaryNew()
43 *
44 **************************************************/
45 NLM_EXTERN
46 Cn3dStyleDictionaryPtr LIBCALL
Cn3dStyleDictionaryNew(void)47 Cn3dStyleDictionaryNew(void)
48 {
49    Cn3dStyleDictionaryPtr ptr = MemNew((size_t) sizeof(Cn3dStyleDictionary));
50 
51    return ptr;
52 
53 }
54 
55 
56 /**************************************************
57 *
58 *    Cn3dStyleDictionaryFree()
59 *
60 **************************************************/
61 NLM_EXTERN
62 Cn3dStyleDictionaryPtr LIBCALL
Cn3dStyleDictionaryFree(Cn3dStyleDictionaryPtr ptr)63 Cn3dStyleDictionaryFree(Cn3dStyleDictionaryPtr ptr)
64 {
65 
66    if(ptr == NULL) {
67       return NULL;
68    }
69    Cn3dStyleSettingsFree(ptr -> global_style);
70    AsnGenericUserSeqOfFree(ptr -> style_table, (AsnOptFreeFunc) Cn3dStyleTableItemFree);
71    return MemFree(ptr);
72 }
73 
74 
75 /**************************************************
76 *
77 *    Cn3dStyleDictionaryAsnRead()
78 *
79 **************************************************/
80 NLM_EXTERN
81 Cn3dStyleDictionaryPtr LIBCALL
Cn3dStyleDictionaryAsnRead(AsnIoPtr aip,AsnTypePtr orig)82 Cn3dStyleDictionaryAsnRead(AsnIoPtr aip, AsnTypePtr orig)
83 {
84    DataVal av;
85    AsnTypePtr atp;
86    Boolean isError = FALSE;
87    AsnReadFunc func;
88    Cn3dStyleDictionaryPtr ptr;
89 
90    if (! loaded)
91    {
92       if (! objcn3dAsnLoad()) {
93          return NULL;
94       }
95    }
96 
97    if (aip == NULL) {
98       return NULL;
99    }
100 
101    if (orig == NULL) {         /* Cn3dStyleDictionary ::= (self contained) */
102       atp = AsnReadId(aip, amp, CN3D_STYLE_DICTIONARY);
103    } else {
104       atp = AsnLinkType(orig, CN3D_STYLE_DICTIONARY);
105    }
106    /* link in local tree */
107    if (atp == NULL) {
108       return NULL;
109    }
110 
111    ptr = Cn3dStyleDictionaryNew();
112    if (ptr == NULL) {
113       goto erret;
114    }
115    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
116       goto erret;
117    }
118 
119    atp = AsnReadId(aip,amp, atp);
120    func = NULL;
121 
122    if (atp == CN3D_STYLE_DICTIONARY_global_style) {
123       ptr -> global_style = Cn3dStyleSettingsAsnRead(aip, atp);
124       if (aip -> io_failure) {
125          goto erret;
126       }
127       atp = AsnReadId(aip,amp, atp);
128    }
129    if (atp == CN3D_STYLE_DICTIONARY_style_table) {
130       ptr -> style_table = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dStyleTableItemAsnRead, (AsnOptFreeFunc) Cn3dStyleTableItemFree);
131       if (isError && ptr -> style_table == NULL) {
132          goto erret;
133       }
134       atp = AsnReadId(aip,amp, atp);
135    }
136 
137    if (AsnReadVal(aip, atp, &av) <= 0) {
138       goto erret;
139    }
140    /* end struct */
141 
142 ret:
143    AsnUnlinkType(orig);       /* unlink local tree */
144    return ptr;
145 
146 erret:
147    aip -> io_failure = TRUE;
148    ptr = Cn3dStyleDictionaryFree(ptr);
149    goto ret;
150 }
151 
152 
153 
154 /**************************************************
155 *
156 *    Cn3dStyleDictionaryAsnWrite()
157 *
158 **************************************************/
159 NLM_EXTERN Boolean LIBCALL
Cn3dStyleDictionaryAsnWrite(Cn3dStyleDictionaryPtr ptr,AsnIoPtr aip,AsnTypePtr orig)160 Cn3dStyleDictionaryAsnWrite(Cn3dStyleDictionaryPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
161 {
162    AsnTypePtr atp;
163    Boolean retval = FALSE;
164 
165    if (! loaded)
166    {
167       if (! objcn3dAsnLoad()) {
168          return FALSE;
169       }
170    }
171 
172    if (aip == NULL) {
173       return FALSE;
174    }
175 
176    atp = AsnLinkType(orig, CN3D_STYLE_DICTIONARY);   /* link local tree */
177    if (atp == NULL) {
178       return FALSE;
179    }
180 
181    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
182    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
183       goto erret;
184    }
185 
186    if (ptr -> global_style != NULL) {
187       if ( ! Cn3dStyleSettingsAsnWrite(ptr -> global_style, aip, CN3D_STYLE_DICTIONARY_global_style)) {
188          goto erret;
189       }
190    }
191    AsnGenericUserSeqOfAsnWrite(ptr -> style_table, (AsnWriteFunc) Cn3dStyleTableItemAsnWrite, aip, CN3D_STYLE_DICTIONARY_style_table, CN3D_STYLE_DICTIONARY_style_table_E);
192    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
193       goto erret;
194    }
195    retval = TRUE;
196 
197 erret:
198    AsnUnlinkType(orig);       /* unlink local tree */
199    return retval;
200 }
201 
202 
203 
204 /**************************************************
205 *
206 *    Cn3dUserAnnotationsNew()
207 *
208 **************************************************/
209 NLM_EXTERN
210 Cn3dUserAnnotationsPtr LIBCALL
Cn3dUserAnnotationsNew(void)211 Cn3dUserAnnotationsNew(void)
212 {
213    Cn3dUserAnnotationsPtr ptr = MemNew((size_t) sizeof(Cn3dUserAnnotations));
214 
215    return ptr;
216 
217 }
218 
219 
220 /**************************************************
221 *
222 *    Cn3dUserAnnotationsFree()
223 *
224 **************************************************/
225 NLM_EXTERN
226 Cn3dUserAnnotationsPtr LIBCALL
Cn3dUserAnnotationsFree(Cn3dUserAnnotationsPtr ptr)227 Cn3dUserAnnotationsFree(Cn3dUserAnnotationsPtr ptr)
228 {
229 
230    if(ptr == NULL) {
231       return NULL;
232    }
233    AsnGenericUserSeqOfFree(ptr -> annotations, (AsnOptFreeFunc) Cn3dUserAnnotationFree);
234    Cn3dViewSettingsFree(ptr -> view);
235    return MemFree(ptr);
236 }
237 
238 
239 /**************************************************
240 *
241 *    Cn3dUserAnnotationsAsnRead()
242 *
243 **************************************************/
244 NLM_EXTERN
245 Cn3dUserAnnotationsPtr LIBCALL
Cn3dUserAnnotationsAsnRead(AsnIoPtr aip,AsnTypePtr orig)246 Cn3dUserAnnotationsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
247 {
248    DataVal av;
249    AsnTypePtr atp;
250    Boolean isError = FALSE;
251    AsnReadFunc func;
252    Cn3dUserAnnotationsPtr ptr;
253 
254    if (! loaded)
255    {
256       if (! objcn3dAsnLoad()) {
257          return NULL;
258       }
259    }
260 
261    if (aip == NULL) {
262       return NULL;
263    }
264 
265    if (orig == NULL) {         /* Cn3dUserAnnotations ::= (self contained) */
266       atp = AsnReadId(aip, amp, CN3D_USER_ANNOTATIONS);
267    } else {
268       atp = AsnLinkType(orig, CN3D_USER_ANNOTATIONS);
269    }
270    /* link in local tree */
271    if (atp == NULL) {
272       return NULL;
273    }
274 
275    ptr = Cn3dUserAnnotationsNew();
276    if (ptr == NULL) {
277       goto erret;
278    }
279    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
280       goto erret;
281    }
282 
283    atp = AsnReadId(aip,amp, atp);
284    func = NULL;
285 
286    if (atp == CN3D_USER_ANNOTATIONS_annotations) {
287       ptr -> annotations = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dUserAnnotationAsnRead, (AsnOptFreeFunc) Cn3dUserAnnotationFree);
288       if (isError && ptr -> annotations == NULL) {
289          goto erret;
290       }
291       atp = AsnReadId(aip,amp, atp);
292    }
293    if (atp == CN3D_USER_ANNOTATIONS_view) {
294       ptr -> view = Cn3dViewSettingsAsnRead(aip, atp);
295       if (aip -> io_failure) {
296          goto erret;
297       }
298       atp = AsnReadId(aip,amp, atp);
299    }
300 
301    if (AsnReadVal(aip, atp, &av) <= 0) {
302       goto erret;
303    }
304    /* end struct */
305 
306 ret:
307    AsnUnlinkType(orig);       /* unlink local tree */
308    return ptr;
309 
310 erret:
311    aip -> io_failure = TRUE;
312    ptr = Cn3dUserAnnotationsFree(ptr);
313    goto ret;
314 }
315 
316 
317 
318 /**************************************************
319 *
320 *    Cn3dUserAnnotationsAsnWrite()
321 *
322 **************************************************/
323 NLM_EXTERN Boolean LIBCALL
Cn3dUserAnnotationsAsnWrite(Cn3dUserAnnotationsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)324 Cn3dUserAnnotationsAsnWrite(Cn3dUserAnnotationsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
325 {
326    AsnTypePtr atp;
327    Boolean retval = FALSE;
328 
329    if (! loaded)
330    {
331       if (! objcn3dAsnLoad()) {
332          return FALSE;
333       }
334    }
335 
336    if (aip == NULL) {
337       return FALSE;
338    }
339 
340    atp = AsnLinkType(orig, CN3D_USER_ANNOTATIONS);   /* link local tree */
341    if (atp == NULL) {
342       return FALSE;
343    }
344 
345    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
346    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
347       goto erret;
348    }
349 
350    AsnGenericUserSeqOfAsnWrite(ptr -> annotations, (AsnWriteFunc) Cn3dUserAnnotationAsnWrite, aip, CN3D_USER_ANNOTATIONS_annotations, CN3D_USER_ANNOTATIONS_annotations_E);
351    if (ptr -> view != NULL) {
352       if ( ! Cn3dViewSettingsAsnWrite(ptr -> view, aip, CN3D_USER_ANNOTATIONS_view)) {
353          goto erret;
354       }
355    }
356    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
357       goto erret;
358    }
359    retval = TRUE;
360 
361 erret:
362    AsnUnlinkType(orig);       /* unlink local tree */
363    return retval;
364 }
365 
366 
367 
368 /**************************************************
369 *
370 *    Cn3dColorNew()
371 *
372 **************************************************/
373 NLM_EXTERN
374 Cn3dColorPtr LIBCALL
Cn3dColorNew(void)375 Cn3dColorNew(void)
376 {
377    Cn3dColorPtr ptr = MemNew((size_t) sizeof(Cn3dColor));
378 
379    ptr -> scale_factor = 255;
380    ptr -> alpha = 255;
381    return ptr;
382 
383 }
384 
385 
386 /**************************************************
387 *
388 *    Cn3dColorFree()
389 *
390 **************************************************/
391 NLM_EXTERN
392 Cn3dColorPtr LIBCALL
Cn3dColorFree(Cn3dColorPtr ptr)393 Cn3dColorFree(Cn3dColorPtr ptr)
394 {
395 
396    if(ptr == NULL) {
397       return NULL;
398    }
399    return MemFree(ptr);
400 }
401 
402 
403 /**************************************************
404 *
405 *    Cn3dColorAsnRead()
406 *
407 **************************************************/
408 NLM_EXTERN
409 Cn3dColorPtr LIBCALL
Cn3dColorAsnRead(AsnIoPtr aip,AsnTypePtr orig)410 Cn3dColorAsnRead(AsnIoPtr aip, AsnTypePtr orig)
411 {
412    DataVal av;
413    AsnTypePtr atp;
414    Boolean isError = FALSE;
415    AsnReadFunc func;
416    Cn3dColorPtr ptr;
417 
418    if (! loaded)
419    {
420       if (! objcn3dAsnLoad()) {
421          return NULL;
422       }
423    }
424 
425    if (aip == NULL) {
426       return NULL;
427    }
428 
429    if (orig == NULL) {         /* Cn3dColor ::= (self contained) */
430       atp = AsnReadId(aip, amp, CN3D_COLOR);
431    } else {
432       atp = AsnLinkType(orig, CN3D_COLOR);
433    }
434    /* link in local tree */
435    if (atp == NULL) {
436       return NULL;
437    }
438 
439    ptr = Cn3dColorNew();
440    if (ptr == NULL) {
441       goto erret;
442    }
443    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
444       goto erret;
445    }
446 
447    atp = AsnReadId(aip,amp, atp);
448    func = NULL;
449 
450    if (atp == CN3D_COLOR_scale_factor) {
451       if ( AsnReadVal(aip, atp, &av) <= 0) {
452          goto erret;
453       }
454       ptr -> scale_factor = av.intvalue;
455       atp = AsnReadId(aip,amp, atp);
456    }
457    if (atp == CN3D_COLOR_red) {
458       if ( AsnReadVal(aip, atp, &av) <= 0) {
459          goto erret;
460       }
461       ptr -> red = av.intvalue;
462       atp = AsnReadId(aip,amp, atp);
463    }
464    if (atp == CN3D_COLOR_green) {
465       if ( AsnReadVal(aip, atp, &av) <= 0) {
466          goto erret;
467       }
468       ptr -> green = av.intvalue;
469       atp = AsnReadId(aip,amp, atp);
470    }
471    if (atp == CN3D_COLOR_blue) {
472       if ( AsnReadVal(aip, atp, &av) <= 0) {
473          goto erret;
474       }
475       ptr -> blue = av.intvalue;
476       atp = AsnReadId(aip,amp, atp);
477    }
478    if (atp == CN3D_COLOR_alpha) {
479       if ( AsnReadVal(aip, atp, &av) <= 0) {
480          goto erret;
481       }
482       ptr -> alpha = av.intvalue;
483       atp = AsnReadId(aip,amp, atp);
484    }
485 
486    if (AsnReadVal(aip, atp, &av) <= 0) {
487       goto erret;
488    }
489    /* end struct */
490 
491 ret:
492    AsnUnlinkType(orig);       /* unlink local tree */
493    return ptr;
494 
495 erret:
496    aip -> io_failure = TRUE;
497    ptr = Cn3dColorFree(ptr);
498    goto ret;
499 }
500 
501 
502 
503 /**************************************************
504 *
505 *    Cn3dColorAsnWrite()
506 *
507 **************************************************/
508 NLM_EXTERN Boolean LIBCALL
Cn3dColorAsnWrite(Cn3dColorPtr ptr,AsnIoPtr aip,AsnTypePtr orig)509 Cn3dColorAsnWrite(Cn3dColorPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
510 {
511    DataVal av;
512    AsnTypePtr atp;
513    Boolean retval = FALSE;
514 
515    if (! loaded)
516    {
517       if (! objcn3dAsnLoad()) {
518          return FALSE;
519       }
520    }
521 
522    if (aip == NULL) {
523       return FALSE;
524    }
525 
526    atp = AsnLinkType(orig, CN3D_COLOR);   /* link local tree */
527    if (atp == NULL) {
528       return FALSE;
529    }
530 
531    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
532    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
533    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
534       goto erret;
535    }
536 
537    av.intvalue = ptr -> scale_factor;
538    retval = AsnWrite(aip, CN3D_COLOR_scale_factor,  &av);
539    av.intvalue = ptr -> red;
540    retval = AsnWrite(aip, CN3D_COLOR_red,  &av);
541    av.intvalue = ptr -> green;
542    retval = AsnWrite(aip, CN3D_COLOR_green,  &av);
543    av.intvalue = ptr -> blue;
544    retval = AsnWrite(aip, CN3D_COLOR_blue,  &av);
545    av.intvalue = ptr -> alpha;
546    retval = AsnWrite(aip, CN3D_COLOR_alpha,  &av);
547    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
548       goto erret;
549    }
550    retval = TRUE;
551 
552 erret:
553    AsnUnlinkType(orig);       /* unlink local tree */
554    return retval;
555 }
556 
557 
558 
559 /**************************************************
560 *
561 *    Cn3dBackboneStyleNew()
562 *
563 **************************************************/
564 NLM_EXTERN
565 Cn3dBackboneStylePtr LIBCALL
Cn3dBackboneStyleNew(void)566 Cn3dBackboneStyleNew(void)
567 {
568    Cn3dBackboneStylePtr ptr = MemNew((size_t) sizeof(Cn3dBackboneStyle));
569 
570    return ptr;
571 
572 }
573 
574 
575 /**************************************************
576 *
577 *    Cn3dBackboneStyleFree()
578 *
579 **************************************************/
580 NLM_EXTERN
581 Cn3dBackboneStylePtr LIBCALL
Cn3dBackboneStyleFree(Cn3dBackboneStylePtr ptr)582 Cn3dBackboneStyleFree(Cn3dBackboneStylePtr ptr)
583 {
584 
585    if(ptr == NULL) {
586       return NULL;
587    }
588    Cn3dColorFree(ptr -> user_color);
589    return MemFree(ptr);
590 }
591 
592 
593 /**************************************************
594 *
595 *    Cn3dBackboneStyleAsnRead()
596 *
597 **************************************************/
598 NLM_EXTERN
599 Cn3dBackboneStylePtr LIBCALL
Cn3dBackboneStyleAsnRead(AsnIoPtr aip,AsnTypePtr orig)600 Cn3dBackboneStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
601 {
602    DataVal av;
603    AsnTypePtr atp;
604    Boolean isError = FALSE;
605    AsnReadFunc func;
606    Cn3dBackboneStylePtr ptr;
607 
608    if (! loaded)
609    {
610       if (! objcn3dAsnLoad()) {
611          return NULL;
612       }
613    }
614 
615    if (aip == NULL) {
616       return NULL;
617    }
618 
619    if (orig == NULL) {         /* Cn3dBackboneStyle ::= (self contained) */
620       atp = AsnReadId(aip, amp, CN3D_BACKBONE_STYLE);
621    } else {
622       atp = AsnLinkType(orig, CN3D_BACKBONE_STYLE);
623    }
624    /* link in local tree */
625    if (atp == NULL) {
626       return NULL;
627    }
628 
629    ptr = Cn3dBackboneStyleNew();
630    if (ptr == NULL) {
631       goto erret;
632    }
633    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
634       goto erret;
635    }
636 
637    atp = AsnReadId(aip,amp, atp);
638    func = NULL;
639 
640    if (atp == CN3D_BACKBONE_STYLE_type) {
641       if ( AsnReadVal(aip, atp, &av) <= 0) {
642          goto erret;
643       }
644       ptr -> type = av.intvalue;
645       atp = AsnReadId(aip,amp, atp);
646    }
647    if (atp == CN3D_BACKBONE_STYLE_style) {
648       if ( AsnReadVal(aip, atp, &av) <= 0) {
649          goto erret;
650       }
651       ptr -> style = av.intvalue;
652       atp = AsnReadId(aip,amp, atp);
653    }
654    if (atp == CN3D_BACKBONE_STYLE_color_scheme) {
655       if ( AsnReadVal(aip, atp, &av) <= 0) {
656          goto erret;
657       }
658       ptr -> color_scheme = av.intvalue;
659       atp = AsnReadId(aip,amp, atp);
660    }
661    if (atp == CN3D_BACKBONE_STYLE_user_color) {
662       ptr -> user_color = Cn3dColorAsnRead(aip, atp);
663       if (aip -> io_failure) {
664          goto erret;
665       }
666       atp = AsnReadId(aip,amp, atp);
667    }
668 
669    if (AsnReadVal(aip, atp, &av) <= 0) {
670       goto erret;
671    }
672    /* end struct */
673 
674 ret:
675    AsnUnlinkType(orig);       /* unlink local tree */
676    return ptr;
677 
678 erret:
679    aip -> io_failure = TRUE;
680    ptr = Cn3dBackboneStyleFree(ptr);
681    goto ret;
682 }
683 
684 
685 
686 /**************************************************
687 *
688 *    Cn3dBackboneStyleAsnWrite()
689 *
690 **************************************************/
691 NLM_EXTERN Boolean LIBCALL
Cn3dBackboneStyleAsnWrite(Cn3dBackboneStylePtr ptr,AsnIoPtr aip,AsnTypePtr orig)692 Cn3dBackboneStyleAsnWrite(Cn3dBackboneStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
693 {
694    DataVal av;
695    AsnTypePtr atp;
696    Boolean retval = FALSE;
697 
698    if (! loaded)
699    {
700       if (! objcn3dAsnLoad()) {
701          return FALSE;
702       }
703    }
704 
705    if (aip == NULL) {
706       return FALSE;
707    }
708 
709    atp = AsnLinkType(orig, CN3D_BACKBONE_STYLE);   /* link local tree */
710    if (atp == NULL) {
711       return FALSE;
712    }
713 
714    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
715    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
716    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
717       goto erret;
718    }
719 
720    av.intvalue = ptr -> type;
721    retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_type,  &av);
722    av.intvalue = ptr -> style;
723    retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_style,  &av);
724    av.intvalue = ptr -> color_scheme;
725    retval = AsnWrite(aip, CN3D_BACKBONE_STYLE_color_scheme,  &av);
726    if (ptr -> user_color != NULL) {
727       if ( ! Cn3dColorAsnWrite(ptr -> user_color, aip, CN3D_BACKBONE_STYLE_user_color)) {
728          goto erret;
729       }
730    }
731    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
732       goto erret;
733    }
734    retval = TRUE;
735 
736 erret:
737    AsnUnlinkType(orig);       /* unlink local tree */
738    return retval;
739 }
740 
741 
742 
743 /**************************************************
744 *
745 *    Cn3dGeneralStyleNew()
746 *
747 **************************************************/
748 NLM_EXTERN
749 Cn3dGeneralStylePtr LIBCALL
Cn3dGeneralStyleNew(void)750 Cn3dGeneralStyleNew(void)
751 {
752    Cn3dGeneralStylePtr ptr = MemNew((size_t) sizeof(Cn3dGeneralStyle));
753 
754    return ptr;
755 
756 }
757 
758 
759 /**************************************************
760 *
761 *    Cn3dGeneralStyleFree()
762 *
763 **************************************************/
764 NLM_EXTERN
765 Cn3dGeneralStylePtr LIBCALL
Cn3dGeneralStyleFree(Cn3dGeneralStylePtr ptr)766 Cn3dGeneralStyleFree(Cn3dGeneralStylePtr ptr)
767 {
768 
769    if(ptr == NULL) {
770       return NULL;
771    }
772    Cn3dColorFree(ptr -> user_color);
773    return MemFree(ptr);
774 }
775 
776 
777 /**************************************************
778 *
779 *    Cn3dGeneralStyleAsnRead()
780 *
781 **************************************************/
782 NLM_EXTERN
783 Cn3dGeneralStylePtr LIBCALL
Cn3dGeneralStyleAsnRead(AsnIoPtr aip,AsnTypePtr orig)784 Cn3dGeneralStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
785 {
786    DataVal av;
787    AsnTypePtr atp;
788    Boolean isError = FALSE;
789    AsnReadFunc func;
790    Cn3dGeneralStylePtr ptr;
791 
792    if (! loaded)
793    {
794       if (! objcn3dAsnLoad()) {
795          return NULL;
796       }
797    }
798 
799    if (aip == NULL) {
800       return NULL;
801    }
802 
803    if (orig == NULL) {         /* Cn3dGeneralStyle ::= (self contained) */
804       atp = AsnReadId(aip, amp, CN3D_GENERAL_STYLE);
805    } else {
806       atp = AsnLinkType(orig, CN3D_GENERAL_STYLE);
807    }
808    /* link in local tree */
809    if (atp == NULL) {
810       return NULL;
811    }
812 
813    ptr = Cn3dGeneralStyleNew();
814    if (ptr == NULL) {
815       goto erret;
816    }
817    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
818       goto erret;
819    }
820 
821    atp = AsnReadId(aip,amp, atp);
822    func = NULL;
823 
824    if (atp == CN3D_GENERAL_STYLE_is_on) {
825       if ( AsnReadVal(aip, atp, &av) <= 0) {
826          goto erret;
827       }
828       ptr -> is_on = av.boolvalue;
829       atp = AsnReadId(aip,amp, atp);
830    }
831    if (atp == CN3D_GENERAL_STYLE_style) {
832       if ( AsnReadVal(aip, atp, &av) <= 0) {
833          goto erret;
834       }
835       ptr -> style = av.intvalue;
836       atp = AsnReadId(aip,amp, atp);
837    }
838    if (atp == CN3D_GENERAL_STYLE_color_scheme) {
839       if ( AsnReadVal(aip, atp, &av) <= 0) {
840          goto erret;
841       }
842       ptr -> color_scheme = av.intvalue;
843       atp = AsnReadId(aip,amp, atp);
844    }
845    if (atp == CN3D_GENERAL_STYLE_user_color) {
846       ptr -> user_color = Cn3dColorAsnRead(aip, atp);
847       if (aip -> io_failure) {
848          goto erret;
849       }
850       atp = AsnReadId(aip,amp, atp);
851    }
852 
853    if (AsnReadVal(aip, atp, &av) <= 0) {
854       goto erret;
855    }
856    /* end struct */
857 
858 ret:
859    AsnUnlinkType(orig);       /* unlink local tree */
860    return ptr;
861 
862 erret:
863    aip -> io_failure = TRUE;
864    ptr = Cn3dGeneralStyleFree(ptr);
865    goto ret;
866 }
867 
868 
869 
870 /**************************************************
871 *
872 *    Cn3dGeneralStyleAsnWrite()
873 *
874 **************************************************/
875 NLM_EXTERN Boolean LIBCALL
Cn3dGeneralStyleAsnWrite(Cn3dGeneralStylePtr ptr,AsnIoPtr aip,AsnTypePtr orig)876 Cn3dGeneralStyleAsnWrite(Cn3dGeneralStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
877 {
878    DataVal av;
879    AsnTypePtr atp;
880    Boolean retval = FALSE;
881 
882    if (! loaded)
883    {
884       if (! objcn3dAsnLoad()) {
885          return FALSE;
886       }
887    }
888 
889    if (aip == NULL) {
890       return FALSE;
891    }
892 
893    atp = AsnLinkType(orig, CN3D_GENERAL_STYLE);   /* link local tree */
894    if (atp == NULL) {
895       return FALSE;
896    }
897 
898    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
899    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
900    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
901       goto erret;
902    }
903 
904    av.boolvalue = ptr -> is_on;
905    retval = AsnWrite(aip, CN3D_GENERAL_STYLE_is_on,  &av);
906    av.intvalue = ptr -> style;
907    retval = AsnWrite(aip, CN3D_GENERAL_STYLE_style,  &av);
908    av.intvalue = ptr -> color_scheme;
909    retval = AsnWrite(aip, CN3D_GENERAL_STYLE_color_scheme,  &av);
910    if (ptr -> user_color != NULL) {
911       if ( ! Cn3dColorAsnWrite(ptr -> user_color, aip, CN3D_GENERAL_STYLE_user_color)) {
912          goto erret;
913       }
914    }
915    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
916       goto erret;
917    }
918    retval = TRUE;
919 
920 erret:
921    AsnUnlinkType(orig);       /* unlink local tree */
922    return retval;
923 }
924 
925 
926 
927 /**************************************************
928 *
929 *    Cn3dBackboneLabelStyleNew()
930 *
931 **************************************************/
932 NLM_EXTERN
933 Cn3dBackboneLabelStylePtr LIBCALL
Cn3dBackboneLabelStyleNew(void)934 Cn3dBackboneLabelStyleNew(void)
935 {
936    Cn3dBackboneLabelStylePtr ptr = MemNew((size_t) sizeof(Cn3dBackboneLabelStyle));
937 
938    return ptr;
939 
940 }
941 
942 
943 /**************************************************
944 *
945 *    Cn3dBackboneLabelStyleFree()
946 *
947 **************************************************/
948 NLM_EXTERN
949 Cn3dBackboneLabelStylePtr LIBCALL
Cn3dBackboneLabelStyleFree(Cn3dBackboneLabelStylePtr ptr)950 Cn3dBackboneLabelStyleFree(Cn3dBackboneLabelStylePtr ptr)
951 {
952 
953    if(ptr == NULL) {
954       return NULL;
955    }
956    return MemFree(ptr);
957 }
958 
959 
960 /**************************************************
961 *
962 *    Cn3dBackboneLabelStyleAsnRead()
963 *
964 **************************************************/
965 NLM_EXTERN
966 Cn3dBackboneLabelStylePtr LIBCALL
Cn3dBackboneLabelStyleAsnRead(AsnIoPtr aip,AsnTypePtr orig)967 Cn3dBackboneLabelStyleAsnRead(AsnIoPtr aip, AsnTypePtr orig)
968 {
969    DataVal av;
970    AsnTypePtr atp;
971    Boolean isError = FALSE;
972    AsnReadFunc func;
973    Cn3dBackboneLabelStylePtr ptr;
974 
975    if (! loaded)
976    {
977       if (! objcn3dAsnLoad()) {
978          return NULL;
979       }
980    }
981 
982    if (aip == NULL) {
983       return NULL;
984    }
985 
986    if (orig == NULL) {         /* Cn3dBackboneLabelStyle ::= (self contained) */
987       atp = AsnReadId(aip, amp, CN3D_BACKBONE_LABEL_STYLE);
988    } else {
989       atp = AsnLinkType(orig, CN3D_BACKBONE_LABEL_STYLE);
990    }
991    /* link in local tree */
992    if (atp == NULL) {
993       return NULL;
994    }
995 
996    ptr = Cn3dBackboneLabelStyleNew();
997    if (ptr == NULL) {
998       goto erret;
999    }
1000    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1001       goto erret;
1002    }
1003 
1004    atp = AsnReadId(aip,amp, atp);
1005    func = NULL;
1006 
1007    if (atp == CN3D_BACKBONE_LABEL_STYLE_spacing) {
1008       if ( AsnReadVal(aip, atp, &av) <= 0) {
1009          goto erret;
1010       }
1011       ptr -> spacing = av.intvalue;
1012       atp = AsnReadId(aip,amp, atp);
1013    }
1014    if (atp == CN3D_BACKBONE_LABEL_STYLE_type) {
1015       if ( AsnReadVal(aip, atp, &av) <= 0) {
1016          goto erret;
1017       }
1018       ptr -> type = av.intvalue;
1019       atp = AsnReadId(aip,amp, atp);
1020    }
1021    if (atp == CN3D_BACKBONE_LABEL_STYLE_number) {
1022       if ( AsnReadVal(aip, atp, &av) <= 0) {
1023          goto erret;
1024       }
1025       ptr -> number = av.intvalue;
1026       atp = AsnReadId(aip,amp, atp);
1027    }
1028    if (atp == CN3D_BACKBONE_LABEL_STYLE_termini) {
1029       if ( AsnReadVal(aip, atp, &av) <= 0) {
1030          goto erret;
1031       }
1032       ptr -> termini = av.boolvalue;
1033       atp = AsnReadId(aip,amp, atp);
1034    }
1035    if (atp == CN3D_BACKBONE_LABEL_STYLE_white) {
1036       if ( AsnReadVal(aip, atp, &av) <= 0) {
1037          goto erret;
1038       }
1039       ptr -> white = av.boolvalue;
1040       atp = AsnReadId(aip,amp, atp);
1041    }
1042 
1043    if (AsnReadVal(aip, atp, &av) <= 0) {
1044       goto erret;
1045    }
1046    /* end struct */
1047 
1048 ret:
1049    AsnUnlinkType(orig);       /* unlink local tree */
1050    return ptr;
1051 
1052 erret:
1053    aip -> io_failure = TRUE;
1054    ptr = Cn3dBackboneLabelStyleFree(ptr);
1055    goto ret;
1056 }
1057 
1058 
1059 
1060 /**************************************************
1061 *
1062 *    Cn3dBackboneLabelStyleAsnWrite()
1063 *
1064 **************************************************/
1065 NLM_EXTERN Boolean LIBCALL
Cn3dBackboneLabelStyleAsnWrite(Cn3dBackboneLabelStylePtr ptr,AsnIoPtr aip,AsnTypePtr orig)1066 Cn3dBackboneLabelStyleAsnWrite(Cn3dBackboneLabelStylePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1067 {
1068    DataVal av;
1069    AsnTypePtr atp;
1070    Boolean retval = FALSE;
1071 
1072    if (! loaded)
1073    {
1074       if (! objcn3dAsnLoad()) {
1075          return FALSE;
1076       }
1077    }
1078 
1079    if (aip == NULL) {
1080       return FALSE;
1081    }
1082 
1083    atp = AsnLinkType(orig, CN3D_BACKBONE_LABEL_STYLE);   /* link local tree */
1084    if (atp == NULL) {
1085       return FALSE;
1086    }
1087 
1088    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1089    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1090    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1091       goto erret;
1092    }
1093 
1094    av.intvalue = ptr -> spacing;
1095    retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_spacing,  &av);
1096    av.intvalue = ptr -> type;
1097    retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_type,  &av);
1098    av.intvalue = ptr -> number;
1099    retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_number,  &av);
1100    av.boolvalue = ptr -> termini;
1101    retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_termini,  &av);
1102    av.boolvalue = ptr -> white;
1103    retval = AsnWrite(aip, CN3D_BACKBONE_LABEL_STYLE_white,  &av);
1104    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1105       goto erret;
1106    }
1107    retval = TRUE;
1108 
1109 erret:
1110    AsnUnlinkType(orig);       /* unlink local tree */
1111    return retval;
1112 }
1113 
1114 
1115 
1116 /**************************************************
1117 *
1118 *    Cn3dStyleSettingsNew()
1119 *
1120 **************************************************/
1121 NLM_EXTERN
1122 Cn3dStyleSettingsPtr LIBCALL
Cn3dStyleSettingsNew(void)1123 Cn3dStyleSettingsNew(void)
1124 {
1125    Cn3dStyleSettingsPtr ptr = MemNew((size_t) sizeof(Cn3dStyleSettings));
1126 
1127    return ptr;
1128 
1129 }
1130 
1131 
1132 /**************************************************
1133 *
1134 *    Cn3dStyleSettingsFree()
1135 *
1136 **************************************************/
1137 NLM_EXTERN
1138 Cn3dStyleSettingsPtr LIBCALL
Cn3dStyleSettingsFree(Cn3dStyleSettingsPtr ptr)1139 Cn3dStyleSettingsFree(Cn3dStyleSettingsPtr ptr)
1140 {
1141 
1142    if(ptr == NULL) {
1143       return NULL;
1144    }
1145    MemFree(ptr -> name);
1146    Cn3dBackboneStyleFree(ptr -> protein_backbone);
1147    Cn3dBackboneStyleFree(ptr -> nucleotide_backbone);
1148    Cn3dGeneralStyleFree(ptr -> protein_sidechains);
1149    Cn3dGeneralStyleFree(ptr -> nucleotide_sidechains);
1150    Cn3dGeneralStyleFree(ptr -> heterogens);
1151    Cn3dGeneralStyleFree(ptr -> solvents);
1152    Cn3dGeneralStyleFree(ptr -> connections);
1153    Cn3dGeneralStyleFree(ptr -> helix_objects);
1154    Cn3dGeneralStyleFree(ptr -> strand_objects);
1155    Cn3dColorFree(ptr -> virtual_disulfide_color);
1156    Cn3dColorFree(ptr -> background_color);
1157    Cn3dBackboneLabelStyleFree(ptr -> protein_labels);
1158    Cn3dBackboneLabelStyleFree(ptr -> nucleotide_labels);
1159    return MemFree(ptr);
1160 }
1161 
1162 
1163 /**************************************************
1164 *
1165 *    Cn3dStyleSettingsAsnRead()
1166 *
1167 **************************************************/
1168 NLM_EXTERN
1169 Cn3dStyleSettingsPtr LIBCALL
Cn3dStyleSettingsAsnRead(AsnIoPtr aip,AsnTypePtr orig)1170 Cn3dStyleSettingsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1171 {
1172    DataVal av;
1173    AsnTypePtr atp;
1174    Boolean isError = FALSE;
1175    AsnReadFunc func;
1176    Cn3dStyleSettingsPtr ptr;
1177 
1178    if (! loaded)
1179    {
1180       if (! objcn3dAsnLoad()) {
1181          return NULL;
1182       }
1183    }
1184 
1185    if (aip == NULL) {
1186       return NULL;
1187    }
1188 
1189    if (orig == NULL) {         /* Cn3dStyleSettings ::= (self contained) */
1190       atp = AsnReadId(aip, amp, CN3D_STYLE_SETTINGS);
1191    } else {
1192       atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS);
1193    }
1194    /* link in local tree */
1195    if (atp == NULL) {
1196       return NULL;
1197    }
1198 
1199    ptr = Cn3dStyleSettingsNew();
1200    if (ptr == NULL) {
1201       goto erret;
1202    }
1203    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1204       goto erret;
1205    }
1206 
1207    atp = AsnReadId(aip,amp, atp);
1208    func = NULL;
1209 
1210    if (atp == CN3D_STYLE_SETTINGS_name) {
1211       if ( AsnReadVal(aip, atp, &av) <= 0) {
1212          goto erret;
1213       }
1214       ptr -> name = av.ptrvalue;
1215       atp = AsnReadId(aip,amp, atp);
1216    }
1217    if (atp == CN3D_STYLE_SETTINGS_protein_backbone) {
1218       ptr -> protein_backbone = Cn3dBackboneStyleAsnRead(aip, atp);
1219       if (aip -> io_failure) {
1220          goto erret;
1221       }
1222       atp = AsnReadId(aip,amp, atp);
1223    }
1224    if (atp == CN3D_STYLE_SETTINGS_nucleotide_backbone) {
1225       ptr -> nucleotide_backbone = Cn3dBackboneStyleAsnRead(aip, atp);
1226       if (aip -> io_failure) {
1227          goto erret;
1228       }
1229       atp = AsnReadId(aip,amp, atp);
1230    }
1231    if (atp == CN3D_STYLE_SETTINGS_protein_sidechains) {
1232       ptr -> protein_sidechains = Cn3dGeneralStyleAsnRead(aip, atp);
1233       if (aip -> io_failure) {
1234          goto erret;
1235       }
1236       atp = AsnReadId(aip,amp, atp);
1237    }
1238    if (atp == CN3D_STYLE_SETTINGS_nucleotide_sidechains) {
1239       ptr -> nucleotide_sidechains = Cn3dGeneralStyleAsnRead(aip, atp);
1240       if (aip -> io_failure) {
1241          goto erret;
1242       }
1243       atp = AsnReadId(aip,amp, atp);
1244    }
1245    if (atp == CN3D_STYLE_SETTINGS_heterogens) {
1246       ptr -> heterogens = Cn3dGeneralStyleAsnRead(aip, atp);
1247       if (aip -> io_failure) {
1248          goto erret;
1249       }
1250       atp = AsnReadId(aip,amp, atp);
1251    }
1252    if (atp == CN3D_STYLE_SETTINGS_solvents) {
1253       ptr -> solvents = Cn3dGeneralStyleAsnRead(aip, atp);
1254       if (aip -> io_failure) {
1255          goto erret;
1256       }
1257       atp = AsnReadId(aip,amp, atp);
1258    }
1259    if (atp == CN3D_STYLE_SETTINGS_connections) {
1260       ptr -> connections = Cn3dGeneralStyleAsnRead(aip, atp);
1261       if (aip -> io_failure) {
1262          goto erret;
1263       }
1264       atp = AsnReadId(aip,amp, atp);
1265    }
1266    if (atp == CN3D_STYLE_SETTINGS_helix_objects) {
1267       ptr -> helix_objects = Cn3dGeneralStyleAsnRead(aip, atp);
1268       if (aip -> io_failure) {
1269          goto erret;
1270       }
1271       atp = AsnReadId(aip,amp, atp);
1272    }
1273    if (atp == CN3D_STYLE_SETTINGS_strand_objects) {
1274       ptr -> strand_objects = Cn3dGeneralStyleAsnRead(aip, atp);
1275       if (aip -> io_failure) {
1276          goto erret;
1277       }
1278       atp = AsnReadId(aip,amp, atp);
1279    }
1280    if (atp == CN3D_STYLE_SETTINGS_virtual_disulfides_on) {
1281       if ( AsnReadVal(aip, atp, &av) <= 0) {
1282          goto erret;
1283       }
1284       ptr -> virtual_disulfides_on = av.boolvalue;
1285       atp = AsnReadId(aip,amp, atp);
1286    }
1287    if (atp == CN3D_STYLE_SETTINGS_virtual_disulfide_color) {
1288       ptr -> virtual_disulfide_color = Cn3dColorAsnRead(aip, atp);
1289       if (aip -> io_failure) {
1290          goto erret;
1291       }
1292       atp = AsnReadId(aip,amp, atp);
1293    }
1294    if (atp == CN3D_STYLE_SETTINGS_hydrogens_on) {
1295       if ( AsnReadVal(aip, atp, &av) <= 0) {
1296          goto erret;
1297       }
1298       ptr -> hydrogens_on = av.boolvalue;
1299       atp = AsnReadId(aip,amp, atp);
1300    }
1301    if (atp == CN3D_STYLE_SETTINGS_background_color) {
1302       ptr -> background_color = Cn3dColorAsnRead(aip, atp);
1303       if (aip -> io_failure) {
1304          goto erret;
1305       }
1306       atp = AsnReadId(aip,amp, atp);
1307    }
1308    if (atp == CN3D_STYLE_SETTINGS_scale_factor) {
1309       if ( AsnReadVal(aip, atp, &av) <= 0) {
1310          goto erret;
1311       }
1312       ptr -> scale_factor = av.intvalue;
1313       atp = AsnReadId(aip,amp, atp);
1314    }
1315    if (atp == CN3D_STYLE_SETTINGS_space_fill_proportion) {
1316       if ( AsnReadVal(aip, atp, &av) <= 0) {
1317          goto erret;
1318       }
1319       ptr -> space_fill_proportion = av.intvalue;
1320       atp = AsnReadId(aip,amp, atp);
1321    }
1322    if (atp == CN3D_STYLE_SETTINGS_ball_radius) {
1323       if ( AsnReadVal(aip, atp, &av) <= 0) {
1324          goto erret;
1325       }
1326       ptr -> ball_radius = av.intvalue;
1327       atp = AsnReadId(aip,amp, atp);
1328    }
1329    if (atp == CN3D_STYLE_SETTINGS_stick_radius) {
1330       if ( AsnReadVal(aip, atp, &av) <= 0) {
1331          goto erret;
1332       }
1333       ptr -> stick_radius = av.intvalue;
1334       atp = AsnReadId(aip,amp, atp);
1335    }
1336    if (atp == CN3D_STYLE_SETTINGS_tube_radius) {
1337       if ( AsnReadVal(aip, atp, &av) <= 0) {
1338          goto erret;
1339       }
1340       ptr -> tube_radius = av.intvalue;
1341       atp = AsnReadId(aip,amp, atp);
1342    }
1343    if (atp == CN3D_STYLE_SETTINGS_tube_worm_radius) {
1344       if ( AsnReadVal(aip, atp, &av) <= 0) {
1345          goto erret;
1346       }
1347       ptr -> tube_worm_radius = av.intvalue;
1348       atp = AsnReadId(aip,amp, atp);
1349    }
1350    if (atp == CN3D_STYLE_SETTINGS_helix_radius) {
1351       if ( AsnReadVal(aip, atp, &av) <= 0) {
1352          goto erret;
1353       }
1354       ptr -> helix_radius = av.intvalue;
1355       atp = AsnReadId(aip,amp, atp);
1356    }
1357    if (atp == CN3D_STYLE_SETTINGS_strand_width) {
1358       if ( AsnReadVal(aip, atp, &av) <= 0) {
1359          goto erret;
1360       }
1361       ptr -> strand_width = av.intvalue;
1362       atp = AsnReadId(aip,amp, atp);
1363    }
1364    if (atp == CN3D_STYLE_SETTINGS_strand_thickness) {
1365       if ( AsnReadVal(aip, atp, &av) <= 0) {
1366          goto erret;
1367       }
1368       ptr -> strand_thickness = av.intvalue;
1369       atp = AsnReadId(aip,amp, atp);
1370    }
1371    if (atp == CN3D_STYLE_SETTINGS_protein_labels) {
1372       ptr -> protein_labels = Cn3dBackboneLabelStyleAsnRead(aip, atp);
1373       if (aip -> io_failure) {
1374          goto erret;
1375       }
1376       atp = AsnReadId(aip,amp, atp);
1377    }
1378    if (atp == CN3D_STYLE_SETTINGS_nucleotide_labels) {
1379       ptr -> nucleotide_labels = Cn3dBackboneLabelStyleAsnRead(aip, atp);
1380       if (aip -> io_failure) {
1381          goto erret;
1382       }
1383       atp = AsnReadId(aip,amp, atp);
1384    }
1385    if (atp == CN3D_STYLE_SETTINGS_ion_labels) {
1386       if ( AsnReadVal(aip, atp, &av) <= 0) {
1387          goto erret;
1388       }
1389       ptr -> ion_labels = av.boolvalue;
1390       atp = AsnReadId(aip,amp, atp);
1391    }
1392 
1393    if (AsnReadVal(aip, atp, &av) <= 0) {
1394       goto erret;
1395    }
1396    /* end struct */
1397 
1398 ret:
1399    AsnUnlinkType(orig);       /* unlink local tree */
1400    return ptr;
1401 
1402 erret:
1403    aip -> io_failure = TRUE;
1404    ptr = Cn3dStyleSettingsFree(ptr);
1405    goto ret;
1406 }
1407 
1408 
1409 
1410 /**************************************************
1411 *
1412 *    Cn3dStyleSettingsAsnWrite()
1413 *
1414 **************************************************/
1415 NLM_EXTERN Boolean LIBCALL
Cn3dStyleSettingsAsnWrite(Cn3dStyleSettingsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1416 Cn3dStyleSettingsAsnWrite(Cn3dStyleSettingsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1417 {
1418    DataVal av;
1419    AsnTypePtr atp;
1420    Boolean retval = FALSE;
1421 
1422    if (! loaded)
1423    {
1424       if (! objcn3dAsnLoad()) {
1425          return FALSE;
1426       }
1427    }
1428 
1429    if (aip == NULL) {
1430       return FALSE;
1431    }
1432 
1433    atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS);   /* link local tree */
1434    if (atp == NULL) {
1435       return FALSE;
1436    }
1437 
1438    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1439    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1440    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1441       goto erret;
1442    }
1443 
1444    if (ptr -> name != NULL) {
1445       av.ptrvalue = ptr -> name;
1446       retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_name,  &av);
1447    }
1448    if (ptr -> protein_backbone != NULL) {
1449       if ( ! Cn3dBackboneStyleAsnWrite(ptr -> protein_backbone, aip, CN3D_STYLE_SETTINGS_protein_backbone)) {
1450          goto erret;
1451       }
1452    }
1453    if (ptr -> nucleotide_backbone != NULL) {
1454       if ( ! Cn3dBackboneStyleAsnWrite(ptr -> nucleotide_backbone, aip, CN3D_STYLE_SETTINGS_nucleotide_backbone)) {
1455          goto erret;
1456       }
1457    }
1458    if (ptr -> protein_sidechains != NULL) {
1459       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> protein_sidechains, aip, CN3D_STYLE_SETTINGS_protein_sidechains)) {
1460          goto erret;
1461       }
1462    }
1463    if (ptr -> nucleotide_sidechains != NULL) {
1464       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> nucleotide_sidechains, aip, CN3D_STYLE_SETTINGS_nucleotide_sidechains)) {
1465          goto erret;
1466       }
1467    }
1468    if (ptr -> heterogens != NULL) {
1469       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> heterogens, aip, CN3D_STYLE_SETTINGS_heterogens)) {
1470          goto erret;
1471       }
1472    }
1473    if (ptr -> solvents != NULL) {
1474       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> solvents, aip, CN3D_STYLE_SETTINGS_solvents)) {
1475          goto erret;
1476       }
1477    }
1478    if (ptr -> connections != NULL) {
1479       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> connections, aip, CN3D_STYLE_SETTINGS_connections)) {
1480          goto erret;
1481       }
1482    }
1483    if (ptr -> helix_objects != NULL) {
1484       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> helix_objects, aip, CN3D_STYLE_SETTINGS_helix_objects)) {
1485          goto erret;
1486       }
1487    }
1488    if (ptr -> strand_objects != NULL) {
1489       if ( ! Cn3dGeneralStyleAsnWrite(ptr -> strand_objects, aip, CN3D_STYLE_SETTINGS_strand_objects)) {
1490          goto erret;
1491       }
1492    }
1493    av.boolvalue = ptr -> virtual_disulfides_on;
1494    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_virtual_disulfides_on,  &av);
1495    if (ptr -> virtual_disulfide_color != NULL) {
1496       if ( ! Cn3dColorAsnWrite(ptr -> virtual_disulfide_color, aip, CN3D_STYLE_SETTINGS_virtual_disulfide_color)) {
1497          goto erret;
1498       }
1499    }
1500    av.boolvalue = ptr -> hydrogens_on;
1501    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_hydrogens_on,  &av);
1502    if (ptr -> background_color != NULL) {
1503       if ( ! Cn3dColorAsnWrite(ptr -> background_color, aip, CN3D_STYLE_SETTINGS_background_color)) {
1504          goto erret;
1505       }
1506    }
1507    av.intvalue = ptr -> scale_factor;
1508    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_scale_factor,  &av);
1509    av.intvalue = ptr -> space_fill_proportion;
1510    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_space_fill_proportion,  &av);
1511    av.intvalue = ptr -> ball_radius;
1512    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_ball_radius,  &av);
1513    av.intvalue = ptr -> stick_radius;
1514    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_stick_radius,  &av);
1515    av.intvalue = ptr -> tube_radius;
1516    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_tube_radius,  &av);
1517    av.intvalue = ptr -> tube_worm_radius;
1518    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_tube_worm_radius,  &av);
1519    av.intvalue = ptr -> helix_radius;
1520    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_helix_radius,  &av);
1521    av.intvalue = ptr -> strand_width;
1522    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_strand_width,  &av);
1523    av.intvalue = ptr -> strand_thickness;
1524    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_strand_thickness,  &av);
1525    if (ptr -> protein_labels != NULL) {
1526       if ( ! Cn3dBackboneLabelStyleAsnWrite(ptr -> protein_labels, aip, CN3D_STYLE_SETTINGS_protein_labels)) {
1527          goto erret;
1528       }
1529    }
1530    if (ptr -> nucleotide_labels != NULL) {
1531       if ( ! Cn3dBackboneLabelStyleAsnWrite(ptr -> nucleotide_labels, aip, CN3D_STYLE_SETTINGS_nucleotide_labels)) {
1532          goto erret;
1533       }
1534    }
1535    av.boolvalue = ptr -> ion_labels;
1536    retval = AsnWrite(aip, CN3D_STYLE_SETTINGS_ion_labels,  &av);
1537    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1538       goto erret;
1539    }
1540    retval = TRUE;
1541 
1542 erret:
1543    AsnUnlinkType(orig);       /* unlink local tree */
1544    return retval;
1545 }
1546 
1547 
1548 
1549 /**************************************************
1550 *
1551 *    Cn3dStyleSettingsSetFree()
1552 *
1553 **************************************************/
1554 NLM_EXTERN
1555 Cn3dStyleSettingsSetPtr LIBCALL
Cn3dStyleSettingsSetFree(Cn3dStyleSettingsSetPtr ptr)1556 Cn3dStyleSettingsSetFree(Cn3dStyleSettingsSetPtr ptr)
1557 {
1558 
1559    if(ptr == NULL) {
1560       return NULL;
1561    }
1562    AsnGenericUserSeqOfFree(ptr,  (AsnOptFreeFunc) Cn3dStyleSettingsFree);
1563    return NULL;
1564 }
1565 
1566 
1567 /**************************************************
1568 *
1569 *    Cn3dStyleSettingsSetAsnRead()
1570 *
1571 **************************************************/
1572 NLM_EXTERN
1573 Cn3dStyleSettingsSetPtr LIBCALL
Cn3dStyleSettingsSetAsnRead(AsnIoPtr aip,AsnTypePtr orig)1574 Cn3dStyleSettingsSetAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1575 {
1576    AsnTypePtr atp;
1577    Boolean isError = FALSE;
1578    AsnReadFunc func;
1579    Cn3dStyleSettingsSetPtr ptr;
1580 
1581    if (! loaded)
1582    {
1583       if (! objcn3dAsnLoad()) {
1584          return NULL;
1585       }
1586    }
1587 
1588    if (aip == NULL) {
1589       return NULL;
1590    }
1591 
1592    if (orig == NULL) {         /* Cn3dStyleSettingsSet ::= (self contained) */
1593       atp = AsnReadId(aip, amp, CN3D_STYLE_SETTINGS_SET);
1594    } else {
1595       atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS_SET);
1596    }
1597    /* link in local tree */
1598    if (atp == NULL) {
1599       return NULL;
1600    }
1601 
1602    func = NULL;
1603 
1604    ptr  = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dStyleSettingsAsnRead, (AsnOptFreeFunc) Cn3dStyleSettingsFree);
1605    if (isError && ptr  == NULL) {
1606       goto erret;
1607    }
1608 
1609 
1610 
1611 ret:
1612    AsnUnlinkType(orig);       /* unlink local tree */
1613    return ptr;
1614 
1615 erret:
1616    aip -> io_failure = TRUE;
1617    ptr = Cn3dStyleSettingsSetFree(ptr);
1618    goto ret;
1619 }
1620 
1621 
1622 
1623 /**************************************************
1624 *
1625 *    Cn3dStyleSettingsSetAsnWrite()
1626 *
1627 **************************************************/
1628 NLM_EXTERN Boolean LIBCALL
Cn3dStyleSettingsSetAsnWrite(Cn3dStyleSettingsSetPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1629 Cn3dStyleSettingsSetAsnWrite(Cn3dStyleSettingsSetPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1630 {
1631    AsnTypePtr atp;
1632    Boolean retval = FALSE;
1633 
1634    if (! loaded)
1635    {
1636       if (! objcn3dAsnLoad()) {
1637          return FALSE;
1638       }
1639    }
1640 
1641    if (aip == NULL) {
1642       return FALSE;
1643    }
1644 
1645    atp = AsnLinkType(orig, CN3D_STYLE_SETTINGS_SET);   /* link local tree */
1646    if (atp == NULL) {
1647       return FALSE;
1648    }
1649 
1650    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1651    retval = AsnGenericUserSeqOfAsnWrite(ptr , (AsnWriteFunc) Cn3dStyleSettingsAsnWrite, aip, atp, CN3D_STYLE_SETTINGS_SET_E);
1652    retval = TRUE;
1653 
1654 erret:
1655    AsnUnlinkType(orig);       /* unlink local tree */
1656    return retval;
1657 }
1658 
1659 
1660 
1661 /**************************************************
1662 *
1663 *    Cn3dStyleTableItemNew()
1664 *
1665 **************************************************/
1666 NLM_EXTERN
1667 Cn3dStyleTableItemPtr LIBCALL
Cn3dStyleTableItemNew(void)1668 Cn3dStyleTableItemNew(void)
1669 {
1670    Cn3dStyleTableItemPtr ptr = MemNew((size_t) sizeof(Cn3dStyleTableItem));
1671 
1672    return ptr;
1673 
1674 }
1675 
1676 
1677 /**************************************************
1678 *
1679 *    Cn3dStyleTableItemFree()
1680 *
1681 **************************************************/
1682 NLM_EXTERN
1683 Cn3dStyleTableItemPtr LIBCALL
Cn3dStyleTableItemFree(Cn3dStyleTableItemPtr ptr)1684 Cn3dStyleTableItemFree(Cn3dStyleTableItemPtr ptr)
1685 {
1686 
1687    if(ptr == NULL) {
1688       return NULL;
1689    }
1690    Cn3dStyleSettingsFree(ptr -> style);
1691    return MemFree(ptr);
1692 }
1693 
1694 
1695 /**************************************************
1696 *
1697 *    Cn3dStyleTableItemAsnRead()
1698 *
1699 **************************************************/
1700 NLM_EXTERN
1701 Cn3dStyleTableItemPtr LIBCALL
Cn3dStyleTableItemAsnRead(AsnIoPtr aip,AsnTypePtr orig)1702 Cn3dStyleTableItemAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1703 {
1704    DataVal av;
1705    AsnTypePtr atp;
1706    Boolean isError = FALSE;
1707    AsnReadFunc func;
1708    Cn3dStyleTableItemPtr ptr;
1709 
1710    if (! loaded)
1711    {
1712       if (! objcn3dAsnLoad()) {
1713          return NULL;
1714       }
1715    }
1716 
1717    if (aip == NULL) {
1718       return NULL;
1719    }
1720 
1721    if (orig == NULL) {         /* Cn3dStyleTableItem ::= (self contained) */
1722       atp = AsnReadId(aip, amp, CN3D_STYLE_TABLE_ITEM);
1723    } else {
1724       atp = AsnLinkType(orig, CN3D_STYLE_TABLE_ITEM);
1725    }
1726    /* link in local tree */
1727    if (atp == NULL) {
1728       return NULL;
1729    }
1730 
1731    ptr = Cn3dStyleTableItemNew();
1732    if (ptr == NULL) {
1733       goto erret;
1734    }
1735    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1736       goto erret;
1737    }
1738 
1739    atp = AsnReadId(aip,amp, atp);
1740    func = NULL;
1741 
1742    if (atp == CN3D_STYLE_TABLE_ITEM_id) {
1743       if ( AsnReadVal(aip, atp, &av) <= 0) {
1744          goto erret;
1745       }
1746       ptr -> id = av.intvalue;
1747       atp = AsnReadId(aip,amp, atp);
1748    }
1749    if (atp == CN3D_STYLE_TABLE_ITEM_style) {
1750       ptr -> style = Cn3dStyleSettingsAsnRead(aip, atp);
1751       if (aip -> io_failure) {
1752          goto erret;
1753       }
1754       atp = AsnReadId(aip,amp, atp);
1755    }
1756 
1757    if (AsnReadVal(aip, atp, &av) <= 0) {
1758       goto erret;
1759    }
1760    /* end struct */
1761 
1762 ret:
1763    AsnUnlinkType(orig);       /* unlink local tree */
1764    return ptr;
1765 
1766 erret:
1767    aip -> io_failure = TRUE;
1768    ptr = Cn3dStyleTableItemFree(ptr);
1769    goto ret;
1770 }
1771 
1772 
1773 
1774 /**************************************************
1775 *
1776 *    Cn3dStyleTableItemAsnWrite()
1777 *
1778 **************************************************/
1779 NLM_EXTERN Boolean LIBCALL
Cn3dStyleTableItemAsnWrite(Cn3dStyleTableItemPtr ptr,AsnIoPtr aip,AsnTypePtr orig)1780 Cn3dStyleTableItemAsnWrite(Cn3dStyleTableItemPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1781 {
1782    DataVal av;
1783    AsnTypePtr atp;
1784    Boolean retval = FALSE;
1785 
1786    if (! loaded)
1787    {
1788       if (! objcn3dAsnLoad()) {
1789          return FALSE;
1790       }
1791    }
1792 
1793    if (aip == NULL) {
1794       return FALSE;
1795    }
1796 
1797    atp = AsnLinkType(orig, CN3D_STYLE_TABLE_ITEM);   /* link local tree */
1798    if (atp == NULL) {
1799       return FALSE;
1800    }
1801 
1802    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1803    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1804    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1805       goto erret;
1806    }
1807 
1808    av.intvalue = ptr -> id;
1809    retval = AsnWrite(aip, CN3D_STYLE_TABLE_ITEM_id,  &av);
1810    if (ptr -> style != NULL) {
1811       if ( ! Cn3dStyleSettingsAsnWrite(ptr -> style, aip, CN3D_STYLE_TABLE_ITEM_style)) {
1812          goto erret;
1813       }
1814    }
1815    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1816       goto erret;
1817    }
1818    retval = TRUE;
1819 
1820 erret:
1821    AsnUnlinkType(orig);       /* unlink local tree */
1822    return retval;
1823 }
1824 
1825 
1826 
1827 /**************************************************
1828 *
1829 *    Cn3dResidueRangeNew()
1830 *
1831 **************************************************/
1832 NLM_EXTERN
1833 Cn3dResidueRangePtr LIBCALL
Cn3dResidueRangeNew(void)1834 Cn3dResidueRangeNew(void)
1835 {
1836    Cn3dResidueRangePtr ptr = MemNew((size_t) sizeof(Cn3dResidueRange));
1837 
1838    return ptr;
1839 
1840 }
1841 
1842 
1843 /**************************************************
1844 *
1845 *    Cn3dResidueRangeFree()
1846 *
1847 **************************************************/
1848 NLM_EXTERN
1849 Cn3dResidueRangePtr LIBCALL
Cn3dResidueRangeFree(Cn3dResidueRangePtr ptr)1850 Cn3dResidueRangeFree(Cn3dResidueRangePtr ptr)
1851 {
1852 
1853    if(ptr == NULL) {
1854       return NULL;
1855    }
1856    return MemFree(ptr);
1857 }
1858 
1859 
1860 /**************************************************
1861 *
1862 *    Cn3dResidueRangeAsnRead()
1863 *
1864 **************************************************/
1865 NLM_EXTERN
1866 Cn3dResidueRangePtr LIBCALL
Cn3dResidueRangeAsnRead(AsnIoPtr aip,AsnTypePtr orig)1867 Cn3dResidueRangeAsnRead(AsnIoPtr aip, AsnTypePtr orig)
1868 {
1869    DataVal av;
1870    AsnTypePtr atp;
1871    Boolean isError = FALSE;
1872    AsnReadFunc func;
1873    Cn3dResidueRangePtr ptr;
1874 
1875    if (! loaded)
1876    {
1877       if (! objcn3dAsnLoad()) {
1878          return NULL;
1879       }
1880    }
1881 
1882    if (aip == NULL) {
1883       return NULL;
1884    }
1885 
1886    if (orig == NULL) {         /* Cn3dResidueRange ::= (self contained) */
1887       atp = AsnReadId(aip, amp, CN3D_RESIDUE_RANGE);
1888    } else {
1889       atp = AsnLinkType(orig, CN3D_RESIDUE_RANGE);
1890    }
1891    /* link in local tree */
1892    if (atp == NULL) {
1893       return NULL;
1894    }
1895 
1896    ptr = Cn3dResidueRangeNew();
1897    if (ptr == NULL) {
1898       goto erret;
1899    }
1900    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
1901       goto erret;
1902    }
1903 
1904    atp = AsnReadId(aip,amp, atp);
1905    func = NULL;
1906 
1907    if (atp == CN3D_RESIDUE_RANGE_from) {
1908       if ( AsnReadVal(aip, atp, &av) <= 0) {
1909          goto erret;
1910       }
1911       ptr -> from = av.intvalue;
1912       atp = AsnReadId(aip,amp, atp);
1913    }
1914    if (atp == CN3D_RESIDUE_RANGE_to) {
1915       if ( AsnReadVal(aip, atp, &av) <= 0) {
1916          goto erret;
1917       }
1918       ptr -> to = av.intvalue;
1919       atp = AsnReadId(aip,amp, atp);
1920    }
1921 
1922    if (AsnReadVal(aip, atp, &av) <= 0) {
1923       goto erret;
1924    }
1925    /* end struct */
1926 
1927 ret:
1928    AsnUnlinkType(orig);       /* unlink local tree */
1929    return ptr;
1930 
1931 erret:
1932    aip -> io_failure = TRUE;
1933    ptr = Cn3dResidueRangeFree(ptr);
1934    goto ret;
1935 }
1936 
1937 
1938 
1939 /**************************************************
1940 *
1941 *    Cn3dResidueRangeAsnWrite()
1942 *
1943 **************************************************/
1944 NLM_EXTERN Boolean LIBCALL
Cn3dResidueRangeAsnWrite(Cn3dResidueRangePtr ptr,AsnIoPtr aip,AsnTypePtr orig)1945 Cn3dResidueRangeAsnWrite(Cn3dResidueRangePtr ptr, AsnIoPtr aip, AsnTypePtr orig)
1946 {
1947    DataVal av;
1948    AsnTypePtr atp;
1949    Boolean retval = FALSE;
1950 
1951    if (! loaded)
1952    {
1953       if (! objcn3dAsnLoad()) {
1954          return FALSE;
1955       }
1956    }
1957 
1958    if (aip == NULL) {
1959       return FALSE;
1960    }
1961 
1962    atp = AsnLinkType(orig, CN3D_RESIDUE_RANGE);   /* link local tree */
1963    if (atp == NULL) {
1964       return FALSE;
1965    }
1966 
1967    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1968    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1969    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
1970       goto erret;
1971    }
1972 
1973    av.intvalue = ptr -> from;
1974    retval = AsnWrite(aip, CN3D_RESIDUE_RANGE_from,  &av);
1975    av.intvalue = ptr -> to;
1976    retval = AsnWrite(aip, CN3D_RESIDUE_RANGE_to,  &av);
1977    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
1978       goto erret;
1979    }
1980    retval = TRUE;
1981 
1982 erret:
1983    AsnUnlinkType(orig);       /* unlink local tree */
1984    return retval;
1985 }
1986 
1987 
1988 
1989 /**************************************************
1990 *
1991 *    Cn3dMoleculeLocationNew()
1992 *
1993 **************************************************/
1994 NLM_EXTERN
1995 Cn3dMoleculeLocationPtr LIBCALL
Cn3dMoleculeLocationNew(void)1996 Cn3dMoleculeLocationNew(void)
1997 {
1998    Cn3dMoleculeLocationPtr ptr = MemNew((size_t) sizeof(Cn3dMoleculeLocation));
1999 
2000    return ptr;
2001 
2002 }
2003 
2004 
2005 /**************************************************
2006 *
2007 *    Cn3dMoleculeLocationFree()
2008 *
2009 **************************************************/
2010 NLM_EXTERN
2011 Cn3dMoleculeLocationPtr LIBCALL
Cn3dMoleculeLocationFree(Cn3dMoleculeLocationPtr ptr)2012 Cn3dMoleculeLocationFree(Cn3dMoleculeLocationPtr ptr)
2013 {
2014 
2015    if(ptr == NULL) {
2016       return NULL;
2017    }
2018    AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dResidueRangeFree);
2019    return MemFree(ptr);
2020 }
2021 
2022 
2023 /**************************************************
2024 *
2025 *    Cn3dMoleculeLocationAsnRead()
2026 *
2027 **************************************************/
2028 NLM_EXTERN
2029 Cn3dMoleculeLocationPtr LIBCALL
Cn3dMoleculeLocationAsnRead(AsnIoPtr aip,AsnTypePtr orig)2030 Cn3dMoleculeLocationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2031 {
2032    DataVal av;
2033    AsnTypePtr atp;
2034    Boolean isError = FALSE;
2035    AsnReadFunc func;
2036    Cn3dMoleculeLocationPtr ptr;
2037 
2038    if (! loaded)
2039    {
2040       if (! objcn3dAsnLoad()) {
2041          return NULL;
2042       }
2043    }
2044 
2045    if (aip == NULL) {
2046       return NULL;
2047    }
2048 
2049    if (orig == NULL) {         /* Cn3dMoleculeLocation ::= (self contained) */
2050       atp = AsnReadId(aip, amp, CN3D_MOLECULE_LOCATION);
2051    } else {
2052       atp = AsnLinkType(orig, CN3D_MOLECULE_LOCATION);
2053    }
2054    /* link in local tree */
2055    if (atp == NULL) {
2056       return NULL;
2057    }
2058 
2059    ptr = Cn3dMoleculeLocationNew();
2060    if (ptr == NULL) {
2061       goto erret;
2062    }
2063    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2064       goto erret;
2065    }
2066 
2067    atp = AsnReadId(aip,amp, atp);
2068    func = NULL;
2069 
2070    if (atp == CN3D_MOLECULE_LOCATION_molecule_id) {
2071       if ( AsnReadVal(aip, atp, &av) <= 0) {
2072          goto erret;
2073       }
2074       ptr -> molecule_id = av.intvalue;
2075       atp = AsnReadId(aip,amp, atp);
2076    }
2077    if (atp == CN3D_MOLECULE_LOCATION_residues) {
2078       ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dResidueRangeAsnRead, (AsnOptFreeFunc) Cn3dResidueRangeFree);
2079       if (isError && ptr -> residues == NULL) {
2080          goto erret;
2081       }
2082       atp = AsnReadId(aip,amp, atp);
2083    }
2084 
2085    if (AsnReadVal(aip, atp, &av) <= 0) {
2086       goto erret;
2087    }
2088    /* end struct */
2089 
2090 ret:
2091    AsnUnlinkType(orig);       /* unlink local tree */
2092    return ptr;
2093 
2094 erret:
2095    aip -> io_failure = TRUE;
2096    ptr = Cn3dMoleculeLocationFree(ptr);
2097    goto ret;
2098 }
2099 
2100 
2101 
2102 /**************************************************
2103 *
2104 *    Cn3dMoleculeLocationAsnWrite()
2105 *
2106 **************************************************/
2107 NLM_EXTERN Boolean LIBCALL
Cn3dMoleculeLocationAsnWrite(Cn3dMoleculeLocationPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2108 Cn3dMoleculeLocationAsnWrite(Cn3dMoleculeLocationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2109 {
2110    DataVal av;
2111    AsnTypePtr atp;
2112    Boolean retval = FALSE;
2113 
2114    if (! loaded)
2115    {
2116       if (! objcn3dAsnLoad()) {
2117          return FALSE;
2118       }
2119    }
2120 
2121    if (aip == NULL) {
2122       return FALSE;
2123    }
2124 
2125    atp = AsnLinkType(orig, CN3D_MOLECULE_LOCATION);   /* link local tree */
2126    if (atp == NULL) {
2127       return FALSE;
2128    }
2129 
2130    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2131    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2132    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2133       goto erret;
2134    }
2135 
2136    av.intvalue = ptr -> molecule_id;
2137    retval = AsnWrite(aip, CN3D_MOLECULE_LOCATION_molecule_id,  &av);
2138    AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dResidueRangeAsnWrite, aip, CN3D_MOLECULE_LOCATION_residues, CN3D_MOLECULE_LOCATION_residues_E);
2139    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2140       goto erret;
2141    }
2142    retval = TRUE;
2143 
2144 erret:
2145    AsnUnlinkType(orig);       /* unlink local tree */
2146    return retval;
2147 }
2148 
2149 
2150 
2151 /**************************************************
2152 *
2153 *    Cn3dObjectLocationNew()
2154 *
2155 **************************************************/
2156 NLM_EXTERN
2157 Cn3dObjectLocationPtr LIBCALL
Cn3dObjectLocationNew(void)2158 Cn3dObjectLocationNew(void)
2159 {
2160    Cn3dObjectLocationPtr ptr = MemNew((size_t) sizeof(Cn3dObjectLocation));
2161 
2162    return ptr;
2163 
2164 }
2165 
2166 
2167 /**************************************************
2168 *
2169 *    Cn3dObjectLocationFree()
2170 *
2171 **************************************************/
2172 NLM_EXTERN
2173 Cn3dObjectLocationPtr LIBCALL
Cn3dObjectLocationFree(Cn3dObjectLocationPtr ptr)2174 Cn3dObjectLocationFree(Cn3dObjectLocationPtr ptr)
2175 {
2176 
2177    if(ptr == NULL) {
2178       return NULL;
2179    }
2180    BiostrucIdFree(ptr -> structure_id);
2181    AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dMoleculeLocationFree);
2182    return MemFree(ptr);
2183 }
2184 
2185 
2186 /**************************************************
2187 *
2188 *    Cn3dObjectLocationAsnRead()
2189 *
2190 **************************************************/
2191 NLM_EXTERN
2192 Cn3dObjectLocationPtr LIBCALL
Cn3dObjectLocationAsnRead(AsnIoPtr aip,AsnTypePtr orig)2193 Cn3dObjectLocationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2194 {
2195    DataVal av;
2196    AsnTypePtr atp;
2197    Boolean isError = FALSE;
2198    AsnReadFunc func;
2199    Cn3dObjectLocationPtr ptr;
2200 
2201    if (! loaded)
2202    {
2203       if (! objcn3dAsnLoad()) {
2204          return NULL;
2205       }
2206    }
2207 
2208    if (aip == NULL) {
2209       return NULL;
2210    }
2211 
2212    if (orig == NULL) {         /* Cn3dObjectLocation ::= (self contained) */
2213       atp = AsnReadId(aip, amp, CN3D_OBJECT_LOCATION);
2214    } else {
2215       atp = AsnLinkType(orig, CN3D_OBJECT_LOCATION);
2216    }
2217    /* link in local tree */
2218    if (atp == NULL) {
2219       return NULL;
2220    }
2221 
2222    ptr = Cn3dObjectLocationNew();
2223    if (ptr == NULL) {
2224       goto erret;
2225    }
2226    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2227       goto erret;
2228    }
2229 
2230    atp = AsnReadId(aip,amp, atp);
2231    func = NULL;
2232 
2233    if (atp == CN3D_OBJECT_LOCATION_structure_id) {
2234       ptr -> structure_id = BiostrucIdAsnRead(aip, atp);
2235       if (aip -> io_failure) {
2236          goto erret;
2237       }
2238       atp = AsnReadId(aip,amp, atp);
2239    }
2240    if (atp == CN3D_OBJECT_LOCATION_residues) {
2241       ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dMoleculeLocationAsnRead, (AsnOptFreeFunc) Cn3dMoleculeLocationFree);
2242       if (isError && ptr -> residues == NULL) {
2243          goto erret;
2244       }
2245       atp = AsnReadId(aip,amp, atp);
2246    }
2247 
2248    if (AsnReadVal(aip, atp, &av) <= 0) {
2249       goto erret;
2250    }
2251    /* end struct */
2252 
2253 ret:
2254    AsnUnlinkType(orig);       /* unlink local tree */
2255    return ptr;
2256 
2257 erret:
2258    aip -> io_failure = TRUE;
2259    ptr = Cn3dObjectLocationFree(ptr);
2260    goto ret;
2261 }
2262 
2263 
2264 
2265 /**************************************************
2266 *
2267 *    Cn3dObjectLocationAsnWrite()
2268 *
2269 **************************************************/
2270 NLM_EXTERN Boolean LIBCALL
Cn3dObjectLocationAsnWrite(Cn3dObjectLocationPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2271 Cn3dObjectLocationAsnWrite(Cn3dObjectLocationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2272 {
2273    AsnTypePtr atp;
2274    Boolean retval = FALSE;
2275 
2276    if (! loaded)
2277    {
2278       if (! objcn3dAsnLoad()) {
2279          return FALSE;
2280       }
2281    }
2282 
2283    if (aip == NULL) {
2284       return FALSE;
2285    }
2286 
2287    atp = AsnLinkType(orig, CN3D_OBJECT_LOCATION);   /* link local tree */
2288    if (atp == NULL) {
2289       return FALSE;
2290    }
2291 
2292    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2293    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2294       goto erret;
2295    }
2296 
2297    if (ptr -> structure_id != NULL) {
2298       if ( ! BiostrucIdAsnWrite(ptr -> structure_id, aip, CN3D_OBJECT_LOCATION_structure_id)) {
2299          goto erret;
2300       }
2301    }
2302    AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dMoleculeLocationAsnWrite, aip, CN3D_OBJECT_LOCATION_residues, CN3D_OBJECT_LOCATION_residues_E);
2303    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2304       goto erret;
2305    }
2306    retval = TRUE;
2307 
2308 erret:
2309    AsnUnlinkType(orig);       /* unlink local tree */
2310    return retval;
2311 }
2312 
2313 
2314 
2315 /**************************************************
2316 *
2317 *    Cn3dUserAnnotationNew()
2318 *
2319 **************************************************/
2320 NLM_EXTERN
2321 Cn3dUserAnnotationPtr LIBCALL
Cn3dUserAnnotationNew(void)2322 Cn3dUserAnnotationNew(void)
2323 {
2324    Cn3dUserAnnotationPtr ptr = MemNew((size_t) sizeof(Cn3dUserAnnotation));
2325 
2326    return ptr;
2327 
2328 }
2329 
2330 
2331 /**************************************************
2332 *
2333 *    Cn3dUserAnnotationFree()
2334 *
2335 **************************************************/
2336 NLM_EXTERN
2337 Cn3dUserAnnotationPtr LIBCALL
Cn3dUserAnnotationFree(Cn3dUserAnnotationPtr ptr)2338 Cn3dUserAnnotationFree(Cn3dUserAnnotationPtr ptr)
2339 {
2340 
2341    if(ptr == NULL) {
2342       return NULL;
2343    }
2344    MemFree(ptr -> name);
2345    MemFree(ptr -> description);
2346    AsnGenericUserSeqOfFree(ptr -> residues, (AsnOptFreeFunc) Cn3dObjectLocationFree);
2347    return MemFree(ptr);
2348 }
2349 
2350 
2351 /**************************************************
2352 *
2353 *    Cn3dUserAnnotationAsnRead()
2354 *
2355 **************************************************/
2356 NLM_EXTERN
2357 Cn3dUserAnnotationPtr LIBCALL
Cn3dUserAnnotationAsnRead(AsnIoPtr aip,AsnTypePtr orig)2358 Cn3dUserAnnotationAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2359 {
2360    DataVal av;
2361    AsnTypePtr atp;
2362    Boolean isError = FALSE;
2363    AsnReadFunc func;
2364    Cn3dUserAnnotationPtr ptr;
2365 
2366    if (! loaded)
2367    {
2368       if (! objcn3dAsnLoad()) {
2369          return NULL;
2370       }
2371    }
2372 
2373    if (aip == NULL) {
2374       return NULL;
2375    }
2376 
2377    if (orig == NULL) {         /* Cn3dUserAnnotation ::= (self contained) */
2378       atp = AsnReadId(aip, amp, CN3D_USER_ANNOTATION);
2379    } else {
2380       atp = AsnLinkType(orig, CN3D_USER_ANNOTATION);
2381    }
2382    /* link in local tree */
2383    if (atp == NULL) {
2384       return NULL;
2385    }
2386 
2387    ptr = Cn3dUserAnnotationNew();
2388    if (ptr == NULL) {
2389       goto erret;
2390    }
2391    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2392       goto erret;
2393    }
2394 
2395    atp = AsnReadId(aip,amp, atp);
2396    func = NULL;
2397 
2398    if (atp == CN3D_USER_ANNOTATION_name) {
2399       if ( AsnReadVal(aip, atp, &av) <= 0) {
2400          goto erret;
2401       }
2402       ptr -> name = av.ptrvalue;
2403       atp = AsnReadId(aip,amp, atp);
2404    }
2405    if (atp == CN3D_USER_ANNOTATION_description) {
2406       if ( AsnReadVal(aip, atp, &av) <= 0) {
2407          goto erret;
2408       }
2409       ptr -> description = av.ptrvalue;
2410       atp = AsnReadId(aip,amp, atp);
2411    }
2412    if (atp == CN3D_USER_ANNOTATION_style_id) {
2413       if ( AsnReadVal(aip, atp, &av) <= 0) {
2414          goto erret;
2415       }
2416       ptr -> style_id = av.intvalue;
2417       atp = AsnReadId(aip,amp, atp);
2418    }
2419    if (atp == CN3D_USER_ANNOTATION_residues) {
2420       ptr -> residues = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) Cn3dObjectLocationAsnRead, (AsnOptFreeFunc) Cn3dObjectLocationFree);
2421       if (isError && ptr -> residues == NULL) {
2422          goto erret;
2423       }
2424       atp = AsnReadId(aip,amp, atp);
2425    }
2426    if (atp == CN3D_USER_ANNOTATION_is_on) {
2427       if ( AsnReadVal(aip, atp, &av) <= 0) {
2428          goto erret;
2429       }
2430       ptr -> is_on = av.boolvalue;
2431       atp = AsnReadId(aip,amp, atp);
2432    }
2433 
2434    if (AsnReadVal(aip, atp, &av) <= 0) {
2435       goto erret;
2436    }
2437    /* end struct */
2438 
2439 ret:
2440    AsnUnlinkType(orig);       /* unlink local tree */
2441    return ptr;
2442 
2443 erret:
2444    aip -> io_failure = TRUE;
2445    ptr = Cn3dUserAnnotationFree(ptr);
2446    goto ret;
2447 }
2448 
2449 
2450 
2451 /**************************************************
2452 *
2453 *    Cn3dUserAnnotationAsnWrite()
2454 *
2455 **************************************************/
2456 NLM_EXTERN Boolean LIBCALL
Cn3dUserAnnotationAsnWrite(Cn3dUserAnnotationPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2457 Cn3dUserAnnotationAsnWrite(Cn3dUserAnnotationPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2458 {
2459    DataVal av;
2460    AsnTypePtr atp;
2461    Boolean retval = FALSE;
2462 
2463    if (! loaded)
2464    {
2465       if (! objcn3dAsnLoad()) {
2466          return FALSE;
2467       }
2468    }
2469 
2470    if (aip == NULL) {
2471       return FALSE;
2472    }
2473 
2474    atp = AsnLinkType(orig, CN3D_USER_ANNOTATION);   /* link local tree */
2475    if (atp == NULL) {
2476       return FALSE;
2477    }
2478 
2479    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2480    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2481    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2482       goto erret;
2483    }
2484 
2485    if (ptr -> name != NULL) {
2486       av.ptrvalue = ptr -> name;
2487       retval = AsnWrite(aip, CN3D_USER_ANNOTATION_name,  &av);
2488    }
2489    if (ptr -> description != NULL) {
2490       av.ptrvalue = ptr -> description;
2491       retval = AsnWrite(aip, CN3D_USER_ANNOTATION_description,  &av);
2492    }
2493    av.intvalue = ptr -> style_id;
2494    retval = AsnWrite(aip, CN3D_USER_ANNOTATION_style_id,  &av);
2495    AsnGenericUserSeqOfAsnWrite(ptr -> residues, (AsnWriteFunc) Cn3dObjectLocationAsnWrite, aip, CN3D_USER_ANNOTATION_residues, CN3D_USER_ANNOTATION_residues_E);
2496    av.boolvalue = ptr -> is_on;
2497    retval = AsnWrite(aip, CN3D_USER_ANNOTATION_is_on,  &av);
2498    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2499       goto erret;
2500    }
2501    retval = TRUE;
2502 
2503 erret:
2504    AsnUnlinkType(orig);       /* unlink local tree */
2505    return retval;
2506 }
2507 
2508 
2509 
2510 /**************************************************
2511 *
2512 *    Cn3dGLMatrixNew()
2513 *
2514 **************************************************/
2515 NLM_EXTERN
2516 Cn3dGLMatrixPtr LIBCALL
Cn3dGLMatrixNew(void)2517 Cn3dGLMatrixNew(void)
2518 {
2519    Cn3dGLMatrixPtr ptr = MemNew((size_t) sizeof(Cn3dGLMatrix));
2520 
2521    return ptr;
2522 
2523 }
2524 
2525 
2526 /**************************************************
2527 *
2528 *    Cn3dGLMatrixFree()
2529 *
2530 **************************************************/
2531 NLM_EXTERN
2532 Cn3dGLMatrixPtr LIBCALL
Cn3dGLMatrixFree(Cn3dGLMatrixPtr ptr)2533 Cn3dGLMatrixFree(Cn3dGLMatrixPtr ptr)
2534 {
2535 
2536    if(ptr == NULL) {
2537       return NULL;
2538    }
2539    return MemFree(ptr);
2540 }
2541 
2542 
2543 /**************************************************
2544 *
2545 *    Cn3dGLMatrixAsnRead()
2546 *
2547 **************************************************/
2548 NLM_EXTERN
2549 Cn3dGLMatrixPtr LIBCALL
Cn3dGLMatrixAsnRead(AsnIoPtr aip,AsnTypePtr orig)2550 Cn3dGLMatrixAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2551 {
2552    DataVal av;
2553    AsnTypePtr atp;
2554    Boolean isError = FALSE;
2555    AsnReadFunc func;
2556    Cn3dGLMatrixPtr ptr;
2557 
2558    if (! loaded)
2559    {
2560       if (! objcn3dAsnLoad()) {
2561          return NULL;
2562       }
2563    }
2564 
2565    if (aip == NULL) {
2566       return NULL;
2567    }
2568 
2569    if (orig == NULL) {         /* Cn3dGLMatrix ::= (self contained) */
2570       atp = AsnReadId(aip, amp, CN3D_GL_MATRIX);
2571    } else {
2572       atp = AsnLinkType(orig, CN3D_GL_MATRIX);
2573    }
2574    /* link in local tree */
2575    if (atp == NULL) {
2576       return NULL;
2577    }
2578 
2579    ptr = Cn3dGLMatrixNew();
2580    if (ptr == NULL) {
2581       goto erret;
2582    }
2583    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2584       goto erret;
2585    }
2586 
2587    atp = AsnReadId(aip,amp, atp);
2588    func = NULL;
2589 
2590    if (atp == CN3D_GL_MATRIX_m0) {
2591       if ( AsnReadVal(aip, atp, &av) <= 0) {
2592          goto erret;
2593       }
2594       ptr -> m0 = av.realvalue;
2595       atp = AsnReadId(aip,amp, atp);
2596    }
2597    if (atp == CN3D_GL_MATRIX_m1) {
2598       if ( AsnReadVal(aip, atp, &av) <= 0) {
2599          goto erret;
2600       }
2601       ptr -> m1 = av.realvalue;
2602       atp = AsnReadId(aip,amp, atp);
2603    }
2604    if (atp == CN3D_GL_MATRIX_m2) {
2605       if ( AsnReadVal(aip, atp, &av) <= 0) {
2606          goto erret;
2607       }
2608       ptr -> m2 = av.realvalue;
2609       atp = AsnReadId(aip,amp, atp);
2610    }
2611    if (atp == CN3D_GL_MATRIX_m3) {
2612       if ( AsnReadVal(aip, atp, &av) <= 0) {
2613          goto erret;
2614       }
2615       ptr -> m3 = av.realvalue;
2616       atp = AsnReadId(aip,amp, atp);
2617    }
2618    if (atp == CN3D_GL_MATRIX_m4) {
2619       if ( AsnReadVal(aip, atp, &av) <= 0) {
2620          goto erret;
2621       }
2622       ptr -> m4 = av.realvalue;
2623       atp = AsnReadId(aip,amp, atp);
2624    }
2625    if (atp == CN3D_GL_MATRIX_m5) {
2626       if ( AsnReadVal(aip, atp, &av) <= 0) {
2627          goto erret;
2628       }
2629       ptr -> m5 = av.realvalue;
2630       atp = AsnReadId(aip,amp, atp);
2631    }
2632    if (atp == CN3D_GL_MATRIX_m6) {
2633       if ( AsnReadVal(aip, atp, &av) <= 0) {
2634          goto erret;
2635       }
2636       ptr -> m6 = av.realvalue;
2637       atp = AsnReadId(aip,amp, atp);
2638    }
2639    if (atp == CN3D_GL_MATRIX_m7) {
2640       if ( AsnReadVal(aip, atp, &av) <= 0) {
2641          goto erret;
2642       }
2643       ptr -> m7 = av.realvalue;
2644       atp = AsnReadId(aip,amp, atp);
2645    }
2646    if (atp == CN3D_GL_MATRIX_m8) {
2647       if ( AsnReadVal(aip, atp, &av) <= 0) {
2648          goto erret;
2649       }
2650       ptr -> m8 = av.realvalue;
2651       atp = AsnReadId(aip,amp, atp);
2652    }
2653    if (atp == CN3D_GL_MATRIX_m9) {
2654       if ( AsnReadVal(aip, atp, &av) <= 0) {
2655          goto erret;
2656       }
2657       ptr -> m9 = av.realvalue;
2658       atp = AsnReadId(aip,amp, atp);
2659    }
2660    if (atp == CN3D_GL_MATRIX_m10) {
2661       if ( AsnReadVal(aip, atp, &av) <= 0) {
2662          goto erret;
2663       }
2664       ptr -> m10 = av.realvalue;
2665       atp = AsnReadId(aip,amp, atp);
2666    }
2667    if (atp == CN3D_GL_MATRIX_m11) {
2668       if ( AsnReadVal(aip, atp, &av) <= 0) {
2669          goto erret;
2670       }
2671       ptr -> m11 = av.realvalue;
2672       atp = AsnReadId(aip,amp, atp);
2673    }
2674    if (atp == CN3D_GL_MATRIX_m12) {
2675       if ( AsnReadVal(aip, atp, &av) <= 0) {
2676          goto erret;
2677       }
2678       ptr -> m12 = av.realvalue;
2679       atp = AsnReadId(aip,amp, atp);
2680    }
2681    if (atp == CN3D_GL_MATRIX_m13) {
2682       if ( AsnReadVal(aip, atp, &av) <= 0) {
2683          goto erret;
2684       }
2685       ptr -> m13 = av.realvalue;
2686       atp = AsnReadId(aip,amp, atp);
2687    }
2688    if (atp == CN3D_GL_MATRIX_m14) {
2689       if ( AsnReadVal(aip, atp, &av) <= 0) {
2690          goto erret;
2691       }
2692       ptr -> m14 = av.realvalue;
2693       atp = AsnReadId(aip,amp, atp);
2694    }
2695    if (atp == CN3D_GL_MATRIX_m15) {
2696       if ( AsnReadVal(aip, atp, &av) <= 0) {
2697          goto erret;
2698       }
2699       ptr -> m15 = av.realvalue;
2700       atp = AsnReadId(aip,amp, atp);
2701    }
2702 
2703    if (AsnReadVal(aip, atp, &av) <= 0) {
2704       goto erret;
2705    }
2706    /* end struct */
2707 
2708 ret:
2709    AsnUnlinkType(orig);       /* unlink local tree */
2710    return ptr;
2711 
2712 erret:
2713    aip -> io_failure = TRUE;
2714    ptr = Cn3dGLMatrixFree(ptr);
2715    goto ret;
2716 }
2717 
2718 
2719 
2720 /**************************************************
2721 *
2722 *    Cn3dGLMatrixAsnWrite()
2723 *
2724 **************************************************/
2725 NLM_EXTERN Boolean LIBCALL
Cn3dGLMatrixAsnWrite(Cn3dGLMatrixPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2726 Cn3dGLMatrixAsnWrite(Cn3dGLMatrixPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2727 {
2728    DataVal av;
2729    AsnTypePtr atp;
2730    Boolean retval = FALSE;
2731 
2732    if (! loaded)
2733    {
2734       if (! objcn3dAsnLoad()) {
2735          return FALSE;
2736       }
2737    }
2738 
2739    if (aip == NULL) {
2740       return FALSE;
2741    }
2742 
2743    atp = AsnLinkType(orig, CN3D_GL_MATRIX);   /* link local tree */
2744    if (atp == NULL) {
2745       return FALSE;
2746    }
2747 
2748    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2749    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2750    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2751       goto erret;
2752    }
2753 
2754    av.realvalue = ptr -> m0;
2755    retval = AsnWrite(aip, CN3D_GL_MATRIX_m0,  &av);
2756    av.realvalue = ptr -> m1;
2757    retval = AsnWrite(aip, CN3D_GL_MATRIX_m1,  &av);
2758    av.realvalue = ptr -> m2;
2759    retval = AsnWrite(aip, CN3D_GL_MATRIX_m2,  &av);
2760    av.realvalue = ptr -> m3;
2761    retval = AsnWrite(aip, CN3D_GL_MATRIX_m3,  &av);
2762    av.realvalue = ptr -> m4;
2763    retval = AsnWrite(aip, CN3D_GL_MATRIX_m4,  &av);
2764    av.realvalue = ptr -> m5;
2765    retval = AsnWrite(aip, CN3D_GL_MATRIX_m5,  &av);
2766    av.realvalue = ptr -> m6;
2767    retval = AsnWrite(aip, CN3D_GL_MATRIX_m6,  &av);
2768    av.realvalue = ptr -> m7;
2769    retval = AsnWrite(aip, CN3D_GL_MATRIX_m7,  &av);
2770    av.realvalue = ptr -> m8;
2771    retval = AsnWrite(aip, CN3D_GL_MATRIX_m8,  &av);
2772    av.realvalue = ptr -> m9;
2773    retval = AsnWrite(aip, CN3D_GL_MATRIX_m9,  &av);
2774    av.realvalue = ptr -> m10;
2775    retval = AsnWrite(aip, CN3D_GL_MATRIX_m10,  &av);
2776    av.realvalue = ptr -> m11;
2777    retval = AsnWrite(aip, CN3D_GL_MATRIX_m11,  &av);
2778    av.realvalue = ptr -> m12;
2779    retval = AsnWrite(aip, CN3D_GL_MATRIX_m12,  &av);
2780    av.realvalue = ptr -> m13;
2781    retval = AsnWrite(aip, CN3D_GL_MATRIX_m13,  &av);
2782    av.realvalue = ptr -> m14;
2783    retval = AsnWrite(aip, CN3D_GL_MATRIX_m14,  &av);
2784    av.realvalue = ptr -> m15;
2785    retval = AsnWrite(aip, CN3D_GL_MATRIX_m15,  &av);
2786    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2787       goto erret;
2788    }
2789    retval = TRUE;
2790 
2791 erret:
2792    AsnUnlinkType(orig);       /* unlink local tree */
2793    return retval;
2794 }
2795 
2796 
2797 
2798 /**************************************************
2799 *
2800 *    Cn3dVectorNew()
2801 *
2802 **************************************************/
2803 NLM_EXTERN
2804 Cn3dVectorPtr LIBCALL
Cn3dVectorNew(void)2805 Cn3dVectorNew(void)
2806 {
2807    Cn3dVectorPtr ptr = MemNew((size_t) sizeof(Cn3dVector));
2808 
2809    return ptr;
2810 
2811 }
2812 
2813 
2814 /**************************************************
2815 *
2816 *    Cn3dVectorFree()
2817 *
2818 **************************************************/
2819 NLM_EXTERN
2820 Cn3dVectorPtr LIBCALL
Cn3dVectorFree(Cn3dVectorPtr ptr)2821 Cn3dVectorFree(Cn3dVectorPtr ptr)
2822 {
2823 
2824    if(ptr == NULL) {
2825       return NULL;
2826    }
2827    return MemFree(ptr);
2828 }
2829 
2830 
2831 /**************************************************
2832 *
2833 *    Cn3dVectorAsnRead()
2834 *
2835 **************************************************/
2836 NLM_EXTERN
2837 Cn3dVectorPtr LIBCALL
Cn3dVectorAsnRead(AsnIoPtr aip,AsnTypePtr orig)2838 Cn3dVectorAsnRead(AsnIoPtr aip, AsnTypePtr orig)
2839 {
2840    DataVal av;
2841    AsnTypePtr atp;
2842    Boolean isError = FALSE;
2843    AsnReadFunc func;
2844    Cn3dVectorPtr ptr;
2845 
2846    if (! loaded)
2847    {
2848       if (! objcn3dAsnLoad()) {
2849          return NULL;
2850       }
2851    }
2852 
2853    if (aip == NULL) {
2854       return NULL;
2855    }
2856 
2857    if (orig == NULL) {         /* Cn3dVector ::= (self contained) */
2858       atp = AsnReadId(aip, amp, CN3D_VECTOR);
2859    } else {
2860       atp = AsnLinkType(orig, CN3D_VECTOR);
2861    }
2862    /* link in local tree */
2863    if (atp == NULL) {
2864       return NULL;
2865    }
2866 
2867    ptr = Cn3dVectorNew();
2868    if (ptr == NULL) {
2869       goto erret;
2870    }
2871    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
2872       goto erret;
2873    }
2874 
2875    atp = AsnReadId(aip,amp, atp);
2876    func = NULL;
2877 
2878    if (atp == CN3D_VECTOR_x) {
2879       if ( AsnReadVal(aip, atp, &av) <= 0) {
2880          goto erret;
2881       }
2882       ptr -> x = av.realvalue;
2883       atp = AsnReadId(aip,amp, atp);
2884    }
2885    if (atp == CN3D_VECTOR_y) {
2886       if ( AsnReadVal(aip, atp, &av) <= 0) {
2887          goto erret;
2888       }
2889       ptr -> y = av.realvalue;
2890       atp = AsnReadId(aip,amp, atp);
2891    }
2892    if (atp == CN3D_VECTOR_z) {
2893       if ( AsnReadVal(aip, atp, &av) <= 0) {
2894          goto erret;
2895       }
2896       ptr -> z = av.realvalue;
2897       atp = AsnReadId(aip,amp, atp);
2898    }
2899 
2900    if (AsnReadVal(aip, atp, &av) <= 0) {
2901       goto erret;
2902    }
2903    /* end struct */
2904 
2905 ret:
2906    AsnUnlinkType(orig);       /* unlink local tree */
2907    return ptr;
2908 
2909 erret:
2910    aip -> io_failure = TRUE;
2911    ptr = Cn3dVectorFree(ptr);
2912    goto ret;
2913 }
2914 
2915 
2916 
2917 /**************************************************
2918 *
2919 *    Cn3dVectorAsnWrite()
2920 *
2921 **************************************************/
2922 NLM_EXTERN Boolean LIBCALL
Cn3dVectorAsnWrite(Cn3dVectorPtr ptr,AsnIoPtr aip,AsnTypePtr orig)2923 Cn3dVectorAsnWrite(Cn3dVectorPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
2924 {
2925    DataVal av;
2926    AsnTypePtr atp;
2927    Boolean retval = FALSE;
2928 
2929    if (! loaded)
2930    {
2931       if (! objcn3dAsnLoad()) {
2932          return FALSE;
2933       }
2934    }
2935 
2936    if (aip == NULL) {
2937       return FALSE;
2938    }
2939 
2940    atp = AsnLinkType(orig, CN3D_VECTOR);   /* link local tree */
2941    if (atp == NULL) {
2942       return FALSE;
2943    }
2944 
2945    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2946    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
2947    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
2948       goto erret;
2949    }
2950 
2951    av.realvalue = ptr -> x;
2952    retval = AsnWrite(aip, CN3D_VECTOR_x,  &av);
2953    av.realvalue = ptr -> y;
2954    retval = AsnWrite(aip, CN3D_VECTOR_y,  &av);
2955    av.realvalue = ptr -> z;
2956    retval = AsnWrite(aip, CN3D_VECTOR_z,  &av);
2957    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
2958       goto erret;
2959    }
2960    retval = TRUE;
2961 
2962 erret:
2963    AsnUnlinkType(orig);       /* unlink local tree */
2964    return retval;
2965 }
2966 
2967 
2968 
2969 /**************************************************
2970 *
2971 *    Cn3dViewSettingsNew()
2972 *
2973 **************************************************/
2974 NLM_EXTERN
2975 Cn3dViewSettingsPtr LIBCALL
Cn3dViewSettingsNew(void)2976 Cn3dViewSettingsNew(void)
2977 {
2978    Cn3dViewSettingsPtr ptr = MemNew((size_t) sizeof(Cn3dViewSettings));
2979 
2980    return ptr;
2981 
2982 }
2983 
2984 
2985 /**************************************************
2986 *
2987 *    Cn3dViewSettingsFree()
2988 *
2989 **************************************************/
2990 NLM_EXTERN
2991 Cn3dViewSettingsPtr LIBCALL
Cn3dViewSettingsFree(Cn3dViewSettingsPtr ptr)2992 Cn3dViewSettingsFree(Cn3dViewSettingsPtr ptr)
2993 {
2994 
2995    if(ptr == NULL) {
2996       return NULL;
2997    }
2998    Cn3dGLMatrixFree(ptr -> matrix);
2999    Cn3dVectorFree(ptr -> rotation_center);
3000    return MemFree(ptr);
3001 }
3002 
3003 
3004 /**************************************************
3005 *
3006 *    Cn3dViewSettingsAsnRead()
3007 *
3008 **************************************************/
3009 NLM_EXTERN
3010 Cn3dViewSettingsPtr LIBCALL
Cn3dViewSettingsAsnRead(AsnIoPtr aip,AsnTypePtr orig)3011 Cn3dViewSettingsAsnRead(AsnIoPtr aip, AsnTypePtr orig)
3012 {
3013    DataVal av;
3014    AsnTypePtr atp;
3015    Boolean isError = FALSE;
3016    AsnReadFunc func;
3017    Cn3dViewSettingsPtr ptr;
3018 
3019    if (! loaded)
3020    {
3021       if (! objcn3dAsnLoad()) {
3022          return NULL;
3023       }
3024    }
3025 
3026    if (aip == NULL) {
3027       return NULL;
3028    }
3029 
3030    if (orig == NULL) {         /* Cn3dViewSettings ::= (self contained) */
3031       atp = AsnReadId(aip, amp, CN3D_VIEW_SETTINGS);
3032    } else {
3033       atp = AsnLinkType(orig, CN3D_VIEW_SETTINGS);
3034    }
3035    /* link in local tree */
3036    if (atp == NULL) {
3037       return NULL;
3038    }
3039 
3040    ptr = Cn3dViewSettingsNew();
3041    if (ptr == NULL) {
3042       goto erret;
3043    }
3044    if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
3045       goto erret;
3046    }
3047 
3048    atp = AsnReadId(aip,amp, atp);
3049    func = NULL;
3050 
3051    if (atp == CN3D_VIEW_SETTINGS_camera_distance) {
3052       if ( AsnReadVal(aip, atp, &av) <= 0) {
3053          goto erret;
3054       }
3055       ptr -> camera_distance = av.realvalue;
3056       atp = AsnReadId(aip,amp, atp);
3057    }
3058    if (atp == CN3D_VIEW_SETTINGS_camera_angle_rad) {
3059       if ( AsnReadVal(aip, atp, &av) <= 0) {
3060          goto erret;
3061       }
3062       ptr -> camera_angle_rad = av.realvalue;
3063       atp = AsnReadId(aip,amp, atp);
3064    }
3065    if (atp == CN3D_VIEW_SETTINGS_camera_look_at_X) {
3066       if ( AsnReadVal(aip, atp, &av) <= 0) {
3067          goto erret;
3068       }
3069       ptr -> camera_look_at_X = av.realvalue;
3070       atp = AsnReadId(aip,amp, atp);
3071    }
3072    if (atp == CN3D_VIEW_SETTINGS_camera_look_at_Y) {
3073       if ( AsnReadVal(aip, atp, &av) <= 0) {
3074          goto erret;
3075       }
3076       ptr -> camera_look_at_Y = av.realvalue;
3077       atp = AsnReadId(aip,amp, atp);
3078    }
3079    if (atp == CN3D_VIEW_SETTINGS_camera_clip_near) {
3080       if ( AsnReadVal(aip, atp, &av) <= 0) {
3081          goto erret;
3082       }
3083       ptr -> camera_clip_near = av.realvalue;
3084       atp = AsnReadId(aip,amp, atp);
3085    }
3086    if (atp == CN3D_VIEW_SETTINGS_camera_clip_far) {
3087       if ( AsnReadVal(aip, atp, &av) <= 0) {
3088          goto erret;
3089       }
3090       ptr -> camera_clip_far = av.realvalue;
3091       atp = AsnReadId(aip,amp, atp);
3092    }
3093    if (atp == CN3D_VIEW_SETTINGS_matrix) {
3094       ptr -> matrix = Cn3dGLMatrixAsnRead(aip, atp);
3095       if (aip -> io_failure) {
3096          goto erret;
3097       }
3098       atp = AsnReadId(aip,amp, atp);
3099    }
3100    if (atp == CN3D_VIEW_SETTINGS_rotation_center) {
3101       ptr -> rotation_center = Cn3dVectorAsnRead(aip, atp);
3102       if (aip -> io_failure) {
3103          goto erret;
3104       }
3105       atp = AsnReadId(aip,amp, atp);
3106    }
3107 
3108    if (AsnReadVal(aip, atp, &av) <= 0) {
3109       goto erret;
3110    }
3111    /* end struct */
3112 
3113 ret:
3114    AsnUnlinkType(orig);       /* unlink local tree */
3115    return ptr;
3116 
3117 erret:
3118    aip -> io_failure = TRUE;
3119    ptr = Cn3dViewSettingsFree(ptr);
3120    goto ret;
3121 }
3122 
3123 
3124 
3125 /**************************************************
3126 *
3127 *    Cn3dViewSettingsAsnWrite()
3128 *
3129 **************************************************/
3130 NLM_EXTERN Boolean LIBCALL
Cn3dViewSettingsAsnWrite(Cn3dViewSettingsPtr ptr,AsnIoPtr aip,AsnTypePtr orig)3131 Cn3dViewSettingsAsnWrite(Cn3dViewSettingsPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
3132 {
3133    DataVal av;
3134    AsnTypePtr atp;
3135    Boolean retval = FALSE;
3136 
3137    if (! loaded)
3138    {
3139       if (! objcn3dAsnLoad()) {
3140          return FALSE;
3141       }
3142    }
3143 
3144    if (aip == NULL) {
3145       return FALSE;
3146    }
3147 
3148    atp = AsnLinkType(orig, CN3D_VIEW_SETTINGS);   /* link local tree */
3149    if (atp == NULL) {
3150       return FALSE;
3151    }
3152 
3153    if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3154    MemSet ((Pointer) (&av), 0, sizeof (DataVal));
3155    if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
3156       goto erret;
3157    }
3158 
3159    av.realvalue = ptr -> camera_distance;
3160    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_distance,  &av);
3161    av.realvalue = ptr -> camera_angle_rad;
3162    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_angle_rad,  &av);
3163    av.realvalue = ptr -> camera_look_at_X;
3164    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_look_at_X,  &av);
3165    av.realvalue = ptr -> camera_look_at_Y;
3166    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_look_at_Y,  &av);
3167    av.realvalue = ptr -> camera_clip_near;
3168    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_clip_near,  &av);
3169    av.realvalue = ptr -> camera_clip_far;
3170    retval = AsnWrite(aip, CN3D_VIEW_SETTINGS_camera_clip_far,  &av);
3171    if (ptr -> matrix != NULL) {
3172       if ( ! Cn3dGLMatrixAsnWrite(ptr -> matrix, aip, CN3D_VIEW_SETTINGS_matrix)) {
3173          goto erret;
3174       }
3175    }
3176    if (ptr -> rotation_center != NULL) {
3177       if ( ! Cn3dVectorAsnWrite(ptr -> rotation_center, aip, CN3D_VIEW_SETTINGS_rotation_center)) {
3178          goto erret;
3179       }
3180    }
3181    if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
3182       goto erret;
3183    }
3184    retval = TRUE;
3185 
3186 erret:
3187    AsnUnlinkType(orig);       /* unlink local tree */
3188    return retval;
3189 }
3190 
3191