-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdbs_getskullobj.m
More file actions
1651 lines (1497 loc) · 33.8 KB
/
Copy pathdbs_getskullobj.m
File metadata and controls
1651 lines (1497 loc) · 33.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function [node_xyz, face_node] = dbs_getskullobj(input_file_name)
%*****************************************************************************80
%
%% dbs_getskullobj returns the faces of a shape defined by an OBJ file.
%
% Usage:
%
% dbs_getskullobj ( 'file.obj' )
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 27 September 2008
%
% Author:
%
% John Burkardt
%
timestamp ( );
fprintf ( 1, '\n' );
fprintf ( 1, ' MATLAB version\n' );
fprintf ( 1, '\n' );
fprintf ( 1, ' Read a 3D surface stored an ASCII OBJ file.\n' );
%
% If at least one command line argument, it's the input file name.
%
if ( nargin < 1 )
fprintf ( 1, '\n' );
fprintf ( 1, 'OBJ:\n' );
input_file_name = input ( 'Enter the name of the input file:' );
end
%
% Get sizes.
%
[ node_num, face_num, normal_num, order_max ] = obj_size(input_file_name);
%
% Print the sizes.
%
obj_size_print ( input_file_name, node_num, face_num, normal_num, order_max );
%
% Get the data.
%
[ node_xyz, face_order, face_node ] = ...
obj_read ( input_file_name, node_num, face_num, normal_num, order_max );
%
% FACE_NODE may contain polygons of different orders.
% To make the call to PATCH, we will assume all the polygons are the same order.
% To do so, we'll simply "stutter" the first node in each face list.
%
for face = 1 : face_num
face_node(face_order(face)+1:order_max,face) = face_node(1,face);
end
%
% If any node index is still less than 1, set the whole face to 1's.
% We're giving up on this presumably meaningless face, but we need to
% do it in a way that keeps MATLAB happy!
%
for face = 1 : face_num
for i = 1 : order_max
face_node(i,face) = max ( face_node(i,face), 1 );
end
end
return
end
function c = ch_cap ( c )
%*****************************************************************************80
%
%% CH_CAP capitalizes a single character.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 22 November 2003
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, character C, the character to capitalize.
%
% Output, character C, the capitalized character.
%
if ( 'a' <= c && c <= 'z' )
c = c + 'A' - 'a';
end
return
end
function truefalse = ch_eqi ( c1, c2 )
%*****************************************************************************80
%
%% CH_EQI is a case insensitive comparison of two characters for equality.
%
% Example:
%
% CH_EQI ( 'A', 'a' ) is TRUE.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 28 July 2000
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, character C1, C2, the characters to compare.
%
% Output, logical TRUEFALSE, is TRUE (1) if the characters are equal.
%
FALSE = 0;
TRUE = 1;
if ( ch_cap ( c1 ) == ch_cap ( c2 ) )
truefalse = TRUE;
else
truefalse = FALSE;
end
return
end
function value = ch_index ( s, c )
%*****************************************************************************80
%
%% CH_INDEX is the first occurrence of a character in a string.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 01 May 2004
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, string S, the string to be searched.
%
% Input, character C, the character to be searched for.
%
% Output, integer VALUE, the location of the first occurrence of C
% in the string, or 0 if C does not occur.
%
value = 0;
for i = 1 : length ( s )
if ( s(i:i) == c )
value = i;
return
end
end
return
end
function value = ch_is_control ( ch )
%*****************************************************************************80
%
%% CH_IS_CONTROL is TRUE if a character is a control character.
%
% Discussion:
%
% A "control character" has ASCII code <= 31 or 127 <= ASCII code.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 27 September 2008
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, character CH, the character to be tested.
%
% Output, integer CH_IS_CONTROL, TRUE if the character is a control
% character, and FALSE otherwise.
%
if ( ch <= 31 || 127 <= ch )
value = 1;
else
value = 0;
end
return
end
function truefalse = ch_is_digit ( c )
%*****************************************************************************80
%
% CH_IS_DIGIT returns TRUE if the character C is a digit.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 11 December 2003
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, character C, a character.
%
% Output, integer TRUEFALSE, is TRUE (1) if C is a digit, FALSE (0) otherwise.
%
TRUE = 1;
FALSE = 0;
if ( '0' <= c && c <= '9' )
truefalse = TRUE;
else
truefalse = FALSE;
end
return
end
function digit = ch_to_digit ( c )
%*****************************************************************************80
%
%% CH_TO_DIGIT returns the integer value of a base 10 digit.
%
% Example:
%
% C DIGIT
% --- -----
% '0' 0
% '1' 1
% ... ...
% '9' 9
% ' ' 0
% 'X' -1
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 22 November 2003
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, character C, the decimal digit, '0' through '9' or blank
% are legal.
%
% Output, integer DIGIT, the corresponding integer value. If C was
% 'illegal', then DIGIT is -1.
%
if ( '0' <= c && c <= '9' )
digit = c - '0';
elseif ( c == ' ' )
digit = 0;
else
digit = -1;
end
return
end
function [ node_xyz, face_order, face_node, normal_vector, vertex_normal ] = ...
obj_read ( input_file_name, node_num, face_num, normal_num, order_max )
%*****************************************************************************80
%
%% OBJ_READ reads graphics information from a Wavefront OBJ file.
%
% Discussion:
%
% It is intended that the information read from the file can
% either start a whole new graphics object, or simply be added
% to a current graphics object via the '<<' command.
%
% This is controlled by whether the input values have been zeroed
% out or not. This routine simply tacks on the information it
% finds to the current graphics object.
%
% Example:
%
% # magnolia.obj
%
% v -3.269770 -39.572201 0.876128
% v -3.263720 -39.507999 2.160890
% ...
% v 0.000000 -9.988540 0.000000
% vn 1.0 0.0 0.0
% ...
% vn 0.0 1.0 0.0
%
% f 8 9 11 10
% f 12 13 15 14
% ...
% f 788 806 774
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 27 September 2008
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, string INPUT_FILE_NAME, the name of the input file.
%
% Input, integer NODE_NUM, the number of points.
%
% Input, integer FACE_NUM, the number of faces.
%
% Input, integer NORMAL_NUM, the number of normal vectors.
%
% Input, integer ORDER_MAX, the maximum number of vertices per face.
%
% Output, real NODE_XYZ(3,NODE_NUM), the coordinates of points.
%
% Output, integer FACE_ORDER(FACE_NUM), the number of vertices per face.
%
% Output, integer FACE_NODE(ORDER_MAX,FACE_NUM), the nodes making faces.
%
% Output, real NORMAL_VECTOR(3,NORMAL_NUM), normal vectors.
%
% Output, integer VERTEX_NORMAL(ORDER_MAX,FACE_NUM), the indices of normal
% vectors per vertex.
%
face = 0;
node = 0;
normal = 0;
text_num = 0;
face_node = zeros ( order_max, face_num );
face_order = zeros ( face_num, 1 );
node_xyz = zeros ( 3, node_num );
normal_vector = zeros ( 3, normal_num );
vertex_normal = zeros ( order_max, face_num );
%
% If no file input, try to get one from the user.
%
if ( nargin < 1 )
input_file_name = input ( 'Enter the name of the ASCII OBJ file.' );
if ( isempty ( input_file_name ) )
return
end
end
%
% Open the file.
%
input_file_unit = fopen ( input_file_name, 'r' );
if ( input_file_unit < 0 )
fprintf ( 1, '\n' );
fprintf ( 1, 'OBJ_READ - Fatal error!\n' );
fprintf ( 1, ' Could not open the file "%s".\n', input_file_name );
error ( 'OBJ_READ - Fatal error!' );
end
%
% Read a line of text from the file.
%
while ( 1 )
text = fgetl ( input_file_unit );
if ( text == -1 )
break
end
text_num = text_num + 1;
%
% Replace any control characters (in particular, TAB's) by blanks.
%
s_control_blank ( text );
done = 1;
word_index = 0;
%
% Read a word from the line.
%
[ word, done ] = word_next_read ( text, done );
%
% If no more words in this line, read a new line.
%
if ( done )
continue
end
%
% If this word begins with '#' or '$', then it's a comment. Read a new line.
%
if ( word(1) == '#' || word(1) == '$' )
continue
end
word_index = word_index + 1;
if ( word_index == 1 )
word_one = word;
end
%
% BEVEL
% Bevel interpolation.
%
if ( s_eqi ( word_one, 'BEVEL' ) )
%
% BMAT
% Basis matrix.
%
elseif ( s_eqi ( word_one, 'BMAT' ) )
%
% C_INTERP
% Color interpolation.
%
elseif ( s_eqi ( word_one, 'C_INTERP' ) )
%
% CON
% Connectivity between free form surfaces.
%
elseif ( s_eqi ( word_one, 'CON' ) )
%
% CSTYPE
% Curve or surface type.
%
elseif ( s_eqi ( word_one, 'CSTYPE' ) )
%
% CTECH
% Curve approximation technique.
%
elseif ( s_eqi ( word_one, 'CTECH' ) )
%
% CURV
% Curve.
%
elseif ( s_eqi ( word_one, 'CURV' ) )
%
% CURV2
% 2D curve.
%
elseif ( s_eqi ( word_one, 'CURV2' ) )
%
% D_INTERP
% Dissolve interpolation.
%
elseif ( s_eqi ( word_one, 'D_INTERP' ) )
%
% DEG
% Degree.
%
elseif ( s_eqi ( word_one, 'DEG' ) )
%
% END
% End statement.
%
elseif ( s_eqi ( word_one, 'END' ) )
%
% F V1 V2 V3 ...
% or
% F V1/VT1/VN1 V2/VT2/VN2 ...
% or
% F V1//VN1 V2//VN2 ...
%
% Face.
% A face is defined by the vertices.
% Optionally, slashes may be used to include the texture vertex
% and vertex normal indices.
%
elseif ( s_eqi ( word_one, 'F' ) )
face = face + 1;
vertex = 0;
while ( 1 )
[ word, done ] = word_next_read ( text, done );
if ( done )
break
end
vertex = vertex + 1;
order_max = max ( order_max, vertex );
%
% Locate the slash characters in the word, if any.
%
i1 = ch_index ( word, '/' );
if ( 0 < i1 )
i2 = ch_index ( word(i1+1), '/' ) + i1;
else
i2 = 0;
end
%
% Read the vertex index.
%
itemp = s_to_i4 ( word );
face_node(vertex,face) = itemp;
face_order(face) = face_order(face) + 1;
%
% If there are two slashes, then read the data following the second one.
%
if ( 0 < i2 )
itemp = s_to_i4 ( word(i2+1) );
vertex_normal(vertex,face) = itemp;
end
end
%
% G
% Group name.
%
elseif ( s_eqi ( word_one, 'G' ) )
%
% HOLE
% Inner trimming loop.
%
elseif ( s_eqi ( word_one, 'HOLE' ) )
%
% L
% A line, described by a sequence of vertex indices.
% Are the vertex indices 0 based or 1 based?
%
elseif ( s_eqi ( word_one, 'L' ) )
%
% LOD
% Level of detail.
%
elseif ( s_eqi ( word_one, 'LOD' ) )
%
% MG
% Merging group.
%
elseif ( s_eqi ( word_one, 'MG' ) )
%
% MTLLIB
% Material library.
%
elseif ( s_eqi ( word_one, 'MTLLIB' ) )
%
% O
% Object name.
%
elseif ( s_eqi ( word_one, 'O' ) )
%
% P
% Point.
%
elseif ( s_eqi ( word_one, 'P' ) )
%
% PARM
% Parameter values.
%
elseif ( s_eqi ( word_one, 'PARM' ) )
%
% S
% Smoothing group.
%
elseif ( s_eqi ( word_one, 'S' ) )
%
% SCRV
% Special curve.
%
elseif ( s_eqi ( word_one, 'SCRV' ) )
%
% SHADOW_OBJ
% Shadow casting.
%
elseif ( s_eqi ( word_one, 'SHADOW_OBJ' ) )
%
% SP
% Special point.
%
elseif ( s_eqi ( word_one, 'SP' ) )
%
% STECH
% Surface approximation technique.
%
elseif ( s_eqi ( word_one, 'STECH' ) )
%
% STEP
% Stepsize.
%
elseif ( s_eqi ( word_one, 'STEP' ) )
%
% SURF
% Surface.
%
elseif ( s_eqi ( word_one, 'SURF' ) )
%
% TRACE_OBJ
% Ray tracing.
%
elseif ( s_eqi ( word_one, 'TRACE_OBJ' ) )
%
% TRIM
% Outer trimming loop.
%
elseif ( s_eqi ( word_one, 'TRIM' ) )
%
% USEMTL
% Material name.
%
elseif ( s_eqi ( word_one, 'USEMTL' ) )
%
% V X Y Z
% Geometric vertex.
%
elseif ( s_eqi ( word_one, 'V' ) )
node = node + 1;
for i = 1 : 3
[ word, done ] = word_next_read ( text, done );
temp = s_to_r8 ( word );
node_xyz(i,node) = temp;
end
%
% VN
% Vertex normals.
%
elseif ( s_eqi ( word_one, 'VN' ) )
normal = normal + 1;
for i = 1 : 3
[ word, done ] = word_next_read ( text, done );
temp = s_to_r8 ( word );
normal_vector(i,normal) = temp;
end
%
% VT
% Vertex texture.
%
elseif ( s_eqi ( word_one, 'VT' ) )
%
% VP
% Parameter space vertices.
%
elseif ( s_eqi ( word_one, 'VP' ) )
%
% Unrecognized keyword.
%
else
end
end
fclose ( input_file_unit );
return
end
function [ node_num, face_num, normal_num, order_max ] = obj_size ( ...
input_file_name )
%*****************************************************************************80
%
%% OBJ_SIZE determines sizes of graphics objects in an Alias OBJ file.
%
% Discussion:
%
% The only items of interest to this routine are vertices,
% faces, and normal vectors.
%
% Example:
%
% # magnolia.obj
%
% v -3.269770 -39.572201 0.876128
% v -3.263720 -39.507999 2.160890
% ...
% v 0.000000 -9.988540 0.000000
%
% vn 1.0 0.0 0.0
% ...
% vn 0.0 1.0 0.0
%
% f 8 9 11 10
% f 12 13 15 14
% ...
% f 788 806 774
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 26 September 2008
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, string INPUT_FILE_NAME, the input file name.
%
% Output, integer NODE_NUM, the number of points.
%
% Output, integer FACE_NUM, the number of faces.
%
% Output, integer NORMAL_NUM, the number of normal vectors.
%
% Output, integer ORDER_MAX, the maximum face order.
%
face_num = 0;
node_num = 0;
normal_num = 0;
order_max = 0;
text_num = 0;
%
% If no file input, try to get one from the user.
%
if ( nargin < 1 )
input_file_name = input ( 'Enter the name of the ASCII OBJ file.' );
if ( isempty ( input_file_name ) )
return
end
end
%
% Open the file.
%
input_file_unit = fopen ( input_file_name, 'r' );
if ( input_file_unit < 0 )
fprintf ( 1, '\n' );
fprintf ( 1, 'OBJ_SIZE - Fatal error!\n' );
fprintf ( 1, ' Could not open the file "%s".\n', input_file_name );
error ( 'OBJ_SIZE - Fatal error!' );
end
%
% Read a line of text from the file.
%
while ( 1 )
text = fgetl ( input_file_unit );
if ( text == -1 )
break
end
text_num = text_num + 1;
%
% Replace any control characters (in particular, TABs) by blanks.
%
s_control_blank ( text );
done = 1;
word_index = 0;
%
% Read a word from the line.
%
[ word, done ] = word_next_read ( text, done );
%
% If no more words in this line, read a new line.
%
if ( done )
continue
end
%
% If this word begins with '#' or '$', then it is a comment. Read a new line.
%
if ( word(1) == '#' || word(1) == '$' )
continue
end
word_index = word_index + 1;
if ( word_index == 1 )
word_one = word;
end
%
% F V1 V2 V3 ...
% or
% F V1/VT1/VN1 V2/VT2/VN2 ...
% or
% F V1//VN1 V2//VN2 ...
%
% Face.
% A face is defined by the vertices.
% Optionally, slashes may be used to include the texture vertex
% and vertex normal indices.
%
if ( s_eqi ( word_one, 'F' ) )
face_num = face_num + 1;
vertex = 0;
while ( 1 )
[ word, done ] = word_next_read ( text, done );
if ( done )
break
end
vertex = vertex + 1;
order_max = max ( order_max, vertex );
%
% Locate the slash characters in the word, if any.
%
i1 = ch_index ( word, '/' );
if ( 0 < i1 )
i2 = ch_index ( word(i1+1), '/' ) + i1;
else
i2 = 0;
end
%
% Read the vertex index.
%
s_to_i4 ( word );
%
% If there are two slashes, then read the data following the second one.
%
if ( 0 < i2 )
s_to_i4 ( word(i2+1) );
end
end
%
% V X Y Z W
% Geometric vertex.
%
elseif ( s_eqi ( word_one, 'V' ) )
node_num = node_num + 1;
continue
%
% VN
% Vertex normals.
%
elseif ( s_eqi ( word_one, 'VN' ) )
normal_num = normal_num + 1;
continue
end
end
fclose ( input_file_unit );
return
end
function obj_size_print ( input_file_name, node_num, face_num, normal_num, ...
order_max )
%*****************************************************************************80
%
%% OBJ_SIZE_PRINT prints sizes associated with an OBJ file.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 26 September 2008
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, string INPUT_FILE_NAME, the name of the input file.
%
% Input, integer NODE_NUM, the number of vertices defined.
%
% Input, integer FACE_NUM, the number of faces defined.
%
% Input, integer NORMAL_NUM, the number of normal vectors defined.
%
% Input, integer ORDER_MAX, the maximum number of vertices per face.
%
fprintf ( 1, '\n' );
fprintf ( 1, ' Object sizes for OBJ file "%s":\n', input_file_name );
fprintf ( 1, '\n' );
fprintf ( 1, ' Nodes = %d\n', node_num );
fprintf ( 1, ' Faces = %d\n', face_num );
fprintf ( 1, ' Maximum face order = %d\n', order_max );
fprintf ( 1, ' Normal vectors = %d\n', normal_num );
return
end
function s = s_control_blank ( s )
%*****************************************************************************80
%
%% S_CONTROL_BLANK replaces control characters with blanks.
%
% Discussion:
%
% A "control character" has ASCII code <= 31 or 127 <= ASCII code.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 27 September 2008
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input/output, string S, the string to be transformed.
%
s_length = s_len_trim ( s );
for i = 1 : s_length
if ( ch_is_control ( s(i) ) )
s(i) = ' ';
end
end
return
end
function value = s_eqi ( s1, s2 )
%*****************************************************************************80
%
%% S_EQI is a case insensitive comparison of two strings for equality.
%
% Example:
%
% S_EQI ( 'Anjana', 'ANJANA' ) is TRUE.
%
% Licensing:
%
% This code is distributed under the GNU LGPL license.
%
% Modified:
%
% 30 April 2004
%
% Author:
%
% John Burkardt
%
% Parameters:
%
% Input, string S1, S2, the strings to compare.
%