[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob ctest/test.cxx include/vob/Coorder.hxx i...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob ctest/test.cxx include/vob/Coorder.hxx i... |
Date: |
Mon, 10 Mar 2003 11:02:06 -0500 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/03/10 11:02:05
Modified files:
ctest : test.cxx
include/vob : Coorder.hxx LinearPrimitives.hxx Primitives.hxx
VecGL.hxx
include/vob/jni: Generate.hxx
org/nongnu/libvob: AffineVobCoorder.java VobScene.java
org/nongnu/libvob/impl/gl: GLRenderingSurface.java
GLVobCoorder.java
src/jni : Gen.cxx
src/trans : Coorder.cxx
Log message:
The coords stuff is now almost there
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/ctest/test.cxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Coorder.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/LinearPrimitives.hxx.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/Primitives.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/VecGL.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Generate.hxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/AffineVobCoorder.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/VobScene.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/jni/Gen.cxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/trans/Coorder.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/ctest/test.cxx
diff -u libvob/ctest/test.cxx:1.4 libvob/ctest/test.cxx:1.5
--- libvob/ctest/test.cxx:1.4 Fri Feb 28 08:56:07 2003
+++ libvob/ctest/test.cxx Mon Mar 10 11:02:04 2003
@@ -35,13 +35,14 @@
using namespace Vob;
RootCoords root;
+Transform *rootPtr = &root;
void testTranslateXYZ() {
- typedef HierarchicalTransform<TranslateXYZ_Explicit> T;
+ typedef PrimitiveHierarchicalTransform<TranslateXYZ_Explicit> T;
T t;
float pars[3] = { 1.5, 2.5, 3.5 };
BOOST_CHECK_EQUAL(t.getNParams(), 3);
- t.setParams(&root, 0, pars);
+ t.setParams((const Transform**)&rootPtr, pars);
ZPt p = t.transform(ZPt(100,200,300));
BOOST_CHECK_CLOSE(p.x+.0, 101.5, .001);
BOOST_CHECK_CLOSE(p.y+.0, 202.5, .001);
@@ -62,13 +63,14 @@
}
void testDependent_UnitSqBox() {
- typedef HierarchicalTransform<Box_Explicit> T1;
- typedef HierarchicalTransform<UnitSqBox> T2;
+ typedef PrimitiveHierarchicalTransform<Box_Explicit> T1;
+ typedef PrimitiveHierarchicalTransform<UnitSqBox> T2;
T1 t1;
+ T1 *t1p = &t1;
T2 t2;
float pars[2] = {100, 200};
- t1.setParams(&root, 0, pars);
- t2.setParams(&t1, 0, pars);
+ t1.setParams((const Transform**)&rootPtr, pars);
+ t2.setParams((const Transform**)&t1p, pars);
ZPt p = t2.transform(ZPt(0,0,0));
BOOST_CHECK_CLOSE(p.x+.0, 0., .001);
BOOST_CHECK_CLOSE(p.y+.0, 0., .001);
@@ -83,9 +85,9 @@
float params[100];
template<class T> void code(T t__) {
- typedef HierarchicalTransform<T> H;
+ typedef PrimitiveHierarchicalTransform<T> H;
H *t = new H();
- t->setParams(&root, 0, params);
+ t->setParams((const Transform**)&rootPtr, params);
delete t;
}
Index: libvob/include/vob/Coorder.hxx
diff -u libvob/include/vob/Coorder.hxx:1.1 libvob/include/vob/Coorder.hxx:1.2
--- libvob/include/vob/Coorder.hxx:1.1 Mon Mar 10 09:26:18 2003
+++ libvob/include/vob/Coorder.hxx Mon Mar 10 11:02:04 2003
@@ -1,22 +1,28 @@
// (c) Tuomas J. Lukka and Asko Soukka
-#include <Vob/Transform.hxx>
+#include <vector>
+#include <vob/Transform.hxx>
+#include <vob/Primitives.hxx>
namespace Vob {
-typedef Transform *(*TransformFactory)(int i);
+enum {
+ CSFLAG_ACTIVE = 0x80000000,
+ CSFLAGS = 0xf0000000
+};
+
+
+
+typedef Primitives::HierarchicalTransform *(*TransformFactory)(int i);
/** A class that manages a set of coordinate systems.
*/
class Coorder {
- vector<Transform *> cs;
- vector<float> params;
+ std::vector<Transform *> cs;
+ std::vector<float> params;
int maxcs;
- int nparams(int typecode) ;
- int nprevious(int typecode) ;
-
TransformFactory transformFactory;
Coorder *cs1_tmp ;
@@ -67,6 +73,7 @@
bool operator!=(const iterator &it) const { return ind != it.ind; }
};
+
/** Return an iterator pointing to the first coordinate system
* (not root, i.e. not 0).
*/
Index: libvob/include/vob/LinearPrimitives.hxx
diff -u libvob/include/vob/LinearPrimitives.hxx:1.7
libvob/include/vob/LinearPrimitives.hxx:1.8
--- libvob/include/vob/LinearPrimitives.hxx:1.7 Mon Mar 10 06:15:12 2003
+++ libvob/include/vob/LinearPrimitives.hxx Mon Mar 10 11:02:05 2003
@@ -88,7 +88,6 @@
}
};
-
/** Expose the vec in TranslateXYZ and ScaleXYZ and possibly
* others explicitly.
*/
@@ -110,6 +109,58 @@
VOB_PRIMITIVETRANS_DEFINED(TranslateXYZ_Explicit, "translate");
VOB_PRIMITIVETRANS_DEFINED(ScaleXYZ_Explicit, "scale");
+
+ /** Rotation clockwise.
+ */
+ class RotateXY :
+ public PrimitiveTransform,
+ public GLPerformablePrimitiveTransform
+ {
+ protected:
+ float a;
+ void angleWasSet() {
+ s = sin(a * M_PI / 180);
+ c = cos(a * M_PI / 180);
+ }
+ private:
+ float s, c;
+ public:
+ RotateXY() { }
+ RotateXY(float angle) {
+ a = angle;
+ angleWasSet();
+ }
+ /** Perform the internal transformation of this
+ * coordsys.
+ */
+ void tr(const ZPt &from, ZPt &to) const {
+ to.x = c * from.x + -s * from.y;
+ to.y = s * from.x + c * from.y;
+ to.z = from.z;
+ }
+ void performGL() const {
+ glRotatef(a, 0, 0, 1);
+ }
+ typedef RotateXY InverseType;
+ void inverse(RotateXY &into) const {
+ into.a = -a;
+ into.angleWasSet();
+ }
+ };
+
+ struct RotateXY_Explicit :
+ public RotateXY,
+ public ParametrizedPrimitiveTransform {
+
+ enum {NParams = 1 };
+
+ template<class Ptr> void setParams(Ptr p) {
+ a = p[0];
+ angleWasSet();
+ }
+ };
+ VOB_PRIMITIVETRANS_DEFINED(RotateXY_Explicit, "rotate");
+
/** A no-op: same coords in and out.
*/
class Unit :
@@ -298,8 +349,8 @@
public DependentPrimitiveTransform
{
enum { NDepends = 1 }; // just parent
- template<class SPtr> void setParams(const Transform *super, SPtr
depends) {
- Pt p = super->getSqSize();
+ template<class SPtr> void setParams(SPtr depends) {
+ Pt p = depends[0]->getSqSize();
vec.x = p.x;
vec.y = p.y;
vec.z = 1;
Index: libvob/include/vob/Primitives.hxx
diff -u libvob/include/vob/Primitives.hxx:1.11
libvob/include/vob/Primitives.hxx:1.12
--- libvob/include/vob/Primitives.hxx:1.11 Mon Mar 10 09:26:18 2003
+++ libvob/include/vob/Primitives.hxx Mon Mar 10 11:02:05 2003
@@ -213,19 +213,21 @@
};
- class HierarchicalTransform {
+ /** A type of transform which exposes a vector of
+ * float parameters and parent transformations.
+ */
+ struct HierarchicalTransform : public Transform {
virtual int getNParams() = 0;
virtual int getNDepends() = 0;
- virtual void setParams(const Transform *super,
- const Transform **depends, float *p) = 0;
- }
+ virtual void setParams(const Transform **depends, float *p) = 0;
+ };
/** A hierarchical transformation, which applies the
* template argument primitive transformation to the result
* of the parent transform.
*/
template<class Primitive> class PrimitiveHierarchicalTransform :
- public Transform , public HierarchicalTransform
+ public HierarchicalTransform
{
const Transform *super;
Transform *inverse;
@@ -282,21 +284,21 @@
// Difficult: double switches: dependent, parametrized for setParams..
void setParams(DependentPrimitiveTransform *t__,
- const Transform *super, const Transform **depends, float *p) {
- setDependentParams(&t, super, depends, p);
+ const Transform **depends, float *p) {
+ setDependentParams(&t, depends, p);
}
void setParams(void *__t,
- const Transform *super, const Transform **depends, float *p) {
+ const Transform **depends, float *p) {
setNondependentParams(&t, p);
}
void setDependentParams(ParametrizedPrimitiveTransform *t__,
- const Transform *super, const Transform **depends, float *p) {
- t.setParams(super, depends, p);
+ const Transform **depends, float *p) {
+ t.setParams(depends, p);
}
void setDependentParams(void *t__,
- const Transform *super, const Transform **depends, float *p) {
- t.setParams(super, depends);
+ const Transform **depends, float *p) {
+ t.setParams(depends);
}
void setNondependentParams(void *t__,
@@ -309,11 +311,11 @@
}
public:
- HierarchicalTransform() {
+ PrimitiveHierarchicalTransform() {
super = 0;
inverse = 0;
}
- virtual ~HierarchicalTransform() {
+ virtual ~PrimitiveHierarchicalTransform() {
if(inverse) delete inverse;
}
@@ -325,9 +327,9 @@
return getNDepends(t);
}
- virtual void setParams(const Transform *super, const Transform
**depends, float *p) {
- this->super = super;
- setParams(&t, super, depends, p);
+ virtual void setParams(const Transform **depends, float *p) {
+ this->super = depends[0];
+ setParams(&t, depends, p);
}
@@ -365,7 +367,7 @@
= new InverseHierarchicalTransform<typename
Primitive::InverseType>(
&(super->getInverse()), this);
t.inverse(inv->t);
- ((HierarchicalTransform<Primitive> *)this)
+ ((PrimitiveHierarchicalTransform<Primitive> *)this)
->inverse = inv;
}
return *inverse;
Index: libvob/include/vob/VecGL.hxx
diff -u libvob/include/vob/VecGL.hxx:1.1 libvob/include/vob/VecGL.hxx:1.2
--- libvob/include/vob/VecGL.hxx:1.1 Tue Feb 25 09:18:10 2003
+++ libvob/include/vob/VecGL.hxx Mon Mar 10 11:02:05 2003
@@ -29,14 +29,13 @@
#ifndef __VECGL_HXX
#define __VECGL_HXX
-#include <libutil/Vec23.hxx>
#include <GL/gl.h>
+#include <vob/Vec23.hxx>
/** Useful overloads for OpenGL routines using Vec23.
*/
-namespace VecGL {
- using namespace Vec23;
+namespace Vob {
inline void glVertex(const ZVec &v) {
glVertex3f(v.x, v.y, v.z);
Index: libvob/include/vob/jni/Generate.hxx
diff -u libvob/include/vob/jni/Generate.hxx:1.13
libvob/include/vob/jni/Generate.hxx:1.14
--- libvob/include/vob/jni/Generate.hxx:1.13 Mon Mar 10 09:26:18 2003
+++ libvob/include/vob/jni/Generate.hxx Mon Mar 10 11:02:05 2003
@@ -41,12 +41,14 @@
#ifndef VOB_JNI_GENERATE_HXX
#define VOB_JNI_GENERATE_HXX
+#include <string>
+#include <cctype>
+#include <iostream>
+
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/preprocessor/iteration/local.hpp>
-#include <string>
-#include <iostream>
#include <vob/Primitives.hxx>
#include <vob/Transform.hxx>
@@ -175,7 +177,7 @@
template<class Primitive> struct TransJNIGenerator {
int ind;
- Primitives::HierarchicalTransform<Primitive> hier;
+ Primitives::PrimitiveHierarchicalTransform<Primitive> hier;
TransJNIGenerator(std::string className, std::string methodName) {
ind = index++;
@@ -216,6 +218,19 @@
VOB_TRANSCSTREAM << " case "<<ind<<": \n"
<< "\t\tTRANSTYPE("<<className<<");break;\n";
+
+ if(hier.getNParams() > 0) {
+ std::string n = methodName;
+ n[0] = std::toupper(n[0]);
+ VOB_TRANSJAVASTREAM << "public void set"<<n
+ <<"Params(int ind";
+ for(int i=0; i<hier.getNParams(); i++)
+ VOB_TRANSJAVASTREAM << ", float p"<<i;
+ VOB_TRANSJAVASTREAM<<") {\n";
+ VOB_TRANSJAVASTREAM<<"int i = inds[ind+"<<
+ (hier.getNDepends()+1)<<"];";
+ VOB_TRANSJAVASTREAM << passignCode.str() << "}\n";
+ }
}
};
Index: libvob/org/nongnu/libvob/AffineVobCoorder.java
diff -u libvob/org/nongnu/libvob/AffineVobCoorder.java:1.2
libvob/org/nongnu/libvob/AffineVobCoorder.java:1.3
--- libvob/org/nongnu/libvob/AffineVobCoorder.java:1.2 Fri Mar 7 06:38:19 2003
+++ libvob/org/nongnu/libvob/AffineVobCoorder.java Mon Mar 10 11:02:05 2003
@@ -37,7 +37,7 @@
*/
public int ortho(int into, float depth,
float x, float y, float sx, float sy) {
- return affineCoordsys(into, depth,
+ return affine(into, depth,
x, y, sx, 0, 0, sy);
}
public void setOrthoParams(int cs, float depth,
@@ -47,7 +47,7 @@
}
- public abstract int affineCoordsys(int into, float depth,
+ public abstract int affine(int into, float depth,
float x, float y,
float xx, float xy, float yx, float yy);
Index: libvob/org/nongnu/libvob/VobScene.java
diff -u libvob/org/nongnu/libvob/VobScene.java:1.2
libvob/org/nongnu/libvob/VobScene.java:1.3
--- libvob/org/nongnu/libvob/VobScene.java:1.2 Fri Mar 7 06:38:21 2003
+++ libvob/org/nongnu/libvob/VobScene.java Mon Mar 10 11:02:05 2003
@@ -165,7 +165,7 @@
float depth, float cx, float cy,
float x_x, float x_y, float y_x, float y_y) {
return matcher.add(into,
- af().affineCoordsys(into, depth, cx, cy,
+ af().affine(into, depth, cx, cy,
x_x, x_y, y_x, y_y), key
);
}
Index: libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java
diff -u libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java:1.2
libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java:1.3
--- libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java:1.2 Fri Mar
7 06:38:22 2003
+++ libvob/org/nongnu/libvob/impl/gl/GLRenderingSurface.java Mon Mar 10
11:02:05 2003
@@ -39,7 +39,7 @@
import org.nongnu.libvob.gl.*;
public class GLRenderingSurface extends GraphicsAPI.AbstractRenderingSurface {
-public static final String rcsid = "$Id: GLRenderingSurface.java,v 1.2
2003/03/07 11:38:22 tjl Exp $";
+public static final String rcsid = "$Id: GLRenderingSurface.java,v 1.3
2003/03/10 16:02:05 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
@@ -63,7 +63,7 @@
public VobScene createVobScene(Dimension size) {
VobScene vs = new VobScene(
new GLVobMap(this),
- new GLVobCoorder(),
+ new GLVobCoorder_Gen(),
new DefaultVobMatcher(),
this.getGraphicsAPI(),
this,
Index: libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java
diff -u libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.2
libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.3
--- libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java:1.2 Mon Mar 10
09:26:18 2003
+++ libvob/org/nongnu/libvob/impl/gl/GLVobCoorder.java Mon Mar 10 11:02:05 2003
@@ -31,8 +31,8 @@
import org.nongnu.libvob.gl.*;
import java.util.HashMap;
-public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.2 2003/03/10
14:26:18 tjl Exp $";
+public abstract class GLVobCoorder extends AffineVobCoorder {
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.3 2003/03/10
16:02:05 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
@@ -56,8 +56,8 @@
if (dbg) {
for (int i=0; i<inds.length; i++) {
- pa("original: "+getCoordSystemStr(inds[i]));
- pa("parent: "+ getCoordSystemStr(getParent(inds[i])));
+ // pa("original: "+getCoordSystemStr(inds[i]));
+ // pa("parent: "+ getCoordSystemStr(getParent(inds[i])));
}
}
Index: libvob/src/jni/Gen.cxx
diff -u libvob/src/jni/Gen.cxx:1.8 libvob/src/jni/Gen.cxx:1.9
--- libvob/src/jni/Gen.cxx:1.8 Mon Mar 10 09:26:18 2003
+++ libvob/src/jni/Gen.cxx Mon Mar 10 11:02:05 2003
@@ -74,8 +74,8 @@
jni << "using namespace Vob::JNI;\n";
jni << "using namespace Vob::Primitives;\n";
jni << "namespace Vob { \n";
- jni << "#define TRANSTYPE(x) return new HierarchicalTransform<x>()\n";
- jni << "Transform *defaultTransformFactory(int id) {\n";
+ jni << "#define TRANSTYPE(x) return new
PrimitiveHierarchicalTransform<x>()\n";
+ jni << "HierarchicalTransform *defaultTransformFactory(int id) {\n";
jni << " switch(id) {\n" << VOB_TRANSCSTREAM.str()<<"\n";
jni << " default: return 0;\n";
jni << " }}\n";
Index: libvob/src/trans/Coorder.cxx
diff -u libvob/src/trans/Coorder.cxx:1.1 libvob/src/trans/Coorder.cxx:1.2
--- libvob/src/trans/Coorder.cxx:1.1 Mon Mar 10 09:26:18 2003
+++ libvob/src/trans/Coorder.cxx Mon Mar 10 11:02:05 2003
@@ -1,12 +1,116 @@
// (c) Tuomas J. Lukka and Asko Soukka
-#include <Vob/Coorder.hxx>
+#include <vob/Coorder.hxx>
+#include <vob/VecGL.hxx>
#define DBG(cname) if(!cname);else (std::cout << "CallGL: ")
+static bool dbg;
+
namespace Vob {
-Coorder::Coorder() : cs1_tmp(0), cs2_tmp(0) {
+/** A transform that interpolates between
+ * two transforms pointwise.
+ */
+struct PointInterpTransform : public Transform {
+ const Transform &cs1, &cs2;
+ float fract;
+ bool didGetMat;
+ float mat[16];
+ Transform *inv;
+
+ PointInterpTransform(const Transform &cs1, const Transform &cs2,
+ float fract)
+ : cs1(cs1), cs2(cs2), fract(fract), inv(0) { }
+ virtual void vertex(const ZPt &p) const {
+ glVertex(transform(p));
+ }
+ virtual ZPt transform(const ZPt &p) const {
+ ZPt res = lerp(cs1.transform(p),
+ cs2.transform(p),
+ fract);
+ DBG(dbg) << "PointInterp: "<<p<<": "<<fract<<" "<<
+ cs1.transform(p) << " " << cs2.transform(p) << " "
+ << res<<"\n";
+ return res;
+ }
+ virtual float nonlinearity(const ZPt &p, float radius) const {
+ return lerp(cs1.nonlinearity(p, radius),
+ cs2.nonlinearity(p, radius), fract);
+ }
+ virtual void dump(std::ostream &out) const {
+ out << "Pointinterp\n";
+ };
+
+ virtual bool shouldBeDrawn() const {
+ return cs1.shouldBeDrawn() && cs2.shouldBeDrawn();
+ }
+ virtual Pt getSqSize() const {
+ return lerp(cs1.getSqSize(), cs2.getSqSize(), fract);
+ }
+
+ bool canPerformGL() const {
+ return cs1.canPerformGL() && cs2.canPerformGL();
+ }
+
+ void getMat() const {
+ if(didGetMat) return;
+
+ GLfloat mat1[16], mat2[16];
+ glPushAttrib(GL_TRANSFORM_BIT);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
+ glLoadIdentity();
+ cs1.performGL();
+ glGetFloatv(GL_MODELVIEW_MATRIX, mat1);
+
+ glLoadIdentity();
+ cs2.performGL();
+ glGetFloatv(GL_MODELVIEW_MATRIX, mat2);
+
+ DBG(dbg) << "PointInterp PerformGL!\n";
+ if(dbg) {
+ for(int i=0; i<16; i++) DBG(dbg) << mat1[i] << " ";
+ DBG(dbg) << "\n";
+ for(int i=0; i<16; i++) DBG(dbg) << mat2[i] << " ";
+ DBG(dbg) << "\n";
+ }
+ for(int i=0; i<16; i++)
+ ((float *)mat)[i] = lerp(mat1[i], mat2[i], fract);
+
+
+ glPopMatrix();
+ glPopAttrib();
+
+
+ }
+
+
+ bool performGL() const {
+ // XXX Allow using of vertex weighting or something
+ if(!canPerformGL()) return false;
+ getMat();
+ glMultMatrixf(mat);
+ return true;
+ }
+ const Transform &getInverse() const {
+ /*
+ if(canPerformGL()) {
+ getMat();
+ return new MatrixCoordSys(invertMat(mat));
+ } else {
+ */
+ // Badly wrong
+ if(inv == 0)
+ ((PointInterpTransform *)this)->inv = new
PointInterpTransform(cs1.getInverse(), cs2.getInverse(), fract);
+ return *inv;
+ }
+};
+
+
+Coorder::Coorder(TransformFactory fac) :
+ transformFactory(fac), cs1_tmp(0), cs2_tmp(0) {
}
Coorder::~Coorder() {
DBG(dbg) << "Deleting coordset "<<this<<" "<<cs1_tmp<<" "<<cs2_tmp<<"\n";
@@ -73,8 +177,14 @@
int tp = inds1[i] & ~CSFLAGS;
- int npars = nparams(tp);
- int nprev = nprevious(tp);
+ Transform *c = 0;
+ // Used as a temp; set to null if moved to c.
+ Primitives::HierarchicalTransform *tmp_c;
+ tmp_c = transformFactory(tp);
+ if(!tmp_c) abort();
+
+ int npars = tmp_c->getNParams();
+ int nprev = tmp_c->getNDepends();
int ind1;
int csind2;
@@ -86,12 +196,13 @@
DBG(dbg) << "inds: "<<parind<<" typ:"<<tp<<" npars:"<<npars<<
" ind1:"<<ind1<<" "<<csind2<<"\n";
- Transform *c;
+
int t2 = 0;
int ind2 = 0;
if(csind2 > 0) {
t2 = inds2[csind2] & ~CSFLAGS;
- ind2 = inds2[csind2 + 1 + nprevious(t2)];
+ if(t2 != tp) goto interpolatePointwise;
+ ind2 = inds2[csind2 + 1 + nprev]; // same as cs1
}
// We need to interpolate. Check the structural constraints:
// If
@@ -120,7 +231,7 @@
points2[ind2 + j], fract));
}
}
- Transform *prev[nprev];
+ const Transform *prev[nprev];
for(int j=0; j<nprev; j++) {
int parent = inds1[i+1+j];
@@ -137,14 +248,15 @@
* params. If the initialized coordsys (according to its
initialized attributes)
* decides not to be drawn, it will be deleted and replaced with
the NULL pointer.
*/
- c = create(tp);
- c->setSuper(prev);
- c->setParams(&(params[0]) + parind);
+ tmp_c->setParams(prev, &(params[0]) + parind);
+ c = tmp_c;
+ tmp_c = 0;
} else {
+ interpolatePointwise:
// Now, the hairy case.
DBG(dbg) << "It got hairy now: "<<tp<<" "<<t2<<"\n";
if(!cs1_tmp) {
- cs1_tmp = new Coorder();
+ cs1_tmp = new Coorder(transformFactory);
cs1_tmp->setPoints(ninds, inds1, points1,
0, 0, 0, 0, true);
}
@@ -153,7 +265,7 @@
for(int k = 1; k<interpinds[0]; k++)
if(interpinds[k] > maxind)
maxind = interpinds[k];
- cs2_tmp = new Coorder();
+ cs2_tmp = new Coorder(transformFactory);
cs2_tmp->setPoints(maxind+1, inds2, points2, 0, 0, 0,
0, true);
}
@@ -162,7 +274,7 @@
if(!cs1_non || !cs2_non) goto nextInd;
- c = new PointInterpCoordSys(cs1_non, cs2_non, fract);
+ c = new PointInterpTransform(*cs1_non, *cs2_non, fract);
}
{
@@ -174,7 +286,8 @@
cs[i] = NULL;
}
}
- nextInd:;
+ nextInd:
+ if(tmp_c) delete tmp_c;
}
DBG(dbg) << "end: "<<cs1_tmp<<" "<<cs2_tmp<<"\n";
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] libvob ctest/test.cxx include/vob/Coorder.hxx i...,
Tuomas J. Lukka <=