Subversion Repositories gelsvn

Rev

Rev 586 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 586 Rev 587
Line 622... Line 622...
622
    {
622
    {
623
        theConsole.printf("usage:  info");
623
        theConsole.printf("usage:  info");
624
        theConsole.printf("Provides information about mesh.");
624
        theConsole.printf("Provides information about mesh.");
625
        return;
625
        return;
626
    }
626
    }
627
    Vec3f p0, p7;
627
    Vec3d p0, p7;
628
    bbox(active_mesh(), p0, p7);
628
    bbox(active_mesh(), p0, p7);
629
    stringstream bbox_corners;
629
    stringstream bbox_corners;
630
    bbox_corners << p0 << " - " << p7 << endl;
630
    bbox_corners << p0 << " - " << p7 << endl;
631
	theConsole.printf("Bounding box corners : %s", bbox_corners.str().c_str());
631
	theConsole.printf("Bounding box corners : %s", bbox_corners.str().c_str());
632
    map<int,int> val_hist;
632
    map<int,int> val_hist;
Line 672... Line 672...
672
        return;
672
        return;
673
    }
673
    }
674
    istringstream a0(args[0]);
674
    istringstream a0(args[0]);
675
    a0 >> keep_fraction;
675
    a0 >> keep_fraction;
676
	
676
	
677
    Vec3f p0, p7;
677
    Vec3d p0, p7;
678
    bbox(active_mesh(), p0, p7);
678
    bbox(active_mesh(), p0, p7);
679
    Vec3f d = p7-p0;
679
    Vec3d d = p7-p0;
680
    float s = 1.0/d.max_coord();
680
    float s = 1.0/d.max_coord();
681
    Vec3f pcentre = (p7+p0)/2.0;
681
    Vec3d pcentre = (p7+p0)/2.0;
682
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi){
682
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi){
683
        active_mesh().pos(*vi) = (active_mesh().pos(*vi) - pcentre) * s;
683
        active_mesh().pos(*vi) = (active_mesh().pos(*vi) - pcentre) * s;
684
    }
684
    }
685
    cout << "Timing the Garland Heckbert (quadric based) mesh simplication..." << endl;
685
    cout << "Timing the Garland Heckbert (quadric based) mesh simplication..." << endl;
686
    Timer timer;
686
    Timer timer;
Line 720... Line 720...
720
        a0 >> noise_amplitude;
720
        a0 >> noise_amplitude;
721
    }
721
    }
722
	
722
	
723
    gel_srand(0);
723
    gel_srand(0);
724
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi){
724
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi){
725
        Vec3f v;
725
        Vec3d v;
726
        do{
726
        do{
727
            v = Vec3f(gel_rand(),gel_rand(),gel_rand());
727
            v = Vec3d(gel_rand(),gel_rand(),gel_rand());
728
            v /= (float)(GEL_RAND_MAX);
728
            v /= (float)(GEL_RAND_MAX);
729
        } 
729
        } 
730
        while(sqr_length(v) > 1.0);
730
        while(sqr_length(v) > 1.0);
731
		
731
		
732
        v -= Vec3f(0.5);
732
        v -= Vec3d(0.5);
733
        v *= 2.0;
733
        v *= 2.0;
734
        v *= noise_amplitude;
734
        v *= noise_amplitude;
735
        v *= avg_length;
735
        v *= avg_length;
736
        active_mesh().pos(*vi) += v;
736
        active_mesh().pos(*vi) += v;
737
    }		
737
    }		
Line 755... Line 755...
755
    {
755
    {
756
        istringstream a0(args[0]);
756
        istringstream a0(args[0]);
757
        a0 >> noise_amplitude;
757
        a0 >> noise_amplitude;
758
    }
758
    }
759
	
759
	
760
    VertexAttributeVector<Vec3f> normals(active_mesh().allocated_vertices());
760
    VertexAttributeVector<Vec3d> normals(active_mesh().allocated_vertices());
761
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi)
761
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi)
762
        normals[*vi] = normal(active_mesh(), *vi);
762
        normals[*vi] = normal(active_mesh(), *vi);
763
	
763
	
764
    gel_srand(0);
764
    gel_srand(0);
765
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi)
765
    for(VertexIDIterator vi = active_mesh().vertices_begin(); vi != active_mesh().vertices_end(); ++vi)
Line 845... Line 845...
845
            double w_sum;
845
            double w_sum;
846
            unnormalized_mean_curvature_normal(active_mesh(), *v, m, w_sum);
846
            unnormalized_mean_curvature_normal(active_mesh(), *v, m, w_sum);
847
            new_pos[*v] = Vec3d(active_mesh().pos(*v))  + (t * m/w_sum);
847
            new_pos[*v] = Vec3d(active_mesh().pos(*v))  + (t * m/w_sum);
848
        }
848
        }
849
        for(VertexIDIterator v = active_mesh().vertices_begin(); v != active_mesh().vertices_end(); ++v)
849
        for(VertexIDIterator v = active_mesh().vertices_begin(); v != active_mesh().vertices_end(); ++v)
850
            active_mesh().pos(*v) = Vec3f(new_pos[*v]);
850
            active_mesh().pos(*v) = new_pos[*v];
851
    }
851
    }
852
    return;
852
    return;
853
}
853
}
854
 
854
 
855
void console_taubin_smooth(const std::vector<std::string> & args)
855
void console_taubin_smooth(const std::vector<std::string> & args)