Salome HOME
[EDF24319] : extension of RCO file reader / get rid off comments starting by # at...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 20 Dec 2021 10:00:57 +0000 (11:00 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 20 Dec 2021 10:00:57 +0000 (11:00 +0100)
src/ContactReader/Test/24319_no_comment.rco [new file with mode: 0644]
src/ContactReader/Test/24319_with_comments.rco [new file with mode: 0644]
src/ContactReader/Test/24319_withcomment.py [new file with mode: 0644]
src/ContactReader/Test/CMakeLists.txt
src/ContactReader/Test/CTestTestfileInstall.cmake
src/ContactReader/plugin/ContactReaderModule/vtkContactReader.cxx

diff --git a/src/ContactReader/Test/24319_no_comment.rco b/src/ContactReader/Test/24319_no_comment.rco
new file mode 100644 (file)
index 0000000..c3e4095
--- /dev/null
@@ -0,0 +1,68 @@
+PLOT                     X            Y            Z            DX           DY           DZ           INST        
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -2.51812E+06  5.18976E+05  2.25963E+06  1.20000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02 -4.86358E+06  7.49731E+05  4.81270E+06  1.20000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -1.21271E+07  3.80027E+06  8.68520E+06  1.20000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -2.48181E+07  1.11422E+07  1.53129E+07  1.20000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -4.82226E+07  2.96337E+07  2.36960E+07  1.20000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.25375E+07  5.60036E+07  5.02024E+07  1.20000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -9.15988E+07  7.93881E+07  6.43735E+07  1.20000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.49890E+08  1.33108E+08  9.24972E+07  1.20000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.68777E+08  1.59446E+08  1.19541E+08  1.20000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -8.03938E+07  5.95932E+07  1.21999E+08  1.20000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -6.69576E+07  1.30459E+07  6.90048E+07  1.20000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -9.52029E+07  6.77110E+06  6.91143E+07  1.20000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -6.38872E+07 -8.67690E+06  4.94395E+07  1.20000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -6.98988E+07 -2.71573E+07  6.51318E+07  1.20000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -6.90477E+07 -4.57827E+07  8.61901E+07  1.20000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.16447E+08 -1.02618E+08  9.74352E+07  1.20000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.31031E+08 -8.53599E+07  9.87310E+07  1.20000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.30232E+08 -8.12113E+07  8.11857E+07  1.20000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.70692E+07 -5.23439E+07  6.35916E+07  1.20000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -1.00899E+08 -5.59920E+07  5.04761E+07  1.20000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -4.17381E+07 -2.59432E+07  1.42756E+07  1.20000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02 -2.04268E+07 -1.25571E+07  5.03521E+06  1.20000E+01
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -1.04869E+07  3.54463E+06 -3.64950E+06  1.30000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02  3.92015E+07 -2.33573E+07  1.05387E+07  1.30000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -3.93550E+05 -1.04232E+07  1.55681E+07  1.30000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -1.43512E+07 -5.61552E+06  2.86027E+07  1.30000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -4.26544E+07  1.45717E+07  3.87523E+07  1.30000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.18437E+07  4.49200E+07  6.65880E+07  1.30000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -1.00551E+08  7.72560E+07  8.60389E+07  1.30000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.66175E+08  1.29224E+08  1.08861E+08  1.30000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.66685E+08  1.55915E+08  7.27720E+07  1.30000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -8.72829E+07  4.84711E+07  9.64935E+07  1.30000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -8.26164E+07  1.50823E+07  5.51339E+07  1.30000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -1.18455E+08  8.25128E+06  6.04022E+07  1.30000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -7.72470E+07 -9.16088E+06  4.66626E+07  1.30000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -8.28891E+07 -2.31785E+07  5.99218E+07  1.30000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -7.60082E+07 -3.46510E+07  7.50832E+07  1.30000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.13654E+08 -9.51880E+07  7.64156E+07  1.30000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.34369E+08 -7.60627E+07  1.00090E+08  1.30000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.36816E+08 -7.72787E+07  8.22694E+07  1.30000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.64893E+07 -4.34282E+07  7.43293E+07  1.30000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -9.09932E+07 -3.70954E+07  6.48947E+07  1.30000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -3.10654E+07 -1.12056E+07  2.80391E+07  1.30000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02  3.23989E+06  4.96836E+06  9.18392E+06  1.30000E+01
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -3.49463E+07  1.65074E+07  1.20951E+06  1.40000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02 -1.56265E+07  1.07460E+07  4.64727E+06  1.40000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -2.79701E+07  2.23303E+07  3.19925E+06  1.40000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -3.59778E+07  3.11175E+07  2.11501E+06  1.40000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -5.58256E+07  4.99791E+07  4.23018E+06  1.40000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.28117E+07  6.92927E+07  3.20710E+07  1.40000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -8.17303E+07  8.12204E+07  4.09510E+07  1.40000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.32963E+08  1.35427E+08  7.01695E+07  1.40000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.66011E+08  1.59072E+08  1.46231E+08  1.40000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -7.40144E+07  6.76345E+07  1.50883E+08  1.40000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -4.82876E+07  1.33687E+07  9.85710E+07  1.40000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -6.62952E+07  4.60461E+06  9.73276E+07  1.40000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -4.80844E+07 -9.72044E+06  5.96427E+07  1.40000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -5.61129E+07 -3.49130E+07  7.64745E+07  1.40000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -6.29820E+07 -5.65680E+07  9.52740E+07  1.40000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.15693E+08 -1.06879E+08  1.07786E+08  1.40000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.25918E+08 -9.23328E+07  9.68982E+07  1.40000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.25647E+08 -8.95375E+07  7.68668E+07  1.40000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.65766E+07 -6.06655E+07  5.26265E+07  1.40000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -1.13865E+08 -8.00611E+07  3.58020E+07  1.40000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -5.25069E+07 -4.15134E+07  6.32092E+05  1.40000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02 -4.87386E+07 -3.35506E+07 -6.17527E+05  1.40000E+01
+
diff --git a/src/ContactReader/Test/24319_with_comments.rco b/src/ContactReader/Test/24319_with_comments.rco
new file mode 100644 (file)
index 0000000..b4ff87f
--- /dev/null
@@ -0,0 +1,71 @@
+#
+#--------------------------------------------------------------------------------
+##ASTER 15.4.0 CONCEPT 000000ba CALCULE LE 07/21/2021 A 10:43:50 DE TYPE  
+PLOT                     X            Y            Z            DX           DY           DZ           INST        
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -2.51812E+06  5.18976E+05  2.25963E+06  1.20000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02 -4.86358E+06  7.49731E+05  4.81270E+06  1.20000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -1.21271E+07  3.80027E+06  8.68520E+06  1.20000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -2.48181E+07  1.11422E+07  1.53129E+07  1.20000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -4.82226E+07  2.96337E+07  2.36960E+07  1.20000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.25375E+07  5.60036E+07  5.02024E+07  1.20000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -9.15988E+07  7.93881E+07  6.43735E+07  1.20000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.49890E+08  1.33108E+08  9.24972E+07  1.20000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.68777E+08  1.59446E+08  1.19541E+08  1.20000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -8.03938E+07  5.95932E+07  1.21999E+08  1.20000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -6.69576E+07  1.30459E+07  6.90048E+07  1.20000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -9.52029E+07  6.77110E+06  6.91143E+07  1.20000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -6.38872E+07 -8.67690E+06  4.94395E+07  1.20000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -6.98988E+07 -2.71573E+07  6.51318E+07  1.20000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -6.90477E+07 -4.57827E+07  8.61901E+07  1.20000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.16447E+08 -1.02618E+08  9.74352E+07  1.20000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.31031E+08 -8.53599E+07  9.87310E+07  1.20000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.30232E+08 -8.12113E+07  8.11857E+07  1.20000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.70692E+07 -5.23439E+07  6.35916E+07  1.20000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -1.00899E+08 -5.59920E+07  5.04761E+07  1.20000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -4.17381E+07 -2.59432E+07  1.42756E+07  1.20000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02 -2.04268E+07 -1.25571E+07  5.03521E+06  1.20000E+01
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -1.04869E+07  3.54463E+06 -3.64950E+06  1.30000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02  3.92015E+07 -2.33573E+07  1.05387E+07  1.30000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -3.93550E+05 -1.04232E+07  1.55681E+07  1.30000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -1.43512E+07 -5.61552E+06  2.86027E+07  1.30000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -4.26544E+07  1.45717E+07  3.87523E+07  1.30000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.18437E+07  4.49200E+07  6.65880E+07  1.30000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -1.00551E+08  7.72560E+07  8.60389E+07  1.30000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.66175E+08  1.29224E+08  1.08861E+08  1.30000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.66685E+08  1.55915E+08  7.27720E+07  1.30000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -8.72829E+07  4.84711E+07  9.64935E+07  1.30000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -8.26164E+07  1.50823E+07  5.51339E+07  1.30000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -1.18455E+08  8.25128E+06  6.04022E+07  1.30000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -7.72470E+07 -9.16088E+06  4.66626E+07  1.30000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -8.28891E+07 -2.31785E+07  5.99218E+07  1.30000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -7.60082E+07 -3.46510E+07  7.50832E+07  1.30000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.13654E+08 -9.51880E+07  7.64156E+07  1.30000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.34369E+08 -7.60627E+07  1.00090E+08  1.30000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.36816E+08 -7.72787E+07  8.22694E+07  1.30000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.64893E+07 -4.34282E+07  7.43293E+07  1.30000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -9.09932E+07 -3.70954E+07  6.48947E+07  1.30000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -3.10654E+07 -1.12056E+07  2.80391E+07  1.30000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02  3.23989E+06  4.96836E+06  9.18392E+06  1.30000E+01
+J_A                       6.99380E+01 -9.92860E+01  2.47510E+02 -3.49463E+07  1.65074E+07  1.20951E+06  1.40000E+01
+J_AB                      5.89892E+01 -9.41141E+01  2.43945E+02 -1.56265E+07  1.07460E+07  4.64727E+06  1.40000E+01
+J_BC                      4.94006E+01 -8.83328E+01  2.41013E+02 -2.79701E+07  2.23303E+07  3.19925E+06  1.40000E+01
+J_CD                      4.05306E+01 -8.18223E+01  2.37012E+02 -3.59778E+07  3.11175E+07  2.11501E+06  1.40000E+01
+J_DE                      3.21359E+01 -7.45872E+01  2.31851E+02 -5.58256E+07  4.99791E+07  4.23018E+06  1.40000E+01
+J_EF                      2.43053E+01 -6.67373E+01  2.25916E+02 -7.28117E+07  6.92927E+07  3.20710E+07  1.40000E+01
+J_FG                      1.69305E+01 -5.83075E+01  2.20191E+02 -8.17303E+07  8.12204E+07  4.09510E+07  1.40000E+01
+J_GH                      1.00718E+01 -4.91424E+01  2.12987E+02 -1.32963E+08  1.35427E+08  7.01695E+07  1.40000E+01
+J_HI                      4.20367E+00 -3.91701E+01  2.02641E+02 -1.66011E+08  1.59072E+08  1.46231E+08  1.40000E+01
+J_IJ                     -2.23839E+00 -2.92321E+01  1.93039E+02 -7.40144E+07  6.76345E+07  1.50883E+08  1.40000E+01
+J_JK                     -7.58248E+00 -1.81314E+01  1.89248E+02 -4.82876E+07  1.33687E+07  9.85710E+07  1.40000E+01
+J_KL                     -1.03040E+01 -6.14203E+00  1.90248E+02 -6.62952E+07  4.60461E+06  9.73276E+07  1.40000E+01
+J_LM                     -1.03047E+01  6.14213E+00  1.91376E+02 -4.80844E+07 -9.72044E+06  5.96427E+07  1.40000E+01
+J_MN                     -7.58064E+00  1.81305E+01  1.92882E+02 -5.61129E+07 -3.49130E+07  7.64745E+07  1.40000E+01
+J_NO                     -2.25230E+00  2.92447E+01  1.95264E+02 -6.29820E+07 -5.65680E+07  9.52740E+07  1.40000E+01
+J_OP                      4.91497E+00  3.90358E+01  2.00085E+02 -1.15693E+08 -1.06879E+08  1.07786E+08  1.40000E+01
+J_PQ                      1.12662E+01  4.85991E+01  2.06748E+02 -1.25918E+08 -9.23328E+07  9.68982E+07  1.40000E+01
+J_QR                      1.78531E+01  5.76811E+01  2.13458E+02 -1.25647E+08 -8.95375E+07  7.68668E+07  1.40000E+01
+J_RS                      2.56587E+01  6.68139E+01  2.20117E+02 -9.65766E+07 -6.06655E+07  5.26265E+07  1.40000E+01
+J_ST                      3.43732E+01  7.59344E+01  2.28900E+02 -1.13865E+08 -8.00611E+07  3.58020E+07  1.40000E+01
+J_TU                      4.39848E+01  8.45035E+01  2.39018E+02 -5.25069E+07 -4.15134E+07  6.32092E+05  1.40000E+01
+J_U                       5.49398E+01  9.19596E+01  2.46487E+02 -4.87386E+07 -3.35506E+07 -6.17527E+05  1.40000E+01
+
diff --git a/src/ContactReader/Test/24319_withcomment.py b/src/ContactReader/Test/24319_withcomment.py
new file mode 100644 (file)
index 0000000..5179967
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright (C) 2021  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+__doc__ = """ non regression test of EDF24319
+resultante_cdth.rco -> 24319_no_comment.rco
+resultante_cdth.resu -> 24319_with_comments.rco
+"""
+
+from paraview.simple import *
+
+def MyAssert(b):
+  if not b:
+    raise RuntimeError("Oooops : Assertion failed !")
+
+
+cr_without_comment = ContactReader(registrationName='WithoutComment', FileName='24319_no_comment.rco')
+cr_with_comments = ContactReader(registrationName='WithComments', FileName='24319_with_comments.rco')
+cr_without_comment.UpdatePipeline()
+cr_with_comments.UpdatePipeline()
+
+polydata_without_comment = servermanager.Fetch(cr_without_comment)
+polydata_with_comments = servermanager.Fetch(cr_with_comments)
+MyAssert(polydata_without_comment.GetNumberOfCells() == polydata_with_comments.GetNumberOfCells())
+MyAssert(polydata_without_comment.GetNumberOfPoints() == polydata_with_comments.GetNumberOfPoints())
index 218263520ae145764171f059d950e0912bd0a4c1..b6de25fcfe26de83d01899f2f4c716ff7d5968ff 100644 (file)
@@ -23,6 +23,9 @@ SET(test_contactreader_0
   23711_with_time.rco
   23711_without_time.py
   23711_without_time.rco
+  24319_withcomment.py
+  24319_with_comments.rco
+  24319_no_comment.rco
   )
 
 # Application tests
index 9759cda2082cf0c88e0d50d750a5a1b1c5f54e58..5b5341c6b14a6c5e4e066657e8f5f05286b6e83d 100644 (file)
@@ -20,6 +20,7 @@
 SET(TEST_NAMES
 23711_with_time
 23711_without_time
+24319_withcomment
 )
 
 FOREACH(tfile ${TEST_NAMES})
index 58df66860e8f4a711fe7aac6e799e811c138c3e4..750f0e7e0fbc610783f44e9a05bbfe46fde36197 100644 (file)
@@ -59,6 +59,86 @@ private:
   std::string _what;
 };
 
+#include <iostream>
+
+#ifndef WIN32
+#include <sys/types.h>
+#include <unistd.h>
+#else
+#include <process.h>
+#include <IO.h>
+#include <stdio.h>
+#define getpid _getpid
+#define unlink _unlink
+#endif
+
+/*!
+ * Class to deal with destruction of temporaty file if any. A temporary file is created when presence of comments is detected (presence of #)
+ */
+class AutoDezinger
+{
+public:
+  AutoDezinger(bool newFileToKill, const std::string& fileName):_newFileToKill(newFileToKill),_fileName(fileName) { }
+  std::string getFileName() const { return _fileName; }
+  void print() const
+  {
+    if(_newFileToKill)
+    {
+      std::cout << "A new file has been created : " << _fileName << std::endl;
+    }
+    else
+    {
+      std::cout << "File remains untouched : " << _fileName << std::endl;
+    }
+  }
+  ~AutoDezinger()
+  {
+    if(_newFileToKill)
+      unlink(_fileName.c_str());
+  }
+private:
+  bool _newFileToKill;
+  std::string _fileName;
+};
+
+std::string generateTmpFileName(const std::string& fileName)
+{
+  auto pos = fileName.find_last_of('.');
+  if(pos == std::string::npos)
+    throw MyException("generateTmpFileName : impossible to find an extention");
+  std::string tmpFileName(fileName.substr(0,pos));
+  std::ostringstream oss; oss << tmpFileName << "_tmp201221_" << getpid() << fileName.substr(pos);
+  return oss.str();
+}
+
+AutoDezinger patchRCOFile(const char *fileName)
+{
+  std::ifstream ifs(fileName);
+  std::string line;
+  bool endOfCommentsReached(false), presenceOfCommentsToSkip(false);
+  std::vector<std::string> linesWithoutComment;
+  while( std::getline(ifs,line) )
+  {
+    if(!endOfCommentsReached)
+    {
+      auto pos = line.find_first_of('#');
+      if(pos==0)// presence of # at first place -> skip it
+        { presenceOfCommentsToSkip = true; continue; }
+      else
+        { endOfCommentsReached = true; }
+    }
+    linesWithoutComment.emplace_back(line);
+  }
+  if(!presenceOfCommentsToSkip)
+    return AutoDezinger(false,fileName);
+  std::string fileNameForDelTextReader = generateTmpFileName(fileName);
+  std::ofstream ofs(fileNameForDelTextReader);
+  for(const auto& line : linesWithoutComment)
+    ofs << line << std::endl;
+  return AutoDezinger(true,fileNameForDelTextReader);
+}
+
+
 template <class T>
 class AutoPtr
 {
@@ -117,8 +197,10 @@ double InstValueOf(vtkTable *table, vtkIdType iRow, vtkIdType iCol)
 
 vtkSmartPointer<vtkTable> LoadDataFromFile(const char *FileName)
 {
+  // EDF24319 : get rid off comments lines
+  AutoDezinger az( patchRCOFile(FileName) );
   vtkNew<vtkDelimitedTextReader> reader;
-  reader->SetFileName(FileName);
+  reader->SetFileName(az.getFileName().c_str());
   reader->SetDetectNumericColumns(true);
   reader->SetUseStringDelimiter(true);
   reader->SetHaveHeaders(true);