+ simplify testing .qm files
+ some triangulation stuff git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5417 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
972e4ad3dd
commit
6b83807dc6
|
@ -86,6 +86,26 @@ void Std_TestQM::activated(int iMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
// Std_TestReloadQM
|
||||||
|
//===========================================================================
|
||||||
|
DEF_STD_CMD(Std_TestReloadQM);
|
||||||
|
|
||||||
|
Std_TestReloadQM::Std_TestReloadQM()
|
||||||
|
: Command("Std_TestReloadQM")
|
||||||
|
{
|
||||||
|
sGroup = "Standard-Test";
|
||||||
|
sMenuText = "Reload translation files";
|
||||||
|
sToolTipText = "Test function to check .qm translation files";
|
||||||
|
sWhatsThis = sToolTipText;
|
||||||
|
sStatusTip = sToolTipText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Std_TestReloadQM::activated(int iMsg)
|
||||||
|
{
|
||||||
|
Translator::instance()->activateLanguage(Translator::instance()->activeLanguage().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// Std_Test1
|
// Std_Test1
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -626,6 +646,7 @@ void CreateTestCommands(void)
|
||||||
CommandManager &rcCmdMgr = Application::Instance->commandManager();
|
CommandManager &rcCmdMgr = Application::Instance->commandManager();
|
||||||
|
|
||||||
rcCmdMgr.addCommand(new Std_TestQM());
|
rcCmdMgr.addCommand(new Std_TestQM());
|
||||||
|
rcCmdMgr.addCommand(new Std_TestReloadQM());
|
||||||
rcCmdMgr.addCommand(new FCCmdTest1());
|
rcCmdMgr.addCommand(new FCCmdTest1());
|
||||||
rcCmdMgr.addCommand(new FCCmdTest2());
|
rcCmdMgr.addCommand(new FCCmdTest2());
|
||||||
rcCmdMgr.addCommand(new FCCmdTest3());
|
rcCmdMgr.addCommand(new FCCmdTest3());
|
||||||
|
|
|
@ -626,23 +626,23 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
unsigned long refPoint0 = *(boundary.begin());
|
unsigned long refPoint0 = *(boundary.begin());
|
||||||
unsigned long refPoint1 = *(boundary.begin()+1);
|
unsigned long refPoint1 = *(boundary.begin()+1);
|
||||||
if (pP2FStructure) {
|
if (pP2FStructure) {
|
||||||
const std::set<unsigned long>& ring = (*pP2FStructure)[refPoint0];
|
const std::set<unsigned long>& ring1 = (*pP2FStructure)[refPoint0];
|
||||||
bool found = false;
|
const std::set<unsigned long>& ring2 = (*pP2FStructure)[refPoint1];
|
||||||
for (std::set<unsigned long>::const_iterator it = ring.begin(); it != ring.end() && !found; ++it) {
|
std::vector<unsigned long> f_int;
|
||||||
for (int i=0; i<3; i++) {
|
std::set_intersection(ring1.begin(), ring1.end(), ring2.begin(), ring2.end(),
|
||||||
if (pP2FStructure->getFacet(*it)->_aulPoints[i] == refPoint1) {
|
std::back_insert_iterator<std::vector<unsigned long> >(f_int));
|
||||||
rFace = *pP2FStructure->getFacet(*it);
|
if (f_int.size() != 1)
|
||||||
|
return false; // error, this must be an open edge!
|
||||||
|
|
||||||
|
rFace = _rclMesh._aclFacetArray[f_int.front()];
|
||||||
rTriangle = _rclMesh.GetFacet(rFace);
|
rTriangle = _rclMesh.GetFacet(rFace);
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bool ready = false;
|
bool ready = false;
|
||||||
for (MeshFacetArray::_TConstIterator it = _rclMesh._aclFacetArray.begin(); it != _rclMesh._aclFacetArray.end(); ++it) {
|
for (MeshFacetArray::_TConstIterator it = _rclMesh._aclFacetArray.begin(); it != _rclMesh._aclFacetArray.end(); ++it) {
|
||||||
for (int i=0; i<3; i++) {
|
for (int i=0; i<3; i++) {
|
||||||
if ((it->_aulPoints[i] == refPoint0) && (it->_aulPoints[(i+1)%3] == refPoint1)) {
|
if ((it->_aulPoints[i] == refPoint0) && (it->_aulPoints[(i+1)%3] == refPoint1) ||
|
||||||
|
(it->_aulPoints[i] == refPoint1) && (it->_aulPoints[(i+1)%3] == refPoint0)) {
|
||||||
rFace = *it;
|
rFace = *it;
|
||||||
rTriangle = _rclMesh.GetFacet(*it);
|
rTriangle = _rclMesh.GetFacet(*it);
|
||||||
ready = true;
|
ready = true;
|
||||||
|
@ -663,7 +663,9 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the last added point if it is duplicated
|
// remove the last added point if it is duplicated
|
||||||
|
std::vector<unsigned long> bounds = boundary;
|
||||||
if (boundary.front() == boundary.back()) {
|
if (boundary.front() == boundary.back()) {
|
||||||
|
bounds.pop_back();
|
||||||
polygon.pop_back();
|
polygon.pop_back();
|
||||||
rPoints.pop_back();
|
rPoints.pop_back();
|
||||||
}
|
}
|
||||||
|
@ -672,6 +674,7 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
// Afterwards we can compare the normals of the created triangles with the z-direction of our local coordinate system.
|
// Afterwards we can compare the normals of the created triangles with the z-direction of our local coordinate system.
|
||||||
// If the scalar product is positive it was a hole, otherwise not.
|
// If the scalar product is positive it was a hole, otherwise not.
|
||||||
cTria.SetPolygon(polygon);
|
cTria.SetPolygon(polygon);
|
||||||
|
cTria.SetIndices(bounds);
|
||||||
|
|
||||||
std::vector<Base::Vector3f> surf_pts = cTria.GetPolygon();
|
std::vector<Base::Vector3f> surf_pts = cTria.GetPolygon();
|
||||||
if (pP2FStructure && level > 0) {
|
if (pP2FStructure && level > 0) {
|
||||||
|
@ -685,7 +688,7 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
if (cTria.TriangulatePolygon()) {
|
if (cTria.TriangulatePolygon()) {
|
||||||
// if we have enough points then we fit a surface through the points and project
|
// if we have enough points then we fit a surface through the points and project
|
||||||
// the added points onto this surface
|
// the added points onto this surface
|
||||||
cTria.ProjectOntoSurface(surf_pts);
|
cTria.PostProcessing(surf_pts);
|
||||||
// get the facets and add the additional points to the array
|
// get the facets and add the additional points to the array
|
||||||
rFaces.insert(rFaces.end(), cTria.GetFacets().begin(), cTria.GetFacets().end());
|
rFaces.insert(rFaces.end(), cTria.GetFacets().begin(), cTria.GetFacets().end());
|
||||||
std::vector<Base::Vector3f> newVertices = cTria.AddedPoints();
|
std::vector<Base::Vector3f> newVertices = cTria.AddedPoints();
|
||||||
|
@ -693,7 +696,7 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
rPoints.push_back((*pt));
|
rPoints.push_back((*pt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfortunately, the CDT algorithm does not care about the orientation of the polygon so we cannot rely on the normal
|
// Unfortunately, some algorithms do not care about the orientation of the polygon so we cannot rely on the normal
|
||||||
// criterion to decide whether it's a hole or not.
|
// criterion to decide whether it's a hole or not.
|
||||||
//
|
//
|
||||||
std::vector<MeshFacet> faces = cTria.GetFacets();
|
std::vector<MeshFacet> faces = cTria.GetFacets();
|
||||||
|
@ -701,10 +704,12 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
// Special case handling for a hole with three edges: the resulting facet might be coincident with the
|
// Special case handling for a hole with three edges: the resulting facet might be coincident with the
|
||||||
// reference facet
|
// reference facet
|
||||||
if (faces.size()==1){
|
if (faces.size()==1){
|
||||||
MeshFacet first;
|
MeshFacet first = faces.front();
|
||||||
first._aulPoints[0] = boundary[faces.front()._aulPoints[0]];
|
if (cTria.NeedsReindexing()) {
|
||||||
first._aulPoints[1] = boundary[faces.front()._aulPoints[1]];
|
first._aulPoints[0] = boundary[first._aulPoints[0]];
|
||||||
first._aulPoints[2] = boundary[faces.front()._aulPoints[2]];
|
first._aulPoints[1] = boundary[first._aulPoints[1]];
|
||||||
|
first._aulPoints[2] = boundary[first._aulPoints[2]];
|
||||||
|
}
|
||||||
if (first.IsEqual(rFace)) {
|
if (first.IsEqual(rFace)) {
|
||||||
rFaces.clear();
|
rFaces.clear();
|
||||||
rPoints.clear();
|
rPoints.clear();
|
||||||
|
@ -717,9 +722,14 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
MeshFacet facet;
|
MeshFacet facet;
|
||||||
unsigned short ref_side = rFace.Side(refPoint0, refPoint1);
|
unsigned short ref_side = rFace.Side(refPoint0, refPoint1);
|
||||||
unsigned short tri_side = USHRT_MAX;
|
unsigned short tri_side = USHRT_MAX;
|
||||||
|
if (cTria.NeedsReindexing()) {
|
||||||
|
// the referenced indices of the polyline
|
||||||
|
refPoint0 = 0;
|
||||||
|
refPoint1 = 1;
|
||||||
|
}
|
||||||
if (ref_side < USHRT_MAX) {
|
if (ref_side < USHRT_MAX) {
|
||||||
for (std::vector<MeshFacet>::iterator it = faces.begin(); it != faces.end(); ++it) {
|
for (std::vector<MeshFacet>::iterator it = faces.begin(); it != faces.end(); ++it) {
|
||||||
tri_side = it->Side(0, 1);
|
tri_side = it->Side(refPoint0, refPoint1);
|
||||||
if (tri_side < USHRT_MAX) {
|
if (tri_side < USHRT_MAX) {
|
||||||
facet = *it;
|
facet = *it;
|
||||||
break;
|
break;
|
||||||
|
@ -737,10 +747,9 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
MeshGeomFacet triangle;
|
MeshGeomFacet triangle;
|
||||||
triangle._aclPoints[0] = rPoints[facet._aulPoints[0]];
|
triangle = cTria.GetTriangle(rPoints, facet);
|
||||||
triangle._aclPoints[1] = rPoints[facet._aulPoints[1]];
|
|
||||||
triangle._aclPoints[2] = rPoints[facet._aulPoints[2]];
|
|
||||||
|
|
||||||
// Now we have two adjacent triangles which we check for overlaps.
|
// Now we have two adjacent triangles which we check for overlaps.
|
||||||
// Therefore we build a separation plane that must separate the two diametrically opposed points.
|
// Therefore we build a separation plane that must separate the two diametrically opposed points.
|
||||||
|
@ -763,6 +772,7 @@ bool MeshAlgorithm::FillupHole(const std::vector<unsigned long>& boundary,
|
||||||
for (MeshFacetArray::_TIterator it = rFaces.begin(); it != rFaces.end(); ++it)
|
for (MeshFacetArray::_TIterator it = rFaces.begin(); it != rFaces.end(); ++it)
|
||||||
it->FlipNormal();
|
it->FlipNormal();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1764,6 +1774,7 @@ void MeshRefPointToFacets::SearchNeighbours(MeshFacetArray::_TConstIterator f_it
|
||||||
rclNb.push_back(f_it);
|
rclNb.push_back(f_it);
|
||||||
f_it->SetFlag(MeshFacet::VISIT);
|
f_it->SetFlag(MeshFacet::VISIT);
|
||||||
|
|
||||||
|
MeshPointArray::_TConstIterator p_beg = _rclMesh.GetPoints().begin();
|
||||||
MeshFacetArray::_TConstIterator f_beg = _rclMesh.GetFacets().begin();
|
MeshFacetArray::_TConstIterator f_beg = _rclMesh.GetFacets().begin();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|
|
@ -1237,55 +1237,20 @@ void MeshTopoAlgorithm::FillupHoles(unsigned long length, int level,
|
||||||
std::list<std::vector<unsigned long> >& aFailed)
|
std::list<std::vector<unsigned long> >& aFailed)
|
||||||
{
|
{
|
||||||
// get the mesh boundaries as an array of point indices
|
// get the mesh boundaries as an array of point indices
|
||||||
std::list<std::vector<unsigned long> > aBorders;
|
std::list<std::vector<unsigned long> > aBorders, aFillBorders;
|
||||||
MeshAlgorithm cAlgo(_rclMesh);
|
MeshAlgorithm cAlgo(_rclMesh);
|
||||||
cAlgo.GetMeshBorders(aBorders);
|
cAlgo.GetMeshBorders(aBorders);
|
||||||
|
|
||||||
// split boundary loops if needed
|
// split boundary loops if needed
|
||||||
cAlgo.SplitBoundaryLoops(aBorders);
|
cAlgo.SplitBoundaryLoops(aBorders);
|
||||||
|
|
||||||
// get the facets to a point
|
|
||||||
MeshRefPointToFacets cPt2Fac(_rclMesh);
|
|
||||||
|
|
||||||
MeshFacetArray newFacets;
|
|
||||||
MeshPointArray newPoints;
|
|
||||||
unsigned long numberOfOldPoints = _rclMesh._aclPointArray.size();
|
|
||||||
for (std::list<std::vector<unsigned long> >::iterator it = aBorders.begin(); it != aBorders.end(); ++it) {
|
for (std::list<std::vector<unsigned long> >::iterator it = aBorders.begin(); it != aBorders.end(); ++it) {
|
||||||
if ( it->size()-1 > length )
|
if (it->size()-1 <= length) // ignore boundary with too many edges
|
||||||
continue; // boundary with too many edges
|
aFillBorders.push_back(*it);
|
||||||
MeshFacetArray cFacets;
|
|
||||||
MeshPointArray cPoints;
|
|
||||||
if (cAlgo.FillupHole(*it, cTria, cFacets, cPoints, level, &cPt2Fac)) {
|
|
||||||
if (it->front() == it->back())
|
|
||||||
it->pop_back();
|
|
||||||
// the triangulation may produce additional points which we must take into account when appending to the mesh
|
|
||||||
unsigned long countBoundaryPoints = it->size();
|
|
||||||
unsigned long countDifference = cPoints.size() - countBoundaryPoints;
|
|
||||||
if (countDifference > 0) {
|
|
||||||
MeshPointArray::_TIterator pt = cPoints.begin() + countBoundaryPoints;
|
|
||||||
for (unsigned long i=0; i<countDifference; i++, pt++) {
|
|
||||||
it->push_back(numberOfOldPoints++);
|
|
||||||
newPoints.push_back(*pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (MeshFacetArray::_TIterator kt = cFacets.begin(); kt != cFacets.end(); ++kt ) {
|
|
||||||
kt->_aulPoints[0] = (*it)[kt->_aulPoints[0]];
|
|
||||||
kt->_aulPoints[1] = (*it)[kt->_aulPoints[1]];
|
|
||||||
kt->_aulPoints[2] = (*it)[kt->_aulPoints[2]];
|
|
||||||
newFacets.push_back(*kt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
aFailed.push_back(*it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert new points and faces into the mesh structure
|
if (!aFillBorders.empty())
|
||||||
_rclMesh._aclPointArray.insert(_rclMesh._aclPointArray.end(), newPoints.begin(), newPoints.end());
|
FillupHoles(level, cTria, aFillBorders, aFailed);
|
||||||
for (MeshPointArray::_TIterator it = newPoints.begin(); it != newPoints.end(); ++it)
|
|
||||||
_rclMesh._clBoundBox &= *it;
|
|
||||||
if (!newFacets.empty())
|
|
||||||
_rclMesh.AddFacets(newFacets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTria,
|
void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTria,
|
||||||
|
@ -1307,15 +1272,16 @@ void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTri
|
||||||
if (bound.front() == bound.back())
|
if (bound.front() == bound.back())
|
||||||
bound.pop_back();
|
bound.pop_back();
|
||||||
// the triangulation may produce additional points which we must take into account when appending to the mesh
|
// the triangulation may produce additional points which we must take into account when appending to the mesh
|
||||||
|
if (cPoints.size() > bound.size()) {
|
||||||
unsigned long countBoundaryPoints = bound.size();
|
unsigned long countBoundaryPoints = bound.size();
|
||||||
unsigned long countDifference = cPoints.size() - countBoundaryPoints;
|
unsigned long countDifference = cPoints.size() - countBoundaryPoints;
|
||||||
if (countDifference > 0) {
|
|
||||||
MeshPointArray::_TIterator pt = cPoints.begin() + countBoundaryPoints;
|
MeshPointArray::_TIterator pt = cPoints.begin() + countBoundaryPoints;
|
||||||
for (unsigned long i=0; i<countDifference; i++, pt++) {
|
for (unsigned long i=0; i<countDifference; i++, pt++) {
|
||||||
bound.push_back(numberOfOldPoints++);
|
bound.push_back(numberOfOldPoints++);
|
||||||
newPoints.push_back(*pt);
|
newPoints.push_back(*pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cTria.NeedsReindexing()) {
|
||||||
for (MeshFacetArray::_TIterator kt = cFacets.begin(); kt != cFacets.end(); ++kt ) {
|
for (MeshFacetArray::_TIterator kt = cFacets.begin(); kt != cFacets.end(); ++kt ) {
|
||||||
kt->_aulPoints[0] = bound[kt->_aulPoints[0]];
|
kt->_aulPoints[0] = bound[kt->_aulPoints[0]];
|
||||||
kt->_aulPoints[1] = bound[kt->_aulPoints[1]];
|
kt->_aulPoints[1] = bound[kt->_aulPoints[1]];
|
||||||
|
@ -1323,6 +1289,12 @@ void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTri
|
||||||
newFacets.push_back(*kt);
|
newFacets.push_back(*kt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for (MeshFacetArray::_TIterator kt = cFacets.begin(); kt != cFacets.end(); ++kt ) {
|
||||||
|
newFacets.push_back(*kt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
aFailed.push_back(*it);
|
aFailed.push_back(*it);
|
||||||
}
|
}
|
||||||
|
@ -1332,8 +1304,24 @@ void MeshTopoAlgorithm::FillupHoles(int level, AbstractPolygonTriangulator& cTri
|
||||||
_rclMesh._aclPointArray.insert(_rclMesh._aclPointArray.end(), newPoints.begin(), newPoints.end());
|
_rclMesh._aclPointArray.insert(_rclMesh._aclPointArray.end(), newPoints.begin(), newPoints.end());
|
||||||
for (MeshPointArray::_TIterator it = newPoints.begin(); it != newPoints.end(); ++it)
|
for (MeshPointArray::_TIterator it = newPoints.begin(); it != newPoints.end(); ++it)
|
||||||
_rclMesh._clBoundBox &= *it;
|
_rclMesh._clBoundBox &= *it;
|
||||||
if (!newFacets.empty())
|
if (!newFacets.empty()) {
|
||||||
_rclMesh.AddFacets(newFacets);
|
// Do some checks for invalid point indices
|
||||||
|
MeshFacetArray addFacets;
|
||||||
|
addFacets.reserve(newFacets.size());
|
||||||
|
unsigned long ctPoints = _rclMesh.CountPoints();
|
||||||
|
for (MeshFacetArray::_TIterator it = newFacets.begin(); it != newFacets.end(); ++it) {
|
||||||
|
if (it->_aulPoints[0] >= ctPoints ||
|
||||||
|
it->_aulPoints[1] >= ctPoints ||
|
||||||
|
it->_aulPoints[2] >= ctPoints) {
|
||||||
|
Base::Console().Log("Ignore invalid face <%d, %d, %d> (%d vertices)\n",
|
||||||
|
it->_aulPoints[0], it->_aulPoints[1], it->_aulPoints[2], ctPoints);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addFacets.push_back(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_rclMesh.AddFacets(addFacets);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshTopoAlgorithm::FindHoles(unsigned long length,
|
void MeshTopoAlgorithm::FindHoles(unsigned long length,
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <Base/Exception.h>
|
#include <Base/Exception.h>
|
||||||
#include "Triangulation.h"
|
#include "Triangulation.h"
|
||||||
#include "Approximation.h"
|
#include "Approximation.h"
|
||||||
|
#include "Algorithm.h"
|
||||||
#include "MeshKernel.h"
|
#include "MeshKernel.h"
|
||||||
|
|
||||||
#include <Mod/Mesh/App/WildMagic4/Wm4Delaunay2.h>
|
#include <Mod/Mesh/App/WildMagic4/Wm4Delaunay2.h>
|
||||||
|
@ -121,7 +122,7 @@ std::vector<Base::Vector3f> AbstractPolygonTriangulator::ProjectToFitPlane()
|
||||||
return proj;
|
return proj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractPolygonTriangulator::ProjectOntoSurface(const std::vector<Base::Vector3f>& points)
|
void AbstractPolygonTriangulator::PostProcessing(const std::vector<Base::Vector3f>& points)
|
||||||
{
|
{
|
||||||
// For a good approximation we should have enough points, i.e. for 9 parameters
|
// For a good approximation we should have enough points, i.e. for 9 parameters
|
||||||
// for the fit function we should have at least 50 points.
|
// for the fit function we should have at least 50 points.
|
||||||
|
@ -144,9 +145,23 @@ void AbstractPolygonTriangulator::ProjectOntoSurface(const std::vector<Base::Vec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MeshGeomFacet AbstractPolygonTriangulator::GetTriangle(const MeshPointArray& points,
|
||||||
|
const MeshFacet& facet) const
|
||||||
|
{
|
||||||
|
MeshGeomFacet triangle;
|
||||||
|
triangle._aclPoints[0] = points[facet._aulPoints[0]];
|
||||||
|
triangle._aclPoints[1] = points[facet._aulPoints[1]];
|
||||||
|
triangle._aclPoints[2] = points[facet._aulPoints[2]];
|
||||||
|
return triangle;
|
||||||
|
}
|
||||||
|
|
||||||
bool AbstractPolygonTriangulator::TriangulatePolygon()
|
bool AbstractPolygonTriangulator::TriangulatePolygon()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
if (this->_points.size() != this->_indices.size()) {
|
||||||
|
Base::Console().Log("Triangulation: %d points <> %d indices\n", _points.size(), _indices.size());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool ok = Triangulate();
|
bool ok = Triangulate();
|
||||||
if (ok) Done();
|
if (ok) Done();
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -177,6 +192,10 @@ void AbstractPolygonTriangulator::Discard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractPolygonTriangulator::Reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractPolygonTriangulator::Done()
|
void AbstractPolygonTriangulator::Done()
|
||||||
{
|
{
|
||||||
_info.push_back(_points.size());
|
_info.push_back(_points.size());
|
||||||
|
@ -625,7 +644,7 @@ bool FlatTriangulator::Triangulate()
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatTriangulator::ProjectOntoSurface(const std::vector<Base::Vector3f>&)
|
void FlatTriangulator::PostProcessing(const std::vector<Base::Vector3f>&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +688,8 @@ bool ConstraintDelaunayTriangulator::Triangulate()
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
Triangulator::Triangulator(const MeshKernel& k) : _kernel(k)
|
#if 0
|
||||||
|
Triangulator::Triangulator(const MeshKernel& k, bool flat) : _kernel(k)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,3 +701,23 @@ bool Triangulator::Triangulate()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MeshGeomFacet Triangulator::GetTriangle(const MeshPointArray&,
|
||||||
|
const MeshFacet& facet) const
|
||||||
|
{
|
||||||
|
return MeshGeomFacet();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Triangulator::PostProcessing(const std::vector<Base::Vector3f>&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Triangulator::Discard()
|
||||||
|
{
|
||||||
|
AbstractPolygonTriangulator::Discard();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Triangulator::Reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -39,6 +39,15 @@ public:
|
||||||
|
|
||||||
/** Sets the polygon to be triangulated. */
|
/** Sets the polygon to be triangulated. */
|
||||||
void SetPolygon(const std::vector<Base::Vector3f>& raclPoints);
|
void SetPolygon(const std::vector<Base::Vector3f>& raclPoints);
|
||||||
|
void SetIndices(const std::vector<unsigned long>& d) {_indices = d;}
|
||||||
|
/** Usually the created faces use the indices of the polygon points
|
||||||
|
* from [0, n]. If the faces should be appended to an existing mesh
|
||||||
|
* they may need to be reindexed from the calling instance.
|
||||||
|
* However, there may other algorithms that directly use the indices
|
||||||
|
* of the mesh and thus do not need to be touched afterwards. In this
|
||||||
|
* case the method should be reimplemented to return false.
|
||||||
|
*/
|
||||||
|
virtual bool NeedsReindexing() const { return true; }
|
||||||
/** Get the polygon points to be triangulated. The points may be
|
/** Get the polygon points to be triangulated. The points may be
|
||||||
* projected onto its average plane.
|
* projected onto its average plane.
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +55,7 @@ public:
|
||||||
/** The triangulation algorithm may create new points when
|
/** The triangulation algorithm may create new points when
|
||||||
* calling Triangulate(). This method returns these added
|
* calling Triangulate(). This method returns these added
|
||||||
* points.
|
* points.
|
||||||
* @note: Make sure to have called ProjectOntoSurface() before using
|
* @note: Make sure to have called PostProcessing() before using
|
||||||
* this method if you want the surface points the new points are lying on.
|
* this method if you want the surface points the new points are lying on.
|
||||||
*/
|
*/
|
||||||
std::vector<Base::Vector3f> AddedPoints() const;
|
std::vector<Base::Vector3f> AddedPoints() const;
|
||||||
|
@ -65,11 +74,13 @@ public:
|
||||||
/** If points were added then we get the 3D points by projecting the added
|
/** If points were added then we get the 3D points by projecting the added
|
||||||
* 2D points onto a surface which fits into the given points.
|
* 2D points onto a surface which fits into the given points.
|
||||||
*/
|
*/
|
||||||
virtual void ProjectOntoSurface(const std::vector<Base::Vector3f>&);
|
virtual void PostProcessing(const std::vector<Base::Vector3f>&);
|
||||||
/** Returns the geometric triangles of the polygon. */
|
/** Returns the geometric triangles of the polygon. */
|
||||||
const std::vector<MeshGeomFacet>& GetTriangles() const { return _triangles;}
|
const std::vector<MeshGeomFacet>& GetTriangles() const { return _triangles;}
|
||||||
/** Returns the topologic facets of the polygon. */
|
/** Returns the topologic facets of the polygon. */
|
||||||
const std::vector<MeshFacet>& GetFacets() const { return _facets;}
|
const std::vector<MeshFacet>& GetFacets() const { return _facets;}
|
||||||
|
/** Returns the the triangle to a given topologic facet. */
|
||||||
|
virtual MeshGeomFacet GetTriangle(const MeshPointArray&, const MeshFacet&) const;
|
||||||
/** Returns the length of the polygon */
|
/** Returns the length of the polygon */
|
||||||
float GetLength() const;
|
float GetLength() const;
|
||||||
/** Get information about the pol<gons that were processed.
|
/** Get information about the pol<gons that were processed.
|
||||||
|
@ -77,7 +88,9 @@ public:
|
||||||
* polygon.
|
* polygon.
|
||||||
*/
|
*/
|
||||||
std::vector<unsigned long> GetInfo() const;
|
std::vector<unsigned long> GetInfo() const;
|
||||||
void Discard();
|
virtual void Discard();
|
||||||
|
/** Resets some internals. The default implementation does nothing.*/
|
||||||
|
virtual void Reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Computes the triangulation of a polygon. The resulting facets can
|
/** Computes the triangulation of a polygon. The resulting facets can
|
||||||
|
@ -89,6 +102,7 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
bool _discard;
|
bool _discard;
|
||||||
Base::Matrix4D _inverse;
|
Base::Matrix4D _inverse;
|
||||||
|
std::vector<unsigned long> _indices;
|
||||||
std::vector<Base::Vector3f> _points;
|
std::vector<Base::Vector3f> _points;
|
||||||
std::vector<Base::Vector3f> _newpoints;
|
std::vector<Base::Vector3f> _newpoints;
|
||||||
std::vector<MeshGeomFacet> _triangles;
|
std::vector<MeshGeomFacet> _triangles;
|
||||||
|
@ -168,7 +182,7 @@ public:
|
||||||
FlatTriangulator();
|
FlatTriangulator();
|
||||||
~FlatTriangulator();
|
~FlatTriangulator();
|
||||||
|
|
||||||
void ProjectOntoSurface(const std::vector<Base::Vector3f>&);
|
void PostProcessing(const std::vector<Base::Vector3f>&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Triangulate();
|
bool Triangulate();
|
||||||
|
@ -187,17 +201,25 @@ private:
|
||||||
float fMaxArea;
|
float fMaxArea;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
class MeshExport Triangulator : public AbstractPolygonTriangulator
|
class MeshExport Triangulator : public AbstractPolygonTriangulator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Triangulator(const MeshKernel&);
|
Triangulator(const MeshKernel&, bool flat);
|
||||||
~Triangulator();
|
~Triangulator();
|
||||||
|
void Discard();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
bool NeedsReindexing() const { return false; }
|
||||||
|
MeshGeomFacet GetTriangle(const MeshPointArray&, const MeshFacet&) const;
|
||||||
|
void PostProcessing(const std::vector<Base::Vector3f>&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Triangulate();
|
bool Triangulate();
|
||||||
|
|
||||||
const MeshKernel& _kernel;
|
const MeshKernel& _kernel;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace MeshCore
|
} // namespace MeshCore
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class TestWorkbench ( Workbench ):
|
||||||
self.appendToolbar("TestTools",list)
|
self.appendToolbar("TestTools",list)
|
||||||
|
|
||||||
menu = ["Test &Commands","TestToolsGui"]
|
menu = ["Test &Commands","TestToolsGui"]
|
||||||
list = ["Std_TestQM","Test_Test","Test_TestAll","Test_TestDoc","Test_TestBase"]
|
list = ["Std_TestQM","Std_TestReloadQM","Test_Test","Test_TestAll","Test_TestDoc","Test_TestBase"]
|
||||||
self.appendCommandbar("TestToolsGui",list)
|
self.appendCommandbar("TestToolsGui",list)
|
||||||
self.appendMenu(menu,list)
|
self.appendMenu(menu,list)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user