Removed features which were deprecated in release 0.2.
This commit is contained in:
@ -1,187 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 David Williams
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __PolyVox_MeshDecimator_H__
|
||||
#define __PolyVox_MeshDecimator_H__
|
||||
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
/// The MeshDecimator reduces the number of triangles in a mesh.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Meshes generated by the PolyVox surface extractors typically have a very high
|
||||
/// number of triangles in them. This can pose difficulties both for the rendering
|
||||
/// storage of such meshes. The MeshDecimator provides a way of reducing the triangle
|
||||
/// count with minimal visual effect.
|
||||
///
|
||||
/// The MeshDecimator is based on the principle of edge collapse, and currently works
|
||||
/// with meshes generated by the MarchingCubesSurfaceExtractor or CubicSurfaceExtractor. It does
|
||||
/// not work with meshes generated by the CubicSurfaceExtractorWithNormals, although
|
||||
/// this may be addressed in the future. The algorithm iterates over each pair of
|
||||
/// connected vertices in the mesh and attemps to determine if they can be collapsed
|
||||
/// into a single vertex.
|
||||
///
|
||||
/// The main criteria used in deciding whether two vertices can collapse is whether
|
||||
/// they have the same normal. In the case of the cubic surfaces the normals must be
|
||||
/// exactly the same, whereas in the case of the Marching Cubes surfaces a threshold
|
||||
/// is used to determine whether two normals are 'close enough'. Additional constraints
|
||||
/// apply to vertices which lie on the edges of regions or on the boundary between two
|
||||
/// regions - these vertices are much less likely to be collapsed.
|
||||
///
|
||||
/// Given a mesh called 'mesh', you can create a decimated version as follows:
|
||||
/// \code
|
||||
/// SurfaceMesh<PositionMaterial> decimatedMesh;
|
||||
/// MeshDecimator<PositionMaterial> decimator(&mesh, &decimatedMesh);
|
||||
/// decimator.execute();
|
||||
/// \endcode
|
||||
///
|
||||
/// The above applies for a cubic mesh, for a Marching Cubes mesh you need to parametise
|
||||
/// the MeshDecimator and resulting SurfaceMesh on the 'PositionMaterialNormal' type
|
||||
/// instead of the 'PositionMaterial' type.
|
||||
///
|
||||
/// \deprecated
|
||||
template <typename VertexType>
|
||||
class MeshDecimator
|
||||
{
|
||||
//Used to keep track of when a vertex is
|
||||
//on one or more faces of the region
|
||||
enum RegionFaceFlags
|
||||
{
|
||||
RFF_ON_REGION_FACE_NEG_X,
|
||||
RFF_ON_REGION_FACE_POS_X ,
|
||||
RFF_ON_REGION_FACE_NEG_Y ,
|
||||
RFF_ON_REGION_FACE_POS_Y ,
|
||||
RFF_ON_REGION_FACE_NEG_Z ,
|
||||
RFF_ON_REGION_FACE_POS_Z,
|
||||
RFF_NO_OF_REGION_FACE_FLAGS
|
||||
};
|
||||
|
||||
//Data about the initial mesh - this
|
||||
//will be fill in once at the start
|
||||
struct InitialVertexMetadata
|
||||
{
|
||||
Vector3DFloat normal;
|
||||
bool isOnMaterialEdge;
|
||||
std::bitset<RFF_NO_OF_REGION_FACE_FLAGS> isOnRegionFace;
|
||||
};
|
||||
|
||||
//Representing a triangle for decimation purposes.
|
||||
struct Triangle
|
||||
{
|
||||
uint32_t v0;
|
||||
uint32_t v1;
|
||||
uint32_t v2;
|
||||
Vector3DFloat normal;
|
||||
};
|
||||
|
||||
struct IntVertex
|
||||
{
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
uint32_t index;
|
||||
|
||||
IntVertex(int32_t xVal, int32_t yVal, int32_t zVal, uint32_t indexVal)
|
||||
:x(xVal)
|
||||
,y(yVal)
|
||||
,z(zVal)
|
||||
,index(indexVal)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const IntVertex& rhs) const
|
||||
{
|
||||
return (x == rhs.x) && (y == rhs.y) && (z == rhs.z);
|
||||
}
|
||||
|
||||
bool operator<(const IntVertex& rhs) const
|
||||
{
|
||||
if (z < rhs.z)
|
||||
return true;
|
||||
if (rhs.z < z)
|
||||
return false;
|
||||
|
||||
if (y < rhs.y)
|
||||
return true;
|
||||
if (rhs.y < y)
|
||||
return false;
|
||||
|
||||
if (x < rhs.x)
|
||||
return true;
|
||||
if (rhs.x < x)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
///Constructor
|
||||
POLYVOX_DEPRECATED MeshDecimator(const SurfaceMesh<VertexType>* pInputMesh, SurfaceMesh<VertexType>* pOutputMesh, float fEdgeCollapseThreshold = 0.95f);
|
||||
|
||||
///Performs the decimation.
|
||||
POLYVOX_DEPRECATED void execute();
|
||||
|
||||
private:
|
||||
|
||||
void fillInitialVertexMetadata(std::vector<InitialVertexMetadata>& vecInitialVertexMetadata);
|
||||
|
||||
void buildConnectivityData(void);
|
||||
|
||||
bool attemptEdgeCollapse(uint32_t uSrc, uint32_t uDst);
|
||||
|
||||
const SurfaceMesh<VertexType>* m_pInputMesh;
|
||||
SurfaceMesh<VertexType>* m_pOutputMesh;
|
||||
|
||||
uint32_t performDecimationPass(float m_fMinDotProductForCollapse);
|
||||
bool isSubset(std::bitset<RFF_NO_OF_REGION_FACE_FLAGS> a, std::bitset<RFF_NO_OF_REGION_FACE_FLAGS> b);
|
||||
|
||||
bool canCollapseEdge(uint32_t uSrc, uint32_t uDst);
|
||||
bool canCollapseNormalEdge(uint32_t uSrc, uint32_t uDst);
|
||||
bool canCollapseRegionEdge(uint32_t uSrc, uint32_t uDst);
|
||||
bool canCollapseMaterialEdge(uint32_t uSrc, uint32_t uDst);
|
||||
bool collapseChangesFaceNormals(uint32_t uSrc, uint32_t uDst, float fThreshold);
|
||||
|
||||
//Data structures used during decimation
|
||||
|
||||
std::vector<bool> vertexLocked;
|
||||
std::vector<uint32_t> vertexMapper;
|
||||
|
||||
std::vector<Triangle> m_vecTriangles;
|
||||
std::vector< std::vector<uint32_t> > trianglesUsingVertex; //Should probably use vector of vectors, and resise in advance.
|
||||
|
||||
std::vector<InitialVertexMetadata> m_vecInitialVertexMetadata;
|
||||
|
||||
float m_fMinDotProductForCollapse;
|
||||
};
|
||||
}
|
||||
|
||||
#include "PolyVoxCore/MeshDecimator.inl"
|
||||
|
||||
#endif //__PolyVox_MeshDecimator_H__
|
@ -1,347 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 David Williams
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Builds a MeshDecimator.
|
||||
/// \param pInputMesh A pointer to the mesh to be decimated.
|
||||
/// \param[out] pOutputMesh A pointer to where the result should be stored. Any existing
|
||||
/// contents will be deleted.
|
||||
/// \param fEdgeCollapseThreshold This is only use in the case of a Marching Cubes
|
||||
/// surface and controls how close two normals must be to collapse. The dot product
|
||||
/// between the normals is computed and compared to this threshold. A threshold of
|
||||
/// 1.0 means nothing will collapse, a threshold of 0.0 means everything will collapse.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename VertexType>
|
||||
MeshDecimator<VertexType>::MeshDecimator(const SurfaceMesh<VertexType>* pInputMesh, SurfaceMesh<VertexType>* pOutputMesh, float fEdgeCollapseThreshold)
|
||||
:m_pInputMesh(pInputMesh)
|
||||
,m_pOutputMesh(pOutputMesh)
|
||||
,m_fMinDotProductForCollapse(fEdgeCollapseThreshold)
|
||||
{
|
||||
*m_pOutputMesh = *m_pInputMesh;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
void MeshDecimator<VertexType>::execute()
|
||||
{
|
||||
//Sanity check.
|
||||
if((m_pOutputMesh->m_vecVertices.empty()) || (m_pOutputMesh->m_vecTriangleIndices.empty()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
buildConnectivityData();
|
||||
fillInitialVertexMetadata(m_vecInitialVertexMetadata);
|
||||
|
||||
uint32_t noOfEdgesCollapsed;
|
||||
do
|
||||
{
|
||||
noOfEdgesCollapsed = performDecimationPass(m_fMinDotProductForCollapse);
|
||||
m_pOutputMesh->removeDegenerateTris();
|
||||
if(noOfEdgesCollapsed > 0)
|
||||
{
|
||||
//Build the connectivity data for the next pass. If this is slow, then look
|
||||
//at adjusting it (based on vertex mapper?) rather than bulding from scratch.
|
||||
buildConnectivityData();
|
||||
}
|
||||
}while(noOfEdgesCollapsed > 0);
|
||||
|
||||
m_pOutputMesh->removeUnusedVertices();
|
||||
|
||||
//Decimation will have invalidated LOD levels.
|
||||
m_pOutputMesh->m_vecLodRecords.clear();
|
||||
LodRecord lodRecord;
|
||||
lodRecord.beginIndex = 0;
|
||||
lodRecord.endIndex = m_pOutputMesh->getNoOfIndices();
|
||||
m_pOutputMesh->m_vecLodRecords.push_back(lodRecord);
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
void MeshDecimator<VertexType>::buildConnectivityData(void)
|
||||
{
|
||||
//Build a list of all the triangles, complete with face normals.
|
||||
m_vecTriangles.clear();
|
||||
m_vecTriangles.resize(m_pOutputMesh->m_vecTriangleIndices.size() / 3);
|
||||
for(uint32_t triCt = 0; triCt < m_vecTriangles.size(); triCt++)
|
||||
{
|
||||
m_vecTriangles[triCt].v0 = m_pOutputMesh->m_vecTriangleIndices[triCt * 3 + 0];
|
||||
m_vecTriangles[triCt].v1 = m_pOutputMesh->m_vecTriangleIndices[triCt * 3 + 1];
|
||||
m_vecTriangles[triCt].v2 = m_pOutputMesh->m_vecTriangleIndices[triCt * 3 + 2];
|
||||
|
||||
Vector3DFloat v0Pos = m_pOutputMesh->m_vecVertices[m_vecTriangles[triCt].v0].position;
|
||||
Vector3DFloat v1Pos = m_pOutputMesh->m_vecVertices[m_vecTriangles[triCt].v1].position;
|
||||
Vector3DFloat v2Pos = m_pOutputMesh->m_vecVertices[m_vecTriangles[triCt].v2].position;
|
||||
|
||||
Vector3DFloat v0v1 = v1Pos - v0Pos;
|
||||
Vector3DFloat v0v2 = v2Pos - v0Pos;
|
||||
Vector3DFloat normal = v0v1.cross(v0v2);
|
||||
normal.normalise();
|
||||
|
||||
m_vecTriangles[triCt].normal = normal;
|
||||
}
|
||||
|
||||
//For each vertex, determine which triangles are using it.
|
||||
trianglesUsingVertex.clear();
|
||||
trianglesUsingVertex.resize(m_pOutputMesh->m_vecVertices.size());
|
||||
for(uint32_t ct = 0; ct < trianglesUsingVertex.size(); ct++)
|
||||
{
|
||||
trianglesUsingVertex[ct].reserve(6);
|
||||
}
|
||||
for(uint32_t ct = 0; ct < m_vecTriangles.size(); ct++)
|
||||
{
|
||||
trianglesUsingVertex[m_vecTriangles[ct].v0].push_back(ct);
|
||||
trianglesUsingVertex[m_vecTriangles[ct].v1].push_back(ct);
|
||||
trianglesUsingVertex[m_vecTriangles[ct].v2].push_back(ct);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
uint32_t MeshDecimator<VertexType>::performDecimationPass(float /*m_fMinDotProductForCollapse*/)
|
||||
{
|
||||
// Count how many edges we have collapsed
|
||||
uint32_t noOfEdgesCollapsed = 0;
|
||||
|
||||
// The vertex mapper track whick vertices collapse onto which.
|
||||
vertexMapper.clear();
|
||||
vertexMapper.resize(m_pOutputMesh->m_vecVertices.size());
|
||||
|
||||
// Once a vertex is involved in a collapse (either because it
|
||||
// moves onto a different vertex, or because a different vertex
|
||||
// moves onto it) it is forbidden to take part in another collapse
|
||||
// this pass. We enforce this by setting the vertex locked flag.
|
||||
vertexLocked.clear();
|
||||
vertexLocked.resize(m_pOutputMesh->m_vecVertices.size());
|
||||
|
||||
// Initialise the vectors
|
||||
for(uint32_t ct = 0; ct < m_pOutputMesh->m_vecVertices.size(); ct++)
|
||||
{
|
||||
// Initiall all vertices points to themselves
|
||||
vertexMapper[ct] = ct;
|
||||
// All vertices are initially unlocked
|
||||
vertexLocked[ct] = false;
|
||||
}
|
||||
|
||||
//For each triangle...
|
||||
for(uint32_t ctIter = 0; ctIter < m_vecTriangles.size(); ctIter++)
|
||||
{
|
||||
if(attemptEdgeCollapse(m_vecTriangles[ctIter].v0, m_vecTriangles[ctIter].v1))
|
||||
{
|
||||
++noOfEdgesCollapsed;
|
||||
}
|
||||
|
||||
if(attemptEdgeCollapse(m_vecTriangles[ctIter].v1, m_vecTriangles[ctIter].v2))
|
||||
{
|
||||
++noOfEdgesCollapsed;
|
||||
}
|
||||
|
||||
if(attemptEdgeCollapse(m_vecTriangles[ctIter].v2, m_vecTriangles[ctIter].v0))
|
||||
{
|
||||
++noOfEdgesCollapsed;
|
||||
}
|
||||
}
|
||||
|
||||
if(noOfEdgesCollapsed > 0)
|
||||
{
|
||||
//Fix up the indices
|
||||
for(uint32_t triCt = 0; triCt < m_pOutputMesh->m_vecTriangleIndices.size(); triCt++)
|
||||
{
|
||||
uint32_t before = m_pOutputMesh->m_vecTriangleIndices[triCt];
|
||||
uint32_t after = vertexMapper[m_pOutputMesh->m_vecTriangleIndices[triCt]];
|
||||
if(before != after)
|
||||
{
|
||||
m_pOutputMesh->m_vecTriangleIndices[triCt] = vertexMapper[m_pOutputMesh->m_vecTriangleIndices[triCt]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noOfEdgesCollapsed;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::attemptEdgeCollapse(uint32_t uSrc, uint32_t uDst)
|
||||
{
|
||||
//A vertex will be locked if it has already been involved in a collapse this pass.
|
||||
if(vertexLocked[uSrc] || vertexLocked[uDst])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(canCollapseEdge(uSrc, uDst))
|
||||
{
|
||||
//Move v0 onto v1
|
||||
vertexMapper[uSrc] = uDst; //vertexMapper[v1];
|
||||
vertexLocked[uSrc] = true;
|
||||
vertexLocked[uDst] = true;
|
||||
|
||||
//Increment the counter
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::canCollapseEdge(uint32_t uSrc, uint32_t uDst)
|
||||
{
|
||||
bool bCanCollapse = true;
|
||||
|
||||
if(m_vecInitialVertexMetadata[uSrc].isOnMaterialEdge)
|
||||
{
|
||||
bCanCollapse &= canCollapseMaterialEdge(uSrc, uDst);
|
||||
}
|
||||
|
||||
if(m_vecInitialVertexMetadata[uSrc].isOnRegionFace.any())
|
||||
{
|
||||
bCanCollapse &= canCollapseRegionEdge(uSrc, uDst);
|
||||
}
|
||||
|
||||
if(bCanCollapse) //Only bother with this if the earlier tests passed.
|
||||
{
|
||||
bCanCollapse &= canCollapseNormalEdge(uSrc, uDst);
|
||||
}
|
||||
|
||||
return bCanCollapse;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::canCollapseRegionEdge(uint32_t uSrc, uint32_t uDst)
|
||||
{
|
||||
// We can collapse normal vertices onto edge vertices, and edge vertices
|
||||
// onto corner vertices, but not vice-versa. Hence we check whether all
|
||||
// the edge flags in the source vertex are also set in the destination vertex.
|
||||
if(isSubset(m_vecInitialVertexMetadata[uSrc].isOnRegionFace, m_vecInitialVertexMetadata[uDst].isOnRegionFace) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// In general adjacent regions surface meshes may collapse differently
|
||||
// and this can cause cracks. We solve this by only allowing the collapse
|
||||
// is the normals are exactly the same. We do not use the user provided
|
||||
// tolerence here (but do allow for floating point error).
|
||||
if(m_vecInitialVertexMetadata[uSrc].normal.dot(m_vecInitialVertexMetadata[uDst].normal) < 0.999f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::canCollapseMaterialEdge(uint32_t /*uSrc*/, uint32_t /*uDst*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//This function should really use some work. For a start we already have the
|
||||
//faces normals for the input mesh yet we are computing them on the fly here.
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::collapseChangesFaceNormals(uint32_t uSrc, uint32_t uDst, float fThreshold)
|
||||
{
|
||||
bool faceFlipped = false;
|
||||
std::vector<uint32_t>& triangles = trianglesUsingVertex[uSrc];
|
||||
|
||||
for(std::vector<uint32_t>::iterator triIter = triangles.begin(); triIter != triangles.end(); triIter++)
|
||||
{
|
||||
uint32_t tri = *triIter;
|
||||
|
||||
const uint32_t& v0Old = m_pOutputMesh->m_vecTriangleIndices[tri * 3];
|
||||
const uint32_t& v1Old = m_pOutputMesh->m_vecTriangleIndices[tri * 3 + 1];
|
||||
const uint32_t& v2Old = m_pOutputMesh->m_vecTriangleIndices[tri * 3 + 2];
|
||||
|
||||
//Check if degenerate
|
||||
if((v0Old == v1Old) || (v1Old == v2Old) || (v2Old == v0Old))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t v0New = v0Old;
|
||||
uint32_t v1New = v1Old;
|
||||
uint32_t v2New = v2Old;
|
||||
|
||||
if(v0New == uSrc)
|
||||
v0New = uDst;
|
||||
if(v1New == uSrc)
|
||||
v1New = uDst;
|
||||
if(v2New == uSrc)
|
||||
v2New = uDst;
|
||||
|
||||
//Check if degenerate
|
||||
if((v0New == v1New) || (v1New == v2New) || (v2New == v0New))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Vector3DFloat& v0OldPos = m_pOutputMesh->m_vecVertices[vertexMapper[v0Old]].getPosition(); //Note: we need the vertex mapper here. These neighbouring vertices may have been moved.
|
||||
const Vector3DFloat& v1OldPos = m_pOutputMesh->m_vecVertices[vertexMapper[v1Old]].getPosition();
|
||||
const Vector3DFloat& v2OldPos = m_pOutputMesh->m_vecVertices[vertexMapper[v2Old]].getPosition();
|
||||
|
||||
const Vector3DFloat& v0NewPos = m_pOutputMesh->m_vecVertices[vertexMapper[v0New]].getPosition();
|
||||
const Vector3DFloat& v1NewPos = m_pOutputMesh->m_vecVertices[vertexMapper[v1New]].getPosition();
|
||||
const Vector3DFloat& v2NewPos = m_pOutputMesh->m_vecVertices[vertexMapper[v2New]].getPosition();
|
||||
|
||||
Vector3DFloat OldNormal = (v1OldPos - v0OldPos).cross(v2OldPos - v1OldPos);
|
||||
Vector3DFloat NewNormal = (v1NewPos - v0NewPos).cross(v2NewPos - v1NewPos);
|
||||
|
||||
OldNormal.normalise();
|
||||
NewNormal.normalise();
|
||||
|
||||
float dotProduct = OldNormal.dot(NewNormal);
|
||||
//NOTE: I don't think we should be using the threshold here, we're just checking for a complete face flip
|
||||
if(dotProduct < fThreshold)
|
||||
{
|
||||
//cout << " Face flipped!!" << endl;
|
||||
|
||||
faceFlipped = true;
|
||||
|
||||
/*vertexLocked[v0] = true;
|
||||
vertexLocked[v1] = true;*/
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return faceFlipped;
|
||||
}
|
||||
|
||||
// Returns true if every bit which is set in 'a' is also set in 'b'. The reverse does not need to be true.
|
||||
template <typename VertexType>
|
||||
bool MeshDecimator<VertexType>::isSubset(std::bitset<RFF_NO_OF_REGION_FACE_FLAGS> a, std::bitset<RFF_NO_OF_REGION_FACE_FLAGS> b)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
for(int ct = 0; ct < RFF_NO_OF_REGION_FACE_FLAGS; ct++)
|
||||
{
|
||||
if(a.test(ct))
|
||||
{
|
||||
if(b.test(ct) == false)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 David Williams
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __PolyVox_SimpleInterface_H__
|
||||
#define __PolyVox_SimpleInterface_H__
|
||||
|
||||
#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/SimpleVolume.h"
|
||||
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//The PolyVox simple interface only exposes one voxel type and one volume type. But if you like you can
|
||||
//adjust these typedefs and rebuild the library in order to modify which one volume and voxel is exposed.
|
||||
typedef SimpleVolume<MaterialDensityPair88> Volume;
|
||||
typedef SurfaceMesh<PositionMaterialNormal> Mesh;
|
||||
|
||||
/// \deprecated
|
||||
POLYVOX_DEPRECATED void extractCubicMesh(Volume& volume, const Region& region, Mesh& resultMesh);
|
||||
/// \deprecated
|
||||
POLYVOX_DEPRECATED void extractSmoothMesh(Volume& volume, const Region& region, Mesh& resultMesh);
|
||||
|
||||
}
|
||||
|
||||
#endif //__PolyVox_SimpleInterface_H__
|
Reference in New Issue
Block a user