iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
620 stars 210 forks source link

Modified element graphics are sometimes clipped #7211

Open pmconne opened 1 month ago

pmconne commented 1 month ago

Describe the bug The temporary graphics drawn during a GraphicalEditingScope to represent modified elements are sometimes partially clipped. Filed on behalf of @bbastings.

To Reproduce Steps to reproduce the behavior:

Replace MoveElementTool in itwinjs-core\test-apps\display-test-app\src\frontend\EditingTools.ts with this (just so you don’t need to register another tool):

export class MoveElementTool extends Tool {
  public static override toolId = "MoveElement";

  public override async run(): Promise<boolean> {
    if (!IModelApp.viewManager.selectedView)
      return false;

    const imodel = IModelApp.viewManager.selectedView.iModel;
    if (!imodel.isBriefcaseConnection())
      return false;

    await startCommand(imodel);

    const id = "0x68b";
    const info = await basicManipulationIpc.requestElementGeometry(id);
    if (undefined === info)
      return false;

    const it = new ElementGeometry.Iterator(info);
    it.requestWorldCoordinates();
    let curveData;

    for (const entry of it) {
      curveData = { geom: entry.toGeometryQuery() as CurveChain, params: entry.geomParams };
      break;
    }

    if (undefined === curveData?.geom)
      return false;

    const result = CurveChainWithDistanceIndex.createCapture(curveData.geom).clonePartialCurve(0.9325068888021624, 1.0);
    if (undefined === result)
      return false;

    const props = await imodel.elements.loadProps(id) as GeometricElementProps;
    if (undefined === props.placement)
      return false;

    const builder = new ElementGeometry.Builder();
    builder.setLocalToWorldFromPlacement(props.placement);

    if (!builder.appendGeometryParamsChange(curveData.params))
      return false;

    if (!builder.appendGeometryQuery(Path.createArray(result.path.children)))
      return false;

    const dataEntry = { format: "flatbuffer", data: builder.entries };
    props.elementGeometryBuilderParams = { entryArray: dataEntry.data };

    await basicManipulationIpc.updateGeometricElement(props);
    await imodel.saveChanges();
    return true;
  }
}

Open the attached .bim file for editing in display-test-app and recall the attached saved view. Key in dta edit then dta move element.

Expected behavior

image

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the applicable information):

Additional context Add any other context about the problem here.

NoScaleBRep_EditTest_Copy4.zip