Commit 8b368628 authored by untereiner's avatar untereiner

Merge cgogn:~jund/CGoGNTesting

Conflicts:
	CMakeLists.txt
parents e5767ab2 0ccfd614
......@@ -72,6 +72,7 @@ SET (CGoGN_EXT_INCLUDES
${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
# define libs for external libs
......
......@@ -51,7 +51,7 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, VertexAttribute
unsigned int nb = map.faceDegree(d);
if(nb == 3)
Algo::ExportPov::exportTrianglePlain<PFP>(out,position[d],position[map.phi1(d)],position[map.phi1(map.phi1(d))]);
exportTrianglePlain<PFP>(out,position[d],position[map.phi1(d)],position[map.phi1(map.phi1(d))]);
else
{
out << "polygon{ " << nb+1 << std::endl;
......@@ -115,7 +115,7 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, VertexAt
if(!markV.isMarked(dd))
{
markV.mark(dd) ;
VEC3 norm = Algo::Geometry::vertexBorderNormal<PFP>(map,dd,position);
VEC3 norm = Geometry::vertexBorderNormal<PFP>(map,dd,position);
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
......@@ -222,7 +222,7 @@ bool exportScenePov(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>&
out << "count 100 nearest_count 10 error_bound 0.15 recursion_limit 1 low_error_factor 0.2 gray_threshold 0.0 minimum_reuse 0.015 brightness 1 adc_bailout 0.01/2 normal off media off}" << std::endl;
out << "max_trace_level 255}" << std::endl;
Algo::ExportPov::exportMeshPlain<PFP>(out,map,position,"myMesh",good);
exportMeshPlain<PFP>(out,map,position,"myMesh",good);
out << "object {myMesh" << std::endl;
out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
......@@ -266,7 +266,7 @@ bool exportScenePovSmooth(typename PFP::MAP& map, VertexAttribute<typename PFP::
// out << "count 300 nearest_count 10 error_bound 0.15 recursion_limit 1 low_error_factor 0.2 gray_threshold 0.0 minimum_reuse 0.015 brightness 1 adc_bailout 0.01/2 normal off media off}" << std::endl;
out << "max_trace_level 60}" << std::endl;
Algo::ExportPov::export3MeshPlainSmooth<PFP>(out,map,position,"myMesh",good);
export3MeshPlainSmooth<PFP>(out,map,position,"myMesh",good);
out << "object {myMesh" << std::endl;
out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
......
......@@ -89,9 +89,12 @@ class BoundingBox
// fusion with the given bounding box
void fusion(const BoundingBox<VEC>& bb) ;
// return true if the vector belongs strictly to a bounding box
// return true if the point belongs strictly to a bounding box
bool contains(const VEC& p);
// return true if the segment belongs strictly to a bounding box
bool contains(const VEC& a, const VEC& b);
// return true if the bounding box belongs strictly to a bounding box
bool contains(const BoundingBox<VEC> & bb);
......
......@@ -212,6 +212,89 @@ bool BoundingBox<VEC>::contains(const VEC& p)
return true;
}
template <typename VEC>
bool BoundingBox<VEC>::contains(const VEC& a, const VEC& b)
{
assert(m_initialized || !"Bounding box not initialized");
#define LEFT 'l'
#define RIGHT 'r'
#define MIDDLE 'm'
//Algorithm from Graphic Gems
//modified to test segment
VEC dir(b-a); /*ray */
bool inside = true;
char quadrant[m_pMin.dimension()];
VEC candidatePlane;
/* Find candidate planes; this loop can be avoided if
rays cast all from the eye(assume perpsective view) */
for (unsigned int i=0; i< m_pMin.dimension(); i++)
{
if(a[i] < m_pMin[i])
{
quadrant[i] = LEFT;
candidatePlane[i] = m_pMin[i];
inside = false;
}
else if (a[i] > m_pMax[i])
{
quadrant[i] = RIGHT;
candidatePlane[i] = m_pMax[i];
inside = false;
}
else
{
quadrant[i] = MIDDLE;
}
}
/* Ray origin inside bounding box */
if(inside)
return true;
VEC maxT;
VEC coord; /* hit point */
/* Calculate T distances to candidate planes */
for(unsigned int i = 0; i < m_pMin.dimension(); i++)
{
if (quadrant[i] != MIDDLE && dir[i] !=0)
maxT[i] = (candidatePlane[i]-a[i]) / dir[i];
else
maxT[i] = -1.;
}
#undef LEFT
#undef RIGHT
#undef MIDDLE
/* Get largest of the maxT's for final choice of intersection */
unsigned int whichPlane = 0;
for(unsigned int i = 1; i < m_pMin.dimension(); i++)
if (maxT[whichPlane] < maxT[i])
whichPlane = i;
/* Check final candidate actually inside box */
if (maxT[whichPlane] < 0.)
return false;
for (unsigned int i = 0; i < m_pMin.dimension(); i++)
{
if (whichPlane != i)
{
coord[i] = a[i] + maxT[whichPlane] *dir[i];
if (coord[i] < m_pMin[i] || coord[i] > m_pMax[i])
return false;
else
coord[i] = candidatePlane[i];
}
}
return VEC(coord-b)*VEC(a-b); /* intersection in segment ?*/
}
template <typename VEC>
bool BoundingBox<VEC>::contains(const BoundingBox<VEC>& bb)
{
......
......@@ -151,7 +151,6 @@ bool isEdgeInOrIntersectingTetrahedron(VEC3 points[4], VEC3& point1, VEC3& point
if(isPointInTetrahedron(points,point1,CCW) || isPointInTetrahedron(points,point1,CCW))
return true ;
VEC3 dir = point2 - point1 ;
VEC3 inter;
if(intersectionSegmentTriangle(point1, point2, points[0], points[1], points[2], inter)
|| intersectionSegmentTriangle(point1, point2, points[0], points[1], points[3], inter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment