86int main(
int argc,
char** argv )
88 trace.
info() <<
"Usage: " << argv[ 0 ] <<
" <input.obj> <h> <view>" << std::endl;
89 trace.
info() <<
"\tComputes a digital polyhedron from an OBJ file" << std::endl;
90 trace.
info() <<
"\t- input.obj: choose your favorite mesh" << std::endl;
91 trace.
info() <<
"\t- h [==1]: the digitization gridstep" << std::endl;
92 trace.
info() <<
"\t- view [==7]: display vertices(1), edges(2), faces(4)" << std::endl;
93 string filename = examplesPath +
"samples/lion.obj";
94 std::string fn = argc > 1 ? argv[ 1 ] : filename;
95 double h = argc > 2 ? atof( argv[ 2 ] ) : 1.0;
96 int view = argc > 3 ? atoi( argv[ 3 ] ) : 7;
98 std::ifstream input( fn.c_str() );
103 trace.
error() <<
"Unable to read obj file : " << fn << std::endl;
107 QApplication application(argc,argv);
110 viewer.setWindowTitle(
"digitalPolyhedronBuilder3D");
113 Point lo(-500,-500,-500);
114 Point up(500,500,500);
127 std::set< Point > faces_set, edges_set;
135 for (
auto v : faceVertices[ f ] )
136 X.push_back( vertices[ v ] );
137 auto F = dconv.
envelope( X, Algorithm::DIRECT );
138 faces_set.insert( F.cbegin(), F.cend() );
143 { vertices[ edgeVertices[ e ].first ],
144 vertices[ edgeVertices[ e ].second ] };
145 auto E = dconv.
envelope( X, Algorithm::DIRECT );
146 edges_set.insert( E.cbegin(), E.cend() );
149 std::vector< Point > face_points, edge_points;
150 std::vector< Point > vertex_points = vertices;
151 std::sort( vertex_points.begin(), vertex_points.end() );
152 std::set_difference( faces_set.cbegin(), faces_set.cend(),
153 edges_set.cbegin(), edges_set.cend(),
154 std::back_inserter( face_points ) );
155 std::set_difference( edges_set.cbegin(), edges_set.cend(),
156 vertex_points.cbegin(), vertex_points.cend(),
157 std::back_inserter( edge_points ) );
158 auto total = vertex_points.size() + edge_points.size() + face_points.size();
159 trace.
info() <<
"#vertex points=" << vertex_points.size() << std::endl;
160 trace.
info() <<
"#edge points=" << edge_points.size() << std::endl;
161 trace.
info() <<
"#face points=" << face_points.size() << std::endl;
162 trace.
info() <<
"#total points=" << total << std::endl;
168 viewer.setLineColor( colors[ 0 ] );
169 viewer.setFillColor( colors[ 0 ] );
170 for (
auto p : vertices ) viewer << p;
174 viewer.setLineColor( colors[ 1 ] );
175 viewer.setFillColor( colors[ 1 ] );
176 for (
auto p : edge_points ) viewer << p;
180 viewer.setLineColor( colors[ 2 ] );
181 viewer.setFillColor( colors[ 2 ] );
182 for (
auto p : face_points ) viewer << p;
184 viewer << MViewer::updateDisplay;
185 return application.exec();