Browse Source

fix examples

Former-commit-id: b633956bd53d3af85673ab107a68d333dc10ca8d
Alec Jacobson 11 năm trước cách đây
mục cha
commit
2c48365937

+ 4 - 3
examples/intersections/example.cpp

@@ -477,9 +477,10 @@ void color_selfintersections(
   using namespace Eigen;
   MatrixXd SV;
   MatrixXi SF,IF;
+  VectorXi J,IM;
   SelfintersectParam params;
   params.detect_only = true;
-  selfintersect(V,F,params,SV,SF,IF);
+  selfintersect(V,F,params,SV,SF,IF,J,IM);
   C.resize(F.rows(),3);
   C.col(0).setConstant(0.4);
   C.col(1).setConstant(0.8);
@@ -622,13 +623,13 @@ int main(int argc, char * argv[])
     return true;
   };
 
-  if(!read_triangle_mesh(filename,V,F,N))
+  if(!read(filename,V,F,N))
   {
     return 1;
   }
   if(has_other)
   {
-    if(!read_triangle_mesh(argv[2],U,G,W))
+    if(!read(argv[2],U,G,W))
     {
       return 1;
     }

+ 4 - 2
examples/patches/example.cpp

@@ -25,7 +25,7 @@
 #include <igl/boost/components.h>
 #include <igl/boost/bfs_orient.h>
 #include <igl/orient_outward.h>
-#include <igl/embree/orient_outward_ao.h>
+#include <igl/embree/reorient_facets_raycast.h>
 #include <igl/unique_simplices.h>
 #include <igl/C_STR.h>
 #include <igl/write_triangle_mesh.h>
@@ -567,9 +567,11 @@ void init_patches()
   switch(orient_method)
   {
     case ORIENT_METHOD_AO:
+    {
       cout<<"orient_outward_ao()"<<endl;
-      orient_outward_ao(V,F,CC,100, F.rows() * 100,F,I);
+      reorient_facets_raycast(V,F,F,I);
       break;
+    }
     case ORIENT_METHOD_OUTWARD:
     default:
       cout<<"orient_outward()"<<endl;

+ 3 - 3
examples/patches/temp.rbr

@@ -1,7 +1,7 @@
-camera_rotation: TW_TYPE_QUAT4D 0.221720768269005 -0.655276665457443 -0.211493904735977 0.690451099560792
+camera_rotation: TW_TYPE_QUAT4D 0.152085375459856 -0.590495112202136 -0.114509193857288 0.784266029838584
 center_type: CenterType orbit
-wireframe_visible: TW_TYPE_BOOLCPP 0
+wireframe_visible: TW_TYPE_BOOLCPP 1
 fill_visible: TW_TYPE_BOOLCPP 1
-rotation_type: RotationType igl_trackball
+rotation_type: RotationType two-axis-valuator-fixed-up
 orient_method: OrientMethod ambient-occlusion
 

+ 34 - 0
include/igl/embree/reorient_facets_raycast.cpp

@@ -218,6 +218,40 @@ IGL_INLINE void igl::reorient_facets_raycast(
   if (is_verbose) cout << "done!" << endl;
 }
 
+template <
+  typename DerivedV, 
+  typename DerivedF, 
+  typename DerivedFF,
+  typename DerivedI>
+IGL_INLINE void igl::reorient_facets_raycast(
+  const Eigen::PlainObjectBase<DerivedV> & V,
+  const Eigen::PlainObjectBase<DerivedF> & F,
+  Eigen::PlainObjectBase<DerivedFF> & FF,
+  Eigen::PlainObjectBase<DerivedI> & I)
+{
+  const int rays_total = F.rows()*100;
+  const int rays_minimum = 10;
+  const bool facet_wise = false;
+  const bool use_parity = false;
+  const bool is_verbose = false;
+  Eigen::VectorXi C;
+  reorient_facets_raycast(
+    V,F,rays_total,rays_minimum,facet_wise,use_parity,is_verbose,I,C);
+  // Conservative in case FF = F
+  FF.conservativeResize(F.rows(),F.cols());
+  for(int i = 0;i<I.rows();i++)
+  {
+    if(I(i))
+    {
+      FF.row(i) = (F.row(i).reverse()).eval();
+    }else
+    {
+      FF.row(i) = F.row(i);
+    }
+  }
+}
+
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
+template void igl::reorient_facets_raycast<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 31 - 11
include/igl/embree/reorient_facets_raycast.h

@@ -11,20 +11,22 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Orient each component (identified by C) of a mesh (V,F) using ambient occlusion 
-  // such that the front side is less occluded than back side
+  // Orient each component (identified by C) of a mesh (V,F) using ambient
+  // occlusion such that the front side is less occluded than back side
   //
   // Inputs:
-  //   V                            #V by 3 list of vertex positions
-  //   F                            #F by 3 list of triangle indices
-  //   rays_total                   Total number of rays that will be shot
-  //   rays_minimum                 Minimum number of rays that each patch should receive
-  //   faceg_wise                   Decision made for each face independently, no use of patches (i.e., each face is treated as a patch)
-  //   use_parity                   Use parity mode
-  //   is_verbose                   Verbose output to cout
+  //   V  #V by 3 list of vertex positions
+  //   F  #F by 3 list of triangle indices
+  //   rays_total  Total number of rays that will be shot
+  //   rays_minimum  Minimum number of rays that each patch should receive
+  //   facet_wise  Decision made for each face independently, no use of patches
+  //     (i.e., each face is treated as a patch)
+  //   use_parity  Use parity mode
+  //   is_verbose  Verbose output to cout
   // Outputs:
-  //   I                            #F list of whether face has been flipped
-  //   C                            #F list of patch ID
+  //   I  #F list of whether face has been flipped
+  //   C  #F list of patch ID (outpute of bfs_orient
+  //     > manifold patches
   template <
     typename DerivedV, 
     typename DerivedF, 
@@ -40,6 +42,24 @@ namespace igl
     bool is_verbose,
     Eigen::PlainObjectBase<DerivedI> & I,
     Eigen::PlainObjectBase<DerivedC> & C);
+  // Outputs:
+  //   FF  #F by 3 list of reoriented faces
+  // Defaults:
+  //   rays_total = F.rows()*100;
+  //   rays_minimum = 10;
+  //   facet_wise = false;
+  //   use_parity = false;
+  //   is_verbose = false;
+  template <
+    typename DerivedV, 
+    typename DerivedF, 
+    typename DerivedFF,
+    typename DerivedI>
+  IGL_INLINE void reorient_facets_raycast(
+    const Eigen::PlainObjectBase<DerivedV> & V,
+    const Eigen::PlainObjectBase<DerivedF> & F,
+    Eigen::PlainObjectBase<DerivedFF> & FF,
+    Eigen::PlainObjectBase<DerivedI> & I);
 };
 
 #ifdef IGL_HEADER_ONLY

+ 1 - 1
include/igl/orient_outward.h

@@ -17,7 +17,7 @@ namespace igl
   // Inputs:
   //   V  #V by 3 list of vertex positions
   //   F  #F by 3 list of triangle indices
-  //   C  #F list of components
+  //   C  #F list of components (output of manifold_patches)
   // Outputs:
   //   FF  #F by 3 list of new triangle indices such that FF(~I,:) = F(~I,:) and
   //     FF(I,:) = fliplr(F(I,:)) (OK if &FF = &F)