65 virtual bool isInterior(
Vector3d pos) {
return false; }
66 virtual std::pair<Vector3d, Vector3d> getBoundingBox() {
67 Vector3d bMax = facets_[0].vertex1();
68 Vector3d bMin = facets_[0].vertex1();
70 for (
auto& t : facets_) {
71 for (
int i = 0; i < 3; i++) {
72 bMax[i] = max(bMax[i], t.vertex1()[i]);
73 bMin[i] = min(bMin[i], t.vertex1()[i]);
74 bMax[i] = max(bMax[i], t.vertex2()[i]);
75 bMin[i] = min(bMin[i], t.vertex2()[i]);
76 bMax[i] = max(bMax[i], t.vertex3()[i]);
77 bMin[i] = min(bMin[i], t.vertex3()[i]);
80 return make_pair(bMax, bMin);
82 virtual bool hasAnalyticalSolution() {
return false; }
83 virtual HydroProp* getHydroProp(RealType viscosity) {
85 props->setCenterOfResistance(V3Zero);
86 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
87 "Mesh was asked to return an analytic HydroProps.\n");
88 painCave.severity = OPENMD_ERROR;
94 virtual bool isComposite() {
return false; }
95 virtual bool isSpherical() {
return false; }
96 virtual bool isMesh() {
return true; }
98 void add(
Triangle t) { facets_.push_back(t); }
102 Triangle t(vertex1, vertex2, vertex3);
103 facets_.push_back(t);
112 void clear() { facets_.clear(); }
114 size_t size() {
return facets_.size(); }
118 x = ((s.
x() != 0) ? s.
x() : 1);
119 y = ((s.
y() != 0) ? s.
y() : 1);
120 z = ((s.
z() != 0) ? s.
z() : 1);
124 for (
auto& t : facets_) {
125 v1.
Vmul(t.vertex1(), _s);
126 v2.
Vmul(t.vertex2(), _s);
127 v3.
Vmul(t.vertex3(), _s);
135 for (
auto& t : facets_) {
136 v1 = t.vertex1() + trans;
137 v2 = t.vertex2() + trans;
138 v3 = t.vertex3() + trans;
145 for (
auto& t : facets_) {
151 void stlWrite(
const std::string& filename,
const std::string& name =
"") {
152 std::ofstream file(filename);
155 <<
" " << name << std::endl;
156 for (
auto& t : facets_) {
159 <<
" " << t.getUnitNormal() << std::endl;
161 <<
"outer loop" << std::endl;
165 <<
" " << t.vertex1() << std::endl;
169 <<
" " << t.vertex2() << std::endl;
173 <<
" " << t.vertex3() << std::endl;
175 <<
"endloop" << std::endl;
177 <<
"endfacet" << std::endl;
180 <<
" " << name << std::endl;
186 facets_.insert(facets_.end(), (m.facets_).begin(), (m.facets_).end());
190 inline void add(
const Mesh& m1,
const Mesh& m2) {
191 this->facets_.insert(this->facets_.end(), (m1.facets_).begin(),
193 this->facets_.insert(this->facets_.end(), (m2.facets_).begin(),
197 std::vector<Triangle> getFacets() {
return facets_; }
200 std::vector<Triangle> facets_;
void Vmul(const Vector< Real, Dim > &v1, const Vector< Real, Dim > &v2)
Sets the elements of this vector to the multiplication of elements of two other vectors.