瀏覽代碼

fix initialization bugs in orient_outward.cpp

Former-commit-id: b600f4ba10a7a3accfa968caf4241eb5909a100b
Alec Jacobson (jalec 11 年之前
父節點
當前提交
d16922f7e2
共有 3 個文件被更改,包括 37 次插入3 次删除
  1. 31 2
      examples/patches/example.cpp
  2. 3 1
      examples/patches/temp.rbr
  3. 3 0
      include/igl/orient_outward.cpp

+ 31 - 2
examples/patches/example.cpp

@@ -62,6 +62,9 @@ enum RotationType
 std::stack<State> undo_stack;
 std::stack<State> redo_stack;
 
+bool wireframe_visible = false;
+bool fill_visible = true;
+
 bool is_rotating = false;
 int down_x,down_y;
 igl::Camera down_camera;
@@ -269,7 +272,25 @@ void display()
   // Set material properties
   glEnable(GL_COLOR_MATERIAL);
   glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
-  draw_mesh(V,F,s.N,C);
+  if(wireframe_visible)
+  {
+    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
+    if(fill_visible)
+    {
+      glColor3f(0,0,0);
+      draw_mesh(V,F,s.N);
+    }else
+    {
+      draw_mesh(V,F,s.N,C);
+    }
+  }
+  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
+  if(fill_visible)
+  {
+    glEnable(GL_POLYGON_OFFSET_FILL); // Avoid Stitching!
+    glPolygonOffset(1.0, 0);
+    draw_mesh(V,F,s.N,C);
+  }
 
   pop_object();
 
@@ -394,6 +415,7 @@ void mouse_drag(int mouse_x, int mouse_y)
   using namespace igl;
   using namespace std;
   using namespace Eigen;
+  bool tw_using = TwMouseMotion(mouse_x,mouse_y);
 
   if(is_rotating)
   {
@@ -647,7 +669,7 @@ int main(int argc, char * argv[])
   }
   // Create a tweak bar
   rebar.TwNewBar("TweakBar");
-  rebar.TwAddVarCB("camera_rotation", TW_TYPE_QUAT4D, set_camera_rotation,get_camera_rotation, NULL, "open");
+  rebar.TwAddVarCB("camera_rotation", TW_TYPE_QUAT4D, set_camera_rotation,get_camera_rotation, NULL, "open readonly=true");
   TwEnumVal RotationTypesEV[NUM_ROTATION_TYPES] = 
   {
     {ROTATION_TYPE_IGL_TRACKBALL,"igl trackball"},
@@ -660,8 +682,15 @@ int main(int argc, char * argv[])
         NUM_ROTATION_TYPES);
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
+  rebar.TwAddVarRW("wireframe_visible",TW_TYPE_BOOLCPP,&wireframe_visible,"key=l");
+  rebar.TwAddVarRW("fill_visible",TW_TYPE_BOOLCPP,&fill_visible,"key=f");
   rebar.load(REBAR_NAME);
 
+
+  animation_from_quat = Quaterniond(1,0,0,0);
+  copy(s.camera.rotation,s.camera.rotation+4,animation_to_quat.coeffs().data());
+  animation_start_time = get_seconds();
+
   // Init antweakbar
   glutInitDisplayString( "rgba depth double samples>=8 ");
   glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);

+ 3 - 1
examples/patches/temp.rbr

@@ -1,3 +1,5 @@
-camera_rotation: TW_TYPE_QUAT4D -0.0878474 0.235658 0.0213947 -0.967621
+wireframe_visible: TW_TYPE_BOOLCPP 1
+fill_visible: TW_TYPE_BOOLCPP 1
+camera_rotation: TW_TYPE_QUAT4D 0.0504783 -0.948499 -0.242586 0.197368
 rotation_type: RotationType two axis fixed up
 

+ 3 - 0
include/igl/orient_outward.cpp

@@ -2,6 +2,7 @@
 #include "per_face_normals.h"
 #include "barycenter.h"
 #include "doublearea.h"
+#include "matlab_format.h"
 #include <iostream>
 
 template <
@@ -39,6 +40,8 @@ IGL_INLINE void igl::orient_outward(
   barycenter(V,F,BC);
   doublearea(V,F,A);
   BCmean.setConstant(num_cc,3,0);
+  dot.setConstant(num_cc,1,0);
+  totA.setConstant(num_cc,1,0);
   // loop over faces
   for(int f = 0;f<m;f++)
   {