Commit 762be9ed authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '184-move-useOctree-to-GUI' into 'master'

Move useOctree variable to GUI and create it's own check box

Closes #184

See merge request grp-fidentis/analyst2!201
parents 452054af 7c26e69c
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@
              <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
              <EmptySpace max="-2" attributes="0"/>
              <Component id="jPanel3" min="-2" max="-2" attributes="0"/>
              <EmptySpace pref="99" max="32767" attributes="0"/>
              <EmptySpace pref="146" max="32767" attributes="0"/>
          </Group>
      </Group>
    </DimensionLayout>
@@ -79,6 +79,7 @@
                          <Component id="spinSlider1" min="-2" max="-2" attributes="0"/>
                      </Group>
                      <Component id="jCheckBox4" alignment="0" min="-2" max="-2" attributes="0"/>
                      <Component id="useRayTracingCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
                  </Group>
                  <EmptySpace max="32767" attributes="0"/>
              </Group>
@@ -105,7 +106,9 @@
                  <Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
                  <EmptySpace max="-2" attributes="0"/>
                  <Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
                  <EmptySpace type="separate" max="-2" attributes="0"/>
                  <EmptySpace max="-2" attributes="0"/>
                  <Component id="useRayTracingCheckBox" min="-2" max="-2" attributes="0"/>
                  <EmptySpace max="-2" attributes="0"/>
                  <Group type="103" groupAlignment="3" attributes="0">
                      <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
                      <Component id="jButton5" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -180,6 +183,16 @@
        </Component>
        <Component class="cz.fidentis.analyst.core.SpinSlider" name="spinSlider1">
        </Component>
        <Component class="javax.swing.JCheckBox" name="useRayTracingCheckBox">
          <Properties>
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
              <ResourceString bundle="cz/fidentis/analyst/batch/Bundle.properties" key="BatchPanel.useRayTracingCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
            </Property>
          </Properties>
          <Events>
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="useRayTracingCheckBoxActionPerformed"/>
          </Events>
        </Component>
      </SubComponents>
    </Container>
    <Container class="javax.swing.JPanel" name="jPanel2">
+80 −55
Original line number Diff line number Diff line
@@ -232,6 +232,15 @@ public class BatchPanel extends ControlPanel {
        return this.jCheckBox2.isSelected();
    }

    /**
     * Determines whether to use ray tracing in AVG face computation
     *
     * @return if {@code true}, ray tracing will be used in AVG face computation
     */
    public boolean useRayTracing() {
        return this.useRayTracingCheckBox.isSelected();
    }

    /**
     * Returns selected similarity strategy
     * @return selected similarity strategy
@@ -319,6 +328,7 @@ public class BatchPanel extends ControlPanel {
        jCheckBox4 = new javax.swing.JCheckBox();
        jButton5 = new javax.swing.JButton();
        spinSlider1 = new cz.fidentis.analyst.core.SpinSlider();
        useRayTracingCheckBox = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox<>();
@@ -367,6 +377,13 @@ public class BatchPanel extends ControlPanel {
        org.openide.awt.Mnemonics.setLocalizedText(jButton5, org.openide.util.NbBundle.getMessage(BatchPanel.class, "BatchPanel.jButton5.text")); // NOI18N
        jButton5.setEnabled(false);

        org.openide.awt.Mnemonics.setLocalizedText(useRayTracingCheckBox, org.openide.util.NbBundle.getMessage(BatchPanel.class, "BatchPanel.useRayTracingCheckBox.text")); // NOI18N
        useRayTracingCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                useRayTracingCheckBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
@@ -385,7 +402,8 @@ public class BatchPanel extends ControlPanel {
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(spinSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jCheckBox4))
                    .addComponent(jCheckBox4)
                    .addComponent(useRayTracingCheckBox))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
@@ -406,7 +424,9 @@ public class BatchPanel extends ControlPanel {
                .addComponent(jCheckBox1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBox3)
                .addGap(18, 18, 18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(useRayTracingCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton5))
@@ -527,7 +547,7 @@ public class BatchPanel extends ControlPanel {
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(99, Short.MAX_VALUE))
                .addContainerGap(146, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

@@ -543,6 +563,10 @@ public class BatchPanel extends ControlPanel {
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void useRayTracingCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useRayTracingCheckBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_useRayTracingCheckBoxActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
@@ -564,6 +588,7 @@ public class BatchPanel extends ControlPanel {
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private cz.fidentis.analyst.core.SpinSlider spinSlider1;
    private javax.swing.JCheckBox useRayTracingCheckBox;
    // End of variables declaration//GEN-END:variables

}
+10 −12
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
    private static final double ICP_ERROR = 0.3; //0.05;
    private static final int ICP_ITERS = 100;

    private final boolean useOctree = false; // todo delete this and move this to gui

    private HumanFace avgFace;
    private final ProgressDialog progressDialog;
    private final BatchPanel controlPanel;
@@ -142,24 +140,24 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
                    //System.out.println(sampling);
                }
                if (computeAvgFace) { // AVG template face
                    if (useOctree) {
                    if (controlPanel.useRayTracing()) {
                        octreeConstructionTime.start();
                        face.computeOctree(false);
                        face.computeOctree(computeICP); // force octree re-computation of ICP transformed face
                        octreeConstructionTime.stop();
                    } else {
                        kdTreeConstructionTime.start();
                        face.computeKdTree(computeICP); // if transformed by ICP, force k-d tree re-computation
                        face.computeKdTree(computeICP); // force k-d tree re-computation of ICP transformed face
                        kdTreeConstructionTime.stop();
                    }

                    avgFaceComputationTime.start();
                    if (useOctree && avgFaceConstructorOctree == null) {
                    if (controlPanel.useRayTracing() && avgFaceConstructorOctree == null) {
                        avgFaceConstructorOctree = new AvgFaceConstructorOctree(initFace.getMeshModel());
                    }
                    if (!useOctree && avgFaceConstructor == null) {
                    if (!controlPanel.useRayTracing() && avgFaceConstructor == null) {
                        avgFaceConstructor = new AvgFaceConstructor(initFace.getMeshModel());
                    }
                    if (useOctree) {
                    if (controlPanel.useRayTracing()) {
                        face.getOctree().accept(avgFaceConstructorOctree);
                    } else {
                        face.getKdTree().accept(avgFaceConstructor);
@@ -168,7 +166,7 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
                }

                //face.removeKdTree(); // preserve k-d tree for the similarity computation phase
                if (useOctree) {
                if (controlPanel.useRayTracing()) {
                    face.removeOctree();
                }
                publish(face);       // update progress bar and possibly render the transformed face
@@ -183,7 +181,7 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
        if (computeAvgFace) {
            File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".obj");
            tempFile.deleteOnExit();
            if (useOctree) {
            if (controlPanel.useRayTracing()) {
                avgFace = new HumanFace(avgFaceConstructorOctree.getAveragedMeshModel(), tempFile.getCanonicalPath());
            } else {
                avgFace = new HumanFace(avgFaceConstructor.getAveragedMeshModel(), tempFile.getCanonicalPath());
@@ -237,7 +235,7 @@ public class IcpTask extends SwingWorker<MeshModel, HumanFace> {
        Logger.print(icpComputationTime.toString());
        Logger.print(loadTime.toString());
        Logger.print(kdTreeConstructionTime.toString());
        if (useOctree) {
        if (controlPanel.useRayTracing()) {
            Logger.print(octreeConstructionTime.toString());
        }
        Logger.print(totalTime.toString());
+1 −0
Original line number Diff line number Diff line
@@ -14,3 +14,4 @@ BatchPanel.jButtonInfo1.text=
BatchPanel.jButton6.text=Export results
BatchPanel.jCheckBox5.text=HD auto-crop
BatchPanel.jButtonInfo2.text=
BatchPanel.useRayTracingCheckBox.text=Use Ray Tracing in AVG face calculation [experimental]