Skip to content
Snippets Groups Projects
Commit 406a87ce authored by Karsten Rink's avatar Karsten Rink
Browse files

Merge branch 'master' of github.com:ufz/ogs

parents 1a3b9053 9d3a5057
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ OPTION(OGS_DONT_USE_QT "Disables all Qt specific code." OFF)
OPTION(OGS_BUILD_CLI "Should the OGS simulator be built?" ON)
OPTION(OGS_BUILD_TESTS "Should the test executables be built?" ON)
OPTION(OGS_BUILD_GUI "Should the Data Explorer be built?" OFF)
OPTION(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF)
OPTION(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF)
......@@ -97,6 +98,9 @@ IF(OGS_BUILD_GUI)
ADD_DEFINITIONS(-DOGS_BUILD_GUI)
ADD_SUBDIRECTORY(Gui)
ENDIF() # OGS_BUILD_GUI
IF(OGS_BUILD_UTILS)
ADD_SUBDIRECTORY( Utils/SimpleMeshCreation )
ENDIF() # OGS_BUILD_UTILS
CONFIGURE_FILE (BaseLib/BuildInfo.h.in ${PROJECT_BINARY_DIR}/BaseLib/BuildInfo.h)
CONFIGURE_FILE (BaseLib/Configure.h.in ${PROJECT_BINARY_DIR}/BaseLib/Configure.h)
......@@ -61,7 +61,7 @@ MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(vtkImageData* img,
double* pixVal (new double[incHeight * incWidth]);
bool* visNodes(new bool[incWidth * incHeight]);
int* node_idx_map(new int[incWidth * incHeight]);
for (size_t j = 0; j < incHeight; j++)
{
pixVal[j]=0;
......@@ -83,7 +83,7 @@ MeshLib::Mesh* VtkMeshConverter::convertImgToMesh(vtkImageData* img,
// is current pixel visible
if (nTuple == 2 || nTuple == 4)
visNodes[index] = (colour[nTuple-1] > 0);
else
else
visNodes[index] = true;
node_idx_map[index]=-1;
......@@ -189,7 +189,7 @@ MeshLib::Mesh* VtkMeshConverter::constructMesh(const double* pixVal,
if (set_node)
{
double zValue = (intensity_type == UseIntensityAs::ELEVATION) ? pixVal[index] : 0.0;
double zValue = (intensity_type == UseIntensityAs::ELEVATION) ? pixVal[index] : origin[2];
MeshLib::Node* node (new MeshLib::Node(x_offset + (scalingFactor * j), y_offset + (scalingFactor * i), zValue));
nodes.push_back(node);
node_idx_map[index] = node_idx_count;
......
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/BaseLib
${CMAKE_SOURCE_DIR}/FileIO
${CMAKE_SOURCE_DIR}/FileIO/Legacy
${CMAKE_SOURCE_DIR}/MeshLib
${CMAKE_SOURCE_DIR}/Gui/VtkVis
)
INCLUDE( ${VTK_USE_FILE} )
# Create executables
IF(QT4_FOUND)
ADD_EXECUTABLE( generateStructuredQuadMesh generateStructuredQuadMesh.cpp )
SET_TARGET_PROPERTIES( generateStructuredQuadMesh PROPERTIES FOLDER Utils)
TARGET_LINK_LIBRARIES( generateStructuredQuadMesh
MeshLib
FileIO
VtkVis
vtkRendering
${QT_LIBRARIES}
)
ENDIF() # QT4_FOUND
/**
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.net/LICENSE.txt
*
* \file generateStructuredQuadMesh.cpp
*
* Created on Sep 21, 2012 by Thomas Fischer
*/
// BaseLib
#include "tclap/CmdLine.h"
// FileIO/Legacy
#include "MeshIO.h"
// Gui/VtkVis
#include "VtkMeshConverter.h"
// MeshLib
#include "Mesh.h"
int main (int argc, char* argv[])
{
TCLAP::CmdLine cmd("Simple mesh creator for unstructured meshes", ' ', "0.1");
TCLAP::ValueArg<std::string> mesh_arg("m", "mesh", "the mesh is stored to this file", true, "test.msh", "filename");
cmd.add( mesh_arg );
TCLAP::ValueArg<unsigned> width_arg("c","columns","the number of columns of the structured mesh", true, 1000, "number of cols");
cmd.add( width_arg );
TCLAP::ValueArg<unsigned> height_arg("r","rows","the number of rows of the structured mesh", true, 1000, "number of rows");
cmd.add( height_arg );
TCLAP::ValueArg<double> edge_length_arg("e","edge-length","the size of the edge length", false, 1, "edge length");
cmd.add( edge_length_arg );
TCLAP::ValueArg<double> origin_x_arg("x","origin-x","x coordinate of the origin of the mesh", false, 0.0, "x coords");
cmd.add( origin_x_arg );
TCLAP::ValueArg<double> origin_y_arg("y","origin-y","y coordinate of the origin of the mesh", false, 0.0, "y coords");
cmd.add( origin_y_arg );
TCLAP::ValueArg<double> origin_z_arg("z","origin-z","z coordinate of the origin of the mesh", false, 0.0, "z coords");
cmd.add( origin_z_arg );
cmd.parse( argc, argv );
// thanks to KR for this algorithm
unsigned height(height_arg.getValue()), width(width_arg.getValue());
double edge_length(edge_length_arg.getValue());
const unsigned size (height*width);
double* values (new double[size]);
const double origin[3] = {origin_x_arg.getValue() + edge_length/2, origin_y_arg.getValue() + edge_length/2, origin_z_arg.getValue()};
for (unsigned i=0; i<size; ++i) values[i]=0;
MeshLib::Mesh* mesh(VtkMeshConverter::convertImgToMesh(values, origin, height, width, edge_length, MshElemType::QUAD, UseIntensityAs::MATERIAL));
delete [] values;
FileIO::MeshIO mesh_writer;
mesh_writer.setMesh(mesh);
mesh_writer.setPrecision(12);
mesh_writer.writeToFile(mesh_arg.getValue());
delete mesh;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment