diff --git a/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.cpp b/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.cpp index 1c66a54db..c89d0c809 100644 --- a/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.cpp +++ b/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.cpp @@ -1183,7 +1183,8 @@ bool SortFaces4DiamondCreation( SubsetHandler& sh, std::vector & assoFac void computeDiamondPointXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, ExpandCrossFracInfo & expCFIAfterFracEdg, Vertex * const & crossPt, Grid::VertexAttachmentAccessor & aaPos, SubsetHandler & sh, Grid & grid, IndexType const & diamantSubsNum, - vector3 & distVecNewVrt2SCrossPt + vector3 & distVecNewVrt2SCrossPt, + bool useTrianglesInDiamonds = false // vector3 & distVecNewVrt2ShiVeBefore = vector3(), vector3 & distVecNewVrt2ShiVeAfter = vector3(), // bool computeDistancesNewVrtsToOldShiVe = false ) @@ -1265,12 +1266,53 @@ void computeDiamondPointXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, E vector3 halfSumShift; - VecScale(halfSumShift,sumShift,0.5); + number scaFa = useTrianglesInDiamonds ? 1 : 0.5; + +// VecScale(halfSumShift, sumShift, 0.5); + VecScale( halfSumShift, sumShift, scaFa ); vector3 posNewVrtOnEdg; VecAdd( posNewVrtOnEdg, posCrossPt, halfSumShift ); + // check if not shifting into the wrong direction TODO FIXME + // if length between posFracEnd and posNewVrtOnEdg bigger than length between posFracEnd and crossPt + // then shifted into the wrong direction, Kommando zurück dann! + +// if( useTrianglesInDiamonds ) +// { + // always + + vector3 distVecOld; + VecSubtract(distVecOld, posFracEnd, posCrossPt ); + vector3 distVecNew; + VecSubtract(distVecNew, posFracEnd, posNewVrtOnEdg); + number oldDistSq = VecLength(distVecOld); + number newDistSq = VecLength(distVecNew); + + if( oldDistSq < newDistSq ) + { + VecScale( halfSumShift, sumShift, - scaFa); + VecAdd(posNewVrtOnEdg, posCrossPt, halfSumShift); + } + else if( oldDistSq == newDistSq ) // cross pt would equal new position + { + if( posNewVrtOnEdg != posCrossPt || distVecNew != distVecOld ) + UG_THROW("Denkfehler, Implementation extemer Spezialfall checken" << std::endl); + + vector3 distCorr; + VecScale( distCorr, distVecOld, 0.05 ); + VecAdd( posNewVrtOnEdg, posCrossPt, distCorr ); + // Versuch, den Punkt ein wenig zu verschieben + } + + // TODO FIXME eventuell noch testen, ob die beiden Punkte in einem kleinen Radius liegen und korrigieren, + // eventuell schon vorher, statt zu werfen + if( posNewVrtOnEdg == posCrossPt ) + UG_THROW("Denkfehler Typ 2, Implementation extemer Spezialfall checken" << std::endl); + +// } + Vertex * newEdgVrtx = *grid.create(); aaPos[newEdgVrtx] = posNewVrtOnEdg; @@ -1326,7 +1368,8 @@ void computeDiamondPointXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, E // } } - +// This function creates the new faces outside the diamond, directly attached to the diamond, +// as part of post processing void createNewFacesForExtXCrossFracs( ExpandCrossFracInfo const & ecf, std::vector & newFracFaceVec, bool & boundAtShiftVrtEdg, //bool & atStartSort, @@ -1529,6 +1572,8 @@ void createNewFacesForExtXCrossFracs( ExpandCrossFracInfo const & ecf, std::vec } +// this function creates the new faces of the diamond center, for XCross, but also for free TEnd type crossing fractures + void createDiamondFacesXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, ExpandCrossFracInfo & expCFIAfterFracEdg, std::vector & newDiamFaceVec, SubsetHandler & sh, Grid & grid, IndexType diamantSubsNum, Vertex * & crossPt, bool isFreeTEnd = false ) @@ -1613,7 +1658,6 @@ void createDiamondFacesXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, Ex vrtxSmallDiamAfter.push_back( shiftVrt ); vrtxSmallDiamAfter.push_back( newVrtAfter ); - Face * newFracFaceBefore = *grid.create( TriangleDescriptor( vrtxSmallDiamBefore[0], vrtxSmallDiamBefore[1], vrtxSmallDiamBefore[2] ) ); @@ -2145,9 +2189,14 @@ void teachAssoFacesNewVrtx( VecVertexOfFaceInfo const & segPart, Grid::FaceAttac #endif bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector const & fracInfos, - bool expandInnerFracBnds, bool expandOuterFracBnds) +// bool expandInnerFracBnds, bool expandOuterFracBnds + bool useTrianglesInDiamonds, bool establishDiamonds +) { + constexpr bool expandInnerFracBnds = false; + constexpr bool expandOuterFracBnds = true; + // for(EdgeIterator iter = sh.begin(1); iter != sh.end(1); ++iter) // { // size_t sm = sh.num_subsets(); @@ -6101,6 +6150,10 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector // return true; + // only Keile, basic system + if( ! establishDiamonds ) + return true; + // alles detachen, was noch attached ist, da ist einiges hinzu gekommen! @@ -6692,7 +6745,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector // shift of free shift point to virtual prolongation of ending fracture center line - computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, sudoTEnd, distVecNewVrt2SCrossPt ); +// computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, sudoTEnd, distVecNewVrt2SCrossPt ); + computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, sudoTEnd, distVecNewVrt2SCrossPt, useTrianglesInDiamonds ); constexpr bool shiftFreePt = false; @@ -6936,6 +6990,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector // create new edges and new faces + // edges and faces outside the diamond, at the crossing fractures attached to the diamond + std::vector newFracFaceVec = std::vector(); bool boundAtShiftVrtEdg = false; @@ -6948,6 +7004,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector createNewFacesForExtXCrossFracs( ecf, newFracFaceVec, boundAtShiftVrtEdg, sh, grid, crossPt, subdomList ); } + // edges and faces of the diamond itself respectively its analogon for the TEnd case here + std::vector newDiamFaceVec = std::vector(); // ExpandCrossFracInfo & expCFIBeforeFracEdg = vecExpCrossFI[ indBeforeT ]; @@ -6973,10 +7031,14 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector ExpandCrossFracInfo & expCFIAfterFracEdg = vecExpCrossFI[ indAfter ]; +// createDiamondFacesXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, +// newDiamFaceVec, sh, grid, sudoTEnd, crossPt, isAtFreeEnd ); createDiamondFacesXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, - newDiamFaceVec, sh, grid, sudoTEnd, crossPt, isAtFreeEnd ); + newDiamFaceVec, sh, grid, sudoTEnd, crossPt, isAtFreeEnd || useTrianglesInDiamonds ); } +// } + std::string diamNam = std::string("spitzDiam_") + std::string(const_cast( sh.get_subset_name( subdomList[0] ) )) @@ -7448,7 +7510,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector vector3 distVecNewVrt2SCrossPt; // not ot interest here, but only with c++17 possible to rule out computation in a clever way - computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, diamantSubsNum, distVecNewVrt2SCrossPt ); +// computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, diamantSubsNum, distVecNewVrt2SCrossPt ); + computeDiamondPointXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, crossPt, aaPos, sh, grid, diamantSubsNum, distVecNewVrt2SCrossPt, useTrianglesInDiamonds ); #if 0 @@ -7800,8 +7863,11 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector // std::vector newDiamFaceVec ) #if 1 +// createDiamondFacesXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, +// newDiamFaceVec, sh, grid, diamantSubsNum, crossPt ); + createDiamondFacesXCrossType( expCFIBeforeFracEdg, expCFIAfterFracEdg, - newDiamFaceVec, sh, grid, diamantSubsNum, crossPt ); + newDiamFaceVec, sh, grid, diamantSubsNum, crossPt, useTrianglesInDiamonds ); #else Face * facBefore = expCFIBeforeFracEdg.getFace(); @@ -8019,20 +8085,31 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector UG_THROW("hier fehlt ein Gesicht " << std::endl); } - for( auto const & edg : allAssoEdgCP ) + if( ! useTrianglesInDiamonds ) // stamdard case { - if( edg != nullptr && edg != avoidToDeleteEdge ) + for( auto const & edg : allAssoEdgCP ) { - UG_LOG("will erasieren " << edg << std::endl ); - grid.erase(edg); + if( edg != nullptr && edg != avoidToDeleteEdge ) + { + UG_LOG("will erasieren " << edg << std::endl ); + grid.erase(edg); + } + else + { + UG_LOG("hier fehlt eine Ecke " << std::endl); + } } - else + } + else + { + for( auto const & edg : origFracEdg ) { - UG_LOG("hier fehlt eine Ecke " << std::endl); + grid.erase(edg); } } + UG_LOG("ALles erasiert " << std::endl); #endif } diff --git a/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.h b/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.h index f2b17fbc9..ecf584f0f 100644 --- a/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.h +++ b/ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.h @@ -46,7 +46,7 @@ namespace ug * */ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, std::vector const & fracInfos, - bool expandInnerFracBnds, bool expandOuterFracBnds ); + bool useTrianglesInDiamonds, bool establishDiamonds );