27 typedef std::pair<unsigned int, unsigned int>
segment;
39 std::vector<unsigned int>* vertices =
triangle->getLocalVertices();
40 for (
unsigned int i = 0; i < vertices->size(); i++)
42 segment seg1 = std::pair<unsigned int, unsigned int>(vertices->at(i),
43 vertices->at((i + 1) % (vertices->size())));
44 mapSegmentShapes::iterator it = currentMap.find(seg1);
46 if (it == currentMap.end())
48 std::vector<Shape*> newList;
49 newList.push_back(shape);
50 currentMap.insert(std::pair<
segment, std::vector<Shape*>>(seg1, newList));
54 it->second.push_back(shape);
57 segment seg2 = std::pair<unsigned int, unsigned int>(vertices->at((i + 1) % (vertices->size())),
59 it = currentMap.find(seg2);
61 if (it == currentMap.end())
63 std::vector<Shape*> newList;
64 newList.push_back(shape);
65 currentMap.insert(std::pair<
segment, std::vector<Shape*>>(seg2, newList));
69 it->second.push_back(shape);
75 std::vector<bool>& isGround)
79 if (!p1->
isSol() && !p2->
isSol() && isGround[seg.first] && isGround[seg.second])
108 for (
unsigned int i = 0; i < vertices->size(); i++)
110 if (vertices->at(i) != seg.first && vertices->at(i) != seg.second)
112 otherVertex = p1->
getVertices()->at(vertices->at(i));
120 vec3 comp = otherVertex - proj;
124 decimal cos_angle = comp.dot(normal);
125 angleOuverture = 2.f * acos(cos_angle);
127 if (cos_angle < cos(
M_PI / 2. + angleMax / 2.))
142 std::vector<Shape*>* shapes = scene->
getShapes();
143 std::vector<bool> isGround(scene->
getVertices()->size(),
false);
145 for (
unsigned int i = 0; i < shapes->size(); i++)
147 Shape* shape = shapes->at(i);
159 std::set<segment> validSegment;
161 for (mapSegmentShapes::iterator it = segmentList.begin(); it != segmentList.end(); it++)
164 if (it->second.size() == 2)
166 std::set<segment>::iterator itset1 = validSegment.find(it->first);
167 std::set<segment>::iterator itset2 =
168 validSegment.find(std::pair<unsigned int, unsigned int>(it->first.second, it->first.first));
170 if (itset1 == validSegment.end() && itset2 == validSegment.end() &&
171 isAcceptableEdge(it->first, it->second.at(0), it->second.at(1), angleOuverture, isGround))
173 validSegment.insert(it->first);
175 it->first.first, it->first.second, cylinderThick);
185 #ifdef _ALLOW_TARGETING_
186 bool PostTreatment::findTargetsForNMPB(
Scene* scene, std::vector<Recepteur>& recepteurs,
190 std::vector<Shape*>* shapes = scene->
getShapes();
191 for (
unsigned int i = 0; i < shapes->size(); i++)
193 if (
dynamic_cast<Triangle*
>(shapes->at(i)))
207 else if (
dynamic_cast<Cylindre*
>(shapes->at(i)))
210 std::vector<vec3> samples;
211 c->sample(density, samples);
216 for (
unsigned int i = 0; i < recepteurs.size(); i++)
224 void PostTreatment::appendDirectionToSources(
TargetManager* targets, std::vector<Source>& sources)
235 for (
unsigned int i = 0; i < sources.size(); i++)
237 sources.at(i).setTargetManager(targets);
238 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, std::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,...)
std::vector< unsigned int > * getLocalVertices()
Get local vertices.
std::vector< vec3 > * getVertices()
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