From b8bf194fcfe300e584d36ad5a367ac272269ea51 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 11 Oct 2016 14:10:36 +0200 Subject: [PATCH] some changes --- libsrc/csg/algprim.hpp | 1 + libsrc/csg/edgeflw.cpp | 23 ++++++++++++-- libsrc/csg/genmesh.cpp | 6 ++++ libsrc/csg/splinesurface.cpp | 43 ++++++++++++++++---------- libsrc/csg/splinesurface.hpp | 6 ++-- libsrc/include/nginterface_v2_impl.hpp | 2 +- libsrc/meshing/meshclass.cpp | 1 + libsrc/meshing/meshfunc.cpp | 2 +- libsrc/meshing/meshtype.cpp | 12 ------- libsrc/meshing/meshtype.hpp | 6 ---- 10 files changed, 60 insertions(+), 42 deletions(-) diff --git a/libsrc/csg/algprim.hpp b/libsrc/csg/algprim.hpp index 0459108a..9ca93cdd 100644 --- a/libsrc/csg/algprim.hpp +++ b/libsrc/csg/algprim.hpp @@ -53,6 +53,7 @@ namespace netgen /// A Plane (i.e., the plane and everything behind it). class Plane : public QuadraticSurface { + protected: /// a point in the plane Point<3> p; /// outward normal vector diff --git a/libsrc/csg/edgeflw.cpp b/libsrc/csg/edgeflw.cpp index b060d683..4541567c 100644 --- a/libsrc/csg/edgeflw.cpp +++ b/libsrc/csg/edgeflw.cpp @@ -486,15 +486,13 @@ namespace netgen mesh); } - (*testout) << "refedges size: " << refedges.Size() << endl; for(int i=0; i(geometry.GetSurface(refedges[i].surfnr1)); if(splinesurface) { auto name = splinesurface->GetBCNameOf(specpoints[startpoints.Get(refedges[i].edgenr)].p,specpoints[endpoints.Get(refedges[i].edgenr)].p); - mesh.SetCD2Name(refedges[i].edgenr-1,*name); + mesh.SetCD2Name(refedges[i].edgenr,*name); } } @@ -1168,7 +1166,23 @@ namespace netgen refedges.Elem(hi).domout = i; } else + { refedges.Elem(hi).tlosurf = i; + for(int kk = 0; kk < geometry.GetNTopLevelObjects(); kk++) + { + auto othersolid = geometry.GetTopLevelObject(kk)->GetSolid(); + auto othersurf = geometry.GetTopLevelObject(kk)->GetSurface(); + if(!othersurf) + { + if(othersolid->IsIn(edgepoints[0]) && + othersolid->IsIn(edgepoints[edgepoints.Size()-1])) + { + refedges.Elem(hi).domin = kk; + refedges.Elem(hi).domout = kk; + } + } + } + } if(pre_ok[k-1]) edges_priority[hi-1] = 1; @@ -1386,6 +1400,7 @@ namespace netgen seg.surfnr2 = refedges.Get(k).surfnr2; seg.seginfo = 0; if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; + *testout << "add segment at 3" << endl; mesh.AddSegment (seg); //(*testout) << "add seg " << mesh[seg.p1] << "-" << mesh[seg.p2] << endl; //(*testout) << "refedge " << k << " surf1 " << seg.surfnr1 << " surf2 " << seg.surfnr2 << " inv " << refedgesinv.Get(k) << endl; @@ -1554,6 +1569,7 @@ namespace netgen seg.surfnr2 = refedges.Get(k).surfnr2; seg.seginfo = 0; if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; + *testout << "add segment at 1" << endl; mesh.AddSegment (seg); // (*testout) << "add seg " << seg[0] << "-" << seg[1] << endl; } @@ -1685,6 +1701,7 @@ namespace netgen seg.surfnr2 = refedges.Get(k).surfnr2; seg.seginfo = 0; if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1; + *testout << "add segment at 2" << endl; mesh.AddSegment (seg); // (*testout) << "copy seg " << seg[0] << "-" << seg[1] << endl; #ifdef DEVELOP diff --git a/libsrc/csg/genmesh.cpp b/libsrc/csg/genmesh.cpp index 9c5e78bf..07fa41d2 100644 --- a/libsrc/csg/genmesh.cpp +++ b/libsrc/csg/genmesh.cpp @@ -98,6 +98,12 @@ namespace netgen //(*testout) << " to " << mesh.LineSegment(i).si << endl; } + for(int k = 1; k<=mesh.GetNFD(); k++) + { + *testout << "face: " << k << endl + << "FD: " << mesh.GetFaceDescriptor(k) << endl; + } + if (geom.identifications.Size()) { PrintMessage (3, "Find Identifications"); diff --git a/libsrc/csg/splinesurface.cpp b/libsrc/csg/splinesurface.cpp index 46fd7a73..1009f41f 100644 --- a/libsrc/csg/splinesurface.cpp +++ b/libsrc/csg/splinesurface.cpp @@ -3,7 +3,7 @@ namespace netgen { -SplineSurface :: SplineSurface() : OneSurfacePrimitive() + SplineSurface :: SplineSurface() : OneSurfacePrimitive() { ; } SplineSurface :: ~SplineSurface() { ; } @@ -34,7 +34,30 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const } return new string("default"); } - + + Array* SplineSurface :: CreatePlanes() const + { + auto planes = new Array(); + auto sol = new Solid(new Plane(splines[0]->GetPoint(0),Cross(splines[0]->GetTangent(0),GetNormalVector(splines[0]->GetPoint(0))))); + for(auto spline : splines) + { + planes->Append(new Plane(spline->GetPoint(0),-spline->GetTangent(0))); + } + return planes; + } + + void SplineSurface :: Print(ostream & str) const +{ + str << "SplineSurface " << endl; +} + + void SplineSurface :: Project(Point<3> & p3d) const + { + double val = CalcFunctionValue(p3d); + p3d -= val * GetNormalVector(p3d); + } + + double SplineSurface :: CalcFunctionValue (const Point<3> & point) const { auto v1 = splines[0]->GetTangent(0); @@ -73,23 +96,8 @@ void SplineSurface :: CalcGradient (const Point<3> & point, Vec<3> & grad) const } } - Array* SplineSurface :: CreatePlanes() const - { - auto planes = new Array(); - auto sol = new Solid(new Plane(splines[0]->GetPoint(0),-(splines[0]->GetTangent(0)))); - for(auto spline : splines) - { - planes->Append(new Plane(spline->GetPoint(0),-spline->GetTangent(0))); - } - return planes; - } - void SplineSurface :: Print(ostream & str) const -{ - str << "SplineSurface " << endl; -} - INSOLID_TYPE SplineSurface :: BoxInSolid(const BoxSphere<3> & box) const { @@ -127,4 +135,5 @@ INSOLID_TYPE SplineSurface :: BoxInSolid(const BoxSphere<3> & box) const return IS_INSIDE; } } + } diff --git a/libsrc/csg/splinesurface.hpp b/libsrc/csg/splinesurface.hpp index 70809163..9211049f 100644 --- a/libsrc/csg/splinesurface.hpp +++ b/libsrc/csg/splinesurface.hpp @@ -4,7 +4,7 @@ namespace netgen { - class SplineSurface : public OneSurfacePrimitive + class SplineSurface : public OneSurfacePrimitive { protected: Array> geompoints; @@ -28,7 +28,8 @@ namespace netgen DLL_HEADER void AppendPoint(const Point<3> & p, const double reffac = 1., const bool hpref=false); void AppendSegment(SplineSeg<3>* spline, string* bcname); Array* CreatePlanes() const; - + + virtual void Project (Point<3> & p3d) const; virtual double CalcFunctionValue (const Point<3> & point) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual double HesseNorm () const; @@ -36,6 +37,7 @@ namespace netgen virtual void CalcSpecialPoints(Array> & pts) const; virtual INSOLID_TYPE BoxInSolid(const BoxSphere<3> & box) const; + virtual void Print (ostream & str) const; diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index dd94d02f..e6918e7e 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -14,7 +14,7 @@ template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const { if(mesh->GetDimension()==3) - return (*mesh)[SegmentIndex(nr)].cd2i; + return (*mesh)[SegmentIndex(nr)].edgenr; else return (*mesh)[SegmentIndex(nr)].si; } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index ba19a36c..36d07b1d 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5773,6 +5773,7 @@ namespace netgen void Mesh :: SetCD2Name ( int cd2nr, const string & abcname ) { + cd2nr++; (*testout) << "setCD2Name on edge " << cd2nr << " to " << abcname << endl; if (cd2nr >= cd2names.Size()) { diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 8440cc1f..54f06a65 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -86,7 +86,7 @@ namespace netgen { const Element2d & el = mesh3d[sei]; if (el.IsDeleted() ) continue; - + if (mesh3d.GetFaceDescriptor(el.GetIndex()).DomainIn() == k || mesh3d.GetFaceDescriptor(el.GetIndex()).DomainOut() == k) diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index acad5a7f..b4476e00 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -2418,18 +2418,6 @@ namespace netgen return s; } - string EdgeDescriptor :: default_bcname = "default"; - void EdgeDescriptor :: SetBCName (string * bcn) - { - if(bcn) - bcname = bcn; - else - bcn = &default_bcname; - } - - - - Identifications :: Identifications (Mesh & amesh) : mesh(amesh) diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index e4963934..78598a44 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1005,9 +1005,6 @@ namespace netgen { int tlosurf; int surfnr[2]; - int bcprop; - static string default_bcname; - string* bcname = &default_bcname; public: EdgeDescriptor () : tlosurf(-1) @@ -1018,9 +1015,6 @@ namespace netgen int TLOSurface() const { return tlosurf; } void SetTLOSurface (int nr) { tlosurf = nr; } - int BCProperty() const { return bcprop; } - void SetBCProperty (int bc) { bcprop = bc; } - void SetBCName (string* bcn); };