Small changes.
This commit is contained in:
parent
4e77db8161
commit
ff951fed19
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.16 2004/10/19 01:23:02 ponchio
|
||||
Daily backup (fragment...)
|
||||
|
||||
Revision 1.15 2004/10/15 16:45:27 ponchio
|
||||
Vbo added.
|
||||
|
||||
|
@ -102,7 +105,7 @@ using namespace std;
|
|||
#include <GL/glut.h>
|
||||
|
||||
#include <wrap/gui/trackball.h>
|
||||
#include "stopwatch.h"
|
||||
#include "watch.h"
|
||||
|
||||
|
||||
using namespace vcg;
|
||||
|
@ -199,7 +202,7 @@ int main(int argc, char *argv[]) {
|
|||
" -: decrease error\n"
|
||||
" +: increase error (= too)\n";
|
||||
|
||||
StopWatch watch;
|
||||
Watch watch;
|
||||
|
||||
bool rotate = false;
|
||||
bool show_borders = true;
|
||||
|
@ -361,7 +364,7 @@ int main(int argc, char *argv[]) {
|
|||
nexus.SetComponent(NexusMt::COLOR, show_colors);
|
||||
nexus.SetComponent(NexusMt::NORMAL, show_normals);
|
||||
|
||||
watch.Restart();
|
||||
watch.Start();
|
||||
|
||||
nexus.Render();
|
||||
|
||||
|
@ -416,7 +419,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
tframe = watch.Elapsed();
|
||||
tframe = watch.Time();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using namespace std;
|
|||
|
||||
#include "nxsalgo.h"
|
||||
#include "nexus.h"
|
||||
#include "watch.h"
|
||||
|
||||
using namespace nxs;
|
||||
using namespace vcg;
|
||||
|
@ -195,7 +196,7 @@ int main(int argc, char *argv[]) {
|
|||
Nexus nexus;
|
||||
nexus.patches.SetRamBufferSize(ram_size);
|
||||
if(!nexus.Load(input, true)) {
|
||||
cerr << "Could not open nexus file: " << input << ".mt\n";
|
||||
cerr << "Could not open nexus file: " << input << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -269,7 +270,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
if(!output.size()) output = input + getSuffix(signature);
|
||||
|
||||
cerr << "Writing to nexus: " << output << endl;
|
||||
cout << "Writing to nexus: " << output << endl;
|
||||
|
||||
Nexus out;
|
||||
out.patches.SetRamBufferSize(ram_size);
|
||||
|
@ -281,8 +282,12 @@ int main(int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
//TODO set rambuffer low (or even direct access!)
|
||||
|
||||
Report report(nexus.index.size());
|
||||
cout << "Copying and allocating...\n";
|
||||
for(unsigned int patch = 0; patch < nexus.index.size(); patch++) {
|
||||
report.Step(patch);
|
||||
Nexus::PatchInfo &src_entry = nexus.index[patch];
|
||||
Patch src_patch = nexus.GetPatch(patch);
|
||||
Border src_border = nexus.GetBorder(patch);
|
||||
|
@ -300,8 +305,6 @@ int main(int argc, char *argv[]) {
|
|||
Nexus::PatchInfo &dst_entry = out.index[patch];
|
||||
Patch dst_patch = out.GetPatch(patch);
|
||||
|
||||
|
||||
|
||||
//copy vertices:
|
||||
memcpy(dst_patch.VertBegin(), src_patch.VertBegin(),
|
||||
src_patch.nv * sizeof(Point3f));
|
||||
|
@ -346,24 +349,21 @@ int main(int argc, char *argv[]) {
|
|||
dst_entry.error = src_entry.error;
|
||||
|
||||
//adding borders.
|
||||
//Check border is ok:
|
||||
for(unsigned int i = 0; i < src_border.Size(); i++) {
|
||||
Link &link = src_border[i];
|
||||
if(link.IsNull()) continue;
|
||||
if(link.end_patch > nexus.index.size()) {
|
||||
cerr << "Link endp: " << link.end_patch << endl;
|
||||
}
|
||||
assert(link.end_patch < nexus.index.size());
|
||||
}
|
||||
Border dst_border = out.GetBorder(patch);
|
||||
out.borders.ResizeBorder(patch, src_border.Size());
|
||||
// dst_entry.border_used = src_entry.border_used;
|
||||
memcpy(dst_border.Start(), src_border.Start(),
|
||||
src_border.Size() * sizeof(Link));
|
||||
}
|
||||
report.Finish();
|
||||
|
||||
//TODO this is ok only if we have faces still!
|
||||
if(add_normals) {
|
||||
cerr << "Computing normals" << endl;
|
||||
cout << "Computing normals" << endl;
|
||||
ComputeNormals(out);
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,19 @@ int main(int argc, char *argv[]) {
|
|||
cerr << "Unsupported color\n";
|
||||
return -1;
|
||||
}
|
||||
if(qvertex) {
|
||||
report.Init(nexus.index.size());
|
||||
cout << "Quantizing vertices\n";
|
||||
for(unsigned int patch = 0; patch < nexus.index.size(); patch++) {
|
||||
report.Step(patch);
|
||||
Patch src_patch = nexus.GetPatch(patch);
|
||||
|
||||
float *ptr = (float *)src_patch.VertBegin();
|
||||
for(unsigned int i = 0; i < src_patch.nv*3; i++)
|
||||
ptr[i] = qvertex * nearbyintf(ptr[i]/qvertex);
|
||||
}
|
||||
report.Finish();
|
||||
}
|
||||
|
||||
//fixing sphere.
|
||||
out.sphere = nexus.sphere;
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.14 2004/10/19 04:23:29 ponchio
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.13 2004/10/15 16:45:27 ponchio
|
||||
Vbo added.
|
||||
|
||||
|
@ -69,6 +72,7 @@ First draft.
|
|||
#include <iostream>
|
||||
|
||||
#include "voronoichain.h"
|
||||
#include "watch.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace vcg;
|
||||
|
@ -114,16 +118,19 @@ void VoronoiChain::Init(Crude &crude, float scaling, int steps) {
|
|||
|
||||
//here goes some optimization pass.
|
||||
//Fine optimization.
|
||||
Report report;
|
||||
vector<Point3f> fcentroids;
|
||||
vector<unsigned int> fcount;
|
||||
for(int i = 0; i < steps; i++) {
|
||||
cerr << "Optimization step 0: " << i << "/" << steps << endl;
|
||||
cerr << "Optimization step: " << i+1 << "/" << steps << endl;
|
||||
fcentroids.clear();
|
||||
fcount.clear();
|
||||
fcentroids.resize(fine.size(), Point3f(0, 0, 0));
|
||||
fcount.resize(fine.size(), 0);
|
||||
|
||||
report.Init(crude.Vertices());
|
||||
for(unsigned int v = 0; v < crude.Vertices(); v++) {
|
||||
if(v & 0xffff) report.Step(v);
|
||||
unsigned int ftarget;
|
||||
float dist = fine.Closest(crude.vert[v], ftarget);
|
||||
assert(ftarget != -1);
|
||||
|
@ -157,14 +164,16 @@ void VoronoiChain::Init(Crude &crude, float scaling, int steps) {
|
|||
vector<unsigned int> ccount;
|
||||
vector<float> radius;
|
||||
for(int i = 0; i < steps; i++) {
|
||||
cerr << "Optimization step 0: " << i << "/" << steps << endl;
|
||||
cerr << "Optimization step: " << i+1 << "/" << steps << endl;
|
||||
ccentroids.clear();
|
||||
ccount.clear();
|
||||
ccentroids.resize(coarse.size(), Point3f(0, 0, 0));
|
||||
ccount.resize(coarse.size(), 0);
|
||||
radius.resize(coarse.size(), 0);
|
||||
|
||||
report.Init(crude.Vertices());
|
||||
for(unsigned int v = 0; v < crude.Vertices(); v++) {
|
||||
if(v & 0xffff) report.Step(v);
|
||||
unsigned int ctarget = 0xffffffff;
|
||||
float dist = coarse.Closest(crude.vert[v], ctarget);
|
||||
assert(ctarget != 0xffffffff);
|
||||
|
@ -372,6 +381,7 @@ void VoronoiChain::BuildLevel(Nexus &nexus, unsigned int offset,
|
|||
|
||||
unsigned int tot_coarse = (unsigned int)(fine.size() * scaling);
|
||||
|
||||
//TODO this method for selecting the seeds is ugly!
|
||||
float ratio = tot_coarse/(float)(nexus.index.size() - offset);
|
||||
float cratio = 0;
|
||||
for(unsigned int idx = offset; idx < nexus.index.size(); idx++) {
|
||||
|
@ -394,20 +404,24 @@ void VoronoiChain::BuildLevel(Nexus &nexus, unsigned int offset,
|
|||
coarse.Init();
|
||||
cerr << "Coarse size: " << coarse.size() << endl;
|
||||
cerr << "Coarse mean: " << coarse_vmean << " mean_size: " << mean_size << endl;
|
||||
|
||||
Report report;
|
||||
//here goes some optimization pass.
|
||||
//Coarse optimization.
|
||||
vector<Point3f> ccentroids;
|
||||
vector<unsigned int> ccount;
|
||||
vector<float> radius;
|
||||
for(int i = 0; i < steps; i++) {
|
||||
cerr << "Optimization step 0: " << i << "/" << steps << endl;
|
||||
cerr << "Optimization step: " << i+1 << "/" << steps << endl;
|
||||
ccentroids.clear();
|
||||
ccount.clear();
|
||||
ccentroids.resize(coarse.size(), Point3f(0, 0, 0));
|
||||
ccount.resize(coarse.size(), 0);
|
||||
radius.resize(coarse.size(), 0);
|
||||
|
||||
report.Init(nexus.index.size());
|
||||
for(unsigned int idx = offset; idx < nexus.index.size(); idx++) {
|
||||
report.Step(idx);
|
||||
Patch patch = nexus.GetPatch(idx);
|
||||
for(unsigned int i = 0; i < patch.nv; i++) {
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.16 2004/10/19 01:23:02 ponchio
|
||||
Daily backup (fragment...)
|
||||
|
||||
Revision 1.15 2004/10/15 11:41:03 ponchio
|
||||
Tests and small changes.
|
||||
|
||||
|
@ -90,28 +93,10 @@ using namespace std;
|
|||
#include "decimate.h"
|
||||
#include "fragment.h"
|
||||
#include "nxsbuild.h"
|
||||
#include "watch.h"
|
||||
using namespace vcg;
|
||||
using namespace nxs;
|
||||
|
||||
/*void RemapVertices(Crude &crude,
|
||||
VertRemap &vert_remap,
|
||||
VFile<unsigned int> &face_remap,
|
||||
vector<unsigned int> &patch_verts);
|
||||
|
||||
void NexusAllocate(Crude &crude,
|
||||
Nexus &nexus,
|
||||
VFile<unsigned int> &face_remap,
|
||||
vector<unsigned int> &patch_faces,
|
||||
vector<unsigned int> &patch_verts);
|
||||
|
||||
void NexusFill(Crude &crude,
|
||||
Nexus &nexus,
|
||||
VertRemap &vert_remap,
|
||||
VFile<RemapLink> &border_remap);
|
||||
|
||||
void NexusFixBorder(Nexus &nexus,
|
||||
VFile<RemapLink> &border_remap);*/
|
||||
|
||||
void NexusSplit(Nexus &nexus, VoronoiChain &vchain,
|
||||
unsigned int level,
|
||||
vector<Point3f> &newvert,
|
||||
|
@ -124,12 +109,6 @@ void BuildFragment(Nexus &nexus, VoronoiPartition &part,
|
|||
set<unsigned int> &patches,
|
||||
Fragment &fragment);
|
||||
|
||||
/*float Decimate(unsigned int target_faces,
|
||||
vector<Point3f> &newvert,
|
||||
vector<unsigned int> &newface,
|
||||
vector<Link> &newbord,
|
||||
vector<int> &vert_remap);*/
|
||||
|
||||
void ReverseHistory(vector<Nexus::Update> &history);
|
||||
|
||||
void TestBorders(Nexus &nexus);
|
||||
|
@ -214,6 +193,7 @@ int main(int argc, char *argv[]) {
|
|||
cerr << " -o N: nomber of optimization steps\n";
|
||||
cerr << " -d <method>: decimation method: quadric, cluster. (default quadric)\n";
|
||||
cerr << " -b N: ram buffer size (in bytes)\n";
|
||||
cerr << " -r : stop after remapping fase\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -248,15 +228,14 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
VFile<unsigned int> face_remap;
|
||||
if(!face_remap.Create(output + ".rmf")) {
|
||||
cerr << "Could not create remap files: " << output << ".frm\n";
|
||||
cerr << "Could not create remap files: " << output << ".rmf\n";
|
||||
return -1;
|
||||
}
|
||||
face_remap.Resize(crude.Faces());
|
||||
|
||||
|
||||
VertRemap vert_remap;
|
||||
if(!vert_remap.Create(output)) {
|
||||
cerr << "Could not create remap files: " << output << ".rmv and .rmb\n";
|
||||
cerr << "Could not create remap file: " << output << ".rmv and .rmb\n";
|
||||
return -1;
|
||||
}
|
||||
vert_remap.Resize(crude.Vertices());
|
||||
|
@ -272,7 +251,9 @@ int main(int argc, char *argv[]) {
|
|||
//Remapping faces and vertices using level 0 and 1 of the chain
|
||||
cerr << "Remapping faces.\n";
|
||||
vector<unsigned int> patch_faces;
|
||||
vchain.RemapFaces(crude, face_remap, patch_faces, scaling, optimization_steps);
|
||||
|
||||
vchain.RemapFaces(crude, face_remap, patch_faces,
|
||||
scaling, optimization_steps);
|
||||
|
||||
cerr << "Remapping vertices.\n";
|
||||
vector<unsigned int> patch_verts;
|
||||
|
@ -302,32 +283,32 @@ int main(int argc, char *argv[]) {
|
|||
nexus.patches.FlushAll();
|
||||
|
||||
/* BUILDING OTHER LEVELS */
|
||||
unsigned int oldoffset = 0;
|
||||
|
||||
Report report;
|
||||
|
||||
unsigned int oldoffset = 0;
|
||||
for(unsigned int level = 1; level < max_level; level++) {
|
||||
cerr << "Level: " << level << endl;
|
||||
|
||||
unsigned int newoffset = nexus.index.size();
|
||||
vchain.BuildLevel(nexus, oldoffset, scaling, optimization_steps);
|
||||
|
||||
cerr << "Level built\n";
|
||||
report.Init(vchain.oldfragments.size(), 1);
|
||||
unsigned int fcount = 0;
|
||||
vector<Nexus::Update> level_history;
|
||||
map<unsigned int, set<unsigned int> >::iterator fragment;
|
||||
for(fragment = vchain.oldfragments.begin();
|
||||
fragment != vchain.oldfragments.end(); fragment++) {
|
||||
|
||||
report.Step(fcount++);
|
||||
|
||||
update.created.clear();
|
||||
update.erased.clear();
|
||||
|
||||
cerr << "Join ";
|
||||
set<unsigned int> &fcells = (*fragment).second;
|
||||
set<unsigned int>::iterator s;
|
||||
for(s = fcells.begin(); s != fcells.end(); s++) {
|
||||
update.erased.push_back(*s);
|
||||
cerr << *s << " ";
|
||||
}
|
||||
cerr << endl;
|
||||
|
||||
vector<Point3f> newvert;
|
||||
vector<unsigned int> newface;
|
||||
|
@ -349,6 +330,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
level_history.push_back(update);
|
||||
}
|
||||
report.Finish();
|
||||
|
||||
for(unsigned int i = 0; i < level_history.size(); i++)
|
||||
nexus.history.push_back(level_history[i]);
|
||||
|
@ -389,8 +371,6 @@ void NexusSplit(Nexus &nexus, VoronoiChain &vchain,
|
|||
Nexus::Update &update,
|
||||
float error) {
|
||||
|
||||
cerr << "Counting nearby cells" << endl;
|
||||
|
||||
map<unsigned int, Point3f> centroids;
|
||||
map<unsigned int, unsigned int> counts;
|
||||
|
||||
|
|
Loading…
Reference in New Issue