vcglib icon indicating copy to clipboard operation
vcglib copied to clipboard

How can I use it to work on release X64 Visual Studio machine

Open bqFirst opened this issue 7 years ago • 10 comments

bqFirst avatar Apr 14 '17 07:04 bqFirst

What do you mean? Can you elaborate?

cignoni avatar Apr 14 '17 09:04 cignoni

I used the function:"samplePoissonDisk" (vs2013,release,x64) , after I clicked " run" button (visual studio 2013), the visual studio was in a state of "Being generated code" and it would seem not to proceed.But this is not a problem with the mode debug, win32

bqFirst avatar Apr 14 '17 10:04 bqFirst

I found the problem only happened in the visual studio with release mode.

bqFirst avatar Apr 14 '17 10:04 bqFirst

Can you show the code where is it happening?

cignoni avatar Apr 14 '17 10:04 cignoni

The problem occurred in "vcg::tri::io::Importer<MyMesh>::Open(m, ply_file_name.c_str())" and the problem is solved by using "vcg::tri::io::ImporterPLY<MyMesh>::Open(m, ply_file_name.c_str())". Note:m is my defined mesh and ply_file_name is a mesh file.

Thank you!

bqFirst avatar Apr 16 '17 14:04 bqFirst

yes, but without the context (the whole code) it is really hard to understand what is happening to you.

cignoni avatar Apr 16 '17 21:04 cignoni

Dear @cignoni and @wangwei19900806:

I have the same issue. Visual Studio 2017 Community edition hangs when the project is built in Release mode. It freezes when the compiler reaches to "Generating Code". It does not have any issue with Debug x86 or x64. The problem is with the Release mode (x86/x64 both does not proceed). What I ended up with is to break the Build from the Build menu (Ctrl+Break).

Here is the project settings:

`

<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ItemGroup Label="ProjectConfigurations">

    <ProjectConfiguration Include="Debug|Win32">

      <Configuration>Debug</Configuration>

      <Platform>Win32</Platform>

    </ProjectConfiguration>

    <ProjectConfiguration Include="Release|Win32">

      <Configuration>Release</Configuration>

      <Platform>Win32</Platform>

    </ProjectConfiguration>

    <ProjectConfiguration Include="Debug|x64">

      <Configuration>Debug</Configuration>

      <Platform>x64</Platform>

    </ProjectConfiguration>

    <ProjectConfiguration Include="Release|x64">

      <Configuration>Release</Configuration>

      <Platform>x64</Platform>

    </ProjectConfiguration>

  </ItemGroup>

  <PropertyGroup Label="Globals">

    <VCProjectVersion>15.0</VCProjectVersion>

    <ProjectGuid>{20C563C9-4644-487E-8345-1913A08A0C1A}</ProjectGuid>

    <Keyword>Win32Proj</Keyword>

    <RootNamespace>MeshlabInterface</RootNamespace>

    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>

  </PropertyGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">

    <ConfigurationType>Application</ConfigurationType>

    <UseDebugLibraries>true</UseDebugLibraries>

    <PlatformToolset>v141</PlatformToolset>

    <CharacterSet>Unicode</CharacterSet>

  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">

    <ConfigurationType>Application</ConfigurationType>

    <UseDebugLibraries>false</UseDebugLibraries>

    <PlatformToolset>v141</PlatformToolset>

    <WholeProgramOptimization>true</WholeProgramOptimization>

    <CharacterSet>Unicode</CharacterSet>

  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">

    <ConfigurationType>Application</ConfigurationType>

    <UseDebugLibraries>true</UseDebugLibraries>

    <PlatformToolset>v141</PlatformToolset>

    <CharacterSet>Unicode</CharacterSet>

  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">

    <ConfigurationType>Application</ConfigurationType>

    <UseDebugLibraries>false</UseDebugLibraries>

    <PlatformToolset>v141</PlatformToolset>

    <WholeProgramOptimization>true</WholeProgramOptimization>

    <CharacterSet>Unicode</CharacterSet>

  </PropertyGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

  <ImportGroup Label="ExtensionSettings">

  </ImportGroup>

  <ImportGroup Label="Shared">

  </ImportGroup>

  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|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'">

    <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)'=='Debug|x64'">

    <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|x64'">

    <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>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

    <LinkIncremental>true</LinkIncremental>

  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

    <LinkIncremental>false</LinkIncremental>

  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

    <LinkIncremental>false</LinkIncremental>

  </PropertyGroup>

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

    <ClCompile>

      <PrecompiledHeader>Use</PrecompiledHeader>

      <WarningLevel>Level3</WarningLevel>

      <Optimization>Disabled</Optimization>

      <SDLCheck>true</SDLCheck>

      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

      <ConformanceMode>true</ConformanceMode>

      <AdditionalIncludeDirectories>C:\Users\falah\Desktop\vcglib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

    </ClCompile>

    <Link>

      <SubSystem>Console</SubSystem>

      <GenerateDebugInformation>true</GenerateDebugInformation>

    </Link>

  </ItemDefinitionGroup>

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

    <ClCompile>

      <PrecompiledHeader>Use</PrecompiledHeader>

      <WarningLevel>Level3</WarningLevel>

      <Optimization>Disabled</Optimization>

      <SDLCheck>true</SDLCheck>

      <PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

      <ConformanceMode>true</ConformanceMode>

      <AdditionalIncludeDirectories>C:\Users\falah\Desktop\vcglib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

    </ClCompile>

    <Link>

      <SubSystem>Console</SubSystem>

      <GenerateDebugInformation>true</GenerateDebugInformation>

    </Link>

  </ItemDefinitionGroup>

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

    <ClCompile>

      <PrecompiledHeader>Use</PrecompiledHeader>

      <WarningLevel>Level3</WarningLevel>

      <Optimization>MaxSpeed</Optimization>

      <FunctionLevelLinking>true</FunctionLevelLinking>

      <IntrinsicFunctions>true</IntrinsicFunctions>

      <SDLCheck>true</SDLCheck>

      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

      <ConformanceMode>true</ConformanceMode>

      <AdditionalIncludeDirectories>C:\Users\falah\Desktop\vcglib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

    </ClCompile>

    <Link>

      <SubSystem>Console</SubSystem>

      <EnableCOMDATFolding>true</EnableCOMDATFolding>

      <OptimizeReferences>true</OptimizeReferences>

      <GenerateDebugInformation>true</GenerateDebugInformation>

    </Link>

  </ItemDefinitionGroup>

  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

    <ClCompile>

      <PrecompiledHeader>Use</PrecompiledHeader>

      <WarningLevel>Level3</WarningLevel>

      <Optimization>MaxSpeed</Optimization>

      <FunctionLevelLinking>true</FunctionLevelLinking>

      <IntrinsicFunctions>true</IntrinsicFunctions>

      <SDLCheck>true</SDLCheck>

      <PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

      <ConformanceMode>true</ConformanceMode>

      <AdditionalIncludeDirectories>C:\Users\falah\Desktop\vcglib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

    </ClCompile>

    <Link>

      <SubSystem>Console</SubSystem>

      <EnableCOMDATFolding>true</EnableCOMDATFolding>

      <OptimizeReferences>true</OptimizeReferences>

          <GenerateDebugInformation>true</GenerateDebugInformation>

    </Link>

  </ItemDefinitionGroup>

  <ItemGroup>

    <ClInclude Include="AFP_vcglib.h" />

    <ClInclude Include="stdafx.h" />

    <ClInclude Include="targetver.h" />

  </ItemGroup>

  <ItemGroup>

    <ClCompile Include="..\..\..\..\Desktop\vcglib\wrap\ply\plylib.cpp" />

    <ClCompile Include="AFP_vcglib.cpp" />

    <ClCompile Include="main.cpp" />

    <ClCompile Include="stdafx.cpp">

      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>

      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>

      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>

    </ClCompile>

  </ItemGroup>

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

  <ImportGroup Label="ExtensionTargets">

  </ImportGroup>

</Project>

`

Here is the code I used to decimate a mesh down to 1000 faces. The executable of Debug x86/x64 works just fine.

In the header, I have:

`

#include <vcg/complex/complex.h>

// io    
#include <wrap/io_trimesh/import.h>
#include <wrap/io_trimesh/export_ply.h>

// local optimization
#include <vcg/complex/algorithms/local_optimization.h>
#include <vcg/complex/algorithms/local_optimization/tri_edge_collapse_quadric.h>

using namespace vcg;
using namespace tri;

// The class prototypes.
class MyVertex;
class MyEdge;
class MyFace;

struct MyUsedTypes : public UsedTypes<Use<MyVertex>::AsVertexType, Use<MyEdge>::AsEdgeType,     Use<MyFace>::AsFaceType> {};

class MyVertex : public Vertex< MyUsedTypes,
vertex::VFAdj,
vertex::Coord3f,
vertex::Normal3f,
vertex::Mark,
vertex::Qualityf,
vertex::BitFlags  > {
public:
vcg::math::Quadric<double> &Qd() { return q; }
private:
math::Quadric<double> q;
};

class MyEdge : public Edge< MyUsedTypes> {};

typedef BasicVertexPair<MyVertex> VertexPair;

class MyFace : public Face< MyUsedTypes,
face::VFAdj,
face::VertexRef,
face::BitFlags > {};

// the main mesh class
class MyMesh : public vcg::tri::TriMesh<std::vector<MyVertex>, std::vector<MyFace> > {};

`

And in the main function, I have:

`

MyMesh mesh;
int FinalSize = 1000;
int err = vcg::tri::io::Importer<MyMesh>::Open(mesh, "Heart_Model.ply");
if (err)
{
	printf("Unable to open mesh %s : '%s'\n", "Heart_Model.ply", vcg::tri::io::Importer<MyMesh>::ErrorMsg(err));
	return;
}

printf("mesh loaded %d %d \n", mesh.vn, mesh.fn);

TriEdgeCollapseQuadricParameter qparams;
qparams.QualityThr = 0.3;
float TargetError = std::numeric_limits<float>::max();
bool CleaningFlag = true;

if (CleaningFlag) {
	int dup = tri::Clean<MyMesh>::RemoveDuplicateVertex(mesh);
	int unref = tri::Clean<MyMesh>::RemoveUnreferencedVertex(mesh);
	printf("Removed %i duplicate and %i unreferenced vertices from mesh \n", dup, unref);
}


printf("reducing it to %i\n", FinalSize);

vcg::tri::UpdateBounding<MyMesh>::Box(mesh);

// decimator initialization
vcg::LocalOptimization<MyMesh> DeciSession(mesh, &qparams);

int t1 = clock();
DeciSession.Init<MyTriEdgeCollapse>();
int t2 = clock();
printf("Initial Heap Size %i\n", int(DeciSession.h.size()));

DeciSession.SetTargetSimplices(FinalSize);
DeciSession.SetTimeBudget(0.5f);
if (TargetError < std::numeric_limits<float>::max()) DeciSession.SetTargetMetric(TargetError);

while (DeciSession.DoOptimization() && mesh.fn > FinalSize && DeciSession.currMetric < TargetError)
	printf("Current Mesh size %7i heap sz %9i err %9g \r", mesh.fn, int(DeciSession.h.size()), DeciSession.currMetric);

int t3 = clock();
printf("mesh  %d %d Error %g \n", mesh.vn, mesh.fn, DeciSession.currMetric);
printf("\nCompleted in (%5.3f+%5.3f) sec\n", float(t2 - t1) / CLOCKS_PER_SEC, float(t3 - t2) / CLOCKS_PER_SEC);

vcg::tri::io::ExporterPLY<MyMesh>::Save(mesh, "out2.ply");

`

afpgit avatar Apr 30 '18 04:04 afpgit

Solution mentioned at https://github.com/cnr-isti-vclab/vcglib/issues/21#issuecomment-294355936 works. I edit vcglib\vcg\complex\algorithms\create\plymc\plymc.h line 183 tri::io::Importer<SMesh>::Open(m,filename,loadmask) to tri::io::ImporterPLY<SMesh>::Open(m,filename,loadmask) and linking successfully ends on Visual Studio 2015 x64 Release.

pituke avatar Mar 31 '20 10:03 pituke

Dear @cignoni @pituke I have the same problem in VS2017 release x64.
image Stay here all the time.

duandongbin000 avatar Jun 15 '20 07:06 duandongbin000

I solve this problem by setting bug

RuiSheep avatar Apr 28 '22 03:04 RuiSheep