Code formatting

This commit is contained in:
Virendra Singh 2015-02-25 07:47:00 +05:30
parent 8212f86bfb
commit c15c549881
3 changed files with 19 additions and 37 deletions

View file

@ -9,13 +9,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <Qvector> #include <QVector>
#include "VHACDUtil.h" #include "VHACDUtil.h"
//Read all the meshes from provided FBX file //Read all the meshes from provided FBX file
bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results) bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *results){
{
// open the fbx file // open the fbx file
QFile fbx(filename); QFile fbx(filename);
@ -29,15 +28,13 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re
//results->meshCount = geometry.meshes.count(); //results->meshCount = geometry.meshes.count();
int count = 0; int count = 0;
foreach(FBXMesh mesh, geometry.meshes) foreach(FBXMesh mesh, geometry.meshes) {
{
//get vertices for each mesh //get vertices for each mesh
QVector<glm::vec3> vertices = mesh.vertices; QVector<glm::vec3> vertices = mesh.vertices;
//get the triangle indices for each mesh //get the triangle indices for each mesh
QVector<int> triangles; QVector<int> triangles;
foreach(FBXMeshPart part, mesh.parts) foreach(FBXMeshPart part, mesh.parts) {
{
QVector<int> indices = part.triangleIndices; QVector<int> indices = part.triangleIndices;
triangles += indices; triangles += indices;
} }
@ -54,15 +51,13 @@ bool vhacd::VHACDUtil::loadFBX(const QString filename, vhacd::LoadFBXResults *re
return true; return true;
} }
bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD::Parameters params, vhacd::ComputeResults *results)const{
{
VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD(); VHACD::IVHACD * interfaceVHACD = VHACD::CreateVHACD();
int meshCount = meshes->meshCount; int meshCount = meshes->meshCount;
int count = 0; int count = 0;
std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl; std::cout << "Performing V-HACD computation on " << meshCount <<" meshes ..... " << std::endl;
for (int i = 0; i < meshCount; i++) for (int i = 0; i < meshCount; i++){
{
std::vector<glm::vec3> vertices = meshes->perMeshVertices.at(i).toStdVector(); std::vector<glm::vec3> vertices = meshes->perMeshVertices.at(i).toStdVector();
std::vector<int> triangles = meshes->perMeshTriangleIndices.at(i).toStdVector(); std::vector<int> triangles = meshes->perMeshTriangleIndices.at(i).toStdVector();
@ -71,8 +66,7 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD
std::cout << "Mesh " << i + 1 << " : "; std::cout << "Mesh " << i + 1 << " : ";
// compute approximate convex decomposition // compute approximate convex decomposition
bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params); bool res = interfaceVHACD->Compute(&vertices[0].x, 3, nPoints, &triangles[0], 3, nTriangles, params);
if (!res) if (!res){
{
std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl; std::cout << "V-HACD computation failed for Mesh : " << i + 1 << std::endl;
continue; continue;
} }
@ -84,8 +78,7 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD
//get all the convex hulls for this mesh //get all the convex hulls for this mesh
QVector<VHACD::IVHACD::ConvexHull> convexHulls; QVector<VHACD::IVHACD::ConvexHull> convexHulls;
for (unsigned int j = 0; j < nConvexHulls; j++) for (unsigned int j = 0; j < nConvexHulls; j++){
{
VHACD::IVHACD::ConvexHull hull; VHACD::IVHACD::ConvexHull hull;
interfaceVHACD->GetConvexHull(j, hull); interfaceVHACD->GetConvexHull(j, hull);
convexHulls.append(hull); convexHulls.append(hull);
@ -105,14 +98,12 @@ bool vhacd::VHACDUtil::computeVHACD(vhacd::LoadFBXResults *meshes, VHACD::IVHACD
return false; return false;
} }
vhacd::VHACDUtil:: ~VHACDUtil() vhacd::VHACDUtil:: ~VHACDUtil(){
{
//nothing to be cleaned //nothing to be cleaned
} }
//ProgressClaback implementation //ProgressClaback implementation
void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation) void vhacd::ProgressCallback::Update(const double overallProgress, const double stageProgress, const double operationProgress, const char * const stage, const char * const operation){
{
int progress = (int)(overallProgress + 0.5); int progress = (int)(overallProgress + 0.5);
if (progress < 10) if (progress < 10)

View file

@ -42,8 +42,7 @@ namespace vhacd{
~VHACDUtil(); ~VHACDUtil();
}; };
class ProgressCallback : public VHACD::IVHACD::IUserCallback class ProgressCallback : public VHACD::IVHACD::IUserCallback{
{
public: public:
ProgressCallback(void); ProgressCallback(void);
~ProgressCallback(); ~ProgressCallback();

View file

@ -19,8 +19,7 @@
using namespace std; using namespace std;
using namespace VHACD; using namespace VHACD;
int main(int argc, char * argv[]) int main(int argc, char * argv[]){
{
vector<int> triangles; // array of indexes vector<int> triangles; // array of indexes
vector<float> points; // array of coordinates vector<float> points; // array of coordinates
vhacd::VHACDUtil vUtil; vhacd::VHACDUtil vUtil;
@ -44,34 +43,29 @@ int main(int argc, char * argv[])
params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls
// load the mesh // load the mesh
if (!vUtil.loadFBX(fname, &fbx)) if (!vUtil.loadFBX(fname, &fbx)){
{
cout << "Error in opening FBX file...."; cout << "Error in opening FBX file....";
return 1; return 1;
} }
if (!vUtil.computeVHACD(&fbx, params, &results)) if (!vUtil.computeVHACD(&fbx, params, &results)){
{
cout << "Compute Failed..."; cout << "Compute Failed...";
return 1; return 1;
} }
int totalVertices = 0; int totalVertices = 0;
for (int i = 0; i < fbx.meshCount; i++) for (int i = 0; i < fbx.meshCount; i++){
{
totalVertices += fbx.perMeshVertices.at(i).count(); totalVertices += fbx.perMeshVertices.at(i).count();
} }
int totalTriangles = 0; int totalTriangles = 0;
for (int i = 0; i < fbx.meshCount; i++) for (int i = 0; i < fbx.meshCount; i++){
{
totalTriangles += fbx.perMeshTriangleIndices.at(i).count(); totalTriangles += fbx.perMeshTriangleIndices.at(i).count();
} }
int totalHulls = 0; int totalHulls = 0;
QVector<int> hullCounts = results.convexHullsCountList; QVector<int> hullCounts = results.convexHullsCountList;
for (int i = 0; i < results.meshCount; i++) for (int i = 0; i < results.meshCount; i++){
{
totalHulls += hullCounts.at(i); totalHulls += hullCounts.at(i);
} }
cout << endl << "Summary of V-HACD Computation..................." << endl; cout << endl << "Summary of V-HACD Computation..................." << endl;
@ -82,14 +76,12 @@ int main(int argc, char * argv[])
cout << "Total Triangles : " << totalTriangles << endl; cout << "Total Triangles : " << totalTriangles << endl;
cout << "Total Convex Hulls : " << totalHulls << endl; cout << "Total Convex Hulls : " << totalHulls << endl;
cout << endl << "Summary per convex hull ........................" << endl <<endl; cout << endl << "Summary per convex hull ........................" << endl <<endl;
for (int i = 0; i < results.meshCount; i++) for (int i = 0; i < results.meshCount; i++){
{
cout << "Mesh : " << i + 1 << endl; cout << "Mesh : " << i + 1 << endl;
QVector<VHACD::IVHACD::ConvexHull> chList = results.convexHullList.at(i); QVector<VHACD::IVHACD::ConvexHull> chList = results.convexHullList.at(i);
cout << "\t" << "Number Of Hulls : " << chList.count() << endl; cout << "\t" << "Number Of Hulls : " << chList.count() << endl;
for (int j = 0; j < results.convexHullList.at(i).count(); j++) for (int j = 0; j < results.convexHullList.at(i).count(); j++){
{
cout << "\tHUll : " << j + 1 << endl; cout << "\tHUll : " << j + 1 << endl;
cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl; cout << "\t\tNumber Of Points : " << chList.at(j).m_nPoints << endl;