Conformed C++ syntax to GCC requirements
This commit is contained in:
parent
e8b3080c93
commit
b717573d47
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.5 2004/03/18 15:29:07 cignoni
|
||||||
|
Completed Octahedron and Icosahedron
|
||||||
|
|
||||||
Revision 1.4 2004/03/11 18:14:19 tarini
|
Revision 1.4 2004/03/11 18:14:19 tarini
|
||||||
prova
|
prova
|
||||||
|
|
||||||
|
|
@ -44,19 +47,25 @@ namespace tri {
|
||||||
template <class TetraMeshType>
|
template <class TetraMeshType>
|
||||||
void Tetrahedron(TetraMeshType &in)
|
void Tetrahedron(TetraMeshType &in)
|
||||||
{
|
{
|
||||||
|
typedef TetraMeshType MeshType;
|
||||||
|
typedef typename MeshType::CoordType CoordType;
|
||||||
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
in.Clear();
|
in.Clear();
|
||||||
Allocator<TetraMeshType>::AddVertices(in,4);
|
Allocator<TetraMeshType>::AddVertices(in,4);
|
||||||
Allocator<TetraMeshType>::AddFaces(in,4);
|
Allocator<TetraMeshType>::AddFaces(in,4);
|
||||||
|
|
||||||
TetraMeshType::VertexPointer ivp[4];
|
VertexPointer ivp[4];
|
||||||
|
|
||||||
TetraMeshType::VertexIterator vi=in.vert.begin();
|
VertexIterator vi=in.vert.begin();
|
||||||
ivp[0]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1, 1, 1); ++vi;
|
ivp[0]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1, 1, 1); ++vi;
|
||||||
ivp[1]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1, 1,-1); ++vi;
|
ivp[1]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1, 1,-1); ++vi;
|
||||||
ivp[2]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1,-1, 1); ++vi;
|
ivp[2]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1,-1, 1); ++vi;
|
||||||
ivp[3]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1,-1,-1);
|
ivp[3]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1,-1,-1);
|
||||||
|
|
||||||
TetraMeshType::FaceIterator fi=in.face.begin();
|
FaceIterator fi=in.face.begin();
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3]; ++fi;
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[1]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[1]; ++fi;
|
||||||
|
|
@ -66,21 +75,27 @@ void Tetrahedron(TetraMeshType &in)
|
||||||
template <class OctMeshType>
|
template <class OctMeshType>
|
||||||
void Octahedron(OctMeshType &in)
|
void Octahedron(OctMeshType &in)
|
||||||
{
|
{
|
||||||
|
typedef OctMeshType MeshType;
|
||||||
|
typedef typename MeshType::CoordType CoordType;
|
||||||
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
in.Clear();
|
in.Clear();
|
||||||
Allocator<OctMeshType>::AddVertices(in,6);
|
Allocator<OctMeshType>::AddVertices(in,6);
|
||||||
Allocator<OctMeshType>::AddFaces(in,8);
|
Allocator<OctMeshType>::AddFaces(in,8);
|
||||||
|
|
||||||
OctMeshType::VertexPointer ivp[6];
|
VertexPointer ivp[6];
|
||||||
|
|
||||||
OctMeshType::VertexIterator vi=in.vert.begin();
|
VertexIterator vi=in.vert.begin();
|
||||||
ivp[0]=&*vi;(*vi).P()=OctMeshType::CoordType ( 1, 0, 0); ++vi;
|
ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 0, 0); ++vi;
|
||||||
ivp[1]=&*vi;(*vi).P()=OctMeshType::CoordType ( 0, 1, 0); ++vi;
|
ivp[1]=&*vi;(*vi).P()=CoordType ( 0, 1, 0); ++vi;
|
||||||
ivp[2]=&*vi;(*vi).P()=OctMeshType::CoordType ( 0, 0, 1); ++vi;
|
ivp[2]=&*vi;(*vi).P()=CoordType ( 0, 0, 1); ++vi;
|
||||||
ivp[3]=&*vi;(*vi).P()=OctMeshType::CoordType (-1, 0, 0); ++vi;
|
ivp[3]=&*vi;(*vi).P()=CoordType (-1, 0, 0); ++vi;
|
||||||
ivp[4]=&*vi;(*vi).P()=OctMeshType::CoordType ( 0,-1, 0); ++vi;
|
ivp[4]=&*vi;(*vi).P()=CoordType ( 0,-1, 0); ++vi;
|
||||||
ivp[5]=&*vi;(*vi).P()=OctMeshType::CoordType ( 0, 0,-1);
|
ivp[5]=&*vi;(*vi).P()=CoordType ( 0, 0,-1);
|
||||||
|
|
||||||
OctMeshType::FaceIterator fi=in.face.begin();
|
FaceIterator fi=in.face.begin();
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
|
||||||
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[5]; ++fi;
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[5]; ++fi;
|
||||||
|
|
@ -94,22 +109,29 @@ void Octahedron(OctMeshType &in)
|
||||||
template <class IcoMeshType>
|
template <class IcoMeshType>
|
||||||
void Icosahedron(IcoMeshType &in)
|
void Icosahedron(IcoMeshType &in)
|
||||||
{
|
{
|
||||||
IcoMeshType::ScalarType L=IcoMeshType::ScalarType((math::Sqrt(5.0)+1.0)/2.0);
|
typedef IcoMeshType MeshType;
|
||||||
IcoMeshType::CoordType vv[12]={
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
IcoMeshType::CoordType ( 0, L, 1),
|
typedef typename MeshType::CoordType CoordType;
|
||||||
IcoMeshType::CoordType ( 0, L,-1),
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
IcoMeshType::CoordType ( 0,-L, 1),
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
IcoMeshType::CoordType ( 0,-L,-1),
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
IcoMeshType::CoordType ( L, 1, 0),
|
ScalarType L=ScalarType((math::Sqrt(5.0)+1.0)/2.0);
|
||||||
IcoMeshType::CoordType ( L,-1, 0),
|
CoordType vv[12]={
|
||||||
IcoMeshType::CoordType (-L, 1, 0),
|
CoordType ( 0, L, 1),
|
||||||
IcoMeshType::CoordType (-L,-1, 0),
|
CoordType ( 0, L,-1),
|
||||||
|
CoordType ( 0,-L, 1),
|
||||||
|
CoordType ( 0,-L,-1),
|
||||||
|
|
||||||
IcoMeshType::CoordType ( 1, 0, L),
|
CoordType ( L, 1, 0),
|
||||||
IcoMeshType::CoordType (-1, 0, L),
|
CoordType ( L,-1, 0),
|
||||||
IcoMeshType::CoordType ( 1, 0,-L),
|
CoordType (-L, 1, 0),
|
||||||
IcoMeshType::CoordType (-1, 0,-L)
|
CoordType (-L,-1, 0),
|
||||||
|
|
||||||
|
CoordType ( 1, 0, L),
|
||||||
|
CoordType (-1, 0, L),
|
||||||
|
CoordType ( 1, 0,-L),
|
||||||
|
CoordType (-1, 0,-L)
|
||||||
};
|
};
|
||||||
|
|
||||||
int ff[20][3]={
|
int ff[20][3]={
|
||||||
|
|
@ -124,16 +146,16 @@ void Icosahedron(IcoMeshType &in)
|
||||||
in.Clear();
|
in.Clear();
|
||||||
Allocator<IcoMeshType>::AddVertices(in,12);
|
Allocator<IcoMeshType>::AddVertices(in,12);
|
||||||
Allocator<IcoMeshType>::AddFaces(in,20);
|
Allocator<IcoMeshType>::AddFaces(in,20);
|
||||||
IcoMeshType::VertexPointer ivp[12];
|
VertexPointer ivp[12];
|
||||||
|
|
||||||
IcoMeshType::VertexIterator vi;
|
VertexIterator vi;
|
||||||
int i;
|
int i;
|
||||||
for(i=0,vi=in.vert.begin();vi!=in.vert.end();++i,++vi){
|
for(i=0,vi=in.vert.begin();vi!=in.vert.end();++i,++vi){
|
||||||
(*vi).P()=vv[i];
|
(*vi).P()=vv[i];
|
||||||
ivp[i]=&*vi;
|
ivp[i]=&*vi;
|
||||||
}
|
}
|
||||||
|
|
||||||
IcoMeshType::FaceIterator fi;
|
FaceIterator fi;
|
||||||
for(i=0,fi=in.face.begin();fi!=in.face.end();++i,++fi){
|
for(i=0,fi=in.face.begin();fi!=in.face.end();++i,++fi){
|
||||||
(*fi).V(0)=ivp[ff[i][0]];
|
(*fi).V(0)=ivp[ff[i][0]];
|
||||||
(*fi).V(1)=ivp[ff[i][1]];
|
(*fi).V(1)=ivp[ff[i][1]];
|
||||||
|
|
@ -141,165 +163,126 @@ void Icosahedron(IcoMeshType &in)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MESH_TYPE>
|
template <class MeshType>
|
||||||
void Hexahedron(MESH_TYPE &in)
|
void Hexahedron(MeshType &in)
|
||||||
{
|
{
|
||||||
in.vn=8;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
in.fn=12;
|
typedef typename MeshType::CoordType CoordType;
|
||||||
in.vert.clear();
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
in.face.clear();
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0;
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
MESH_TYPE::CoordType tp;
|
|
||||||
tp=MESH_TYPE::CoordType (-1,-1,-1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 1,-1,-1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (-1, 1,-1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 1, 1,-1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (-1,-1, 1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 1,-1, 1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (-1, 1, 1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 1, 1, 1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
|
|
||||||
vector<MESH_TYPE::vertex_pointer> index(in.vn);
|
in.Clear();
|
||||||
|
Allocator<MeshType>::AddVertices(in,8);
|
||||||
|
Allocator<MeshType>::AddFaces(in,12);
|
||||||
|
|
||||||
MESH_TYPE::face_type f;f.Supervisor_Flags()=0;
|
VertexPointer ivp[8];
|
||||||
|
|
||||||
MESH_TYPE::vertex_iterator vi;
|
VertexIterator vi=in.vert.begin();
|
||||||
int j;
|
ivp[0]=&*vi;(*vi).P()=CoordType (-1,-1,-1); ++vi;
|
||||||
for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
|
ivp[1]=&*vi;(*vi).P()=CoordType ( 1,-1,-1); ++vi;
|
||||||
f.V(0)=index[0]; f.V(1)=index[1];f.V(2)=index[2]; in.face.push_back(f);
|
ivp[2]=&*vi;(*vi).P()=CoordType (-1, 1,-1); ++vi;
|
||||||
f.V(0)=index[3]; f.V(1)=index[2];f.V(2)=index[1]; in.face.push_back(f);
|
ivp[3]=&*vi;(*vi).P()=CoordType ( 1, 1,-1); ++vi;
|
||||||
|
ivp[3]=&*vi;(*vi).P()=CoordType (-1,-1, 1); ++vi;
|
||||||
|
ivp[3]=&*vi;(*vi).P()=CoordType ( 1,-1, 1); ++vi;
|
||||||
|
ivp[4]=&*vi;(*vi).P()=CoordType (-1, 1, 1); ++vi;
|
||||||
|
ivp[5]=&*vi;(*vi).P()=CoordType ( 1, 1, 1);
|
||||||
|
|
||||||
f.V(0)=index[0]; f.V(1)=index[2];f.V(2)=index[4]; in.face.push_back(f);
|
FaceIterator fi=in.face.begin();
|
||||||
f.V(0)=index[6]; f.V(1)=index[4];f.V(2)=index[2]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1]; ++fi;
|
||||||
f.V(0)=index[0]; f.V(1)=index[4];f.V(2)=index[1]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
|
||||||
f.V(0)=index[5]; f.V(1)=index[1];f.V(2)=index[4]; in.face.push_back(f);
|
(*fi).V(0)=ivp[6]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[1]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[5];f.V(2)=index[6]; in.face.push_back(f);
|
(*fi).V(0)=ivp[5]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[4]; ++fi;
|
||||||
f.V(0)=index[4]; f.V(1)=index[6];f.V(2)=index[5]; in.face.push_back(f);
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[6]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[4]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[5]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[6];f.V(2)=index[3]; in.face.push_back(f);
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[3]; ++fi;
|
||||||
f.V(0)=index[2]; f.V(1)=index[3];f.V(2)=index[6]; in.face.push_back(f);
|
(*fi).V(0)=ivp[2]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[6]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[5]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[3];f.V(2)=index[5]; in.face.push_back(f);
|
(*fi).V(0)=ivp[1]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[3];
|
||||||
f.V(0)=index[1]; f.V(1)=index[5];f.V(2)=index[3]; in.face.push_back(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MESH_TYPE>
|
template <class MeshType>
|
||||||
void HalfOctahedron(MESH_TYPE &in)
|
void Square(MeshType &in)
|
||||||
{
|
{
|
||||||
in.vn=5;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
in.fn=4;
|
typedef typename MeshType::CoordType CoordType;
|
||||||
in.vert.clear();
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
in.face.clear();
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0;
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
MESH_TYPE::CoordType tp;
|
|
||||||
tp=MESH_TYPE::CoordType ( 1, 0, 0); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 0, 1, 0); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 0, 0, 1); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (-1, 0, 0); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType ( 0,-1, 0); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
|
|
||||||
vector<MESH_TYPE::vertex_pointer> index(in.vn);
|
in.Clear();
|
||||||
|
Allocator<MeshType>::AddVertices(in,4);
|
||||||
|
Allocator<MeshType>::AddFaces(in,2);
|
||||||
|
|
||||||
MESH_TYPE::face_type f;f.Supervisor_Flags()=0;
|
VertexPointer ivp[4];
|
||||||
|
|
||||||
MESH_TYPE::vertex_iterator vi;
|
VertexIterator vi=in.vert.begin();
|
||||||
int j;
|
ivp[0]=&*vi;(*vi).P()=CoordType ( 1, 0, 0); ++vi;
|
||||||
for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
|
ivp[1]=&*vi;(*vi).P()=CoordType ( 0, 1, 0); ++vi;
|
||||||
|
ivp[2]=&*vi;(*vi).P()=CoordType (-1, 0, 0); ++vi;
|
||||||
|
ivp[5]=&*vi;(*vi).P()=CoordType ( 0,-1, 0);
|
||||||
|
|
||||||
f.V(0)=index[0]; f.V(1)=index[1];f.V(2)=index[2]; in.face.push_back(f);
|
FaceIterator fi=in.face.begin();
|
||||||
f.V(0)=index[0]; f.V(1)=index[2];f.V(2)=index[4]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
//f.V(0)=index[0]; f.V(1)=index[4];f.V(2)=index[5]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3];
|
||||||
//f.V(0)=index[0]; f.V(1)=index[5];f.V(2)=index[1]; in.face.push_back(f);
|
|
||||||
//f.V(0)=index[3]; f.V(1)=index[1];f.V(2)=index[5]; in.face.push_back(f);
|
|
||||||
//f.V(0)=index[3]; f.V(1)=index[5];f.V(2)=index[4]; in.face.push_back(f);
|
|
||||||
f.V(0)=index[3]; f.V(1)=index[4];f.V(2)=index[2]; in.face.push_back(f);
|
|
||||||
f.V(0)=index[3]; f.V(1)=index[2];f.V(2)=index[1]; in.face.push_back(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MESH_TYPE>
|
//template <class MESH_TYPE>
|
||||||
void Square(MESH_TYPE &in)
|
//void Sphere(MESH_TYPE &in, const int subdiv = 3 )
|
||||||
{
|
//{
|
||||||
in.vn=4;
|
// Icosahedron(in);
|
||||||
in.fn=2;
|
// in.ComputeBorderFlag();
|
||||||
in.vert.clear();
|
// int lastsize = 0;
|
||||||
in.face.clear();
|
// for(int i=0;i<subdiv;++i)
|
||||||
MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0;
|
// {
|
||||||
MESH_TYPE::CoordType tp;
|
// Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),0);
|
||||||
tp=MESH_TYPE::CoordType ( 1, 0, 0); tv.P()=tp; in.vert.push_back(tv);
|
// MESH_TYPE::vertex_iterator vi;
|
||||||
tp=MESH_TYPE::CoordType ( 0, 1, 0); tv.P()=tp; in.vert.push_back(tv);
|
//
|
||||||
tp=MESH_TYPE::CoordType (-1, 0, 0); tv.P()=tp; in.vert.push_back(tv);
|
// for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi)
|
||||||
tp=MESH_TYPE::CoordType ( 0,-1, 0); tv.P()=tp; in.vert.push_back(tv);
|
// vi->P().Normalize();
|
||||||
|
//
|
||||||
vector<MESH_TYPE::vertex_pointer> index(in.vn);
|
// lastsize = in.vert.size();
|
||||||
|
// }
|
||||||
MESH_TYPE::face_type f;f.Supervisor_Flags()=0;
|
//}
|
||||||
|
|
||||||
MESH_TYPE::vertex_iterator vi;
|
|
||||||
int j;
|
|
||||||
for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
|
|
||||||
|
|
||||||
f.V(0)=index[0]; f.V(1)=index[1];f.V(2)=index[2]; in.face.push_back(f);
|
|
||||||
f.V(0)=index[0]; f.V(1)=index[2];f.V(2)=index[3]; in.face.push_back(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MESH_TYPE>
|
|
||||||
void Sphere(MESH_TYPE &in, const int subdiv = 3 )
|
|
||||||
{
|
|
||||||
Icosahedron(in);
|
|
||||||
in.ComputeBorderFlag();
|
|
||||||
int lastsize = 0;
|
|
||||||
for(int i=0;i<subdiv;++i)
|
|
||||||
{
|
|
||||||
Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),0);
|
|
||||||
MESH_TYPE::vertex_iterator vi;
|
|
||||||
|
|
||||||
for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi)
|
|
||||||
vi->P().Normalize();
|
|
||||||
|
|
||||||
lastsize = in.vert.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// r1 = raggio 1, r2 = raggio2, h = altezza (asse y)
|
/// r1 = raggio 1, r2 = raggio2, h = altezza (asse y)
|
||||||
template <class MESH_TYPE>
|
template <class MeshType>
|
||||||
void Cone( MESH_TYPE & in,
|
void Cone( MeshType& in,
|
||||||
const typename MESH_TYPE::ScalarType r1,
|
const typename MeshType::ScalarType r1,
|
||||||
const typename MESH_TYPE::ScalarType r2,
|
const typename MeshType::ScalarType r2,
|
||||||
const typename MESH_TYPE::ScalarType h )
|
const typename MeshType::ScalarType h )
|
||||||
{
|
{
|
||||||
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
|
typedef typename MeshType::CoordType CoordType;
|
||||||
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
|
|
||||||
const int D = 24;
|
const int D = 24;
|
||||||
int i,b1,b2;
|
int i,b1,b2;
|
||||||
|
in.Clear();
|
||||||
if(r1==0 || r2==0)
|
int VN,FN;
|
||||||
{
|
if(r1==0 || r2==0) {
|
||||||
in.vn=D+2;
|
VN=D+2;
|
||||||
in.fn=D*2;
|
FN=D*2;
|
||||||
}
|
} else {
|
||||||
else
|
VN=D*2+2;
|
||||||
{
|
FN=D*4;
|
||||||
in.vn=D*2+2;
|
|
||||||
in.fn=D*4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in.vert.clear();
|
Allocator<MeshType>::AddVertices(in,VN);
|
||||||
in.face.clear();
|
Allocator<MeshType>::AddFaces(in,FN);
|
||||||
|
VertexPointer ivp[VN];
|
||||||
|
|
||||||
MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0;
|
VertexIterator vi=in.vert.begin();
|
||||||
MESH_TYPE::CoordType tp;
|
ivp[0]=&*vi;(*vi).P()=CoordType ( 0,-h/2,0 ); ++vi;
|
||||||
|
ivp[1]=&*vi;(*vi).P()=CoordType ( 0, h/2,0 ); ++vi;
|
||||||
tp=MESH_TYPE::CoordType ( 0,-h/2,0 );
|
|
||||||
tv.P()=tp;
|
|
||||||
in.vert.push_back(tv);
|
|
||||||
|
|
||||||
tp=MESH_TYPE::CoordType ( 0, h/2,0 );
|
|
||||||
tv.P()=tp;
|
|
||||||
in.vert.push_back(tv);
|
|
||||||
|
|
||||||
b1 = b2 = 2;
|
b1 = b2 = 2;
|
||||||
|
int cnt=2;
|
||||||
if(r1!=0)
|
if(r1!=0)
|
||||||
{
|
{
|
||||||
for(i=0;i<D;++i)
|
for(i=0;i<D;++i)
|
||||||
|
|
@ -311,9 +294,8 @@ void Cone( MESH_TYPE & in,
|
||||||
x = r1*c;
|
x = r1*c;
|
||||||
z = r1*s;
|
z = r1*s;
|
||||||
y = -h/2;
|
y = -h/2;
|
||||||
tp=MESH_TYPE::CoordType ( x,y,z );
|
|
||||||
tv.P()=tp;
|
ivp[cnt]=&*vi; (*vi).P()= CoordType( x,y,z ); ++vi;++cnt;
|
||||||
in.vert.push_back(tv);
|
|
||||||
}
|
}
|
||||||
b2 += D;
|
b2 += D;
|
||||||
}
|
}
|
||||||
|
|
@ -329,124 +311,93 @@ void Cone( MESH_TYPE & in,
|
||||||
x = r2*c;
|
x = r2*c;
|
||||||
z = r2*s;
|
z = r2*s;
|
||||||
y = h/2;
|
y = h/2;
|
||||||
tp=MESH_TYPE::CoordType ( x,y,z );
|
|
||||||
tv.P()=tp;
|
ivp[cnt]=&*vi; (*vi).P()= CoordType( x,y,z ); ++vi;++cnt;
|
||||||
in.vert.push_back(tv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<MESH_TYPE::vertex_pointer> index(in.vn);
|
FaceIterator fi=in.face.begin();
|
||||||
|
|
||||||
MESH_TYPE::face_type f;
|
if(r1!=0) for(i=0;i<D;++i,++fi) {
|
||||||
f.Supervisor_Flags()=0;
|
(*fi).V(0)=ivp[0];
|
||||||
|
(*fi).V(1)=ivp[b1+i];
|
||||||
MESH_TYPE::vertex_iterator vi;
|
(*fi).V(2)=ivp[b1+(i+1)%D];
|
||||||
int j;
|
|
||||||
for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
|
|
||||||
|
|
||||||
if(r1!=0)
|
|
||||||
{
|
|
||||||
for(i=0;i<D;++i)
|
|
||||||
{
|
|
||||||
f.V(0)=index[0];
|
|
||||||
f.V(1)=index[b1+i];
|
|
||||||
f.V(2)=index[b1+(i+1)%D];
|
|
||||||
in.face.push_back(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r2!=0)
|
if(r2!=0) for(i=0;i<D;++i,++fi) {
|
||||||
{
|
(*fi).V(0)=ivp[1];
|
||||||
for(i=0;i<D;++i)
|
(*fi).V(1)=ivp[b2+i];
|
||||||
{
|
(*fi).V(2)=ivp[b2+(i+1)%D];
|
||||||
f.V(0)=index[1];
|
|
||||||
f.V(1)=index[b2+(i+1)%D];
|
|
||||||
f.V(2)=index[b2+i];
|
|
||||||
in.face.push_back(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r1==0)
|
if(r1==0) for(i=0;i<D;++i,++fi)
|
||||||
{
|
{
|
||||||
for(i=0;i<D;++i)
|
(*fi).V(0)=ivp[0];
|
||||||
{
|
(*fi).V(1)=ivp[b2+i];
|
||||||
f.V(0)=index[0];
|
(*fi).V(2)=ivp[b2+(i+1)%D];
|
||||||
f.V(1)=index[b2+i];
|
|
||||||
f.V(2)=index[b2+(i+1)%D];
|
|
||||||
in.face.push_back(f);
|
in.face.push_back(f);
|
||||||
}
|
}
|
||||||
|
if(r2==0) for(i=0;i<D;++i,++fi){
|
||||||
|
(*fi).V(0)=ivp[1];
|
||||||
|
(*fi).V(1)=ivp[b1+i];
|
||||||
|
(*fi).V(2)=ivp[b1+(i+1)%D];
|
||||||
}
|
}
|
||||||
else if(r2==0)
|
|
||||||
|
if(r1!=0 && r2!=0)for(i=0;i<D;++i)
|
||||||
{
|
{
|
||||||
for(i=0;i<D;++i)
|
(*fi).V(0)=ivp[b1+i];
|
||||||
{
|
(*fi).V(1)=ivp[b2+i];
|
||||||
f.V(0)=index[1];
|
(*fi).V(2)=ivp[b2+(i+1)%D];
|
||||||
f.V(2)=index[b1+i];
|
++fi;
|
||||||
f.V(1)=index[b1+(i+1)%D];
|
(*fi).V(0)=ivp[b1+1];
|
||||||
in.face.push_back(f);
|
(*fi).V(2)=ivp[b2+(i+1)%D];
|
||||||
}
|
(*fi).V(2)=ivp[b1+(i+1)%D];
|
||||||
}
|
++fi;
|
||||||
else
|
|
||||||
{
|
|
||||||
for(i=0;i<D;++i)
|
|
||||||
{
|
|
||||||
f.V(0)=index[b1+i];
|
|
||||||
f.V(1)=index[b2+i];
|
|
||||||
f.V(2)=index[b2+(i+1)%D];
|
|
||||||
in.face.push_back(f);
|
|
||||||
f.V(0)=index[b1+i];
|
|
||||||
f.V(1)=index[b2+(i+1)%D];
|
|
||||||
f.V(2)=index[b1+(i+1)%D];
|
|
||||||
in.face.push_back(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class MESH_TYPE>
|
template <class MeshType >
|
||||||
void Box(MESH_TYPE &in, const typename MESH_TYPE::BoxType & bb )
|
void Box(MeshType &in, const typename MeshType::BoxType & bb )
|
||||||
{
|
{
|
||||||
in.vn=8;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
in.fn=12;
|
typedef typename MeshType::CoordType CoordType;
|
||||||
in.vert.clear();
|
typedef typename MeshType::VertexPointer VertexPointer;
|
||||||
in.face.clear();
|
typedef typename MeshType::VertexIterator VertexIterator;
|
||||||
MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0;
|
typedef typename MeshType::FaceIterator FaceIterator;
|
||||||
MESH_TYPE::CoordType tp;
|
|
||||||
tp=MESH_TYPE::CoordType (bb.min[0],bb.min[1],bb.min[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.max[0],bb.min[1],bb.min[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.min[0],bb.max[1],bb.min[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.max[0],bb.max[1],bb.min[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.min[0],bb.min[1],bb.max[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.max[0],bb.min[1],bb.max[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.min[0],bb.max[1],bb.max[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
tp=MESH_TYPE::CoordType (bb.max[0],bb.max[1],bb.max[2]); tv.P()=tp; in.vert.push_back(tv);
|
|
||||||
|
|
||||||
vector<MESH_TYPE::vertex_pointer> index(in.vn);
|
in.Clear();
|
||||||
|
Allocator<MeshType>::AddVertices(in,8);
|
||||||
|
Allocator<MeshType>::AddFaces(in,12);
|
||||||
|
|
||||||
MESH_TYPE::face_type f;f.Supervisor_Flags()=0;
|
VertexPointer ivp[8];
|
||||||
|
|
||||||
MESH_TYPE::vertex_iterator vi;
|
VertexIterator vi=in.vert.begin();
|
||||||
int j;
|
ivp[0]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.min[1],bb.min[2]); ++vi;
|
||||||
for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &*vi;
|
ivp[1]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.min[1],bb.min[2]); ++vi;
|
||||||
f.V(0)=index[0]; f.V(1)=index[1];f.V(2)=index[2]; in.face.push_back(f);
|
ivp[2]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.max[1],bb.min[2]); ++vi;
|
||||||
f.V(0)=index[3]; f.V(1)=index[2];f.V(2)=index[1]; in.face.push_back(f);
|
ivp[3]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.max[1],bb.min[2]); ++vi;
|
||||||
|
ivp[3]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.min[1],bb.max[2]); ++vi;
|
||||||
|
ivp[3]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.min[1],bb.max[2]); ++vi;
|
||||||
|
ivp[4]=&*vi;(*vi).P()=CoordType (bb.min[0],bb.max[1],bb.max[2]); ++vi;
|
||||||
|
ivp[5]=&*vi;(*vi).P()=CoordType (bb.max[0],bb.max[1],bb.max[2]);
|
||||||
|
|
||||||
f.V(0)=index[0]; f.V(1)=index[2];f.V(2)=index[4]; in.face.push_back(f);
|
FaceIterator fi=in.face.begin();
|
||||||
f.V(0)=index[6]; f.V(1)=index[4];f.V(2)=index[2]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1]; ++fi;
|
||||||
f.V(0)=index[0]; f.V(1)=index[4];f.V(2)=index[1]; in.face.push_back(f);
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[4]; ++fi;
|
||||||
f.V(0)=index[5]; f.V(1)=index[1];f.V(2)=index[4]; in.face.push_back(f);
|
(*fi).V(0)=ivp[6]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[2]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[4]; (*fi).V(2)=ivp[1]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[5];f.V(2)=index[6]; in.face.push_back(f);
|
(*fi).V(0)=ivp[5]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[4]; ++fi;
|
||||||
f.V(0)=index[4]; f.V(1)=index[6];f.V(2)=index[5]; in.face.push_back(f);
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[6]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[4]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[5]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[6];f.V(2)=index[3]; in.face.push_back(f);
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[6]; (*fi).V(2)=ivp[3]; ++fi;
|
||||||
f.V(0)=index[2]; f.V(1)=index[3];f.V(2)=index[6]; in.face.push_back(f);
|
(*fi).V(0)=ivp[2]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[6]; ++fi;
|
||||||
|
(*fi).V(0)=ivp[7]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[5]; ++fi;
|
||||||
f.V(0)=index[7]; f.V(1)=index[3];f.V(2)=index[5]; in.face.push_back(f);
|
(*fi).V(0)=ivp[1]; (*fi).V(1)=ivp[5]; (*fi).V(2)=ivp[3];
|
||||||
f.V(0)=index[1]; f.V(1)=index[5];f.V(2)=index[3]; in.face.push_back(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Questa funzione costruisce una mesh a partire da un insieme di coordiante
|
/// Questa funzione costruisce una mesh a partire da un insieme di coordiante
|
||||||
/// ed un insieme di terne di indici di vertici
|
/// ed un insieme di terne di indici di vertici
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue