Commit 58ef9cfa authored by Dan Lipsa's avatar Dan Lipsa

Add CityGML reader

parent 06bbcedb
......@@ -86,6 +86,9 @@ int vtkContourTriangulator::RequestData(
vtkCellArray *polys = vtkCellArray::New();
output->SetPolys(polys);
output->SetPoints(input->GetPoints());
output->GetPointData()->PassData(input->GetPointData());
polys->Delete();
this->TriangulationError = !vtkContourTriangulator::TriangulateContours(
......
set(Module_SRCS vtkCityGMLReader.cxx)
vtk_module_library(vtkIOCityGML ${Module_SRCS})
# pugixml does not set _INCLUDE_DIRS or _LIBRARIES
if(VTK_USE_SYSTEM_PUGIXML AND NOT pugixml_INCLUDE_DIRS)
find_package(pugixml REQUIRED)
get_target_property(pugixml_INCLUDE_DIRS pugixml INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(pugixml_LIBRARIES pugixml LOCATION)
include_directories(${pugixml_INCLUDE_DIRS})
vtk_module_link_libraries(vtkIOCityGML LINK_PRIVATE ${pugixml_LIBRARIES})
endif()
ExternalData_Expand_Arguments(VTKData _
"DATA{${VTK_TEST_INPUT_DIR}/CityGML/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/CityGML/textures/,REGEX:.*}"
)
vtk_add_test_cxx(vtkIOCityGMLCxxTests tests
TestCityGMLReader.cxx
)
vtk_test_cxx_executable(vtkIOCityGMLCxxTests tests)
/*=========================================================================
Program: Visualization Toolkit
Module: TestCityGMLReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME Test of an RGBA texture on a vtkActor.
// .SECTION Description
// this program tests the CityGML Reader and setting of textures to
// individual datasets of the multiblock tree.
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCityGMLReader.h"
#include "vtkCompositeDataIterator.h"
#include "vtkFieldData.h"
#include "vtkJPEGReader.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyData.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStringArray.h"
#include "vtksys/SystemTools.hxx"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
int TestCityGMLReader(int argc, char *argv[])
{
char* fname =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/CityGML/Part-4-Buildings-V4-one.gml");
std::cout << fname << std::endl;
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(0.5,0.7,0.7);
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renWin);
vtkNew<vtkCityGMLReader> reader;
reader->SetFileName(fname);
reader->Update();
vtkMultiBlockDataSet* mb = reader->GetOutput();
vtkSmartPointer<vtkCompositeDataIterator> it;
for(it.TakeReference(mb->NewIterator()); ! it->IsDoneWithTraversal(); it->GoToNextItem())
{
vtkPolyData* poly = vtkPolyData::SafeDownCast(it->GetCurrentDataObject());
if (poly)
{
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputDataObject(poly);
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
renderer->AddActor(actor);
vtkStringArray* textureField =
vtkStringArray::SafeDownCast(poly->GetFieldData()->GetAbstractArray("texture_uri"));
if (textureField)
{
std::string fnamePath = vtksys::SystemTools::GetFilenamePath(std::string(fname));
const char* textureURI = textureField->GetValue(0);
vtkNew<vtkJPEGReader> JpegReader;
JpegReader->SetFileName((fnamePath + "/" + textureURI).c_str());
JpegReader->Update();
vtkNew<vtkTexture> texture;
texture->SetInputConnection(JpegReader->GetOutputPort());
texture->InterpolateOn();
actor->SetTexture(texture);
}
}
}
renderer->ResetCamera();
renderer->GetActiveCamera()->Azimuth(90);
renderer->GetActiveCamera()->Roll(-90);
renderer->GetActiveCamera()->Zoom(1.5);
renWin->SetSize(400,400);
renWin->Render();
interactor->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage( renWin );
if( retVal == vtkRegressionTester::DO_INTERACTOR)
{
interactor->Start();
}
delete fname;
return !retVal;
}
540c9970f1271d58cbe75a01e83052286b8d5007a7244fd1ea0e7b7582cf8fdd90061ab85d3dcab940fc6c4b8efa138d69a8f20b0781c38ac89e39adad084e2e
vtk_module(vtkIOCityGML
GROUPS
StandAlone
TEST_DEPENDS
vtkTestingCore
vtkRenderingOpenGL2
vtkTestingRendering
vtkInteractionStyle
KIT
vtkIO
DEPENDS
vtkCommonCore
vtkCommonExecutionModel
vtkFiltersGeneral
vtkFiltersModeling
vtkpugixml
PRIVATE_DEPENDS
vtkCommonDataModel
vtksys
)
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCityGMLReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkCityGMLReader
* @brief read CityGML data file
*
*/
#ifndef vtkCityGMLReader_h
#define vtkCityGMLReader_h
#include "vtkIOCityGMLModule.h" // For export macro
#include "vtkMultiBlockDataSetAlgorithm.h"
/**
* @class vtkCityGMLReader
* @brief reads CityGML files
*
* vtkCityGMLReader is a reader for CityGML .gml files. The output is
* a multiblock dataset. We read objects at level of detail (LOD)
* specified (default is 3).
* The leafs of the multiblock dataset (which are polygonal datasets)
* have a field array with one element called "gml_id" which
* coresponds to the gml:id for gml:TriangulatedSurface,
* gml:MultiSurface or gml:CompositeSurface in the CityGML file. If
* the poly dataset has a texture, we specify this with a point array
* called "tcoords" and a field array with one element called
* "texture_uri" containing the path to the texture file. If the poly
* dataset has a app::X3DMaterial we store two fields arrays with 3
* components and 1 tuple: "diffuse_color" and "specular_color" and
* one field array with 1 component and 1 tuple: "transparency".
* Top level children of the multiblock dataset have a field array
* with one element called "element" which contains the CityGML
* element name for example: dem:ReliefFeature, wtr:WaterBody,
* grp::CityObjectGroup (forest), veg:SolitaryVegetationObject,
* brid:Bridge, run:Tunel, tran:Railway, tran:Road, bldg:Building,
* gen:GenericCityObject, luse:LandUse
*/
class VTKIOCITYGML_EXPORT vtkCityGMLReader : public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkCityGMLReader *New();
vtkTypeMacro(vtkCityGMLReader,vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@{
/**
* Specify file name of the CityGML data file to read.
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
//@{
/**
* Specify the level of detail (LOD) to read. Valid values are from 0 (least detailed)
* through 4 (most detailed), default value is 3.
*/
vtkSetClampMacro(LOD, int, 0, 4);
vtkGetMacro(LOD, int);
//@}
//@{
/**
* Certain input files use app:transparency as opacity. Set this field true
* to show that correctly. The default is false.
*/
vtkSetMacro(UseTransparencyAsOpacity, int);
vtkGetMacro(UseTransparencyAsOpacity, int);
vtkBooleanMacro(UseTransparencyAsOpacity, int);
//@}
protected:
vtkCityGMLReader();
~vtkCityGMLReader() override;
int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *) override;
char *FileName;
int LOD;
int UseTransparencyAsOpacity;
private:
vtkCityGMLReader(const vtkCityGMLReader&) = delete;
void operator=(const vtkCityGMLReader&) = delete;
class Implementation;
Implementation* Impl;
};
#endif
08e69c6be6894f317722df457a444dfab44608a1dd331e07b752f63ad1aa9b0cd423986b9dcf0a6919053d6b12687ea08d746f82015a786545df7c5a67363dd4
716bff80cc06102638372feb2da4ec9fb0aa700be09b5e5bd7eef79ccaaa744ba80632216ee2834aad00047c1a58ac5483d3980c61cb787e5272474437c68127
9e033a38f1b0b2261992cb40b92ea4a95f2ae6ee695599458136d880c19e8d5a5197dbeaef1c7fa323d2919c9b861158bc78b6394025953b9b0c9f32e2b4a76d
5dc5960641bc6b57042e036986e1d32e5a87197fd7a2a2dc16321d8346f1d5471211ad391741ca6d0d2587aad0f5b947ca2d20ae6567fd89e19b2863573c4b12
866995c8b6fc74bcb565d20dfd6ab0687d907651d6e6f3a57d295d37fb29fac429efdd9ef729bfd886dd88dc620cdffc9eaf0005b39b1c278851c669584301bc
866995c8b6fc74bcb565d20dfd6ab0687d907651d6e6f3a57d295d37fb29fac429efdd9ef729bfd886dd88dc620cdffc9eaf0005b39b1c278851c669584301bc
3450f6df945c4790c4ef1119b3a2069edbf917dd3c04ab0fd92c356b6041c8cde2f03d4620c078719d83800584c474066c0dfb1efa70f60870e80ff640b17ac1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment