28 typedef std::pair<unsigned int, unsigned int>
segment;
40 std::vector<unsigned int>* vertices =
triangle->getLocalVertices();
41 for (
unsigned int i = 0; i < vertices->size(); i++)
43 segment seg1 = std::pair<unsigned int, unsigned int>(vertices->at(i),
44 vertices->at((i + 1) % (vertices->size())));
45 mapSegmentShapes::iterator it = currentMap.find(seg1);
47 if (it == currentMap.end())
49 std::vector<Shape*> newList;
50 newList.push_back(shape);
51 currentMap.insert(std::pair<
segment, std::vector<Shape*>>(seg1, newList));
55 it->second.push_back(shape);
58 segment seg2 = std::pair<unsigned int, unsigned int>(vertices->at((i + 1) % (vertices->size())),
60 it = currentMap.find(seg2);
62 if (it == currentMap.end())
64 std::vector<Shape*> newList;
65 newList.push_back(shape);
66 currentMap.insert(std::pair<
segment, std::vector<Shape*>>(seg2, newList));
70 it->second.push_back(shape);
76 vector<bool>& isGround)
80 if (!p1->
isSol() && !p2->
isSol() && isGround[seg.first] && isGround[seg.second])
109 for (
unsigned int i = 0; i < vertices->size(); i++)
111 if (vertices->at(i) != seg.first && vertices->at(i) != seg.second)
113 otherVertex = p1->
getVertices()->at(vertices->at(i));
121 vec3 comp = otherVertex - proj;
125 decimal cos_angle = comp.dot(normal);
126 angleOuverture = 2.f * acos(cos_angle);
128 if (cos_angle < cos(
M_PI / 2. + angleMax / 2.))
143 std::vector<Shape*>* shapes = scene->
getShapes();
144 std::vector<bool> isGround(scene->
getVertices()->size(),
false);
146 for (
unsigned int i = 0; i < shapes->size(); i++)
148 Shape* shape = shapes->at(i);
160 ss << segmentList.size() <<
" segments ont ete enregistres." << std::endl;
162 std::set<segment> validSegment;
164 for (mapSegmentShapes::iterator it = segmentList.begin(); it != segmentList.end(); it++)
167 if (it->second.size() == 2)
169 std::set<segment>::iterator itset1 = validSegment.find(it->first);
170 std::set<segment>::iterator itset2 =
171 validSegment.find(std::pair<unsigned int, unsigned int>(it->first.second, it->first.first));
173 if (itset1 == validSegment.end() && itset2 == validSegment.end() &&
174 isAcceptableEdge(it->first, it->second.at(0), it->second.at(1), angleOuverture, isGround))
176 validSegment.insert(it->first);
178 it->first.first, it->first.second, cylinderThick);
181 ss <<
"Ajout du segment (" << it->first.first <<
"," << it->first.second <<
")" << std::endl;
186 ss << validSegment.size() <<
" cylindre ont ete ajoutes." << std::endl;
191 #ifdef _ALLOW_TARGETING_
192 bool PostTreatment::findTargetsForNMPB(
Scene* scene, std::vector<Recepteur>& recepteurs,
196 std::vector<Shape*>* shapes = scene->
getShapes();
197 for (
unsigned int i = 0; i < shapes->size(); i++)
199 if (
dynamic_cast<Triangle*
>(shapes->at(i)))
213 else if (
dynamic_cast<Cylindre*
>(shapes->at(i)))
216 std::vector<vec3> samples;
217 c->sample(density, samples);
222 for (
unsigned int i = 0; i < recepteurs.size(); i++)
230 void PostTreatment::appendDirectionToSources(
TargetManager* targets, std::vector<Source>& sources)
241 for (
unsigned int i = 0; i < sources.size(); i++)
243 sources.at(i).setTargetManager(targets);
244 sources.at(i).setInitialTargetCount(sources.at(i).getInitialRayCount());
std::pair< unsigned int, unsigned int > segment
bool isAcceptableEdge(const segment &seg, Shape *p1, Shape *p2, decimal &angleOuverture, vector< bool > &isGround)
void registerSegmentsFromShapes(Shape *shape, mapSegmentShapes ¤tMap)
std::map< segment, std::vector< Shape * > > mapSegmentShapes
double CylindreThick
Diffraction cylinder diameter.
static AcousticRaytracerConfiguration * get()
Get access to the configuration.
void setAngleOuverture(decimal angle)
This class mainly define a mesh (list of Shape) used by the Simulation object.
std::vector< Shape * > * getShapes()
Return all the shapes.
void addShape(Shape *shape)
Add a shape to the list.
std::vector< vec3 > * getVertices()
Return all the vertices.
base class for shapes (Cylindre, Mesh, Sphere, Triangle,...)
vector< vec3 > * getVertices()
vector< unsigned int > * getLocalVertices()
Get local vertices.
bool isSol() const
Get/Set the flag _isSol (ground or not)
virtual vec3 getNormal(const vec3 pos=vec3())
Get normal.
bool registerTargets(std::vector< vec3 > &newTargets)
Register a vector of targets.
bool registerTarget(const vec3 newTarget)
Register a new target.
bool constructEdge(Scene *scene)
Build the edges list of a scene.
base_vec3< decimal > vec3