Switching to SketchUp 2017 API and moving some tests

parent 082801ed
......@@ -131,6 +131,10 @@ if( ITA_GEOMETRICAL_ACOUSTICS_WITH_TESTS )
add_subdirectory( "tests" )
if( ITA_GEO_WITH_SKETCHUP_IO )
add_subdirectory( "tests/sketchup" )
endif( )
if( ITA_GEO_WITH_CITYGML_SUPPORT )
add_subdirectory( "tests/citygml" )
endif( )
......
......@@ -6,19 +6,19 @@
#include <ITAException.h>
// Sketchup includes
#include <slapi/model/component_definition.h>
#include <slapi/model/component_instance.h>
#include <slapi/model/drawing_element.h>
#include <slapi/model/edge.h>
#include <slapi/model/entities.h>
#include <slapi/model/model.h>
#include <slapi/model/face.h>
#include <slapi/model/group.h>
#include <slapi/model/vertex.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/transformation.h>
#include <slapi/unicodestring.h>
#include <SketchUpAPI/model/component_definition.h>
#include <SketchUpAPI/model/component_instance.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <SketchUpAPI/model/edge.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/group.h>
#include <SketchUpAPI/model/vertex.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/transformation.h>
#include <SketchUpAPI/unicodestring.h>
// Vista includes
#include <VistaMath/VistaGeometries.h>
......
......@@ -6,21 +6,21 @@
#include <ITAException.h>
// Sketchup includes
#include <slapi/model/component_definition.h>
#include <slapi/model/component_instance.h>
#include <slapi/model/drawing_element.h>
#include <slapi/model/edge.h>
#include <slapi/model/entities.h>
#include <slapi/model/face.h>
#include <slapi/model/geometry_input.h>
#include <slapi/model/group.h>
#include <slapi/model/model.h>
#include <slapi/model/material.h>
#include <slapi/model/vertex.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/transformation.h>
#include <slapi/unicodestring.h>
#include <SketchUpAPI/model/component_definition.h>
#include <SketchUpAPI/model/component_instance.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <SketchUpAPI/model/edge.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/geometry_input.h>
#include <SketchUpAPI/model/group.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/material.h>
#include <SketchUpAPI/model/vertex.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/transformation.h>
#include <SketchUpAPI/unicodestring.h>
// Vista includes
#include <VistaTools/VistaFileSystemFile.h>
......
......@@ -28,7 +28,7 @@
// OpenMesh includes
#include <OpenMesh/Core/IO/writer/BaseWriter.hh>
#include <slapi/model/model.h>
#include <SketchUpAPI/model/model.h>
//! SketchUp generic writer class (file or stream output)
/**
......
......@@ -15,23 +15,23 @@
#include <VistaTools/VistaFileSystemFile.h>
// Sketchup includes
#include <slapi/model/component_definition.h>
#include <slapi/model/component_instance.h>
#include <slapi/model/drawing_element.h>
#include <slapi/model/edge.h>
#include <slapi/model/entities.h>
#include <slapi/model/face.h>
#include <slapi/model/group.h>
#include <slapi/model/material.h>
#include <slapi/model/model.h>
#include <slapi/model/layer.h>
#include <slapi/model/rendering_options.h>
#include <slapi/model/texture.h>
#include <slapi/model/vertex.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/transformation.h>
#include <slapi/unicodestring.h>
#include <SketchUpAPI/model/component_definition.h>
#include <SketchUpAPI/model/component_instance.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <SketchUpAPI/model/edge.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/group.h>
#include <SketchUpAPI/model/material.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/layer.h>
#include <SketchUpAPI/model/rendering_options.h>
#include <SketchUpAPI/model/texture.h>
#include <SketchUpAPI/model/vertex.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/transformation.h>
#include <SketchUpAPI/unicodestring.h>
// OpenMesh includes
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
......
......@@ -24,9 +24,9 @@
#include <VistaBase/VistaTransformMatrix.h>
// Sketchup includes
#include <slapi/model/model.h>
#include <slapi/geometry.h>
#include <slapi/transformation.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/transformation.h>
// OpenMesh includes
#include <OpenMesh/Core/IO/MeshIO.hh>
......
......@@ -24,8 +24,8 @@
#include <VistaBase/VistaTransformMatrix.h>
// Sketchup includes
#include <slapi/slapi.h>
#include <slapi/unicodestring.h>
#include <SketchUpAPI/slapi.h>
#include <SketchUpAPI/unicodestring.h>
// OpenMesh includes
#include <OpenMesh/Core/IO/MeshIO.hh>
......
......@@ -22,9 +22,9 @@
#include <ITAGeoAcousticMaterial.h>
// Sketchup includes
#include <slapi/model/face.h>
#include <slapi/model/material.h>
#include <slapi/model/texture.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/material.h>
#include <SketchUpAPI/model/texture.h>
// OpenMesh includes
#include <OpenMesh/Core/IO/MeshIO.hh>
......
......@@ -8,19 +8,19 @@
#include <ITAException.h>
// Sketchup includes
#include <slapi/model/component_definition.h>
#include <slapi/model/component_instance.h>
#include <slapi/model/drawing_element.h>
#include <slapi/model/edge.h>
#include <slapi/model/face.h>
#include <slapi/model/group.h>
#include <slapi/model/material.h>
#include <slapi/model/model.h>
#include <slapi/model/texture.h>
#include <slapi/model/vertex.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/transformation.h>
#include <SketchUpAPI/model/component_definition.h>
#include <SketchUpAPI/model/component_instance.h>
#include <SketchUpAPI/model/drawing_element.h>
#include <SketchUpAPI/model/edge.h>
#include <SketchUpAPI/model/face.h>
#include <SketchUpAPI/model/group.h>
#include <SketchUpAPI/model/material.h>
#include <SketchUpAPI/model/model.h>
#include <SketchUpAPI/model/texture.h>
#include <SketchUpAPI/model/vertex.h>
#include <SketchUpAPI/geometry.h>
#include <SketchUpAPI/initialize.h>
#include <SketchUpAPI/transformation.h>
SUResult SUEntitiesToITAMesh( SUEntitiesRef rEntities, CITAMesh* pMesh, bool bExplodeGroups, std::vector< SUTransformation >& vtTransform )
{
......
......@@ -20,9 +20,9 @@
#define INCLUDE_WATCHER_ITA_GEO_SU_MESH_CONVERSIONS
// Sketchup includes
#include <slapi/model/entities.h>
#include <slapi/model/layer.h>
#include <slapi/transformation.h>
#include <SketchUpAPI/model/entities.h>
#include <SketchUpAPI/model/layer.h>
#include <SketchUpAPI/transformation.h>
// OpenMesh includes
#include <OpenMesh/Core/IO/MeshIO.hh>
......
......@@ -5,7 +5,7 @@
#include <ITAException.h>
// SketchUp includes
#include <slapi/model/model.h>
#include <SketchUpAPI/model/model.h>
void CITAGeoSketchUpIO::SetSketchUpVersion( int iVersion )
{
......
......@@ -17,16 +17,6 @@ if( ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC )
endif( )
add_executable( SketchUpLoaderTest SketchUpLoaderTest.cpp )
target_link_libraries( SketchUpLoaderTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( SketchUpLoaderTest )
vista_install( SketchUpLoaderTest )
vista_create_default_info_file( SketchUpLoaderTest )
set_property( TARGET SketchUpLoaderTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAGeo" )
add_executable( PointCloudExporter PointCloudExporter.cpp )
target_link_libraries( PointCloudExporter ${VISTA_USE_PACKAGE_LIBRARIES} )
......@@ -37,16 +27,6 @@ vista_create_default_info_file( PointCloudExporter )
set_property( TARGET PointCloudExporter PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAGeo" )
add_executable( ITAGeoHalfedgeSketchUpIOTest ITAGeoHalfedgeSketchUpIOTest.cpp )
target_link_libraries( ITAGeoHalfedgeSketchUpIOTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ITAGeoHalfedgeSketchUpIOTest )
vista_install( ITAGeoHalfedgeSketchUpIOTest )
vista_create_default_info_file( ITAGeoHalfedgeSketchUpIOTest )
set_property( TARGET ITAGeoHalfedgeSketchUpIOTest PROPERTY FOLDER "ITAGeometricalAcoustics/Tests/ITAGeo" )
add_executable( ITAGeoHalfedgeMeshModelTest ITAGeoHalfedgeMeshModelTest.cpp )
target_link_libraries( ITAGeoHalfedgeMeshModelTest ${VISTA_USE_PACKAGE_LIBRARIES} )
......
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: ITAGeoHalfedgeSketchupIOTest.h 2057 2011-10-24 20:08:48Z stienen $
#include <ITAGeoHalfedgeMeshModel.h>
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <VistaTools/VistaFileSystemDirectory.h>
#include <VistaTools/VistaFileSystemFile.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <assert.h>
using namespace std;
typedef OpenMesh::PolyMesh_ArrayKernelT<> CITAMesh;
int main( int, char** )
{
VistaFileSystemFile oInFile( "../../../../ITAGeo/tests/SolidCube.skp" );
assert( oInFile.Exists() );
VistaFileSystemFile oOutFile( "../../../../ITAGeo/tests/SolidCube_out.skp" );
if( oOutFile.Exists() )
cout << "[Warning] Output file exists, will overwrite." << endl;
VistaFileSystemDirectory oParentDir( oOutFile.GetParentDirectory() );
assert( oParentDir.Exists() );
ITAStopWatch sw;
CITAMesh oMesh;
bool bReadOK = false, bWriteOK = false;
if( OpenMesh::IO::IOManager().can_read( "skp" ) )
{
sw.start();
bReadOK = OpenMesh::IO::read_mesh( oMesh, oInFile.GetName() );
cout << "Reading took " << sw.stop() << endl;
if( bReadOK )
cout << "Successfully read mesh from file " << oInFile.GetLocalName() << endl;
else
cerr << "[Error] Could not read mesh from file " << oInFile.GetLocalName() << endl;
}
else
cerr << "[Error] IOManager can not read extension 'skp'" << endl;
if( OpenMesh::IO::IOManager().can_write( "skp" ) )
{
sw.start();
bWriteOK = OpenMesh::IO::write_mesh( oMesh, oOutFile.GetName() );
cout << "Writing took " << sw.stop() << endl;
if( bWriteOK )
cout << "Successfully written mesh to file " << oOutFile.GetLocalName() << endl;
else
cerr << "[Error] Could not write mesh to file " << oOutFile.GetLocalName() << endl;
}
else
cerr << "[Error] IOManager can not write extension 'skp'" << endl;
return 0;
}
#include <ITAGeoHalfedgeMeshModel.h>
#include <ITAGeoModel.h>
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h>
#include <VistaTools/VistaFileSystemFile.h>
#include <iostream>
#include <assert.h>
using namespace std;
void piptest();
void load_sketchup_file();
int main( int argc, char** argv )
{
if( false )
piptest();
if( true )
load_sketchup_file();
cout << "Type any key + enter: ";
int iIn;
cin >> iIn;
return 0;
}
void load_sketchup_file()
{
//string sSKPFilePath = correctPath( "D:/ITA/Sciebo/Daten/Models/Pintoy/PintoyCar.skp" );
string sSKPFilePath = "../../../../ITAGeo/tests/SolidCube.skp";
VistaFileSystemFile oFile(sSKPFilePath);
assert( oFile.Exists() );
CITAGeoHalfedgeMeshModel oModel;
if( oModel.Load( sSKPFilePath ) )
cout << "Sucessfully loaded file '" << sSKPFilePath << "' as an halfedge model" << endl;
//write model to .skp
/*oModel.Store("../../../../ITAGeo/tests/SolidCube_out.skp");
oModel.Load("../../../../ITAGeo/tests/SolidCube_out.skp");
oModel.Store("../../../../ITAGeo/tests/SolidCube_out.off");*/
CITAGeoModel model;
model.Load("../../../../ITAGeo/tests/CompTest.skp");
int a = 1;
/*test writer
if (oModel.SaveSUModel("../../../../ITAGeo/tests/model.skp"))
cout << "Sucessfully wrote model.skp" << endl;
if (oModel.LoadSUModel("../../../../ITAGeo/tests/model.skp"))
cout << "Sucessfully loaded model.skp" << endl;
if (oModel.SaveSUModel("../../../../ITAGeo/tests/model.off"))
cout << "Sucessfully wrote model.off" << endl;
//oModel.GetNumFaces();*/
return;
}
void piptest()
{
ITAStopWatch sw;
std::vector< VistaVector3D* > vVertices;
vVertices.push_back( new VistaVector3D( 9.0f, 10.0f, -21.0f ) );
vVertices.push_back( new VistaVector3D( -10.0f, 11.0f, -20.0f ) );
vVertices.push_back( new VistaVector3D( 0.2f, -5, -22.0f ) );
VistaPolygon polygon( vVertices );
VistaVector3D vDirection( 0.3f, 0.7f, -9.4f, 1.0f );
vDirection.Normalize();
VistaRay vRay1( VistaVector3D(), vDirection );
VistaRay vRay2( VistaVector3D(), -vDirection );
VistaVector3D vContactPoint1, vContactPoint2;
float fScalarProduct;
sw.start();
bool bRet1 = vRay1.IntersectionTriangle( *(vVertices[0]), *(vVertices[1]), *(vVertices[2]), vContactPoint1 );
cout << "Intersection test: " << std::to_string( long double( sw.stop() ) ) << endl;
fScalarProduct = vRay1.GetDir() * polygon.GetUpVector();
bool bRet2 = vRay2.IntersectionTriangle( *(vVertices[0]), *(vVertices[2]), *(vVertices[1]), vContactPoint2 );
fScalarProduct = vRay2.GetDir() * polygon.GetUpVector();
// Extended function returning face normal
float fPenDepths, fBarycentricAB, fBaricentricAC;
VistaVector3D vContactPoint3, vFaceNormal;
sw.start();
bool bRet3 = vRay1.IntersectionTriangle( *(vVertices[0]), *(vVertices[1]), *(vVertices[2]), vContactPoint3, vFaceNormal, fPenDepths, fBarycentricAB, fBaricentricAC );
cout << "Extended intersection test with face normal: " << std::to_string( long double( sw.stop() ) ) << endl;
// Check direction with face culling
fScalarProduct = vFaceNormal * vDirection;
bool bFaceBacksideIntersection = ( fScalarProduct < 0 );
if( bRet3 && !bFaceBacksideIntersection )
cout << "Ray intersection detected." << endl;
else
cout << "No ray intersection detected." << endl;
for( size_t i=0; i<vVertices.size(); i++ )
delete vVertices[i];
return;
}
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2016
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
// $Id: SketchupLoaderTest.cpp 2057 2011-10-24 20:08:48Z stienen $
#include <ITAGeoHalfedgeMeshModel.h>
#include <ITAGeoModel.h>
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <VistaBase/VistaVector3D.h>
#include <VistaMath/VistaGeometries.h>
#include <VistaTools/VistaFileSystemFile.h>
#include <iostream>
#include <assert.h>
using namespace std;
void piptest();
void load_sketchup_file();
int main( int, char** )
{
if( false )
piptest();
if( true )
load_sketchup_file();
cout << "Type any key + enter: ";
int iIn;
cin >> iIn;
return 0;
}
void load_sketchup_file()
{
//string sSKPFilePath = correctPath( "D:/ITA/Sciebo/Daten/Models/Pintoy/PintoyCar.skp" );
string sSKPFilePath = "../../../../ITAGeo/tests/SolidCube.skp";
VistaFileSystemFile oFile(sSKPFilePath);
assert( oFile.Exists() );
//CITAGeoHalfedgeMeshModel oModel;
//if( oModel.Load( sSKPFilePath ) )
// cout << "Sucessfully loaded file '" << sSKPFilePath << "' as an halfedge model" << endl;
//write model to .skp
/*oModel.Store("../../../../ITAGeo/tests/SolidCube_out.skp");
oModel.Load("../../../../ITAGeo/tests/SolidCube_out.skp");
oModel.Store("../../../../ITAGeo/tests/SolidCube_out.off");*/
CITAGeoModel model;
model.Load("../../../../ITAGeo/tests/CompTest.skp");
CITAGeoPropagationPath oPropPath;
oPropPath.resize(4);
oPropPath[ 0 ] = new CITAGeoPropagationAnchor( VistaVector3D((double)0, (double)-10, (double)0));
oPropPath[ 1 ] = new CITAGeoPropagationAnchor( VistaVector3D( ( double ) 0, ( double ) -10, ( double ) 100 ) );
oPropPath[ 2 ] = new CITAGeoPropagationAnchor( VistaVector3D( ( double ) 100, ( double ) -10, ( double ) 100 ) );
oPropPath[ 3 ] = new CITAGeoPropagationAnchor( VistaVector3D( ( double ) 100, ( double ) -10, ( double ) 0 ) );
model.AddPropagationPathVisualization(oPropPath, "test");
model.Store("../../../../ITAGeo/tests/CompTestStore.skp");
/*test writer
if (oModel.SaveSUModel("../../../../ITAGeo/tests/model.skp"))
cout << "Sucessfully wrote model.skp" << endl;
if (oModel.LoadSUModel("../../../../ITAGeo/tests/model.skp"))
cout << "Sucessfully loaded model.skp" << endl;
if (oModel.SaveSUModel("../../../../ITAGeo/tests/model.off"))
cout << "Sucessfully wrote model.off" << endl;
//oModel.GetNumFaces();*/
return;
}
void piptest()
{
ITAStopWatch sw;
std::vector< VistaVector3D* > vVertices;
vVertices.push_back( new VistaVector3D( 9.0f, 10.0f, -21.0f ) );
vVertices.push_back( new VistaVector3D( -10.0f, 11.0f, -20.0f ) );
vVertices.push_back( new VistaVector3D( 0.2f, -5, -22.0f ) );
VistaPolygon polygon( vVertices );
VistaVector3D vDirection( 0.3f, 0.7f, -9.4f, 1.0f );
vDirection.Normalize();
VistaRay vRay1( VistaVector3D(), vDirection );
VistaRay vRay2( VistaVector3D(), -vDirection );
VistaVector3D vContactPoint1, vContactPoint2;
float fScalarProduct;
sw.start();
vRay1.IntersectionTriangle( *(vVertices[0]), *(vVertices[1]), *(vVertices[2]), vContactPoint1 );
cout << "Intersection test: " << std::to_string( long double( sw.stop() ) ) << endl;
fScalarProduct = vRay1.GetDir() * polygon.GetUpVector();
vRay2.IntersectionTriangle( *(vVertices[0]), *(vVertices[2]), *(vVertices[1]), vContactPoint2 );
fScalarProduct = vRay2.GetDir() * polygon.GetUpVector();
// Extended function returning face normal
float fPenDepths, fBarycentricAB, fBaricentricAC;
VistaVector3D vContactPoint3, vFaceNormal;
sw.start();
bool bRet3 = vRay1.IntersectionTriangle( *(vVertices[0]), *(vVertices[1]), *(vVertices[2]), vContactPoint3, vFaceNormal, fPenDepths, fBarycentricAB, fBaricentricAC );
cout << "Extended intersection test with face normal: " << std::to_string( long double( sw.stop() ) ) << endl;
// Check direction with face culling
fScalarProduct = vFaceNormal * vDirection;
bool bFaceBacksideIntersection = ( fScalarProduct < 0 );
if( bRet3 && !bFaceBacksideIntersection )
cout << "Ray intersection detected." << endl;
else
cout << "No ray intersection detected." << endl;
for( size_t i=0; i<vVertices.size(); i++ )
delete vVertices[i];
return;
}
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