Skip to content

Commit

Permalink
doc: STLReader documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricix committed Jan 17, 2025
1 parent 9872f53 commit 22634ad
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 4 additions & 2 deletions build/msbuild/MPM-Geomechanics.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)../../inc</AdditionalIncludeDirectories>
</ClCompile>
Expand All @@ -120,7 +120,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions); _CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)../../inc</AdditionalIncludeDirectories>
<OpenMPSupport>true</OpenMPSupport>
Expand Down Expand Up @@ -164,6 +164,7 @@
<ClCompile Include="..\..\src\SolverExplicitTwoPhaseUSL.cpp" />
<ClCompile Include="..\..\src\SolverExplicitUSL.cpp" />
<ClCompile Include="..\..\src\States.cpp" />
<ClCompile Include="..\..\src\STLReader.cpp" />
<ClCompile Include="..\..\src\Update.cpp" />
<ClCompile Include="..\..\src\Warning.cpp" />
<ClCompile Include="..\..\tests\deformation-gradient\testDeformationGradient.cpp">
Expand Down Expand Up @@ -201,6 +202,7 @@
<ClInclude Include="..\..\inc\Mesh\Mesh.h" />
<ClInclude Include="..\..\inc\Mesh\Node.h" />
<ClInclude Include="..\..\inc\Mesh\NodeMixture.h" />
<ClInclude Include="..\..\inc\Mesh\STLReader.h" />
<ClInclude Include="..\..\inc\Model.h" />
<ClInclude Include="..\..\inc\MPM.h" />
<ClInclude Include="..\..\inc\Output.h" />
Expand Down
2 changes: 2 additions & 0 deletions build/msbuild/MPM-Geomechanics.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Filter>tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\BodySphere.cpp" />
<ClCompile Include="..\..\src\STLReader.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\inc\Body\Body.h" />
Expand Down Expand Up @@ -77,6 +78,7 @@
<ClInclude Include="..\..\inc\Update.h" />
<ClInclude Include="..\..\inc\Warning.h" />
<ClInclude Include="..\..\inc\Body\BodySphere.h" />
<ClInclude Include="..\..\inc\Mesh\STLReader.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="tests">
Expand Down
2 changes: 1 addition & 1 deletion inc/Mesh/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Eigen::Vector3d;

/// \class Node
/// \brief Represents a mesh node.
/// \brief Represents a mesh node
class Node {

public:
Expand Down
17 changes: 15 additions & 2 deletions inc/Mesh/STLReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ using namespace Eigen;
#include <string>
#include <vector>

/// @brief Struct representing a triangle
struct Triangle {
Vector3d normal;
Vector3d v1, v2, v3;
Vector3f normal;
Vector3f v1, v2, v3;
};

/// @brief Class to read STL files
class STLReader {

public:
/// @brief Read the STL file
bool read(const std::string& filename);

/// @brief Get the triangles of the STL mesh
/// @return Vector containing the triangles
const std::vector<Triangle>& getTriangles() const;

private:

/// @brief Vector containing the triangles
std::vector<Triangle> triangles;

/// @brief Read the ASCII STL file
bool readASCII(std::ifstream& file);

/// @brief Read the binary STL file
bool readBinary(std::ifstream& file);
};

Expand Down
2 changes: 1 addition & 1 deletion src/STLReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool STLReader::readASCII(std::ifstream& file) {
Triangle triangle;
ss >> word >> triangle.normal.x() >> triangle.normal.y() >> triangle.normal.z();

// Leer los vértices
// read vertex coordinates
std::getline(file, line); // outer loop
std::getline(file, line);
std::sscanf(line.c_str(), " vertex %f %f %f", &triangle.v1.x(), &triangle.v1.y(), &triangle.v1.z());
Expand Down

0 comments on commit 22634ad

Please sign in to comment.