Revision: 52654
http://brlcad.svn.sourceforge.net/brlcad/?rev=52654&view=rev
Author: brlcad
Date: 2012-10-02 04:36:17 +0000 (Tue, 02 Oct 2012)
Log Message:
-----------
don't assume fastf_t is a double, be consistent with usage. overload functions
with float/double types where warranted too.
Modified Paths:
--------------
brlcad/trunk/include/dvec.h
brlcad/trunk/include/nurbs.h
brlcad/trunk/include/vector_fpu.h
brlcad/trunk/src/libnurbs/PullbackCurve.cpp
brlcad/trunk/src/libnurbs/opennurbs_ext.cpp
Modified: brlcad/trunk/include/dvec.h
===================================================================
--- brlcad/trunk/include/dvec.h 2012-10-02 04:34:50 UTC (rev 52653)
+++ brlcad/trunk/include/dvec.h 2012-10-02 04:36:17 UTC (rev 52654)
@@ -38,9 +38,12 @@
const double VEQUALITY = 0.0000001;
template<int LEN>
- struct vec_internal;
+ struct dvec_internal;
template<int LEN>
+ struct fvec_internal;
+
+ template<int LEN>
class dvec;
template<int LEN>
@@ -62,12 +65,15 @@
class dvec {
public:
dvec(double s);
- dvec(const double* vals, bool aligned=true);
+ dvec(const float* vals);
+ dvec(const double* vals);
dvec(const dvec<LEN>& p);
dvec<LEN>& operator=(const dvec<LEN>& p);
double operator[](int index) const;
+ void u_store(float* arr) const;
void u_store(double* arr) const;
+ void a_store(float* arr) const;
void a_store(double* arr) const;
bool operator==(const dvec<LEN>& b) const;
@@ -104,9 +110,10 @@
double operator()(double a) const { return ::sqrt(a); }
};
private:
- vec_internal<LEN> data;
+ dvec_internal<LEN> data;
- dvec(const vec_internal<LEN>& d);
+ dvec(const dvec_internal<LEN>& d);
+ dvec(const fvec_internal<LEN>& f);
};
//#define DVEC4(V, t, a, b, c, d) double v#t[4] VEC_ALIGN = {(a), (b), (c),
(d)}; V(v#t)
@@ -180,10 +187,15 @@
return sqrt(sq.foldr(0, dvec<2>::add()));
}
inline
- void move(pt2d_t a, const pt2d_t b) {
+ void move(pt2d_t a, const float *b) {
a[0] = b[0];
a[1] = b[1];
}
+ inline
+ void move(pt2d_t a, const double *b) {
+ a[0] = b[0];
+ a[1] = b[1];
+ }
}
#endif /* __DVEC_H__ */
Modified: brlcad/trunk/include/nurbs.h
===================================================================
--- brlcad/trunk/include/nurbs.h 2012-10-02 04:34:50 UTC (rev 52653)
+++ brlcad/trunk/include/nurbs.h 2012-10-02 04:36:17 UTC (rev 52654)
@@ -230,7 +230,7 @@
* min----------------*
* u
*/
- void GetBBox(double* min, double* max) const;
+ void GetBBox(fastf_t* min, fastf_t* max) const;
/** Surface Information */
const ON_BrepFace* m_face;
@@ -425,7 +425,7 @@
template<class BA>
inline void
_BU_ATTR_ALWAYS_INLINE
-BANode<BA>::GetBBox(double* min, double* max) const
+BANode<BA>::GetBBox(fastf_t* min, fastf_t* max) const
{
VSETALL(min, MAX_FASTF);
VSETALL(max, -MAX_FASTF);
@@ -865,6 +865,7 @@
// - _ | _ -
// min
//
+ void GetBBox(float* min, float* max);
void GetBBox(double* min, double* max);
// Surface Information
@@ -1053,6 +1054,18 @@
template<class BV>
inline void
+BVNode<BV>::GetBBox(float* min, float* max)
+{
+ min[0] = m_node.m_min[0];
+ min[1] = m_node.m_min[1];
+ min[2] = m_node.m_min[2];
+ max[0] = m_node.m_max[0];
+ max[1] = m_node.m_max[1];
+ max[2] = m_node.m_max[2];
+}
+
+template<class BV>
+inline void
BVNode<BV>::GetBBox(double* min, double* max)
{
min[0] = m_node.m_min[0];
Modified: brlcad/trunk/include/vector_fpu.h
===================================================================
--- brlcad/trunk/include/vector_fpu.h 2012-10-02 04:34:50 UTC (rev 52653)
+++ brlcad/trunk/include/vector_fpu.h 2012-10-02 04:36:17 UTC (rev 52654)
@@ -33,11 +33,16 @@
#endif
template<int LEN>
-struct vec_internal {
+struct dvec_internal {
double v[LEN] VEC_ALIGN;
};
template<int LEN>
+struct fvec_internal {
+ float v[LEN] VEC_ALIGN;
+};
+
+template<int LEN>
inline dvec<LEN>::dvec(double s)
{
for (int i = 0; i < LEN; i++)
@@ -45,13 +50,20 @@
}
template<int LEN>
-inline dvec<LEN>::dvec(const double* vals, bool UNUSED(aligned))
+inline dvec<LEN>::dvec(const float* vals)
{
for (int i = 0; i < LEN; i++)
data.v[i] = vals[i];
}
template<int LEN>
+inline dvec<LEN>::dvec(const double* vals)
+{
+ for (int i = 0; i < LEN; i++)
+ data.v[i] = vals[i];
+}
+
+template<int LEN>
inline dvec<LEN>::dvec(const dvec<LEN>& p)
{
for (int i = 0; i < LEN; i++)
@@ -59,13 +71,20 @@
}
template<int LEN>
-inline dvec<LEN>::dvec(const vec_internal<LEN>& d)
+inline dvec<LEN>::dvec(const dvec_internal<LEN>& d)
{
for (int i = 0; i < LEN; i++)
data.v[i] = d.v[i];
}
template<int LEN>
+inline dvec<LEN>::dvec(const fvec_internal<LEN>& f)
+{
+ for (int i = 0; i < LEN; i++)
+ data.v[i] = f.v[i];
+}
+
+template<int LEN>
inline dvec<LEN>&
dvec<LEN>::operator=(const dvec<LEN>& p)
{
@@ -83,6 +102,13 @@
template<int LEN>
inline void
+dvec<LEN>::u_store(float* arr) const
+{
+ a_store(arr);
+}
+
+template<int LEN>
+inline void
dvec<LEN>::u_store(double* arr) const
{
a_store(arr);
@@ -90,6 +116,14 @@
template<int LEN>
inline void
+dvec<LEN>::a_store(float* arr) const
+{
+ for (int i = 0; i < LEN; i++)
+ arr[i] = data.v[i];
+}
+
+template<int LEN>
+inline void
dvec<LEN>::a_store(double* arr) const
{
for (int i = 0; i < LEN; i++)
@@ -109,7 +143,7 @@
inline dvec<LEN>
dvec<LEN>::operator+(const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] + b.data.v[i];
return dvec<LEN>(r);
@@ -119,7 +153,7 @@
inline dvec<LEN>
dvec<LEN>::operator-(const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] - b.data.v[i];
return dvec<LEN>(r);
@@ -129,7 +163,7 @@
inline dvec<LEN>
dvec<LEN>::operator*(const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] * b.data.v[i];
return dvec<LEN>(r);
@@ -139,7 +173,7 @@
inline dvec<LEN>
dvec<LEN>::operator/(const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] / b.data.v[i];
return dvec<LEN>(r);
@@ -149,7 +183,7 @@
inline dvec<LEN>
dvec<LEN>::madd(const dvec<LEN>& s, const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] * s.data.v[i] + b.data.v[i];
return dvec<LEN>(r);
@@ -159,7 +193,7 @@
inline dvec<LEN>
dvec<LEN>::madd(const double s, const dvec<LEN>& b)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < LEN; i++)
r.v[i] = data.v[i] * s + b.data.v[i];
return dvec<LEN>(r);
@@ -190,7 +224,7 @@
inline dvec<LEN>
dvec<LEN>::map(const dvec_unop& op, int limit)
{
- vec_internal<LEN> r;
+ dvec_internal<LEN> r;
for (int i = 0; i < limit; i++) {
r.v[i] = op(data.v[i]);
}
Modified: brlcad/trunk/src/libnurbs/PullbackCurve.cpp
===================================================================
--- brlcad/trunk/src/libnurbs/PullbackCurve.cpp 2012-10-02 04:34:50 UTC (rev
52653)
+++ brlcad/trunk/src/libnurbs/PullbackCurve.cpp 2012-10-02 04:36:17 UTC (rev
52654)
@@ -155,8 +155,11 @@
pr.d2 = p2d;
try {
- ON_2dPoint uv = surftree->getClosestPointEstimate(knudgedPointOnCurve);
- ON_3dVector dir = surf->NormalAt(uv.x, uv.y);
+ pt2d_t uv;
+ ON_2dPoint uv2d =
surftree->getClosestPointEstimate(knudgedPointOnCurve);
+ move(uv, uv2d);
+
+ ON_3dVector dir = surf->NormalAt(uv[0], uv[1]);
dir.Reverse();
ON_Ray ray(pointOnCurve, dir);
brep_get_plane_ray(ray, pr);
@@ -190,7 +193,7 @@
}
///////////////////////////////////////
- out_pt.Set(uv.x, uv.y);
+ out_pt.Set(uv[0], uv[1]);
return true;
} catch(...) {
return false;
Modified: brlcad/trunk/src/libnurbs/opennurbs_ext.cpp
===================================================================
--- brlcad/trunk/src/libnurbs/opennurbs_ext.cpp 2012-10-02 04:34:50 UTC (rev
52653)
+++ brlcad/trunk/src/libnurbs/opennurbs_ext.cpp 2012-10-02 04:36:17 UTC (rev
52654)
@@ -89,17 +89,25 @@
void
brep_r(const ON_Surface* surf, plane_ray& pr, pt2d_t uv, ON_3dPoint& pt,
ON_3dVector& su, ON_3dVector& sv, pt2d_t R)
{
+ vect_t vp;
+
assert(surf->Ev1Der(uv[0], uv[1], pt, su, sv));
- R[0] = VDOT(pr.n1, ((fastf_t*)pt)) - pr.d1;
- R[1] = VDOT(pr.n2, ((fastf_t*)pt)) - pr.d2;
+ VMOVE(vp, pt);
+
+ R[0] = VDOT(pr.n1, vp) - pr.d1;
+ R[1] = VDOT(pr.n2, vp) - pr.d2;
}
void
brep_newton_iterate(plane_ray& pr, pt2d_t R, ON_3dVector& su, ON_3dVector& sv,
pt2d_t uv, pt2d_t out_uv)
{
- mat2d_t jacob = { VDOT(pr.n1, ((fastf_t*)su)), VDOT(pr.n1, ((fastf_t*)sv)),
- VDOT(pr.n2, ((fastf_t*)su)), VDOT(pr.n2, ((fastf_t*)sv))
};
+ vect_t vsu, vsv;
+ VMOVE(vsu, su);
+ VMOVE(vsv, sv);
+
+ mat2d_t jacob = { VDOT(pr.n1, vsu), VDOT(pr.n1, vsv),
+ VDOT(pr.n2, vsu), VDOT(pr.n2, vsv) };
mat2d_t inv_jacob;
if (mat2d_inverse(inv_jacob, jacob)) {
// check inverse validity
@@ -115,8 +123,12 @@
void
brep_newton_iterate(const ON_Surface* UNUSED(surf), plane_ray& pr, pt2d_t R,
ON_3dVector& su, ON_3dVector& sv, pt2d_t uv, pt2d_t out_uv)
{
- mat2d_t jacob = { VDOT(pr.n1, ((fastf_t*)su)), VDOT(pr.n1, ((fastf_t*)sv)),
- VDOT(pr.n2, ((fastf_t*)su)), VDOT(pr.n2, ((fastf_t*)sv))
};
+ vect_t vsu, vsv;
+ VMOVE(vsu, su);
+ VMOVE(vsv, sv);
+
+ mat2d_t jacob = { VDOT(pr.n1, vsu), VDOT(pr.n1, vsv),
+ VDOT(pr.n2, vsu), VDOT(pr.n2, vsv) };
mat2d_t inv_jacob;
if (mat2d_inverse(inv_jacob, jacob)) {
// check inverse validity
@@ -221,14 +233,14 @@
double *knots = new double[knotcnt + 1];
trimCurve->GetSpanVector(knots);
- std::list<double> splitlist;
+ std::list<fastf_t> splitlist;
for (int knot_index = 1; knot_index <= knotcnt; knot_index++) {
ON_Interval range(knots[knot_index - 1], knots[knot_index]);
if (range.Length() > TOL)
getHVTangents(trimCurve, range, splitlist);
}
- for (std::list<double>::iterator l = splitlist.begin(); l !=
splitlist.end(); l++) {
+ for (std::list<fastf_t>::iterator l = splitlist.begin(); l !=
splitlist.end(); l++) {
double xmax = *l;
if (!NEAR_EQUAL(xmax, min, TOL)) {
m_root->addChild(subdivideCurve(trimCurve,
adj_face_index, min, xmax, innerLoop, 0));
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits