Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding cloud to mesh as ball pivot, marching cubes is up next

  • Loading branch information...
commit a60201fc7b8c88e02ac44db1e3133c55de8aad16 1 parent eb14c24
base authored
View
150 src/ofxMeshFace.cpp
@@ -2,8 +2,6 @@
* ofxMeshFace.cpp
* emptyExample
*
- * Created by base on 15/04/11.
- * Copyright 2011 __MyCompanyName__. All rights reserved.
*
*/
@@ -13,36 +11,136 @@
ofxMeshFace::ofxMeshFace(ofVec3f a, ofVec3f b, ofVec3f c)
{
- if(!va) {
- va = new ofxVCGVertex(a);
- _face.V0(0) = va;
- } else {
- va->update(a);
- }
-
- if(!vb) {
- vb = new ofxVCGVertex(b);
- _face.V0(1) = vb;
- } else {
- va->update(a);
- }
-
- if(!vc) {
- vc = new ofxVCGVertex(c);
- _face.V0(2) = vc;
- } else {
- va->update(a);
- }
+ vv0.update(a);
+ vv1.update(a);
+ vv2.update(a);
+ ofv0 = a;
+ ofv1 = a;
+ ofv2 = a;
+
+}
+
+ofxMeshFace::ofxMeshFace(ofxVCGVertex a, ofxVCGVertex b, ofxVCGVertex c)
+{
+
+ // not sure about copying these this way...
+ vv0.P() = a.P();
+ vv0.N() = a.N();
+ vv0.Flags() = a.Flags();
+ vv0.C() = a.C();
+
+ // not sure about copying these this way...
+ vv2.P() = b.P();
+ vv2.N() = b.N();
+ vv2.Flags() = b.Flags();
+ vv2.C() = b.C();
+
+ // not sure about copying these this way...
+ vv1.P() = c.P();
+ vv1.N() = c.N();
+ vv1.Flags() = c.Flags();
+ vv1.C() = c.C();
+
+ ofv0 = vv0.toOf();
+ ofv1 = vv1.toOf();
+ ofv2 = vv2.toOf();
+
+ ofn0 = vv0.normalToOf();
+ ofn1 = vv1.normalToOf();
+ ofn2 = vv2.normalToOf();
+}
+
+ofxMeshFace::ofxMeshFace(innerMesh::FacePointer fp)
+{
+ // not sure about copying these this way...
+ vv0.P() = fp->V(0)->P();
+ vv0.N() = fp->V(0)->N();
+ vv0.Flags() = fp->V(0)->Flags();
+ vv0.C() = fp->V(0)->C();
+
+ // not sure about copying these this way...
+ vv2.P() = fp->V(2)->P();
+ vv2.N() = fp->V(2)->N();
+ vv2.Flags() = fp->V(2)->Flags();
+ vv2.C() = fp->V(2)->C();
+
+ // not sure about copying these this way...
+ vv1.P() = fp->V(1)->P();
+ vv1.N() = fp->V(1)->N();
+ vv1.Flags() = fp->V(1)->Flags();
+ vv1.C() = fp->V(1)->C();
+
+ ofv0 = vv0.toOf();
+ ofv1 = vv1.toOf();
+ ofv2 = vv2.toOf();
+
+ ofn0 = vv0.normalToOf();
+ ofn1 = vv1.normalToOf();
+ ofn2 = vv2.normalToOf();
}
ofxMeshFace::ofxMeshFace()
{
+}
+ofxMeshFace::ofxMeshFace(const ofxMeshFace& copy)
+{
+ vv0 = copy.vv0;
+ vv1 = copy.vv1;
+ vv2 = copy.vv2;
+
+ ofv0 = copy.ofv0;
+ ofv1 = copy.ofv1;
+ ofv2 = copy.ofv2;
+
+ ofn0 = copy.ofn0;
+ ofn1 = copy.ofn1;
+ ofn2 = copy.ofn2;
+
+}
+
+ofxMeshFace& ofxMeshFace::operator=(const ofxMeshFace& rhs)
+{
+
+ if (this == &rhs) // Same object?
+ return *this;
+
+ vv0 = rhs.vv0;
+ vv1 = rhs.vv1;
+ vv2 = rhs.vv2;
+
+ ofv0 = rhs.ofv0;
+ ofv1 = rhs.ofv1;
+ ofv2 = rhs.ofv2;
+
+ ofn0 = rhs.ofn0;
+ ofn1 = rhs.ofn1;
+ ofn2 = rhs.ofn2;
+
+ return *this;
}
-void ofxMeshFace::addVertex(ofVec3f vert)
+void ofxMeshFace::addThisToMesh(innerMesh* m)
{
- //vcg::vert::Normal3fOcc vvert(vert);
- //vertices.push_back(vvert);
-}
+ Allocator<innerMesh>::AddVertices(*m,3);
+ Allocator<innerMesh>::AddFaces(*m,1);
+
+ innerMesh::VertexPointer ivp[3];
+ innerMesh::VertexIterator vi = m->vert.begin();
+ ivp[0]=&*vi;
+ (*vi).P() = Point3f( 1.0, 1.0, 1.0);
+ ++vi;
+ ivp[1]=&*vi;
+ (*vi).P() = Point3f (-1.0, 1.0,-1.0);
+ ++vi;
+ ivp[2]=&*vi;
+ (*vi).P() = Point3f (-1.0,-1.0, 1.0);
+ ++vi;
+
+ innerMesh::FaceIterator fi = m->face.begin();
+ (*fi).V(0)=ivp[0];
+ (*fi).V(1)=ivp[1];
+ (*fi).V(2)=ivp[2];
+
+}
View
57 src/ofxMeshFace.h
@@ -9,32 +9,61 @@
#include "ofMain.h"
#include "ofxVCGLibDefinitions.h"
-//#include <vcg/simplex/vertex/component_occ.h>
-//#include <vcg/simplex/face/component_occ.h>
-//#include <vcg/container/vector_occ.h>
-
-//using namespace vcg;
-
class ofxMeshFace
{
public:
ofxMeshFace(ofVec3f a, ofVec3f b, ofVec3f c);
+ ofxMeshFace(ofxVCGVertex a, ofxVCGVertex b, ofxVCGVertex c);
+ ofxMeshFace(innerMesh::FacePointer fp);
ofxMeshFace();
- //const ofxMeshFace();
- //const ofxMeshFace(ofVec3f a, ofVec3f b, ofVec3f c);
+ ofxMeshFace(const ofxMeshFace& copy);
+ ofxMeshFace& operator =(const ofxMeshFace& rhs);
+
+
+
+ ofVec3f& toOfV0() { return ofv0; }
+ ofVec3f& toOfV1() { return ofv1; }
+ ofVec3f& toOfV2() { return ofv2; }
+
+ ofVec3f& toOfN0() { return ofn0; }
+ ofVec3f& toOfN1() { return ofn1; }
+ ofVec3f& toOfN2() { return ofn2; }
+
+ ofxVCGVertex& toVcgV0() { return vv0; }
+ ofxVCGVertex& toVcgV1() { return vv1; }
+ ofxVCGVertex& toVcgV2() { return vv2; }
+
+ Point3f toVcgN0() { return vv0.N(); }
+ Point3f toVcgN1() { return vv1.N(); }
+ Point3f toVcgN2() { return vv2.N(); }
+
+ Point3f toVcgP0() { return vv0.P(); }
+ Point3f toVcgP1() { return vv1.P(); }
+ Point3f toVcgP2() { return vv2.P(); }
+
+ void addThisToMesh(innerMesh* m);
+
+protected:
- void addVertex(ofVec3f vert);
+ // there's no innerMeshFace b/c those are created using the
+ // addThisToMesh method
-private:
+ // normals are contained in the ofxVCGVertex
+ ofxVCGVertex vv0;
+ ofxVCGVertex vv1;
+ ofxVCGVertex vv2;
- innerMeshFace _face;
+ // normals aren't contained in the ofVec3, so they're separate here
+ ofVec3f ofv0;
+ ofVec3f ofv1;
+ ofVec3f ofv2;
- ofxVCGVertex *va;
- ofxVCGVertex *vb;
- ofxVCGVertex *vc;
+ ofVec3f ofn0;
+ ofVec3f ofn1;
+ ofVec3f ofn2;
};
View
187 src/ofxVCGLib.cpp
@@ -14,15 +14,6 @@ ofMesh* ofxVCG::intersectMeshes(vector<ofMesh> meshes)
//tri::Append<MyMesh,MyMesh>::Mesh(ml,mr);
}
-ofMesh* ofxVCG::createMeshFromCloud(ofxVCGCloud* cloud)
-{
-
- // up to you to manage this one, but this really should be a smart ptr
- ofMesh* mesh = new ofMesh();
- return mesh;
-
-}
-
void ofxVCG::cleanMesh(ofMesh* mesh)
{
@@ -143,8 +134,6 @@ ofMesh* ofxVCG::joinMeshes( ofMesh* toBeParent, ofMesh* toBeChild )
innerMesh mP(toBeParent);
innerMesh mC(toBeChild);
-
-
tri::Append<innerMesh,innerMesh>::Mesh(mP,mC); // join them
tri::Clean<innerMesh>::RemoveDuplicateVertex(mP); // now clean it up
@@ -186,64 +175,132 @@ bool ofxVCG::nodeIntersection(ofNode* aNode, ofNode* bNode)
// smart pointers would be freaking sweet here
-ofxVCGCloud* ofxVCG::createCloudFromMesh(ofMesh* mesh)
-{
-}
-
-
-ofMesh* ofxVCG::createMeshFromPoints(vector<ofVec3f> points, int degreeOfFidelity)
-{
-}
-
-
-ofMesh* ofxVCG::createMeshFromPoints(vector<ofVec2f> points, int degreeOfFidelity)
-{
-}
-
-
-ofxVCGCloud* ofxVCG::createCloudFromPoints(vector<ofVec2f> points)
+ofMesh* ofxVCG::createMeshFromPoints(vector<ofVec3f> points, int degreeOfFidelity, meshConstructionAlgo useMeshConstructionAlgo = BALL_PIVOT_CONSTRUCTION)
{
+
+ innerMesh m;
+
+ if(useMeshConstructionAlgo == BALL_PIVOT_CONSTRUCTION)
+ {
+
+ Allocator<innerMesh>::AddVertices(m, points.size());
+
+
+ const int sz = points.size();
+ innerMesh::VertexIterator vi = m.vert.begin();
+ vector<ofVec3f>::iterator pit = points.begin();
+ while(pit != points.end())
+ {
+ (*vi).update( *pit );
+ ++vi;
+ ++pit;
+ }
+
+
+ vcg::tri::UpdateBounding<innerMesh>::Box(m);
+ vcg::tri::UpdateNormals<innerMesh>::PerFace(m);
+
+ tri::BallPivoting<innerMesh>* pivot = new tri::BallPivoting<innerMesh>(m);
+ pivot->BuildMesh();
+
+ NormalExtrapolation<vector<ofxVCGVertex> >::ExtrapolateNormals(m.vert.begin(), m.vert.end(), 2);
+ }
+ else
+ {
+ /*ofxVolume volume;
+ volume.Init(points/3);
+
+ vector<float>::iterator pit = points.begin();
+ while(pit != points.end())
+ {
+ volume.Val(*pit, ++pit, ++pit);
+ ++pit;
+ }
+
+
+ vcg::tri::TrivialWalker<innerMesh,ofxVolume> walker;
+ vcg::tri::MarchingCubes<innerMesh, TrivialWalker<innerMesh, ofxVolume> > marchingCubes;
+
+ MyMarchingCubes mc(m, walker);
+ walker.BuildMesh<MyMarchingCubes>(m, volume, marchingCubes, 20*20);*/
+
+ }
+ ofMesh* ofm = new ofMesh();
+
+ vcgMeshToOf(&m, ofm);
+
+ return ofm;
+
}
-
-ofxVCGCloud* ofxVCG::createCloudFromPoints(vector<ofVec3f> points)
+ofMesh* ofxVCG::createMeshFromPoints(vector<float> points, int degreeOfFidelity, meshConstructionAlgo useMeshConstructionAlgo = BALL_PIVOT_CONSTRUCTION)
{
innerMesh m;
- m.face.clear();
- m.fn = 0;
- m.Clear();
-
- vector<ofVec3f>::iterator pIt = points.begin();
- while (pIt != points.end()) {
- ofxVCGVertex mv;
- mv.P() = Point3f(pIt->x,pIt->y,pIt->z);
- m.vert.push_back(mv);
- m.vn++;
+ if(useMeshConstructionAlgo == BALL_PIVOT_CONSTRUCTION)
+ {
+
+
+ Allocator<innerMesh>::AddVertices(m, points.size()/3);
+
+
+ const int sz = points.size();
+ innerMesh::VertexIterator vi = m.vert.begin();
+ vector<float>::iterator pit = points.begin();
+ while(pit != points.end())
+ {
+ (*vi).P().X() = *pit;
+ (*vi).P().Y() = *(++pit);
+ (*vi).P().Z() = *(++pit);
+ ++vi;
+ ++pit;
+ }
+
+
+ vcg::tri::UpdateBounding<innerMesh>::Box(m);
+ vcg::tri::UpdateNormals<innerMesh>::PerFace(m);
+
+ tri::BallPivoting<innerMesh>* pivot = new tri::BallPivoting<innerMesh>(m);
+ pivot->BuildMesh();
+
+ NormalExtrapolation<vector<ofxVCGVertex> >::ExtrapolateNormals(m.vert.begin(), m.vert.end(), 2);
+
+ }
+ else
+ {
+
+ /*ofxVolume volume;
+ volume.Init(points/3);
+
+ vector<float>::iterator pit = points.begin();
+ while(pit != points.end())
+ {
+ volume.Val(*pit, ++pit, ++pit);
+ ++pit;
+ }
+
+
+ vcg::tri::TrivialWalker<innerMesh,ofxVolume> walker;
+ vcg::tri::MarchingCubes<innerMesh, TrivialWalker<innerMesh, ofxVolume> > marchingCubes;
+
+ MyMarchingCubes mc(m, walker);
+ walker.BuildMesh<MyMarchingCubes>(m, volume, marchingCubes, 20*20);*/
- ++pIt;
}
- vcg::tri::UpdateBounding<innerMesh>::Box(m);
- vcg::tri::UpdateNormals<innerMesh>::PerFace(m);
-
- /*
- legacyPivot = NULL;
- if (legacyPivot) delete legacyPivot;
- legacyPivot = new tri::BallPivoting<innerMesh>(m, _radius, _clustering, _angle);
- legacyPivot->BuildMesh();
+ ofMesh* ofm = new ofMesh();
- NormalExtrapolation<vector<CVertex> >::ExtrapolateNormals(m.vert.begin(), m.vert.end(), 2);
+ vcgMeshToOf(&m, ofm);
- pivot = new tri::ofxVCGPivot<CMesh>(m, _radius, _clustering, _angle);
- */
+ return ofm;
}
-void ofxVCG::getFacesForRay(ofxVCGRay ray, ofMesh* mesh)
+
+vcgRayMeshIntersection ofxVCG::getFacesForRay(ofxVCGRay ray, ofMesh* mesh)
{
innerMesh m(mesh);
float t;
@@ -260,9 +317,31 @@ void ofxVCG::getFacesForRay(ofxVCGRay ray, ofMesh* mesh)
vcg_ray.SetOrigin(beg);
vcg_ray.SetDirection(dir);
- // now actually find the face
- innerMeshFace *rf = tri::DoRay<innerMesh,innerMeshGrid>(m, grid, vcg_ray, maxDist, t);
+ // get the baricentric points of the intersection
+ // plus the face intersected plus the point where they meet
+ innerMesh::FacePointer intersectedFace;
+ innerMesh::ScalarType bc1, bc2, bc3;
+ Point3f hitPoint;
+
+ Line3f line;
+
+ IntersectionRayMesh(&m, line, hitPoint, bc1, bc2, bc3, intersectedFace);
+
+ // now set the intersection data so we have it on the other side
+ vcgRayMeshIntersection intersectionData;
+
+ intersectionData.baricentricCenter.x = bc1;
+ intersectionData.baricentricCenter.y = bc2;
+ intersectionData.baricentricCenter.z = bc3;
+
+ ofxMeshFace face(intersectedFace);
+ intersectionData.intersectedFace = face;
+
+ intersectionData.hitPoint.x = hitPoint.X();
+ intersectionData.hitPoint.y = hitPoint.Y();
+ intersectionData.hitPoint.z = hitPoint.Z();
+ return intersectionData;
}
void ofxVCG::pointsToPlane(vector<ofVec2f> points)
View
17 src/ofxVCGLib.h
@@ -30,6 +30,8 @@
#include <vcg/complex/trimesh/base.h>
+#include <vcg/complex/intersection.h>
+
//#include <vcg/complex/trimesh/refine.h>
//#include <vcg/complex/trimesh/refine_loop.h>
@@ -43,10 +45,13 @@
#include "ofxVCGLibDefinitions.h"
#include "ofxMeshFace.h"
+#include "vcgRayMeshIntersection.h"
using namespace vcg;
using namespace tri;
+enum meshConstructionAlgo { BALL_PIVOT_CONSTRUCTION, MARCHING_CUBES_CONSTRUCTION };
+
namespace ofxVCG {
@@ -69,14 +74,8 @@ namespace ofxVCG {
bool nodeIntersection(ofNode* aNode, ofNode* bNode);
// smart pointers would be freaking sweet here
- ofxVCGCloud* createCloudFromMesh(ofMesh* mesh);
- ofMesh* createMeshFromCloud(ofxVCGCloud* mesh);
-
- ofMesh* createMeshFromPoints(vector<ofVec3f> points, int degreeOfFidelity);
- ofMesh* createMeshFromPoints(vector<ofVec2f> points, int degreeOfFidelity);
-
- ofxVCGCloud* createCloudFromPoints(vector<ofVec2f> points);
- ofxVCGCloud* createCloudFromPoints(vector<ofVec3f> points);
+ ofMesh* createMeshFromPoints(vector<ofVec3f> points, int degreeOfFidelity, meshConstructionAlgo useMeshConstructionAlgo);
+ ofMesh* createMeshFromPoints(vector<float> points, int degreeOfFidelity, meshConstructionAlgo useMeshConstructionAlgo);
void pointsToPlane(vector<ofVec2f> points);
void cleanMesh(ofMesh* mesh);
@@ -85,7 +84,7 @@ namespace ofxVCG {
void getNeighboringFaces(ofxMeshFace* face, ofMesh* mesh);
void getFacesFromMesh(vector<ofxMeshFace>* faces, ofMesh* mesh);
void constructMeshFromFaces(ofMesh* mesh, vector<ofxMeshFace>* faces);
- void getFacesForRay(ofxVCGRay ray, ofMesh* mesh);
+ vcgRayMeshIntersection getFacesForRay(ofxVCGRay ray, ofMesh* mesh);
// aka the kyle mcdonald functions
void vcgMeshToOf(innerMesh* inner, ofMesh* mesh);
View
6 src/ofxVCGLibDefinitions.cpp
@@ -38,8 +38,7 @@ innerMesh::innerMesh(ofMesh* mesh)
++inVit;
++vi;
}
-
- innerMesh::PerFaceAttributeHandle<Point3i> meshIndicesHandle = Allocator<innerMesh>::AddPerFaceAttribute<Point3i> (*this, string("MeshIndices"));
+
//// get all the faces
FaceIterator fi = face.begin();
@@ -49,19 +48,16 @@ innerMesh::innerMesh(ofMesh* mesh)
(*fi).V(0) = &vert[(unsigned int) (*indPtr)];
if(indPtr != mesh->getIndices().end())
{
- meshIndicesHandle[fi][0] = *indPtr;
++indPtr;
}
if(indPtr != mesh->getIndices().end())
{
(*fi).V(1) = &vert[(unsigned int) (*indPtr)];
- meshIndicesHandle[fi][1] = *indPtr;
++indPtr;
}
if(indPtr != mesh->getIndices().end())
{
(*fi).V(2) = &vert[(unsigned int) (*indPtr)];
- meshIndicesHandle[fi][2] = *indPtr;
++indPtr;
}
++fi;
View
41 src/ofxVCGLibDefinitions.h
@@ -41,14 +41,20 @@
#include<vcg/complex/trimesh/clean.h>
#include<vcg/complex/trimesh/smooth.h>
+// to make vertex meshes (i.e no faces)
+#include<vcg/complex/vertexmesh/base.h>
+#include<vcg/complex/vertexmesh/allocate.h>
+
+
#include "ofxVCGCloud.h"
-#include "ofxVCGVoxel.h"
+//#include "ofxVCGVolume.h"
#define __FLT_EVAL_METHOD__ 0
using namespace vcg;
+
// base types
class ofxVCGVertex;
@@ -59,7 +65,7 @@ class innerEdge;
struct ofxVCGTypes:public UsedTypes<Use<ofxVCGVertex>::AsVertexType, Use<innerEdge>::AsEdgeType, Use<innerMeshFace>::AsFaceType>{};
class ofxVCGVertex:
-public Vertex<ofxVCGTypes, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f, vertex::Mark, vertex::Color4b>
+public Vertex<ofxVCGTypes, vertex::Coord3f, vertex::BitFlags, vertex::Normal3f, vertex::Mark, vertex::Color4b, vertex::VFAdj>
{
public:
@@ -95,6 +101,14 @@ public Vertex<ofxVCGTypes, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f, v
return ofVec;
}
+ ofVec3f& normalToOf()
+ {
+ ofVec.x = N().X();
+ ofVec.y = N().Y();
+ ofVec.z = N().Z();
+ return ofVec;
+ }
+
private:
ofVec3f ofVec;
@@ -104,21 +118,6 @@ public Vertex<ofxVCGTypes, vertex::Coord3f, vertex::BitFlags,vertex::Normal3f, v
// used to store face info
// only used in vcg->ofxMeshFace conversion
class innerMeshFace:public Face<ofxVCGTypes, face::FFAdj, face::Mark, face::VertexRef, face::BitFlags, face::Normal3f> {
-
-public:
- int ind0, ind1, ind2;
-
- /*innerMeshFace(const innerMeshFace &copy) {
- ind0 = copy.ind0;
- ind1 = copy.ind1;
- ind2 = copy.ind2;
-
-
- }
-
- innerMesh& operator=( const innerMesh& rhs ) {
- }*/
-
};
@@ -161,8 +160,14 @@ class ofxVCGRay {
};
+// to be implemented
+class ofxVCGMesh : public vrt::VertexMesh< vector<ofxVCGVertex> > {
+};
+
// other typedefs
-typedef SimpleVolume<SimpleVoxel> ofxVCGVolume;
+//typedef SimpleVolume<SimpleVoxel> ofxVCGVolume;
+//typedef ofxVCGVolume<SimpleVoxel> ofxVolume;
+
typedef vcg::GridStaticPtr<innerMesh::FaceType, innerMesh::ScalarType> innerMeshGrid;
View
109 src/ofxVCGVoxel.h
@@ -1,109 +0,0 @@
-/*
- * ofxVCGVoxel.h
- * emptyExample
- *
- * Created by base on 19/04/11.
- * Copyright 2011 __MyCompanyName__. All rights reserved.
- *
- */
-
-#ifndef OFXVCG_SIMPLE_VOLUME
-#define OFXVCG_SIMPLE_VOLUME
-
-#include<vector>
-namespace vcg
-{
-
- template <class VOX_TYPE>
- class SimpleVolume
- {
- public:
- typedef VOX_TYPE VoxelType;
- std::vector<VoxelType> Vol;
-
- Point3i sz; /// Dimensioni griglia come numero di celle per lato
-
- const Point3i &ISize() {return sz;}; /// Dimensioni griglia come numero di celle per lato
-
- void Init(Point3i _sz)
- {
- sz=_sz;
- Vol.resize(sz[0]*sz[1]*sz[2]);
- }
-
- float Val(const int &x,const int &y,const int &z) const {
- return cV(x,y,z).V();
- //else return numeric_limits<float>::quiet_NaN( );
- }
-
- float &Val(const int &x,const int &y,const int &z) {
- return V(x,y,z).V();
- //else return numeric_limits<float>::quiet_NaN( );
- }
-
- VOX_TYPE &V(const int &x,const int &y,const int &z) {
- return Vol[x+y*sz[0]+z*sz[0]*sz[1]];
- }
-
- const VOX_TYPE &cV(const int &x,const int &y,const int &z) const {
- return Vol[x+y*sz[0]+z*sz[0]*sz[1]];
- }
-
-
- typedef enum { XAxis=0,YAxis=1,ZAxis=2} VolumeAxis;
-
- template < class VertexPointerType, VolumeAxis AxisVal >
- void GetIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
- {
- float f1 = Val(p1.X(), p1.Y(), p1.Z())-thr;
- float f2 = Val(p2.X(), p2.Y(), p2.Z())-thr;
- float u = (float) f1/(f1-f2);
- if(AxisVal==XAxis) v->P().X() = (float) p1.X()*(1-u) + u*p2.X();
- else v->P().X() = (float) p1.X();
- if(AxisVal==YAxis) v->P().Y() = (float) p1.Y()*(1-u) + u*p2.Y();
- else v->P().Y() = (float) p1.Y();
- if(AxisVal==ZAxis) v->P().Z() = (float) p1.Z()*(1-u) + u*p2.Z();
- else v->P().Z() = (float) p1.Z();
- }
-
- template < class VertexPointerType >
- void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
- { GetIntercept<VertexPointerType,XAxis>(p1,p2,v,thr); }
-
- template < class VertexPointerType >
- void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
- { GetIntercept<VertexPointerType,YAxis>(p1,p2,v,thr); }
-
- template < class VertexPointerType >
- void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, const float thr)
- { GetIntercept<VertexPointerType,ZAxis>(p1,p2,v,thr); }
- };
- template <class VolumeType>
- class RawVolumeImporter
- {
- public:
- enum DataType
- {
- // Funzioni superiori
- UNDEF=0,
- BYTE=1,
- SHORT=2,
- FLOAT=3
- };
-
- static bool Open(const char *filename, VolumeType &V, Point3i sz, DataType d)
- {
- return true;
- }
- };
-
- class SimpleVoxel
- {
- private:
- float _v;
- public:
- float &V() {return _v;};
- float V() const {return _v;};
- };
-} // end namespace
-#endif // __VCG_SIMPLE_VOLUME
Please sign in to comment.
Something went wrong with that request. Please try again.