diff --git a/src/basics/CMakeLists.txt b/src/basics/CMakeLists.txt index 476cbdc75b100d91a8659f2292bcd457d7d0b8c9..e10456fbeb7274fd898839e9c26fdd1130f2d42e 100644 --- a/src/basics/CMakeLists.txt +++ b/src/basics/CMakeLists.txt @@ -1,7 +1,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/geometry3d) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/geometry3d/Creator) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/geometry3d/KdTree) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/basics/container) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/basics/memory) @@ -24,7 +23,6 @@ INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) vf_add_library(BUILDTYPE static FOLDER ${CMAKE_CURRENT_LIST_DIR}/geometry3d - ${CMAKE_CURRENT_LIST_DIR}/geometry3d/creator ${CMAKE_CURRENT_LIST_DIR}/geometry3d/KdTree ${CMAKE_CURRENT_LIST_DIR}/basics/container ${CMAKE_CURRENT_LIST_DIR}/basics/memory diff --git a/src/basics/basics/writer/WbWriterAvsASCII.h b/src/basics/basics/writer/WbWriterAvsASCII.h index 8f7f97a759fb4bf9bd414769dcfd7adfbe8858b6..a683ae7a1185c74be9c2b33ce7674eca41f82fef 100644 --- a/src/basics/basics/writer/WbWriterAvsASCII.h +++ b/src/basics/basics/writer/WbWriterAvsASCII.h @@ -12,8 +12,6 @@ class WbWriterAvsASCII : public WbWriter { public: - OBCREATOR_EXT( WbWriterAvsASCII ) - static WbWriterAvsASCII* getInstance() { static WbWriterAvsASCII instance; @@ -71,6 +69,4 @@ public: std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsASCII ,WbWriter>::getInstance()), CAB_WbWriterAvsASCII); - #endif //WBWRITERAVSASCII_H diff --git a/src/basics/basics/writer/WbWriterAvsBinary.h b/src/basics/basics/writer/WbWriterAvsBinary.h index 2ba0e78420012314f2f286f83d12866ee534cee8..8a31c3e9437f22772781442809d035b191e865f6 100644 --- a/src/basics/basics/writer/WbWriterAvsBinary.h +++ b/src/basics/basics/writer/WbWriterAvsBinary.h @@ -12,8 +12,6 @@ class WbWriterAvsBinary : public WbWriter { public: - OBCREATOR_EXT( WbWriterAvsBinary ) - static WbWriterAvsBinary* getInstance() { static WbWriterAvsBinary instance; @@ -69,6 +67,4 @@ public: std::string writeOctsWithNodeData(const std::string& filename, std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector< std::vector<double > >& nodedata); }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterAvsBinary ,WbWriter>::getInstance()), CAB_WbWriterAvsBinary); - #endif //WBWRITERAVSBINARY_H diff --git a/src/basics/basics/writer/WbWriterSunflow.h b/src/basics/basics/writer/WbWriterSunflow.h index a14461b0618557fbef2b2da4b95077b397568f78..726476009f41c4cd8652fc9ae25affb6fdaef0d3 100644 --- a/src/basics/basics/writer/WbWriterSunflow.h +++ b/src/basics/basics/writer/WbWriterSunflow.h @@ -8,8 +8,6 @@ class WbWriterSunflow : public WbWriter { public: - OBCREATOR_EXT( WbWriterSunflow ) - static WbWriterSunflow* getInstance() { static WbWriterSunflow instance; @@ -33,6 +31,4 @@ public: std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterSunflow ,WbWriter>::getInstance()), CAB_WbWriterSunflow); - #endif //WbWriterSunflow_H diff --git a/src/basics/basics/writer/WbWriterTecPlotASCII.h b/src/basics/basics/writer/WbWriterTecPlotASCII.h index 01b067557a9d39ecfe706cb2f266aaaf75d3f016..ef63390327bbd3b14806f8648b9b2243a224bcb3 100644 --- a/src/basics/basics/writer/WbWriterTecPlotASCII.h +++ b/src/basics/basics/writer/WbWriterTecPlotASCII.h @@ -8,10 +8,6 @@ class WbWriterTecPlotASCII : public WbWriter { public: - #ifndef SWIG - OBCREATOR_EXT( WbWriterTecPlotASCII ) - #endif - static WbWriterTecPlotASCII* getInstance() { static WbWriterTecPlotASCII instance; @@ -88,8 +84,4 @@ public: }; -#ifndef SWIG -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterTecPlotASCII ,WbWriter>::getInstance()), CAB_WbWriterTecPlotASCII); -#endif - #endif //WBWRITERTECPLOTASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkASCII.h b/src/basics/basics/writer/WbWriterVtkASCII.h index aaa1f563cd252fd95691a0e6039f7cadeabc9e58..75f0da4530df2100b6d47bdc574affc4ace11dbd 100644 --- a/src/basics/basics/writer/WbWriterVtkASCII.h +++ b/src/basics/basics/writer/WbWriterVtkASCII.h @@ -12,8 +12,6 @@ class WbWriterVtkASCII : public WbWriter { public: - OBCREATOR_EXT( WbWriterVtkASCII ) - static WbWriterVtkASCII* getInstance() { static WbWriterVtkASCII instance; @@ -73,6 +71,4 @@ public: }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkASCII,WbWriter>::getInstance()), CAB_WbWriterVtkASCII); - #endif //WBWRITERVTKASCII_H diff --git a/src/basics/basics/writer/WbWriterVtkBinary.h b/src/basics/basics/writer/WbWriterVtkBinary.h index c67666c2cc5d688f4901ee02c7741b056e55ac33..30dfc923c0a09231c5b878257e377055a2b520e9 100644 --- a/src/basics/basics/writer/WbWriterVtkBinary.h +++ b/src/basics/basics/writer/WbWriterVtkBinary.h @@ -12,8 +12,6 @@ class WbWriterVtkBinary : public WbWriter { public: - OBCREATOR_EXT( WbWriterVtkBinary ) - static WbWriterVtkBinary* getInstance() { static WbWriterVtkBinary instance; @@ -72,6 +70,4 @@ public: }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterVtkBinary ,WbWriter>::getInstance()), CAB_WbWriterVtkBinary); - #endif //WBWRITERVTKBINARY_H diff --git a/src/basics/basics/writer/WbWriterX3D.h b/src/basics/basics/writer/WbWriterX3D.h index 6bb503f1c71fbd462a0f36e07e0a270051c48e29..2cea1c46ddc537f080dc8e7081cd92bc406b147c 100644 --- a/src/basics/basics/writer/WbWriterX3D.h +++ b/src/basics/basics/writer/WbWriterX3D.h @@ -8,8 +8,6 @@ class WbWriterX3D : public WbWriter { public: - OBCREATOR_EXT( WbWriterX3D ) - static WbWriterX3D* getInstance() { static WbWriterX3D instance; @@ -33,6 +31,4 @@ public: std::string writeTriangles(const std::string& filename,std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt3 >& triangles); }; -UB_AUTO_RUN_NAMED(ObFactory<WbWriter>::getInstance()->addObCreator(ObSingletonCreatorImpl<WbWriterX3D ,WbWriter>::getInstance()), CAB_WbWriterX3D); - #endif //WBWRITERX3D_H diff --git a/src/basics/geometry3d/GbCylinder3D.cpp b/src/basics/geometry3d/GbCylinder3D.cpp index b8eea6401428b464ac7b93b3df9f60ede2fa3e5c..f45fe77abe1b3015cbc6b6b3357ddf2c72cc0f90 100644 --- a/src/basics/geometry3d/GbCylinder3D.cpp +++ b/src/basics/geometry3d/GbCylinder3D.cpp @@ -4,15 +4,8 @@ #include <geometry3d/GbTriangle3D.h> #include <basics/utilities/UbInfinity.h> -#include <geometry3d/creator/GbCylinder3DCreator.h> - using namespace std; -/*=======================================================*/ -ObObjectCreator* GbCylinder3D::getCreator() -{ - return GbCylinder3DCreator::getInstance(); -} // Konstruktor /*==========================================================*/ GbCylinder3D::GbCylinder3D() @@ -1049,23 +1042,7 @@ void GbCylinder3D::scale(const double& sx1, const double& sx2, const double& sx3 this->mLine->scale(sx1,sx2,sx3); //notify observer wird automatisch aufgerufen } -/*==========================================================*/ -void GbCylinder3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(mRad); - out->writeInteger(cylinderType); -} -/*==========================================================*/ -void GbCylinder3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - mRad = in->readDouble(); - cylinderType = in->readInteger(); -} + /*==========================================================*/ double GbCylinder3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { diff --git a/src/basics/geometry3d/GbCylinder3D.h b/src/basics/geometry3d/GbCylinder3D.h index eddf709c5ea2a54b5fa63ec9a2ee977eb9191f69..04cdbb802ed4ce659097e258e341dd92e96c8766 100644 --- a/src/basics/geometry3d/GbCylinder3D.h +++ b/src/basics/geometry3d/GbCylinder3D.h @@ -7,9 +7,6 @@ #ifndef GBCYLINDER3D_H #define GBCYLINDER3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF #include <vector> #include <cmath> @@ -100,27 +97,11 @@ public: void addSurfaceTriangleSetSegments(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight ); std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); //virtuelle Methoden von UbObserver void objectChanged(UbObservable* changedObject); void objectWillBeDeleted(UbObservable* objectForDeletion); -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & mLine; - ar & mRad; - ar & cylinderType; - - if( ArchiveTools::isReading(ar) ) - this->calculateValues(); - } -#endif //CAB_RCF using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere @@ -144,10 +125,4 @@ protected: static const int X3PARALLEL = (1<<3); //8 }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCylinder3D >("GbCylinder3D") , SF_GbCylinder3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCylinder3D >() ), SF_GbCylinder3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCylinder3D>() ), SF_GbCylinder3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h index 3db7a89b03c596590cfc7570e7e297ee8ab5cb6d..b51849282b2e6a171b0036fbdac778ea79f58037 100644 --- a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h +++ b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h @@ -74,7 +74,6 @@ public: } void finalize(){} - ObObjectCreator* getCreator(){ return NULL; } double getX1Centroid(){ return 0.0; } double getX1Minimum() { return -99999.0; } @@ -86,8 +85,6 @@ public: double getX3Minimum() { return -99999.0; } double getX3Maximum() { return 99999.0; } - void write(UbFileOutput* out){} - void read(UbFileInput* in){} GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2) { diff --git a/src/basics/geometry3d/GbObject3DManager.cpp b/src/basics/geometry3d/GbObject3DManager.cpp deleted file mode 100644 index 2ae8af69fc795a323a9238639287d26c3273201c..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/GbObject3DManager.cpp +++ /dev/null @@ -1,285 +0,0 @@ -#include <geometry3d/GbObject3DManager.h> -#include <geometry3d/GbObject3D.h> -#include <geometry3d/creator/GbObject3DFactory.h> - -using namespace std; - -GbObject3DEntry::GbObject3DEntry(GbObject3DManager *parent, GbObject3D *geoObject, bool active, string name):ObObjectEntry(parent, geoObject) -{ - //this->parent = parent; - //this->geoObject = geoObject; - this->active = active; - this->name = name; -} - -/*======================================================*/ -/*== nun halt der Manager ====*/ -/*======================================================*/ - -GbObject3DManager::GbObject3DManager(): ObObjectManager() -{ - this->tableModel = new GbObject3DTableModel(this); -} -/*======================================================*/ -GbObject3DManager::~GbObject3DManager() -{ -// this->gbObject3DList.clear(); -} -/*======================================================*/ -ObObjectFactory* GbObject3DManager::getObObjectFactory() -{ - return GbObject3DFactory::getInstance(); -} - -/*======================================================*/ -ObObjectEntry* GbObject3DManager::createNewObObjectEntry(ObObject *obj) -{ - GbObject3D *geoobject = dynamic_cast<GbObject3D*>(obj); - return new GbObject3DEntry(this, geoobject, true, geoobject->getTypeID()); -} - -/*======================================================*/ -//UbTableModel* GbObject3DManager::getTableModel() -//{ -// return this->tablemodel; -//} - -/*======================================================*/ -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject) -//{ -// return this->addGbObject3D(geoObject, true, "GeoObject"); -//} -// -///*======================================================*/ -bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, string name) -{ - GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); - return ObObjectManager::addObObjectEntry(entry); -} -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, bool active, string name) -//{ -// GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); -// return ObObjectManager::addObObjectEntry(entry); -//} -// -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(GbObject3D *geoObject) -{ - return ObObjectManager::removeObObject(geoObject); -} -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(int index) -{ - return ObObjectManager::removeObObject(index); -} -/*======================================================*/ -//void GbObject3DManager::removeAllGbObject3Ds() -//{ -// this->gbObject3DList.clear(); -//} -/*======================================================*/ -int GbObject3DManager::getNumberOfGbObject3Ds() -{ - return GbObject3DManager::getNumberOfObObjects(); -} -/*======================================================*/ -vector<GbObject3D*>* GbObject3DManager::getAllGbObject3Ds() -{ - throw UbException(UB_EXARGS,"not implemented"); - //vector<GbObject3D*> *geoVektor = new vector<GbObject3D*>; - //for(int u=0; u<(int)this->gbObject3DList.size();u++) - //{ - // GbObject3D* geoObject = dynamic_cast<GbObject3D*>((gbObject3DList)[u]->getObject()); - // geoVektor->push_back(geoObject); - //} - //return geoVektor; -} -/*======================================================*/ -GbObject3D* GbObject3DManager::getGbObject3D(int index) -{ - if(index < 0) return NULL; - if(index >= this->getNumberOfObObjects()) return NULL; - - GbObject3D* geoObject = dynamic_cast<GbObject3D*>(this->getObObject(index)); - return(geoObject); -} -/*======================================================*/ -//GbObject3DEntry* GbObject3DManager::getGbObject3DEntry(int index) -//{ -// if(index < 0) return NULL; -// if(index >= (int)this->gbObject3DList.size()) return NULL; -// -// return((this->gbObject3DList)[index]); -//} -/*====================================================*/ -void GbObject3DManager::write(UbFileOutput *out) -{ - int size = this->getNumberOfObObjects(); - out->writeInteger(size); - out->writeString("// #GbObjects"); - - GbObject3D *geoObject; - for(int pos=0; pos<size; pos++) - { - out->writeLine(); - geoObject = dynamic_cast<GbObject3D*>(this->getObObject(pos)); - cout<<pos<<".:"<<geoObject->toString()<<endl; - geoObject->write(out); - } -} -/*======================================================================*/ -void GbObject3DManager::read(UbFileInput *in) -{ - this->removeAllObObjects(); - - int n = in->readInteger(); - - cout<<"GbObject3DManager::read "<<n<<" GbObject3Ds\n"; - GbObject3D *geoObject; - for(int pos=1; pos<=n; pos++) - { - in->readLine(); - cout<<" - GbObject3D "<<pos<<" ..."; - geoObject = GbObject3DFactory::getInstance()->createGbObject3D(in); - - GbObject3DEntry *entry = new GbObject3DEntry(this, geoObject, true, "GeoObject"); - this->addObObjectEntry(entry); - cout<<"done\n"; - } -} -/*======================================================*/ -string GbObject3DManager::toString() -{ - stringstream ss; ss<<endl; - - int size = this->getNumberOfObObjects(); - for(int pos=0; pos<size; pos++) - { - ObObject* geoObject = this->getObObject(pos); - ss<<(pos+1)<<". "<<geoObject->toString()<<endl; - } - string back = ss.str(); - return back; -} - -/*======================================================*/ -/*======================================================*/ -/*======================================================*/ - -GbObject3DTableModel::GbObject3DTableModel(GbObject3DManager* manager) -{ - this->objectManager = manager; -} - -/*======================================================*/ -GbObject3DTableModel::~GbObject3DTableModel(void) -{ -} - -/*======================================================*/ -//Gibt die Anzahl der Spalten zurueck. -int GbObject3DTableModel::getColumnNumber() -{ - return 3; -} - -/*======================================================*/ -std::string GbObject3DTableModel::getColumnLabel(int column) -{ - switch(column) - { - case COL_NAME: return "Name"; - case COL_TYPE: return "Type"; - case COL_ACTIVE: return "Active"; - default: throw UbException(UB_EXARGS,"falscher Spaltenindex"); - } -} - -/*======================================================*/ -int GbObject3DTableModel::getRowNumber() -{ - return this->objectManager->getNumberOfGbObject3Ds(); -} -/*======================================================*/ -int GbObject3DTableModel::getSelectedRowIndex() -{ - return 0; - // return this->objectManager->getSelectedIndex(); -} - -/*======================================================*/ -int GbObject3DTableModel::getColumnType(int column) -{ - switch(column) { - case COL_NAME : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_TYPE : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_ACTIVE : - return UbTableModel::COL_TYPE_BOOL; - break; - } - return -1; -} - -//Gibt den Eintag der Tabelle an der angegebenen Spalten- und -//Zeilenposition in Form eines String Werts zurueck. -std::string GbObject3DTableModel::getStringValue(int row, int col) -{ - GbObject3DEntry* gbObjEntry = dynamic_cast<GbObject3DEntry*>(this->objectManager->getObObjectEntry(row)); - switch(col) { - case COL_NAME: - return gbObjEntry->name; - break; - case COL_TYPE: - return gbObjEntry->getObject()->getTypeID(); - break; - case COL_ACTIVE: - if ( gbObjEntry->active ) return "True"; - return "False"; - break; - } - return "Fehler"; -} - -/*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(int index) -//{ -// cout<<"GbObject3DManager::selectGbObject3D(int index):"<<index<<endl; -// if (index > (int)this->gbObject3DList.size()-1 || index < 0) return false; -// if ( this->selectedObject == this->getGbObject3D(index) ) return true; -// this->selectedObject = this->getGbObject3D(index); -// this->notifyObserversObjectChanged(); -// return true; -//} -///*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(GbObject3D* geoObject) -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==geoObject) -// { -// return this->selectGbObject3D(pos); -// } -// } -// return false; -//} -///*======================================================*/ -//GbObject3D* GbObject3DManager::getSelectedGbObject3D() -//{ -// return this->selectedObject; -//} -///*======================================================*/ -//int GbObject3DManager::getSelectedIndex() -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==this->selectedObject) -// { -// return pos; -// } -// } -// return -1; -//} diff --git a/src/basics/geometry3d/GbObject3DManager.h b/src/basics/geometry3d/GbObject3DManager.h deleted file mode 100644 index 5f698f090e5be352ee10b70f798cdc7c914151bc..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/GbObject3DManager.h +++ /dev/null @@ -1,119 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECT3DMANAGER_H -#define GBOBJECT3DMANAGER_H - -#include <string> -#include <sstream> -#include <vector> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbTableModel.h> -#include <basics/objects/ObObjectManager.h> - -#include <PointerDefinitions.h> - -class GbObject3D; -class GbObject3DManager; -class GbObject3DTableModel; - -class GbObject3DEntry : public ObObjectEntry -{ - friend class GbObject3DManager; - friend class GbObject3DTableModel; -public: - std::string getName() { return this->name;} -private: - //GbObject3DManager *parent; - //GbObject3D *geoObject; - bool active; - std::string name; - - - GbObject3DEntry(GbObject3DManager* parent, GbObject3D* geoObject, bool active, std::string name); - -}; - - -class GbObject3DManager : public ObObjectManager -{ -public: - GbObject3DManager(); - ~GbObject3DManager(); - - ObObjectEntry* createNewObObjectEntry(ObObject *obj); - ObObjectFactory* getObObjectFactory(); - - - //bool addGbObject3D(GbObject3D *geoObject3D); - bool addGbObject3D(GbObject3D *geoObject3D, std::string name); - //bool addGbObject3D(GbObject3D *geoObject3D, bool active, std::string name); - - bool removeGbObject3D(GbObject3D *geoObject3D); - bool removeGbObject3D(int index); - - int getNumberOfGbObject3Ds(); - std::vector<GbObject3D*>* getAllGbObject3Ds(); - GbObject3D* getGbObject3D(int index); - - //keine Definition dafuer da ... - //void writeValidationAVSFile(string filename); - //void writeSurfaceAVSFile(string filename); - - //public final OctConstructionDescriptor[] getAllActiveConstructions() - //public final OctSpecificConstructionInstrument getSpecificConstructionInstrumentInstance(int index) - //public final boolean isConstructionActive(int index) - //public final boolean isConstructionVisible(int index) - //public final void activateConstruction(int index, boolean active) - //public final void visibleConstruction(int index, boolean visible) - // UbTableModel* getTableModel(); - //void objectChanged(UbObservable* observable); - //void objectWillBeDeleted(UbObservable* observable); - - - void read(UbFileInput *in); - void write(UbFileOutput *out); - - std::string toString(); - -private: - //GbObject3DTableModel* tablemodel; - // GbObject3D* selectedObject; - //vector<GbObject3DEntry*> gbObject3DList; -}; - -class GbObject3DTableModel : public UbTableModel -{ -public: - - static const int COL_NAME = 0; - static const int COL_TYPE = 1; - static const int COL_ACTIVE = 2; - - GbObject3DTableModel(GbObject3DManager* manager); - ~GbObject3DTableModel(void); - - ////////////////////////////////////////////////////////////////////////// - //Geerbt von CabTable - int getColumnNumber(void); - int getRowNumber(); - - std::string getColumnLabel(int column); - - int getColumnType(int); - std::string getStringValue(int row, int col); - int getSelectedRowIndex(); - //bool GetBoolValue(int row, int col); - void setStringValue(int row, int col, std::string str) { throw UbException(UB_EXARGS,"not implemented"); } - -protected: - GbObject3DManager* objectManager; -}; - -#endif diff --git a/src/basics/geometry3d/GbObjectGroup3D.cpp b/src/basics/geometry3d/GbObjectGroup3D.cpp index b26d48eded74f64a5fbddfb582fbd98e2ee62d2a..54b40d5aed352b1daba03d94abdb35507f514dcc 100644 --- a/src/basics/geometry3d/GbObjectGroup3D.cpp +++ b/src/basics/geometry3d/GbObjectGroup3D.cpp @@ -107,18 +107,6 @@ void GbObjectGroup3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector { } /*=======================================================*/ -void GbObjectGroup3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbObjectGroup3D::read(UbFileInput* in) -{ -} -/*=======================================================*/ bool GbObjectGroup3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) { return false; diff --git a/src/basics/geometry3d/GbObjectGroup3D.h b/src/basics/geometry3d/GbObjectGroup3D.h index 359494f46adbeee84785a508091776600321bee8..fac78a728de7303a937ecb6db473f5357c7b7b3c 100644 --- a/src/basics/geometry3d/GbObjectGroup3D.h +++ b/src/basics/geometry3d/GbObjectGroup3D.h @@ -7,9 +7,6 @@ #ifndef GBOBJECTGROUP3D_H #define GBOBJECTGROUP3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF #ifdef CAB_CTL #include <ctl.h> #endif //CAB_CTL @@ -86,9 +83,6 @@ public: std::string toString(); - ObObjectCreator* getCreator(){ return NULL; }; - void write(UbFileOutput* out); - void read(UbFileInput* in); void translate(const double& x1, const double& x2, const double& x3) { @@ -116,17 +110,6 @@ public: std::list< GbObject3D* > getGbObject3DList() { return this->geoobjects; } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - ar & geoobjects; - } -#endif //CAB_RCF #ifdef CAB_CTL ctl::oStream &write(ctl::oStream &os) const { @@ -148,12 +131,4 @@ private: std::list< GbObject3D* > geoobjects; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) - SF_SERIALIZE_ENUM(GbObjectGroup3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbObjectGroup3D>("GbObjectGroup3D") , SF_GbObjectGroup3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbObjectGroup3D >()), SF_GbObjectGroup3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif //GbObjectGroup3D_H diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp index 2f9b7d5de6a32bb0af809bd53a260c14f0680f23..3211811370d466a32345772c1fecc6c13bb51e8e 100644 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp +++ b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp @@ -1,5 +1,4 @@ #include <geometry3d/GbQuadFaceMesh3D.h> -#include <geometry3d/creator/GbQuadFaceMesh3DCreator.h> #include <geometry3d/GbHalfSpace3D.h> #include <geometry3d/GbCuboid3D.h> @@ -41,11 +40,6 @@ GbQuadFaceMesh3D::~GbQuadFaceMesh3D() } } /*======================================================================*/ -ObObjectCreator* GbQuadFaceMesh3D::getCreator() -{ - return GbQuadFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ void GbQuadFaceMesh3D::init() { @@ -298,65 +292,3 @@ GbLine3D* GbQuadFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& p { throw UbException(UB_EXARGS,"not implemented"); } - -/*======================================================================*/ -void GbQuadFaceMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbQuadFaceMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbQuadFaceMesh3D"); - - int quadsize = (int)this->quads->size(); - int nodesize = (int)this->nodes->size(); - - out->writeInteger(nodesize); - out->writeInteger(quadsize); - - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - Vertex node; - QuadFace face; - for(int i=0;i<nodesize; i++) - { - node = (*nodes)[i]; - out->writeInteger(nr++); - out->writeDouble(node.x); - out->writeDouble(node.y); - out->writeDouble(node.z); - out->writeLine(); - } - - nr=1; - for(int i=0;i<quadsize; i++) - { - face = (*quads)[i]; - out->writeInteger(nr++); - out->writeInteger(2); - out->writeString("quad"); - out->writeInteger(face.vertex1+1); - out->writeInteger(face.vertex2+1); - out->writeInteger(face.vertex3+1); - out->writeInteger(face.vertex4+1); - out->writeLine(); - } - - //out->writeInteger(0); out->writeInteger(1); out->writeLine(); - //out->writeInteger(1); out->writeInteger(1); out->writeLine(); - //out->writeLine("TEST,no_unit"); - //nr=1; - //for(int i=0;i<quadsize; i++) - //{ - // out->writeInteger(nr++); - // out->writeInteger(10); - // out->writeLine(); - //} - cout<<"done\n"; -} - diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.h b/src/basics/geometry3d/GbQuadFaceMesh3D.h index 6c9998a633d3131f53cf10bd413846eb815affde..d04c84e1f6a83bf7b4de05e57698fe9835b9ec1b 100644 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.h +++ b/src/basics/geometry3d/GbQuadFaceMesh3D.h @@ -95,7 +95,6 @@ public: virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); //virtual std::vector<GbQuad3D*> getSurfaceQuadSet(); virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); virtual void write(UbFileOutput* out) { std::cout<<"GbQuadFaceMesh3D::write - sorry not implemented\n"; } virtual void read(UbFileInput* in) { std::cout<<"GbQuadFaceMesh3D::read - sorry not implemented\n"; } diff --git a/src/basics/geometry3d/GbSphere3D.cpp b/src/basics/geometry3d/GbSphere3D.cpp index d902a637793f70f380ed7fc73cddd8a086365526..05b634dbe60475aea45099deec32c0f54fdbafd1 100644 --- a/src/basics/geometry3d/GbSphere3D.cpp +++ b/src/basics/geometry3d/GbSphere3D.cpp @@ -4,14 +4,8 @@ #include <geometry3d/GbLine3D.h> #include <geometry3d/GbTriangle3D.h> -#include <geometry3d/creator/GbSphere3DCreator.h> - using namespace std; -ObObjectCreator* GbSphere3D::getCreator() -{ - return GbSphere3DCreator::getInstance(); -} /*=====================================================*/ GbSphere3D::GbSphere3D() : GbObject3D(), UbObserver() @@ -559,30 +553,6 @@ void GbSphere3D::transform(const double matrix[4][4]) this->notifyObserversObjectChanged(); } /*=======================================================*/ -void GbSphere3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbSphere3D::read(UbFileInput* in) -{ - if(midPoint) - { - midPoint->removeObserver(this); - midPoint->finalize(); - delete midPoint; - } - midPoint = new GbPoint3D; - in->readString(); - midPoint->read(in); - midPoint->addObserver(this); - radius = in->readDouble(); - triangulationMode = (TRIANGULATIONMODE)in->readInteger(); -} -/*=======================================================*/ bool GbSphere3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) { GbVector3D vecOrigin(origin.getX1Coordinate(),origin.getX2Coordinate(), origin.getX3Coordinate()) ; diff --git a/src/basics/geometry3d/GbSphere3D.h b/src/basics/geometry3d/GbSphere3D.h index 67db679c2a5dd77a91db197c8f4e23f75baadf97..694225a68df684cc5fc60e569a17322a1b335981 100644 --- a/src/basics/geometry3d/GbSphere3D.h +++ b/src/basics/geometry3d/GbSphere3D.h @@ -7,9 +7,6 @@ #ifndef GBSPHERE3D_H #define GBSPHERE3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF #ifdef CAB_CTL #include <ctl.h> #endif //CAB_CTL @@ -90,10 +87,6 @@ public: std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - void translate(const double& x1, const double& x2, const double& x3) { this->midPoint->translate(x1, x2, x3); @@ -124,16 +117,6 @@ public: using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - } -#endif //CAB_RCF #ifdef CAB_CTL ctl::oStream &write(ctl::oStream &os) const { @@ -153,12 +136,5 @@ private: TRIANGULATIONMODE triangulationMode; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if CAB_RCF <= 903 - SF_SERIALIZE_ENUM(GbSphere3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbSphere3D>("GbSphere3D") , SF_GbSphere3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbSphere3D >()), SF_GbSphere3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION #endif //GBSPHERE3D_H diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.cpp b/src/basics/geometry3d/GbTriFaceMesh3D.cpp index 7b6dc16c4b2bbb5c0677c57ad5d56ddd6ab13dfe..2f9dd9296265463ceacbc22af77366e7ecd7e3b2 100644 --- a/src/basics/geometry3d/GbTriFaceMesh3D.cpp +++ b/src/basics/geometry3d/GbTriFaceMesh3D.cpp @@ -4,10 +4,10 @@ #include <geometry3d/GbCuboid3D.h> #include <geometry3d/GbHalfSpace3D.h> #include <geometry3d/CoordinateTransformation3D.h> -#include <geometry3d/creator/GbTriFaceMesh3DCreator.h> #include <basics/utilities/UbRandom.h> #include <basics/utilities/UbTiming.h> #include <basics/utilities/UbLogger.h> +#include <basics/utilities/UbFileInputASCII.h> #include <basics/writer/WbWriter.h> #include <geometry3d/KdTree/KdTree.h> @@ -73,11 +73,6 @@ GbTriFaceMesh3D::~GbTriFaceMesh3D() if( kdTree ) { delete kdTree; kdTree = NULL; } } /*======================================================================*/ -ObObjectCreator* GbTriFaceMesh3D::getCreator() -{ - return GbTriFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ void GbTriFaceMesh3D::init() { nodes = NULL; @@ -959,101 +954,7 @@ GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& po { throw UbException(UB_EXARGS,"not implemented"); } -/*======================================================================*/ -void GbTriFaceMesh3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeInteger((int)kdtreeSplitAlg); - out->writeBool(transferViaFilename); - if(!transferViaFilename) - { - //nodes - vector<Vertex>& vertices = *nodes; - out->writeSize_t( nodes->size() ); - out->writeLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - out->writeFloat(v.x); - out->writeFloat(v.y); - out->writeFloat(v.z); - out->writeLine(); - } - - //triangles - vector<TriFace>& tris = *triangles; - out->writeSize_t( tris.size() ); - out->writeLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - out->writeInteger(t.v1); - out->writeInteger(t.v2); - out->writeInteger(t.v3); - out->writeLine(); - } - } - else - { - out->writeString(filename); - out->writeLine(); - out->writeDouble(transX1); - out->writeDouble(transX2); - out->writeDouble(transX3); - - } -} -/*======================================================================*/ -void GbTriFaceMesh3D::read(UbFileInput* in) -{ - kdtreeSplitAlg = (KDTREE_SPLITAGORITHM)in->readInteger(); - transferViaFilename = in->readBool(); - - if(!transferViaFilename) - { - if(!nodes) nodes = new vector<Vertex>; - //nodes - vector<Vertex>& vertices = *nodes; - vertices.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - v.x = in->readFloat(); - v.y = in->readFloat(); - v.z = in->readFloat(); - in->readLine(); - } - - //triangles - if(!triangles) triangles = new vector<TriFace>; - vector<TriFace>& tris = *triangles; - tris.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - t.v1 = in->readInteger(); - t.v2 = in->readInteger(); - t.v3 = in->readInteger(); - in->readLine(); - } - - this->calculateValues(); - } - else - { - filename = in->readString(); - in->readLine(); - transX1 = in->readDouble(); - transX2 = in->readDouble(); - transX3 = in->readDouble(); - - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } -} /*======================================================================*/ UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata ) { diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.h b/src/basics/geometry3d/GbTriFaceMesh3D.h index 3d4853906329be1e52a039ebbb5dd347572f3ca8..61eac36e1dac626dd039c0ffd20fd06e1d3929e8 100644 --- a/src/basics/geometry3d/GbTriFaceMesh3D.h +++ b/src/basics/geometry3d/GbTriFaceMesh3D.h @@ -11,10 +11,6 @@ #include <iostream> #include <vector> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <basics/utilities/UbException.h> #include <basics/utilities/UbMath.h> @@ -26,6 +22,8 @@ #include <PointerDefinitions.h> +#include <basics_export.h> + namespace Kd { template< typename T> class Tree; @@ -97,14 +95,6 @@ public: return(new Vertex(this)); } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & x; ar & y; ar & z; - } -#endif //CAB_RCF - public: float x, y, z; }; @@ -217,13 +207,6 @@ public: <<"->removeRedunantNodes"<<std::endl; } } - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & v1; ar & v2; ar & v3; - } - #endif //CAB_RCF public: int v1, v2, v3; @@ -303,11 +286,6 @@ public: KDTREE_SPLITAGORITHM getKdTreeSplitAlgorithm() { return this->kdtreeSplitAlg; } Kd::Tree<double>* getKdTree() { return this->kdTree; } - virtual ObObjectCreator* getCreator(); - - void write(UbFileOutput* out); - void read(UbFileInput* in); - virtual UbTuple<std::string, std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL ); void writeMeshPly( const std::string& filename); @@ -317,35 +295,6 @@ public: bool intersectLine(const double& p1_x1, const double& p1_x2, const double& p1_x3, const double& p2_x1, const double& p2_x2, const double& p2_x3); -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & kdtreeSplitAlg; - ar & transferViaFilename; - if(!transferViaFilename) - { - ar & nodes; - ar & triangles; - } - else - { - ar & filename; - ar & transX1; - ar & transX2; - ar & transX3; - if(ArchiveTools::isReading(ar) ) - { - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } - } - - if(ArchiveTools::isReading(ar)) this->calculateValues(); - } -#endif //CAB_RCF - protected: KDTREE_SPLITAGORITHM kdtreeSplitAlg; void init(); @@ -377,9 +326,5 @@ protected: Kd::Tree< double >* kdTree; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriFaceMesh3D >("GbTriFaceMesh3D ") , SF_GbTriFaceMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriFaceMesh3D >() ), SF_GbTriFaceMesh3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION #endif //GBTRIFACEMESH3D_H diff --git a/src/basics/geometry3d/GbTriangularMesh3D.cpp b/src/basics/geometry3d/GbTriangularMesh3D.cpp index d520bb4a6cc9d36feadcbdfec266f79a67fff8ef..c709cc7da9f9702493245575e84547bb7a06eb26 100644 --- a/src/basics/geometry3d/GbTriangularMesh3D.cpp +++ b/src/basics/geometry3d/GbTriangularMesh3D.cpp @@ -1,5 +1,4 @@ #include <geometry3d/GbTriangularMesh3D.h> -#include <geometry3d/creator/GbTriangularMesh3DCreator.h> #include <map> @@ -111,11 +110,6 @@ GbTriangularMesh3D::~GbTriangularMesh3D() } } /*======================================================================*/ -ObObjectCreator* GbTriangularMesh3D::getCreator() -{ - return GbTriangularMesh3DCreator::getInstance(); -} -/*======================================================================*/ void GbTriangularMesh3D::deleteRedundantNodes() { std::map<GbPoint3D*,GbTriangle3D*> pointTriMap; @@ -1034,106 +1028,6 @@ void GbTriangularMesh3D::writeMesh(string filename, WbWriter* writer, bool write writer->writeLines(filename+"_normals",lineNodes,lines); } } -/*======================================================================*/ -void GbTriangularMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbTriangularMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbTriangularMesh3D"); - //vector<GbPoint3D*> *nodes = this->getNodes(); - vector<GbTriangle3D*> *triangles = this->getTriangles(); - //int nodesize = (int)nodes->size(); - int trianglesize = (int)triangles->size(); - int nodesize = trianglesize*3; - if(normals) - { - out->writeInteger(nodesize+trianglesize*2); - out->writeInteger(trianglesize*2); - } - else - { - out->writeInteger(nodesize); - out->writeInteger(trianglesize); - } - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - GbPoint3D *node; - for(int i=0;i<trianglesize; i++) - { - node = (*triangles)[i]->getPoint(0); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(1); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(2); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - } - - if(normals) - { - for(int i=0;i<trianglesize; i++) - { - GbVector3D vec = (*triangles)[i]->getNormal(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()); - out->writeDouble((*triangles)[i]->getX2Centroid()); - out->writeDouble((*triangles)[i]->getX3Centroid()); - out->writeLine(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()+vec.X1()); - out->writeDouble((*triangles)[i]->getX2Centroid()+vec.X2()); - out->writeDouble((*triangles)[i]->getX3Centroid()+vec.X3()); - out->writeLine(); - } - } - nr=1; - int el=1; - for(int i=0;i<trianglesize; i++) - { - nr = 3*el-2; - out->writeInteger(el); - out->writeInteger(2); - out->writeString("tri"); - out->writeInteger(nr); - out->writeInteger(nr+1); - out->writeInteger(nr+2); - out->writeLine(); - el++; - } - if(normals) - { - nr = trianglesize*3+1; - for(int i=trianglesize;i<2*trianglesize; i++) - { - out->writeInteger(el); - out->writeInteger(2); - out->writeString("line"); - out->writeInteger(nr++); - out->writeInteger(nr++); - out->writeLine(); - el++; - } - } - cout<<"done\n"; -} /*======================================================================*/ /* diff --git a/src/basics/geometry3d/GbTriangularMesh3D.h b/src/basics/geometry3d/GbTriangularMesh3D.h index 1b9b1ccfc26d8485116c1caa2aaf7fe5b4a9f7f4..d0b71589dd08b7332fc6293417d682c9c25f51ef 100644 --- a/src/basics/geometry3d/GbTriangularMesh3D.h +++ b/src/basics/geometry3d/GbTriangularMesh3D.h @@ -110,14 +110,8 @@ public: virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); - - virtual void write(UbFileOutput* out) { std::cout<<"GbTriangularMesh3D::write - sorry not implemented\n"; } - virtual void read(UbFileInput* in) { std::cout<<"GbTriangularMesh3D::read - sorry not implemented\n"; } void writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false); - void writeAVSMesh(UbFileOutput* out, bool normals=false); - /*======================================================================*/ using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.cpp b/src/basics/geometry3d/GbVoxelMatrix3D.cpp index 2acdd559171434c694b2e0952072098856ed6693..0995526a7863e786806892297ee2cbc75aa000cb 100644 --- a/src/basics/geometry3d/GbVoxelMatrix3D.cpp +++ b/src/basics/geometry3d/GbVoxelMatrix3D.cpp @@ -2,7 +2,6 @@ #include <basics/utilities/UbMath.h> #include <basics/utilities/UbFileInputASCII.h> -#include <geometry3d/creator/GbVoxelMatrix3DCreator.h> #include <geometry3d/GbTriangle3D.h> #include <basics/utilities/UbFileOutputASCII.h> #include <geometry3d/CoordinateTransformation3D.h> @@ -19,11 +18,6 @@ const float GbVoxelMatrix3D::SOLID = 1.0f; const float GbVoxelMatrix3D::FLUID = 0.0f; -/*=======================================================*/ -ObObjectCreator* GbVoxelMatrix3D::getCreator() -{ - return GbVoxelMatrix3DCreator::getInstance(); -} /*=======================================================*/ // Konstruktor GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold) @@ -520,72 +514,6 @@ string GbVoxelMatrix3D::toString() return "GbVoxelMatrix3D"; } /*=======================================================*/ -void GbVoxelMatrix3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(minX1); - out->writeDouble(minX2); - out->writeDouble(minX3); - out->writeDouble(deltaX1); - out->writeDouble(deltaX2); - out->writeDouble(deltaX3); - out->writeInteger(nodesX1); - out->writeInteger(nodesX2); - out->writeInteger(nodesX3); - out->writeDouble(lowerThreshold); - out->writeDouble(upperThreshold); - out->writeBool(addSurfaceTriangleSetFlag); - out->writeBool(transferViaFilename); - if (!transferViaFilename) - { - throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::write(UbFileOutput* out) - geht ned"); - } - else - { - out->writeString(filename); - } - - - //CbUniformMatrix3D<float> voxelMatrix; -} -/*=======================================================*/ -void GbVoxelMatrix3D::read(UbFileInput* in) -{ -#ifdef CAB_RCF - try - { -#endif - //!!! den string nimmt er vorher um das Object zu erstellen - //in->readString(); - minX1 = in->readDouble(); - minX2 = in->readDouble(); - minX3 = in->readDouble(); - deltaX1 = in->readDouble(); - deltaX2 = in->readDouble(); - deltaX3 = in->readDouble(); - nodesX1 = in->readInteger(); - nodesX2 = in->readInteger(); - nodesX3 = in->readInteger(); - lowerThreshold = in->readDouble(); - upperThreshold = in->readDouble(); - addSurfaceTriangleSetFlag = in->readBool(); - transferViaFilename = in->readBool(); - if (!transferViaFilename) - { - throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::read(UbFileOutput* out) - geht ned"); - } - else - { - filename = in->readString(); - this->readMatrixFromVtiASCIIFile(filename); - } -#ifdef CAB_RCF - } - catch (std::exception& e) { UBLOGML(logERROR, UB_FUNCTION+(std::string)e.what()); throw RCF::Exception(1002, UB_FUNCTION+(std::string)e.what()); } - catch (...) { UBLOGML(logERROR, UB_FUNCTION+(std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION+(std::string)"unknown error"); } -#endif -} -/*=======================================================*/ void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename) { diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.h b/src/basics/geometry3d/GbVoxelMatrix3D.h index 6e8f47ed1de066d78a07258111469186e0fb8b86..4cc0925e065e05a3b66b5ec94b1dcaaa1759b878 100644 --- a/src/basics/geometry3d/GbVoxelMatrix3D.h +++ b/src/basics/geometry3d/GbVoxelMatrix3D.h @@ -7,9 +7,6 @@ #ifndef GBVOXELMATRIX3D_H #define GBVOXELMATRIX3D_H -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF #include <vector> #include <cmath> @@ -110,10 +107,6 @@ public: std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - //virtuelle Methoden von UbObserver void objectChanged(UbObservable* changedObject) {} void objectWillBeDeleted(UbObservable* objectForDeletion) {} @@ -162,38 +155,6 @@ protected: using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -//#ifdef CAB_RCF -// template<class Archive> -// void SF_SERIALIZE(Archive & ar) -// { -// SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); -// ar & minX1; -// ar & minX2; -// ar & minX3; -// ar & deltaX1; -// ar & deltaX2; -// ar & deltaX3; -// ar & nodesX1; -// ar & nodesX2; -// ar & nodesX3; -// ar & threshold; -// ar & transferViaFilename; -// ar & addSurfaceTriangleSetFlag; -// if (!transferViaFilename) -// { -// ar & voxelMatrix; -// } -// else -// { -// ar & filename; -// if (ArchiveTools::isReading(ar)) -// { -// this->readMatrixFromVtiASCIIFile(filename); -// } -// } -// -// } -//#endif //CAB_RCF protected: //for transfer diff --git a/src/basics/geometry3d/creator/GbCuboid3DCreator.h b/src/basics/geometry3d/creator/GbCuboid3DCreator.h deleted file mode 100644 index 5a878cda2d224562ca01ccff66ec3e8452594ed2..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbCuboid3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBCUBOID3DCREATOR_H -#define GBCUBOID3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbCuboid3D.h> - -#ifdef CAB_QT -#include <geometry3d/presentation/QGbCuboid3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <geometry3d/presentation/vtkGbCuboid3D.h> -#endif - -class GbCuboid3DCreator : public GbObject3DCreator -{ -public: - static GbCuboid3DCreator* getInstance() - { - static GbCuboid3DCreator instance; - return &instance; - } - - GbCuboid3D* createGbObject3D() { return new GbCuboid3D(); } - - std::string getGbObject3DTypeID() { return "GbCuboid3D"; }; - std::string toString() { return "GbCuboid3DCreator"; } - -private: - GbCuboid3DCreator() : GbObject3DCreator() {} - - GbCuboid3DCreator( const GbCuboid3DCreator& ); //no copy allowed - const GbCuboid3DCreator& operator=( const GbCuboid3DCreator& ); //no copy allowed - -#ifdef CAB_QT -public: - GbCuboid3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = this->createGbObject3D(); - cuboid->getPoint2()->setX1(2.0); - cuboid->getPoint2()->setX2(2.0); - cuboid->getPoint2()->setX3(2.0); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - if (instrument.exec()) { return cuboid; } - delete cuboid; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbCuboid3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = dynamic_cast<GbCuboid3D*>(gbObj); - if(!cuboid) throw UbException(UB_EXARGS,"selected object to edit is no GbCuboid3D!"); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCuboid3D(dynamic_cast<GbCuboid3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCuboid3DCreator::getInstance()), CAB_GbCuboid3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbCylinder3DCreator.h b/src/basics/geometry3d/creator/GbCylinder3DCreator.h deleted file mode 100644 index fc9ef7117328b20ca507a34d493973f65b910130..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbCylinder3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBCYLINDER3DCREATOR_H -#define GBCYLINDER3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbCylinder3D.h> - -#ifdef CAB_QT -#include <geometry3d/presentation/QGbCylinder3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <geometry3d/presentation/vtkGbCylinder3D.h> -#endif - - -class GbCylinder3DCreator : public GbObject3DCreator -{ -public: - static GbCylinder3DCreator* getInstance() - { - static GbCylinder3DCreator instance; - return &instance; - } - - GbCylinder3D* createGbObject3D() { return new GbCylinder3D(); } - - std::string getGbObject3DTypeID(){ return "GbCylinder3D"; } - std::string toString() { return "GbCylinder3DCreator"; } - -private: - GbCylinder3DCreator( const GbCylinder3DCreator& ); //no copy allowed - const GbCylinder3DCreator& operator=( const GbCylinder3DCreator& ); //no copy allowed -GbCylinder3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbCylinder3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = this->createGbObject3D(); - cylinder->setRadius(2.0); - cylinder->setPoint1(0.0, 0.0, 0.0); - cylinder->setPoint2(0.0, 5.0, 0.0); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - if (instrument.exec()){ return cylinder; } - delete cylinder; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) - { - return new QGbCylinder3DInstrument(parent, flags); - } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = dynamic_cast<GbCylinder3D*>(gbObj); - if(!cylinder) throw UbException(UB_EXARGS,"selected object to edit is no GbCylinder3D!"); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCylinder3D(dynamic_cast<GbCylinder3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCylinder3DCreator::getInstance()), CAB_GbCylinder3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbLine3DCreator.h b/src/basics/geometry3d/creator/GbLine3DCreator.h deleted file mode 100644 index 3ffcbfd90f101c223c92df3bb5595637eddedc1a..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbLine3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBLINE3DCREATOR_H -#define GBLINE3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbLine3D.h> - -class GbLine3DCreator : public GbObject3DCreator -{ -public: - static GbLine3DCreator* getInstance() - { - static GbLine3DCreator instance; - return &instance; - } - - GbLine3D* createGbObject3D() { return new GbLine3D(); } - - std::string getGbObject3DTypeID(){ return "GbLine3D"; } - std::string toString() { return "GbLine3DCreator"; } - -private: - GbLine3DCreator( const GbLine3DCreator& ); //no copy allowed - const GbLine3DCreator& operator=( const GbLine3DCreator& ); //no copy allowed - GbLine3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbLine3DCreator::getInstance()), CAB_GbLine3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbObject3DCreator.h b/src/basics/geometry3d/creator/GbObject3DCreator.h deleted file mode 100644 index bf9fe32e3c3d899ae72e69a10a5b5a6ca68b1705..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbObject3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBOBJECT3DCREATOR_H -#define GBOBJECT3DCREATOR_H - -#include <string> - -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbAutoRun.hpp> - -#include <geometry3d/GbObject3D.h> - -#ifdef CAB_QT -#include <qdialog.h> -#endif - -#ifdef CAB_VTK -#include <userinterface/presentation/vtkPoElement3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkPVSource.h" -#endif - -class GbObject3DCreator : public ObObjectCreator -{ -protected: - GbObject3DCreator() {} -private: - GbObject3DCreator( const GbObject3DCreator& ); //no copy allowed !!! - const GbObject3DCreator& operator=( const GbObject3DCreator& ); //no copy allowed -public: - virtual ~GbObject3DCreator(){} - - virtual std::string getTypeID() { return getGbObject3DTypeID();} - virtual ObObject* createObObject() - { - return this->createGbObject3D(); - } - - - virtual GbObject3D* createGbObject3D()=0; - virtual std::string getGbObject3DTypeID()=0; - virtual std::string toString() { return "GbObject3DCreator"; } - -#ifdef CAB_QT - virtual GbObject3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } - virtual void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } -#endif - //die Teile von ObObjectCreator ... -#ifdef CAB_QT - void showSpecificInstrument(ObObject* object,QWidget* parent=0) - { - GbObject3D* geoObj = dynamic_cast<GbObject3D*>(object); - this->editGbObject3DwithQt(geoObj, parent); - } - virtual ObObject* createObObjectWithQt() { return this->createGbObject3DwithQt();} - virtual QObObjectSpecificInstrument* getSpecificInstrument() { throw UbException(UB_EXARGS,"not implemented"); } - -#endif -#ifdef CAB_VTK - virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; } -#endif - - -#ifdef CAB_PARAVIEW - virtual vtkPVSource* createPVSource(vtkPVWindow *Window) { throw UbException(UB_EXARGS,"vtkPVSource* createPVSource"); } -#endif - - -}; - -#include <geometry3d/creator/GbObject3DFactory.h> - -/*=========================================================================*/ -#endif - - - diff --git a/src/basics/geometry3d/creator/GbObject3DFactory.cpp b/src/basics/geometry3d/creator/GbObject3DFactory.cpp deleted file mode 100644 index 5ec0885802ade1808cf185dcef3d1da7f51f7d3f..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbObject3DFactory.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include <geometry3d/creator/GbObject3DFactory.h> -#include <geometry3d/creator/GbObject3DCreator.h> -//#include <geometry3d/creator/GbPoint3DCreator.h> -// #include <geometry3d/creator/GbCuboid3DCreator.h> -// #include <geometry3d/creator/GbSphere3DCreator.h> -// #include <geometry3d/creator/GbCylinder3DCreator.h> -// #include <geometry3d/creator/GbLine3DCreator.h> -// #include <geometry3d/creator/GbPolygon3DCreator.h> -// #include <geometry3d/creator/GbTriangle3DCreator.h> -// #include <geometry3d/creator/GbTriangularMesh3DCreator.h> - -using namespace std; - -//GbObject3DFactory* GbObject3DFactory::instance = NULL; - -/*======================================================================*/ -GbObject3DFactory::GbObject3DFactory() - : ObObjectFactory() -{ -} -/*======================================================================*/ -GbObject3DFactory* GbObject3DFactory::getInstance() -{ - static GbObject3DFactory instance; - return &instance; -} - -///*======================================================================*/ -//void GbObject3DFactory::addGbObject3DCreator(GbObject3DCreator* creator) -//{ -// //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getGbObject3DTypeID()<<endl; -// creatorSet.insert(pair<string, GbObject3DCreator*>(creator->getGbObject3DTypeID(), creator)); -//} -// -//void GbObject3DFactory::deleteGbObject3DCreator(GbObject3DCreator* creator) -//{ -// throw UbException(UB_EXARGS,"GbObject3DFactory::deleteGbObject3DCreator not yet implemented"); -// // this.creatorSet.delete(creator); -//} - -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createGbObject3D(UbFileInput *in) -{ - string str = in->readString(); - //cout<<"GbObject3DFactory::createGbObject3D:"<<str<<endl; - - GbObject3D *gbObject3D = createEmptyGbObject3D(str); - - if(!gbObject3D) - throw UbException(UB_EXARGS,"creator for type available"); - - gbObject3D->read(in); - - return gbObject3D; -} -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createEmptyGbObject3D(string objectType) -{ - typedef std::map<string, ObObjectCreator*>::iterator CreatorIterator; - std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet(); - CreatorIterator creatorIterator = creatorSet->find(objectType); - - if(creatorIterator == creatorSet->end()) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - GbObject3DCreator *creator = dynamic_cast<GbObject3DCreator*>(creatorIterator->second); - - if(!creator) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - return creator->createGbObject3D(); -} -/*======================================================================*/ -//GbObject3DCreator* GbObject3DFactory::getCreator(string objectType) -//{ -// CreatorIterator creatorIterator = creatorSet.find(objectType); -// if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// GbObject3DCreator *creator = creatorIterator->second; -// if(!creator) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// return(creator); -//} -/*======================================================================*/ -string GbObject3DFactory::toString() -{ - stringstream ss; - ss<<"GbObject2DFactory"; - int a=1; - std::map<std::string, ObObjectCreator*>::iterator creatorIterator; - std::map<std::string, ObObjectCreator*>* tmp = this->getCreatorSet(); - for(creatorIterator=tmp->begin(); creatorIterator!=tmp->end(); creatorIterator++) - { - ss<<(a++)<<". "; - ss<<creatorIterator->second->getTypeID(); - ss<<endl; - } - return(ss.str()); -} diff --git a/src/basics/geometry3d/creator/GbObject3DFactory.h b/src/basics/geometry3d/creator/GbObject3DFactory.h deleted file mode 100644 index 0231e34ad42493a70d5fc665864992c84789b5fb..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbObject3DFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GBOBJECT3DFACTORY_H -#define GBOBJECT3DFACTORY_H - -#include <string> -#include <sstream> -#include <map> - -#include <basics/objects/ObObjectFactory.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -class GbObject3D; -class GbObject3DCreator; - -class GbObject3DFactory : public ObObjectFactory -{ -private: - GbObject3DFactory(); - GbObject3DFactory( const GbObject3DFactory& ); //no copy allowed - const GbObject3DFactory& operator=( const GbObject3DFactory& ); //no copy allowed -public: - static GbObject3DFactory* getInstance(); - - GbObject3D* createGbObject3D(UbFileInput* in); - - //void addGbObject3DCreator(GbObject3DCreator* creator); - //void deleteGbObject3DCreator(GbObject3DCreator* creator); - //std::map<std::string, GbObject3DCreator*>* getCreatorSet() { return &creatorSet; } - - std::string toString(); - GbObject3D* createEmptyGbObject3D(std::string objectType); - //GbObject3DCreator* getCreator(std::string objectTypeID); - -private: - - - //std::map<std::string, GbObject3DCreator*> creatorSet; - //typedef std::map<std::string, GbObject3DCreator*>::iterator CreatorIterator; -}; -/*=========================================================================*/ -#endif - diff --git a/src/basics/geometry3d/creator/GbPoint3DCreator.h b/src/basics/geometry3d/creator/GbPoint3DCreator.h deleted file mode 100644 index 02ebb61de7e333c117c115a87827707810ca7a7c..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbPoint3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBPOINT3DCREATOR_H -#define GBPOINT3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbPoint3D.h> - -class GbPoint3DCreator : public GbObject3DCreator -{ -public: - static GbPoint3DCreator* getInstance() - { - static GbPoint3DCreator instance; - return &instance; - } - - GbPoint3D* createGbObject3D() { return new GbPoint3D(); } - - std::string getGbObject3DTypeID() { return "GbPoint3D"; } - std::string toString() { return "GbPoint3DCreator"; } - -private: - GbPoint3DCreator( const GbPoint3DCreator& ); //no copy allowed - const GbPoint3DCreator& operator=( const GbPoint3DCreator& ); //no copy allowed - GbPoint3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPoint3DCreator::getInstance()), CAB_GbPoint3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbPolygon3DCreator.h b/src/basics/geometry3d/creator/GbPolygon3DCreator.h deleted file mode 100644 index 838e87866e77fc4202ca4b427eba7a64ba7f8228..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbPolygon3DCreator.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GBPOLYGON3DCREATOR_H -#define GBPOLYGON3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbPoint3D.h> - -class GbPolygon3DCreator : public GbObject3DCreator -{ -public: - static GbPolygon3DCreator* getInstance() - { - static GbPolygon3DCreator instance; - return &instance; - } - - GbPolygon3D* createGbObject3D() { return new GbPolygon3D(); } - - std::string getGbObject3DTypeID() { return "GbPolygon3D"; } - std::string toString() { return "GbPolygon3DCreator"; } - -private: - GbPolygon3DCreator( const GbPolygon3DCreator& ); //no copy allowed - const GbPolygon3DCreator& operator=( const GbPolygon3DCreator& ); //no copy allowed - - GbPolygon3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPolygon3DCreator::getInstance()), CAB_GbPolygon3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp deleted file mode 100644 index 8ade9dece0efd7117fdca11714eda612ef79a186..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include <geometry3d/creator/GbQuadFaceMesh3DCreator.h> -#include <geometry3d/GbQuadFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -using namespace std; - -/***************************************************************************/ -GbObject3D* GbQuadFaceMesh3DCreator::createGbObject3D() -{ - return new GbQuadFaceMesh3D(); -} -/***************************************************************************/ -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, string name) -{ - vector<GbQuadFaceMesh3D::Vertex> *vertices = new vector<GbQuadFaceMesh3D::Vertex>; - vector<GbQuadFaceMesh3D::QuadFace> *quads = new vector<GbQuadFaceMesh3D::QuadFace>; - for(int x1=0;x1<nodesX1;x1++) - { - for(int x2=0;x2<nodesX2;x2++) - { - vertices->push_back(GbQuadFaceMesh3D::Vertex((float)(x1*knotenabstandX1+startX1), (float)(x2*knotenabstandX2+startX2), nullNiveau)); - } - } - for(int x1=0;x1<nodesX1-1;x1++) - { - for(int x2=0;x2<nodesX2-1;x2++) - { - int index = x1*nodesX2+x2; - quads->push_back(GbQuadFaceMesh3D::QuadFace(index, index+nodesX2, index+nodesX2+1, index+1)); - } - } - - return (new GbQuadFaceMesh3D(name, vertices, quads)); -} - -/*============================================================*/ - -#ifdef CAB_QT - -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createGbObject3DwithQt() -{ - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - //QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - //UbFileInputASCII in( s.toAscii().data() ); - //stringstream stream; - //stream <<"TriangularMesh3D ";//<<_objCount++; - //GbQuadFaceMesh3D *mesh = NULL;//GbQuadFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - //return mesh; - return NULL; -} -//QDialog* getSpecificInstrument() { return 0;} -void GbQuadFaceMesh3DCreator::editGbObject3DwithQt(GbObject3D* gbObj) -{ - -} -#endif -#ifdef CAB_VTK -Presentator* GbQuadFaceMesh3DCreator::createObjectPresentator(ObObject *object) -{ - return NULL; -} -#endif diff --git a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h deleted file mode 100644 index 8309708b3b910e8ac10a0d1974af63009835f5dd..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef GBQUADFACEMESH3DCREATOR_H -#define GBQUADFACEMESH3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> - -class GbQuadFaceMesh3D; - -#ifdef CAB_QT - -#endif - -#ifdef CAB_VTK -//#include <geometry3d/presentation/vtkGbQuadangularMesh3D.h> -#endif - -class GbQuadFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbQuadFaceMesh3DCreator* getInstance() - { - static GbQuadFaceMesh3DCreator instance; - return &instance; - } - static GbQuadFaceMesh3D *createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, std::string name); - - GbObject3D* createGbObject3D(); - - std::string getGbObject3DTypeID() { return "GbQuadFaceMesh3D"; } - std::string toString() { return "GbQuadFaceMesh3DCreator"; } - -#ifdef CAB_QT - - GbQuadFaceMesh3D* createGbObject3DwithQt(); - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj); -#endif -#ifdef CAB_VTK - Presentator* createObjectPresentator(ObObject *object); -#endif - - -private: - GbQuadFaceMesh3DCreator( const GbQuadFaceMesh3DCreator& ); //no copy allowed - const GbQuadFaceMesh3DCreator& operator=( const GbQuadFaceMesh3DCreator& ); //no copy allowed - GbQuadFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbQuadFaceMesh3DCreator::getInstance()), CAB_GbQuadFaceMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbSphere3DCreator.h b/src/basics/geometry3d/creator/GbSphere3DCreator.h deleted file mode 100644 index 222bb80dc9dccfefeb96c3aa15ce591a26f36164..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbSphere3DCreator.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef GBSPHERE3DCREATOR_H -#define GBSPHERE3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbSphere3D.h> - -#ifdef CAB_QT -#include <geometry3d/presentation/QGbSphere3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <geometry3d/presentation/vtkGbSphere3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkSMSourceProxy.h" -#include "vtkSMProperty.h" -#include "vtkSMDoubleVectorProperty.h" -#endif - -class GbSphere3DCreator : public GbObject3DCreator -{ -public: - static GbSphere3DCreator* getInstance() - { - static GbSphere3DCreator instance; - return &instance; - } - - GbSphere3D* createGbObject3D() { return new GbSphere3D(); } - - std::string getGbObject3DTypeID() { return "GbSphere3D"; }; - std::string toString() { return "GbSphere3DCreator"; } - -private: - GbSphere3DCreator( const GbSphere3DCreator& ); //no copy allowed - const GbSphere3DCreator& operator=( const GbSphere3DCreator& ); //no copy allowed - GbSphere3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbSphere3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = this->createGbObject3D(); - sphere->setRadius(3.0); - sphere->setCenterX1Coordinate(6.0); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - if (instrument.exec()) { return sphere; } - delete sphere; - return NULL; - } - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbSphere3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = dynamic_cast<GbSphere3D*>(gbObj); - if(!sphere) throw UbException(UB_EXARGS,"selected object to edit is no GbSphere3D"); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbSphere3D(dynamic_cast<GbSphere3D*>(object)); } -#endif - - -#ifdef CAB_PARAVIEW - vtkPVSource* createPVSource(vtkPVWindow *Window); -#endif -}; - -#ifdef CAB_PARAVIEW -vtkPVSource* GbSphere3DCreator::createPVSource(vtkPVWindow *Window) -{ - GbSphere3D *mysphere = this->createGbObject3D(); - mysphere->setCenterX1Coordinate(2.0); - mysphere->setCenterX2Coordinate(1.0); - mysphere->setCenterX3Coordinate(3.0); - mysphere->setRadius(0.3); - - vtkPVSource* pvs = Window->CreatePVSource("SphereSource"); - pvs->CreateProperties(); - if (pvs) - { - pvs->IsPermanentOn(); - pvs->Accept(1, 1); - //pvs->SetTraceReferenceObject(this->GetWindow()); - pvs->SetTraceReferenceObject(Window); - } - //vtkPVDisplayGUI *settingsGUI= pvs->GetPVOutput(); - - vtkSMSourceProxy* proxy = pvs->GetProxy(); - vtkSMProperty *prop = proxy->GetProperty("Center"); - - vtkSMDoubleVectorProperty *doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Center")); - doubleprop->SetElement(0, mysphere->getX1Centroid()); - doubleprop->SetElement(1, mysphere->getX2Centroid()); - doubleprop->SetElement(2, mysphere->getX3Centroid()); - pvs->SetLabel("Kugel"); - - doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Radius")); - doubleprop->SetElement(0, mysphere->getRadius()); - - pvs->GetPVWidget("Center")->ResetInternal(); - pvs->GetPVWidget("Radius")->ResetInternal(); - - pvs->SetVisibility(TRUE); - pvs->AcceptCallback(); - pvs->Update(); - return pvs; -} -#endif - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbSphere3DCreator::getInstance()), CAB_GbSphere3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp deleted file mode 100644 index 144fb0bc9d2c71ad2bbd6c4696ba93b08121ad4d..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp +++ /dev/null @@ -1,431 +0,0 @@ -#include <geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbTiming.h> - -using namespace std; - -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist - - //UBLOG(logINFO, "GbTriFaceMesh3DCreator::readMeshFromFile - read " <<filename ); - - if ( !ext.compare("ply" ) ) return GbTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("stl" ) ) return GbTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("inp" ) ) return GbTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("mesh") ) return GbTriFaceMesh3DCreator::readMeshFromMeshFile(filename, meshName,splitAlg , removeRedundantNodes); - //else if( !ext.compare("raw") ) return GbTriFaceMesh3DCreator::readMeshFromRAWFile(filename,splitAlg , meshName); - else throw UbException(UB_EXARGS,"fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII meshfile(filename); - if(!meshfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromMeshFile(&meshfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Vertices") !=std::string::npos ) - break; - } - int numVertices = in->readInteger(); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - - nodes->resize(numVertices); - - float x, y, z; - for (int i=0; i<numVertices; i++) - { - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Triangles") !=std::string::npos ) - break; - } - int numFaces = in->readInteger(); - triangles->reserve(numFaces); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - int j,k,l; - for(int i=0; i<numFaces; i++) - { - j = in->readInteger()-1; - k = in->readInteger()-1; - l = in->readInteger()-1; - in->readLine(); - - (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes ); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII plyfile(filename); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - float x, y, z; - string dummy; - - int numVertices = in->readIntegerAfterString("element vertex"); - int numFaces = in->readIntegerAfterString("element face"); - in->setPosAfterLineWithString("end_header"); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - nodes->resize(numVertices); - triangles->reserve(numFaces); - - int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01)); - for (int i=0; i<numVertices; i++) - { - if( i%onePercent==0 ) - cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush; - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - int p,j,k,l,n; - onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); - for(int i=0; i<numFaces; i++) - { - if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush; - - p = in->readInteger(); - if(p==3) //Dreieck, alles andere wird stumpf ingnoriert - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) ) - { - throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - else if(p==4) //Viereck --> wird zu zwei Dreiecken! - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - n = in->readInteger(); - numFaces++; - i++; - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) - || !UbMath::inClosedInterval(n,0,numVertices-1) - ) - { - throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j)); - } - - in->readLine(); - - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - nr+=3; - //std::cout<<"read mesh "<< nr <<" \n"; - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -////////////////////////////////////////////////////////////////////////// -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile2(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes, bool isBinaryFormat) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - int nr=0; - - if (!isBinaryFormat) { - ifstream in(filename.c_str()); - if (!in.good()) - { - delete nodes; - delete triangles; - UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); - } - char title[80]; - std::string s0, s1; - float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8; - in.read(title, 80); - while (!in.eof()) { - in >> s0; // facet || endsolid - if (s0=="facet") { - in >> s1 >> n0 >> n1 >> n2; // normal x y z - in >> s0 >> s1; // outer loop - in >> s0 >> f0 >> f1 >> f2; // vertex x y z - in >> s0 >> f3 >> f4 >> f5; // vertex x y z - in >> s0 >> f6 >> f7 >> f8; // vertex x y z - in >> s0; // endloop - in >> s0; // endfacet - // Generate a new Triangle without Normal as 3 Vertices - nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2)); - nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5)); - nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - nr+=3; - } - else if (s0=="endsolid") { - break; - } - } - in.close(); - } - else { - FILE *f = fopen(filename.c_str(), "rb"); - if (!f) - { - delete nodes; - delete triangles; - UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); - } - char title[80]; - int nFaces; - fread(title, 80, 1, f); - fread((void*)&nFaces, 4, 1, f); - float v[12]; // normal=3, vertices=3*3 = 12 - unsigned short uint16; - // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer - for (size_t i=0; i<nFaces; ++i) { - for (size_t j=0; j<12; ++j) { - fread((void*)&v[j], sizeof(float), 1, f); - } - fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces - nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5])); - nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8])); - nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11])); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2)); - nr+=3; - } - fclose(f); - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} - -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - int numberNodes = in->readInteger(); - int numberTris = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - in->readInteger(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - in->readLine(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - in->readInteger(); - in->readString(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1)); - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - - in->readString(); - int numberNodes = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //cout<<u<<" - x,y,z:"<<x<<","<<y<<","<<z<<endl; - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //in->readLine(); - } - in->readLine(); - in->readString(); - int numberTris = in->readInteger(); - in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); - - - return mesh; -} diff --git a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h deleted file mode 100644 index 65821a0fe18c4c08c95bf30306fe815ebfd5c9ef..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef GBTRIFACEMESH3DCREATOR_H -#define GBTRIFACEMESH3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbTriFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriFaceMesh3DCreator* getInstance() - { - static GbTriFaceMesh3DCreator instance; - return &instance; - } - static GbTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromMeshFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromSTLFile2(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true, bool isBinaryFormat=true); - - static GbTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriFaceMesh3D"; }; - std::string toString() { return "GbTriFaceMesh3DCreator"; } - -#ifdef CAB_QT - - - GbTriFaceMesh3D* createGbObject3DwithQt() - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriFaceMesh3D *mesh = NULL;//GbTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriFaceMesh3DCreator( const GbTriFaceMesh3DCreator& ); //no copy allowed - const GbTriFaceMesh3DCreator& operator=( const GbTriFaceMesh3DCreator& ); //no copy allowed - GbTriFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriFaceMesh3DCreator::getInstance()), CAB_GbTriFaceMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriangle3DCreator.h b/src/basics/geometry3d/creator/GbTriangle3DCreator.h deleted file mode 100644 index 20ff2af7bf3ae2f4b9c0cfdff05d3cc12e9f23fb..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbTriangle3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBTRIANGLE3DCREATOR_H -#define GBTRIANGLE3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbTriangle3D.h> - -class GbTriangle3DCreator : public GbObject3DCreator -{ -public: - static GbTriangle3DCreator* getInstance() - { - static GbTriangle3DCreator instance; - return &instance; - } - - GbTriangle3D* createGbObject3D() { return new GbTriangle3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangle3D"; } - std::string toString() { return "GbTriangle3DCreator"; } - -private: - GbTriangle3DCreator( const GbTriangle3DCreator& ); //no copy allowed - const GbTriangle3DCreator& operator=( const GbTriangle3DCreator& ); //no copy allowed - GbTriangle3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangle3DCreator::getInstance()), CAB_GbTriangle3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp deleted file mode 100644 index 0838953efa289ace40d69f76c70621efcbdbcc01..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include <geometry3d/creator/GbTriangularMesh3DCreator.h> -#include <algorithm> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromFile(string filename, string meshName) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); - - if ( !ext.compare("ply") ) return GbTriangularMesh3DCreator::readMeshFromPLYFile(filename, meshName); - else if( !ext.compare("stl") ) return GbTriangularMesh3DCreator::readMeshFromSTLFile(filename, meshName); - else if( !ext.compare("gts") ) return GbTriangularMesh3DCreator::readMeshFromGTSFile(filename, meshName); - else if( !ext.compare("raw") ) return GbTriangularMesh3DCreator::readMeshFromRAWFile(filename, meshName); - else throw UbException(UB_EXARGS,"unrecognized fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(string filename, string meshName) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriangularMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(UbFileInput* in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - //int nr=0; - string dummy; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node1 = new GbPoint3D(x,y,z); nodes->push_back(node1); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node2 = new GbPoint3D(x,y,z); nodes->push_back(node2); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node3 = new GbPoint3D(x,y,z); nodes->push_back(node3); - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - } - return new GbTriangularMesh3D(meshName, nodes, triangles); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(string inputfile, string meshName) -{ - UbFileInputASCII gtlfile(inputfile); - if(!gtlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromGTSFile(>lfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int edgesize = in->readInteger(); - int trianglesize = in->readInteger(); - UBLOG(logINFO,"node-/edge-/trianglesize: "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<edgesize;i++) - { - in->readLine(); - point1=in->readInteger()-1; - point2=in->readInteger()-1; - edges->push_back(new GbLine3D((*nodes)[point1],(*nodes)[point2])); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - //triangles->push_back(new GbTriangle3D((*nodes)[point1-1],(*nodes)[point2-1],(*nodes)[point3-1])); - triangles->push_back(new GbTriangle3D((GbPoint3D*)(*edges)[point1-1]->getPoint1(),(GbPoint3D*)(*edges)[point2-1]->getPoint1(),(GbPoint3D*)(*edges)[point3-1]->getPoint1())); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(string inputfile, string meshName) -{ - UbFileInputASCII plyfile(inputfile); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(UbFileInput *in, string meshName) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int nr=0; - string dummy; - int numVertices, numFaces; - GbPoint3D *node = NULL; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numVertices = in->readInteger(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numFaces = in->readInteger(); in->readLine(); - in->readLine(); - in->readLine(); - UBLOG(logINFO,"Number of vertices "<<numVertices); - UBLOG(logINFO,"Number of faces "<<numFaces); - for (int i=0; i<numVertices; i++) - { - x = in->readDouble(); - y = in->readDouble(); - z = in->readDouble(); - // cout<<x<<y<<z; - // in->readString(); in->readString(); in->readString(); - in->readLine(); - node = new GbPoint3D(x,y,z); nodes->push_back(node); - } - nr=0; - - for (int i=0; i<numFaces; i++) - { - in->readString(); - int j,k,l; - j = in->readInteger(); k = in->readInteger(); l = in->readInteger(); - node1 = (*nodes)[j]; - node2 = (*nodes)[k]; - node3 = (*nodes)[l]; - in->readLine(); - nr++; - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - } - - return(new GbTriangularMesh3D(meshName, nodes, triangles)); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(string inputfile, string meshName) -{ - UbFileInputASCII stlfile(inputfile); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromRAWFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int trianglesize = in->readInteger(); - int edgesize = 0; - UBLOG(logINFO,"node-/edge-/trianglesize "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - triangles->push_back(new GbTriangle3D((*nodes)[point1],(*nodes)[point2],(*nodes)[point3])); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} diff --git a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h deleted file mode 100644 index e2e9d173a59facca1aed54acf1334c8a3e43765a..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef GBTRIANGULARMESH3DCREATOR_H -#define GBTRIANGULARMESH3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbTriangularMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriangularMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriangularMesh3DCreator* getInstance() - { - static GbTriangularMesh3DCreator instance; - return &instance; - } - - static GbTriangularMesh3D* readMeshFromFile(std::string filename, std::string meshName=""); - - static GbTriangularMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(std::string inputFile, std::string meshName); - - static GbTriangularMesh3D* readMeshFromSTLFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(UbFileInput* infile, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(UbFileInput* infile, std::string meshName); - - - GbTriangularMesh3D* createGbObject3D() { return new GbTriangularMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangularMesh3D"; }; - std::string toString() { return "GbTriangularMesh3DCreator"; } - -#ifdef CAB_QT - - GbTriangularMesh3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - mesh->deleteRedundantNodes(); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriangularMesh3DCreator( const GbTriangularMesh3DCreator& ); //no copy allowed - const GbTriangularMesh3DCreator& operator=( const GbTriangularMesh3DCreator& ); //no copy allowed - GbTriangularMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangularMesh3DCreator::getInstance()), CAB_GbTriangularMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp deleted file mode 100644 index 137143cd357e13dd7d255e64ab28693729912f17..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include <geometry3d/creator/GbVoxelMatrix3DCreator.h> -#include <geometry3d/GbVoxelMatrix3D.h> -#include <basics/utilities/UbFileInputASCII.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromRawFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, ios::end ); //Ende springen - fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, ios::beg ); //An den Anfang springen - if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize"); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - float val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - in.read((char*)&val,sizeof(float)); - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - UbFileInputASCII in(filename); - //ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - //in.readLine(); !!!manchmal hat das vti file noch die xml version dabei ... - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - int val; - int u=0; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - val = in.readInteger(); - - //u++; if(u>125000) UBLOG(logINFO,"val:"<<u<<" "<<val); - - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} - diff --git a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h deleted file mode 100644 index ddfc2991132dcc8299b923c37f7658c14f1300eb..0000000000000000000000000000000000000000 --- a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBVOXELMATRIX3DCREATOR_H -#define GBVOXELMATRIX3DCREATOR_H - -#include <geometry3d/creator/GbObject3DCreator.h> -#include <geometry3d/GbVoxelMatrix3D.h> -#include <iostream> -#include <fstream> - -class GbVoxelMatrix3DCreator : public GbObject3DCreator -{ -public: - enum DataType {t8bit, t16bit}; -public: - static GbVoxelMatrix3DCreator* getInstance() - { - static GbVoxelMatrix3DCreator instance; - return &instance; - } - - GbVoxelMatrix3D* createGbObject3D() { return new GbVoxelMatrix3D(); } - GbVoxelMatrix3D* createFromRawFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - GbVoxelMatrix3D* createFromVtiASCIIFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - - std::string getGbObject3DTypeID() { return "GbVoxelMatrix3D"; }; - std::string toString() { return "GbVoxelMatrix3DCreator"; } - -private: - GbVoxelMatrix3DCreator() : GbObject3DCreator() {} - - GbVoxelMatrix3DCreator( const GbVoxelMatrix3DCreator& ); //no copy allowed - const GbVoxelMatrix3DCreator& operator=( const GbVoxelMatrix3DCreator& ); //no copy allowed - -public: - template< typename T > - GbVoxelMatrix3D* createFromRawFile(std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) - { - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - - std::ifstream in(filename.c_str(), std::ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, std::ios::end ); //Ende springen - std::fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, std::ios::beg ); //An den Anfang springen - long m_size = (nodesX1*nodesX2*nodesX3)*sizeof(T); - if( m_size != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize: " + UbSystem::toString(length)); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - T val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) - { - in.read((char*)&val,sizeof(T)); - //if( !UbMath::equal(val, 0.0f) ) - //if( UbMath::greater(val, (T)threshold) ) - if(val > (T)threshold) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; - } -}; - - - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbVoxelMatrix3DCreator::getInstance()), CAB_GbVoxelMatrix3DCreator); -#endif - -#endif //GBVOXELMATRIX3DCREATOR_H