From 68c5e5aa721468794022d8c1c9d993b240ca2a33 Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Wed, 18 Apr 2018 16:57:51 +0200 Subject: [PATCH] new discretizition methods implemented --- .../GridCpuStrategy/GridCpuStrategy.cpp | 341 ++++--- .../GridCpuStrategy/GridCpuStrategy.h | 5 +- .../basics/utilities/UbMath.h | 2 +- .../basics/writer/WbWriter.h | 2 +- .../basics/writer/WbWriterAvsASCII.cpp | 1 + .../basics/writer/WbWriterAvsBinary.cpp | 2 + .../basics/writer/WbWriterVtkXmlBinary.cpp | 2 + .../numerics/geometry3d/GbObject3D.h | 12 +- .../numerics/geometry3d/GbTriFaceMesh3D.cpp | 903 ++++-------------- .../numerics/geometry3d/GbTriFaceMesh3D.h | 26 +- .../creator/GbTriFaceMesh3DCreator.cpp | 214 +++-- .../creator/GbTriFaceMesh3DCreator.h | 23 +- 12 files changed, 534 insertions(+), 999 deletions(-) diff --git a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp index e28022c38..f39d04da3 100644 --- a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp +++ b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.cpp @@ -1,3 +1,4 @@ + #include "GridCpuStrategy.h" #include <time.h> @@ -7,7 +8,7 @@ #include <GridGenerator/grid/distributions/Distribution.h> #include <GridGenerator/grid/GridImp.h> - + #include <GridGenerator/geometries/TriangularMesh/TriangularMesh.h> #include <utilities/logger/Logger.h> @@ -15,14 +16,15 @@ #include "grid/GridInterface.h" #include "io/GridVTKWriter/GridVTKWriter.h" +#include "numerics/geometry3d/GbTriFaceMesh3D.h" void GridCpuStrategy::allocateGridMemory(SPtr<GridImp> grid) { - + grid->neighborIndexX = new int[grid->size]; grid->neighborIndexY = new int[grid->size]; grid->neighborIndexZ = new int[grid->size]; - + grid->sparseIndices = new int[grid->size]; @@ -60,7 +62,7 @@ void GridCpuStrategy::findInnerNodes(SPtr<GridImp> grid) void GridCpuStrategy::findInnerNodes(SPtr<GridImp> grid, TriangularMesh* triangularMesh) { - switch(triangularMesh->getDiscretizationMethod()) + switch (triangularMesh->getDiscretizationMethod()) { case DiscretizationMethod::POINT_UNDER_TRIANGLE: pointUnderTriangleMethod(grid, triangularMesh); @@ -68,13 +70,14 @@ void GridCpuStrategy::findInnerNodes(SPtr<GridImp> grid, TriangularMesh* triangu case DiscretizationMethod::RAYCASTING: rayCastingMethod(grid, triangularMesh); break; + case DiscretizationMethod::POINT_IN_OBJECT: + pointInObjectMethod(grid, triangularMesh); } } void GridCpuStrategy::pointUnderTriangleMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh) { - #pragma omp parallel for for (int i = 0; i < triangularMesh->size; i++) grid->meshReverse(triangularMesh->triangles[i]); @@ -90,158 +93,178 @@ void GridCpuStrategy::pointUnderTriangleMethod(SPtr<GridImp> grid, TriangularMes << "nodes: " << grid->nx << " x " << grid->ny << " x " << grid->nz << " = " << grid->size << "\n"; } +void GridCpuStrategy::pointInObjectMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh) +{ + auto triangles = triangularMesh->triangleVec; + std::vector<GbTriFaceMesh3D::Vertex> *gbVertices = new std::vector<GbTriFaceMesh3D::Vertex>(triangles.size() * 3); + std::vector<GbTriFaceMesh3D::TriFace> *gbTriangles = new std::vector<GbTriFaceMesh3D::TriFace>(triangles.size()); + for (int i = 0; i < triangles.size(); i++) + { + (*gbVertices)[i * 3] = GbTriFaceMesh3D::Vertex(triangles[i].v1.x, triangles[i].v1.y, triangles[i].v1.z); + (*gbVertices)[i * 3 + 1] = GbTriFaceMesh3D::Vertex(triangles[i].v2.x, triangles[i].v2.y, triangles[i].v2.z); + (*gbVertices)[i * 3 + 2] = GbTriFaceMesh3D::Vertex(triangles[i].v3.x, triangles[i].v3.y, triangles[i].v3.z); + + (*gbTriangles)[i] = GbTriFaceMesh3D::TriFace(i * 3, i * 3 + 1, i * 3 + 2); + } + + GbTriFaceMesh3D mesh("stl", gbVertices, gbTriangles); + + for (int i = 0; i < grid->getSize(); i++) + { + real x, y, z; + grid->transIndexToCoords(i, x, y, z); + + if (mesh.isPointInGbObject3D(x, y, z)) + grid->field.setFieldEntryToFluid(i); + } +} + void GridCpuStrategy::rayCastingMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh) { - //int nx1 = bcMatrices.geoMatrix.getNX1(); - //int nx2 = bcMatrices.geoMatrix.getNX2(); - //int nx3 = bcMatrices.geoMatrix.getNX3(); - - - //const int minX = triangularMesh->minmax.minX; - //const int minY = triangularMesh->minmax.minY; - //const int minZ = triangularMesh->minmax.minZ; - // - //const int maxX = triangularMesh->minmax.maxX; - //const int maxY = triangularMesh->minmax.maxY; - //const int maxZ = triangularMesh->minmax.maxZ; - - //int x, y, z; - - //for (z = minZ; z <= maxZ; z++) - //{ - // for (y = minY; y <= maxY; y++) - // { - // for (x = minX; x <= maxX; x++) - // { - // if (y == 0 || y == (int)nx2 - 1 || - // x == 0 || x == (int)nx1 - 1 || - // z == 0 || z == (int)nx3 - 1) - // { - // } - // else - // { - // /* - // * The first 3 bits contain node type (fluid, inlet, etc.). - // * The remaining 5 bits contain the unique geometry number - // * in case of solid nodes. - // * - // * 0 0 0 0 0 | 0 0 0 - // */ - - // // Add the unique geometry number to the upper 5 bits. - // geoMatrix(x, y, z) = NodeType::solid; - // setGeoID(geoMatrix(x, y, z), mesh->getUniqueID()); - // } - // } - // } - //} - - - //int counter = 0; - - //// Test line intersection - //for (z = minZ; z <= maxZ; z++) - //{ - // for (y = minY; y <= maxY; y++) - // { - // for (x = minX; x <= maxX; x++) - // { - // counter++; - // if (mesh->intersectLine((x - 1)*deltaXWorld, y*deltaXWorld, z*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid; - // } - // } - //} - - //// Test line intersection from opposite direction - //for (z = minZ; z <= maxZ; z++) - //{ - // for (y = minY; y <= maxY; y++) - // { - // for (x = maxX; x >= minX; x--) - // { - // if (geoMatrix(x, y, z) != NodeType::fluid) - // { - // counter++; - // if (mesh->intersectLine((x + 1)*deltaXWorld, y*deltaXWorld, z*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid; - // } - // } - // } - //} - - //// Test line intersection - //for (z = minZ; z <= maxZ; z++) - //{ - // for (x = minX; x <= maxX; x++) - // { - // for (y = minY; y <= maxY; y++) - // { - // if (geoMatrix(x, y, z) != NodeType::fluid) - // { - // counter++; - // if (mesh->intersectLine(x*deltaXWorld, (y - 1)*deltaXWorld, z*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid; - // } - // } - // } - //} - - //// Test line intersection from opposite direction - //for (z = minZ; z <= maxZ; z++) - //{ - // for (x = minX; x <= maxX; x++) - // { - // for (y = maxY; y >= minY; y--) - // { - // if (geoMatrix(x, y, z) != NodeType::fluid) - // { - // counter++; - // if (mesh->intersectLine(x*deltaXWorld, (y + 1)*deltaXWorld, z*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid;; - // } - // } - // } - //} - - //// Test line intersection - //for (x = minX; x <= maxX; x++) - //{ - // for (y = minY; y <= maxY; y++) - // { - // for (z = minZ; z <= maxZ; z++) - // { - // if (geoMatrix(x, y, z) != NodeType::fluid) - // { - // counter++; - // if (mesh->intersectLine(x*deltaXWorld, y*deltaXWorld, (z - 1)*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid; - // } - // } - // } - //} - - //// Test line intersection from opposite direction - //for (x = minX; x <= maxX; x++) - //{ - // for (y = minY; y <= maxY; y++) - // { - // for (z = maxZ; z >= minZ; z--) - // { - // if (geoMatrix(x, y, z) != NodeType::fluid) - // { - // counter++; - // if (mesh->intersectLine(x*deltaXWorld, y*deltaXWorld, (z + 1)*deltaXWorld, x*deltaXWorld, y*deltaXWorld, z*deltaXWorld)) break; - // else geoMatrix(x, y, z) = NodeType::fluid; - // } - // } - // } - //} - - //std::cout << counter << " nodes tested...\n"; - - //// map temp geoMatrix to final geoMatrix - //mapSolidNodesToFinalGeoMatrix(geoMatrix, bcMatrices); + auto triangles = triangularMesh->triangleVec; + std::vector<GbTriFaceMesh3D::Vertex> *gbVertices = new std::vector<GbTriFaceMesh3D::Vertex>(triangles.size() * 3); + std::vector<GbTriFaceMesh3D::TriFace> *gbTriangles = new std::vector<GbTriFaceMesh3D::TriFace>(triangles.size()); + for (int i = 0; i < triangles.size(); i++) + { + (*gbVertices)[i * 3] = GbTriFaceMesh3D::Vertex(triangles[i].v1.x, triangles[i].v1.y, triangles[i].v1.z); + (*gbVertices)[i * 3 + 1] = GbTriFaceMesh3D::Vertex(triangles[i].v2.x, triangles[i].v2.y, triangles[i].v2.z); + (*gbVertices)[i * 3 + 2] = GbTriFaceMesh3D::Vertex(triangles[i].v3.x, triangles[i].v3.y, triangles[i].v3.z); + + (*gbTriangles)[i] = GbTriFaceMesh3D::TriFace(i * 3, i * 3 + 1, i * 3 + 2); + } + + GbTriFaceMesh3D mesh("stl", gbVertices, gbTriangles); + + const real minXExact = triangularMesh->minmax.minX; + const real minYExact = triangularMesh->minmax.minY; + const real minZExact = triangularMesh->minmax.minZ; + + const real maxXExact = triangularMesh->minmax.maxX; + const real maxYExact = triangularMesh->minmax.maxY; + const real maxZExact = triangularMesh->minmax.maxZ; + + const auto min = grid->getMinimumOnNode(Vertex(minXExact, minYExact, minZExact)); + + const real minX = min.x; + const real minY = min.y; + const real minZ = min.z; + + const auto max = grid->getMaximumOnNode(Vertex(maxXExact, maxYExact, maxZExact)); + + const real maxX = max.x; + const real maxY = max.y; + const real maxZ = max.z; + + real x, y, z; + + for (int i = 0; i < grid->getSize(); i++) + { + grid->field.setFieldEntryToFluid(i); + } + + + int counter = 0; + + // Test line intersection + for (z = minZ; z <= maxZ; z += grid->getDelta()) + { + for (y = minY; y <= maxY; y += grid->getDelta()) + { + for (x = minX; x <= maxX; x += grid->getDelta()) + { + counter++; + if (mesh.intersectLine((x - grid->getDelta()), y, z, x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + + } + } + } + + // Test line intersection from opposite direction + for (z = minZ; z <= maxZ; z += grid->getDelta()) + { + for (y = minY; y <= maxY; y += grid->getDelta()) + { + for (x = maxX; x >= minX; x -= grid->getDelta()) + { + if (!grid->field.isOutOfGrid(grid->transCoordToIndex(x, y, z))) + { + counter++; + if (mesh.intersectLine((x + grid->getDelta()), y, z, x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + } + } + } + } + + // Test line intersection + for (z = minZ; z <= maxZ; z += grid->getDelta()) + { + for (x = minX; x <= maxX; x += grid->getDelta()) + { + for (y = minY; y <= maxY; y += grid->getDelta()) + { + if (!grid->field.isOutOfGrid(grid->transCoordToIndex(x, y, z))) + { + counter++; + if (mesh.intersectLine(x, (y - grid->getDelta()), z, x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + } + } + } + } + + // Test line intersection from opposite direction + for (z = minZ; z <= maxZ; z += grid->getDelta()) + { + for (x = minX; x <= maxX; x += grid->getDelta()) + { + for (y = maxY; y >= minY; y -= grid->getDelta()) + { + if (!grid->field.isOutOfGrid(grid->transCoordToIndex(x, y, z))) + { + counter++; + if (mesh.intersectLine(x, (y + grid->getDelta()), z, x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + } + } + } + } + + // Test line intersection + for (x = minX; x <= maxX; x += grid->getDelta()) + { + for (y = minY; y <= maxY; y += grid->getDelta()) + { + for (z = minZ; z <= maxZ; z += grid->getDelta()) + { + if (!grid->field.isOutOfGrid(grid->transCoordToIndex(x, y, z))) + { + counter++; + if (mesh.intersectLine(x, y, (z - grid->getDelta()), x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + } + } + } + } + + // Test line intersection from opposite direction + for (x = minX; x <= maxX; x += grid->getDelta()) + { + for (y = minY; y <= maxY; y += grid->getDelta()) + { + for (z = maxZ; z >= minZ; z -= grid->getDelta()) + { + if (!grid->field.isOutOfGrid(grid->transCoordToIndex(x, y, z))) + { + counter++; + if (mesh.intersectLine(x, y, (z + grid->getDelta()), x, y, z)) break; + else grid->field.setFieldEntryToOutOfGrid(grid->transCoordToIndex(x, y, z)); + + } + } + } + } } void GridCpuStrategy::findStopperNodes(SPtr<GridImp> grid) @@ -270,9 +293,9 @@ void GridCpuStrategy::findGridInterface(SPtr<GridImp> grid, SPtr<GridImp> fineGr grid->gridInterface = new GridInterface(); const uint sizeCF = fineGrid->nx * fineGrid->ny + fineGrid->ny * fineGrid->nz + fineGrid->nx * fineGrid->nz; grid->gridInterface->cf.coarse = new uint[sizeCF]; - grid->gridInterface->cf.fine = new uint[sizeCF]; + grid->gridInterface->cf.fine = new uint[sizeCF]; grid->gridInterface->fc.coarse = new uint[sizeCF]; - grid->gridInterface->fc.fine = new uint[sizeCF]; + grid->gridInterface->fc.fine = new uint[sizeCF]; for (uint index = 0; index < grid->getSize(); index++) grid->findGridInterfaceCF(index, *fineGrid); @@ -295,7 +318,7 @@ void GridCpuStrategy::findSparseIndices(SPtr<GridImp> coarseGrid, SPtr<GridImp> coarseGrid->updateSparseIndices(); findForNeighborsNewIndices(coarseGrid); - if(fineGrid) + if (fineGrid) { fineGrid->updateSparseIndices(); findForGridInterfaceNewIndices(coarseGrid, fineGrid); @@ -351,7 +374,7 @@ void GridCpuStrategy::freeFieldMemory(Field* field) void GridCpuStrategy::freeMemory(SPtr<GridImp> grid) { //if(grid->gridInterface) - //delete grid->gridInterface; + //delete grid->gridInterface; delete[] grid->neighborIndexX; delete[] grid->neighborIndexY; diff --git a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h index f4f19926a..1e611f6ea 100644 --- a/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h +++ b/src/GridGenerator/grid/GridStrategy/GridCpuStrategy/GridCpuStrategy.h @@ -14,7 +14,7 @@ struct TriangularMesh; class VF_PUBLIC GridCpuStrategy : public GridStrategy { public: - virtual ~GridCpuStrategy() {}; + virtual ~GridCpuStrategy() {}; void allocateGridMemory(SPtr<GridImp> grid) override; @@ -40,6 +40,7 @@ protected: void pointUnderTriangleMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh); void rayCastingMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh); + void pointInObjectMethod(SPtr<GridImp> grid, TriangularMesh* triangularMesh); public: void allocateFieldMemory(Field* field) override; @@ -48,4 +49,4 @@ public: }; -#endif +#endif \ No newline at end of file diff --git a/src/VirtualFluidsBasics/basics/utilities/UbMath.h b/src/VirtualFluidsBasics/basics/utilities/UbMath.h index 98034171b..8c091893e 100644 --- a/src/VirtualFluidsBasics/basics/utilities/UbMath.h +++ b/src/VirtualFluidsBasics/basics/utilities/UbMath.h @@ -11,7 +11,7 @@ #include <limits> #include <iostream> #include <cassert> -#include <basics/utilities/UbSystem.h> +//#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbEqual.h> /*=========================================================================*/ diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriter.h b/src/VirtualFluidsBasics/basics/writer/WbWriter.h index 0f3478155..23fb67e65 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriter.h +++ b/src/VirtualFluidsBasics/basics/writer/WbWriter.h @@ -21,9 +21,9 @@ #include <iostream> #include <map> +#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbTuple.h> #include <basics/utilities/UbPointerWrapper.h> #include <basics/utilities/UbAutoRun.hpp> diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterAvsASCII.cpp b/src/VirtualFluidsBasics/basics/writer/WbWriterAvsASCII.cpp index b7e279e36..388feecb9 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterAvsASCII.cpp +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterAvsASCII.cpp @@ -1,6 +1,7 @@ #include <basics/writer/WbWriterAvsASCII.h> #include <basics/utilities/UbLogger.h> #include <cstring> +#include <basics/utilities/UbSystem.h> using namespace std; diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterAvsBinary.cpp b/src/VirtualFluidsBasics/basics/writer/WbWriterAvsBinary.cpp index 27b5a16b3..2d0ad38c5 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterAvsBinary.cpp +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterAvsBinary.cpp @@ -1,6 +1,8 @@ #include <basics/writer/WbWriterAvsBinary.h> #include <basics/writer/WbWriterAvsASCII.h> #include <basics/utilities/UbLogger.h> +#include <basics/utilities/UbSystem.h> + #include <cstring> using namespace std; diff --git a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp index 7db53a8f9..f7fdd7934 100644 --- a/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp +++ b/src/VirtualFluidsBasics/basics/writer/WbWriterVtkXmlBinary.cpp @@ -1,6 +1,8 @@ #include <basics/writer/WbWriterVtkXmlBinary.h> #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> +#include <basics/utilities/UbSystem.h> + #include <buildInfo.h> #include <cstring> diff --git a/src/VirtualFluidsBasics/numerics/geometry3d/GbObject3D.h b/src/VirtualFluidsBasics/numerics/geometry3d/GbObject3D.h index fb19b0aca..70ccebef9 100644 --- a/src/VirtualFluidsBasics/numerics/geometry3d/GbObject3D.h +++ b/src/VirtualFluidsBasics/numerics/geometry3d/GbObject3D.h @@ -11,11 +11,8 @@ #include <vector> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF -#include <basics/utilities/UbSystem.h> +//#include <basics/utilities/UbSystem.h> #include <basics/utilities/UbException.h> #include <basics/utilities/UbFileInput.h> #include <basics/utilities/UbFileOutput.h> @@ -28,15 +25,12 @@ class GbLine3D; class GbTriangle3D; class GbObject3DCreator; -#ifdef CAB_CTL -#include <ctl.h> -#endif +#include <VirtualFluidsDefinitions.h> #include <basics/memory/MbSharedPointerDefines.h> class GbObject3D; typedef VFSharedPtr<GbObject3D> GbObject3DPtr; - /*=========================================================================*/ /* GbObject3D */ /* */ @@ -47,7 +41,7 @@ typedef VFSharedPtr<GbObject3D> GbObject3DPtr; * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> * @version 1.0 - 02.02.05 */ -class GbObject3D : public ObObject +class VF_PUBLIC GbObject3D : public ObObject { public: #ifdef CAB_CTL diff --git a/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.cpp b/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.cpp index 0beb2b12b..10f3c07f4 100644 --- a/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.cpp +++ b/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.cpp @@ -1,4 +1,3 @@ - #include <numerics/geometry3d/GbTriFaceMesh3D.h> #include <numerics/geometry3d/GbCuboid3D.h> @@ -15,39 +14,31 @@ #include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> #include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> -#define MAX_ITER 10 - using namespace std; GbTriFaceMesh3D::GbTriFaceMesh3D() : GbObject3D() , buildVertTriRelationMap(false) , kdTree(NULL) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) - + , kdTreeValid(false) { this->setName("CAB_GbTriFaceMesh3D"); this->nodes = new vector<Vertex>; this->triangles = new vector<TriFace>; this->consistent = false; - this->kdtreeSplitAlg = KDTREE_SAHPLIT; + //this->kdtreeSplitAlg = KDTREE_SHAPLIT; + this->kdtreeSplitAlg = KDTREE_SPATIALSPLIT; } /*=======================================================================*/ -GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) +GbTriFaceMesh3D::GbTriFaceMesh3D( string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) : GbObject3D() , nodes(nodes) , triangles(triangles) , buildVertTriRelationMap(false) , consistent(false) , kdTree(NULL) + , kdTreeValid(false) , kdtreeSplitAlg(splitAlg) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) { if( name.empty() ) throw UbException(UB_EXARGS,"no name specified"); if( !nodes ) throw UbException(UB_EXARGS,"no nodes specified"); @@ -67,6 +58,7 @@ GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriF /*=======================================================================*/ GbTriFaceMesh3D::~GbTriFaceMesh3D() { + UBLOG(logERROR,"~GbTriFaceMesh3D") if( nodes ) { delete nodes; nodes = NULL; } if( triangles ) { delete triangles; triangles = NULL; } if( kdTree ) { delete kdTree; kdTree = NULL; } @@ -91,52 +83,16 @@ void GbTriFaceMesh3D::init() x3max = 0.0; x3center = 0.0; consistent = false; + kdTreeValid = false; } -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3D::clone() -{ - vector<GbTriFaceMesh3D::Vertex> *newNodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *newTriangles = new vector<GbTriFaceMesh3D::TriFace>; - - int numberNodes = (int)this->nodes->size(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=(*nodes)[u].x; - y=(*nodes)[u].y; - z=(*nodes)[u].z; - newNodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int numberTris = (int)this->triangles->size(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - id1 = (*this->triangles)[u].v1; - id2 = (*this->triangles)[u].v2; - id3 = (*this->triangles)[u].v3; - newTriangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D("no name", newNodes, newTriangles); - UBLOG(logDEBUG1,"mesh cloned ..."); - - return mesh; -} - /*======================================================================*/ //checks for doppelt nodes und fixed Dreicke die zweimal denselben Knoten haben void GbTriFaceMesh3D::deleteRedundantNodes() { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size()); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size()); map<Vertex,size_t/*new vecIndex*/> vertexMap; map<Vertex,size_t/*new vecIndex*/>::iterator pos; - map<Vertex,size_t/*new vecIndex*/>::iterator it; vector<TriFace>& tris = *this->triangles; vector<Vertex>& oldNodes = *this->nodes; @@ -144,25 +100,12 @@ void GbTriFaceMesh3D::deleteRedundantNodes() for(size_t t=0; t<tris.size(); t++) { - if(t%100==0) UBLOG(logDEBUG5,"GbTriFaceMesh3D::deleteRedundantNodes - tri: "<<(t)<<" von "<<tris.size()); TriFace& tri = tris[t]; //Knoten bereits in neuem node vector? for(int v=0; v<=2; v++) { Vertex& vert = tri.getNode(v,oldNodes); - //pos=vertexMap.find( vert ); - //if( pos==vertexMap.end() ) - { - for(pos=vertexMap.begin();pos!=vertexMap.end();pos++) - { - Vertex rhs = pos->first; - //if(UbMath::inClosedInterval(vert.z,0.01999, 0.02001)) - if ( fabs(vert.x-rhs.x)<1.E-5 && fabs(vert.y-rhs.y)<1.E-5 && fabs(vert.z-rhs.z)<1.E-5 ) - { - break; - } - } - } + pos=vertexMap.find( vert ); if( pos!=vertexMap.end() ) tri.setNode(v, (int)pos->second); else { @@ -176,56 +119,8 @@ void GbTriFaceMesh3D::deleteRedundantNodes() std::swap(*nodes,newNodes); - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size()); - // - //Das geht irgendwie nicht ... - // - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for double triangles !!!"); - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles before deleting redundant: "<<this->triangles->size()); - //vector<TriFace> newSingleTris; - //newSingleTris.reserve( this->triangles->size() ); - //for(size_t t=0; t<tris.size(); t++) - //{ - // Vertex& v1 = tris[t].getNode(0,*nodes); - // Vertex& v2 = tris[t].getNode(1,*nodes); - // Vertex& v3 = tris[t].getNode(2,*nodes); - - // if(UbMath::greater(std::fabs(v1.x), 0.0634) && UbMath::inClosedInterval(v1.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V1:"<<v1.x<<" "<<v1.y<<" "<<v1.z); - // } - // if(UbMath::greater(std::fabs(v2.x), 0.0634) && UbMath::inClosedInterval(v2.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V2:"<<v2.x<<" "<<v2.y<<" "<<v2.z); - // } - // if(UbMath::greater(std::fabs(v3.x), 0.0634) && UbMath::inClosedInterval(v3.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V3:"<<v3.x<<" "<<v3.y<<" "<<v3.z); - // } - - // bool inList = false; - // for(size_t u=0; u<newSingleTris.size(); u++) - // { - // Vertex& vn1 = newSingleTris[t].getNode(0,*nodes); - // Vertex& vn2 = newSingleTris[t].getNode(1,*nodes); - // Vertex& vn3 = newSingleTris[t].getNode(2,*nodes); - - // if(v1==vn1 && v2==vn2 && v3==vn3) inList = true; - // else if(v1==vn1 && v2==vn3 && v3==vn2) inList = true; - // else if(v1==vn2 && v2==vn3 && v3==vn1) inList = true; - // else if(v1==vn2 && v2==vn1 && v3==vn3) inList = true; - // else if(v1==vn3 && v2==vn1 && v3==vn2) inList = true; - // else if(v1==vn3 && v2==vn2 && v3==vn1) inList = true; - // } - // if(!inList) newSingleTris.push_back(tris[t]); - // else - // UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - inList !!!!"); - - //} - //swap(tris,newSingleTris); - - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles after deleting redundant:"<<this->triangles->size()); - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!"); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size()); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!"); int counter1 = 0; int counter2 = 0; vector<TriFace> newTris; @@ -247,23 +142,23 @@ void GbTriFaceMesh3D::deleteRedundantNodes() } if(counter1) { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter1<<" triangle with double nodes!"); + UBLOG(logWARNING,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter1<<" triangle with double nodes!"); } if(counter2) { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter2<<" triangle that are lines!") ; + UBLOG(logWARNING,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter2<<" triangle that are lines!") ; } - if(!counter1 && !counter2) { UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); } + if(!counter1 && !counter2) { UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); } else swap(tris,newTris); - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - done" ); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes - done" ); this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode) -{ - if(kdTree && mode != this->kdtreeSplitAlg) { delete kdTree; kdTree = NULL; } - this->kdtreeSplitAlg = mode; + + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes !!! Falls das FeTriFaceMesh verwendet wird !!!"); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes !!! und darin die VertexTriFaceMap !!!"); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes !!! dann muss diese neu erzeugt werden !!!"); + UBLOG(logINFO,"GbTriFaceMesh3D::deleteRedundantNodes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } /*======================================================================*/ /** @@ -288,10 +183,7 @@ vector<GbTriFaceMesh3D::Vertex>* GbTriFaceMesh3D::getNodes() { return thi * @return the triangles of this triangular mesh */ vector<GbTriFaceMesh3D::TriFace>* GbTriFaceMesh3D::getTriangles() { return this->triangles; } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ +/*===============================================*/ double GbTriFaceMesh3D::getVolume() { vector<Vertex>& vertices = *nodes; @@ -434,18 +326,16 @@ void GbTriFaceMesh3D::calculateValues() for(size_t i=1; i<this->nodes->size(); i++) { Vertex& v1 = (*nodes)[i]; - x1min = UbMath::min<double>(x1min,v1.x); - x2min = UbMath::min<double>(x2min,v1.y); - x3min = UbMath::min<double>(x3min,v1.z); - x1max = UbMath::max<double>(x1max,v1.x); + x2min = UbMath::min<double>(x2min,v1.y); x2max = UbMath::max<double>(x2max,v1.y); + x3min = UbMath::min<double>(x3min,v1.z); x3max = UbMath::max<double>(x3max,v1.z); } - x1center = 0.5 * (x1min + x1max ); - x2center = 0.5 * (x2min + x2max ); - x3center = 0.5 * (x3min + x3max ); + x1center = 0.5*(x1min+x1max); + x2center = 0.5*(x2min+x2max); + x3center = 0.5*(x3min+x3max); vector<TriFace>& tris = *this->triangles; vector<Vertex>& verts = *this->nodes; @@ -465,18 +355,45 @@ void GbTriFaceMesh3D::calculateValues() } } } - if(kdTree) - { - delete kdTree; - kdTree=NULL; - } - this->consistent = true; + + // Need to rebuild kd-tree. + kdTreeValid=false; +} + +void GbTriFaceMesh3D::generateKdTree() +{ + ////////////////////////////////////////////////////////////////////////// + //ACHTUNG: kdTree MUSS hier erfolgen (nach this->consistent = true; da der kdTree auf Methodes des GbTriFaceMesh zurück greift) + if (!consistent) calculateValues(); + + if( !nodes->empty() ) + { + UBLOG(logDEBUG1, "GbTriFaceMesh3D::calculateValues - build KdTree start"); + + if(kdTree) delete kdTree; + + UbTimer timer; timer.start(); + if(kdtreeSplitAlg == KDTREE_SHAPLIT ) + { + UBLOG(logDEBUG1, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); + this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); + } + else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) + { + UBLOG(logDEBUG1, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); + this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); + } + else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); + std::cout<<"GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"<<std::endl; + //UBLOG(logDEBUG1, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); + } + kdTreeValid = true; } /*=========================================================================*/ std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Vertex* vertex) { - if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false;} + if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false; } if(!consistent) this->calculateValues(); typedef std::multimap<Vertex*,TriFace*>::iterator Iterator; @@ -488,71 +405,79 @@ std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Ve return tmpTris; } -/*=======================================================*/ -void GbTriFaceMesh3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} /*======================================================================*/ -void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), sx1, sx2, sx3, 0, 0, 0); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} +void GbTriFaceMesh3D::transform(const double matrix[4][4]) + { + if(!this->consistent) this->calculateValues(); + vector<Vertex>& vertices = *nodes; + float tempX = 0.f; + float tempY = 0.f; + float tempZ = 0.f; + + for(size_t i=0; i<vertices.size(); i++) + { + Vertex& v = vertices[i]; + tempX = v.x; + tempY = v.y; + tempZ = v.z; + v.x = (float)(matrix[0][0] * tempX + matrix[0][1] * tempY + matrix[0][2] * tempZ + matrix[0][3] * 1.); + v.y = (float)(matrix[1][0] * tempX + matrix[1][1] * tempY + matrix[1][2] * tempZ + matrix[1][3] * 1.); + v.z = (float)(matrix[2][0] * tempX + matrix[2][1] * tempY + matrix[2][2] * tempZ + matrix[2][3] * 1.); + } + this->calculateValues(); + this->notifyObserversObjectChanged(); + } /*======================================================================*/ void GbTriFaceMesh3D::rotate(const double& alpha, const double& beta, const double& gamma) { - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, alpha, beta, gamma); + if(!this->consistent) this->calculateValues(); + double a1 = this->getX1Centroid(); + double a2 = this->getX2Centroid(); + double a3 = this->getX3Centroid(); + CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); + CoordinateTransformation3D trafoBack(a1, a2, a3, 1.0, 1.0, 1.0, alpha, beta, gamma); vector<Vertex>& vertices = *nodes; for(size_t i=0; i<vertices.size(); i++) { Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); + double p1x1 = trafoFor.transformForwardToX1Coordinate(v.x, v.y, v.z); + double p1x2 = trafoFor.transformForwardToX2Coordinate(v.x, v.y, v.z); + double p1x3 = trafoFor.transformForwardToX3Coordinate(v.x, v.y, v.z); v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); } this->calculateValues(); + this->notifyObserversObjectChanged(); } + /*======================================================================*/ -void GbTriFaceMesh3D::rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma) +void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3) { - CoordinateTransformation3D trafoForw(px1, px2, px3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(px1, px2, px3, 1.0, 1.0, 1.0, alpha, beta, gamma); + if(!this->consistent) this->calculateValues(); + double a1 = this->getX1Centroid(); + double a2 = this->getX2Centroid(); + double a3 = this->getX3Centroid(); + CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); + CoordinateTransformation3D trafoBack(a1, a2, a3, sx1, sx2, sx3, 0.0, 0.0, 0.0); vector<Vertex>& vertices = *nodes; for(size_t i=0; i<vertices.size(); i++) { Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); + double p1x1 = trafoFor.transformForwardToX1Coordinate(v.x, v.y, v.z); + double p1x2 = trafoFor.transformForwardToX2Coordinate(v.x, v.y, v.z); + double p1x3 = trafoFor.transformForwardToX3Coordinate(v.x, v.y, v.z); v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); } this->calculateValues(); + this->notifyObserversObjectChanged(); } - /*======================================================================*/ void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double& x3) { @@ -560,16 +485,17 @@ void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double for(size_t i=0; i<vertices.size(); i++) { Vertex& v = vertices[i]; - v.x += static_cast<float>(x1); - v.y += static_cast<float>(x2); - v.z += static_cast<float>(x3); + v.x+=static_cast<float>(x1); + v.y+=static_cast<float>(x2); + v.z+=static_cast<float>(x3); } this->calculateValues(); + this->notifyObserversObjectChanged(); } /*======================================================================*/ vector<GbTriangle3D*> GbTriFaceMesh3D::getSurfaceTriangleSet() { - //SirAnn: eine miese Speicherlochmethode + //SirAnn: eine miese Spciehrflochmethode // hier werden dynmamische Objekte angelegt // mit sowas rechnet von aussen kein Mensch!!! vector<GbTriangle3D*> tris( triangles->size() ); @@ -602,327 +528,69 @@ void GbTriFaceMesh3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& pts, vector<U } } /*======================================================================*/ -//bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) -//{ -// -// -// if( !nodes->empty() ) -// { -// //Baum erstellen, wen noch keiner vorhanden -// if( !kdTree) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); -// UbTimer timer; timer.start(); -// if(kdtreeSplitAlg == KDTREE_SAHPLIT ) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); -// } -// else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); -// } -// else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); -// } -// -// //eigentlicher PIO-Test -// //int iSec; -// //for(int i=0; i<100; i++) -// //{ -// // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); -// // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); -// // -// // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); -// // -// // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen -// // { -// // if(iSec == Kd::Intersection::ON_BOUNDARY ) -// // { -// // return true; -// // } -// // return (iSec&1); //ungerade anzahl an schnitten --> drinnen -// // } -// // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); -// //} -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// int iSec1,iSec2; -// -// Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); -// iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); -// Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); -// iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); -// -// if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) -// { -// return true; -// } -// if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec2&1); -// } -// else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec1&1); -// } -// else -// { -// if((iSec1&1) != (iSec2&1)) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// return iSec1&1; -// } -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// -// } -// return false; -//} -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) +bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) { + if (!kdTreeValid) generateKdTree(); - - if( !nodes->empty() ) + int iSec; + for(int i=0; i<100; i++) { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) + Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); + , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) + , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) + , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); + + iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); + + if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) + if(iSec == Kd::Intersection::ON_BOUNDARY ) { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); + return true; } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - //int iSec; - //for(int i=0; i<100; i++) - //{ - // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - // - // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - // - // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - // { - // if(iSec == Kd::Intersection::ON_BOUNDARY ) - // { - // return true; - // } - // return (iSec&1); //ungerade anzahl an schnitten --> drinnen - // } - // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - //} - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - int iSec1,iSec2; - double eps = 0.05; - Kd::Ray<double> ray1( x1, x2, x3, 1.0+eps*((double)counter), eps*((double)counter) ,eps*((double)counter) ); - iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - Kd::Ray<double> ray2( x1, x2, x3, -1.0-eps*((double)counter), -eps*((double)counter) ,-eps*((double)counter) ); - - iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - { - return true; - } - if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec2&1); + return (iSec&1); //ungerade anzahl an schnitten --> drinnen } - else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec1&1); - } - else - { - if((iSec1&1) != (iSec2&1)) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - return iSec1&1; - } - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - + UBLOG(logWARNING, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); } - return false; + throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); } /*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) +bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) { - int counter=0; - - if( !nodes->empty() ) + if (!kdTreeValid) generateKdTree(); + + int iSec; + for(int i=0; i<100; i++) { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } + Kd::Ray<double> ray( x1, x2, x3 + , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) + , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) + , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) ); + + iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<MAX_ITER; i++) + if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen { - Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen + if(iSec == Kd::Intersection::ON_BOUNDARY ) { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - return true; - } - return (iSec&1); //ungerade anzahl an schnitten --> drinnen + pointIsOnBoundary = true; + return true; } - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); + pointIsOnBoundary = false; + return (iSec&1); //ungerade anzahl an schnitten --> drinnen } - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - // int iSec1,iSec2; - // - // Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); - // iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - // Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); - // iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - // if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - // { - // return true; - // } - // if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec2&1); - // } - // else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec1&1); - // } - // else - // { - // if((iSec1&1) != (iSec2&1)) - // { - // UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // return iSec1&1; - // } - // //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - return false; + + throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); } /*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) +bool GbTriFaceMesh3D::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) { - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } + if (!kdTreeValid) generateKdTree(); - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<MAX_ITER; i++) - { - Kd::Ray<double> ray( x1, x2, x3 - , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - pointIsOnBoundary = true; - return true; - } - pointIsOnBoundary = false; - return (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - } + int iSec = kdTree->intersectLine( UbTupleDouble3(p1_x1, p1_x2, p1_x3), UbTupleDouble3(p2_x1, p2_x2, p2_x3), Kd::CountLineIntersectionHandler<double>() ); - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - - return false; + return (iSec != Kd::Intersection::NO_INTERSECTION); } /*======================================================================*/ GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) @@ -933,96 +601,69 @@ GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& po 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++) { - //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() ); + Vertex& v = vertices[i]; + out->writeFloat(v.x); + out->writeFloat(v.y); + out->writeFloat(v.z); 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 + + //triangles + vector<TriFace>& tris = *triangles; + out->writeSize_t( tris.size() ); + out->writeLine(); + for(size_t i=0; i<tris.size(); i++) { - out->writeString(filename); + TriFace& t = tris[i]; + out->writeInteger(t.v1); + out->writeInteger(t.v2); + out->writeInteger(t.v3); 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++) { - 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( ) ); + Vertex& v = vertices[i]; + v.x = in->readFloat(); + v.y = in->readFloat(); + v.z = in->readFloat(); 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 + + //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++) { - filename = in->readString(); + TriFace& t = tris[i]; + t.v1 = in->readInteger(); + t.v2 = in->readInteger(); + t.v3 = in->readInteger(); in->readLine(); - transX1 = in->readDouble(); - transX2 = in->readDouble(); - transX3 = in->readDouble(); - - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); } + + this->calculateValues(); } /*======================================================================*/ UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata ) @@ -1059,10 +700,9 @@ UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* wr lineNodes[i*2 ] = makeUbTuple( triangle.getX1Centroid(*nodes) ,triangle.getX2Centroid(*nodes) ,triangle.getX3Centroid(*nodes)); - - lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.0*triangle.nx) - ,(float)(triangle.getX2Centroid(*nodes)+1.0*triangle.ny) - ,(float)(triangle.getX3Centroid(*nodes)+1.0*triangle.nz)); + lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.*triangle.nx) + ,(float)(triangle.getX2Centroid(*nodes)+1.*triangle.ny) + ,(float)(triangle.getX3Centroid(*nodes)+1.*triangle.nz)); lines[i] = makeUbTuple((int)i*2,(int)i*2+1); } @@ -1072,156 +712,3 @@ UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* wr return filenames; } /*======================================================================*/ -void GbTriFaceMesh3D::writeMeshPly( const std::string& filename) -{ - ofstream out(filename.c_str() ); - if( !out ) - throw UbException(UB_EXARGS, "couldn't open " + filename); - - out << "ply" << endl; - out << "format ascii 1.0" << endl; - out << "element vertex " << (int)nodes->size() << endl; - out << "property float x" << endl; - out << "property float y" << endl; - out << "property float z" << endl; - out << "element face " << (int)triangles->size() << endl; - out << "property list uchar int vertex_indices" << endl; - out << "end_header" << endl; - - for(size_t i=0; i<nodes->size(); i++) - out << (*nodes)[i].x << " " << (*nodes)[i].y << " " << (*nodes)[i].z << endl; - - for(size_t i=0; i<triangles->size(); i++) - out << "3 " << (*triangles)[i].v1 << " " << (*triangles)[i].v2 << " " << (*triangles)[i].v3 << endl; -} -/*======================================================================*/ -void GbTriFaceMesh3D::readMeshFromSTLFile(string filename, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - UbFileInputASCII in(filename); - //this->nodes = new vector<GbTriFaceMesh3D::Vertex>; - //this->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; - } - if(removeRedundantNodes) - { - this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen - } - else - { - this->calculateValues(); - } -} -////////////////////////////////////////////////////////////////////////// -//void GbTriFaceMesh3D::writeMeshToSTLFile(string filename, bool isBinaryFormat) -//{ -// vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; -// vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; -// int nr=0; -// -// if (!isBinaryFormat) { -// ofstream out(filename.c_str()); -// if (!out.good()) -// { -// delete nodes; -// delete triangles; -// UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); -// } -// char title[80] = "ASCII"; -// std::string s0, s1; -// float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8; -// out.write(title, 80); -// size_t size = nodes->size(); -// for (size_t i = 0; i < size) -// { -// out << nodes[i++] -// 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; -//} -////////////////////////////////////////////////////////////////////////// diff --git a/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.h b/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.h index 1b6a5f5db..470c31eee 100644 --- a/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.h +++ b/src/VirtualFluidsBasics/numerics/geometry3d/GbTriFaceMesh3D.h @@ -10,20 +10,18 @@ #include <sstream> #include <iostream> #include <vector> +#include <map> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - +#include <VirtualFluidsDefinitions.h> #include <basics/utilities/UbException.h> #include <basics/utilities/UbMath.h> -#include <basics/writer/WbWriter.h> -#include <basics/memory/MbSmartPtr.h> -#include <numerics/geometry3d/GbPoint3D.h> #include "basics/utilities/Vector3D.h" +#include "GbObject3D.h" + +class WbWriter; namespace Kd { @@ -44,7 +42,7 @@ namespace Kd * Note, that up to now no methods for checking consistency are included. * in this context this class describes facettes from an 3D-object !!! */ -class GbTriFaceMesh3D : public GbObject3D +class VF_PUBLIC GbTriFaceMesh3D : public GbObject3D { public: // nested class start @@ -191,12 +189,12 @@ public: //GbVector3D AC = C-A; //GbVector3D N = AB.Cross(AC); //return 0.5*N.Length(); - Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); - Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); - Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); - Vector3D AB = B-A; - Vector3D AC = C-A; - Vector3D N = AB.Cross(AC); + Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); + Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); + Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); + Vector3D AB = B - A; + Vector3D AC = C - A; + Vector3D N = AB.Cross(AC); return 0.5*N.Length(); } void calculateNormal(std::vector<Vertex>& nodes) diff --git a/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp index a39bf633a..3d935050b 100644 --- a/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp +++ b/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp @@ -20,8 +20,6 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, strin //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); @@ -52,7 +50,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, s } int numVertices = in->readInteger(); - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); + UBLOG(logINFO,"Number of vertices "<<numVertices); nodes->resize(numVertices); @@ -65,7 +63,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, s in->readLine(); (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); + UBLOG(logINFO," - read vertices (#"<<numVertices<<") done"); while( !in->eof() ) { @@ -75,7 +73,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, s } int numFaces = in->readInteger(); triangles->reserve(numFaces); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); + UBLOG(logINFO,"Number of faces "<<numFaces); int j,k,l; for(int i=0; i<numFaces; i++) @@ -87,7 +85,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, s (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l)); } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); + UBLOG(logINFO," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes ); @@ -114,8 +112,8 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, st int numFaces = in->readIntegerAfterString("element face"); in->setPosAfterLineWithString("end_header"); - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); + UBLOG(logINFO,"Number of vertices "<<numVertices); + UBLOG(logINFO,"Number of faces "<<numFaces); nodes->resize(numVertices); triangles->reserve(numFaces); @@ -131,7 +129,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, st in->readLine(); (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); + UBLOG(logINFO," - read vertices (#"<<numVertices<<") done"); int p,j,k,l,n; onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); @@ -178,7 +176,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, st in->readLine(); } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); + UBLOG(logINFO," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); @@ -194,7 +192,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, st /*======================================================================*/ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) { - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); + UBLOG(logINFO,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; @@ -232,89 +230,119 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, st 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::readMeshFromMeshFile(string filename, string meshName, bool removeRedundantNodes) +// { +// public static void read(String file, ArrayList<Node3d> nodeList, ArrayList<TrianglePatch> patches) throws FileReaderException { +// +// UBLOG(logINFO,"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; +// } +// +// +// GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); +// +// return mesh; +// +// +// try { +// +// FileInput input = new FileInput(file); +// +// int line = 0; +// while(true) +// { +// if(line>1000) break; +// if(input.readLine().contains("Vertices")) +// break; +// line++; +// } +// +// int num_of_points = input.readInt(); +// +// for (int i = 0; i < num_of_points; i++) { +// float x = (float) input.readDouble(); +// float y = (float) input.readDouble(); +// float z = (float) input.readDouble(); +// int nr = input.readInt(); +// nodeList.add(new Node3d(x, y, z)); +// } +// +// input.skipLine(); +// input.skipLine(); +// int num_of_triangles = input.readInt(); +// +// for (int i = 0; i < num_of_triangles; i++) { +// +// int a = input.readInt(); +// int b = input.readInt(); +// int c = input.readInt(); +// int nr = input.readInt(); +// +// Node3d P1 = nodeList.get(a - 1); +// Node3d P2 = nodeList.get(b - 1); +// Node3d P3 = nodeList.get(c - 1); +// +// patches.add(new TrianglePatch(P1, P2, P3)); +// } +// +// // END reading mesh file +// } +// +// -- +// +// Dipl.-Ing. Sebastian Bindick +// +// Institute for Computational Modeling in Civil Engineering (iRMB) Technische Universität Braunschweig Pockelsstr. 3 (9th Floor) D-38106, Braunschweig, Germany +// +// phone +49 531/391-7598 +// fax +49 531/391-7599 +// email bindick@irmb.tu-bs.de +// web www.irmb.tu-bs.de +// +// /*======================================================================*/ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) { @@ -325,7 +353,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, st /*======================================================================*/ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes) { - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); + UBLOG(logINFO,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; @@ -372,7 +400,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filenam /*======================================================================*/ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) { - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); + UBLOG(logINFO,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; @@ -409,7 +437,7 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *i in->readString(); int numberTris = in->readInteger(); in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); + UBLOG(logINFO,"numberTris:"<<numberTris); int id1,id2,id3; for(int u=0;u<numberTris;u++) @@ -421,10 +449,10 @@ GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *i triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; } - UBLOG(logDEBUG1,"Tris gelesen"); + UBLOG(logINFO,"Tris gelesen"); GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); + UBLOG(logINFO,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); return mesh; diff --git a/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h index 38247cdbe..d2b57f695 100644 --- a/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h +++ b/src/VirtualFluidsBasics/numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h @@ -21,23 +21,22 @@ public: 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* readMeshFromFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, 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* readMeshFromMeshFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); + static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, 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* readMeshFromPLYFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); + static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, 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* readMeshFromSTLFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); + static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=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* readMeshFromAVSFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); + static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, 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); + static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); + static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SHAPLIT, bool removeRedundantNodes=true); GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); } -- GitLab