-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add Support for loading mesh files
- Loading branch information
1 parent
152fc3b
commit 486a8d1
Showing
5 changed files
with
98 additions
and
15 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
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,24 @@ | ||
#include "Mesh.hpp" | ||
#include <vtkSTLReader.h> | ||
#include <vtkSTLWriter.h> | ||
|
||
Mesh::Mesh(const std::string& filename) { | ||
vtkSTLReader* reader = vtkSTLReader::New(); | ||
reader->SetFileName(filename.c_str()); | ||
reader->Update(); | ||
this->polyData = reader->GetOutput(); | ||
reader->Delete(); | ||
} | ||
|
||
Mesh::Mesh(const Mesh& other) { | ||
this->polyData = vtkPolyData::New(); | ||
this->polyData->DeepCopy(other.polyData); | ||
} | ||
|
||
void Mesh::Write(const std::string& filename) const { | ||
vtkSTLWriter* writer = vtkSTLWriter::New(); | ||
writer->SetFileName(filename.c_str()); | ||
writer->SetInputData(this->polyData); | ||
writer->Write(); | ||
writer->Delete(); | ||
} |
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,17 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vtkPolyData.h> | ||
|
||
class Mesh { | ||
public: | ||
Mesh(const std::string& filename); | ||
Mesh(const Mesh&); | ||
|
||
vtkPolyData* GetPolyData() const { return this->polyData; } | ||
|
||
void Write(const std::string& filename) const; | ||
|
||
private: | ||
|
||
vtkPolyData* polyData; | ||
}; |
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
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