New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assimp support and GridIn::read_assimp. #5095
Conversation
13237cf
to
0d1633e
Compare
looking forward to that, i used Blender some 10 years ago as a 3dmax like rendering program. |
* the given index will be extracted, otherwise all meshes which are | ||
* present in the file will be used to generate the Triangulation. | ||
* | ||
* This function can only be used to read two-dimensional meshes (possibly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if .obj
supports volume information... so far I could only make it work with surface one. I know it's a pity, but there is a lot of BEM and shell models that would benefit from this anyway. :)
include/deal.II/grid/grid_in.h
Outdated
* | ||
* This function can only be used to read two-dimensional meshes (possibly | ||
* embedded in three dimensions), as this is the only format supported | ||
* by the supported graphical formats. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported by the supported
maybe reword
include/deal.II/grid/grid_in.h
Outdated
* `ignore_unsupported_element_types`, all the other element types are simply | ||
* ignored by this algorithm. If your mesh contains a mixture of triangles | ||
* and quadrilaterals, for example, only the quadrilaterals will be | ||
* extracted. Careful that your mesh may not make any sense if you are mixing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe: Careful that Your mesh...
/run_tests |
/run-tests (with a dash) |
include/deal.II/grid/grid_in.h
Outdated
* @ref GlossBoundaryIndicator "this" | ||
* glossary entry for more information). | ||
* boundary ids to cells or faces (see @ref GlossMaterialId "this" and @ref | ||
* GlossBoundaryIndicator "this" glossary entry for more information). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you undo the change in formatting?
include/deal.II/grid/grid_in.h
Outdated
* `ignore_unsupported_element_types`, all the other element types are simply | ||
* ignored by this algorithm. If your mesh contains a mixture of triangles | ||
* and quadrilaterals, for example, only the quadrilaterals will be | ||
* extracted. Your mesh may not make any sense if you are mixing compatible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid confusing between the use of "your mesh" in this sentence and the one in the previous sentence, how about writing "The resulting mesh (as represented in the Triangulation object) may not make ..." in the second sentence?
source/grid/grid_in.cc
Outdated
DEAL_II_ENABLE_EXTRA_DIAGNOSTICS | ||
|
||
#undef AI_CONFIG_PP_RVC_FLAGS | ||
#define AI_CONFIG_PP_RVC_FLAGS \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be done with a local variable in the function that uses it, instead of a global preprocessor define?
source/grid/grid_in.cc
Outdated
// Only good for surface grids. | ||
AssertThrow(dim<3, ExcImpossibleInDim(dim)); | ||
|
||
// Create an istance of the Importer class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> instance
source/grid/grid_in.cc
Outdated
Assimp::Importer importer; | ||
|
||
// And have it read the given file with some postprocessing | ||
const aiScene *scene = importer.ReadFile( filename.c_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you creating a memory leak here? Or is the memory managed by the importer object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is managed by the importer object:
Create an object of this class and call
ReadFile()
to import a file. If the import succeeds, the function returns a pointer to the imported data. The data remains property of the object, it is intended to be accessed read-only. The imported data will be destroyed along with the Importer object. If the import fails, ReadFile() returns a NULL pointer. In this case you can retrieve a human-readable error description be calling GetErrorString(). You can call ReadFile() multiple times with a single Importer instance. Actually, constructing Importer objects involves quite many allocations and may take some time, so it's better to reuse them as often as possible.
source/grid/grid_in.cc
Outdated
std::stringstream s; | ||
s << "Incompatible mesh " << m | ||
<< "/" << scene->mNumMeshes; | ||
AssertThrow(ignore_unsupported_types, ExcMessage(s.str())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
source/grid/grid_in.cc
Outdated
<< m << " has " << mFaces[i].mNumIndices | ||
<< " vertices. We expected only " | ||
<< GeometryInfo<dim>::vertices_per_cell; | ||
AssertThrow(ignore_unsupported_types, ExcMessage(s.str())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
source/grid/grid_in.cc
Outdated
} | ||
cells.resize(valid_cell); | ||
|
||
// The vertices are added all at once. Cells are check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> checked
source/grid/grid_in.cc
Outdated
"functions, instead.")); | ||
return; | ||
|
||
case tecplot: | ||
read_tecplot (in); | ||
return; | ||
|
||
case assimp: | ||
Assert(false, ExcMessage("There is no read_assimp(istream &) function. " | ||
"Use the read_netcdf)(string &filename, ...) " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> read_assimp
source/grid/grid_in.cc
Outdated
@@ -2820,14 +3000,20 @@ void GridIn<dim, spacedim>::read (std::istream &in, | |||
|
|||
case netcdf: | |||
Assert(false, ExcMessage("There is no read_netcdf(istream &) function. " | |||
"Use the read(_netcdf)(string &filename) " | |||
"Use the read_netcdf)(string &filename) " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the stray closing parenthesis
ping @bangerth |
This new additional external dependency also still needs an entry in readme.html. Can you please put that on your list as well? |
@luca-heltai btw, the up-to-date homepage is http://www.assimp.org |
PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib | ||
) | ||
|
||
SET(ASSIMP_INC "${ASSIMP_DIR}/include") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luca-heltai The include directory does not need to be ${ASSIMP_DIR}/include
. I will make a pull request (later today) to clean up this file.
Added support for the Open Asset Library (http://assimp.sourceforge.net/).
This can be used by invoking the (new)
GridIn::read_assimp()
function, that translates one of the graphical formats supported byAssimp
into adeal.II
compatible grid.The most reliable format so far is the Wavefront
.obj
format, to which most opensource graphical softwares can export to (Blender, for example, can http://www.blender.org).As soon as I find the time, I'll make a video tutorial using Blender to create a complex
Triangulation<2,3>
grid that exploits some of the (many) functionalities of Blender.