All Downloads are FREE. Search and download functionalities are using the official Maven repository.

one.empty3.gui.MeshEditorBean Maven / Gradle / Ivy

There is a newer version: 2024.5.10
Show newest version
/*
 * Copyright (c) 2022-2023. Manuel Daniel Dahmen
 *
 *
 *    Copyright 2012-2023 Manuel Daniel Dahmen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package one.empty3.gui;

import one.empty3.library.CopyRepresentableError;
import one.empty3.library.Point3D;
import one.empty3.library.Representable;
import one.empty3.library.StructureMatrix;
import one.empty3.library.core.nurbs.CourbeParametriquePolynomiale;
import one.empty3.library.core.nurbs.SurfaceParametriquePolynomialeBezier;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MeshEditorBean {
    public static final int MESH_EDITOR_ParametricSurface = 0;
    public static final int MESH_EDITOR_Sphere = 1;
    public static final int MESH_EDITOR_Cube = 2;
    public static final int MESH_EDITOR_Plane = 4;
    private static final int OP_SELECTION_TRANSLATION = 0;
    private static final int OP_NEW_ROW_COL           = 1;
    private static final int OP_TRANSLATE_SURFACE     = 2;


    private int meshType;
    private boolean activateMarkers = false;
    private boolean selection;
    private boolean translation;
    private boolean newPoint;
    private boolean newRow;
    private boolean newCol;
    private double translateXonS;
    private double translateYonS;
    private double translateZonS;
    private boolean translateOnSuv;
    private double translateOnSu;
    private double translateOnSv;
    private ArrayList inSelection = new ArrayList<>();
    private HashMap inSelectionMoves;
    private int opType = 0;

    public static class ReplaceMatrix {
        private Representable representable;
        protected StructureMatrix in;
        protected StructureMatrix outs;

        public ReplaceMatrix(StructureMatrix origin, Representable r) {
            this.in = origin;
            try {
                this.outs = origin.copy();
                this.representable = r;
            } catch (IllegalAccessException | CopyRepresentableError | InstantiationException e) {
                e.printStackTrace();
            }
        }

        public boolean updateIjp(Point3D p, int i, int j) {
            if (i >= 0 && j >= 0 && outs.getDim() == 2) {
                outs.setElem(p, i, j);
                return true;
            }
            if (i >= 0 && j < 0 && outs.getDim() == 1) {
                outs.setElem(p, i);
                return true;
            }
            if (i < 0 && j < 0 && outs.getDim() == 0) {
                outs.setElem(p);
                return true;
            }
            return false;
        }

        public Representable getRepresentable() {
            return representable;
        }

        public void setRepresentable(Representable representable) {
            this.representable = representable;
        }

        public StructureMatrix getIn() {
            return in;
        }

        public void setIn(StructureMatrix in) {
            this.in = in;
        }

        public StructureMatrix getOuts() {
            return outs;
        }

        public void setOuts(StructureMatrix outs) {
            this.outs = outs;
        }

        @Override
        public String toString() {
            return "ReplaceMatrix{" +
                    "representable=" + representable +
                    ", in=" + in +
                    ", outs=" + outs +
                    '}';
        }
    }
    protected ArrayList replaces = new ArrayList<>();


    public ArrayList getReplaces() {
        return replaces;
    }

    public void setReplaces(ArrayList replaces) {
        this.replaces = replaces;
    }

    private Main main;

    public void setMain(Main main) {
        this.main = main;
    }


    public void actionOk() {
       switch(getOperationType()) {
           case OP_SELECTION_TRANSLATION:
               getReplaces().forEach(replaceMatrix -> {
                   Logger.getAnonymousLogger().log(Level.INFO, "Replace points from ("+replaceMatrix.representable.getClass()+") of string {\n"+replaceMatrix.representable.toString()+"+\n}");
                   if(replaceMatrix.representable instanceof SurfaceParametriquePolynomialeBezier) {
                       SurfaceParametriquePolynomialeBezier surface = (SurfaceParametriquePolynomialeBezier) replaceMatrix.representable;
                       for(int i=0; i inSelection) {
        this.inSelection = inSelection;
    }

    public ArrayList getInSelection() {
        return inSelection;
    }

    public HashMap getInSelectionMoves() {
        return inSelectionMoves;
    }

    public void setInSelectionMoves(HashMap inSelectionMoves) {
        this.inSelectionMoves = inSelectionMoves;
    }

    public void setOpType(int i) {
        this.opType = i;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy