Commit 3429cb80 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'master' of cgogn:~jund/CGoGN

Conflicts:
	include/Geometry/intersection.hpp
parents dc1e629f b5395a85
......@@ -43,7 +43,6 @@ add_executable( Geom_inclusionD ./Geom_inclusion.cpp)
target_link_libraries( Geom_inclusionD
${CGoGN_LIBS_D} ${COMMON_LIBS} )
#add_executable( Algo_Geom_inclusionD ./Algo_Geom_inclusion.cpp)
#target_link_libraries( Algo_Geom_inclusionD
# containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( Geom_intersectionD ./Geom_intersection.cpp)
target_link_libraries( Geom_intersectionD
${CGoGN_LIBS_D} ${COMMON_LIBS} )
#include <iostream>
#include <Geometry/intersection.h>
using namespace CGoGN;
int main()
{
typedef Geom::Vec3f VEC3;
std::cout << "Check Geometry/intersection.h" << std::endl;
std::cout << "Check Status : PARTIAL" << std::endl;
// enum Intersection
// {
// NO_INTERSECTION = 0,
// VERTEX_INTERSECTION = 1,
// EDGE_INTERSECTION = 2,
// FACE_INTERSECTION = 3
// } ;
// Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
// Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
// Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
// Intersection intersectionSegmentTriangle(const VEC3& PA, const VEC3& PB, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
std::cout << "Check intersectPlaneRay : Start" << std::endl;
VEC3 p1(0,0,0);
VEC3 p2(5,0,0);
VEC3 p3(5,5,0);
VEC3 p4(5,10,0);
VEC3 p5(5,10,1);
VEC3 p6(10,13,13);
Geom::Plane3D<float> pl1(p1,p2,p3);
Geom::Plane3D<float> pl2(p3,p4,p5);
Geom::Plane3D<float> pl3(p3,p5,p6);
VEC3 res;
if(intersectionPlaneRay(pl1,p4,VEC3(0,1,0),res) == Geom::FACE_INTERSECTION) {
if(p4[0]!=res[0] || p4[1]!=res[1] || p4[2]!=res[2])
std::cout << "ERROR : intersectPlaneRay : point in plane (bad intersection point)" << std::endl;
}
else
std::cout << "ERROR : intersectPlaneRay : point in plane" << std::endl;
if(intersectionPlaneRay(pl1,p5,VEC3(0,0,-1),res) == Geom::FACE_INTERSECTION) {
if(p4[0]!=res[0] || p4[1]!=res[1] || p4[2]!=res[2])
std::cout << "ERROR : intersectPlaneRay : point/plane (bad intersection point)" << std::endl;
}
else
std::cout << "ERROR : intersectPlaneRay : point/plane" << std::endl;
if(intersectionPlaneRay(pl2,p1,VEC3(1,0,0),res) != Geom::FACE_INTERSECTION)
std::cout << "ERROR : intersectPlaneRay (1)" << std::endl;
if(intersectionPlaneRay(pl3,p1,VEC3(1,0,0),res) != Geom::FACE_INTERSECTION)
std::cout << "ERROR : intersectPlaneRay (2)" << std::endl;
if(intersectionPlaneRay(pl2,p1,VEC3(0,1,0),res) == Geom::FACE_INTERSECTION)
std::cout << "ERROR : intersectPlaneRay : ray parallel to plane" << std::endl;
if(intersectionPlaneRay(pl1,p5,VEC3(0,0,1),res) == Geom::FACE_INTERSECTION)
std::cout << "ERROR : intersectPlaneRay : point/plane" << std::endl;
std::cout << "Check intersectPlaneRay : Done" << std::endl;
// Intersection intersection2DSegmentSegment(const VEC3& PA, const VEC3& PB, const VEC3& QA, const VEC3& QB, VEC3& Inter) ;
return 0;
}
......@@ -87,7 +87,7 @@ template <typename VEC3>
Intersection intersectionSegmentTriangle(const VEC3& PA, const VEC3& PB, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
template <typename VEC3, typename PLANE3D>
Intersection intersectPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter);
Intersection intersectionPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter);
template <typename VEC3>
Intersection intersection2DSegmentSegment(const VEC3& PA, const VEC3& PB, const VEC3& QA, const VEC3& QB, VEC3& Inter) ;
......
......@@ -149,7 +149,7 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
return VERTEX_INTERSECTION ;
}
//inter with AB
CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AB" << CGoGNendl ;
// CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AB" << CGoGNendl ;
return EDGE_INTERSECTION ;
}
if(oA == ALIGNED)
......@@ -163,7 +163,7 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
return VERTEX_INTERSECTION ;
}
//inter with AC
CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AC" << CGoGNendl ;
// CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AC" << CGoGNendl ;
return EDGE_INTERSECTION ;
}
if(oPBC == RIGHT) // same side of BC, test this edge
......@@ -179,7 +179,7 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
return VERTEX_INTERSECTION ;
}
//inter with BC
CGoGNout << __FILE__ << " TODO compute edge coplanar intersection BC" << CGoGNendl ;
// CGoGNout << __FILE__ << " TODO compute edge coplanar intersection BC" << CGoGNendl ;
return EDGE_INTERSECTION ;
}
......@@ -194,7 +194,7 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
return VERTEX_INTERSECTION ;
}
//inter with AB
CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AB" << CGoGNendl ;
// CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AB" << CGoGNendl ;
return EDGE_INTERSECTION ;
}
if(oPAB == ALIGNED)
......@@ -214,7 +214,7 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
return VERTEX_INTERSECTION ;
}
//inter with AC
CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AC" << CGoGNendl ;
// CGoGNout << __FILE__ << " TODO compute edge coplanar intersection AC" << CGoGNendl ;
return EDGE_INTERSECTION ;
}
}
......@@ -282,13 +282,27 @@ Intersection intersectionSegmentTriangle(const VEC3& PA, const VEC3& PB, const V
// }
template <typename VEC3, typename PLANE3D>
Intersection intersectPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter)
Intersection intersectionPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter)
{
typename VEC3::DATA_TYPE isect = (pl.normal() * (pl.normal()*pl.d()-p1)) / (pl.normal()*dir);
typename VEC3::DATA_TYPE denom = pl.normal()*dir;
if(denom==0)
{
if(pl.distance(p1)==0)
{
Inter = p1;
return FACE_INTERSECTION;
}
else
return NO_INTERSECTION;
}
typename VEC3::DATA_TYPE isect = ( pl.normal() * (pl.normal()*-1.0f*pl.d()-p1) ) / denom;
Inter = p1 + dir * isect;
if(0.0f <= isect)
{
Inter = p1 + dir * isect;
return FACE_INTERSECTION;
}
......
......@@ -220,7 +220,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
m_cbs->cb_mouseMove(event->button(), event->x(), getHeight() - event->y());
}
void GLWidget::wheelEvent ( QWheelEvent * event )
void GLWidget::wheelEvent(QWheelEvent* event)
{
float wl = -0.05f * FAR_PLANE / foc;
......@@ -233,7 +233,7 @@ void GLWidget::wheelEvent ( QWheelEvent * event )
updateGL();
}
void GLWidget:: keyPressEvent(QKeyEvent* event)
void GLWidget::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Escape)
close();
......
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