From 4aa8378d9baee5bf2727f1ea43831e9047a6bc4e Mon Sep 17 00:00:00 2001 From: vsk Date: Mon, 18 Nov 2024 15:10:25 +0100 Subject: [PATCH] Changes from RevEng --- .../GoTools/compositemodel/ftPointSet.h | 5 + .../GoTools/compositemodel/ftSurface.h | 7 +- .../src/SurfaceModel_intersections.C | 9 +- compositemodel/src/ftEdge.C | 43 ++++++--- compositemodel/src/ftPointSet.C | 91 ++++++++++++++++--- compositemodel/src/ftSurface.C | 16 ++++ .../include/GoTools/creators}/TrimCrvUtils.h | 3 +- .../include/GoTools/creators/TrimCurve.h | 7 ++ .../include/GoTools/creators}/TrimUtils.h | 0 gotools-core/src/creators/CurveCreators.C | 17 +++- .../src/creators}/TrimCrvUtils.C | 21 +++-- gotools-core/src/creators/TrimCurve.C | 9 ++ .../src/creators}/TrimUtils.C | 2 +- gotools-core/src/geometry/CurveOnSurface.C | 9 +- gotools-core/src/geometry/SurfaceTools.C | 57 ++++++++++++ gotools-core/src/utils/DirectionCone.C | 2 +- intersections/src/Identity.C | 62 ++++++++++++- lrsplines2D/app/trimCurveApprox.C | 2 +- lrsplines2D/app/trimSurfaceFromTrimPts.C | 14 +-- lrsplines2D/app/trimmedSfsFromCloud.C | 4 +- lrsplines2D/src/LRTraceIsocontours.C | 2 +- lrsplines2D/src/TrimSurface.C | 4 +- 22 files changed, 318 insertions(+), 68 deletions(-) rename {lrsplines2D/include/GoTools/lrsplines2D => gotools-core/include/GoTools/creators}/TrimCrvUtils.h (99%) rename {lrsplines2D/include/GoTools/lrsplines2D => gotools-core/include/GoTools/creators}/TrimUtils.h (100%) rename {lrsplines2D/src => gotools-core/src/creators}/TrimCrvUtils.C (98%) rename {lrsplines2D/src => gotools-core/src/creators}/TrimUtils.C (99%) diff --git a/compositemodel/include/GoTools/compositemodel/ftPointSet.h b/compositemodel/include/GoTools/compositemodel/ftPointSet.h index 0ae1f331c..fb9b3e2ed 100644 --- a/compositemodel/include/GoTools/compositemodel/ftPointSet.h +++ b/compositemodel/include/GoTools/compositemodel/ftPointSet.h @@ -107,6 +107,8 @@ class ftSamplePoint /// Add a new neighbouring point void addNeighbour(PointIter next); + void addTriangle(PointIter next1, PointIter next2); + /// If neighbour exists it is removed from neighbour vector. void removeNeighbour(PointIter neighbour); @@ -153,6 +155,8 @@ class ftSamplePoint /// Distance between sample points double pntDist(ftSamplePoint* other) const; + bool isNeighbour(ftSamplePoint* other) const; + /// Fetch all triangles containing this point void getAttachedTriangles(std::vector >& triangles) const; @@ -169,6 +173,7 @@ class ftSamplePoint // 2: boundary point on subface, inner point on merged surface. std::vector next_; + ftSamplePoint(); }; // End of ftSamplePoint diff --git a/compositemodel/include/GoTools/compositemodel/ftSurface.h b/compositemodel/include/GoTools/compositemodel/ftSurface.h index 2f8cfaf4b..841ef14d2 100644 --- a/compositemodel/include/GoTools/compositemodel/ftSurface.h +++ b/compositemodel/include/GoTools/compositemodel/ftSurface.h @@ -91,6 +91,8 @@ namespace Go class GO_API ftSurface : public ftFaceBase { public: + ftSurface(); + /// Constructor. Typically, the ParamSurface in this constructor /// will be a BoundedSurface. A loop will be built from this, but /// if we already have a loop and the edges in the loop has @@ -111,6 +113,8 @@ class GO_API ftSurface : public ftFaceBase /// Empty destructor virtual ~ftSurface(); + void attachSurface(shared_ptr sf); + /// Return as type ftSurface virtual ftSurface* asFtSurface(); @@ -634,7 +638,8 @@ class GO_API ftSurface : public ftFaceBase void replaceSurf(shared_ptr sf) { surf_ = sf;} -private: + //private: + protected: /// Geometric description of the surface associated to this face shared_ptr surf_; diff --git a/compositemodel/src/SurfaceModel_intersections.C b/compositemodel/src/SurfaceModel_intersections.C index ed7e291a9..c9dfd18df 100644 --- a/compositemodel/src/SurfaceModel_intersections.C +++ b/compositemodel/src/SurfaceModel_intersections.C @@ -878,6 +878,7 @@ shared_ptr SurfaceModel::trimWithPlane(const ftPlane& plane) // The other surface model for (ki=0; ki face2 = model2->getFace(ki); if (all_int_cvs2[ki].size() == 0) { // The surface is not involved in any intersections. Check if @@ -910,10 +911,10 @@ shared_ptr SurfaceModel::trimWithPlane(const ftPlane& plane) bool inside = isInside(pnt, normal, pt_dist); shared_ptr tmp_surf(surf->clone()); shared_ptr tmp_face(new ftSurface(tmp_surf, -1)); - if (faces_[ki]->asFtSurface()->hasBoundaryConditions()) + if (face2->asFtSurface()->hasBoundaryConditions()) { int bd_cond_type, bd_cond; - faces_[ki]->asFtSurface()->getBoundaryConditions(bd_cond_type, bd_cond); + face2->asFtSurface()->getBoundaryConditions(bd_cond_type, bd_cond); tmp_face->setBoundaryConditions(bd_cond_type, bd_cond); } if (inside) @@ -974,10 +975,10 @@ shared_ptr SurfaceModel::trimWithPlane(const ftPlane& plane) double pt_dist; bool inside = isInside(pnt, normal, pt_dist); shared_ptr tmp_face(new ftSurface(trim_sfs[kr], -1)); - if (faces_[ki]->asFtSurface()->hasBoundaryConditions()) + if (face2->asFtSurface()->hasBoundaryConditions()) { int bd_cond_type, bd_cond; - faces_[ki]->asFtSurface()->getBoundaryConditions(bd_cond_type, bd_cond); + face2->asFtSurface()->getBoundaryConditions(bd_cond_type, bd_cond); tmp_face->setBoundaryConditions(bd_cond_type, bd_cond); } if (inside) diff --git a/compositemodel/src/ftEdge.C b/compositemodel/src/ftEdge.C index 4be8aaabd..6484931d7 100644 --- a/compositemodel/src/ftEdge.C +++ b/compositemodel/src/ftEdge.C @@ -767,12 +767,20 @@ void ftEdge::disconnectTwin() ftEdge *prev = dynamic_cast(prev_); ftEdge *next = dynamic_cast(next_); - shared_ptr prev_start = prev->getVertex(true); - shared_ptr next_start = next->getVertex(true); - shared_ptr prev_end = prev->getVertex(false); - shared_ptr next_end = next->getVertex(false); - bool prev_v1 = (v1_->hasEdge(prev)); - bool next_v2 = (v2_->hasEdge(next)); + shared_ptr prev_start, next_start, prev_end, next_end; + bool prev_v1 = false, next_v2 = false; + if (prev) + { + prev_start = prev->getVertex(true); + prev_end = prev->getVertex(false); + prev_v1 = (v1_->hasEdge(prev)); + } + if (next) + { + next_start = next->getVertex(true); + next_end = next->getVertex(false); + next_v2 = (v2_->hasEdge(next)); + } bool at_start1 = (prev_v1 && prev_start == v1_) || ((!prev_v1) && prev_start == v2_) ; bool at_start2 = (next_v2 && next_start == v2_) || @@ -790,12 +798,19 @@ void ftEdge::disconnectTwin() v1_ = shared_ptr(new Vertex(this, !is_reversed_)); v2_ = shared_ptr(new Vertex(this, is_reversed_)); - shared_ptr tmp_vx1 = prev_v1 ? prev->getVertex(at_start1) : - next->getVertex(!at_start2); - joinVertex(v1_, tmp_vx1); - shared_ptr tmp_vx2 = next_v2 ? next->getVertex(at_start2) : - prev->getVertex(!at_start1); - joinVertex(v2_, tmp_vx2); + shared_ptr tmp_vx1, tmp_vx2; + if (prev_v1) + tmp_vx1 = prev->getVertex(at_start1); + else if (next_v2) + tmp_vx1 = next->getVertex(!at_start2); + if (tmp_vx1) + joinVertex(v1_, tmp_vx1); + if (next_v2) + tmp_vx2 = next->getVertex(at_start2); + else if (prev_v1) + tmp_vx2 = prev->getVertex(!at_start1); + if (tmp_vx2) + joinVertex(v2_, tmp_vx2); // Remove from radial edge if (all_edges_.get()) @@ -1095,6 +1110,10 @@ shared_ptr ftEdge::getOtherSignificantVertex(const Vertex* vx, return edgs[ki]->getOtherSignificantVertex(other.get(), angtol); } + + shared_ptr dummy; + return dummy; // Uncertain about the effect, but the function should + // always return something } //=========================================================================== diff --git a/compositemodel/src/ftPointSet.C b/compositemodel/src/ftPointSet.C index e73d71c12..0290521c0 100644 --- a/compositemodel/src/ftPointSet.C +++ b/compositemodel/src/ftPointSet.C @@ -51,6 +51,19 @@ namespace Go { +//=========================================================================== +ftSamplePoint::ftSamplePoint() + : xyz_(Vector3D(0.0, 0.0, 0.0)), uv_(Vector2D(0.0, 0.0)), + dist_(-1.0), index_(0), at_boundary_(0) +//--------------------------------------------------------------------------- +// +// Purpose: Constructor +// +//=========================================================================== +{ +} + + //=========================================================================== ftSamplePoint::ftSamplePoint(Vector3D xyz, int bnd) : xyz_(xyz), uv_(Vector2D(0.0, 0.0)), @@ -80,6 +93,36 @@ void ftSamplePoint::addNeighbour(PointIter next) next_.push_back(next); } +//=========================================================================== + void ftSamplePoint::addTriangle(PointIter next1, PointIter next2) +//--------------------------------------------------------------------------- +// +// Purpose: Add a new triangle +// +//=========================================================================== +{ + size_t ki, kj; + for (ki=0; kixyz_); } +//=========================================================================== +bool ftSamplePoint::isNeighbour(ftSamplePoint* other) const +//=========================================================================== +{ + for (size_t ki=0; ki >& triangles) const //=========================================================================== @@ -156,8 +209,10 @@ double ftSamplePoint::pntDist(ftSamplePoint* other) const index[1] = next_[ki]->index_; index[2] = pnt->index_; std::sort(index.begin(), index.end()); + auto it = std::find(triangles.begin(), triangles.end(), index); - triangles.push_back(index); + if (it == triangles.end()) + triangles.push_back(index); break; } // if (khnext_.size()) @@ -1383,7 +1438,7 @@ void ftPointSet::getOrientedTriangles(vector >& triangles) Vector3D node2 = index_to_iter_[triangles[0][1]]->getPoint(); Vector3D node3 = index_to_iter_[triangles[0][2]]->getPoint(); Point vec1(node2[0]-node1[0], node2[1]-node1[1], node2[2]-node1[2]); - Point vec2(node3[0]-node1[0], node3[1]-node1[1], node3[2]-node1[2]); + Point vec2(node1[0]-node3[0], node1[1]-node3[1], node1[2]-node3[2]); Point norm2 = vec2.cross(vec1); if (norm1*norm2 < 0.0) std::swap(triangles[0][1],triangles[0][2]); @@ -1423,26 +1478,32 @@ void ftPointSet::getOrientedTriangles(vector >& triangles) if (ki2 >= 0) { // Common edge - // @@@ VSK, 0214. Uncertain whether this test always will - // be correct - if ((ki2-ki1 == kj2-kj1 && (ki2-ki1)*(kj2-kj1) > 0) || - (ki1==0 && ki2==2 && (ki2-ki1)*(kj2-kj1)<0) || - (kj1==0 && kj2==2 && (ki2-ki1)*(kj2-kj1)<0)) + // // @@@ VSK, 0214. Uncertain whether this test always will + // // be correct + // if ((ki2-ki1 == kj2-kj1 && (ki2-ki1)*(kj2-kj1) > 0) || + // (ki1==0 && ki2==2 && (ki2-ki1)*(kj2-kj1)<0) || + // (kj1==0 && kj2==2 && (ki2-ki1)*(kj2-kj1)<0)) + if (ki2 - ki1 > 1) + std::swap(ki1, ki2); + if (kj1 > kj2) + std::swap(kj1, kj2); + if (kj2 - kj1 > 1) + std::swap(kj1, kj2); + if ((triangles[ki][ki2]-triangles[ki][ki1])* + (triangles[kj][kj2]-triangles[kj][kj1]) > 0) { // Same orientation. Swap std::swap(triangles[kj][kj1], triangles[kj][kj2]); } - if (not_swapped >= 0) + + if (kj > not_swapped) { // Reorganize triangles to avoid changing sequence back - if (kj > ki+1) - { - triangles.insert(triangles.begin()+ki+1, - triangles[kj]); - triangles.erase(triangles.begin()+kj+1); - } - not_swapped++; + triangles.insert(triangles.begin()+not_swapped, + triangles[kj]); + triangles.erase(triangles.begin()+kj+1); } + not_swapped++; } // else if (not_swapped == -1) // { diff --git a/compositemodel/src/ftSurface.C b/compositemodel/src/ftSurface.C index 3aa50727a..d316ed322 100644 --- a/compositemodel/src/ftSurface.C +++ b/compositemodel/src/ftSurface.C @@ -75,6 +75,15 @@ using std::make_pair; namespace Go { +//--------------------------------------------------------------------------- +ftSurface::ftSurface() + : ftFaceBase(-1), surf_(0), prio_type_(ftNoType), degenerate_eps_(-1.0), + twin_(0), body_(0), has_boundary_condition_(false), + boundary_cond_type_(-1), boundary_cond_(-1) +//--------------------------------------------------------------------------- +{ +} + //--------------------------------------------------------------------------- ftSurface::ftSurface(shared_ptr sf, int id) : ftFaceBase(id), surf_(sf), prio_type_(ftNoType), degenerate_eps_(-1.0), @@ -105,6 +114,13 @@ ftSurface::~ftSurface() } +//=========================================================================== +void ftSurface::attachSurface(shared_ptr sf) +//=========================================================================== +{ + surf_ = sf; +} + //=========================================================================== ftSurface* ftSurface::asFtSurface() //=========================================================================== diff --git a/lrsplines2D/include/GoTools/lrsplines2D/TrimCrvUtils.h b/gotools-core/include/GoTools/creators/TrimCrvUtils.h similarity index 99% rename from lrsplines2D/include/GoTools/lrsplines2D/TrimCrvUtils.h rename to gotools-core/include/GoTools/creators/TrimCrvUtils.h index 5773e880f..b71502b23 100644 --- a/lrsplines2D/include/GoTools/lrsplines2D/TrimCrvUtils.h +++ b/gotools-core/include/GoTools/creators/TrimCrvUtils.h @@ -124,9 +124,10 @@ namespace Go /// Translation of surface void translateSurfaceDomain(ParamSurface* sf, const Point& translate_vec); +#if 0 // We rescale the value of the z dimension. Typically relevant for 2.5D surfaces. void scaleZ(ParamSurface& sf, double scale_factor); - +#endif // from and to referr to index of a 2-tuple in pts_2d. We allow negative indices as // well as indices larger than the number of 2-tuples, with the modulo operation // defining the correct index. diff --git a/gotools-core/include/GoTools/creators/TrimCurve.h b/gotools-core/include/GoTools/creators/TrimCurve.h index da7a1a1da..5872b6edc 100644 --- a/gotools-core/include/GoTools/creators/TrimCurve.h +++ b/gotools-core/include/GoTools/creators/TrimCurve.h @@ -67,6 +67,13 @@ class TrimCurve : public EvalCurveSet /// limited in the parameter domain TrimCurve(CurveOnSurface* bd_crv, double start, double end); + /// Constructor given the CurveOnSurface curve representing the trim curve + /// limited in the geometry space and in parameter space. This can avoid + /// troubles in the case of a closed input curve. It is left to the user + /// to ensure consistence + TrimCurve(double startpar, Point startpt, double endpar, Point endpt, + CurveOnSurface* bd_crv); + /// Constructor given the CurveOnSurface curve representing the trim curve /// limited in the geometry space TrimCurve(Point startpt, Point endpt, CurveOnSurface* bd_crv); diff --git a/lrsplines2D/include/GoTools/lrsplines2D/TrimUtils.h b/gotools-core/include/GoTools/creators/TrimUtils.h similarity index 100% rename from lrsplines2D/include/GoTools/lrsplines2D/TrimUtils.h rename to gotools-core/include/GoTools/creators/TrimUtils.h diff --git a/gotools-core/src/creators/CurveCreators.C b/gotools-core/src/creators/CurveCreators.C index a0a04a598..a875916bc 100644 --- a/gotools-core/src/creators/CurveCreators.C +++ b/gotools-core/src/creators/CurveCreators.C @@ -352,8 +352,23 @@ CurveCreators::projectCurve(shared_ptr& space_cv, shared_ptr sf_cv = shared_ptr(new CurveOnSurface(surf, space_cv, false)); + // Compute endpoints + // There is a possibility to end up at the wrong side of the seam for closed + // surface, but the position of the closest point should not be that distant + double eps = 1.0e-9; + Point pos1, pos2; + double t1 = space_cv->startparam(); + double t2 = space_cv->endparam(); + space_cv->point(pos1, t1); + space_cv->point(pos2, t2); + + double u1, v1, u2, v2, d1, d2; + Point close1, close2; + surf->closestPoint(pos1, u1, v1, close1, d1, eps); + surf->closestPoint(pos2, u2, v2, close2, d2, eps); + // We must first construct a EvalCurveSet for use in GoHermitAppS. - shared_ptr proj_crv(new TrimCurve(sf_cv.get())); + shared_ptr proj_crv(new TrimCurve(t1, close1, t2, close2, sf_cv.get())); // Approximate vector initpars; diff --git a/lrsplines2D/src/TrimCrvUtils.C b/gotools-core/src/creators/TrimCrvUtils.C similarity index 98% rename from lrsplines2D/src/TrimCrvUtils.C rename to gotools-core/src/creators/TrimCrvUtils.C index 8adc9e031..4451484b8 100644 --- a/lrsplines2D/src/TrimCrvUtils.C +++ b/gotools-core/src/creators/TrimCrvUtils.C @@ -38,14 +38,14 @@ */ -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" #include "GoTools/geometry/GeometryTools.h" #include "GoTools/geometry/PointCloud.h" #include "GoTools/geometry/ObjectHeader.h" #include "GoTools/geometry/Utils.h" #include "GoTools/geometry/BoundedSurface.h" -#include "GoTools/lrsplines2D/LRSplineSurface.h" +//#include "GoTools/lrsplines2D/LRSplineSurface.h" #include "GoTools/creators/ApproxCurve.h" #include @@ -287,8 +287,9 @@ TrimCrvUtils::approximateTrimPts(vector trim_pts, int dim, { Point pnt1(trim_pts[0], trim_pts[1]); Point pnt2(trim_pts[dim], trim_pts[dim+1]); + double len = std::max(0.01, pnt1.dist(pnt2)); shared_ptr curve(new SplineCurve(pnt1, 0.0, - pnt2, pnt1.dist(pnt2))); + pnt2, len)); return curve; } @@ -727,11 +728,11 @@ void TrimCrvUtils::translateObject(GeomObject& go_object, SplineSurface& spline_sf = dynamic_cast(go_object); GeometryTools::translateSplineSurf(translate_vec, spline_sf); } - else if (go_object.instanceType() == Class_LRSplineSurface) - { - LRSplineSurface& lr_spline_sf = dynamic_cast(go_object); - lr_spline_sf.translate(translate_vec); - } + // else if (go_object.instanceType() == Class_LRSplineSurface) + // { + // LRSplineSurface& lr_spline_sf = dynamic_cast(go_object); + // lr_spline_sf.translate(translate_vec); + // } else { MESSAGE("Object type " << go_object.instanceType() << " is not supported yet."); @@ -775,7 +776,7 @@ void TrimCrvUtils::translateSurfaceDomain(ParamSurface* sf, // } } - +#if 0 //=========================================================================== void TrimCrvUtils::scaleZ(ParamSurface& sf, double scale_factor) //=========================================================================== @@ -806,7 +807,7 @@ void TrimCrvUtils::scaleZ(ParamSurface& sf, double scale_factor) MESSAGE("Z scaling of surface type " << sf.instanceType() << " not supported yet."); } } - +#endif //=========================================================================== Point TrimCrvUtils::averageDirection(const vector& pts_2d, diff --git a/gotools-core/src/creators/TrimCurve.C b/gotools-core/src/creators/TrimCurve.C index 7d9f28126..a810ed812 100644 --- a/gotools-core/src/creators/TrimCurve.C +++ b/gotools-core/src/creators/TrimCurve.C @@ -77,6 +77,15 @@ TrimCurve::TrimCurve(Point startpt, Point endpt, CurveOnSurface* sfcv) sfcv->closestPoint(endpt, sfcv->startparam(), sfcv->endparam(), end_, clo_pt, clo_d); } + +//=========================================================================== +TrimCurve::TrimCurve(double startpar, Point startpt, double endpar, Point endpt, + CurveOnSurface* sfcv) + : sfcv_(sfcv), start_(startpar), startpt_(startpt), end_(endpar), endpt_(endpt) +//=========================================================================== +{ +} + //=========================================================================== TrimCurve::~TrimCurve() //=========================================================================== diff --git a/lrsplines2D/src/TrimUtils.C b/gotools-core/src/creators/TrimUtils.C similarity index 99% rename from lrsplines2D/src/TrimUtils.C rename to gotools-core/src/creators/TrimUtils.C index 9dd091d42..fb73f00f9 100644 --- a/lrsplines2D/src/TrimUtils.C +++ b/gotools-core/src/creators/TrimUtils.C @@ -38,7 +38,7 @@ */ -#include "GoTools/lrsplines2D/TrimUtils.h" +#include "GoTools/creators/TrimUtils.h" #include "GoTools/geometry/Utils.h" #include "GoTools/geometry/GoIntersections.h" #include "GoTools/geometry/SplineCurve.h" diff --git a/gotools-core/src/geometry/CurveOnSurface.C b/gotools-core/src/geometry/CurveOnSurface.C index 9adf92d2b..a602f3c1b 100644 --- a/gotools-core/src/geometry/CurveOnSurface.C +++ b/gotools-core/src/geometry/CurveOnSurface.C @@ -59,6 +59,7 @@ #include #include +//#define SBR_DEBUG using namespace Go; using std::vector; @@ -153,19 +154,19 @@ CurveOnSurface::CurveOnSurface(shared_ptr surf, Point pnt8 = surf->point(pt4[0], pt4[1]); if (constdir_ && (pt4-pt3)*(pt2-pt1) < 0.0) { - same_orientation_ = false; + //same_orientation_ = false; std::swap(pt1,pt2); } else if (pnt5.dist(pnt7) + pnt6.dist(pnt8) > pnt5.dist(pnt8) + pnt6.dist(pnt7)) { - same_orientation_ = false; + //same_orientation_ = false; std::swap(pt1,pt2); } } else if (d1 > d2) { - same_orientation_ = false; + //same_orientation_ = false; std::swap(pt1, pt2); } @@ -1533,7 +1534,7 @@ bool CurveOnSurface::ensureParCrvExistence(double epsgeo, if (!pcurve_) { -#ifdef SBR_DBG +#ifdef SBR_DEBUG { Point spacecv_startpt = spacecurve_->point(spacecurve_->startparam()); Point spacecv_endpt = spacecurve_->point(spacecurve_->endparam()); diff --git a/gotools-core/src/geometry/SurfaceTools.C b/gotools-core/src/geometry/SurfaceTools.C index e4fcc9756..ce4b724fc 100644 --- a/gotools-core/src/geometry/SurfaceTools.C +++ b/gotools-core/src/geometry/SurfaceTools.C @@ -70,6 +70,9 @@ CurveLoop SurfaceTools::outerBoundarySfLoop(shared_ptr surf, shared_ptr spline_sf = dynamic_pointer_cast(surf); + shared_ptr elem_sf = + dynamic_pointer_cast(surf); + shared_ptr bd_sf = dynamic_pointer_cast(surf); @@ -110,6 +113,60 @@ CurveLoop SurfaceTools::outerBoundarySfLoop(shared_ptr surf, } } } + else if (elem_sf.get()) + { + if (elem_sf->isBounded()) + { + RectDomain dom = elem_sf->containingDomain(); + vector par(4); + par[0] = dom.vmin(); + par[1] = dom.umax(); + par[2] = dom.vmax(); + par[3] = dom.umin(); + bool u_dir = true; + for (int edgenum = 0; edgenum < 4; ++edgenum) { + if (!deg[edgenum]) + { + // Fetch geometry curve + vector > edgecurve = + elem_sf->constParamCurves(par[edgenum], u_dir); + + // Construct corresponding parameter curve + Point pt1(2), pt2(2); + if (u_dir) + { + pt1[0] = dom.umin(); + pt2[0] = dom.umax(); + pt1[1] = pt2[1] = par[edgenum]; + } + else + { + pt1[1] = dom.vmin(); + pt2[1] = dom.vmax(); + pt1[0] = pt2[0] = par[edgenum]; + } + shared_ptr parcv(new SplineCurve(pt1, + edgecurve[0]->startparam(), + pt2, + edgecurve[0]->endparam())); + + // Define curve on surface curve + shared_ptr sfcv = + shared_ptr(new CurveOnSurface(surf, parcv, edgecurve[0], + false, 3)); + if (edgenum == 2 || edgenum == 3) + sfcv->reverseParameterDirection(); + vec.push_back(sfcv); + } + u_dir = !u_dir; + } + } + else + { + CurveLoop loop; + return loop; // For non bounded surface, return and empty loop + } + } else { // The boundary loop of non bounded surfaces misses information diff --git a/gotools-core/src/utils/DirectionCone.C b/gotools-core/src/utils/DirectionCone.C index be915471c..68ed08067 100644 --- a/gotools-core/src/utils/DirectionCone.C +++ b/gotools-core/src/utils/DirectionCone.C @@ -164,7 +164,7 @@ void DirectionCone::addUnionWith(const Point& pt) Point t = pt; double tlength = t.length(); if (tlength == 0.0) { - MESSAGE("Ignoring vector of zero length"); + //MESSAGE("Ignoring vector of zero length"); return; } t /= tlength; diff --git a/intersections/src/Identity.C b/intersections/src/Identity.C index ebdffa58a..fc1977ee2 100644 --- a/intersections/src/Identity.C +++ b/intersections/src/Identity.C @@ -225,6 +225,9 @@ namespace Go intcv1->point(pt2, &end1); intcv2->point(pt3, &start2); intcv2->point(pt4, &end2); + + double del1 = 0.1*(end1 - start1); + double del2 = 0.1*(end2 - start2); // First check coincidence int coincident = 0; @@ -239,14 +242,38 @@ namespace Go // Project the endpoints on one curve onto the other curve and // check for embedded curves // First check if the first curve is embedded into the second - Point clo_pt1, clo_pt2; - double clo_dist1, clo_dist2; - double clo_par1, clo_par2; + Point clo_pt1, clo_pt2, mid1, clo_mid; + double clo_dist1, clo_dist2, dist_mid; + double clo_par1, clo_par2, par_mid1, clo_par_mid; + par_mid1 = 0.5*(start1 + end1); + intcv1->point(mid1, &par_mid1); cv2->closestPoint(pt1, start2, end2, clo_par1, clo_pt1, clo_dist1); cv2->closestPoint(pt2, start2, end2, clo_par2, clo_pt2, clo_dist2); - if (clo_dist1 <= tol && clo_dist2 <= tol) + cv2->closestPoint(mid1, start2, end2, clo_par_mid, clo_mid, dist_mid); + if (clo_dist1 <= tol && clo_dist2 <= tol && dist_mid <= tol) { + // Check for seam + if (pt3.dist(pt4) <= tol) + { + if (clo_par_mid < std::min(clo_par1, clo_par2) && + end2 - std::max(clo_par1, clo_par2) < del2) + { + if (clo_par1 > clo_par2) + clo_par1 = start2; + else + clo_par2 = start2; + } + else if (clo_par_mid > std::max(clo_par1, clo_par2) && + std::min(clo_par1, clo_par2) - start2 < del2) + { + if (clo_par1 < clo_par2) + clo_par1 = end2; + else + clo_par2 = end2; + } + } + // Posibility for embedded curve coincident = checkCoincide(intcv1.get(), start1, end1, eps, intcv2.get(), clo_par1, clo_par2); @@ -257,10 +284,35 @@ namespace Go if (!coincident) { // Check if curve two is embedded in curve one + Point mid2; + double par_mid2 = 0.5*(start2 + end2); + intcv2->point(mid2, &par_mid2); cv1->closestPoint(pt3, start1, end1, clo_par1, clo_pt1, clo_dist1); cv1->closestPoint(pt4, start1, end1, clo_par2, clo_pt2, clo_dist2); - if (clo_dist1 <= tol && clo_dist2 <= tol) + cv1->closestPoint(mid2, start1, end1, clo_par_mid, clo_mid, dist_mid); + if (clo_dist1 <= tol && clo_dist2 <= tol && dist_mid <= tol) { + // Check for seam + if (pt1.dist(pt2) <= tol) + { + if (clo_par_mid < std::min(clo_par1, clo_par2) && + end1 - std::max(clo_par1, clo_par2) < del1) + { + if (clo_par1 > clo_par2) + clo_par1 = start1; + else + clo_par2 = start1; + } + } + else if (clo_par_mid > std::max(clo_par1, clo_par2) && + std::min(clo_par1, clo_par2) - start1 < del1) + { + if (clo_par1 < clo_par2) + clo_par1 = end1; + else + clo_par2 = end1; + } + // Posibility for embedded curve coincident = checkCoincide(intcv2.get(), start2, end2, eps, intcv1.get(), clo_par1, clo_par2); diff --git a/lrsplines2D/app/trimCurveApprox.C b/lrsplines2D/app/trimCurveApprox.C index 3c296536c..be6b8ce27 100644 --- a/lrsplines2D/app/trimCurveApprox.C +++ b/lrsplines2D/app/trimCurveApprox.C @@ -38,7 +38,7 @@ */ -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" #include "GoTools/geometry/SplineCurve.h" #include diff --git a/lrsplines2D/app/trimSurfaceFromTrimPts.C b/lrsplines2D/app/trimSurfaceFromTrimPts.C index 43366aa7a..853a419ef 100644 --- a/lrsplines2D/app/trimSurfaceFromTrimPts.C +++ b/lrsplines2D/app/trimSurfaceFromTrimPts.C @@ -38,7 +38,7 @@ */ -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" #include "GoTools/geometry/PointCloud.h" #include "GoTools/geometry/BoundedSurface.h" #include "GoTools/geometry/ObjectHeader.h" @@ -112,12 +112,12 @@ int main(int argc, char* argv[]) } #endif - double scale_z_factor = 5.0; - if (scale_z_factor != 1.0) - { - cout << "\nRescaling the z dimension of the surface by a factor of " << scale_z_factor << "!\n" << endl; - TrimCrvUtils::scaleZ(*sf, scale_z_factor); - } + // double scale_z_factor = 5.0; + // if (scale_z_factor != 1.0) + // { + // cout << "\nRescaling the z dimension of the surface by a factor of " << scale_z_factor << "!\n" << endl; + // TrimCrvUtils::scaleZ(*sf, scale_z_factor); + // } const double epsgeo = 20;//10;//5;//1e-04; const double kink_tol = 5e-01; // 0.1 deg => 5.7 degrees. diff --git a/lrsplines2D/app/trimmedSfsFromCloud.C b/lrsplines2D/app/trimmedSfsFromCloud.C index 026da69f5..320147a9f 100644 --- a/lrsplines2D/app/trimmedSfsFromCloud.C +++ b/lrsplines2D/app/trimmedSfsFromCloud.C @@ -37,7 +37,7 @@ * written agreement between you and SINTEF ICT. */ -#include "GoTools/lrsplines2D/TrimUtils.h" +#include "GoTools/creators/TrimUtils.h" #include "GoTools/lrsplines2D/TrimSurface.h" #include "GoTools/lrsplines2D/LRSplineSurface.h" #include "GoTools/geometry/PointCloud.h" @@ -49,7 +49,7 @@ #include "GoTools/geometry/LoopUtils.h" #include "GoTools/geometry/Factory.h" #include "GoTools/geometry/GoTools.h" -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" #include #include #include diff --git a/lrsplines2D/src/LRTraceIsocontours.C b/lrsplines2D/src/LRTraceIsocontours.C index 59fbfca5e..50a869e7a 100644 --- a/lrsplines2D/src/LRTraceIsocontours.C +++ b/lrsplines2D/src/LRTraceIsocontours.C @@ -47,7 +47,7 @@ #include "GoTools/geometry/RectDomain.h" #include "GoTools/geometry/SplineDebugUtils.h" #include "GoTools/lrsplines2D/SSurfTraceIsocontours.h" -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" //#define DEBUG0 //#define DEBUG diff --git a/lrsplines2D/src/TrimSurface.C b/lrsplines2D/src/TrimSurface.C index bb7c4da99..98f3f9eec 100644 --- a/lrsplines2D/src/TrimSurface.C +++ b/lrsplines2D/src/TrimSurface.C @@ -39,7 +39,7 @@ #include "GoTools/lrsplines2D/TrimSurface.h" -#include "GoTools/lrsplines2D/TrimUtils.h" +#include "GoTools/creators/TrimUtils.h" #include "GoTools/geometry/Utils.h" #include "GoTools/geometry/SplineCurve.h" #include "GoTools/geometry/RectDomain.h" @@ -47,7 +47,7 @@ #include "GoTools/geometry/GeometryTools.h" #include "GoTools/geometry/CurveBoundedDomain.h" #include "GoTools/geometry/CurveLoop.h" -#include "GoTools/lrsplines2D/TrimCrvUtils.h" +#include "GoTools/creators/TrimCrvUtils.h" #include "GoTools/lrsplines2D/LRSplineSurface.h" #include #include