@@ -214,17 +214,62 @@ public Chunk(
214214 Box3d ? bbox = null
215215 )
216216 {
217- if ( positions == null ) throw new ArgumentNullException ( nameof ( positions ) , "Invariant ad93ff8e-d1a9-4c96-a626-43c69617371e." ) ;
218- if ( colors != null && colors . Count != positions . Count ) throw new ArgumentException ( nameof ( colors ) ) ;
219- if ( normals != null && normals . Count != positions . Count ) throw new ArgumentException ( nameof ( normals ) ) ;
220- if ( intensities != null && intensities . Count != positions . Count ) throw new ArgumentException ( nameof ( intensities ) ) ;
221- if ( classifications != null && classifications . Count != positions . Count ) throw new ArgumentException ( nameof ( classifications ) ) ;
217+ if ( positions == null ) throw new ArgumentNullException (
218+ nameof ( positions ) , "Error ad93ff8e-d1a9-4c96-a626-43c69617371e."
219+ ) ;
222220
223- if ( colors != null && positions . Count != colors . Count )
221+ var countMismatch = false ;
222+
223+ if ( colors != null && colors . Count != positions . Count )
224+ {
225+ countMismatch = true ; //throw new ArgumentException(nameof(colors));
226+ Report . Warn ( $ "Expected { positions . Count } color values, but found { colors . Count } . " +
227+ $ "Warning 3c3ac3d4-c4de-4ad6-a925-d2fbaece1634."
228+ ) ;
229+ }
230+ if ( normals != null && normals . Count != positions . Count )
224231 {
225- Report . Warn ( "[Chunk-ctor] inconsistent length: pos.length = {0} vs cs.length = {1}" , positions . Count , colors . Count ) ;
226- colors = new C4b [ positions . Count ] ;
232+ countMismatch = true ; //throw new ArgumentException(nameof(normals));
233+ Report . Warn ( $ "Expected { positions . Count } normal values, but found { normals . Count } . " +
234+ $ "Warning 0e6b1e22-25a1-4814-8dc7-add137edcd45."
235+ ) ;
236+ }
237+ if ( intensities != null && intensities . Count != positions . Count )
238+ {
239+ countMismatch = true ; //throw new ArgumentException(nameof(intensities));
240+ Report . Warn ( $ "Expected { positions . Count } intensity values, but found { intensities . Count } . " +
241+ $ "Warning ea548345-6f32-4504-8189-4dd4a4531708."
242+ ) ;
227243 }
244+ if ( classifications != null && classifications . Count != positions . Count )
245+ {
246+ countMismatch = true ; //throw new ArgumentException(nameof(classifications));
247+ Report . Warn (
248+ $ "Expected { positions . Count } classification values, but found { classifications . Count } . " +
249+ $ "Warning 0c82c851-986f-4690-980b-7a3a240bf499."
250+ ) ;
251+ }
252+
253+ if ( countMismatch )
254+ {
255+ var minCount = positions . Count ;
256+ if ( colors != null && colors . Count != positions . Count ) minCount = Math . Min ( minCount , colors . Count ) ;
257+ if ( normals != null && normals . Count != positions . Count ) minCount = Math . Min ( minCount , normals . Count ) ;
258+ if ( intensities != null && intensities . Count != positions . Count ) minCount = Math . Min ( minCount , intensities . Count ) ;
259+ if ( classifications != null && classifications . Count != positions . Count ) minCount = Math . Min ( minCount , classifications . Count ) ;
260+
261+ if ( positions . Count != minCount ) positions = positions . Take ( minCount ) . ToArray ( ) ;
262+ if ( colors != null && colors . Count != minCount ) colors = colors . Take ( minCount ) . ToArray ( ) ;
263+ if ( normals != null && normals . Count != minCount ) normals = normals . Take ( minCount ) . ToArray ( ) ;
264+ if ( intensities != null && intensities . Count != minCount ) intensities = intensities . Take ( minCount ) . ToArray ( ) ;
265+ if ( classifications != null && classifications . Count != minCount ) classifications = classifications . Take ( minCount ) . ToArray ( ) ;
266+ }
267+
268+ //if (colors != null && positions.Count != colors.Count)
269+ //{
270+ // Report.Warn("[Chunk-ctor] inconsistent length: pos.length = {0} vs cs.length = {1}", positions.Count, colors.Count);
271+ // colors = new C4b[positions.Count];
272+ //}
228273
229274 //if (positions.Any(p => p.IsNaN)) throw new ArgumentException("One or more positions are NaN.");
230275
0 commit comments