25get_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);
123 BendPoints::iterator bi, bnext;
127 Segments::iterator si;
146 bi = bpoints.begin();
147 int min_separation = _maxi/count;
148 while (bi != bpoints.end()) {
152 if (bnext != bpoints.end() && (*bnext) - (*bi) < min_separation) {
154 if (_cscore[*bnext] > _cscore[*bi]) {
157 bpoints.erase(bnext);
166 while (count - 1 < (
int)bpoints.size()) {
167 bi = bpoints.begin();
168 BendPoints::iterator mi = bi;
169 for (++bi; bi != bpoints.end(); ++bi) {
170 if (_cscore[*bi] < _cscore[*mi]) {
178 bi = bpoints.begin();
180 for (bi = bpoints.begin(); bi != bpoints.end(); ++bi) {
186 int nr = count - segments.size();
194 double net_score = _cint[_maxi];
195 nassertv(net_score > 0.0);
197 for (si = segments.begin(); si != segments.end(); ++si) {
198 (*si)._num_cuts = (int)floor(nr * (*si).get_score() / net_score);
199 nassertv((*si)._num_cuts <= nr);
200 ns += (*si)._num_cuts;
206 si = min_element(segments.begin(), segments.end());
212 for (si = segments.begin(); si != segments.end(); ++si) {
217 iso_points.erase(iso_points.begin(), iso_points.end());
219 iso_points.push_back(0.0);
220 for (si = segments.begin(); si != segments.end(); ++si) {
222 for (ci = (*si)._cuts.begin(); ci != (*si)._cuts.end(); ++ci) {
223 iso_points.push_back((*ci+1) / (double)(_maxi+1));
225 iso_points.push_back(((*si)._t+1) / (double)(_maxi+1));
229 iso_points.back() = 1.0;
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.
Represents a single hypothetical subdivided segment, under consideration by the IsoPlacer.
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.