Skip to content

Commit

Permalink
Added PLY Functionality
Browse files Browse the repository at this point in the history
Signed-off-by: spotenza2016 <saganpotenza@gmail.com>

Signed-off-by: spotenza2016 <64374401+spotenza2016@users.noreply.github.com>
  • Loading branch information
spotenza2016 committed Sep 29, 2022
1 parent fce7b82 commit e16b571
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions avogadro/qtplugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ add_subdirectory(networkdatabases)
add_subdirectory(openbabel)
add_subdirectory(openmminput)
add_subdirectory(playertool)
add_subdirectory(ply)
add_subdirectory(propertytables)
add_subdirectory(povray)
add_subdirectory(resetview)
Expand Down
2 changes: 2 additions & 0 deletions avogadro/rendering/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(HEADERS
linestripgeometry.h
meshgeometry.h
node.h
plyvisitor.h
povrayvisitor.h
primitive.h
quad.h
Expand Down Expand Up @@ -75,6 +76,7 @@ set(SOURCES
linestripgeometry.cpp
meshgeometry.cpp
node.cpp
plyvisitor.cpp
povrayvisitor.cpp
quad.cpp
quadoutline.cpp
Expand Down
18 changes: 9 additions & 9 deletions avogadro/rendering/plyvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void PLYVisitor::visitSphereIcosphereRecursionMethod(const SphereColor& sphere,
}

//Adjust the counts and add the new vertices and faces
m_vertexCount += vertices.size();
m_vertexCount += vertices.size();
m_faceCount += faces.size();
m_sceneVertices += vertexStr.str();
m_sceneFaces += faceStr.str();
Expand Down Expand Up @@ -313,29 +313,29 @@ void PLYVisitor::visitCylinderLateralMethod(const CylinderColor& geometry, unsig
//2 * i gives the index of the first vertex, plus 1 for second vertex, plus 2 or 3 for next faces vertex
//Modulo included for +2 or +3 to prevent going out of bounds

//Lateral face made up of first vertex, next face's first vertex, and second vertex
//Lateral face made up of the next face's first vertex, first vertex, and second vertex
faceStr << 3 << " "
<< 2 * i + m_vertexCount << " "
<< (2 * i + 2) % (2 * lateralFaces) + m_vertexCount << " "
<< 2 * i + m_vertexCount << " "
<< 2 * i + 1 + m_vertexCount << '\n';
//Lateral face made up of second vertex, next face's first vertex, and next face's second vertex
//Lateral face made up of next face's first vertex, second vertex, and next face's second vertex
faceStr << 3 << " "
<< 2 * i + 1 + m_vertexCount << " "
<< (2 * i + 2) % (2 * lateralFaces) + m_vertexCount << " "
<< 2 * i + 1 + m_vertexCount << " "
<< (2 * i + 3) % (2 * lateralFaces) + m_vertexCount << '\n';

//Code needs to deal with faces on top and bottom of cylinder
//To turn local indices to the indices of the PLY file, -2 is used for end1 and -1 is used for end2

//Top face made up of first vertex, end1, and next face's first vertex
//Top face made up of end1, first vertex, and next face's first vertex
faceStr << 3 << " "
<< 2 * i + m_vertexCount << " "
<< -2 + m_vertexCount << " "
<< 2 * i + m_vertexCount << " "
<< (2 * i + 2) % (2 * lateralFaces) + m_vertexCount << '\n';
//Bottom face made up of second vertex, next face's second vertex, and end2
//Bottom face made up of next face's second vertex, second vertex, and end2
faceStr << 3 << " "
<< 2 * i + 1 + m_vertexCount << " "
<< (2 * i + 3) % (2 * lateralFaces) + m_vertexCount << " "
<< 2 * i + 1 + m_vertexCount << " "
<< -1 + m_vertexCount << '\n';
}

Expand Down

0 comments on commit e16b571

Please sign in to comment.