edgesThis.push_back(tmpp2[i+1]);
}
}
+
+void Edge::fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+ std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
+{
+ int tmp[2];
+ _start->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp);
+ _end->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp+1);
+ if(direction)
+ {
+ edgesThis.push_back(tmp[0]);
+ edgesThis.push_back(tmp[1]);
+ }
+ else
+ {
+ edgesThis.push_back(tmp[1]);
+ edgesThis.push_back(tmp[0]);
+ }
+}
+
+void Edge::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+ std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
+{
+ _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
+ _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
+}
public:
bool sortSubNodesAbs(const double *coo, std::vector<int>& subNodes);
void sortIdsAbs(const std::vector<INTERP_KERNEL::Node *>& addNodes, const std::map<INTERP_KERNEL::Node *, int>& mapp1, const std::map<INTERP_KERNEL::Node *, int>& mapp2, std::vector<int>& edgesThis);
- virtual void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const = 0;
- virtual void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const = 0;
virtual Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const = 0;
+ void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+ std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
+ void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
+ std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
+
protected:
Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { }
virtual ~Edge();
if(IsIn2Pi(_angle0,_angle,M_PI))
_bounds[0]=_center[0]-_radius;
}
-
-void EdgeArcCircle::fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
-{
- int tmp[2];
- _start->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp);
- _end->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp+1);
- if(direction)
- {
- edgesThis.push_back(tmp[0]);
- edgesThis.push_back(tmp[1]);
- }
- else
- {
- edgesThis.push_back(tmp[1]);
- edgesThis.push_back(tmp[0]);
- }
-}
-
-void EdgeArcCircle::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
-{
- _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
- _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
-}
protected:
void updateBounds();
Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction=true) const;
- void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
- void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
+
protected:
//! Absolute angle where the arc starts. Value between -Pi and Pi
double _angle0;
*/
bool SegSegIntersector::areColinears() const
{
- Bounds b;
- b.prepareForAggregation();
- b.aggregate(_e1.getBounds());
- b.aggregate(_e2.getBounds());
- double determinant=_matrix[0]*_matrix[3]-_matrix[1]*_matrix[2];
- double dimChar=b.getCaracteristicDim();
+// Bounds b;
+// b.prepareForAggregation();
+// b.aggregate(_e1.getBounds());
+// b.aggregate(_e2.getBounds());
+// double dimChar=b.getCaracteristicDim();
- return fabs(determinant)< 2.*dimChar*QuadraticPlanarPrecision::getPrecision(); // same criteria as in areOverlappedOrOnlyColinears, see comment below
+ double determinant=_matrix[0]*_matrix[3]-_matrix[1]*_matrix[2];
+ Bounds b1, b2;
+ b1.prepareForAggregation();
+ b2.prepareForAggregation();
+ b1.aggregate(_e1.getBounds());
+ b2.aggregate(_e2.getBounds());
+ double dimCharE1(b1.getCaracteristicDim()) ,dimCharE2(b2.getCaracteristicDim());
+
+// return fabs(determinant)< 2.*dimChar*QuadraticPlanarPrecision::getPrecision(); // same criteria as in areOverlappedOrOnlyColinears, see comment below
+ return fabs(determinant)< 2.*dimCharE1*dimCharE2*QuadraticPlanarPrecision::getPrecision(); // same criteria as in areOverlappedOrOnlyColinears, see comment below
}
/*!
void SegSegIntersector::areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped)
{
double determinant=_matrix[0]*_matrix[3]-_matrix[1]*_matrix[2];
- Bounds b;
- b.prepareForAggregation();
- b.aggregate(_e1.getBounds());
- b.aggregate(_e2.getBounds());
- double dimChar=b.getCaracteristicDim();
+ Bounds b1, b2;
+ b1.prepareForAggregation();
+ b2.prepareForAggregation();
+ b1.aggregate(_e1.getBounds());
+ b2.aggregate(_e2.getBounds());
+ double dimCharE1(b1.getCaracteristicDim()) ,dimCharE2(b2.getCaracteristicDim());
// Same criteria as in areColinears(), see doc.
// [ABN] the 2 is not really justified, but the initial tests from Tony were written so closely to precision that I can't bother to change all of them ...
- if(fabs(determinant)>2.*dimChar*QuadraticPlanarPrecision::getPrecision())
+ if(fabs(determinant)>2.*dimCharE1*dimCharE2*QuadraticPlanarPrecision::getPrecision())
{
obviousNoIntersection=false; areOverlapped=false;
_matrix[0]/=determinant; _matrix[1]/=determinant; _matrix[2]/=determinant; _matrix[3]/=determinant;
}
else // colinear vectors
{
- double x=(*(_e1.getStartNode()))[0]-(*(_e2.getStartNode()))[0];
- double y=(*(_e1.getStartNode()))[1]-(*(_e2.getStartNode()))[1]; // (x,y) is the vector between the two start points of e1 and e2
- areOverlapped = fabs(-_matrix[0]*y+_matrix[1]*x) < dimChar*QuadraticPlanarPrecision::getPrecision(); // test colinearity of (x,y) with e1
-
+ // Compute vectors joining tips of e1 and e2
+ double xS=(*(_e1.getStartNode()))[0]-(*(_e2.getStartNode()))[0];
+ double yS=(*(_e1.getStartNode()))[1]-(*(_e2.getStartNode()))[1];
+ double xE=(*(_e1.getEndNode()))[0]-(*(_e2.getEndNode()))[0];
+ double yE=(*(_e1.getEndNode()))[1]-(*(_e2.getEndNode()))[1];
+ double maxDimS(std::max(fabs(xS),fabs(yS))), maxDimE(std::max(fabs(xE), fabs(yE)));
+ bool isS = (maxDimS > maxDimE), isE1 = (dimCharE1 >= dimCharE2);
+ double x = isS ? xS : xE;
+ double y = isS ? yS : yE;
+ unsigned shift = isE1 ? 0 : 2;
+ // test colinearity of the greatest tip-joining vector and greatest vector among {e1, e2}
+ areOverlapped = fabs(x*_matrix[1+shift]-y*_matrix[0+shift]) < dimCharE1*dimCharE2*QuadraticPlanarPrecision::getPrecision();
+ if (areOverlapped)
+ {
+ std::cout << "ARE OVER\n";
+ std::cout << maxDimS << " " << maxDimE << " " << dimCharE1 << " " << dimCharE2 << "\n";
+ }
// explanation: if areOverlapped is true, we don't know yet if there will be an intersection (see meaning of areOverlapped in method doxy above)
// if areOverlapped is false, we have two colinear vectors, not lying on the same line, so we're sure there is no intersec
obviousNoIntersection = !areOverlapped;
double car1_1y=node[1]-(*(_start))[1]; double car1_2y=(*(_end))[1]-(*(_start))[1];
return (car1_1x*car1_2x+car1_1y*car1_2y)/(car1_2x*car1_2x+car1_2y*car1_2y);
}
-
-void EdgeLin::fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
-{
- int tmp[2];
- _start->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp);
- _end->fillGlobalInfoAbs(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,tmp+1);
- if(direction)
- {
- edgesThis.push_back(tmp[0]);
- edgesThis.push_back(tmp[1]);
- }
- else
- {
- edgesThis.push_back(tmp[1]);
- edgesThis.push_back(tmp[0]);
- }
-}
-
-void EdgeLin::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
-{
- _start->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
- _end->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,addCoo,mapAddCoo,edgesOther);
-}
EdgeLin() { }
void updateBounds();
Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const;
- void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
- void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
- std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
};
}
for(itOther.first();!itOther.finished();itOther.next(),i++)
{
// For each edge of 'other', proceed with intersections: the edge might split into sub-edges, 'otherTmp' will hold the final split result.
+ std::cout << " with tool seg #" << otherEdgeIds[i] << "\n";
QuadraticPolygon otherTmp;
ElementaryEdge* curOther=itOther.current();
otherTmp.pushBack(new ElementaryEdge(curOther->getPtr(),curOther->getDirection())); curOther->getPtr()->incrRef();
{
ElementaryEdge* curOtherTmp=itOtherTmp.current();
if(!curOtherTmp->isThereStartPoint())
- itThis.first();
+ itThis.first(); // rewind iterator on 'this'
else
itThis=curOtherTmp->getIterator();
for(;!itThis.finished();)
{
if(!curThis->getDirection()) cThis->reverse();
if(!curOtherTmp->getDirection()) cOther->reverse();
+ // Substitution of a single simple edge by two sub-edges resulting from the intersection
+ // First modify the edges currently pointed by itThis and itOtherTmp so that the newly created node becomes the end of the previous sub-edge and the beginning of the next one
UpdateNeighbours(merge,itThis,itOtherTmp,cThis,cOther);
- //Substitution of simple edge by sub-edges.
delete curThis; // <-- destroying simple edge coming from pol1
delete curOtherTmp; // <-- destroying simple edge coming from pol2
+ // Then insert second part of the intersection
itThis.insertElemEdges(cThis,true); // <-- 2nd param is true to go next.
itOtherTmp.insertElemEdges(cOther,false); // <-- 2nd param is false to avoid to go next.
curOtherTmp=itOtherTmp.current();
//
- itThis.assignMySelfToAllElems(cOther);//To avoid that others
+ itThis.assignMySelfToAllElems(cOther);
SoftDelete(cThis);
SoftDelete(cOther);
cThis=new ComposedEdge;
int offset2(offset1+m2Desc->getNumberOfNodes());
for(int i=0;i<nDescCell1;i++) // for all edges in the first mesh
{
+ std::cout << "Base seg #" << i << "\n";
std::vector<int> candidates2; // edges of mesh2 candidate for intersection
myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
if(!candidates2.empty()) // candidates2 holds edges from the second mesh potentially intersecting current edge i in mesh1
revDesc1->decrRef(); revDescIndx1->decrRef(); revDesc2->decrRef(); revDescIndx2->decrRef();
MCAuto<DataArrayInt> dd1(desc1),dd2(descIndx1),dd3(desc2),dd4(descIndx2);
MCAuto<MEDCouplingUMesh> dd5(m1Desc),dd6(m2Desc);
+// subDiv2[4].push_back(12);subDiv2[4].push_back(14);
+// subDiv2[5][0] = 12; subDiv2[5].push_back(15);
// Step 2: re-order newly created nodes according to the ordering found in m2
std::vector< std::vector<int> > intersectEdge2;