Skip to content

Commit

Permalink
Arte 2D ready for use
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus committed Oct 6, 2024
1 parent 93e58a8 commit ca96fdc
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 16 deletions.
107 changes: 92 additions & 15 deletions ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,8 @@ bool SortFaces4DiamondCreation( SubsetHandler& sh, std::vector<Face *> & assoFac
void computeDiamondPointXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, ExpandCrossFracInfo & expCFIAfterFracEdg,
Vertex * const & crossPt, Grid::VertexAttachmentAccessor<APosition> & aaPos,
SubsetHandler & sh, Grid & grid, IndexType const & diamantSubsNum,
vector3 & distVecNewVrt2SCrossPt
vector3 & distVecNewVrt2SCrossPt,
bool useTrianglesInDiamonds = false
// vector3 & distVecNewVrt2ShiVeBefore = vector3(), vector3 & distVecNewVrt2ShiVeAfter = vector3(),
// bool computeDistancesNewVrtsToOldShiVe = false
)
Expand Down Expand Up @@ -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<RegularVertex>();
aaPos[newEdgVrtx] = posNewVrtOnEdg;

Expand Down Expand Up @@ -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<Face*> & newFracFaceVec,
bool & boundAtShiftVrtEdg, //bool & atStartSort,
Expand Down Expand Up @@ -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<Face*> & newDiamFaceVec, SubsetHandler & sh, Grid & grid, IndexType diamantSubsNum, Vertex * & crossPt,
bool isFreeTEnd = false )
Expand Down Expand Up @@ -1613,7 +1658,6 @@ void createDiamondFacesXCrossType( ExpandCrossFracInfo & expCFIBeforeFracEdg, Ex
vrtxSmallDiamAfter.push_back( shiftVrt );
vrtxSmallDiamAfter.push_back( newVrtAfter );


Face * newFracFaceBefore =
*grid.create<Triangle>( TriangleDescriptor( vrtxSmallDiamBefore[0], vrtxSmallDiamBefore[1], vrtxSmallDiamBefore[2] ) );

Expand Down Expand Up @@ -2145,9 +2189,14 @@ void teachAssoFacesNewVrtx( VecVertexOfFaceInfo const & segPart, Grid::FaceAttac
#endif

bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo> 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<Edge>(1); iter != sh.end<Edge>(1); ++iter)
// {
// size_t sm = sh.num_subsets();
Expand Down Expand Up @@ -6101,6 +6150,10 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>

// return true;

// only Keile, basic system
if( ! establishDiamonds )
return true;

// alles detachen, was noch attached ist, da ist einiges hinzu gekommen!


Expand Down Expand Up @@ -6692,7 +6745,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>

// 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;

Expand Down Expand Up @@ -6936,6 +6990,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>

// create new edges and new faces

// edges and faces outside the diamond, at the crossing fractures attached to the diamond

std::vector<Face*> newFracFaceVec = std::vector<Face*>();

bool boundAtShiftVrtEdg = false;
Expand All @@ -6948,6 +7004,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>
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<Face*> newDiamFaceVec = std::vector<Face*>();

// ExpandCrossFracInfo & expCFIBeforeFracEdg = vecExpCrossFI[ indBeforeT ];
Expand All @@ -6973,10 +7031,14 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>
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<char*>( sh.get_subset_name( subdomList[0] ) ))
Expand Down Expand Up @@ -7448,7 +7510,8 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>

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

Expand Down Expand Up @@ -7800,8 +7863,11 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>
// std::vector<Face*> 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();
Expand Down Expand Up @@ -8019,20 +8085,31 @@ bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, vector<FractureInfo>
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
}
Expand Down
2 changes: 1 addition & 1 deletion ugbase/lib_grid/algorithms/extrusion/expand_layers_arte.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ug
*
*/
bool ExpandFractures2dArte( Grid& grid, SubsetHandler& sh, std::vector<FractureInfo> const & fracInfos,
bool expandInnerFracBnds, bool expandOuterFracBnds );
bool useTrianglesInDiamonds, bool establishDiamonds );



Expand Down

0 comments on commit ca96fdc

Please sign in to comment.