Vec3d to Vec<3>, comparison operator for Vec<>

This commit is contained in:
Matthias Hochsteger 2019-11-27 14:47:24 +01:00
parent 385040333b
commit 05e6456ec2
6 changed files with 17 additions and 24 deletions

View File

@ -120,6 +120,11 @@ namespace netgen
return *this;
}
bool operator== (const Vec<D,T> &a)
{
return x[0]==a.x[0] && x[1]==a.x[1] && x[2]==a.x[2];
}
T & operator() (int i) { return x[i]; }
const T & operator() (int i) const { return x[i]; }

View File

@ -818,11 +818,11 @@ namespace netgen
outfile.width(8);
outfile << GetFaceDescriptor(i).SurfNr()+1 << " ";
outfile.width(12);
outfile << GetFaceDescriptor(i).SurfColour().X() << " ";
outfile << GetFaceDescriptor(i).SurfColour()[0] << " ";
outfile.width(12);
outfile << GetFaceDescriptor(i).SurfColour().Y() << " ";
outfile << GetFaceDescriptor(i).SurfColour()[1] << " ";
outfile.width(12);
outfile << GetFaceDescriptor(i).SurfColour().Z();
outfile << GetFaceDescriptor(i).SurfColour()[2];
outfile << endl;
}
}

View File

@ -1163,7 +1163,7 @@ namespace netgen
// Philippose - 06/07/2009
// Get Surface colour
Vec3d SurfColour () const { return surfcolour; }
Vec<3> SurfColour () const { return surfcolour; }
DLL_HEADER const string & GetBCName () const { return *bcname; }
// string * BCNamePtr () { return bcname; }
// const string * BCNamePtr () const { return bcname; }
@ -1174,7 +1174,7 @@ namespace netgen
void SetBCName (string * bcn); // { bcname = bcn; }
// Philippose - 06/07/2009
// Set the surface colour
void SetSurfColour (Vec3d colour) { surfcolour = colour; }
void SetSurfColour (Vec<3> colour) { surfcolour = colour; }
void SetDomainInSingular (double v) { domin_singular = v; }
void SetDomainOutSingular (double v) { domout_singular = v; }

View File

@ -138,6 +138,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
py::class_<Vec<2>> (m, "Vec2d")
.def(py::init<double,double>())
.def ("__str__", &ToString<Vec<3>>)
.def(py::self==py::self)
.def(py::self+py::self)
.def(py::self-py::self)
.def(-py::self)
@ -150,6 +151,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
py::class_<Vec<3>> (m, "Vec3d")
.def(py::init<double,double,double>())
.def ("__str__", &ToString<Vec<3>>)
.def(py::self==py::self)
.def(py::self+py::self)
.def(py::self-py::self)
.def(-py::self)
@ -492,20 +494,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
[](FaceDescriptor & self) -> string { return self.GetBCName(); },
[](FaceDescriptor & self, string name) { self.SetBCName(new string(name)); } // memleak
)
.def_property("color",
[](FaceDescriptor & self)
{
auto c = self.SurfColour();
return py::make_tuple( c.X(), c.Y(), c.Z() );
},
[](FaceDescriptor & self, py::tuple color)
{
Vec3d c;
c.X() = py::extract<double>(color[0])();
c.Y() = py::extract<double>(color[1])();
c.Z() = py::extract<double>(color[2])();
self.SetSurfColour(c);
})
.def_property("color", &FaceDescriptor::SurfColour, &FaceDescriptor::SetSurfColour )
;

View File

@ -416,11 +416,11 @@ namespace netgen
if(!(geom.face_colours.IsNull())
&& (geom.face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)))
{
mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(face_colour.Red(),face_colour.Green(),face_colour.Blue()));
mesh.GetFaceDescriptor(facenr).SetSurfColour({face_colour.Red(),face_colour.Green(),face_colour.Blue()});
}
else
{
mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(0.0,1.0,0.0));
mesh.GetFaceDescriptor(facenr).SetSurfColour({0.0,1.0,0.0});
}
if(geom.fnames.Size()>=facenr)

View File

@ -1019,9 +1019,8 @@ namespace netgen
// the mesh data structure, rather than limit it to the OCC geometry
// structure... allows other geometry types to use face colours too
matcol[0] = mesh->GetFaceDescriptor(faceindex).SurfColour().X();
matcol[1] = mesh->GetFaceDescriptor(faceindex).SurfColour().Y();
matcol[2] = mesh->GetFaceDescriptor(faceindex).SurfColour().Z();
for (auto i : Range(3))
matcol[i] = mesh->GetFaceDescriptor(faceindex).SurfColour()[i];
matcol[3] = 1.0;
if (faceindex == selface)