Adding SketchUp IO tests for SketchUp 2017 SKD

parent 8532b37d
cmake_minimum_required( VERSION 2.8 )
project( ITAGeoSketchUpTest )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITAGeo REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITABase REQUIRED )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaBase VistaMath )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC )
endif( )
if( ITA_GEOMETRICAL_ACOUSTICS_BUILD_STATIC )
add_definitions( -DITA_GEO_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/SketchUp" )
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/SketchUp" )
/*
* ----------------------------------------------------------------
*
* ITA geometrical acoustics
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#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( "SolidCube2017.skp" );
assert( oInFile.Exists() );
VistaFileSystemFile oOutFile( "SolidCube2017_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;
}
/*
* ----------------------------------------------------------------
*
* 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(); // why is a pont-in-polygon test in here? @todo move
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 = "SolidCube2017.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("SolidCube2017_out.skp");
oModel.Load("SolidCube2017_out.skp");
oModel.Store("SolidCube2017_out.off");*/
CITAGeoModel model;
model.Load( "../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( "SolidCube2017Store.skp" );
/*test writer
if (oModel.SaveSUModel("SolidCube2017.skp"))
cout << "Sucessfully wrote SolidCube2017.skp" << endl;
if (oModel.LoadSUModel("SolidCube2017.skp"))
cout << "Sucessfully loaded SolidCube2017.skp" << endl;
if (oModel.SaveSUModel("SolidCube2017.off"))
cout << "Sucessfully wrote SolidCube2017.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;
}
B໿SketchUp Model௿{15.0.9350}辽ꁝ蓛䌧림ᄔÿÀ嗿￿ 噃牥楳湯慍ー￾䌉䄀爀挀䌀甀爀瘀攀̀＀￾䌊䄀琀琀爀椀戀甀琀攀＀￾䌓䄀琀琀爀椀戀甀琀攀䌀漀渀琀愀椀渀攀爀＀￾䌏䄀琀琀爀椀戀甀琀攀一愀洀攀搀Ā＀￾䌐䈀愀挀欀最爀漀甀渀搀䤀洀愀最攀਀＀￾䌇䌀愀洀攀爀愀Ԁ＀￾䌊䌀漀洀瀀漀渀攀渀琀଀＀￾䌒䌀漀洀瀀漀渀攀渀琀䈀攀栀愀瘀椀漀爀Ԁ＀￾䌔䌀漀洀瀀漀渀攀渀琀䐀攀昀椀渀椀琀椀漀渀਀＀￾䌒䌀漀洀瀀漀渀攀渀琀䤀渀猀琀愀渀挀攀Ԁ＀￾䌕䌀漀渀猀琀爀甀挀琀椀漀渀䜀攀漀洀攀琀爀礀＀￾䌑䌀漀渀猀琀爀甀挀琀椀漀渀䰀椀渀攀Ā＀￾䌒䌀漀渀猀琀爀甀挀琀椀漀渀倀漀椀渀琀＀￾䌆䌀甀爀瘀攀Ѐ＀￾䌏䐀攀昀椀渀椀琀椀漀渀䰀椀猀琀＀￾䌄䐀椀戀̀＀￾䌊䐀椀洀攀渀猀椀漀渀Ā＀￾䌐䐀椀洀攀渀猀椀漀渀䰀椀渀攀愀爀؀＀￾䌐䐀椀洀攀渀猀椀漀渀刀愀搀椀愀氀Ȁ＀￾䌏䐀椀洀攀渀猀椀漀渀匀琀礀氀攀Ѐ＀￾䌏䐀爀愀眀椀渀最䔀氀攀洀攀渀琀ऀ＀￾䌅䔀搀最攀Ȁ＀￾䌈䔀搀最攀唀猀攀Ā＀￾䌇䔀渀琀椀琀礀̀＀￾䌅䘀愀挀攀̀＀￾䌒䘀愀挀攀吀攀砀琀甀爀攀䌀漀漀爀搀猀Ѐ＀￾䌌䘀漀渀琀䴀愀渀愀最攀爀＀￾䌆䜀爀漀甀瀀Ā＀￾䌆䤀洀愀最攀Ā＀￾䌆䰀愀礀攀爀Ȁ＀￾䌍䰀愀礀攀爀䴀愀渀愀最攀爀Ѐ＀￾䌅䰀漀漀瀀Ā＀￾䌉䴀愀琀攀爀椀愀氀ఀ＀￾䌐䴀愀琀攀爀椀愀氀䴀愀渀愀最攀爀Ѐ＀￾䌉倀愀最攀䰀椀猀琀Ā＀￾䌋倀漀氀礀氀椀渀攀㌀搀＀￾䌍刀攀氀愀琀椀漀渀猀栀椀瀀＀￾䌐刀攀氀愀琀椀漀渀猀栀椀瀀䴀愀瀀＀￾䌑刀攀渀搀攀爀椀渀最伀瀀琀椀漀渀猀␀＀￾䌋匀挀栀攀洀愀䘀椀氀攀Ā＀￾䌑匀挀栀攀洀愀䘀椀氀琀攀爀䘀椀氀攀＀￾䌎匀挀栀攀洀愀娀椀瀀䘀椀氀攀Ā＀￾䌍匀攀挀琀椀漀渀倀氀愀渀攀Ȁ＀￾䌋匀栀愀搀漀眀䤀渀昀漀܀＀￾䌇匀欀䘀漀渀琀Ā＀￾䌉匀欀攀琀挀栀䌀匀＀￾䌎匀欀攀琀挀栀唀瀀䴀漀搀攀氀᠀＀￾䌍匀欀攀琀挀栀唀瀀倀愀最攀Ā＀￾䌉匀欀瀀匀琀礀氀攀Ā＀￾䌐匀欀瀀匀琀礀氀攀䴀愀渀愀最攀爀Ȁ＀￾䌅吀攀砀琀ऀ＀￾䌊吀攀砀琀匀琀礀氀攀Ԁ＀￾䌈吀攀砀琀甀爀攀؀＀￾䌊吀栀甀洀戀渀愀椀氀Ā＀￾䌇嘀攀爀琀攀砀＀￾䌉嘀椀攀眀倀愀最攀ఀ＀￾䌊圀愀琀攀爀洀愀爀欀Ā＀￾䌑圀愀琀攀爀洀愀爀欀䴀愀渀愀最攀爀Ȁ＀￾䔒渀搀ⴀ伀昀ⴀ嘀攀爀猀椀漀渀ⴀ䴀愀瀀Ā뀀؀＀ϿЀ䌀楄Ѣ 褀乐േᨊ B໿SketchUp Model௿{15.0.9350}辽ꁝ蓛䌧림ᄔÿÀ嗿￿ 噃牥楳湯慍ー￾䌉䄀爀挀䌀甀爀瘀攀̀＀￾䌊䄀琀琀爀椀戀甀琀攀＀￾䌓䄀琀琀爀椀戀甀琀攀䌀漀渀琀愀椀渀攀爀＀￾䌏䄀琀琀爀椀戀甀琀攀一愀洀攀搀Ā＀￾䌐䈀愀挀欀最爀漀甀渀搀䤀洀愀最攀਀＀￾䌇䌀愀洀攀爀愀Ԁ＀￾䌊䌀漀洀瀀漀渀攀渀琀଀＀￾䌒䌀漀洀瀀漀渀攀渀琀䈀攀栀愀瘀椀漀爀Ԁ＀￾䌔䌀漀洀瀀漀渀攀渀琀䐀攀昀椀渀椀琀椀漀渀਀＀￾䌒䌀漀洀瀀漀渀攀渀琀䤀渀猀琀愀渀挀攀Ԁ＀￾䌕䌀漀渀猀琀爀甀挀琀椀漀渀䜀攀漀洀攀琀爀礀＀￾䌑䌀漀渀猀琀爀甀挀琀椀漀渀䰀椀渀攀Ā＀￾䌒䌀漀渀猀琀爀甀挀琀椀漀渀倀漀椀渀琀＀￾䌆䌀甀爀瘀攀Ѐ＀￾䌏䐀攀昀椀渀椀琀椀漀渀䰀椀猀琀＀￾䌄䐀椀戀̀＀￾䌊䐀椀洀攀渀猀椀漀渀Ā＀￾䌐䐀椀洀攀渀猀椀漀渀䰀椀渀攀愀爀؀＀￾䌐䐀椀洀攀渀猀椀漀渀刀愀搀椀愀氀Ȁ＀￾䌏䐀椀洀攀渀猀椀漀渀匀琀礀氀攀Ѐ＀￾䌏䐀爀愀眀椀渀最䔀氀攀洀攀渀琀ऀ＀￾䌅䔀搀最攀Ȁ＀￾䌈䔀搀最攀唀猀攀Ā＀￾䌇䔀渀琀椀琀礀̀＀￾䌅䘀愀挀攀̀＀￾䌒䘀愀挀攀吀攀砀琀甀爀攀䌀漀漀爀搀猀Ѐ＀￾䌌䘀漀渀琀䴀愀渀愀最攀爀＀￾䌆䜀爀漀甀瀀Ā＀￾䌆䤀洀愀最攀Ā＀￾䌆䰀愀礀攀爀Ȁ＀￾䌍䰀愀礀攀爀䴀愀渀愀最攀爀Ѐ＀￾䌅䰀漀漀瀀Ā＀￾䌉䴀愀琀攀爀椀愀氀ఀ＀￾䌐䴀愀琀攀爀椀愀氀䴀愀渀愀最攀爀Ѐ＀￾䌉倀愀最攀䰀椀猀琀Ā＀￾䌋倀漀氀礀氀椀渀攀㌀搀＀￾䌍刀攀氀愀琀椀漀渀猀栀椀瀀＀￾䌐刀攀氀愀琀椀漀渀猀栀椀瀀䴀愀瀀＀￾䌑刀攀渀搀攀爀椀渀最伀瀀琀椀漀渀猀␀＀￾䌋匀挀栀攀洀愀䘀椀氀攀Ā＀￾䌑匀挀栀攀洀愀䘀椀氀琀攀爀䘀椀氀攀＀￾䌎匀挀栀攀洀愀娀椀瀀䘀椀氀攀Ā＀￾䌍匀攀挀琀椀漀渀倀氀愀渀攀Ȁ＀￾䌋匀栀愀搀漀眀䤀渀昀漀܀＀￾䌇匀欀䘀漀渀琀Ā＀￾䌉匀欀攀琀挀栀䌀匀＀￾䌎匀欀攀琀挀栀唀瀀䴀漀搀攀氀᠀＀￾䌍匀欀攀琀挀栀唀瀀倀愀最攀Ā＀￾䌉匀欀瀀匀琀礀氀攀Ā＀￾䌐匀欀瀀匀琀礀氀攀䴀愀渀愀最攀爀Ȁ＀￾䌅吀攀砀琀ऀ＀￾䌊吀攀砀琀匀琀礀氀攀Ԁ＀￾䌈吀攀砀琀甀爀攀؀＀￾䌊吀栀甀洀戀渀愀椀氀Ā＀￾䌇嘀攀爀琀攀砀＀￾䌉嘀椀攀眀倀愀最攀ఀ＀￾䌊圀愀琀攀爀洀愀爀欀Ā＀￾䌑圀愀琀攀爀洀愀爀欀䴀愀渀愀最攀爀Ȁ＀￾䔒渀搀ⴀ伀昀ⴀ嘀攀爀猀椀漀渀ⴀ䴀愀瀀Ā뀀؀＀ϿЀ䌀楄Ѣ 褀乐േᨊ
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