edits
This commit is contained in:
parent
73fba9e9e5
commit
0ab8fee7d9
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "3-Modeling/c++/deps/polyscope"]
|
||||
path = 3-Modeling/c++/deps/polyscope
|
||||
url = https://github.com/nmwsharp/polyscope.git
|
70
3-modeling/c++/CMakeLists.txt
Normal file
70
3-modeling/c++/CMakeLists.txt
Normal file
@ -0,0 +1,70 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
project(CGDI)
|
||||
|
||||
|
||||
# Print the build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
|
||||
endif()
|
||||
message(STATUS "cmake build type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
### Configure the compiler
|
||||
# This is a basic, decent setup that should do something sane on most compilers
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
|
||||
# using Clang (linux or apple) or GCC
|
||||
message("Using clang/gcc compiler flags")
|
||||
SET(BASE_CXX_FLAGS "-std=c++11 -Wall -Wextra")
|
||||
SET(DISABLED_WARNINGS " -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-deprecated-declarations -Wno-missing-braces -Wno-unused-private-field")
|
||||
SET(TRACE_INCLUDES " -H -Wno-error=unused-command-line-argument")
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
message("Setting clang-specific options")
|
||||
SET(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -ferror-limit=3 -fcolor-diagnostics")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-g3 -fsanitize=address -fno-limit-debug-info")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
message("Setting gcc-specific options")
|
||||
SET(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} -fmax-errors=5")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-g3")
|
||||
SET(DISABLED_WARNINGS "${DISABLED_WARNINGS} -Wno-maybe-uninitialized -Wno-format-zero-length -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
|
||||
endif()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${BASE_CXX_FLAGS} ${DISABLED_WARNINGS}")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG")
|
||||
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
message("Using Visual Studio compiler flags")
|
||||
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} /W4")
|
||||
set(BASE_CXX_FLAGS "${BASE_CXX_FLAGS} /MP") # parallel build
|
||||
SET(DISABLED_WARNINGS "${DISABLED_WARNINGS} /wd\"4267\"") # ignore conversion to smaller type (fires more aggressively than the gcc version, which is annoying)
|
||||
SET(DISABLED_WARNINGS "${DISABLED_WARNINGS} /wd\"4244\"") # ignore conversion to smaller type (fires more aggressively than the gcc version, which is annoying)
|
||||
SET(DISABLED_WARNINGS "${DISABLED_WARNINGS} /wd\"4305\"") # ignore truncation on initialization
|
||||
SET(CMAKE_CXX_FLAGS "${BASE_CXX_FLAGS} ${DISABLED_WARNINGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||
|
||||
add_definitions(/D "_CRT_SECURE_NO_WARNINGS")
|
||||
add_definitions(-DNOMINMAX)
|
||||
add_definitions(-D_USE_MATH_DEFINES)
|
||||
else()
|
||||
# unrecognized
|
||||
message( FATAL_ERROR "Unrecognized compiler [${CMAKE_CXX_COMPILER_ID}]" )
|
||||
endif()
|
||||
|
||||
|
||||
# == Deps
|
||||
add_subdirectory(deps/polyscope)
|
||||
|
||||
# == Build our project stuff
|
||||
|
||||
set(SRCS
|
||||
simpleTest.cpp
|
||||
# add any other source files here
|
||||
)
|
||||
|
||||
# To change the name of your executable, change "gc_project" in the lines below to whatever you want
|
||||
add_executable(simpleTest "${SRCS}")
|
||||
target_link_libraries(simpleTest polyscope)
|
1
3-modeling/c++/deps/polyscope
Submodule
1
3-modeling/c++/deps/polyscope
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 047dd980715c590f7720715c94a4382802c4e116
|
98
3-modeling/c++/simppleTest.cpp
Normal file
98
3-modeling/c++/simppleTest.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include "polyscope/polyscope.h"
|
||||
#include "polyscope/point_cloud.h"
|
||||
|
||||
#include "deps/CLI11.hpp"
|
||||
|
||||
void processFile(const std::string &filename,
|
||||
const std::vector<unsigned int> &vectorCols)
|
||||
{
|
||||
std::vector<std::array<double, 3>> pc;
|
||||
std::vector<std::vector<double>> alldata;
|
||||
std::ifstream ifs(filename);
|
||||
double x,y,z;
|
||||
std::string line;
|
||||
while(std::getline(ifs, line))
|
||||
{
|
||||
std::stringstream linestream(line);
|
||||
std::vector<double> data;
|
||||
auto i=0;
|
||||
while(linestream.good())
|
||||
{
|
||||
double v;
|
||||
linestream >> v;
|
||||
data.push_back(v);
|
||||
++i;
|
||||
}
|
||||
pc.push_back({data[0],data[1],data[2]});
|
||||
alldata.push_back(data);
|
||||
}
|
||||
std::cout<<filename<<" "<<alldata[0].size()<<" cols ["
|
||||
<<vectorCols.size()<<" vectors, "
|
||||
<< alldata[0].size()-3*vectorCols.size()-3<<" scalars]"<<std::endl;
|
||||
//Polyscope
|
||||
auto ps = polyscope::registerPointCloud(filename, pc);
|
||||
|
||||
unsigned int indexV;
|
||||
for(auto col=3u; col < alldata[0].size(); ++col)
|
||||
{
|
||||
if (std::find(vectorCols.begin(), vectorCols.end(), col) == vectorCols.end())
|
||||
{
|
||||
std::vector<double> scalars;
|
||||
for(auto i=0u; i < alldata.size(); ++i)
|
||||
scalars.push_back(alldata[i][col]);
|
||||
ps->addScalarQuantity("Scalar col"+std::to_string(col), scalars);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::array<double, 3>> V;
|
||||
for(auto i=0u; i < alldata.size(); ++i)
|
||||
V.push_back({alldata[i][col],alldata[i][col+1],alldata[i][col+2]});
|
||||
ps->addVectorQuantity("Vector col"+std::to_string(col), V);
|
||||
col +=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CLI::App app{"displayPTS"};
|
||||
std::vector<std::string> filenames;
|
||||
app.add_option("-i,--input,1", filenames, "Input point clouds")
|
||||
->required();
|
||||
std::vector<unsigned int> vectorCols;
|
||||
app.add_option("--vectorCols", vectorCols, "Indices of columns to group as vectors (col col+1 col+2)");
|
||||
CLI11_PARSE(app,argc,argv);
|
||||
|
||||
auto errorMSG=[&](const size_t vi, const size_t vj){
|
||||
std::cout<<"Error while parsing the vectorCols: ";
|
||||
std::cout<<"("<<vi<<","<<vi+1<<","<<vi+2<<") overlaps with "<<"("<<vj<<","<<vj+1<<","<<vj+2<<")"<<std::endl;
|
||||
exit(2);
|
||||
};
|
||||
|
||||
//Check the consistency of the param.
|
||||
for(auto i=0u; i < vectorCols.size(); ++i)
|
||||
{
|
||||
for(auto j=i+1; j < vectorCols.size(); ++j)
|
||||
{
|
||||
if ((vectorCols[j] == vectorCols[i]) || (vectorCols[j] == vectorCols[i]+1) || (vectorCols[j] == vectorCols[i]+2))
|
||||
errorMSG(vectorCols[i], vectorCols[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize polyscope
|
||||
polyscope::init();
|
||||
|
||||
//Process all files
|
||||
for(auto &filename: filenames)
|
||||
processFile(filename,vectorCols);
|
||||
|
||||
// Give control to the polyscope gui
|
||||
polyscope::show();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
40
3-modeling/cube.obj
Normal file
40
3-modeling/cube.obj
Normal file
@ -0,0 +1,40 @@
|
||||
# Blender v2.91.2 OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib cube.mtl
|
||||
o Cube
|
||||
v 1.000000 1.000000 -1.000000
|
||||
v 1.000000 -1.000000 -1.000000
|
||||
v 1.000000 1.000000 1.000000
|
||||
v 1.000000 -1.000000 1.000000
|
||||
v -1.000000 1.000000 -1.000000
|
||||
v -1.000000 -1.000000 -1.000000
|
||||
v -1.000000 1.000000 1.000000
|
||||
v -1.000000 -1.000000 1.000000
|
||||
vt 0.625000 0.500000
|
||||
vt 0.875000 0.500000
|
||||
vt 0.875000 0.750000
|
||||
vt 0.625000 0.750000
|
||||
vt 0.375000 0.750000
|
||||
vt 0.625000 1.000000
|
||||
vt 0.375000 1.000000
|
||||
vt 0.375000 0.000000
|
||||
vt 0.625000 0.000000
|
||||
vt 0.625000 0.250000
|
||||
vt 0.375000 0.250000
|
||||
vt 0.125000 0.500000
|
||||
vt 0.375000 0.500000
|
||||
vt 0.125000 0.750000
|
||||
vn 0.0000 1.0000 0.0000
|
||||
vn 0.0000 0.0000 1.0000
|
||||
vn -1.0000 0.0000 0.0000
|
||||
vn 0.0000 -1.0000 0.0000
|
||||
vn 1.0000 0.0000 0.0000
|
||||
vn 0.0000 0.0000 -1.0000
|
||||
usemtl Material
|
||||
s off
|
||||
f 1/1/1 5/2/1 7/3/1 3/4/1
|
||||
f 4/5/2 3/4/2 7/6/2 8/7/2
|
||||
f 8/8/3 7/9/3 5/10/3 6/11/3
|
||||
f 6/12/4 2/13/4 4/5/4 8/14/4
|
||||
f 2/13/5 1/1/5 3/4/5 4/5/5
|
||||
f 6/11/6 5/10/6 1/1/6 2/13/6
|
Loading…
x
Reference in New Issue
Block a user