// Count a nuber of polygons stored inside the vector of expolygons. // Useful for allocating space for polygons when converting expolygons to polygons. inline size_t number_polygons(const Surfaces &surfaces) { size_t n_polygons = 0; for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) n_polygons += it->expolygon.holes.size() + 1; return n_polygons; }
inline Polygons to_polygons(const Surfaces &surfaces) { Slic3r::Polygons pp; for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) append_to(pp, (Polygons)*s); return pp; }
inline ExPolygons to_expolygons(const Surfaces &src) { ExPolygons expolygons; expolygons.reserve(src.size()); for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it) expolygons.push_back(it->expolygon); return expolygons; }
// Append a vector of Surfaces at the end of another vector of polygons. inline void polygons_append(Polygons &dst, const Surfaces &src) { dst.reserve(dst.size() + number_polygons(src)); for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++ it) { dst.push_back(it->expolygon.contour); dst.insert(dst.end(), it->expolygon.holes.begin(), it->expolygon.holes.end()); } }
void ImplicitInterrogator::setImplicit(std::string s) { _implicit = empty_p; ParticleSystem *psys = ps->particleSystem; if (psys) { Surfaces *surfs = psys->surfaces; if (surfs) { _implicit = dynamic_cast<Implicit *>(surfs->withName(s)); if (!_implicit) _implicit = empty_p; } } }
void SurfaceCollection::simplify(double tolerance) { Surfaces ss; for (Surfaces::const_iterator it_s = this->surfaces.begin(); it_s != this->surfaces.end(); ++it_s) { ExPolygons expp; it_s->expolygon.simplify(tolerance, expp); for (ExPolygons::const_iterator it_e = expp.begin(); it_e != expp.end(); ++it_e) { Surface s = *it_s; s.expolygon = *it_e; ss.push_back(s); } } this->surfaces = ss; }
Surfaces offset(const Surface &surface, const float delta, double scale, ClipperLib::JoinType joinType, double miterLimit) { // perform offset ExPolygons expp = offset_ex(surface.expolygon, delta, scale, joinType, miterLimit); // clone the input surface for each expolygon we got Surfaces retval; retval.reserve(expp.size()); for (ExPolygons::iterator it = expp.begin(); it != expp.end(); ++it) { Surface s = surface; // clone s.expolygon = *it; retval.push_back(s); } return retval; }
bool SurfacesNode::setValue (const String& strMemberName, const String* pstrValue) { bool bValueSet = false; Surfaces* pObject = dynamic_cast<Surfaces*>(m_pObject); if (strMemberName == L"Desc") { if (!pstrValue) { pObject->resetValue_Desc(); } else { pObject->setDesc(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Name") { if (!pstrValue) { pObject->resetValue_Name(); } else { pObject->setName(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"State") { if (!pstrValue) { pObject->resetValue_State(); } else { pObject->setState(EnumStateTypeImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } return bValueSet; }
bool SurfacesNode::getValue (const String& strMemberName, String& strValue) { bool bValueSet = false; Surfaces* pObject = dynamic_cast<Surfaces*>(m_pObject); if (strMemberName == L"value") { ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject); if (pValueObj) { if (!pValueObj->isNothing()) { strValue = pValueObj->toString(); bValueSet = true; } } } else if (strMemberName == L"Desc") { if (pObject->hasValue_Desc()) { strValue = (StringObjectImpl(pObject->getDesc())).toString(); bValueSet = true; } } else if (strMemberName == L"Name") { if (pObject->hasValue_Name()) { strValue = (StringObjectImpl(pObject->getName())).toString(); bValueSet = true; } } else if (strMemberName == L"State") { if (pObject->hasValue_State()) { strValue = (EnumStateTypeImpl(pObject->getState())).toString(); bValueSet = true; } } return bValueSet; }
void SVG::draw_outline(const Surfaces &surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width) { for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) draw_outline(*it, stroke_outer, stroke_holes, stroke_width); }
void SVG::draw(const Surfaces &surfaces, std::string fill, const float fill_opacity) { for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it) this->draw(*it, fill, fill_opacity); }
bool empty() const { return surfaces.empty(); }
void clear() { surfaces.clear(); }
double CalcIntegral(Surfaces &s, PointsXYZ &m){ //return; int ns=s.size(); // число треугольников CoordXYZ x[3]; for (int i = 0; i < 3; i++) x[i].resize(3); //============= init =================== vrt.Init(m.size(),p_DeltaT); CoordXYZ w(3); CoordXYZ control_point(3); CoordXYZ position_of_source(3); w[0] = 0; w[1] = 0; w[2] = 0; position_of_source[0] = e_x0; position_of_source[1] = e_y0; position_of_source[2] = e_z0; control_point[0] = p_control_x; control_point[1] = p_control_y; control_point[2] = p_control_z; double omega = p_omega; SourceOfNoise source_of_noise(omega, position_of_source,w);//,control_point); //========== end of init =============== double Sintegral; // for(double z=90.;z<100.;z+=(100.-90.)/200.) double T=0.; // for(;T<110.;T+=(110.-90.)/230.) { for (int i = 0; i < 3; ++i) IntN[i]=0; S_Surf=0.; // control_point[2]=z; Sintegral=0; for(int j=0;j<ns;j++) { int err; Sintegral+=CalcIntegralOfFullTrg(s[j],m,T,source_of_noise, control_point,err); if(err) { cout << " ERROR 3_ ret=" << err << " j= " << j << endl; return 0.; } } { static int ugu=0; if(!ugu) cout << " S_Surf=" << S_Surf << " (" << S_Surf/(4.*M_PI*kva(p_Rsphere)) << ") IntN " << IntN[0] << " " << IntN[1] << " " << IntN[2] << endl<< endl; ugu=1; } // cout << control_point[2] << " " << Sintegral << " " << source_of_noise.GetRho(control_point,T) << endl; if(!isbp) cout << T << "\t" << source_of_noise.GetRho(control_point,T) << " " << Sintegral << endl; } if(isbp) { vrt.PutData("koeff.txt"); // следует выполнить свёртку! int nk=150,ik; double dt=(p_T2-p_T1)/nk; for(ik=0,T=p_T1;ik<=nk;ik++,T+=dt) { Sintegral=vrt.Svertka(s,m,source_of_noise,T); cout << T << "\t" << source_of_noise.GetRho(control_point,T) << " " << Sintegral << endl; } } cout << endl; cout << " S_Surf=" << S_Surf << " (" << S_Surf/(4.*M_PI*kva(p_Rsphere)) << ") Int_N " << IntN[0] << " " << IntN[1] << " " << IntN[2] << endl; return Sintegral; }
vector<SimplifiedRib> CreateInitialStructure(Surfaces& s, PointsXYZ &m){ vector<Rib> k; k.resize(s.size()*3); //cout << s.size() << " " << k.size() << endl; for(int i = 0; i < s.size(); i++){ // заполняем k ребрами с номерами треугольников k[i*3].TriangleNumber = k[i*3+1].TriangleNumber = k[i*3+2].TriangleNumber = i; k[i*3].a = k[i*3+1].a = GetCoordSurf(s[i][0],m); k[i*3].b = k[i*3+2].a = GetCoordSurf(s[i][1],m); k[i*3+1].b = k[i*3+2].b = GetCoordSurf(s[i][2],m); } for(int i = 0; i < k.size(); i++){ //упорядочиваем вершины каждого ребра по величине модуля CoordXYZ t; /* cout << i << endl; cout << "a: " << k[i].a[0] << " " << k[i].a[1] << " "<< k[i].a[2] << " "; cout << "b: " << k[i].b[0] << " " << k[i].b[1] << " "<< k[i].b[2] << endl; if(!((i+1)%3)) cout << k[i].TriangleNumber << endl;*/ if(keisu(k[i].a) > keisu(k[i].b)) { t = k[i].a; k[i].a = k[i].b; k[i].b = t; } } qsortmy1(k,0,k.size()-1,0); int lb = 0; int rb = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a[0] != k[i-1].a[0]){ rb = i-1; qsortmy1(k,lb,rb,1); lb = i; } else if(i == k.size()-1){ rb = i; qsortmy1(k,lb,rb,1); } } lb = rb = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a[0] != k[i-1].a[0] || k[i].a[1] != k[i-1].a[1]){ rb = i-1; qsortmy1(k,lb,rb,2); lb = i; } else if(i == k.size()-1){ rb = i; qsortmy1(k,lb,rb,2); } } lb = rb = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a[0] != k[i-1].a[0] || k[i].a[1] != k[i-1].a[1] || k[i].a[2] != k[i-1].a[2]){ rb = i-1; qsortmy2(k,lb,rb,0); lb = i; } else if(i == k.size()-1){ rb = i; qsortmy2(k,lb,rb,0); } } lb = rb = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a[0] != k[i-1].a[0] || k[i].a[1] != k[i-1].a[1] || k[i].a[2] != k[i-1].a[2] || k[i].b[0] != k[i-1].b[0]){ rb = i-1; qsortmy2(k,lb,rb,1); lb = i; } else if(i == k.size()-1){ rb = i; qsortmy2(k,lb,rb,1); } } lb = rb = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a[0] != k[i-1].a[0] || k[i].a[1] != k[i-1].a[1] || k[i].a[2] != k[i-1].a[2] || k[i].b[0] != k[i-1].b[0] || k[i].b[1] != k[i-1].b[1]){ rb = i-1; qsortmy2(k,lb,rb,2); lb = i; } else if(i == k.size()-1){ rb = i; qsortmy2(k,lb,rb,2); } } //qsorttriangletest(k,0,k.size()-1); /*for(int i = 0; i < k.size();i++){ if(k[i].TriangleNumber == 3779){ cout << i << " " << k[i].TriangleNumber << endl; cout << "a: " << k[i].a[0] << " " << k[i].a[1] << " "<< k[i].a[2] << " "; cout << "b: " << k[i].b[0] << " " << k[i].b[1] << " "<< k[i].b[2] << endl; } }*/ vector<SimplifiedRib> ret; ret.resize(k.size()); ret[0].RibNumber = 0; ret[0].TriangleNumber = k[0].TriangleNumber; int z = 0; for(int i = 1; i < k.size(); i++){ if(k[i].a != k[i-1].a || k[i].b != k[i-1].b) z++; ret[i].RibNumber = z; ret[i].TriangleNumber = k[i].TriangleNumber; } //qsorttriangle(ret,0,ret.size()-1); /*for(int i = 0; i < ret.size(); i++){ if(ret[i].RibNumber == 6805){ cout << i << " "; cout << "RibNumber: " << ret[i].RibNumber << " "; cout << "TriangleNumber: " << ret[i].TriangleNumber << endl; } }*/ return ret; }