Open Rock2000 opened 7 months ago
Show your code please.
The polyface creation is in the attached file. Then just create the geomstream
const builder = new CoreElementGeometry.Builder();
const meshParams = new GeometryParams(categoryId);
meshParams.fillDisplay = FillDisplay.ByView;
meshParams.lineColor = sourceParams.color;
meshParams.fillColor = meshParams.lineColor;
meshParams.weight = 1;
builder.appendGeometryParamsChange(meshParams));
builder.appendGeometryQuery(polyface);
const builderParams = { viewIndependent: false, entryArray: builder.entries };
and assign this to a geometric element's elementGeometryBuilderParams property. It works fine without the auxChannel data.
I might be reading it wrong, but if the test just stores the geomstream into the database and no other services are running than I expect it won't show the problem. The actual update of the element is not what crashes. While I can't be sure, I believe it is either the tile generation based on this new geomstream, or somehow rendering the tile. It may actually be easier to reproduce this way. Here is an imodel that has the stored geomstream (not the exact same as the sample code, but conceptually the same, with zero scalar values). If you open the imodel the platform crashes before the view is shown. You need all the files supplied to see the issue (the bim file alone will open successfully)
Gonna need actual repro steps.
Alternatively, consider using the debugging, logging, and crash reporting capabilities built into Studio to capture a native stack trace.
Either generating and saving that geomstream in an application, or opening that imodel in an application should reproduce it. I checked for logs in %TEMP%\iTwinStudio\Logs but I don't see anything from native.
No crash when opening the view, whether I open the .bim with none of the other files present, nor with all the other files present. Tiles finish loading and I see a green polyface and below it the outline of a blue rectangle.
Several seconds after I zoom out a bit, it crashes.
Element geometry stream reported in display-test-app does not include the aux channels, but otherwise looks reasonable. (I assume the green polyface is the element that's supposed to contain aux channels).
[Geometry Summary for Element 0x43]
(3D) Category: 0x20
Model: 0x31
{"indexedMesh":{"point":[[-654.9048006685064,-1.4512710321434947,96.23637695258049],[-654.9048006685065,4.053085326891638,95.95386238246687],[-649.3438639060464,-1.4512710321434952,99.54052114474263],[-654.9048006685066,29.931437053898083,96.34726252605145],[-628.3941831407569,-1.4512710321434916,100.65866566847339],[-651.4272276049248,32.973304760030146,96.53578492155617],[-654.9048006685065,39.07867526869474,96.93754218214954],[-605.308653297898,-1.4512710321434987,103.25636921582586],[-654.9048006685065,87.79336297826025,100.35819054360066],[-609.4219308449618,71.34595723491742,99.5557591817957],[-654.9048006685065,125.70467657837608,102.1961085963678],[-654.9048006685065,153.42772454324592,93.88062736243208],[-654.9048006685065,153.4371901455186,93.88056136234766],[-654.9048006685065,153.43333063041302,100.74258321319715],[-654.9048006685065,153.4373652616992,100.74243001435757],[-654.9048006685065,153.43733202986965,105.64032513230606],[-654.9048006685065,153.43749025357482,105.64019462967075],[-616.5726456072529,153.42379476700907,91.77634290746832],[-616.5700399700352,153.4332597908009,91.77618145387596],[-616.5705905963625,153.43355995531127,103.5358449477339],[-616.5660451592433,153.43340188905796,103.53610642462573],[-474.81938053349916,-1.4512710321434952,108.38131405867404],[-654.9048006685065,226.15632508721202,112.85960012402703],[-654.9048006685065,232.134133357733,113.46559193039062],[-654.9048006685065,242.05668144725368,114.16819539972958],[-589.7684504014187,188.82151300410246,105.75875576169469],[-423.3066820804337,-1.4512710321434916,110.80675622350873],[-404.5147093535424,-1.4512710321434952,111.34229170876313],[-374.39203705558975,-1.4512710321434987,111.57033132887935],[-654.9048006685065,335.2243743844598,114.74248653609375],[-468.2235049083565,153.42379108825284,91.6391650197537],[-468.2208987002782,153.43325613563783,91.63992788545393],[-339.65167002623565,-1.4512710321434952,110.78985481265185],[-468.2214493266056,153.4335563001482,103.39959137931187],[-468.21690446034705,153.43339821030173,103.39892853691111],[-343.1162802846683,24.820778996580284,110.92093374138955],[-612.3746590310424,335.2243743844598,115.50765057211902],[-308.2981631691962,-1.4512710321434774,103.74060050640131],[-308.28728883556863,-1.4512710321435272,103.74079074479788],[-380.65218706476327,84.1432518457489,108.63580312204505],[-308.292322602812,-1.4512710321434987,114.14607825538063],[-308.2877765204508,-1.4512710321434987,114.14655629603067],[-308.29156293942015,-1.4512710321434916,115.49956393248544],[-308.2878399526808,-1.4512710321434952,115.50001410957975],[-590.648506609563,330.74566470249636,115.87092092563508],[-590.3933881239175,335.2243743844598,115.64445676585113],[-589.3542526091531,335.22437438445974,115.65028265744641],[-295.7483745676837,-1.451271032143497,116.25605740876532],[-292.4384523295355,-1.4512710321434956,115.47537482403197],[-308.2973762290798,29.464785790419658,104.50733648383982],[-308.28567904354844,29.46494311641624,104.5074776176353],[-581.0796351817118,335.2243743844598,115.75205297510557],[-360.98676789587023,89.9322040695449,109.66385708306079],[-284.87214933761936,-1.451271032143496,115.4150608225775],[-308.29077575134176,29.47439289626269,116.26646509313525],[-308.2862296604229,29.474550230767697,116.26693922790298],[-308.2972567308535,45.73327797761249,101.95522653280096],[-308.2855595042957,45.73343528124421,101.95449146981645],[-368.13800378655367,107.39213716214581,113.01412028023792],[-274.3984437698102,-1.451271032143496,118.14346648259033],[-357.41138332450726,101.58459618004633,112.9728668541029],[-308.290656282844,45.742885099661436,113.7149900499584],[-308.2861101481559,45.743042410306366,113.71452941128626],[-266.3385790761713,-1.4512710321434987,115.8637072182954],[-373.5077064930143,153.41461660090087,96.83333703949528],[-373.5050998706502,153.42408088568246,96.83362626433303],[-464.653276423388,249.32165593810063,108.00291166059569],[-373.50110604500475,153.42422372295,108.59310055665271],[-373.4984994179433,153.42438105019286,108.59329009302813],[-244.25364252359148,-1.451271032143497,116.76163075985258],[-256.43372577543687,18.99490254116083,115.62817799601548],[-357.41798608883863,153.4147296375735,101.26257276053153],[-357.41537939269915,153.42419391844874,101.26270894515838],[-357.4113856111006,153.42433674341663,113.02170136982696],[-357.4087789168713,153.42449407035514,113.02187898155897],[-308.29005681789033,112.03599873424712,100.91228560141955],[-308.2855107158061,112.03615606266548,100.91252127746411],[-341.3279586785944,153.41467531514672,99.13511499074086],[-341.32535191427047,153.42413959516344,99.13521753942292],[-446.77571181035347,265.5822899481498,110.8436269819675],[-464.6535440274807,286.5247007331324,113.71810166074923],[-273.40319128932896,69.01045416782559,114.66709166336912],[-308.28606133268056,112.04576317701688,112.6719828877318],[-308.2834563698809,112.045605856296,112.67204911857698],[-358.30981501696044,170.21559488397097,113.02486474657819],[-341.3213582305849,153.42428243719584,110.89487850789827],[-341.3187514615636,153.42443975967382,110.89488136811804],[-406.5578283343061,234.17797436751593,106.25404335695754],[-365.44640655893795,186.4853630801093,109.0663700513902],[-439.62452437660954,272.563009986957,108.52888535859707],[-281.4552957841905,86.45168212223354,114.44322927535424],[-343.1065192865679,165.56168668798975,110.85350309605744],[-429.79904488565336,267.9092134373009,110.73128405533589],[-308.290388111293,137.61169165682716,107.98768091036655],[-308.28584204304843,137.6118490036926,107.98863929516527],[-196.15273800239768,-1.4512710321434952,120.9792640500043],[-280.55439711633227,100.41218945281713,117.37528828219664],[-276.09221406471136,94.5860848232841,119.30289747256833],[-342.2198396680386,177.17773269813404,112.01069725627704],[-308.2863926599229,137.6214561180439,119.74810090543296],[-308.2837876632836,137.62129877887617,119.74744442752397],[-251.96450928007033,77.18209848756788,120.0681102918677],[-308.29044077128174,153.4149299434192,109.11233426610895],[-308.28589464633933,153.41508725937683,109.11208176356382],[-308.2878338664218,153.42439422138384,109.11235642090283],[-308.2832896664378,153.42455303017147,109.11178275112199],[-243.02552298361954,72.50993210259976,117.13108795594898],[-425.4367727992307,291.17841512984785,108.29946110164352],[-279.66756631079204,119.02604655814456,115.30352034299999],[-465.4938649675414,335.2243743844598,114.00811600292641],[-260.0024580671359,95.7588547860752,122.97196902513515],[-308.28644526321386,153.42469437372824,120.8715433738315],[-308.28384030258337,153.4248532000341,120.87165593181062],[-308.2838403232722,153.42453706546831,120.87209778326637],[-308.281233413715,153.42469438589424,120.87202024959792],[-243.02554142103773,89.932561902309,117.52485378715738],[-286.81890632476143,138.79416125029618,120.87753264785351],[-411.0203151303519,290.02432378942456,110.81307457988159],[-245.70017419230953,99.23958734036609,120.28454112564397],[-319.8802430842187,185.33148677670934,120.00603241702721],[-154.2911880296001,-1.4512710321434916,121.87808233392138],[-251.96440698668118,114.37263488031316,117.88344208006275],[-435.85120554328955,335.2243743844598,114.5552341547228],[-406.55792867594243,314.44768136753277,108.39702820760373],[-383.31692061994175,288.8514905693559,108.37259877757266],[-425.4369921836011,335.2243743844598,112.9848280056465],[-342.2197148251579,245.8126850577411,109.34444213144128],[-168.84766691152277,36.4549446049554,123.25208457460562],[-416.7766306034057,335.2243743844598,111.89410847257693],[-236.76072928395965,153.41504737837144,107.55299691595702],[-236.76527511236608,153.42451316299912,107.55323951116661],[-393.14187999285105,335.2243743844598,113.59961593276066],[-236.7612799278199,153.42465450743364,119.31303485742683],[-236.75867466947747,153.42481333286176,119.31311302669239],[-380.64263899847464,328.40935996344206,113.11261411780727],[-385.5651672325497,335.2243743844598,112.94121397270854],[-319.87990706763264,262.10125863252966,112.82976462280978],[-308.2876057376926,264.4279657486322,104.24023724386603],[-308.2759104743607,264.428124565971,104.23999892220019],[-372.48817574304786,335.2243743844598,113.39174605758808],[-79.58371988756396,-1.4512710321435165,119.51302120855802],[-308.2810052849857,264.4282659131426,115.99990107256114],[-308.2764611105063,264.42842473583363,115.99987210288882],[-366.50501283952855,335.2243743844598,113.16548251220625],[-308.28772204269654,278.389587412226,106.72414990986269],[-308.2760268020899,278.3897462419531,106.72439692827461],[-314.51683129170533,280.71679693679164,117.81684276833818],[-308.2811215668687,278.3898875641323,118.48331994626326],[-308.27657741292126,278.39004639801607,118.48372947485232],[-325.236221949082,305.90340616695437,116.17581375000654],[-308.2803819800477,310.93853055231915,102.68804880201999],[-308.2758377921134,310.93868936767547,102.68773247836262],[-308.27638842824786,310.94829724304,114.44760542147276],[-308.27378152732973,310.9481384223314,114.44771239313661],[-308.2803588561324,335.2243743844598,102.19419398766827],[-308.27581468548425,335.2243743844598,102.19424684199946],[-316.5701497323321,335.2243743844598,114.74909910388885],[-308.27729718249145,335.2243743844598,107.64910771327641],[-308.2760700937125,335.2243743844598,107.64897116006722],[-308.27636531902044,335.2243743844598,113.95406429417889],[-308.27375841256264,335.2243743844598,113.95405295568403],[5.3465819147278495,-1.4512710321434943,122.61413204704249],[-283.9343939978507,335.2243743844598,116.67710253974964],[-237.6598803837097,281.86193417648764,122.93852864438595],[12.848875499197362,-1.451271032143496,122.57724613209751],[16.602562794584415,-1.451271032143496,122.73873224375285],[19.510138223279014,-1.4512710321434943,122.61110320807312],[-268.22179489307433,335.2243743844598,115.10356189198227],[14.341540750976417,5.025348430971552,122.90183366590911],[31.153561038064836,-1.4512710321434952,121.45551402685865],[-253.29914817623683,335.2243743844598,116.64582719457951],[-73.98139764875503,128.323867266631,122.07788959293467],[-215.3196489521517,298.1502767926346,117.3754932779098],[-197.44233366254971,277.2081478018377,125.54098063135226],[-233.56360713557984,335.2243743844598,116.83657726270347],[-32.11891075084401,105.05644140144513,120.57621919046896],[63.47178732282396,-1.451271032143496,120.08991905495117],[-196.54091906636256,308.63075518869755,117.45449699303106],[63.47178732282396,12.25279578336365,121.64710270489587],[-185.8288539712119,305.89442676021434,122.82194324625742],[-187.18152859567346,335.2243743844598,117.33296282643536],[-25.861441147643315,153.40592242552253,114.69324180363397],[-25.858835001124813,153.41538744720614,114.69299775603798],[-25.8548406855132,153.41552953987383,126.4527037487388],[-25.852234532921912,153.41568760326913,126.45233063745286],[-177.37736646299223,335.2243743844598,121.82977634069641],[-10.672399678990015,153.4058408393713,111.49762015087424],[-10.6697934744609,153.41530586370908,111.49748008642906],[-10.670344110606475,153.41560603357172,123.2573532671177],[-10.665799243845575,153.41544796843343,123.2576584271812],[1.8510830926771864,180.66862891689343,125.65387495093339],[6.313495589296042,181.82270852868197,122.68164808776682],[15.25239193061235,188.80346173935843,121.66657759006662],[63.47178732282396,136.56333523391822,118.61984572640819],[10.775647666564439,194.63017739956214,125.27116750948053],[63.471787322823964,153.39713973275894,106.71716264077092],[63.47178732282396,153.40660360494948,106.71705626667946],[63.47178732282396,150.42058559313034,118.22621624380388],[63.47178732282395,153.40599542649505,117.55741260054039],[63.47178732282396,153.4068809901156,117.55670024949987],[63.47178732282396,153.4069044711399,118.47682092439243],[63.471787322823964,153.406746862841,118.47720116869137],[-73.97181798434596,305.8945043142152,125.86554447255094],[63.47178732282396,156.2246551281366,118.5283353225767],[63.47178732282396,157.49274517288703,118.4861340838261],[63.47178732282395,161.65766953189993,118.66169917521322],[-83.44536333934988,335.2243743844598,124.38564473930532],[16.15336064528001,223.69808634535326,123.10273456468603],[63.47178732282396,188.82896500856899,119.26290009619237],[-64.38972741715561,335.2243743844598,126.93307978423016],[-32.996381791580475,317.9201943001751,131.13563554901916],[-34.146838951345664,335.2243743844598,130.87798051854827],[32.228783950978226,286.5065934277809,127.42533508412971],[63.47178732282396,264.71385774355196,122.1177950402292],[46.53117402196102,284.17954057857145,122.4711525265135],[1.464039800199103,335.2243743844598,130.66273457676812],[63.47178732282396,303.7325677834757,122.58571561646787],[63.47178732282396,329.4304402083619,126.01564431063771],[58.82910475661193,335.22437438445974,128.6116988157965],[63.47178732282394,335.2243743844598,127.15163110146474]],"pointIndex":[165,169,162,0,166,169,165,0,121,141,176,128,0,96,121,128,0,176,141,162,169,0,170,169,167,0,167,169,166,0,179,194,169,0,177,179,169,170,0,169,194,198,176,0,176,198,202,190,0,128,176,172,0,172,176,184,0,184,176,190,0,128,116,107,0,116,128,133,0,71,128,107,0,133,128,172,0,96,128,71,70,0,184,133,172,0,133,112,117,0,116,133,119,0,133,122,119,0,117,122,133,0,116,111,102,0,119,111,116,0,107,116,102,0,102,71,107,0,56,71,82,0,49,54,71,56,0,82,71,102,0,70,71,64,0,60,71,54,0,64,71,60,0,48,56,44,0,49,56,48,0,56,82,63,0,82,111,98,0,63,82,91,0,102,111,82,0,91,82,98,0,111,109,98,0,122,109,111,0,122,111,119,0,109,122,117,0,109,83,97,0,117,83,109,0,98,109,97,0,91,98,97,0,83,63,91,0,97,83,91,0,100,83,117,0,112,100,117,0,42,56,44,0,56,42,39,51,0,63,56,51,0,63,51,58,0,83,63,58,0,83,58,77,0,100,83,77,0,100,77,95,0,112,100,95,0,112,95,104,0,133,112,104,0,133,104,130,0,184,133,130,0,184,130,182,0,190,184,182,0,190,182,187,0,199,202,190,187,0,199,187,196,0,17,20,23,0,30,25,45,37,0,26,24,23,20,0,24,26,45,25,0,34,26,20,0,67,26,34,0,67,45,26,0,110,52,45,81,0,37,45,46,0,81,45,67,0,47,46,45,0,47,45,52,0,123,110,81,0,80,81,67,0,108,126,123,81,0,90,108,81,0,90,81,80,0,34,88,67,0,67,88,80,0,88,34,69,0,118,88,125,0,88,69,89,0,88,118,93,0,125,88,127,0,127,88,89,0,80,88,93,0,93,90,80,0,93,108,90,0,124,129,126,108,0,118,124,108,0,93,118,108,0,132,129,124,135,0,132,135,136,0,136,135,140,0,144,135,150,157,0,140,135,144,0,135,124,125,0,125,150,135,0,127,150,125,0,125,124,118,0,150,127,137,0,89,99,127,0,137,127,120,0,120,127,99,0,85,99,89,0,89,69,85,0,69,75,85,0,85,92,99,0,85,75,92,0,99,92,120,0,87,120,92,0,120,115,142,0,120,87,115,0,142,137,120,0,142,147,137,0,147,150,137,0,150,147,154,0,161,157,150,154,0,154,147,148,0,148,147,142,0,75,87,92,0,142,115,105,0,142,105,138,0,148,142,138,0,148,138,145,0,154,148,145,0,154,145,151,0,158,161,154,151,0,158,151,155,0,15,20,17,0,20,15,13,19,0,34,20,19,0,34,19,32,0,69,34,32,0,69,32,66,0,75,69,66,0,75,66,73,0,87,75,73,0,87,73,79,0,115,87,79,0,115,79,105,0,113,134,143,0,174,164,134,0,185,174,134,0,134,164,143,0,143,164,149,0,173,168,163,164,0,164,163,160,153,0,164,174,173,0,149,164,153,0,178,174,180,0,174,178,173,0,203,180,174,0,174,185,203,0,191,203,185,0,191,185,189,0,203,207,186,180,0,211,203,208,0,208,203,191,0,210,203,211,212,0,210,207,203,0,180,186,181,178,0,175,178,181,0,175,171,173,178,0,168,173,171,0,212,211,216,0,213,219,216,211,0,213,211,208,0,206,209,215,208,0,208,215,213,0,208,191,195,0,205,206,208,193,0,193,208,195,0,191,189,192,0,195,191,192,0,204,192,189,201,0,209,214,215,0,192,204,205,193,0,215,218,220,219,213,0,217,215,214,0,218,215,217,0,195,192,193,0,143,113,106,0,143,106,139,0,149,143,139,0,149,139,146,0,153,149,146,0,153,146,152,0,159,160,153,152,0,159,152,156,0,134,113,106,0,134,106,131,0,185,134,131,0,185,131,183,0,189,185,183,0,189,183,188,0,200,201,189,188,0,200,188,197,0,29,33,36,0,36,33,43,55,0,8,22,10,0,28,29,36,40,0,35,27,28,40,0,10,22,27,35,0,8,10,6,5,0,5,6,3,0,7,6,10,9,0,35,21,10,0,11,9,10,21,0,40,68,35,0,53,40,36,0,59,68,40,0,59,40,53,0,53,36,62,0,62,36,55,0,53,84,61,0,59,53,61,0,84,53,62,0,59,74,68,0,61,74,59,0,86,74,61,0,61,84,86,0,86,84,101,0,114,86,101,0,11,21,16,0,4,6,7,0,2,6,4,0,1,3,6,2,0,41,55,43,0,55,41,38,50,0,62,55,50,0,62,50,57,0,84,62,57,0,84,57,76,0,101,84,76,0,101,76,94,0,114,101,94,0,114,94,103,0,14,21,16,0,21,14,12,18,0,35,21,18,0,35,18,31,0,68,35,31,0,68,31,65,0,74,68,65,0,74,65,72,0,86,74,72,0,86,72,78,0,114,86,78,0,114,78,103,0],"tags":{"tagA":0,"tagB":0}}}
Yes the green mesh is the one with the aux data. Although if it shows no aux data then I wonder if it actually got the last transaction or not? Since it crashed after that change. But I would have thought it would be in the journal file and applied even in that case; assuming the display app has that logic? I did find a dump folder and I sent you the crashes I got, Too big to post those here.
Index out of bounds.
> iTwinGeom.dll!BentleyM0200::PolyfaceQuery::ClusteredVertexDecimate(double tolerance, double minCompressionRatio, bool doNormals) Line 84 C++
iTwinVisualization.dll!Viz::Polyface::Decimate(unsigned __int64 minPointCount, double minRatio) Line 85 C++
iTwinVisualization.dll!Viz::PrimitiveGeometry::_GetPolyfaces(BentleyM0200::IFacetOptions & facetOptions, Viz::Output & output) Line 390 C++
iTwinVisualization.dll!Viz::SingularGeometry::_GetPolyfaces(double chordTolerance, Viz::NormalMode normalMode, Viz::Output & output) Line 174 C++
iTwinVisualization.dll!Viz::Geometry::GetPolyfaces(double chordTolerance, Viz::NormalMode normalMode, Viz::Output & output) Line 275 C++
iTwinVisualization.dll!Viz::Tile::MeshGenerator<Viz::QTraits>::AddMeshes(Viz::Geometry & geom, bool doRangeTest) Line 124 C++
iTwinVisualization.dll!Viz::Tile::GeometryLoader<Viz::QTraits>::GenerateGeometry() Line 74 C++
iTwinVisualization.dll!Viz::Tile::generateAndEncodeTileGeometry<Viz::QTraits>(BentleyM0200::StreamBuffer & tileBytes, Viz::Tile::LoaderContext & context) Line 316 C++
iTwinVisualization.dll!Viz::Tile::Loader::ReadFromModel() Line 339 C++
iTwinVisualization.dll!Viz::Tile::Loader::Perform() Line 182 C++
@Rock2000 your mesh has the same number of aux data indices as it does vertices. It is expected to have the same number of aux data indices as it does point indices.
The aux data indices is not the same as the point indices? I'm passing in the polyface pointIndex as the aux data indices.
I was going off the iTwin Scientific Visualization sample
If you're talking about this sample, the flat mesh has 58806 point indices, 58806 aux data indices, and 10,000 points.
The cantilever has 5688 point+aux indices, and 1424 points.
If you look at my previous screenshot (from your polyface), you've got 4124 point indices, 3093 aux data indices, and 3093 points.
The documentation is sparse and unclear, but the code appears to assume that aux data index count == point index count.
Yeah I had misread your first explanation. I thought you said aux data needed to be the same length as pointIndex. But now that I read it correctly, it is very weird because I literally pass the pointIndex as the auxIndex, so I'm not sure how it would end up as point count.
polyface.data.auxData = new PolyfaceAuxData(auxChannels, polyface.data.pointIndex);
Let me poke around a bit more. See if I can step in and see anything.
The documentation is sparse and unclear, but the code appears to assume that aux data index count == point index count.
In addition, the Polyface visitor code assumes the indices for aux data are parallel in structure to the other Polyface index arrays. In other words, the indices for a given facet are found in the same range of every index array in the Polyface. I'll try to make this clearer in the documentation.
The platform is changing the polyface data somewhere. In my sample data from aux.txt, there are 723 points and 723 pointIndex and 723 auxIndices. I save that geomStream to an element and then read that element back. The geom that is read now has 723 points, 723 auxIndices, but 964 pointIndices. I'm surprised it touched my polyface at all, but maybe that's legit? If so, it feels like there is code that tinkers with the pointIndices but doesn't adjust the auxIndices similarly.
Maybe related, I will want to compress our polyfaces as all the facet vertices are their own points right now (none shared). I was curious if the compress also correctly updated the auxIndices during this process.
Looks like iTwinjs transfers AuxData indices verbatim to flatbuffer bytes, without transforming them into 1-based, 0-terminated format like it does for the Polyface point/normal/param/color indices.
I believe this was a mistake.
When that polyface flatbuffer is deserialized into an imodel-native polyface, it's probably missing the zero after each face loop that the other polyface index arrays have. This is what causes PolyfaceQuery::ClusteredVertexDecimate to crash.
I propose changing the Polyface AuxData index array FB format to be 1-based 0-terminated, exactly how we persist the other polyface index arrays. In native/iTwinjs FB deserialization logic, it should be possible to come up with heuristics to detect invalid AuxData index blocking in existing flatbuffers, and to use the point indices to recover the correct blocking. Serialization would be changed to always write the correct blocking.
As for compress, PolyfaceData.compress
does not change the index arrays' size, nor does it compress AuxData. Theoretically it could compress AuxData if there were exactly one channel, but it is not possible in general to compress multi-channel AuxData since all channels share the same indices.
Here's a file containing a polyface with aux data that was created using the existing TypeScript API AnalysisExample.zip, to test against any changes you make to the persistence/serialization layer.
Here's a file containing a polyface with aux data that was created using the existing TypeScript API AnalysisExample.zip, to test against any changes you make to the persistence/serialization layer.
Actually, it looks like the native API must have written the flatbuffer bits stored in this bim file, as the mesh in this file has valid aux data. (It's the TypeScript API that has the AuxData serialization error.) I am creating other test cases, though, and using the sandbox aux data for one of them.
I literally pass the pointIndex as the auxIndex I was curious if the compress also correctly updated the auxIndices during this process.
FYI @Rock2000 if you plan on compressing a mesh that has PolyfaceAuxData
comprised of exactly one AuxChannelData
, then you should pass a clone of pointIndex as the aux data indices. For the PR, I added aux data compression to PolyfaceData.compress
for this very specific scenario, and you'll want compress to remap those two index arrays separately.
TypeScript and imodel-native PRs are merged. Keeping this issue open to track:
We are creating geometric elements that represent a 3d surface. We tried to add auxChannel data in order to use the Scientific Visualization feature, but after saving the element with the auxChannel data the platform crashes.
To Reproduce Attached is the mesh with aux data that was used. The aux data in this test is Scalar data that is simply zeros. Save this polyface to a geomstream. The element update call will succeed, but afterwards the platform will disappear. I presume when the tiles are being regenerated.
aux.txt
Desktop (please complete the applicable information):