|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/cn3d/cn3dmesh.c |
source navigation diff markup identifier search freetext search file search |
1 /* cn3dmesh.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: cn3dmesh.c
27 *
28 * Author: Lewis Geer
29 *
30 * First Version Creation Date: 1/31/96
31 *
32 * $Revision: 6.3 $
33 *
34 * File Description:
35 *
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * Date Name Description of modification
40 * ------- ---------- -----------------------------------------------------
41 *
42 *
43 * ==========================================================================
44 */
45
46 #include <vibrant.h>
47 #include <math.h>
48 #include <mmdbapi.h>
49 #include <cn3dmain.h>
50 #include <cn3dmesh.h>
51
52
53
54 static TexT Cn3D_tMesh;
55 static ButtoN Cn3D_bMeshAccept;
56
57 static WindoW Cn3D_wMesh;
58 static ButtoN Cn3D_bMeshBrowse;
59
60
61 static void Cn3D_MeshEnableProc(TexT t)
62 {
63 Char str[32];
64 GetTitle(Cn3D_tMesh, str, sizeof(str));
65 if (StringLen(str) == 0) {
66 Disable(Cn3D_bMeshAccept);
67 } else {
68 Enable(Cn3D_bMeshAccept);
69 }
70 return;
71 }
72
73
74
75 static void Cn3D_MeshBrowseProc(GraphiC g)
76 {
77 Char path[PATH_MAX];
78
79 path[0] = '\0';
80
81 if (GetInputFileName(path, sizeof(path), NULL, NULL)) {
82 SetTitle(Cn3D_tMesh, path);
83 Cn3D_MeshEnableProc(NULL);
84 }
85
86 return;
87 }
88
89
90 static void Cn3D_MeshCancelProc(ButtoN b)
91 {
92 Remove(Cn3D_wMesh);
93 return;
94 }
95
96
97 Cn3D_Mesh Mesh;
98 Boolean MeshLoaded = FALSE;
99
100 static void Cn3D_MeshAcceptProc(ButtoN b)
101 {
102 Char str[PATH_MAX];
103 PMSD pmsdThis = NULL;
104 FILE *hFile;
105 FloatLo fDummy;
106 Int4 lDummy, i;
107
108
109 GetTitle(Cn3D_tMesh, str, sizeof(str));
110 hFile = FileOpen(str, "r");
111 fscanf(hFile, "%d %d %d", &(Mesh.NumVert), &(Mesh.NumEdge),
112 &(Mesh.NumTri));
113
114 Mesh.Vertices = MemNew(sizeof(Cn3D_Vert) * Mesh.NumVert);
115 Mesh.Edges = MemNew(sizeof(Cn3D_Edge) * Mesh.NumEdge);
116 Mesh.Tri = MemNew(sizeof(Cn3D_Tri) * Mesh.NumTri);
117
118 for (i = 0; i < Mesh.NumVert; i++)
119 fscanf(hFile, "%lf %lf %lf %lf %lf %lf %f %f %f %d %d %d",
120 &(Mesh.Vertices[i].Vertex[0]),
121 &(Mesh.Vertices[i].Vertex[1]),
122 &(Mesh.Vertices[i].Vertex[2]),
123 &(Mesh.Vertices[i].Normal[0]),
124 &(Mesh.Vertices[i].Normal[1]),
125 &(Mesh.Vertices[i].Normal[2]), &fDummy, &fDummy, &fDummy,
126 &lDummy, &lDummy, &lDummy);
127
128 for (i = 0; i < Mesh.NumEdge; i++)
129 fscanf(hFile, "%d %d %d %d %d", &Mesh.Edges[i].Vertex[0],
130 &Mesh.Edges[i].Vertex[1], &lDummy, &lDummy, &lDummy);
131
132 for (i = 0; i < Mesh.NumTri; i++)
133 fscanf(hFile, "%d %d %d %d %d %d %d %d %d", &Mesh.Tri[i].Edge[0],
134 &Mesh.Tri[i].Edge[1], &Mesh.Tri[i].Edge[2],
135 &Mesh.Tri[i].Vertex[0], &Mesh.Tri[i].Vertex[1],
136 &Mesh.Tri[i].Vertex[2], &lDummy, &Mesh.Tri[i].Atom,
137 &lDummy);
138
139 MeshLoaded = TRUE;
140 FileClose(hFile);
141
142
143 Remove(Cn3D_wMesh);
144
145 return;
146 }
147
148 void Cn3D_OpenMesh(IteM i)
149 {
150 GrouP g;
151 ButtoN b;
152
153
154 Cn3D_wMesh = FixedWindow(-30, -20, -10, -10, " Open a mesh: ", NULL);
155 g =
156 NormalGroup(Cn3D_wMesh, 2, 1, " Enter mesh file name:", systemFont,
157 NULL);
158 SetGroupMargins(g, 10, 10);
159 SetGroupSpacing(g, 10, 20);
160 Cn3D_tMesh = DialogText(g, "", 25, (TxtActnProc) Cn3D_MeshEnableProc);
161 Cn3D_bMeshBrowse =
162 PushButton(g, " browse...", (BtnActnProc) Cn3D_MeshBrowseProc);
163
164 g = HiddenGroup(Cn3D_wMesh, 3, 1, NULL);
165 SetGroupMargins(g, 10, 10);
166 SetGroupSpacing(g, 30, 30);
167
168
169 b = PushButton(g, "Cancel", (BtnActnProc) Cn3D_MeshCancelProc);
170 Cn3D_bMeshAccept =
171 DefaultButton(g, "OK", (BtnActnProc) Cn3D_MeshAcceptProc);
172
173 Disable(Cn3D_bMeshAccept);
174 Select(Cn3D_tMesh);
175 Show(Cn3D_wMesh);
176 return;
177 }
178 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |