25 get_scores(
int subdiv,
int across,
double ratio,
32 _cscore.reserve(_maxi);
33 _sscore.reserve(_maxi);
37 for (i = 0; i < _maxi; i++) {
38 _cscore.push_back(0.0);
39 _sscore.push_back(0.0);
43 for (a = 0; a <= across; a++) {
44 double v = (double)a / (
double)across;
46 LVecBase3 p1, p2, p3, pnext;
55 for (i = -1; i < _maxi; i++) {
56 double u = (double)(i+1) / (double)(_maxi+1);
65 if (!pnext.almost_equal(p3)) {
73 double vlength = length(v2);
77 _sscore[i] += vlength;
80 if (num_points >= 3) {
83 double d = v1.dot(v2);
85 _cscore[i] += acos(std::max(std::min(d, 1.0), -1.0));
93 _cint.reserve(_maxi + 1);
96 double ad = (double)(across+1);
98 for (i = 0; i < _maxi; i++) {
99 net += _cscore[i]/ad + ratio * _sscore[i]/ad;
100 _cint.push_back(net);
112 double avg_curve = 0.0;
113 for (i = 0; i < _maxi; i++) {
114 avg_curve += _cscore[i];
116 avg_curve /= (double)_maxi;
121 BendPoints::iterator bi, bnext;
125 Segments::iterator si;
144 bi = bpoints.begin();
145 int min_separation = _maxi/count;
146 while (bi != bpoints.end()) {
150 if (bnext != bpoints.end() && (*bnext) - (*bi) < min_separation) {
152 if (_cscore[*bnext] > _cscore[*bi]) {
155 bpoints.erase(bnext);
164 while (count - 1 < (
int)bpoints.size()) {
165 bi = bpoints.begin();
166 BendPoints::iterator mi = bi;
167 for (++bi; bi != bpoints.end(); ++bi) {
168 if (_cscore[*bi] < _cscore[*mi]) {
176 bi = bpoints.begin();
178 for (bi = bpoints.begin(); bi != bpoints.end(); ++bi) {
184 int nr = count - segments.size();
192 double net_score = _cint[_maxi];
193 nassertv(net_score > 0.0);
195 for (si = segments.begin(); si != segments.end(); ++si) {
196 (*si)._num_cuts = (int)floor(nr * (*si).get_score() / net_score);
197 nassertv((*si)._num_cuts <= nr);
198 ns += (*si)._num_cuts;
204 si = min_element(segments.begin(), segments.end());
210 for (si = segments.begin(); si != segments.end(); ++si) {
215 iso_points.erase(iso_points.begin(), iso_points.end());
217 iso_points.push_back(0.0);
218 for (si = segments.begin(); si != segments.end(); ++si) {
220 for (ci = (*si)._cuts.begin(); ci != (*si)._cuts.end(); ++ci) {
221 iso_points.push_back((*ci+1) / (
double)(_maxi+1));
223 iso_points.push_back(((*si)._t+1) / (
double)(_maxi+1));
227 iso_points.back() = 1.0;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The result of a NurbsSurfaceEvaluator.
bool eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point)
Computes the point on the surface corresponding to the indicated value in parametric time.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a single hypothetical subdivided segment, under consideration by the IsoPlacer.