-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
880 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "FbxConsumer.h" | ||
#include "FbxProducer.h" | ||
#include "Framework/Processor.h" | ||
#include "HalfEdgeMesh/HalfEdgeMesh.h" | ||
#include "Scene/SceneDatabase.h" | ||
#include "Utilities/PerformanceProfiler.h" | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
// argv[0] : exe name | ||
// argv[1] : input file path | ||
// argv[2] : output file path | ||
if (argc != 3) | ||
{ | ||
return 1; | ||
} | ||
|
||
const char* pInputFilePath = argv[1]; | ||
const char* pOutputFilePath = argv[2]; | ||
|
||
using namespace cdtools; | ||
PerformanceProfiler profiler("ProgressiveMesh"); | ||
|
||
auto pSceneDatabase = std::make_unique<cd::SceneDatabase>(); | ||
|
||
// Generate a source mesh. | ||
{ | ||
FbxProducer producer(pInputFilePath); | ||
Processor processor(&producer, nullptr, pSceneDatabase.get()); | ||
processor.SetDumpSceneDatabaseEnable(false); | ||
processor.Run(); | ||
} | ||
|
||
{ | ||
for (const auto& mesh : pSceneDatabase->GetMeshes()) | ||
{ | ||
auto halfEdgeMesh = cd::HalfEdgeMesh::FromIndexedMesh(mesh); | ||
assert(halfEdgeMesh.Validate()); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "HalfEdgeMesh/Edge.h" | ||
|
||
#include "HalfEdgeMesh/Face.h" | ||
#include "HalfEdgeMesh/HalfEdge.h" | ||
#include "HalfEdgeMesh/Vertex.h" | ||
|
||
namespace cd::hem | ||
{ | ||
|
||
bool Edge::IsOnBoundary() const | ||
{ | ||
return m_halfEdgeRef->GetFace()->IsBoundary() || m_halfEdgeRef->GetTwin()->GetFace()->IsBoundary(); | ||
} | ||
|
||
Point Edge::Center() const | ||
{ | ||
return (m_halfEdgeRef->GetVertex()->GetPosition() + m_halfEdgeRef->GetTwin()->GetVertex()->GetPosition()) * 0.5f; | ||
} | ||
|
||
Direction Edge::Normal() const | ||
{ | ||
return Direction::Zero(); | ||
} | ||
|
||
float Edge::Length() const | ||
{ | ||
return (m_halfEdgeRef->GetVertex()->GetPosition() - m_halfEdgeRef->GetTwin()->GetVertex()->GetPosition()).Length(); | ||
} | ||
|
||
bool Edge::Validate() const | ||
{ | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "HalfEdgeMesh/Face.h" | ||
|
||
#include "HalfEdgeMesh/HalfEdge.h" | ||
#include "HalfEdgeMesh/Vertex.h" | ||
|
||
namespace cd::hem | ||
{ | ||
|
||
Point Face::Center() const | ||
{ | ||
Point center(0.0f); | ||
float vertexCount = 0.0f; | ||
|
||
HalfEdgeCRef h = m_halfEdgeRef; | ||
do | ||
{ | ||
center += h->GetVertex()->GetPosition(); | ||
vertexCount += 1.0f; | ||
h = h->GetNext(); | ||
} while (h != m_halfEdgeRef); | ||
|
||
center /= vertexCount; | ||
return center; | ||
} | ||
|
||
Direction Face::Normal() const | ||
{ | ||
return Direction::Zero(); | ||
} | ||
|
||
uint32_t Face::Degree() const | ||
{ | ||
uint32_t degree = 0U; | ||
|
||
HalfEdgeCRef h = m_halfEdgeRef; | ||
do | ||
{ | ||
++degree; | ||
h = h->GetNext(); | ||
} while (h != m_halfEdgeRef); | ||
|
||
return degree; | ||
} | ||
|
||
float Face::Area() const | ||
{ | ||
float area = 0.0f; | ||
HalfEdgeCRef h = m_halfEdgeRef; | ||
Point v0 = h->GetVertex()->GetPosition(); | ||
h = h->GetNext(); | ||
|
||
do | ||
{ | ||
Direction v1v0 = h->GetVertex()->GetPosition() - v0; | ||
Direction v2v0 = h->GetNext()->GetVertex()->GetPosition() - v0; | ||
area += v1v0.Cross(v2v0).Length() * 0.5f; | ||
h = h->GetNext(); | ||
} while (h != m_halfEdgeRef); | ||
|
||
return area; | ||
} | ||
|
||
bool Face::Validate() const | ||
{ | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "HalfEdgeMesh/HalfEdge.h" | ||
|
||
namespace cd::hem | ||
{ | ||
|
||
bool HalfEdge::Validate() const | ||
{ | ||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.