Commit b4752e7e authored by untereiner's avatar untereiner

Merge cgogn:~jund/CGoGN

Conflicts:
	include/Algo/Import/importSvg.hpp
	include/Geometry/intersection.hpp
parents 3f75f814 200b462f
......@@ -49,6 +49,8 @@
#include "Algo/Render/GL2/topo3Render.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __ALGO_BOOLEANOPERATOR_VERTICES_H__
#define __ALGO_BOOLEANOPERATOR_VERTICES_H__
#include "Geometry/basic.h"
#include "Geometry/inclusion.h"
#include "Geometry/orientation.h"
namespace CGoGN
{
namespace Algo
{
namespace BooleanOperator
{
template <typename PFP>
void mergeVertex(typename PFP::MAP& map, const typename PFP::TVEC3& positions, Dart d, Dart e);
template <typename PFP>
void mergeVertices(typename PFP::MAP& map, const typename PFP::TVEC3& positions);
}
}
}
#include "mergeVertices.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace CGoGN
{
namespace Algo
{
namespace BooleanOperator
{
template <typename PFP>
void mergeVertex(typename PFP::MAP& map, const typename PFP::TVEC3& positions, Dart d, Dart e)
{
assert(Geom::arePointsEquals(positions[d],positions[e]) && !map.sameVertex(d,e));
Dart dd;
do
{
dd = map.alpha1(d);
map.removeEdgeFromVertex(dd);
Dart ee = e;
do
{
if(Geom::testOrientation2D(positions[map.phi1(dd)],positions[ee],positions[map.phi1(ee)])!=Geom::RIGHT
&& Geom::testOrientation2D(positions[map.phi1(dd)],positions[ee],positions[map.phi1(map.alpha1(ee))])==Geom::RIGHT)
{
break;
}
ee = map.alpha1(ee);
} while(ee != e);
map.insertEdgeInVertex(ee,dd);
} while(dd!=d);
}
template <typename PFP>
void mergeVertices(typename PFP::MAP& map, const typename PFP::TVEC3& positions)
{
for(Dart d = map.begin() ; d != map.end() ; map.next(d))
{
CellMarker vM(map,VERTEX);
vM.mark(d);
for(Dart dd = map.begin() ; dd != map.end() ; map.next(dd))
{
if(!vM.isMarked(dd))
{
vM.mark(dd);
if(Geom::arePointsEquals(positions[d],positions[dd]))
{
mergeVertex<PFP>(map,positions,d,dd);
}
}
}
}
}
}
}
}
......@@ -95,7 +95,7 @@ void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TV
if(position[dd][0]!=position[map.phi1(dd)][0] || position[dd][1]!=position[map.phi1(dd)][1] || position[dd][2]!=position[map.phi1(dd)][2]) {
out << "cylinder{ " << std::endl;
out << "<" << position[dd][0] << "," << position[dd][2] << "," << position[dd][1] << ">," << std::endl;
out << "<" << position[map.phi1(dd)][0] << "," << position[map.phi1(dd)][2] << "," << position[map.phi1(dd)][1] << ">, 0.5" << std::endl;
out << "<" << position[map.phi1(dd)][0] << "," << position[map.phi1(dd)][2] << "," << position[map.phi1(dd)][1] << ">, 1.5" << std::endl;
out << "}" << std::endl;
}
dd = map.phi1(dd);
......
......@@ -16,7 +16,7 @@ namespace Import
* @param name the name
* @ return true if node has the good name
*/
bool chechXmlNode(xmlNodePtr node, const std::string& name);
bool checkXmlNode(xmlNodePtr node, const std::string& name);
template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position, CellMarker& polygons);
......
This diff is collapsed.
......@@ -71,6 +71,9 @@ public :
void edgeState(const VEC3& current, Geom::Orientation2D sideOfEdge=Geom::ALIGNED);
//just an orientation test : check which dart is aimed to leave the current face to reach an other position
Dart faceOrientationState(const VEC3& toward);
void faceState(const VEC3& current);
void move(const VEC3& newCurrent)
......
......@@ -45,12 +45,6 @@ typename PFP::VEC3 ParticleCell2D<PFP>::intersectLineEdge(const VEC3& pA, const
Geom::intersection2DSegmentSegment(pA,pB,q1,q2,Inter);
// if(VEC3(Inter-pA).norm()>VEC3(pA-pB).norm()) {
// CGoGNout << "probleme : " << pA << "/" << pB << "/" << q1 << "/" << q2 << "/" << Inter << CGoGNendl;
// CGoGNout << "isPointOnHalf " << Algo::Geometry::isPointOnHalfEdge<PFP>(m,d,m_positions,Inter) << CGoGNendl;
// CGoGNout << "isPointOnHalf " << Algo::Geometry::isPointOnHalfEdge<PFP>(m,m.phi1(d),m_positions,Inter) << CGoGNendl;
// }
return Inter;
}
......@@ -74,6 +68,7 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& current)
if(Algo::Geometry::isPointOnVertex<PFP>(m,d,m_positions,current))
{
state = VERTEX;
m_position = current;
return;
}
else
......@@ -101,6 +96,7 @@ void ParticleCell2D<PFP>::vertexState(const VEC3& current)
}
else
{
m_position = current;
state = VERTEX;
return;
}
......@@ -176,6 +172,85 @@ void ParticleCell2D<PFP>::edgeState(const VEC3& current, Geom::Orientation2D sid
vertexState(current);
return;
}
m_position = current;
}
template <typename PFP>
Dart ParticleCell2D<PFP>::faceOrientationState(const VEC3& toward)
{
#ifdef DEBUG
CGoGNout << "faceOrientationState" << d << CGoGNendl;
#endif
assert(std::isfinite(m_position[0]) && std::isfinite(m_position[1]) && std::isfinite(m_position[2]));
assert(std::isfinite(toward[0]) && std::isfinite(toward[1]) && std::isfinite(toward[2]));
Dart res = d;
Dart dd = d;
float wsoe = getOrientationFace(toward, m_position, m.phi1(res));
// orientation step
if(wsoe != Geom::RIGHT)
{
res = m.phi1(res);
wsoe = getOrientationFace(toward, m_position, m.phi1(res));
while(wsoe != Geom::RIGHT && dd != res)
{
res = m.phi1(res);
wsoe = getOrientationFace(toward, m_position, m.phi1(res));
}
// source and position to reach are the same : verify if no edge is crossed due to numerical approximation
if(dd == res)
{
do
{
switch (getOrientationEdge(toward, res))
{
case Geom::LEFT: res = m.phi1(res);
break;
case Geom::ALIGNED:
return res;
case Geom::RIGHT:
return res;
}
} while(res != dd);
return res;
}
}
else
{
wsoe = getOrientationFace(toward,m_position,d);
while(wsoe == Geom::RIGHT && m.phi_1(res) != dd)
{
res = m.phi_1(res);
wsoe = getOrientationFace(toward, m_position, res);
}
// in case of numerical incoherence
if(m.phi_1(res) == dd && wsoe == Geom::RIGHT)
{
res = m.phi_1(res);
do
{
switch (getOrientationEdge(toward, res))
{
case Geom::LEFT :
res = m.phi1(res);
break;
case Geom::ALIGNED :
return res;
case Geom::RIGHT :
return res;
}
} while(res != dd);
return res;
}
}
return res;
}
template <typename PFP>
......@@ -215,10 +290,11 @@ void ParticleCell2D<PFP>::faceState(const VEC3& current)
case Geom::ALIGNED: m_position = current;
edgeState(current);
return;
case Geom::RIGHT: CGoGNout << "smthg went bad " << m_position << " " << current << CGoGNendl;
CGoGNout << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi1(d)] << CGoGNendl;
case Geom::RIGHT:
// CGoGNout << "smthg went bad " << m_position << " " << current << CGoGNendl;
// CGoGNout << "d1 " << m_positions[d] << " d2 " << m_positions[m.phi1(d)] << CGoGNendl;
m_position = intersectLineEdge(current, m_position, d);
CGoGNout << " " << m_position << CGoGNendl;
// CGoGNout << " " << m_position << CGoGNendl;
edgeState(current,Geom::RIGHT);
return;
......@@ -265,7 +341,7 @@ void ParticleCell2D<PFP>::faceState(const VEC3& current)
edgeState(current);
return;
case Geom::RIGHT :
CGoGNout << "smthg went bad(2) " << m_position << CGoGNendl;
// CGoGNout << "smthg went bad(2) " << m_position << CGoGNendl;
m_position = intersectLineEdge(current, m_position, d);
// CGoGNout << " " << m_position << CGoGNendl;
edgeState(current, Geom::RIGHT);
......@@ -300,6 +376,7 @@ void ParticleCell2D<PFP>::faceState(const VEC3& current)
default :
if(wsoe == Geom::ALIGNED)
{
d = m.phi1(d); //to check
m_position = m_positions[d];
vertexState(current);
}
......
......@@ -69,7 +69,7 @@ public:
NoMathNameAttribute(const T& att): T(att) {}
NoMathNameAttribute<T>& operator = (const T& fa) { *this = NoMathNameAttribute<T>(fa); }
NoMathNameAttribute<T>& operator = (const T& fa) { return *this = NoMathNameAttribute<T>(fa); }
void operator += (const NoMathNameAttribute<T>& fa) {}
void operator -= (const NoMathNameAttribute<T>& fa) {}
void operator *= (double v) {}
......
This diff is collapsed.
......@@ -45,11 +45,14 @@ template <typename T>
class Plane3D
{
public:
static std::string CGoGNnameOfType() ;
/**********************************************/
/* CONSTRUCTORS */
/**********************************************/
Plane3D();
Plane3D(int d = 0);
Plane3D(const Plane3D<T>& p);
......
......@@ -28,13 +28,25 @@ namespace CGoGN
namespace Geom
{
template <typename T>
std::string Plane3D<T>::CGoGNnameOfType()
{
std::stringstream ss ;
ss << "Geom::Plane3D<" ;
ss << nameOfType(T()) ;
ss << ">" ;
return ss.str() ;
}
/**********************************************/
/* CONSTRUCTORS */
/**********************************************/
template <typename T>
Plane3D<T>::Plane3D()
{}
Plane3D<T>::Plane3D(int d) :
m_normal(0), m_d(d)
{ }
template <typename T>
Plane3D<T>::Plane3D(const Plane3D<T>& p)
......@@ -110,7 +122,7 @@ void Plane3D<T>::project(Vector<3,T>& p) const
T d = -distance(p) ;
if(abs(d) > PRECISION)
{
Vector<3,T> v = m_normal / d ;
Vector<3,T> v = m_normal * d ;
p += v ;
}
#undef PRECISION
......
......@@ -49,6 +49,12 @@ public:
*/
virtual bool deleteVertex(Dart d) ;
/**
* No attribute is attached to the new edge
* The attributes attached to the face of dart d are kept on the resulting face
*/
virtual void linkVertices(Dart d, Dart e) ;
/**
* No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
......@@ -84,6 +90,18 @@ public:
*/
virtual bool flipBackEdge(Dart d) ;
/**
* The attributes attached to the vertex of dart d are kept on the resulting vertex
* The attributes attached to the face of dart d are overwritten on the face of dart e
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
/**
* The attributes attached to the vertex of dart d are kept on the resulting vertex
* The attributes attached to the face of dart d are overwritten on the face of dart e
*/
virtual void removeEdgeFromVertex(Dart d);
/**
* The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge
* The attributes attached to the edge of d are kept on the resulting edge
......
......@@ -66,6 +66,25 @@ bool EmbeddedMap2<MAP2>::deleteVertex(Dart d)
return false ;
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::linkVertices(Dart d, Dart e)
{
Dart dNext = MAP2::phi1(d) ;
MAP2::linkVertices(d,e);
if (MAP2::isOrbitEmbedded(VERTEX))
{
MAP2::copyDartEmbedding(VERTEX, MAP2::phi_1(e), d) ;
MAP2::copyDartEmbedding(VERTEX, MAP2::phi_1(d), e) ;
}
if (MAP2::isOrbitEmbedded(FACE))
{
MAP2::embedOrbit(FACE, dNext, MAP2::getEmbedding(FACE, dNext)) ;
}
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::cutEdge(Dart d)
{
......@@ -218,6 +237,57 @@ bool EmbeddedMap2<MAP2>::flipBackEdge(Dart d)
return false ;
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::insertEdgeInVertex(Dart d, Dart e)
{
MAP2::insertEdgeInVertex(d, e);
if (MAP2::isOrbitEmbedded(VERTEX))
{
MAP2::copyDartEmbedding(VERTEX, e, d) ;
}
if (MAP2::isOrbitEmbedded(FACE))
{
if(!MAP2::sameFace(d,e))
{
MAP2::embedNewCell(FACE, e);
MAP2::copyCell(FACE, e, d) ;
}
else
{
MAP2::embedOrbit(FACE, d, MAP2::getEmbedding(FACE, d)) ;
}
}
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::removeEdgeFromVertex(Dart d)
{
Dart dPrev = MAP2::alpha_1(d);
MAP2::removeEdgeFromVertex(d);
if (MAP2::isOrbitEmbedded(VERTEX))
{
MAP2::embedNewCell(VERTEX, d);
MAP2::copyCell(VERTEX, d, dPrev);
}
if (MAP2::isOrbitEmbedded(FACE))
{
if(!MAP2::sameFace(d, dPrev))
{
MAP2::embedNewCell(FACE, d);
MAP2::copyCell(FACE, d, dPrev) ;
}
else
{
MAP2::embedOrbit(FACE, d, MAP2::getEmbedding(FACE, d)) ;
}
}
}
template <typename MAP2>
void EmbeddedMap2<MAP2>::sewFaces(Dart d, Dart e)
{
......
......@@ -145,6 +145,13 @@ public:
*/
void splitFace(Dart d, Dart e);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void linkVertices(Dart d, Dart e);
//! Merge the two faces of d and e, darts d & e disappear
/*! \pre Dart d and e MUST belong to distinct faces
* \warning Darts d and e no longer exist after the call
......
......@@ -157,6 +157,14 @@ inline void Map1::splitFace(Dart d, Dart e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
}
inline void Map1::linkVertices(Dart d, Dart e)
{
assert(d != e && !sameOrientedFace(d, e)) ;
Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
}
inline void Map1::mergeFaces(Dart d, Dart e)
{
assert(!sameOrientedFace(d, e)) ;
......
......@@ -125,6 +125,13 @@ public:
*/
virtual bool deleteVertex(Dart d) ;
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
virtual void linkVertices(Dart d, Dart e);
//! Cut the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to cut
*/
......@@ -163,6 +170,20 @@ public:
*/
virtual bool flipBackEdge(Dart d);
//! Insert an edge after a dart in the vertex orbit
/*! \pre Dart d and e MUST be different and belong to distinct face
* \pre Dart e must be phi2-linked with its phi_1 dart
* @param d dart of the vertex
* @param e dart of the edge
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
//! Remove an edge from a vertex orbit
/*! \pre Dart d must be phi2 sewn
* @param d the dart of the edge to remove from the vertex
*/
virtual void removeEdgeFromVertex(Dart d);
//! Sew two oriented faces along oriented edges
/*! \pre Darts d & e MUST be fixed point of phi2 relation
* @param d a dart of the first face
......
......@@ -73,6 +73,12 @@ bool Map2::deleteVertex(Dart d)
return true ;
}
void Map2::linkVertices(Dart d, Dart e)
{
Map1::linkVertices(d, e); // Split the face
phi2sew(phi_1(d), phi_1(e)); // Sew the two resulting faces along the new edge
}
void Map2::cutEdge(Dart d)
{
Map1::cutEdge(d); // Cut the edge of d
......@@ -193,6 +199,20 @@ bool Map2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge
}
void Map2::insertEdgeInVertex(Dart d, Dart e)
{
assert(!sameVertex(d,e) && phi2(e)==phi_1(e));
phi1sew(phi_1(d),phi_1(e));
}
void Map2::removeEdgeFromVertex(Dart d)
{
assert(phi2(d)!=d);
phi1sew(phi_1(d),phi2(d));
}
void Map2::sewFaces(Dart d, Dart e)
{
phi2sew(d, e);
......
......@@ -763,31 +763,34 @@ bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
DartMarkerStore mv(*this,thread); // Lock a marker
bool found = false; // Last functor return value
std::list<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d
std::list<Dart>::iterator darts;
std::vector<Dart> darts_list; //Darts that are traversed
darts_list.reserve(50);
darts_list.push_back(d); //Start with the dart d
mv.mark(d);
for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
for(std::vector<Dart>::iterator darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
{
Dart dc = *darts;
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(dc);
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
if(d2 != dc)
{
darts_list.push_back(d21);
mv.mark(d21);
}
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if((d23!=d2) && !mv.isMarked(d23))
{
darts_list.push_back(d23);
mv.mark(d23);
if(!mv.isMarked(d21))
{
darts_list.push_back(d21);
mv.mark(d21);
}
if((d23!=d2) && !mv.isMarked(d23))
{
darts_list.push_back(d23);
mv.mark(d23);
}
}
found = f(dc);
......
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