Browse Source

template instanciation

Former-commit-id: 85c4923b4898f4c8f2a018ca5cfd3d2e47648deb
Alec Jacobson (jalec 11 years ago
parent
commit
2bf18e23d7

+ 14 - 0
.hgignore

@@ -23,3 +23,17 @@ external/embree/doc/latex/*
 .DS_Store
 libigl.zip
 *tags
+*.exe
+*.pdb
+*.sdf
+*.suo
+*.ilk
+*.log
+*.tlog
+Debug/
+Release/
+*.orig
+*.user
+*.vsp
+*.opensdf
+*.psess

+ 19 - 17
examples/patches/example.vcxproj

@@ -16,48 +16,50 @@
     <RootNamespace>example</RootNamespace>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
+    <UseDebugLibraries>false</UseDebugLibraries>
     <PlatformToolset>v110</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>false</UseDebugLibraries>
     <PlatformToolset>v110</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <WholeProgramOptimization>false</WholeProgramOptimization>
     <CharacterSet>MultiByte</CharacterSet>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
   <ImportGroup Label="ExtensionSettings">
   </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
     <IncludePath>C:\Users\kenshi\dev\igl_hg\ext_toolboxes\embree-1.1beta\common;$(IncludePath)</IncludePath>
     <OutDir>$(ProjectDir)\</OutDir>
-    <TargetName>$(ProjectName)d</TargetName>
   </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>false</LinkIncremental>
     <IncludePath>C:\Users\kenshi\dev\igl_hg\ext_toolboxes\embree-1.1beta\common;$(IncludePath)</IncludePath>
     <OutDir>$(ProjectDir)\</OutDir>
+    <TargetName>$(ProjectName)d</TargetName>
   </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
       <PrecompiledHeader>
       </PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>IGL_HEADER_ONLY;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>IGL_HEADER_ONLY;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <AdditionalIncludeDirectories>..\..\external\embree;..\..\external\embree\embree;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <OpenMPSupport>true</OpenMPSupport>
     </ClCompile>
@@ -66,7 +68,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
   </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <WarningLevel>Level3</WarningLevel>
       <PrecompiledHeader>
@@ -78,6 +80,7 @@
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <AdditionalIncludeDirectories>..\..\external\embree;..\..\external\embree\embree;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <OpenMPSupport>true</OpenMPSupport>
+      <WholeProgramOptimization>false</WholeProgramOptimization>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>
@@ -87,7 +90,6 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\..\kt84\dbg.cpp" />
     <ClCompile Include="..\..\external\embree\embree\builders\heuristic_binning.cpp" />
     <ClCompile Include="..\..\external\embree\embree\builders\heuristic_spatial.cpp" />
     <ClCompile Include="..\..\external\embree\embree\builders\primrefgen.cpp" />

+ 0 - 1
examples/patches/example.vcxproj.filters

@@ -143,7 +143,6 @@
     <ClCompile Include="..\..\external\embree\embree\embree.cpp">
       <Filter>embree</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\kt84\dbg.cpp" />
   </ItemGroup>
   <ItemGroup>
     <Filter Include="igl">

+ 13 - 4
include/igl/embree/orient_outward_ao.cpp

@@ -5,6 +5,8 @@
 #include "EmbreeIntersector.h"
 #include <iostream>
 #include <random>
+#include <ctime>
+#include <limits>
 
 template <
   typename DerivedV, 
@@ -47,7 +49,11 @@ IGL_INLINE void igl::orient_outward_ao(
   // face area
   Matrix<typename DerivedV::Scalar,Dynamic,1> A;
   doublearea(V,F,A);
-  double area_min = A.minCoeff();
+  double area_min = numeric_limits<double>::max();
+  for (int f = 0; f < m; ++f)
+  {
+    area_min = A(f) != 0 && A(f) < area_min ? A(f) : area_min;
+  }
   double area_total = A.sum();
   
   // determine number of rays per component according to its area
@@ -68,7 +74,7 @@ IGL_INLINE void igl::orient_outward_ao(
   cout << "generating rays... ";
   uniform_real_distribution<float> rdist;
   mt19937 prng;
-  prng.seed(0);
+  prng.seed(time(nullptr));
   vector<int     > ray_face;
   vector<Vector3f> ray_ori;
   vector<Vector3f> ray_dir;
@@ -77,6 +83,10 @@ IGL_INLINE void igl::orient_outward_ao(
   ray_dir .reserve(total_num_rays);
   for (int c = 0; c < num_cc; ++c)
   {
+    if (area_per_component[c] == 0)
+    {
+      continue;
+    }
     vector<int> CF;     // set of faces per component
     vector<int> CF_area;
     for (int f = 0; f < m; ++f)
@@ -92,7 +102,7 @@ IGL_INLINE void igl::orient_outward_ao(
     discrete_distribution<int> ddist(CF.size(), 0, CF.size(), ddist_func);      // simple ctor of (Iter, Iter) not provided by the stupid VC11 impl...
     for (int i = 0; i < num_rays_per_component[c]; ++i)
     {
-      int f     = CF[ddist(prng)];    // select face with probability proportional to face area
+      int f    = CF[ddist(prng)];    // select face with probability proportional to face area
       float t0 = rdist(prng);        // random barycentric coordinate
       float t1 = rdist(prng);
       float t2 = rdist(prng);
@@ -104,7 +114,6 @@ IGL_INLINE void igl::orient_outward_ao(
                  + t1 * V.row(F(f,1)).template cast<float>().eval()
                  + t2 * V.row(F(f,2)).template cast<float>().eval();
       Vector3f n = N.row(f).cast<float>();
-      assert(n != Vector3f::Zero());
       // random direction in hemisphere around n (avoid too grazing angle)
       Vector3f d;
       while (true) {