[Cam] Remove the Cam module

as discussed here: https://forum.freecadweb.org/viewtopic.php?p=581725#p581725
This commit is contained in:
Uwe
2022-03-21 14:03:56 +01:00
parent 252905d0c7
commit 5766528ff6
53 changed files with 0 additions and 27622 deletions

View File

@@ -1,59 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Jürgen Riegel <Juergen.Riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include <Base/Console.h>
#include <Base/Interpreter.h>
extern struct PyMethodDef Cam_methods[];
PyDoc_STRVAR(module_part_doc,
"This module is the playground for the CAM stuff.");
extern "C"
{
void CamExport initCam()
{
// load dependent module
try {
Base::Interpreter().loadModule("Part");
Base::Interpreter().loadModule("Mesh");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
}
Py_InitModule3("Cam", Cam_methods, module_part_doc); /* mod name, table ptr */
Base::Console().Log("Loading Cam module... done\n");
// NOTE: To finish the initialization of our own type objects we must
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
// This function is responsible for adding inherited slots from a type's base class.
return;
}
} // extern "C"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,134 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* Copyright (c) 2007 Mohamad Najib Muhammad Noor <najib_bean@yahoo.co.uk>
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/**************APPROX.H*********************
*Class Approximate, inheriting from Routines
*Dependencies:- BOOST, ATLAS, UMFPACK, BLAS
* LAPACK
********************************************/
#ifndef APPROX_H
#define APPROX_H
#ifndef NDEBUG //This is for faster matrix operations. In fact, some checks are turned off in the uBlas functions
#define NDEBUG
#endif
/*******MAIN INCLUDE*********/
#include "routine.h"
#include <GeomAdaptor_Surface.hxx>
/*******BOOST********/
#include <boost/numeric/ublas/matrix.hpp>
/*****NAMESPACE******/
using namespace boost::numeric;
/*! \class Approximate
\brief The main class for the approximate routine
Inheriting the Routines class defined in Routines.h, it takes a mesh structure and tolerance level as it's input parameter.
As output, it gives out the following NURBS info:-
Control Points, Knot U, Knot V, Order U, Order V
where Control Points, Knot U, Knot V are of type std::vectors, Order U and Order V of type int
In this program, it will be directly converted into a topo surface from the given information
*/
class CamExport Approximate : protected Routines
{
public:
Approximate(const MeshCore::MeshKernel &m, std::vector<double> &_Cntrl, std::vector<double> &_KnotU, std::vector<double> &_KnotV,
int &_OrderU, int &_OrderV, double tol);
~Approximate();
MeshCore::MeshKernel MeshParam;
GeomAdaptor_Surface aAdaptorSurface;
protected:
void ParameterBoundary();
void ParameterInnerPoints();
void ErrorApprox();
void ApproxMain();
double Reparam();
void eFair2(ublas::compressed_matrix<double> &E_Matrix);
void ComputeError(int &h, double eps_1, double eps_2, double &max_error,
double &av, double &c2, std::vector <double> &err_w);
void ExtendNurb(double c2, int h);
void ReorderNeighbourList(std::set<unsigned long> &pnt,
std::set<unsigned long> &face, std::vector<unsigned long> &nei,unsigned long CurInd);
//void RemakeList(std::vector<MyMesh::VertexHandle> &v_neighbour);
private:
/** @brief Local Mesh */
MeshCore::MeshKernel LocalMesh; //Local Mesh
/** @brief Parameterized Mesh */
MeshCore::MeshKernel ParameterMesh; //Parameterized Mesh - ONLY USED FOR VISUALIZING TO CHECK FOR PARAMETERIZATION ERRORS
/** @brief total number of mesh-points */
int NumOfPoints; //Info about the Mesh
/** @brief number of inner mesh-points */
int NumOfInnerPoints;
/** @brief number of boundary mesh-points */
int NumOfOuterPoints;
/** @brief error-tolerance */
double tolerance; //error level
/** @brief Parametervalues in x-direction*/
ublas::vector<double> ParameterX; //Parameterized Coordinate Lists
/** @brief Parametervalues in y-direction*/
ublas::vector<double> ParameterY;
/** @brief Parametervalues of the boundary-points in x-direction*/
ublas::vector<double> BoundariesX; //Parametrized Boundaries' Coordinate List
/** @brief Parametervalues of the boundary-points in y-direction*/
ublas::vector<double> BoundariesY;
/** @brief Original Boundaries' Coordinate List in x-direction*/
std::vector<double> UnparamBoundariesX; //Original Boundaries' Coordinate List
/** @brief Original Boundaries' Coordinate List in y-direction*/
std::vector<double> UnparamBoundariesY;
/** @brief Original Boundaries' Coordinate List in z-direction*/
std::vector<double> UnparamBoundariesZ;
/** @brief Original Coordinate List in x-direction*/
std::vector<double> UnparamX; //Original Coordinate Lists
/** @brief Original Coordinate List in y-direction*/
std::vector<double> UnparamY;
/** @brief Original Coordinate List in z-direction*/
std::vector<double> UnparamZ;
std::vector<int> mapper;
/** @brief List of indices of the boundary points*/
std::list< std::vector <unsigned long> > BoundariesIndex;
/** @brief List of point-coordinates of the boundary points*/
std::list< std::vector <Base::Vector3f> > BoundariesPoints;
//NURBS
NURBS MainNurb;
//Bounding box
double MinX;
double MaxX;
double MinY;
double MaxY;
};
#endif /*APPROX_H DEFINED*/

View File

@@ -1,517 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Adapted by Joachim Zettler to use with a WireExplorer made *
* by Stephane Routelous *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
//
#include "PreCompiled.h"
#include "BRepAdaptor_CompCurve2.h"
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepAdaptor_HCompCurve.hxx>
#include <BRepAdaptor_HArray1OfCurve.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <BRep_Tool.hxx>
#include <TopAbs_Orientation.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <ElCLib.hxx>
#include <TopExp.hxx>
#include <TopoDS_Vertex.hxx>
#include "WireExplorer.h"
BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2()
{
}
BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2(const TopoDS_Wire& W,
const Standard_Boolean AC)
{
Initialize(W, AC);
}
BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2(const TopoDS_Wire& W,
const Standard_Boolean AC,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol)
{
Initialize(W, AC, First, Last, Tol);
}
void BRepAdaptor_CompCurve2::Initialize(const TopoDS_Wire& W,
const Standard_Boolean AC)
{
Standard_Integer ii, NbEdge;
TopoDS_Edge E;
myWire = W;
WireExplorer wexp(myWire);
PTol = 0.0;
IsbyAC = AC;
for (NbEdge=0, wexp.Init();wexp.More(); wexp.Next())
if (! BRep_Tool::Degenerated(wexp.Current())) NbEdge++;
if (NbEdge == 0) return;
CurIndex = (NbEdge+1)/2;
myCurves = new BRepAdaptor_HArray1OfCurve(1,NbEdge);
myKnots = new (TColStd_HArray1OfReal) (1,NbEdge+1);
myKnots->SetValue(1, 0.);
for (ii=0, wexp.Init();wexp.More(); wexp.Next()) {
E = wexp.Current();
if (! BRep_Tool::Degenerated(E)) {
ii++;
myCurves->ChangeValue(ii).Initialize(E);
if (AC) {
myKnots->SetValue(ii+1, myKnots->Value(ii));
myKnots->ChangeValue(ii+1) +=
GCPnts_AbscissaPoint::Length(myCurves->ChangeValue(ii));
}
else myKnots->SetValue(ii+1, (Standard_Real)ii);
}
}
Forward = Standard_True; // Default; Led Edge Reverse will be counted backward.
if((NbEdge > 2) || ((NbEdge==2) && (!myWire.Closed())) ) {
TopAbs_Orientation Or = myCurves->Value(1).Edge().Orientation();
Standard_Boolean B;
TopoDS_Vertex VI, VL;
B = TopExp::CommonVertex(myCurves->Value(1).Edge(),
myCurves->Value(2).Edge(),
VI);
VL = TopExp::LastVertex(myCurves->Value(1).Edge());
if (VI.IsSame(VL)) { // We always keep the direction of the path
if (Or == TopAbs_REVERSED)
Forward = Standard_False;
}
else {// We always reverse the direction of path
if (Or != TopAbs_REVERSED)
Forward = Standard_False;
}
}
TFirst = 0;
TLast = myKnots->Value(myKnots->Length());
myPeriod = TLast - TFirst;
if (NbEdge == 1) {
Periodic = myCurves->Value(1).IsPeriodic();
}
else {
Periodic = Standard_False;
}
}
void BRepAdaptor_CompCurve2::Initialize(const TopoDS_Wire& W,
const Standard_Boolean AC,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol)
{
Initialize(W, AC);
TFirst = First;
TLast = Last;
PTol = Tol;
// Trim extreme curves.
Handle (BRepAdaptor_HCurve) HC;
Standard_Integer i1, i2;
Standard_Real f=TFirst, l=TLast, d;
i1 = i2 = CurIndex;
Prepare(f, d, i1);
Prepare(l, d, i2);
CurIndex = (i1+i2)/2; // Small optimization
if (i1==i2) {
if (l > f)
HC = Handle(BRepAdaptor_HCurve)::DownCast(myCurves->Value(i1).Trim(f, l, PTol));
else
HC = Handle(BRepAdaptor_HCurve)::DownCast(myCurves->Value(i1).Trim(l, f, PTol));
myCurves->SetValue(i1, HC->ChangeCurve());
}
else {
const BRepAdaptor_Curve& c1 = myCurves->Value(i1);
const BRepAdaptor_Curve& c2 = myCurves->Value(i2);
Standard_Real k;
k = c1.LastParameter();
if (k>f)
HC = Handle(BRepAdaptor_HCurve)::DownCast(c1.Trim(f, k, PTol));
else
HC = Handle(BRepAdaptor_HCurve)::DownCast(c1.Trim(k, f, PTol));
myCurves->SetValue(i1, HC->ChangeCurve());
k = c2.FirstParameter();
if (k<=l)
HC = Handle(BRepAdaptor_HCurve)::DownCast(c2.Trim(k, l, PTol));
else
HC = Handle(BRepAdaptor_HCurve)::DownCast(c2.Trim(l, k, PTol));
myCurves->SetValue(i2, HC->ChangeCurve());
}
}
void BRepAdaptor_CompCurve2::SetPeriodic(const Standard_Boolean isPeriodic)
{
if (myWire.Closed()) {
Periodic = isPeriodic;
}
}
const TopoDS_Wire& BRepAdaptor_CompCurve2::Wire() const
{
return myWire;
}
void BRepAdaptor_CompCurve2::Edge(const Standard_Real U,
TopoDS_Edge& E,
Standard_Real& UonE) const
{
Standard_Real d;
Standard_Integer index = CurIndex;
UonE = U;
Prepare(UonE, d, index);
E = myCurves->Value(index).Edge();
}
Standard_Real BRepAdaptor_CompCurve2::FirstParameter() const
{
return TFirst;
}
Standard_Real BRepAdaptor_CompCurve2::LastParameter() const
{
return TLast;
}
GeomAbs_Shape BRepAdaptor_CompCurve2::Continuity() const
{
if ( myCurves->Length() > 1) return GeomAbs_C0;
return myCurves->Value(1).Continuity();
}
Standard_Integer BRepAdaptor_CompCurve2::NbIntervals(const GeomAbs_Shape S)
{
Standard_Integer NbInt, ii;
for (ii=1, NbInt=0; ii<=myCurves->Length(); ii++)
NbInt += myCurves->ChangeValue(ii).NbIntervals(S);
return NbInt;
}
void BRepAdaptor_CompCurve2::Intervals(TColStd_Array1OfReal& T,
const GeomAbs_Shape S)
{
Standard_Integer ii, jj, kk, n;
Standard_Real f, F, delta;
// First curve (direction of path edge)
n = myCurves->ChangeValue(1).NbIntervals(S);
Handle(TColStd_HArray1OfReal) Ti = new (TColStd_HArray1OfReal) (1, n+1);
myCurves->ChangeValue(1).Intervals(Ti->ChangeArray1(), S);
InvPrepare(1, f, delta);
F = myKnots->Value(1);
if (delta < 0) {
//reverse direction of path
for (kk=1,jj=Ti->Length(); jj>0; kk++, jj--)
T(kk) = F + (Ti->Value(jj)-f)*delta;
}
else {
for (kk=1; kk<=Ti->Length(); kk++)
T(kk) = F + (Ti->Value(kk)-f)*delta;
}
// and the following
for (ii=2; ii<=myCurves->Length(); ii++) {
n = myCurves->ChangeValue(ii).NbIntervals(S);
if (n != Ti->Length()-1) Ti = new (TColStd_HArray1OfReal) (1, n+1);
myCurves->ChangeValue(ii).Intervals(Ti->ChangeArray1(), S);
InvPrepare(ii, f, delta);
F = myKnots->Value(ii);
if (delta < 0) {
//reverse direction of path
for (jj=Ti->Length()-1; jj>0; kk++, jj--)
T(kk) = F + (Ti->Value(jj)-f)*delta;
}
else {
for (jj=2; jj<=Ti->Length(); kk++, jj++)
T(kk) = F + (Ti->Value(jj)-f)*delta;
}
}
}
Standard_Boolean BRepAdaptor_CompCurve2::IsClosed() const
{
return myWire.Closed();
}
Standard_Boolean BRepAdaptor_CompCurve2::IsPeriodic() const
{
return Periodic;
}
Standard_Real BRepAdaptor_CompCurve2::Period() const
{
return myPeriod;
}
gp_Pnt BRepAdaptor_CompCurve2::Value(const Standard_Real U) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
return myCurves->Value(index).Value(u);
}
void BRepAdaptor_CompCurve2::D0(const Standard_Real U,
gp_Pnt& P) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D0(u, P);
}
void BRepAdaptor_CompCurve2::D1(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D1(u, P, V);
V*=d;
}
void BRepAdaptor_CompCurve2::D2(const Standard_Real U,
gp_Pnt& P,
gp_Vec& V1,
gp_Vec& V2) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D2(u, P, V1, V2);
V1*=d;
V2 *= d*d;
}
void BRepAdaptor_CompCurve2::D3(const Standard_Real U,
gp_Pnt& P,gp_Vec& V1,
gp_Vec& V2,
gp_Vec& V3) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
myCurves->Value(index).D3(u, P, V1, V2, V3);
V1*=d;
V2 *= d*d;
V3 *= d*d*d;
}
gp_Vec BRepAdaptor_CompCurve2::DN(const Standard_Real U,
const Standard_Integer N) const
{
Standard_Real u = U, d;
Standard_Integer index = CurIndex;
Prepare(u, d, index);
return (myCurves->Value(index).DN(u, N) * Pow(d, N));
}
Standard_Real BRepAdaptor_CompCurve2::Resolution(const Standard_Real R3d) const
{
Standard_Real Res = 1.e200, r;
Standard_Integer ii, L = myCurves->Length();
for (ii=1; ii<=L; ii++) {
r = myCurves->Value(ii).Resolution(R3d);
if (r < Res) Res = r;
}
return Res;
}
GeomAbs_CurveType BRepAdaptor_CompCurve2::GetType() const
{
return GeomAbs_OtherCurve; //temporary
// if ( myCurves->Length() > 1) return GeomAbs_OtherCurve;
// return myCurves->Value(1).GetType();
}
gp_Lin BRepAdaptor_CompCurve2::Line() const
{
return myCurves->Value(1).Line();
}
gp_Circ BRepAdaptor_CompCurve2::Circle() const
{
return myCurves->Value(1).Circle();
}
gp_Elips BRepAdaptor_CompCurve2::Ellipse() const
{
return myCurves->Value(1).Ellipse();
}
gp_Hypr BRepAdaptor_CompCurve2::Hyperbola() const
{
return myCurves->Value(1).Hyperbola();
}
gp_Parab BRepAdaptor_CompCurve2::Parabola() const
{
return myCurves->Value(1).Parabola();
}
Standard_Integer BRepAdaptor_CompCurve2::Degree() const
{
return myCurves->Value(1).Degree();
}
Standard_Boolean BRepAdaptor_CompCurve2::IsRational() const
{
return myCurves->Value(1).IsRational();
}
Standard_Integer BRepAdaptor_CompCurve2::NbPoles() const
{
return myCurves->Value(1).NbPoles();
}
Standard_Integer BRepAdaptor_CompCurve2::NbKnots() const
{
return myCurves->Value(1).NbKnots();
}
Handle(Geom_BezierCurve) BRepAdaptor_CompCurve2::Bezier() const
{
return myCurves->Value(1).Bezier();
}
Handle(Geom_BSplineCurve) BRepAdaptor_CompCurve2::BSpline() const
{
return myCurves->Value(1).BSpline();
}
//=======================================================================
//function : Prepare
//purpose :
// When the parameter is near a "node" we determine the law by
// function of the sign of Tol:
// - negative -> Law preceding the node.
// - positive -> Law following the node.
//=======================================================================
void BRepAdaptor_CompCurve2::Prepare(Standard_Real& W,
Standard_Real& Delta,
Standard_Integer& CurIndex) const
{
Standard_Real f,l, Wtest, Eps;
Standard_Integer ii;
if (W-TFirst < TLast-W) { Eps = PTol; }
else { Eps = -PTol;}
Wtest = W+Eps; //Offset to discriminate between nodes
if(Periodic){
Wtest = ElCLib::InPeriod(Wtest,
0,
myPeriod);
W = Wtest-Eps;
}
// Index search
Standard_Boolean Trouve = Standard_False;
if (myKnots->Value(CurIndex) > Wtest) {
for (ii=CurIndex-1; ii>0 && !Trouve; ii--)
if (myKnots->Value(ii)<= Wtest) {
CurIndex = ii;
Trouve = Standard_True;
}
if (!Trouve) CurIndex = 1; // Out of bounds...
}
else if (myKnots->Value(CurIndex+1) <= Wtest) {
for (ii=CurIndex+1; ii<=myCurves->Length() && !Trouve; ii++)
if (myKnots->Value(ii+1)> Wtest) {
CurIndex = ii;
Trouve = Standard_True;
}
if (!Trouve) CurIndex = myCurves->Length(); // Out of bounds...
}
// Reverse ?
const TopoDS_Edge& E = myCurves->Value(CurIndex).Edge();
TopAbs_Orientation Or = E.Orientation();
Standard_Boolean Reverse;
Reverse = (Forward && (Or == TopAbs_REVERSED)) ||
(!Forward && (Or != TopAbs_REVERSED));
// Calculation of the local parameter
BRep_Tool::Range(E, f, l);
Delta = myKnots->Value(CurIndex+1) - myKnots->Value(CurIndex);
if (Delta > PTol*1.e-9) Delta = (l-f)/Delta;
if (Reverse) {
Delta *= -1;
W = l + (W-myKnots->Value(CurIndex)) * Delta;
}
else {
W = f + (W-myKnots->Value(CurIndex)) * Delta;
}
}
void BRepAdaptor_CompCurve2::InvPrepare(const Standard_Integer index,
Standard_Real& First,
Standard_Real& Delta) const
{
// Reverse ?
const TopoDS_Edge& E = myCurves->Value(index).Edge();
TopAbs_Orientation Or = E.Orientation();
Standard_Boolean Reverse;
Reverse = (Forward && (Or == TopAbs_REVERSED)) ||
(!Forward && (Or != TopAbs_REVERSED));
// Calculation of reparametrization parameters
// such as: T = Ti + (t-First)*Delta
Standard_Real f, l;
BRep_Tool::Range(E, f, l);
Delta = myKnots->Value(index+1) - myKnots->Value(index);
if (l-f > PTol*1.e-9) Delta /= (l-f);
if (Reverse) {
Delta *= -1;
First = l;
}
else {
First = f;
}
}

View File

@@ -1,285 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Adapted by Joachim Zettler to use with a WireExplorer made *
* by Stephane Routelous *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _BRepAdaptor_CompCurve2_HeaderFile
#define _BRepAdaptor_CompCurve2_HeaderFile
#ifndef _TopoDS_Wire_HeaderFile
#include <TopoDS_Wire.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Handle_BRepAdaptor_HArray1OfCurve_HeaderFile
#include <Handle_BRepAdaptor_HArray1OfCurve.hxx>
#endif
#ifndef _Handle_TColStd_HArray1OfReal_HeaderFile
#include <Handle_TColStd_HArray1OfReal.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Adaptor3d_Curve_HeaderFile
#include <Adaptor3d_Curve.hxx>
#endif
#ifndef _GeomAbs_Shape_HeaderFile
#include <GeomAbs_Shape.hxx>
#endif
#ifndef _Handle_Adaptor3d_HCurve_HeaderFile
#include <Handle_Adaptor3d_HCurve.hxx>
#endif
#ifndef _GeomAbs_CurveType_HeaderFile
#include <GeomAbs_CurveType.hxx>
#endif
#ifndef _Handle_Geom_BezierCurve_HeaderFile
#include <Handle_Geom_BezierCurve.hxx>
#endif
#ifndef _Handle_Geom_BSplineCurve_HeaderFile
#include <Handle_Geom_BSplineCurve.hxx>
#endif
class BRepAdaptor_HArray1OfCurve;
class TColStd_HArray1OfReal;
class Standard_NullObject;
class Standard_DomainError;
class Standard_OutOfRange;
class Standard_NoSuchObject;
class TopoDS_Wire;
class TopoDS_Edge;
class TColStd_Array1OfReal;
class Adaptor3d_HCurve;
class gp_Pnt;
class gp_Vec;
class gp_Lin;
class gp_Circ;
class gp_Elips;
class gp_Hypr;
class gp_Parab;
class Geom_BezierCurve;
class Geom_BSplineCurve;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
//! The Curve from BRepAdaptor allows to use a Wire of the BRep topology
//! like a 3D curve. <br>
//! Warning: With this class of curve, C0 and C1 continuities
//! are not assumed. So be careful with some algorithms!
class BRepAdaptor_CompCurve2 : public Adaptor3d_Curve
{
public:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
void* operator new(size_t size)
{
return Standard::Allocate(size);
}
void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// Methods PUBLIC
//
//! Creates an undefined Curve with no Wire loaded.
Standard_EXPORT BRepAdaptor_CompCurve2();
Standard_EXPORT BRepAdaptor_CompCurve2(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa = Standard_False);
//! Creates a Curve to access to the geometry of edge \p W.
Standard_EXPORT BRepAdaptor_CompCurve2(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa,const Standard_Real First,const Standard_Real Last,const Standard_Real Tol);
//! Sets the wire \p W.
Standard_EXPORT void Initialize(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa) ;
//! Sets wire \p W and trimmed parameter.
Standard_EXPORT void Initialize(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa,const Standard_Real First,const Standard_Real Last,const Standard_Real Tol) ;
//! Set the flag Periodic. <br>
//! Warning: This method has no effect if the wire is not closed.
Standard_EXPORT void SetPeriodic(const Standard_Boolean Periodic) ;
//! Returns the wire.
Standard_EXPORT const TopoDS_Wire& Wire() const;
//! returns an edge and one parameter on them
//! corresponding to the parameter \p U.
Standard_EXPORT void Edge(const Standard_Real U,TopoDS_Edge& E,Standard_Real& UonE) const;
Standard_EXPORT Standard_Real FirstParameter() const;
Standard_EXPORT Standard_Real LastParameter() const;
Standard_EXPORT GeomAbs_Shape Continuity() const;
//! Returns the number of intervals for continuity \<S\>. <br>
//! May be one if Continuity(me) >= \<S\>
Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) ;
//! Stores in \<T\> the parameters bounding the intervals of continuity \<S\>. <br>
//! The array must provide enough room to accommodate for the parameters.
//! i.e. T.Length() > NbIntervals()
Standard_EXPORT void Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) ;
Standard_EXPORT Standard_Boolean IsClosed() const;
Standard_EXPORT Standard_Boolean IsPeriodic() const;
Standard_EXPORT Standard_Real Period() const;
//! Computes the point of parameter \p U on the curve
Standard_EXPORT gp_Pnt Value(const Standard_Real U) const;
//! Computes the point of parameter \p U.
Standard_EXPORT void D0(const Standard_Real U,gp_Pnt& P) const;
//! Computes the point of parameter \p U on the curve with its first
//! derivative. <br>
//! Raised if the continuity of the current interval is not C1.
Standard_EXPORT void D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V) const;
//! Returns the point \p P of parameter \p U, the first and second
//! derivatives \p V1 and \p V2. <br>
//! Raised if the continuity of the current interval is not C2.
Standard_EXPORT void D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const;
//! Returns the point \p P of parameter \p U, the first, the second
//! and the third derivative. <br>
//! Raised if the continuity of the current interval is not C3.
Standard_EXPORT void D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const;
//! The returned vector gives the value of the derivative for the
//! order of derivation N. <br>
//! Raised if the continuity of the current interval is not CN. <br>
//! Raised if N < 1.
Standard_EXPORT gp_Vec DN(const Standard_Real U,const Standard_Integer N) const;
//! returns the parametric resolution
Standard_EXPORT Standard_Real Resolution(const Standard_Real R3d) const;
Standard_EXPORT GeomAbs_CurveType GetType() const;
Standard_EXPORT gp_Lin Line() const;
Standard_EXPORT gp_Circ Circle() const;
Standard_EXPORT gp_Elips Ellipse() const;
Standard_EXPORT gp_Hypr Hyperbola() const;
Standard_EXPORT gp_Parab Parabola() const;
Standard_EXPORT Standard_Integer Degree() const;
Standard_EXPORT Standard_Boolean IsRational() const;
Standard_EXPORT Standard_Integer NbPoles() const;
Standard_EXPORT Standard_Integer NbKnots() const;
Standard_EXPORT Handle_Geom_BezierCurve Bezier() const;
Standard_EXPORT Handle_Geom_BSplineCurve BSpline() const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
Standard_EXPORT void Prepare(Standard_Real& W,Standard_Real& D,Standard_Integer& ind) const;
Standard_EXPORT void InvPrepare(const Standard_Integer ind,Standard_Real& F,Standard_Real& D) const;
// Fields PRIVATE
//
TopoDS_Wire myWire;
Standard_Real TFirst;
Standard_Real TLast;
Standard_Real PTol;
Standard_Real myPeriod;
Handle_BRepAdaptor_HArray1OfCurve myCurves;
Handle_TColStd_HArray1OfReal myKnots;
Standard_Integer CurIndex;
Standard_Boolean Forward;
Standard_Boolean IsbyAC;
Standard_Boolean Periodic;
};
#endif

View File

@@ -1,45 +0,0 @@
#include "BRepUtils.h"
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
double BRepUtils::GetLength(const TopoDS_Edge& edge)
{
GProp_GProps lProps;
BRepGProp::LinearProperties(edge,lProps);
return lProps.Mass();
}
bool BRepUtils::CheckTopologie(const TopoDS_Shape& shape)
{
TopTools_IndexedDataMapOfShapeListOfShape aMap;
aMap.Clear();
TopExp::MapShapesAndAncestors(shape,TopAbs_EDGE,TopAbs_FACE,aMap);
TopExp_Explorer anExplorer;
for(anExplorer.Init(shape,TopAbs_EDGE);anExplorer.More();anExplorer.Next())
{
const TopTools_ListOfShape& aFaceList = aMap.FindFromKey(anExplorer.Current());
TopTools_ListIteratorOfListOfShape aListIterator(aFaceList);
int i=0;
for(aListIterator.Initialize(aFaceList);aListIterator.More();aListIterator.Next())
{
i++;
}
if(i<2)
{
cout << "less" << endl;
}
}
return true;
}

View File

@@ -1,22 +0,0 @@
#ifndef _BRepUtils_HeaderFile
#define _BRepUtils_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class TopoDS_Edge;
class TopoDS_Shape;
class BRepUtils
{
public:
Standard_EXPORT static bool CheckTopologie(const TopoDS_Shape& shape);
Standard_EXPORT static double GetLength(const TopoDS_Edge& edge);
};
#endif //_BRepUtils_HeaderFile

View File

@@ -1,101 +0,0 @@
if(WIN32)
add_definitions(-DWNT -DFCAppCam -DHAVE_ACOSH -DHAVE_ATANH -DHAVE_ASINH)
else(WIN32)
add_definitions(-DFCAppCam)
endif(WIN32)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/3rdParty
${CMAKE_SOURCE_DIR}/src/3rdParty/ANN/include
#${CMAKE_SOURCE_DIR}/src/3rdParty/OCCAdaptMesh/Include
${Boost_INCLUDE_DIRS}
${QT_INCLUDE_DIR}
${OCC_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${UMFPACK_INCLUDE_DIR}
${SMSH_INCLUDE_DIR}
${SMESH_INCLUDE_DIR}
)
if(MSVC)
set(Cam_LIBS
Mesh
Part
${QT_QTCORE_LIBRARY}
${QT_QTCORE_LIBRARY_DEBUG}
ANN
#${ATLAS_LIBRARIES}
importlib_atlas.lib
importlib_umfpackamd.lib
${SMSH_LIBRARIES}
${SMESH_LIBRARIES}
)
else(MSVC)
set(Cam_LIBS
Mesh
Part
${QT_QTCORE_LIBRARY}
${SMESH_LIBRARIES}
ANN
atlas
blas
lapack
umfpack
amd
)
endif(MSVC)
SET(Cam_SRCS
AppCamPy.cpp
deviation.cpp
deviation.h
Approx.cpp
Approx.h
mergedata.h
mergedata.cpp
best_fit.cpp
best_fit.h
BRepAdaptor_CompCurve2.cxx
BRepAdaptor_CompCurve2.h
BRepUtils.h
BRepUtils.cpp
ChangeDyna.cpp
ChangeDyna.h
ConvertDyna.cpp
ConvertDyna.h
cutting_tools.cpp
cutting_tools.h
edgesort.cpp
edgesort.h
path_simulate.cpp
path_simulate.h
PreCompiled.cpp
PreCompiled.h
routine.cpp
routine.h
stuff.h
SpringbackCorrection.cpp
SpringbackCorrection.h
UniGridApprox.cpp
UniGridApprox.h
WireExplorer.cxx
WireExplorer.h
AppCam.cpp
)
add_library(Cam SHARED ${Cam_SRCS})
target_link_libraries(Cam ${Cam_LIBS})
fc_target_copy_resource(Cam
${CMAKE_SOURCE_DIR}/src/Mod/Cam
${CMAKE_BINARY_DIR}/Mod/Cam
Init.py)
SET_BIN_DIR(Cam Cam /Mod/Cam)
if(WIN32)
set_target_properties(Cam PROPERTIES SUFFIX ".pyd")
endif(WIN32)
INSTALL(TARGETS Cam DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -1,184 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "ChangeDyna.h"
#include <sstream>
#include <vector>
#include <fstream>
#include <stdexcept>
ChangeDyna::ChangeDyna()
{
m_ProperTime.clear();
}
bool ChangeDyna::Read( const std::string & _filename)
{
// open file for reading
std::ifstream input( _filename.c_str() );
std::ifstream input2("CurveTimes.k");
if (!input2.is_open()) return false;
if (!ReadTimes(input2)) return false;
std::ofstream output("dyna2.str");
if ( !input.is_open() )
{
std::cout << "failed to open file" << std::endl;
return false;
}
if ( !ReadCurve( input, output ) )
{
std::cout << "failed to read curve_data" << std::endl;
return false;
}
input.close();
output.close();
input2.close();
return true;
}
bool ChangeDyna::ReadTimes(std::ifstream &input2)
{
input2.seekg(std::ifstream::beg);
std::string line;
unsigned int i=0;
std::pair<float,float> tempPair;
std::stringstream astream1;
do
{
std::getline(input2,line);
if (line.size() == 0) continue;
astream1.str(line);
astream1 >> tempPair.first >> tempPair.second;
m_ProperTime.push_back(tempPair);
astream1.str("");
astream1.clear();
}
while (input2.good());
return true;
}
bool ChangeDyna::ReadCurve(std::ifstream &input,std::ofstream &output)
{
input.seekg( std::ifstream::beg );
std::string line,subline1;
bool found = false;
int current_index;
do
{
std::getline( input, line );
if (line.size() == 0) //if we have an empty line
{
continue;
}
if (found)
{
//If we find a new Keyword description
if (line.size() > 3 && line.at(0) == '$' && (line.find("nid") == std::string::npos))
{
found = false;
output << line << std::endl;
continue; //go directly to the next line
}
else if (line.at(0) == '$')
{
output << line << std::endl;
continue;
}
else // Now we change the Birth and Death-Times
{
std::stringstream astream1,astream2;
astream1.precision(20);
astream2.precision(20);
if (line.at(9) != '0') //If we are at the first line
{
//Extract the Curve-Index
astream1.str(line.substr(10,5));
astream1 >> current_index;
//Exchange the Death time. We need a vector of pairs (birth,death)
if ((current_index-2) < 0)
return false;
astream2 << m_ProperTime[current_index-2].second;
//Now we have to reformat the string to fit exactly 9 digits
try
{
ReformatStream(astream2,subline1);
output << line.substr(0,66) << subline1 << line.substr(75,5) << std::endl;
}
catch (const std::out_of_range&)
{
output << line << std::endl;
return false;
}
continue;
}
else //we are at the second line and can exchange the Birth-Time
{
astream2 << m_ProperTime[current_index-2].first;
try
{
ReformatStream(astream2,subline1);
output << line.substr(0,31) << subline1 << std::endl;
}
catch (std::out_of_range)
{
output << line << std::endl;
return false;
}
continue;
}
}
}
else
{
std::string search("Velocity/Acceleration/");
if (line.find(search)!=std::string::npos)
found = true;
output << line << std::endl;
continue;
}
}
while ( input.good());
return true;
}
bool ChangeDyna::ReformatStream(const std::stringstream& astream, std::string& astring)
{
astring.clear();
std::string tempstring(astream.str());
unsigned int found=tempstring.find('.');
astring = tempstring.substr(0,found);
astring += '.';
//Now add the rest. We have only space for 9 digits in total (the '-' is already there)
astring += tempstring.substr(found+1,9-astring.size());
while (astring.size() < 9)
astring += '0'; //We add '0' until we have a size of 9
return true;
}

View File

@@ -1,44 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef CHANGEDYNA_H
#define CHANGEDYNA_H
#include <iosfwd>
#include <string>
#include <vector>
class CamExport ChangeDyna
{
public:
ChangeDyna();
bool Read(const std::string &filename);
// ~ChangeDyna();
private:
bool ReformatStream(const std::stringstream& astream, std::string& astring);
bool ReadCurve(std::ifstream &input,std::ofstream &output);
bool ReadTimes(std::ifstream &input2);
std::vector<std::pair<float,float> > m_ProperTime;
};
#endif

View File

@@ -1,608 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/******CONVERTDYNA.CPP******/
/******MAIN INCLUDES******/
#include "PreCompiled.h"
#include "ConvertDyna.h"
#include <cstdlib>
ReadDyna::ReadDyna(MeshCore::MeshKernel &m, const char* &inputname)
{
//Open the file and perform standard check for file
std::ifstream inputfile;
inputfile.open(inputname);
std::string line;
if (!inputfile.is_open()) //Exists...?
{
std::cerr << "File not found. Exiting..." << std::endl;
return;
}
getline(inputfile,line);
if (line.find("*KEYWORD") == std::string::npos) //Really a DYNA file...?
{
std::cerr << "NOT A DYNA FILE\a" << std::endl;
return;
}
while (inputfile) //First find *NODE Keyword to initialize the VERTICES list (it's the main list)
{
getline(inputfile,line);
if (line.find("*NODE") != std::string::npos)
{
std::cout << "*NODE found. Parsing... ";
ReadNode(inputfile);
std::cout << "done\n";
break;
}
}
inputfile.seekg(std::ios::beg); //bring back the file pointer, you never know where those two other will spawn...
if (inputfile.fail())
inputfile.clear(); //...clear the badbits...
while (inputfile) //and reread.
{
getline(inputfile,line);
if (line.find("*ELEMENT_SHELL_THICKNESS") != std::string::npos) //For Faces
{
std::cout << "*ELEMENT_SHELL_THICKNESS found. Parsing... ";
ReadShellThickness(inputfile);
std::cout << "done\n";
}
else if (line.find("*CONSTRAINED_ADAPTIVITY") != std::string::npos) //For constraints
{
std::cout << "*CONSTRAINED_ADAPTIVITY found. Parsing... ";
ReadConstraints(inputfile);
std::cout << "done\n";
}
}
inputfile.close();
std::cout << "Triangulating... ";
Convert();
std::cout << "done\nWriting into list... ";
PutInMesh(m);
std::cout << "done\n";
}
/*! \brief *NODE Keyword Information Parser
*/
void ReadDyna::ReadNode(std::ifstream &inputfile)
{
std::string line;
getline(inputfile, line);
char *cstr;
char Byte[16] = {0};
char Nibble[8] = {0};
int i = 0, j = 0;
while (line.find("*") == std::string::npos) //while next keyword is not yet found...
{
if (line.find("$") != std::string::npos) //comment, ignore
{
getline(inputfile, line);
continue;
}
VERTICES Temp;
Temp.Constrain = false; //Initialize both flags to false
Temp.Constrained = false;
cstr = new char [line.size()+1];
strcpy(cstr, line.c_str());
for (i = 0; i < 8; i++)
{
Nibble[j] = cstr[i];
j++;
}
Temp.PointIndex = atoi(Nibble); //Index
j = 0;
for (i = 8; i < 24; i++)
{
Byte[j] = cstr[i];
j++;
}
Temp.Coords.push_back(atof(Byte)); //X Coords
j = 0;
for (i = 24; i < 40; i++)
{
Byte[j] = cstr[i];
j++;
}
Temp.Coords.push_back(atof(Byte)); //Y Coords
j = 0;
for (i = 40; i < 56; i++)
{
Byte[j] = cstr[i];
j++;
}
Temp.Coords.push_back(atof(Byte)); //Z Coords
j = 0;
Pointlist.insert(std::pair<unsigned int, VERTICES>(Temp.PointIndex, Temp));
delete[] cstr;
getline(inputfile, line);
}
}
/*! \brief Face Reader
Inside *ELEMENT_SHELL_THICKNESS there's the information about which points makes up a face. All other infos are ignored.
Maybe it is in other keywords there is such infos, but I dunno...
*/
void ReadDyna::ReadShellThickness(std::ifstream &inputfile)
{
std::map<unsigned int, VERTICES>::iterator pnt_it(Pointlist.begin());
std::string line;
char *c_str;
char Info[8] = {0};
int i = 0, j = 0;
getline(inputfile, line);
while (line.find("*") == std::string::npos) //While next keyword is not yet found..
{
if (line.find("$") != std::string::npos) //Ignore the comments
{
getline(inputfile, line);
continue;
}
FACE Temp;
c_str = new char [line.size()+1];
strcpy(c_str, line.c_str());
for (i = 0; i < 8; i++,j++)
Info[j] = c_str[i];
Temp.FaceIndex = atoi(Info); //Facet Index
j= 0;
for (i = 16; i < 24; i++,j++)
Info[j] = c_str[i];
Temp.PointIndex.push_back(atoi(Info)); //First Point
j = 0;
for (i = 24; i < 32; i++,j++)
Info[j] = c_str[i];
Temp.PointIndex.push_back(atoi(Info)); //Second Point
j = 0;
for (i = 32; i < 40; i++,j++)
Info[j] = c_str[i];
Temp.PointIndex.push_back(atoi(Info)); //Third Point
j = 0;
for (i = 40; i < 48; i++,j++)
Info[j] = c_str[i];
Temp.PointIndex.push_back(atoi(Info)); //Fourth Point
j = 0;
getline(inputfile,line);
/*If you need extra info from here, extract it here*/
for (unsigned int k = 0; k < Temp.PointIndex.size(); k++)
{
pnt_it = Pointlist.find(Temp.PointIndex[k]);
(*pnt_it).second.FacetRef.push_back(Temp.FaceIndex); //Put into the Facet Reference
}
Facelist.insert(std::pair<unsigned int,FACE>(Temp.FaceIndex, Temp));
getline(inputfile,line);
}
}
/*! \brief *CONSTRAINTS_ADATIVITY parser
*/
void ReadDyna::ReadConstraints(std::ifstream &inputfile)
{
std::map<unsigned int, VERTICES>::iterator pnt_it(Pointlist.begin());
std::string line;
char *str;
char Info[10] = {0};
int i = 0, j = 0;
unsigned int First;
unsigned int Second;
unsigned int Third;
getline(inputfile, line);
while (line.find("*") == std::string::npos) //While... you know the drill
{
if (line.find("$") != std::string::npos) //Ignore comments...
{
getline(inputfile, line);
continue;
}
str = new char [line.size()+1];
strcpy(str, line.c_str());
for (i = 0; i < 10; i++,j++)
Info[j] = str[i];
First = atoi(Info); //Constrained Point
j = 0;
for (i = 10; i < 20; i++,j++)
Info[j] = str[i];
Second = atoi(Info); //Constrainer 1
j = 0;
for (i = 20; i < 30; i++,j++)
Info[j] = str[i];
Third = atoi(Info); //Constrainer 2
j = 0;
//Set all necessary flags fill the necessary std::vector's
pnt_it = Pointlist.find(First);
(*pnt_it).second.Constrained = true;
(*pnt_it).second.ConstrainedBy.push_back(Second);
(*pnt_it).second.ConstrainedBy.push_back(Third);
pnt_it = Pointlist.find(Second);
(*pnt_it).second.Constrain = true;
(*pnt_it).second.Constraining.push_back(First);
pnt_it = Pointlist.find(Third);
(*pnt_it).second.Constrain = true;
(*pnt_it).second.Constraining.push_back(First);
delete[] str;
getline(inputfile,line);
}
}
/*! \brief Triangulator
This will triangulate the squares, taking note of the constraining point that might come into play.
To date, only three things are considered now: No constraints in the edges, One Constraint in the edges, and Two
Constraints next to each other (not opposite each other!) in the edges
Sparing some commenting... I got lost inside of it too...
*/
void ReadDyna::Convert()
{
std::map<unsigned int, VERTICES>::iterator pnt_it(Pointlist.begin());
std::map<unsigned int, VERTICES>::iterator constraint_it(Pointlist.begin());
std::map<unsigned int, FACE>::iterator face_it(Facelist.begin());
std::vector<unsigned int>::iterator ver_it;
std::vector<unsigned int>::iterator constrainter_it;
for ( ; face_it != Facelist.end(); face_it++) //For every face...
{
FACE CurFace = (*face_it).second;
std::vector<unsigned int> AdditionalPoint;
std::vector<unsigned int> Constrainter;
unsigned int Doubler = 0;
bool HaveConstraint = false;
bool Side = false;
for (unsigned int i = 0; i < CurFace.PointIndex.size(); i++)//...and for every point in the face...
{
pnt_it = Pointlist.find(CurFace.PointIndex[i]);
if ((*pnt_it).second.Constrain)//...does it constraining any other points?
{
int NumOfConstraint = 0;
for (unsigned int j = 0; j < (*pnt_it).second.Constraining.size(); j++) //Yes, so for every point it constraints...
{
constraint_it = Pointlist.find((*pnt_it).second.Constraining[j]);
if ((constrainter_it = find(CurFace.PointIndex.begin(),CurFace.PointIndex.end(),
(*constraint_it).second.PointIndex)) != CurFace.PointIndex.end()) //...does the constraint point also a part of the current face?
{
continue; //Yes, so skip it.
}
unsigned int ver = (*constraint_it).second.ConstrainedBy[0]; //No, so...
if (ver == CurFace.PointIndex[i]) //...the point is current point?
ver = (*constraint_it).second.ConstrainedBy[1]; //Yes, so move to second point in ConstrainedBy
if ((constrainter_it = find(CurFace.PointIndex.begin(),CurFace.PointIndex.end(),ver))
!= CurFace.PointIndex.end()) //So, the point we are checking, is it a part of the current face?
{
HaveConstraint = true;
NumOfConstraint++; //Yes, so...
if ((ver_it = find(AdditionalPoint.begin(), AdditionalPoint.end(),(*pnt_it).second.Constraining[j]))
== AdditionalPoint.end()) //...have the additional point been added to the list?
{
//Yes, push it back, and push the current point index too!!!
AdditionalPoint.push_back((*pnt_it).second.Constraining[j]);
Constrainter.push_back(i);
}
}
}
if (NumOfConstraint == 2) //One point constraining two point...?
{
Side = true;
Doubler = i; //Set the doubler~
}
}
}
if (!HaveConstraint) //No Constraints, so...
{
/* ------
| /|
| / |
| / |
| / |
-------
or so...
*/
STLINDEX Temp;
Temp.PointIndex.push_back(CurFace.PointIndex[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[1]);
Temp.PointIndex.push_back(CurFace.PointIndex[3]);
Stllist.push_back(Temp);
Temp.PointIndex.clear();
Temp.PointIndex.push_back(CurFace.PointIndex[1]);
Temp.PointIndex.push_back(CurFace.PointIndex[2]);
Temp.PointIndex.push_back(CurFace.PointIndex[3]);
Stllist.push_back(Temp);
}
else
{
//Houston, we have some constraints...
switch (AdditionalPoint.size()) //"How much" asks Houston
{
case 1: //1 constrain is the reply
{
/* ____
| /|
|/ |
|\ |
| \|
----
*/
STLINDEX Temp;
int checker;
if (Constrainter[0] != 0)
{
Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0]]);
Temp.PointIndex.push_back(AdditionalPoint[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] - 1]);
Stllist.push_back(Temp);
Temp.PointIndex.clear();
Temp.PointIndex.push_back(AdditionalPoint[0]);
checker = Constrainter[0] - 2;
if (checker < 0)
Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0]+2]);
else Temp.PointIndex.push_back(CurFace.PointIndex[checker]);
checker = Constrainter[0] - 1;
if (checker < 0)
Temp.PointIndex.push_back(CurFace.PointIndex[3]);
else Temp.PointIndex.push_back(CurFace.PointIndex[checker]);
Stllist.push_back(Temp);
Temp.PointIndex.clear();
Temp.PointIndex.push_back(AdditionalPoint[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] + 1]);
checker = Constrainter[0] + 2;
if (checker >= 4)
{
Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] - 2]);
}
else
{
Temp.PointIndex.push_back(CurFace.PointIndex[checker]);
}
Stllist.push_back(Temp);
}
else //Seems Constrainter[0] == 0 have it's own... possibilities
{
Temp.PointIndex.push_back(AdditionalPoint[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[2]);
Temp.PointIndex.push_back(CurFace.PointIndex[3]);
Stllist.push_back(Temp);
Temp.PointIndex.clear();
Temp.PointIndex.push_back(AdditionalPoint[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[1]);
Temp.PointIndex.push_back(CurFace.PointIndex[2]);
Stllist.push_back(Temp);
Temp.PointIndex.clear();
Temp.PointIndex.push_back(AdditionalPoint[0]);
std::map<unsigned int, VERTICES>::iterator pnt = Pointlist.find(AdditionalPoint[0]);
std::vector<unsigned int> temp = (*pnt).second.ConstrainedBy;
std::vector<unsigned int>::iterator vec = find(temp.begin(), temp.end(), CurFace.PointIndex[1]);
if (vec != temp.end())
{
Temp.PointIndex.push_back(CurFace.PointIndex[3]);
Temp.PointIndex.push_back(CurFace.PointIndex[0]);
Stllist.push_back(Temp);
}
else
{
Temp.PointIndex.push_back(CurFace.PointIndex[0]);
Temp.PointIndex.push_back(CurFace.PointIndex[1]);
Stllist.push_back(Temp);
}
}
break;
}
case 2: //2 Constraints is the reply
{
/* This one i can't draw... sorry
*/
STLINDEX temp;
if (Doubler != 0 && Doubler != 3)
{
int checker;
temp.PointIndex.push_back(AdditionalPoint[1]);
temp.PointIndex.push_back(AdditionalPoint[0]);
temp.PointIndex.push_back(CurFace.PointIndex[Doubler]);
Stllist.push_back(temp);
checker = Doubler + 2;
temp.PointIndex[0] = AdditionalPoint[0];
temp.PointIndex[1] = AdditionalPoint[1];
if (checker >= 4)
{
temp.PointIndex[2] = CurFace.PointIndex[Doubler-2];
}
else
{
temp.PointIndex[2] = CurFace.PointIndex[Doubler+2];
}
Stllist.push_back(temp);
checker = Doubler - 2;
temp.PointIndex[0] = AdditionalPoint[0];
if (checker < 0)
temp.PointIndex[1] = CurFace.PointIndex[Doubler+2];
else
temp.PointIndex[1] = CurFace.PointIndex[Doubler-2];
temp.PointIndex[2] = CurFace.PointIndex[Doubler-1];
Stllist.push_back(temp);
temp.PointIndex[0] = AdditionalPoint[1];
checker = Doubler + 1;
temp.PointIndex[1] = CurFace.PointIndex[Doubler+1];
checker = Doubler + 2;
if (checker >= 4)
temp.PointIndex[2] = CurFace.PointIndex[Doubler-2];
else
temp.PointIndex[2] = CurFace.PointIndex[Doubler+2];
Stllist.push_back(temp);
}
else if (Doubler == 0)
{
temp.PointIndex.push_back(AdditionalPoint[0]);
temp.PointIndex.push_back(AdditionalPoint[1]);
temp.PointIndex.push_back(CurFace.PointIndex[0]);
Stllist.push_back(temp);
temp.PointIndex[0] = AdditionalPoint[1];
temp.PointIndex[1] = AdditionalPoint[0];
temp.PointIndex[2] = CurFace.PointIndex[2];
Stllist.push_back(temp);
temp.PointIndex[0] = CurFace.PointIndex[1];
temp.PointIndex[1] = CurFace.PointIndex[2];
temp.PointIndex[2] = AdditionalPoint[0];
Stllist.push_back(temp);
temp.PointIndex[0] = CurFace.PointIndex[2];
temp.PointIndex[1] = CurFace.PointIndex[3];
temp.PointIndex[2] = AdditionalPoint[1];
Stllist.push_back(temp);
}
else
{
temp.PointIndex.push_back(AdditionalPoint[0]);
temp.PointIndex.push_back(AdditionalPoint[1]);
temp.PointIndex.push_back(CurFace.PointIndex[3]);
Stllist.push_back(temp);
temp.PointIndex[0] = AdditionalPoint[1];
temp.PointIndex[1] = AdditionalPoint[0];
temp.PointIndex[2] = CurFace.PointIndex[1];
Stllist.push_back(temp);
temp.PointIndex[0] = CurFace.PointIndex[1];
temp.PointIndex[1] = CurFace.PointIndex[2];
temp.PointIndex[2] = AdditionalPoint[1];
Stllist.push_back(temp);
temp.PointIndex[0] = CurFace.PointIndex[0];
temp.PointIndex[1] = CurFace.PointIndex[1];
temp.PointIndex[2] = AdditionalPoint[0];
Stllist.push_back(temp);
}
break;
}
case 3:
{
std::cout << "3 Constraints" << std::endl;
break;
}
case 4:
{
std::cout << "4 Constraints" << std::endl;
break;
}
default: //Have constraints, but no constraining points, or more than 5...? BUGSPAWN
{
std::cout << AdditionalPoint.size() << std::endl;
std::cout << "Blah...?" << std::endl;
break;
}
}
}
}
}
/*! \brief Loading into Mesh Function...
*/
void ReadDyna::PutInMesh(MeshCore::MeshKernel &mesh)
{
std::map<unsigned int,VERTICES>::iterator pnt_it(Pointlist.begin());
Base::Vector3f Points[3];
MeshCore::MeshBuilder builder(mesh);
builder.Initialize(Stllist.size());
for (unsigned int i = 0; i < Stllist.size();i++)
{
for (unsigned int j = 0; j < 3; j++)
{
pnt_it = Pointlist.find(Stllist[i].PointIndex[j]);
Base::Vector3f Temp((float)(*pnt_it).second.Coords[0],(float)(*pnt_it).second.Coords[1],(float)(*pnt_it).second.Coords[2]);
Points[j] = Temp;
}
MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]);
Face.CalcNormal();
builder.AddFacet(Face);
}
builder.Finish();
}

View File

@@ -1,103 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/******CONVERTDYNA.H******/
#ifndef CONVERTDYNA_H
#define CONVERTDYNA_H
/******MAIN INCLUDES******/
#include <fstream>
#include <vector>
#include <map>
#include <string>
/******MESH INCLUDES******/
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/Builder.h>
#include <Mod/Mesh/App/Core/TopoAlgorithm.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/MeshPy.h>
#include <Mod/Mesh/App/Mesh.h>
/******STRUCTS******/
//This structure will be used internally in this routine without any affects of outside variable
typedef struct
{
unsigned int PointIndex;
std::vector<double> Coords;
bool Constrained; //Another pair of points constraining this point...?
bool Constrain; //This point constraining another point...?
std::vector<unsigned int> ConstrainedBy;
std::vector<unsigned int> Constraining;
std::vector<unsigned int> FacetRef;
}VERTICES; /*!< VERTICES struct. Contains coordinates, index, face reference, and constraining information*/
typedef struct
{
unsigned int FaceIndex;
std::vector<unsigned int> PointIndex;
}FACE; /*!< FACE struct. Contains the face index, and the reference to the point*/
typedef struct
{
std::vector<unsigned int> PointIndex;
}STLINDEX; /*!< STLINDEX struct, contains only the triangulated face vertex indexes */
/*! \brief DYNA Files Reader
This Function will read in a DYNA file, designated by inputname. Only three Information will be parsed:-
*NODE, *CONSTRAINTS_ADAPTIVITY, and *ELEMENT_SHELL_THICKNESS (for the third, only first line will be parsed)
From *NODE the coordinates and vertex index will be parsed. From *ELEMENT_SHELL_THICKNESS only the face nodal
will be parsed, and from *CONSTRAINTS_ADAPTIVITY the constraints point (flagged by Constrain and Constrained) will
be parsed.
As output, a mesh.
TODO:-
1. A face might consists of 2 opposite constraint points, 3 constraint points or 4 constraint points in it's
edges. These are not implemented yet.
2. Some other keyword might contain the face information other than *ELEMENT_SHELL_THICKNESS
3. Multiple-PIDS DYNA files is not yet implemented. This program still assumes that it's only a single PID DYNA
*/
class ReadDyna
{
public:
ReadDyna(MeshCore::MeshKernel &m,const char* &inputname);
protected:
void ReadNode(std::ifstream &inputfile);
void ReadConstraints(std::ifstream &inputfile);
void ReadShellThickness(std::ifstream &inputfile);
void Convert();
void PutInMesh(MeshCore::MeshKernel &mesh);
private:
std::map<unsigned int, VERTICES> Pointlist;
std::map<unsigned int, FACE> Facelist;
std::vector<STLINDEX> Stllist;
};
#endif /*CONVERTDYNA_H DEFINED*/

View File

@@ -1,132 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef MESH_INTERFACE_H
#define MESH_INTERFACE_H
#include <Mod/Mesh/App/Core/Elements.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Base/Vector3D.h>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#error
namespace Mesh
{
/** The Interface class is useful to convert between the MeshKernel and the OpenMesh data
* structures. This class is implemented as template to accept any OpenMesh kernel type.
* @author Werner Mayer
*/
template <class Kernel>
class Interface : public Kernel
{
public:
Interface()
{
}
Interface(const MeshCore::MeshKernel& kernel)
{
copy(kernel);
}
~Interface()
{
}
void copy(const MeshCore::MeshKernel& kernel_In)
{
this->clear();
std::vector<Kernel::VertexHandle> vertex_handles;
vertex_handles.reserve(kernel_In.CountPoints());
MeshCore::MeshPointIterator it(kernel_In);
for (it.Init(); it.More(); it.Next()) {
vertex_handles.push_back(this->add_vertex(Kernel::Point(it->x, it->y, it->z)));
}
const MeshCore::MeshFacetArray& ary = kernel_In.GetFacets();
for (MeshCore::MeshFacetArray::_TConstIterator it = ary.begin(); it != ary.end(); ++it) {
this->add_face(vertex_handles[it->_aulPoints[0]], vertex_handles[it->_aulPoints[1]], vertex_handles[it->_aulPoints[2]]);
}
vertex_handles.clear();
}
void release(MeshCore::MeshKernel& kernel_Out)
{
MeshCore::MeshFacetArray facets;
MeshCore::MeshPointArray points;
facets.reserve(this->n_faces());
points.reserve(this->n_vertices());
// get the points
Kernel::ConstVertexIter v_it, v_end(this->vertices_end());
for (v_it=this->vertices_begin(); v_it!=v_end; ++v_it) {
Kernel::Point p = this->point(v_it);
points.push_back(Base::Vector3f(p[0], p[1], p[2]));
}
// get the facets
Kernel::ConstFaceIter f_it, f_end(this->faces_end());
for (f_it=this->faces_begin(); f_it!=f_end; ++f_it) {
MeshCore::MeshFacet face;
int i=0;
for (Kernel::ConstFaceVertexIter fv_it=this->cfv_iter(f_it); fv_it; ++fv_it) {
face._aulPoints[i++] = fv_it.handle().idx();
}
facets.push_back(face);
}
// get the neighbourhood
//
// iterate over all faces
for (f_it=this->faces_begin(); f_it!=f_end; ++f_it) {
// iterate over the half edges to which belong the current face
for (Kernel::ConstFaceHalfedgeIter fh_it=this->cfh_iter(f_it); fh_it; ++fh_it) {
// get the opposite half edge of the current half edge
Kernel::HalfedgeHandle hh = this->opposite_halfedge_handle(fh_it);
if (hh.is_valid()) {
// if the opposite half edge is valid a neighbour face must exist
Kernel::FaceHandle fh = this->face_handle(hh);
Kernel::VertexHandle vh = this->to_vertex_handle(hh);
for (int j=0; j<3; j++) {
// find the appropriate vertex and set the neighbour face
if (facets[f_it.handle().idx()]._aulPoints[j] == vh.idx()) {
facets[f_it.handle().idx()]._aulNeighbours[j] = fh.idx();
break;
}
}
}
}
}
this->clear();
kernel_Out.Adopt(points, facets, false);
}
};
} // namespace Mesh
#endif // MESH_INTERFACE_H

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -1,79 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __PRECOMPILED__
#define __PRECOMPILED__
#include <FCConfig.h>
// Exporting of App classes
#ifdef FC_OS_WIN32
# define CamExport __declspec(dllexport)
# define CamExport __declspec(dllexport)
# define PartExport __declspec(dllimport)
# define MeshExport __declspec(dllimport)
#else // for Linux
# define CamExport
# define CamExport
# define PartExport
# define MeshExport
#endif
#ifdef _MSC_VER
# pragma warning(disable : 4251)
# pragma warning(disable : 4290)
# pragma warning(disable : 4275)
# pragma warning(disable : 4503)
# pragma warning(disable : 4786)
# pragma warning(disable : 4101)
#endif
#ifdef _PreComp_
// STL
#include <vector>
#include <list>
#include <map>
#include <string>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <bitset>
#ifdef FC_OS_WIN32
#include <windows.h>
#endif
// OpenCasCade Base
#include <Standard_Failure.hxx>
// OpenCascade View
#include <Mod/Part/App/OpenCascadeAll.h>
#endif //_PreComp_
#endif //__PRECOMPILED__

File diff suppressed because it is too large Load Diff

View File

@@ -1,341 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _SpringbackCorrection_H_
#define _SpringbackCorrection_H_
#include <Mod/Mesh/App/Core/TopoAlgorithm.h>
#include "cutting_tools.h"
/** @brief The main class for the SpringbackCorrection routine
It takes a mesh and a Topo_Shape and computes
a deformation of the triangulated Topo_Shape.
The deformation is based on mirroring the input-mesh on the Topo_Shape.
*/
class MeshFacet;
# define cMin 15.0
# define toolRad 5.0
/** @brief a struct referring to the edges of the input-shape
@param anEdge edge
@param aFace vector of faces limited by edge
@param pntList point-vector of the mesh-points of the edge
@param MaxOffset maximum curvature-radius
@param MinOffset minimum curvature-radius
*/
struct EdgeStruct
{
TopoDS_Edge anEdge;
std::vector<TopoDS_Face> aFace;
std::vector<gp_Pnt> pntList;
double MaxOffset;
double MinOffset;
};
/** @brief a struct referring to the mesh-points of the input-shape
@param index index of the mesh-point
@param minCurv minimum curvature-radius
@param maxCurv maximum curvature-radius
@param error distance value
@param pnt mesh-point
@param normal normal-vector
*/
struct MeshPnt
{
int index;
double minCurv;
double maxCurv;
double error;
Base::Vector3f pnt;
Base::Vector3f normal;
};
/** @brief a struct for computing the maximum and minimum curvature-radius
of a single mesh-point
@param pnt mesh-point
@param distances distance-vector to all surrounding edges
@param MinEdgeOff minimum curvature-radii of surrounding edges
@param MaxEdgeOff maximum curvature-radii of surrounding edges
*/
struct FacePnt
{
Base::Vector3f pnt;
std::vector<double> distances;
std::vector<double> MinEdgeOff;
std::vector<double> MaxEdgeOff;
};
struct EdgeStruct_Less
{
bool operator()(const EdgeStruct& _Left, const EdgeStruct& _Right) const
{
if (_Left.anEdge.IsSame(_Right.anEdge)) return false;
return true;
}
};
struct Edge_Less
{
bool operator()(const TopoDS_Edge& _Left, const TopoDS_Edge& _Right) const
{
return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast()));
}
};
struct MeshPntLess
{
bool operator()(const Base::Vector3f& _Left, const Base::Vector3f& _Right) const
{
if ( fabs(_Left.x - _Right.x) > 0.0001 )
return _Left.x < _Right.x;
else if ( fabs(_Left.y - _Right.y) > 0.0001)
return _Left.y < _Right.y;
else if ( fabs(_Left.z - _Right.z) > 0.0001 )
return _Left.z < _Right.z;
return false;
}
};
class CamExport SpringbackCorrection : public MeshCore::MeshFacetVisitor
{
public:
/** @brief Constructor */
SpringbackCorrection();
/** @brief Constructor
@param aShape input-shape (CAD-Model)
@param aMesh input-mesh
*/
SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh);
/** @brief Constructor */
//SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh, const MeshCore::MeshKernel& bMesh);
~SpringbackCorrection();
/** @brief loads input-mesh */
bool Load(const MeshCore::MeshKernel& aMesh);
/** @brief loads input-shape */
bool Load(const TopoDS_Shape& aShape);
/** @brief loads input-shape and -mesh */
bool Load(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh);
/** @brief sets parameter-values to initial state, tessellates the input
shape and computes a curvature-radius-value at each edge
contained in the input-shape */
bool Init();
/** @brief get external setting-parameters */
bool Init_Setting(struct CuttingToolsSettings& set);
/** @brief main-function
@param deg_Tol limiting forming-angle
@param out
@todo undocumented parameter out
*/
bool Perform(int deg_Tol, bool out);
/** @brief sets curvature-radius-value of user-specified edges to zero */
bool SetFixEdges();
/** @brief calculates curvature-values as a distance-weighted
convexcombination */
bool CalcCurv();
/** @brief Computes mesh-based curvature-values at each mesh-point
@param aFace
@param mesh input-mesh
@todo undocumented parameter aFace
*/
std::vector<double> MeshCurvature(const TopoDS_Face& aFace, const MeshCore::MeshKernel& mesh);
/** @brief computes maximum and minimum curvature-values of the specified
input-face \p aFace
@param aFace input-face */
bool GetCurvature(TopoDS_Face aFace);
//bool MirrorMesh(std::vector<double> error);
//double LocalCorrection(std::vector<Base::Vector3f> Neib ,std::vector<Base::Vector3f> Normal,
// bool sign, double minScale);
//double GlobalCorrection(std::vector<Base::Vector3f> Neib ,std::vector<Base::Vector3f> Normal,
// bool sign, int ind);
//std::vector<Base::Vector3f> FillConvex(std::vector<Base::Vector3f> Neib,std::vector<Base::Vector3f> Normals, int n);
//bool InsideCheck(Base::Vector3f pnt, Base::Vector3f normal, std::vector<Base::Vector3f> Neib);
//MeshCore::MeshKernel BuildMesh(Handle_Poly_Triangulation aTri, std::vector<Base::Vector3f> TrPoints);
/** @brief returns index-value which specifies the boundary-points of the
input-mesh
@param mesh input-mesh
@param meshPnts mesh-points of input-mesh
*/
int GetBoundary(const MeshCore::MeshKernel &mesh, MeshCore::MeshPointArray &meshPnts);
//bool SmoothCurvature();
/** @brief smooths input-mesh
@param mesh input-mesh
@param maxTranslation value which stands for the maximum deviation
from the initial-mesh
*/
bool SmoothMesh(MeshCore::MeshKernel &mesh, double maxTranslation);
/** @brief smooths specified mesh-points of the input-mesh
@param mesh input-mesh
@param indicies vector of indicies of the mesh-points for
smoothing
@param maxTranslation value which stands for the maximum deviation
from the initial-mesh
*/
bool SmoothMesh(MeshCore::MeshKernel &mesh, std::vector<int> indicies, double maxTranslation);
/** @brief computes current angles of all triangles and stores the angle
degrees in a vector
@param mesh input-mesh
@param deg_tol limiting forming-angle
*/
//bool GetFaceAng(MeshCore::MeshKernel &mesh, int deg_tol);
/** @brief computes current angles of all triangles and stores the
critical-triangle-indicies in a vector
@param mesh input-mesh
@param deg_tol limiting forming-angle
*/
std::vector<int> FaceCheck(MeshCore::MeshKernel &mesh, int deg_tol);
/** @brief computes current angles of all triangles and sets the property
value of the critical triangles to zero
@param mesh input-mesh
@param deg_tol limiting forming-angle
*/
std::vector<int> InitFaceCheck(MeshCore::MeshKernel &mesh, int deg_tol);
//void ReorderNeighbourList(std::set<MeshCore::MeshPointArray::_TConstIterator> &pnt,
// std::set<MeshCore::MeshFacetArray::_TConstIterator> &face,
// std::vector<unsigned long> &nei,
// unsigned long CurInd);
/** @brief performs a region-growing-algorithm */
bool FacetRegionGrowing(MeshCore::MeshKernel &mesh,
std::vector<MeshCore::MeshFacet> &arr,
MeshCore::MeshFacetArray &mFacets);
//bool CorrectScale(double max_zVal);
/** @brief checks the visit-state of specified triangle */
bool Visit(const MeshCore::MeshFacet &rclFacet, const MeshCore::MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel);
/** @brief builds a mesh-kernel out of one face-triangulation
@param aFace face of concern
@param TFaceMesh MeshKernel where the triangulation will be stored
*/
bool TransferFaceTriangulationtoFreeCAD(const TopoDS_Face& aFace, MeshCore::MeshKernel& TFaceMesh);
/** @brief computes offset-values for the inner-points of the specified
region */
std::vector< std::pair<unsigned long, double> > RegionEvaluate(const MeshCore::MeshKernel &mesh, std::vector<unsigned long> &RegionFacets, std::vector<Base::Vector3f> &normals);
/** @brief input-mesh */
MeshCore::MeshKernel m_Mesh;
/** @brief mesh containing the movable regions for the local translation
*/
MeshCore::MeshKernel m_Mesh_vis;
/** @brief mesh containing the fix regions for the local translation */
MeshCore::MeshKernel m_Mesh_vis2;
/** @brief triangulation of the CAD-shape */
MeshCore::MeshKernel m_CadMesh;
/** @brief vector containing translation-vectors at all mesh-points */
std::vector<Base::Vector3f> m_dist_vec;
private:
/** @brief initial input-shape (CAD-model) */
TopoDS_Shape m_Shape;
/** @brief vector containing the maximum curvature-radius-values at all
mesh-points */
std::vector<double> m_CurvPos;
/** @brief vector containing the minimum curvature-radius-values at all
mesh-points */
std::vector<double> m_CurvNeg;
/** @brief */
std::vector<double> m_CurvMax;
/** @brief struct-vector over all edges */
std::vector<EdgeStruct> m_EdgeStruct;
/** @brief index-vector for the region-growing-algorithm containing the
triangles at the current ring-neighbourhood */
std::vector<unsigned long> m_RingVector;
/** @brief index-vector for the region-growing-algorithm containing the
triangles of one computed region */
std::vector< std::vector<unsigned long> > m_RegionVector;
/** @brief index-vector for the region-growing-algorithm containing the
triangles of all computed region */
std::vector< std::vector<unsigned long> > m_Regions;
/** @brief */
//std::vector<MeshCore::MeshFacet> m_RegionBounds;
/** @brief external setting-parameters */
CuttingToolsSettings m_set;
/** @brief index which specifies the current ring-neighbourhood for the
region-growing-algorithm */
int m_RingCurrent;
private:
/** @brief vector over all input-meshes for the iteration-process */
std::vector<MeshCore::MeshKernel> m_MeshVec;
/** @brief copy of the initial input-mesh */
MeshCore::MeshKernel MeshRef;
/** @brief */
//MeshCore::MeshKernel m_Mesh2Fit;
/** @brief vector over the normal-vectors at all mesh-points */
std::vector<Base::Vector3f> m_normals;
/** @brief vector containing the distance-values at all mesh points
between the initial input-shape (CAD-model) and -mesh */
std::vector<double> m_error;
/** @brief vector containing the initial angle-degrees of all triangles */
std::vector<double> m_FaceAng;
/** @brief struct-vector over all mesh-points */
std::vector<MeshPnt> m_MeshStruct;
/** @brief vector containing the resulting offset-values of all mesh
points */
std::vector<double> m_Offset;
public:
/** @brief map which links mesh-point to mesh-index */
std::map<Base::Vector3f,MeshPnt,MeshPntLess > MeshMap;
/** @brief map over all edges */
std::map<TopoDS_Edge, std::vector<double>, Edge_Less> EdgeMap;
/** @brief vector containing the user-specified faces which stands fix
during the springback-correction */
std::vector<TopoDS_Face> m_FixFaces;
};
#endif

View File

@@ -1,993 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "UniGridApprox.h"
#include "best_fit.h"
#include <Mod/Mesh/App/Core/Grid.h>
#include <Base/Builder3D.h>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Handle_Geom_BSplineSurface.hxx>
//
///*********BINDINGS********/
#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
#include <boost/numeric/bindings/atlas/cblas.hpp>
#include <boost/numeric/bindings/atlas/clapack.hpp>
//
using namespace boost::numeric::bindings;
typedef ublas::matrix<double, ublas::column_major> cm_t;
typedef ublas::symmetric_adaptor<cm_t, ublas::upper> adapt;
UniGridApprox::UniGridApprox(const MeshCore::MeshKernel &mesh, double Tol)
:m_Mesh(mesh),m_Tol(Tol),m_udeg(3),m_vdeg(3)
{
}
UniGridApprox::~UniGridApprox()
{
}
bool UniGridApprox::Perform(double TOL)
{
double maxErr;
cout << "MeshOffset" << endl;
MeshOffset();
cout << "SurfMeshParam" << endl;
SurfMeshParam();
while (true)
{
cout << "CompKnots" << endl;
CompKnots(uCP, vCP);
cout << "MatComp" << endl;
MatComp(uCP, vCP);
BuildSurf();
cout << "Compute Error";
maxErr = CompMeshError();
if (maxErr == -1)
throw Base::RuntimeError("CompError() couldn't project one point...");
cout << " -> " << maxErr << endl;
if (maxErr <= TOL) break;
else
{
if (uCP >= vCP)
{
uCP += 10;
vCP += vCP*10/uCP;
}
else
{
vCP += 10;
uCP += uCP*10/vCP;
}
}
if ( (uCP > (n_x + m_udeg + 1)) || (vCP > (n_y + m_vdeg + 1)) ) break;
m_Grid.clear();
m_Grid = m_GridCopy;
}
return true;
}
bool UniGridApprox::MeshOffset()
{
MeshCore::MeshPointIterator p_it(m_Mesh);
//temporary solution until CAD standards can be used
std::vector<Base::Vector3f> normals = best_fit::Comp_Normals(m_Mesh);
double x_max=-(1e+10),y_max=-(1e+10),z_max=-(1e+10),x_min=1e+10,y_min=1e+10,st_x,st_y;
int n = normals.size();
// perform shift
//for(int i=0; i<n; ++i)
//{
// normals[i].Normalize();
// normals[i].Scale(m_offset,m_offset,m_offset);
// m_Mesh.MovePoint(i,normals[i]);
//}
// now create a uniform rectangular grid on the CAD mesh
m_Mesh.RecalcBoundBox();
for (p_it.Begin(); p_it.More(); p_it.Next())
{
if (p_it->z>z_max) z_max = p_it->z;
if (p_it->x>x_max) x_max = p_it->x;
if (p_it->x<x_min) x_min = p_it->x;
if (p_it->y>y_max) y_max = p_it->y;
if (p_it->y<y_min) y_min = p_it->y;
}
// grid size can be determined using the bounding box
n_x = int((x_max - x_min)/(y_max - y_min)*sqrt((x_max - x_min)*(y_max - y_min)));
n_y = int((y_max - y_min)/(x_max - x_min)*sqrt((x_max - x_min)*(y_max - y_min)));
st_x = (x_max - x_min)/n_x;
st_y = (y_max - y_min)/n_y;
uCP = n_x/10;
vCP = n_y/10;
m_Grid.resize(n_x+1);
for (int i=0; i<n_x+1; ++i)
m_Grid[i].resize(n_y+1);
unsigned long facetIndex;
MeshCore::MeshFacetGrid aFacetGrid(m_Mesh);
MeshCore::MeshAlgorithm malg(m_Mesh);
MeshCore::MeshAlgorithm malg2(m_Mesh);
Base::Vector3f projPoint, pnt, aNormal(0,0,1.0);
Base::Builder3D log3d;
pnt.z = float(z_max);
//gp_Pnt p;
//TColgp_Array2OfPnt Input(1,n_x+1,1,n_y+1);
for (int i=0; i<n_x+1; ++i)
{
cout << double(i)/double(n_x) << endl;
pnt.x = float(x_min + i*st_x);
for (int j=0; j<n_y+1 - 10; ++j)
{
pnt.y = float(y_min + j*st_y);
aNormal.z = 1.0;
if (!malg.NearestFacetOnRay(pnt, aNormal, aFacetGrid, projPoint, facetIndex))
{
aNormal.Scale(1,1,-1);// grid optimized
if (!malg.NearestFacetOnRay(pnt, aNormal, aFacetGrid, projPoint, facetIndex))
{
aNormal.Scale(1,1,-1);
if (!malg2.NearestFacetOnRay(pnt, aNormal, projPoint, facetIndex))
{
aNormal.Scale(1,1,-1);
if (!malg2.NearestFacetOnRay(pnt, aNormal, projPoint, facetIndex))
{
if (i != 0 && i !=n_x && j != 0 && j!= n_y)
{
pnt.x += float(st_x / 10.0);
aNormal.Scale(1,1,-1);
if (malg.NearestFacetOnRay(pnt, aNormal, aFacetGrid, projPoint, facetIndex))
{
log3d.addSinglePoint(projPoint, 3, 1,0,0);
m_Grid[i][j] = projPoint;
}
else
{
log3d.addSinglePoint(pnt, 3, 0,0,0);
pnt.z = 1e+10;
m_Grid[i][j] = pnt;
pnt.z = (float) z_max;
}
}
else
{
log3d.addSinglePoint(pnt, 3, 0,0,0);
m_Grid[i][j] = pnt;
}
}
else
{
log3d.addSinglePoint(projPoint, 3, 1,1,1);
m_Grid[i][j] = projPoint;
}
}
else
{
log3d.addSinglePoint(projPoint, 3, 1,1,1);
m_Grid[i][j] = projPoint;
}
}
else
{
log3d.addSinglePoint(projPoint, 3, 1,1,1);
m_Grid[i][j] = projPoint;
}
}
else
{
log3d.addSinglePoint(projPoint, 3, 1,1,1);
m_Grid[i][j] = projPoint;
}
}
}
int c=0;
for (int i=0; i<n_x+1; ++i)
{
for (int j=0; j<n_y+1; ++j)
{
c=0;
if (m_Grid[i][j].z == 1e+10)
{
m_Grid[i][j].x = 0;
m_Grid[i][j].y = 0;
m_Grid[i][j].z = 0;
if (m_Grid[i-1][j].z != 1e+10)
{
m_Grid[i][j] += (m_Grid[i-1][j]);
c++;
}
if (m_Grid[i][j-1].z != 1e+10)
{
m_Grid[i][j] += (m_Grid[i][j-1]);
c++;
}
if (m_Grid[i][j+1].z != 1e+10)
{
m_Grid[i][j] += (m_Grid[i][j+1]);
c++;
}
if (m_Grid[i+1][j].z != 1e+10)
{
m_Grid[i][j] += (m_Grid[i+1][j]);
c++;
}
m_Grid[i][j].Scale( float(1.0 / double(c)), float(1.0 / double(c)), float(1.0 / double(c)));;
log3d.addSinglePoint(m_Grid[i][j], 3, 0,0,0);
}
}
}
m_GridCopy = m_Grid;
log3d.saveToFile("c:/projection.iv");
return true;
}
bool UniGridApprox::SurfMeshParam()
{
// here the grid generated in MeshOffset is parameterized
// parameterization: (x,y) -> (u,v) , ( R x R ) -> ( [0,1] x [0,1] )
int n = m_Grid.size()-1; // number of points to be approximated in x-direction
int m = m_Grid[0].size()-1; // number of points to be approximated in y-direction
std::vector<double> dist_x, dist_y;
double sum,d;
Base::Vector3f vlen;
m_uParam.clear();
m_vParam.clear();
m_uParam.resize(n+1);
m_vParam.resize(m+1);
m_uParam[n] = 1.0;
m_vParam[m] = 1.0;
// calculate node vector in u-direction (corresponds to x-direction)
for (int j=0; j<m+1; ++j)
{
sum = 0.0;
dist_x.clear();
for (int i=0; i<n; ++i)
{
vlen = (m_Grid[i+1][j] - m_Grid[i][j]);
dist_x.push_back(vlen.Length());
sum += dist_x[i];
}
d = 0.0;
for (int i=0; i<n-1; ++i)
{
d += dist_x[i];
m_uParam[i+1] = m_uParam[i+1] + d/sum;
}
}
for (int i=0; i<n; ++i)
m_uParam[i] /= m+1;
// calculate node vector in v-direction (corresponds to y-direction)
for (int i=0; i<n+1; ++i)
{
sum = 0.0;
dist_y.clear();
for (int j=0; j<m; ++j)
{
vlen = (m_Grid[i][j+1] - m_Grid[i][j]);
dist_y.push_back(vlen.Length());
sum += dist_y[j];
}
d = 0.0;
for (int j=0; j<m-1; ++j)
{
d += dist_y[j];
m_vParam[j+1] = m_vParam[j+1] + d/sum;
}
}
for (int j=0; j<m; ++j)
m_vParam[j] /= n+1;
/*cout << "uParam:" << endl;
for(int i=0; i<m_uParam.size(); ++i){
cout << " " << m_uParam[i] << ", " << endl;
}
cout << "vParam:" << endl;
for(int i=0; i<m_vParam.size(); ++i){
cout << " " << m_vParam[i] << ", " << endl;
}*/
return true;
}
bool UniGridApprox::CompKnots(int u_CP, int v_CP)
{
// calculation of the node vectors
// see NURBS-BOOK page 412
int r = n_x;
int s = n_y;
int n = u_CP-1;
int m = v_CP-1;
m_um = u_CP;
m_vm = v_CP;
int p = m_udeg;
int q = m_vdeg;
// U-Knot Vector Computation
double d = ((double)r + 1.0)/((double)n - (double)p + 1.0);
m_uknots.clear();
m_uknots.resize(n + p + 2);
for (int i=(p + 1) ; i<(n + p + 2); ++i)
m_uknots[i] = 1.0;
int ind;
double alp;
for (int i=1; i<(n - p + 1); ++i)
{
ind = int(i*d); // rounded whole number
alp = i*d - ind; // rest
m_uknots[p+i] = ((1 - alp) * m_uParam[ind-1]) + (alp * m_uParam[ind]);
}
/*for(int i=0; i<m_uknots.size(); ++i){
cout << " " << m_uknots[i] << ", " << endl;
}*/
// V-Knot Vector Computation
d = ((double)s + 1.0)/((double)m - (double)q + 1.0);
m_vknots.clear();
m_vknots.resize(m + q + 2);
for (int i = (q + 1) ; i< (m + q + 2); ++i)
m_vknots[i] = 1.0;
for (int i=1; i<(m - q + 1); ++i)
{
ind = int(i*d); // rounded whole number
alp = i*d - ind; // rest
m_vknots[q+i] = ((1 - alp) * m_vParam[ind-1]) + (alp * m_vParam[ind]);
}
/*for(int i=0; i<m_vknots.size(); ++i){
cout << " " << m_vknots[i] << ", " << endl;
}*/
return true;
}
bool UniGridApprox::MatComp(int u_CP, int v_CP)
{
// here it is finally approximated
int r = n_x;
int s = n_y;
int n = u_CP-1;
int m = v_CP-1;
int p = m_udeg;
int q = m_vdeg;
ublas::matrix<double> Nu_full(r - 1, n + 1);
ublas::matrix<double> Nv_full(s - 1, m + 1);
ublas::matrix<double> Nu_left(r - 1, n - 1);
ublas::matrix<double> Nv_left(s - 1, m - 1);
ublas::matrix<double> Nu (n - 1, n - 1);
ublas::matrix<double> Nv (m - 1, m - 1);
ublas::matrix<double> bx (1, n - 1);
ublas::matrix<double> by (1, n - 1);
ublas::matrix<double> bz (1, n - 1);
// pre-initialize with zero
for (int i=0; i<r-1; ++i)
for (int j=0; j<n+1; ++j)
Nu_full(i,j) = 0.0;
for (int i=0; i<s-1; ++i)
for (int j=0; j<m+1; ++j)
Nv_full(i,j) = 0.0;
std::vector<double> output(p+1);
int ind;
for (int i=1; i<r; ++i)
{
output.clear();
output.resize(p+1);
ind = Routines::FindSpan(n, p, m_uParam[i],m_uknots);
Routines::Basisfun(ind,m_uParam[i],p,m_uknots,output);
for (unsigned int j=0; j<output.size(); ++j)
{
Nu_full(i-1,ind-p+j) = output[j];
}
}
for (int i=0; i<r-1; ++i)
{
for (int j=0; j<n-1; ++j)
{
Nu_left(i,j) = Nu_full(i,j+1);
}
}
//WriteMatrix(Nu_full);
for (int i=1; i<s; ++i)
{
output.clear();
output.resize(q+1);
ind = Routines::FindSpan(m, q, m_vParam[i],m_vknots);
Routines::Basisfun(ind,m_vParam[i],q,m_vknots,output);
for (unsigned int j=0; j<output.size(); ++j)
{
Nv_full(i-1,ind-q+j) = output[j];
}
}
for (int i=0; i<s-1; ++i)
{
for (int j=0; j<m-1; ++j)
{
Nv_left(i,j) = Nv_full(i,j+1);
}
}
//cout << "NV" << endl;
//WriteMatrix(Nv_left);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Nu_left,Nu_left, 0.0,Nu); // Nu_left'*Nu_left = Nu
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Nv_left,Nv_left, 0.0,Nv); // Nv_left'*Nv_left = Nv !!! Attention !!!
std::vector<int> upiv(n - 1); // pivot element
atlas::lu_factor(Nu,upiv); // performs LU decomposition
std::vector<int> vpiv(m - 1);
atlas::lu_factor(Nv,vpiv);
ublas::matrix<double> uCP_x(n + 1, s + 1);
ublas::matrix<double> uCP_y(n + 1, s + 1);
ublas::matrix<double> uCP_z(n + 1, s + 1);
CPx.resize(n + 1, m + 1);
CPy.resize(n + 1, m + 1);
CPz.resize(n + 1, m + 1);
// pre-initialize with zero
for (int i=0; i<n+1; ++i)
for (int j=0; j<s+1; ++j)
{
uCP_x(i,j) = 0.0;
uCP_y(i,j) = 0.0;
uCP_z(i,j) = 0.0;
}
std::vector< ublas::matrix<double> > Ru_x(s+1);
std::vector< ublas::matrix<double> > Ru_y(s+1);
std::vector< ublas::matrix<double> > Ru_z(s+1);
for (int j=0; j<s+1; ++j)
{
Ru_x[j].resize(r-1,1);
Ru_y[j].resize(r-1,1);
Ru_z[j].resize(r-1,1);
uCP_x(0,j) = m_Grid[0][j].x;
uCP_y(0,j) = m_Grid[0][j].y;
uCP_z(0,j) = m_Grid[0][j].z;
uCP_x(n,j) = m_Grid[r][j].x;
uCP_y(n,j) = m_Grid[r][j].y;
uCP_z(n,j) = m_Grid[r][j].z;
for (int k=0; k<r-1; ++k)
{
Ru_x[j](k,0) = m_Grid[k+1][j].x - Nu_full(k,0)*m_Grid[0][j].x - Nu_full(k,n)*m_Grid[r][j].x;
Ru_y[j](k,0) = m_Grid[k+1][j].y - Nu_full(k,0)*m_Grid[0][j].y - Nu_full(k,n)*m_Grid[r][j].y;
Ru_z[j](k,0) = m_Grid[k+1][j].z - Nu_full(k,0)*m_Grid[0][j].z - Nu_full(k,n)*m_Grid[r][j].z;
}
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Ru_x[j],Nu_left, 0.0, bx);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Ru_y[j],Nu_left, 0.0, by);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Ru_z[j],Nu_left, 0.0, bz);
atlas::getrs(CblasTrans,Nu,upiv,bx);
atlas::getrs(CblasTrans,Nu,upiv,by);
atlas::getrs(CblasTrans,Nu,upiv,bz);
for (int i=1; i<n; ++i)
{
uCP_x(i,j) = bx(0,i-1);
uCP_y(i,j) = by(0,i-1);
uCP_z(i,j) = bz(0,i-1);
}
}
Base::Builder3D log3d;
Base::Vector3f pnt,pnt1;
for (int j=0; j<s; ++j)
{
for (int i=0; i<n; ++i)
{
pnt.x = (float) uCP_x(i,j);
pnt.y = (float) uCP_y(i,j);
pnt.z = (float) uCP_z(i,j);
pnt1.x = (float) uCP_x(i+1,j);
pnt1.y = (float) uCP_y(i+1,j);
pnt1.z = (float) uCP_z(i+1,j);
log3d.addSingleLine(pnt,pnt1, 1, 1,0,0);
}
}
log3d.saveToFile("c:/ControlPoints_u.iv");
//CPx = uCP_x;
//CPy = uCP_y;
//CPz = uCP_z;
//return true;
m_Grid.clear();
m_Grid.resize(n+1);
for (int i=0; i<n+1; ++i)
m_Grid[i].resize(s+1);
for (int i=0; i<n+1; ++i)
{
for (int j=0; j<s+1; ++j)
{
m_Grid[i][j].x = (float) uCP_x(i,j);
m_Grid[i][j].y = (float) uCP_y(i,j);
m_Grid[i][j].z = (float) uCP_z(i,j);
}
}
//SurfMeshParam();
// pre-initialize with zero
for (int i=0; i<n + 1; ++i)
{
for (int j=0; j<m + 1; ++j)
{
CPx(i,j) = 0.0;
CPy(i,j) = 0.0;
CPz(i,j) = 0.0;
}
}
std::vector< ublas::matrix<double> > Rv_x(n+1);
std::vector< ublas::matrix<double> > Rv_y(n+1);
std::vector< ublas::matrix<double> > Rv_z(n+1);
Base::Builder3D log,logo;
for (int j=0; j<n+1; ++j)
{
Rv_x[j].resize(s-1,1);
Rv_y[j].resize(s-1,1);
Rv_z[j].resize(s-1,1);
CPx(j,0) = uCP_x(j,0);
CPy(j,0) = uCP_y(j,0);
CPz(j,0) = uCP_z(j,0);
CPx(j,m) = uCP_x(j,s);
CPy(j,m) = uCP_y(j,s);
CPz(j,m) = uCP_z(j,s);
for (int k=0; k<s-1; ++k)
{
Rv_x[j](k,0) = uCP_x(j,k+1) - Nv_full(k,0)*uCP_x(j,0) - Nv_full(k,m)*uCP_x(j,s);
Rv_y[j](k,0) = uCP_y(j,k+1) - Nv_full(k,0)*uCP_y(j,0) - Nv_full(k,m)*uCP_y(j,s);
Rv_z[j](k,0) = uCP_z(j,k+1) - Nv_full(k,0)*uCP_z(j,0) - Nv_full(k,m)*uCP_z(j,s);
pnt.x = (float) uCP_x(j,k+1);
pnt.y = (float) uCP_y(j,k+1);
pnt.z = (float) uCP_z(j,k+1);
pnt1.x = (float) uCP_x(j,k+2);
pnt1.y = (float) uCP_y(j,k+2);
pnt1.z = (float) uCP_z(j,k+2);
log.addSingleLine(pnt,pnt1, 1, 0,0,0);
}
bx.clear();
by.clear();
bz.clear();
bx.resize(1, m - 1);
by.resize(1, m - 1);
bz.resize(1, m - 1);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Rv_x[j],Nv_left, 0.0, bx);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Rv_y[j],Nv_left, 0.0, by);
atlas::gemm(CblasTrans,CblasNoTrans, 1.0, Rv_z[j],Nv_left, 0.0, bz);
atlas::getrs(CblasTrans,Nv,vpiv,bx);
atlas::getrs(CblasTrans,Nv,vpiv,by);
atlas::getrs(CblasTrans,Nv,vpiv,bz);
for (int i=1; i<m; ++i)
{
CPx(j,i) = bx(0,i-1);
CPy(j,i) = by(0,i-1);
CPz(j,i) = bz(0,i-1);
pnt.x = (float) CPx(j,i);
pnt.y = (float) CPy(j,i);
pnt.z = (float) CPz(j,i);
logo.addSinglePoint(pnt,2,0,0,0);
}
}
logo.saveToFile("c:/contrPnts.iv");
ublas::matrix<double> Tmp = CPz;
//Smoothing the control point network
for (int i=1; i<n; ++i)
{
for (int j=1; j<m; ++j)
{
/*CPz(i,j) = ((Tmp(i-1,j-1) + Tmp(i-1,j) + Tmp(i-1,j+1)) +
(Tmp(i,j-1) + Tmp(i,j) + Tmp(i,j+1)) +
(Tmp(i+1,j-1) + Tmp(i+1,j) + Tmp(i+1,j+1)))/9;*/
CPz(i,j) = (Tmp(i-1,j) + Tmp(i,j-1) + Tmp(i,j) + Tmp(i,j+1) +Tmp(i+1,j))/5;
}
}
//for(int i=1; i<n; ++i){
// for(int j=1; j<m; ++j){
// /*CPz(i,j) = ((Tmp(i-1,j-1) + Tmp(i-1,j) + Tmp(i-1,j+1)) +
// (Tmp(i,j-1) + Tmp(i,j) + Tmp(i,j+1)) +
// (Tmp(i+1,j-1) + Tmp(i+1,j) + Tmp(i+1,j+1)))/9;*/
// CPz(i,j) = (Tmp(i-1,j) + Tmp(i,j-1) + Tmp(i,j) + Tmp(i,j+1) +Tmp(i+1,j))/5;
// }
//}
return true;
}
bool UniGridApprox::BuildSurf()
{
gp_Pnt pnt;
TColgp_Array2OfPnt Poles(1,m_um,1,m_vm);
for (int i=0; i<m_um; ++i)
{
for (int j=0; j<m_vm; ++j)
{
pnt.SetX(CPx(i,j));
pnt.SetY(CPy(i,j));
pnt.SetZ(CPz(i,j));
Poles.SetValue(i+1,j+1,pnt);
}
}
int c=1;
for (unsigned int i=0; i<m_uknots.size()-1; ++i)
{
if (m_uknots[i+1] != m_uknots[i])
{
++c;
}
}
TColStd_Array1OfReal UKnots(1,c);
TColStd_Array1OfInteger UMults(1,c);
c=1;
for (unsigned int i=0; i<m_vknots.size()-1; ++i)
{
if (m_vknots[i+1] != m_vknots[i])
{
++c;
}
}
TColStd_Array1OfReal VKnots(1,c);
TColStd_Array1OfInteger VMults(1,c);
int d=0;
c=1;
for (unsigned int i=0; i<m_uknots.size(); ++i)
{
if (m_uknots[i+1] != m_uknots[i])
{
UKnots.SetValue(d+1,m_uknots[i]);
UMults.SetValue(d+1,c);
++d;
c=1;
}
else
{
++c;
}
if (i==(m_uknots.size()-2))
{
UKnots.SetValue(d+1,m_uknots[i+1]);
UMults.SetValue(d+1,c);
break;
}
}
d=0;
c=1;
for (unsigned int i=0; i<m_vknots.size(); ++i)
{
if (m_vknots[i+1] != m_vknots[i])
{
VKnots.SetValue(d+1,m_vknots[i]);
VMults.SetValue(d+1,c);
++d;
c=1;
}
else
{
++c;
}
if (i==(m_vknots.size()-2))
{
VKnots.SetValue(d+1,m_vknots[i+1]);
VMults.SetValue(d+1,c);
break;
}
}
/*cout << "UKnots: " << endl;
for(int i=0; i<UKnots.Upper(); ++i)
cout << UKnots.Value(i+1) << ", ";
cout << endl;
cout << "UMults: " << endl;
for(int i=0; i<UMults.Upper(); ++i)
cout << UMults.Value(i+1) << ", ";
cout << endl;
cout << "VKnots: " << endl;
for(int i=0; i<VKnots.Upper(); ++i)
cout << VKnots.Value(i+1) << ", ";
cout << endl;
cout << "VMults: " << endl;
for(int i=0; i<VMults.Upper(); ++i)
cout << VMults.Value(i+1) << ", ";
cout << endl;*/
const Handle(Geom_BSplineSurface) surface = new Geom_BSplineSurface(
Poles, // const TColgp_Array2OfPnt & Poles,
UKnots, // const TColStd_Array1OfReal & UKnots,
VKnots, // const TColStd_Array1OfReal & VKnots,
UMults, // const TColStd_Array1OfInteger & UMults,
VMults, // const TColStd_Array1OfInteger & VMults,
3, // const Standard_Integer UDegree,
3 // const Standard_Integer VDegree,
// const Standard_Boolean UPeriodic = Standard_False,
// const Standard_Boolean VPeriodic = Standard_False*/
);
aAdaptorSurface.Load(surface);
return true;
}
double UniGridApprox::CompGridError()
{
GeomAPI_ProjectPointOnSurf proj;
MeshCore::MeshPointIterator pIt(m_Mesh);
gp_Pnt pnt;
double tmp = 0.0;
mG_err.clear();
mG_err.resize(m_Grid.size());
for (unsigned int i=0; i<m_Grid.size(); ++i)
mG_err[i].resize(m_Grid[i].size());
for (unsigned int i=0; i<m_Grid.size(); ++i)
{
for (unsigned int j=0; j<m_Grid[i].size(); ++j)
{
pnt.SetCoord(m_Grid[i][j].x, m_Grid[i][j].y, m_Grid[i][j].z);
proj.Init(pnt,aAdaptorSurface.BSpline(),0.1);
if (proj.IsDone() == false)
return -1.0;
mG_err[i][j] = proj.LowerDistance();
if (mG_err[i][j] > tmp)
tmp = mG_err[i][j];
}
}
return tmp;
}
bool UniGridApprox::WriteMatrix(ublas::matrix<double> M)
{
int row = M.size1();
int col = M.size2();
for (int i=0; i<row; ++i)
{
for (int j=0; j<col; ++j)
{
cout << M(i,j) << ", ";
}
cout << endl;
}
return true;
}
double UniGridApprox::CompMeshError()
{
Base::Builder3D log3d;
MeshCore::MeshKernel mesh;
BRepBuilderAPI_MakeFace Face(aAdaptorSurface.BSpline());
GeomAPI_ProjectPointOnSurf proj;
best_fit::Tesselate_Face(Face.Face(), mesh, float(0.1));
cout << mesh.CountPoints() << endl;
std::vector<Base::Vector3f> normals = best_fit::Comp_Normals(mesh);
double tmp = 0.0, sqrdis;
double errSum = 0.0;
int c=0;
m_err.clear();
m_err.resize(mesh.CountPoints(), 0.0);
MeshCore::MeshFacetGrid aFacetGrid(m_Mesh);
MeshCore::MeshAlgorithm malg(m_Mesh);
MeshCore::MeshAlgorithm malg2(m_Mesh);
MeshCore::MeshPointIterator p_it(mesh);
Base::Vector3f projPoint, distVec, pnt;
unsigned long facetIndex;
for (p_it.Begin(); p_it.More(); p_it.Next())
{
if (!malg.NearestFacetOnRay(*p_it, normals[p_it.Position()], aFacetGrid, projPoint, facetIndex)) // gridoptimiert
{
if (malg2.NearestFacetOnRay(*p_it, normals[p_it.Position()], projPoint, facetIndex))
{
pnt.x = p_it->x;
pnt.y = p_it->y;
pnt.z = p_it->z;
log3d.addSingleLine(pnt,projPoint);
distVec = projPoint - pnt;
sqrdis = distVec*distVec;
}
else
{
cout << "oops, ";
continue;
}
}
else
{
pnt.x = p_it->x;
pnt.y = p_it->y;
pnt.z = p_it->z;
log3d.addSingleLine(pnt,projPoint);
distVec = projPoint - pnt;
sqrdis = distVec*distVec;
}
errSum += sqrt(sqrdis);
++c;
if (sqrt(sqrdis) > tmp)
{
m_err[p_it.Position()] = sqrt(sqrdis);
tmp = m_err[p_it.Position()];
}
}
log3d.saveToFile("c:/Error.iv");
return errSum/c;
}

View File

@@ -1,82 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef UNIGRIDAPPROX_H
#define UNIGRIDAPPROX_H
#include "routine.h"
#include <boost/numeric/ublas/matrix.hpp>
#include <GeomAdaptor_Surface.hxx>
#include <TopoDS_Face.hxx>
using namespace boost::numeric;
class CamExport UniGridApprox: public Routines
{
public:
UniGridApprox(const MeshCore::MeshKernel &InputMesh, double Tol);
~UniGridApprox();
bool Perform(double TOL);
bool MeshOffset();
bool SurfMeshParam();
bool CompKnots(int m, int n);
bool MatComp(int m, int n);
bool BuildSurf();
double CompGridError();
double CompMeshError();
bool WriteMatrix(ublas::matrix<double> M);
MeshCore::MeshKernel m_Mesh;
GeomAdaptor_Surface aAdaptorSurface;
double m_offset;
std::vector< std::vector<Base::Vector3f> > m_Grid;
std::vector< std::vector<Base::Vector3f> > m_GridCopy;
std::vector<double> m_err;
std::vector< std::vector<double> > mG_err;
ublas::matrix<double> Q; //Data-Matrix
ublas::matrix<double> CPx;
ublas::matrix<double> CPy;
ublas::matrix<double> CPz;
std::vector<double> m_uParam;
std::vector<double> m_vParam;
std::vector<double> m_uknots;
std::vector<double> m_vknots;
int uCP, vCP;
int m_um;
int m_vm;
int m_udeg;
int m_vdeg;
int n_x;
int n_y;
double m_Tol;
TopoDS_Face m_Face;
protected:
};
#endif

View File

@@ -1,238 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Stephane Routelous <stephane.routelous@exotk.org> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "WireExplorer.h"
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TopoDS_Vertex.hxx>
#include <Precision.hxx>
WireExplorer::WireExplorer(const TopoDS_Wire& wire)
:m_wire(wire),m_done(false)
{
}
WireExplorer::~WireExplorer(void)
{
}
void WireExplorer::Init()
{
if ( !m_done )
Perform();
m_edgeIter = m_edges.begin();
}
bool WireExplorer::More()
{
return m_edgeIter != m_edges.end();
}
bool WireExplorer::MoreEdge()
{
return (m_edgeIter+1) != m_edges.end();
}
void WireExplorer::Next()
{
++m_edgeIter;
}
const TopoDS_Edge& WireExplorer::Current()
{
return *m_edgeIter;
}
const TopoDS_Edge& WireExplorer::NextEdge()
{
return *(m_edgeIter+1);
}
void WireExplorer::Perform()
{
if ( m_wire.IsNull() )
return;
//adds all the vertices to a map, and store the associated edges
TopExp_Explorer explorer;
Standard_Integer nbEdges = 0;
Standard_Integer nbNonEdges = 0;
for ( explorer.Init(m_wire,TopAbs_EDGE) ; explorer.More() ; explorer.Next() )
{
const TopoDS_Edge& currentEdge = TopoDS::Edge(explorer.Current());
if (IsValidEdge(currentEdge))
{
Perform(currentEdge);
nbEdges++;
}
else
{
nbNonEdges++;
}
}
//now, iterate through the edge to sort them
//take the first entry in the map
tMapPntShapes::iterator iter = m_vertices.begin();
const gp_Pnt& firstPoint = iter->first;
gp_Pnt currentPoint = firstPoint;
Standard_Boolean toContinue;
do
{
toContinue = PerformEdges(currentPoint);
}
while (toContinue == Standard_True);
m_done = true;
}
bool WireExplorer::PerformEdges(gp_Pnt& point)
{
tMapPntShapes::iterator iter = m_vertices.find(point);
if ( iter == m_vertices.end() )
return false;
tEdgeVector& edges = iter->second;
tEdgeVector::iterator edgeIt = edges.begin();
//no more edges. pb
if ( edgeIt == edges.end() )
return false;
TopoDS_Edge theEdge = *edgeIt;
//we are storing the edge, so remove it from the vertex association
edges.erase(edgeIt);
//if no more edges, remove the vertex
if ( edges.empty() )
m_vertices.erase(iter);
TopoDS_Vertex V1,V2;
TopExp::Vertices(theEdge,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
if ( theEdge.Orientation() == TopAbs_REVERSED )
{
//switch the points
gp_Pnt tmpP = P1;
P1 = P2;
P2 = tmpP;
}
gp_Pnt nextPoint;
if ( P2.IsEqual(point,Precision::Confusion()) )
{
//need to reverse the edge
theEdge.Reverse();
nextPoint = P1;
}
else
{
nextPoint = P2;
}
//need to erase the edge from the second point
iter = m_vertices.find(nextPoint);
if ( iter != m_vertices.end() )
{
tEdgeVector& nextEdges = iter->second;
bool somethingRemoved = false;
for ( edgeIt = nextEdges.begin() ; edgeIt != nextEdges.end(); ++edgeIt )
{
if ( theEdge.IsSame(*edgeIt) )
{
nextEdges.erase(edgeIt);
somethingRemoved = true;
break;
}
}
}
//put the edge at the end of the list
m_edges.push_back(theEdge);
point = nextPoint;
return true;
}
void WireExplorer::Perform(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return;
TopoDS_Vertex V1,V2;
TopExp::Vertices(edge,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
tEdgeVector emptyList;
std::pair<tMapPntShapes::iterator,bool> iter = m_vertices.insert(tMapPntShapesPair(P1,emptyList));
iter.first->second.push_back(edge);
iter = m_vertices.insert(tMapPntShapesPair(P2,emptyList));
iter.first->second.push_back(edge);
}
#include <BRepAdaptor_Curve.hxx>
bool WireExplorer::IsValidEdge(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return false;
if ( BRep_Tool::Degenerated(edge) )
return false;
BRepAdaptor_Curve bac(edge);
Standard_Real fparam = bac.FirstParameter();
Standard_Real lparam = bac.LastParameter();
gp_Pnt fpoint = bac.Value(fparam);
gp_Pnt lpoint = bac.Value(lparam);
//do not test the distance first last in case of a full circle edge (fpoint == lastpoint)
//if ( fpoint.IsEqual(lpoint,1e-5 ) )
// return false;
gp_Pnt mpoint = bac.Value((fparam+lparam)*0.5);
Standard_Real dist = mpoint.Distance(lpoint);
if ( dist <= 1e-5 )
return false;
dist = mpoint.Distance(fpoint);
if ( dist <= 1e-5 )
return false;
return true;
}

View File

@@ -1,80 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Stephane Routelous <stephane.routelous@exotk.org> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef WIREEXPLORER_H
#define WIREEXPLORER_H
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <gp_Pnt.hxx>
#include <TopTools_MapOfShape.hxx>
#include <map>
#include <list>
#include <vector>
struct WireExplorer_gp_PntLess
{
bool operator()(const gp_Pnt& _Left, const gp_Pnt& _Right) const
{
Standard_Real x1,y1,z1,x2,y2,z2;
_Left.Coord(x1,y1,z1);
_Right.Coord(x2,y2,z2);
if ( x1 != x2 )
return x1 < x2;
else if ( y1 != y2 )
return y1 < y2;
return z1 < z2;
}
};
typedef std::vector<TopoDS_Edge> tEdgeVector;
typedef std::map<gp_Pnt,tEdgeVector,WireExplorer_gp_PntLess> tMapPntShapes;
typedef std::pair<gp_Pnt,tEdgeVector> tMapPntShapesPair;
class WireExplorer
{
public:
Standard_EXPORT WireExplorer(const TopoDS_Wire& wire);
Standard_EXPORT virtual ~WireExplorer(void);
Standard_EXPORT void Init();
Standard_EXPORT bool More();
Standard_EXPORT bool MoreEdge();
Standard_EXPORT void Next();
Standard_EXPORT const TopoDS_Edge& NextEdge();
Standard_EXPORT const TopoDS_Edge& Current();
private:
void Perform();
void Perform(const TopoDS_Edge& edge);
bool PerformEdges(gp_Pnt& point);
bool IsValidEdge(const TopoDS_Edge& edge);
TopoDS_Wire m_wire;
tMapPntShapes m_vertices;
bool m_done;
tEdgeVector m_edges;
tEdgeVector::const_iterator m_edgeIter;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,256 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef BEST_FIT_H
#define BEST_FIT_H
#include <Mod/Mesh/App/Core/Approximation.h>
#include <Mod/Mesh/App/Core/Evaluation.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Base/Exception.h>
#include <gp_Vec.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <SMESH_Mesh.hxx>
#include <SMDS_VolumeTool.hxx>
#define SMALL_NUM 1e-6
#define ERR_TOL 0.001 // Abort criterion for least square matching
// (error change in two successive iteration steps)
/*! \brief The main class for the best_fit routine
It takes a mesh and a Topo_Shape as it's input parameter.
As output, it gives a transformed mesh (rotation + translation)
based on a weighted ICP-Algorithm (ICP: Iterative Closed Point) which fits the
Topo_Shape
*/
class CamExport best_fit
{
public:
best_fit();
~best_fit();
/*! \brief Load the input-shapes. Must be called before running the main program
\param InputMesh Input-mesh
\param CAD_Shape Input-shape
*/
void Load(const MeshCore::MeshKernel &InputMesh, const TopoDS_Shape &CAD_Shape);
bool Initialize_Mesh_Geometrie_1();
bool Initialize_Mesh_Geometrie_2();
/*! \brief Determines the local-coordinate-systems of the input-shapes and
apply a coordinate transformation to the mesh
*/
bool MeshFit_Coarse();
/*! \brief Determines the center of mass of the input-shape and
translates the shape to the global origin
*/
bool ShapeFit_Coarse();
/*! \brief Determines the center of mass of the point-cloud and
translates the shape to the global origin
*/
bool PointCloud_Coarse();
/*! \brief Main function of the best-fit-algorithm */
bool Perform();
/*! \brief Main function of the best-fit-algorithm only on point clouds */
bool Perform_PointCloud();
bool output_best_fit_mesh();
//double CompError(std::vector<Base::Vector3f> &pnts, std::vector<Base::Vector3f> &normals);
//double CompError(std::vector<Base::Vector3f> &pnts, std::vector<Base::Vector3f> &normals, bool plot);
//std::vector<double> CompError_GetPnts(std::vector<Base::Vector3f> pnts,
// std::vector<Base::Vector3f> &normals);
/*! \brief Computes error between the input-shapes through intersection
along the normal-directions and returns an average-error-value
*/
double CompTotalError();
/*! \brief Computes error between mesh and the input-shape through
intersection along the normal-directions and returns an
average-error-value
*/
double CompTotalError(MeshCore::MeshKernel &mesh);
/*! \brief Computes a triangulation on shape.
\param shape specifies the shape to be tessellated
\param mesh output-mesh to store the computed triangulation
\param deflection parameter which determines the accuracy of the
triangulation
*/
static bool Tesselate_Shape(const TopoDS_Shape &shape, MeshCore::MeshKernel &mesh, float deflection);
/*! \brief Computes a triangulation on aface.
\param aface specifies the face to be tessellated
\param mesh output-mesh to store the computed triangulation
\param deflection parameter which determines the accuracy of the
triangulation
*/
static bool Tesselate_Face (const TopoDS_Face &aface, MeshCore::MeshKernel &mesh, float deflection);
/*! \brief Returns a normal-vector of Mesh at the knots with uniform
weighting
\param Mesh Input-Mesh
*/
static std::vector<Base::Vector3f> Comp_Normals(MeshCore::MeshKernel &Mesh);
/*! \brief Check and corrects mesh-position by rotating around all
coordinate-axes with 180 degree
*/
bool Coarse_correction();
/*! \brief Determines two corresponding point-sets for the ICP-Method
using the Nearest-Neighbour-Algorithm
*/
double ANN();
/*! \brief Input-shape from the function Load */
TopoDS_Shape m_Cad; // CAD-Geometrie
/*! \brief Input-mesh from the function Load */
MeshCore::MeshKernel m_Mesh; // das zu fittende Netz
/*! \brief A copy of m_Mesh */
MeshCore::MeshKernel m_MeshWork;
/*! \brief Triangulated input-shape m_Cad */
MeshCore::MeshKernel m_CadMesh; // Netz aus CAD-Triangulierung
std::vector<Base::Vector3f> m_pntCloud_1;
std::vector<Base::Vector3f> m_pntCloud_2;
/*! \brief Stores the knots of m_CadMesh in relative order */
std::vector<Base::Vector3f> m_pnts;
/*! \brief Stores the normals of m_CadMesh in relative order */
std::vector<Base::Vector3f> m_normals;
/*! \brief Stores the error-values of m_CadMesh in relative order */
std::vector<double> m_error;
/*! \brief Stores the point-sets computed with the function ANN() */
std::vector<std::vector<Base::Vector3f> > m_LSPnts; // Points sets to be fitted for Least-Square
/*! \brief Stores the weights computed with the function Comp_Weights() */
std::vector<double> m_weights; // weighting for the Least-Square with respect to all network points
/*! \brief A working-copy of m_weights */
std::vector<double> m_weights_loc; // weighting for the Least-Square with respect to the projected network points
/*! \brief Translation-vector from the function ShapeFit_Coarse() */
gp_Vec m_cad2orig; // Translation vector that centers the CAD geometry about the origin
/*! \brief Vector of the preselected-faces for the weighting */
std::vector<TopoDS_Face> m_LowFaces; // Vector of the faces selected in the GUI with little weighting
private:
/*! \brief Computes the rotation-matrix with reference to the given
parameters
\param matrix 4x4-output-matrix
\param degree rotation-angle in degree
\param rotationAxis rotation-axis (1: x-axis, 2: y-axis, 3: z-axis)
*/
inline bool RotMat(Base::Matrix4D &matrix, double degree, int rotationAxis);
/*! \brief Computes the translation-matrix with reference to the given
parameters
\param matrix 4x4-output-matrix
\param translation translation-value
\param translationAxis translation-axis (1: x-axis, 2: y-axis, 3: z-axis)
*/
inline bool TransMat(Base::Matrix4D &matrix, double translation, int translationAxis);
/*! \brief Transforms the point-set \p pnts and the corresponding
surface-normals normals with reference to the input-matrix
\param pnts point-vector to transform
\param normals normal-vector to transform
\param M 4x4-input-matrix
*/
inline bool PointNormalTransform(std::vector<Base::Vector3f> &pnts,
std::vector<Base::Vector3f> &normals,
Base::Matrix4D &M);
/*! \brief Transforms the point-set pnts with reference to the input-matrix
\param pnts point-vector to transform
\param M is the 4x4-input-matrix
*/
bool PointTransform(std::vector<Base::Vector3f> &pnts, const Base::Matrix4D &M);
/*! \brief Sets the weights for the ICP-Algorithm */
bool Comp_Weights();
/*! \brief Performing the ICP-Algorithm */
bool LSM();
/*! \brief Returns the first derivative of the rotation-matrix at the
position x
\param params is a three-dimensional-vector specifying the rotation
angle along the x-,y- and z-axis
*/
std::vector<double> Comp_Jacobi(const std::vector<double> &params);
/*! \brief Returns the second derivative (Hessian matrix) of the rotation
matrix at the position x in form of a two-dimensional vector
of type double
\param params is a three-dimensional-vector specifying the rotation
angle along the x-,y- and z-axis
*/
std::vector<std::vector<double> > Comp_Hess (const std::vector<double> &params);
SMESH_Mesh *m_referencemesh;
SMESH_Mesh *m_meshtobefit;
SMESH_Gen *m_aMeshGen1;
SMESH_Gen *m_aMeshGen2;
//int intersect_RayTriangle(const Base::Vector3f &normal,const MeshCore::MeshGeomFacet &T, Base::Vector3f &P, Base::Vector3f &I);
// bool Intersect(const Base::Vector3f &normal,const MeshCore::MeshKernel &mesh, Base::Vector3f &P, Base::Vector3f &I);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,233 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/**\file
\brief Here you can find the header file for all the cutting stuff.
This is the place where all the prototypes are declared and the members are defined
*/
#ifndef Cutting_Tools
#define Cutting_Tools
#include <Handle_Geom_BSplineCurve.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Base/BoundBox.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <map>
#include "stuff.h"
namespace MeshCore {
class MeshAlgorithm;
class MeshFacetGrid;
}
/**\brief A Container to transfer the GUI settings
This struct can be used to transfer the settings of the CAM-Workbench GUI to other functions if required.
It provides members for all fields of the GUI settings window.
*/
struct CuttingToolsSettings
{
/**This represents the maximum allowed angle for the springback functions*/
float limit_angle;
/**This represents the minimum CAD-Radius of the forming shape. This is necessary for the springback
to avoid the generation of radii which are below that value*/
float cad_radius;
/**This represents the radius of the Master Tool*/
float master_radius;
/**This represents the radius of the Slave Tool*/
float slave_radius;
/**This represents the cutting distance between two levels (the pitch)*/
float level_distance;
/**This represents the springback correction factor used for the mirror part*/
float correction_factor;
/**This represents the sheet thickness*/
float sheet_thickness;
/**This represents the maximum velocity for the simulation output*/
float max_Vel;
/**This represents the maximum acceleration for the simulation output*/
float max_Acc;
/**This represents the pretension of the spring if used during simulation in mm*/
int spring_pretension;
/**This represents the Y-Offset value for the robot output*/
float y_offset_robot;
/**This represents the X-Offset value for the robot output*/
float x_offset_robot;
/**This represents the error of the approximated NURB surface*/
float error_tolerance;
/**This value is necessary to tell some special functions if we move zig/zag or clockwise/counterclockwise
without changing direction after each step*/
bool clockwise;
};
/**\brief A Container used for the Spiral-Toolpath Generation*/
struct SpiralHelper
{
/**This represents the SurfacePoint of the CAD-Surface*/
gp_Pnt SurfacePoint;
/**This represents the direction vector between two following points*/
gp_Vec LineD1;
/**This represents the SurfaceNormal at the SurfacePoint*/
gp_Vec SurfaceNormal;
};
struct BoundBox3f_Less
{
bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const
{
if (_Left.IsInBox(_Right)) return false;
return true;
}
};
struct Face_Less
{
bool operator()(const TopoDS_Face& _Left, const TopoDS_Face& _Right) const
{
return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast()));
}
};
/**\brief This class is the main class for the cutting Algorithms.
Its idea is to provide the basic functionality for cutting CAD surfaces. In this class you can also find
functions useful for generating spiral and feature based toolpaths
*/
class CamExport cutting_tools
{
public:
/**\brief The standard constructor
\param aShape A TopoDS_Shape
*/
cutting_tools(TopoDS_Shape aShape);
/**\brief The second standard constructor
This one gets a vertical step down value as well
\param aShape A TopoDS_Shape
\param pitch A vertical step down in[mm]
*/
cutting_tools(TopoDS_Shape aShape, float pitch);
/**\brief The standard destructor*/
~cutting_tools();
TopoDS_Wire ordercutShape(const TopoDS_Shape &aShape);
double GetEdgeLength(const TopoDS_Edge& anEdge);
bool OffsetWires_Standard();
bool OffsetWires_FeatureBased();
bool OffsetWires_Spiral();
//The sequence of the flat areas is determined here (the input comes from the GUI)
bool SetMachiningOrder(const TopoDS_Face &aFace, float x,float y,float z);
/*
It is used to check how many faces we have and a vector is also filled here where all
the flat areas are inside
*/
/*! \brief Here we find a great function */
bool arrangecuts_ZLEVEL();
//bool checkPointIntersection(std::vector<projectPointContainer> &finalPoints);
bool calculateAccurateSlaveZLevel(std::vector<std::pair<gp_Pnt,double> >&OffsetPoints, double current_z_level, double &slave_z_level, double &average_sheet_thickness,double &average_angle, bool &cutpos);
//bool checkPointDistance(std::vector<gp_Pnt> &finalPoints,std::vector<gp_Pnt> &output);
bool initializeMeshStuff();
bool arrangecuts_SPIRAL();
bool arrangecuts_FEATURE_BASED();
inline const std::vector<Handle_Geom_BSplineCurve>* getOutputhigh()
{
return &m_all_offset_cuts_high;
}
inline const std::vector<Handle_Geom_BSplineCurve>* getOutputlow()
{
return &m_all_offset_cuts_low;
}
inline std::vector<std::pair<float,TopoDS_Shape> > getCutShape()
{
return m_ordered_cuts;
}
std::vector<float> getFlatAreas();
CuttingToolsSettings m_UserSettings;
private:
//typedef std::list<std::vector<Base::Vector3f> > Polylines;
bool CheckEdgeTangency(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2);
bool CheckPoints(Handle(TColgp_HArray1OfPnt) PointArray);
bool getShapeBB();
bool fillFaceWireMap();
bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector<std::vector<std::pair<gp_Pnt,double> > >& MasterPointsStorage);
bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector<std::vector<gp_Pnt> >& SlavePointsStorage);
bool CheckforLastPoint(const gp_Pnt& lastPoint, int &start_index_master,int &start_array_master,int &start_index_slave,int &start_array_slave,const std::vector<std::vector<std::pair<gp_Pnt,double> > >& MasterPointsStorage, const std::vector<std::vector<gp_Pnt> >& SlavePointsStorage);
TopoDS_Shape getProperCut(TopoDS_Shape& aShape);
Handle_Geom_BSplineCurve InterpolateOrderedPoints(Handle(TColgp_HArray1OfPnt) InterpolationPoints,const bool direction);
//bool projectWireToSurface(const TopoDS_Wire &aWire,const TopoDS_Shape &aShape,std::vector<projectPointContainer> &aContainer);
bool fillFaceBBoxes();
Base::BoundBox3f getWireBBox(TopoDS_Wire aWire);
bool checkPointinFaceBB(const gp_Pnt &aPnt,const Base::BoundBox3f &aBndBox);
bool classifyShape();
//bool GenFlatLevelBSpline(
//bool checkFlatLevel();
bool cut(float z_level, float min_level, TopoDS_Shape &aCutShape,float &z_level_corrected);
bool cut_Mesh(float z_level, float min_level, std::list<std::vector<Base::Vector3f> > &result,float &z_level_corrected);
std::vector<SpiralHelper> OffsetSpiral(const std::vector<SpiralHelper>& SpiralPoints,bool master_or_slave=true);
gp_Dir getPerpendicularVec(gp_Vec& anInput);
std::vector<std::pair<float,TopoDS_Shape> > m_ordered_cuts;
std::vector<std::pair<TopoDS_Face,Base::BoundBox3f> > m_face_bboxes;
std::vector<std::pair<TopoDS_Face,Base::BoundBox3f> >::iterator m_face_bb_it;
std::vector<Handle_Geom_BSplineCurve> m_all_offset_cuts_high,m_all_offset_cuts_low;
//std::multimap<float,TopoDS_Wire> m_zl_wire_combination;
std::map<TopoDS_Face,std::map<Base::BoundBox3f,TopoDS_Wire,BoundBox3f_Less>,Face_Less > m_FaceWireMap;
std::vector<std::pair<float,TopoDS_Shape> >::iterator m_ordered_cuts_it;
//Member to check whether CAD or not
bool m_cad;
TopoDS_Shape m_Shape;
MeshCore::MeshKernel m_CAD_Mesh;
MeshCore::MeshAlgorithm * m_aMeshAlgo;
MeshCore::MeshFacetGrid * m_CAD_Mesh_Grid;
bool m_mirrortobothsides;
//Delivery amount
float m_pitch;
//The highest and lowest z-value of the shape
float m_minlevel,m_maxlevel;
//The radius of the tools
float m_radius,m_radius_slave;
//Sheet metal thickness
float m_sheet_thickness;
bool m_direction; ////If we cut from top to bottom (true) or from bottom to top (false)
std::vector<std::pair<Base::Vector3f,TopoDS_Face> > m_MachiningOrder;
};
#endif

View File

@@ -1,228 +0,0 @@
/**************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "deviation.h"
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/Builder.h>
#include <Mod/Mesh/App/Core/Grid.h>
#include <BRepAdaptor_Surface.hxx>
#include <Base/Builder3D.h>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Surface.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
Deviation::Deviation()
{}
Deviation::~Deviation()
{}
void Deviation::ImportGeometry(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh)
{
m_Mesh = aMesh;
m_Cad = aShape;
}
bool Deviation::GenNormals()
{
Base::Builder3D log;
TopExp_Explorer aExpFace;
MeshPnt aMeshStruct;
std::pair<Base::Vector3f, MeshPnt> inp;
std::map<Base::Vector3f,MeshPnt,MeshPntLess >::iterator meshIt;
MeshCore::MeshKernel FaceMesh;
MeshCore::MeshPointArray MeshPnts;
int n;
MeshPnts = m_MeshCad.GetPoints();
m_pnts.resize(m_MeshCad.CountPoints());
m_nlvec.resize((m_MeshCad.CountPoints()));
for (unsigned int i=0; i<MeshPnts.size(); ++i)
{
aMeshStruct.pnt = MeshPnts[i]; // stores point
aMeshStruct.index = i; // stores index
inp.first = aMeshStruct.pnt;
inp.second = aMeshStruct;
MeshMap.insert(inp);
}
// explores all faces ------------ Main loop
for (aExpFace.Init(m_Cad,TopAbs_FACE);aExpFace.More();aExpFace.Next())
{
TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());
TransferFaceTriangulationtoFreeCAD(aFace, FaceMesh);
MeshPnts.clear();
MeshPnts = FaceMesh.GetPoints();
n = MeshPnts.size();
TopLoc_Location aLocation;
Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation);
const TColgp_Array1OfPnt& aNodes = aTr->Nodes();
// create array of node points in absolute coordinate system
TColgp_Array1OfPnt aPoints(1, aNodes.Length());
for (Standard_Integer i = 1; i <= aNodes.Length(); i++)
aPoints(i) = aNodes(i).Transformed(aLocation);
const TColgp_Array1OfPnt2d& aUVNodes = aTr->UVNodes();
BRepAdaptor_Surface aSurface(aFace);
Base::Vector3f pnt, normal;
gp_Pnt2d par;
gp_Pnt P;
gp_Vec D1U, D1V;
for (int i=1; i<n+1; ++i)
{
par = aUVNodes.Value(i);
aSurface.D1(par.X(),par.Y(),P,D1U,D1V);
P = aPoints(i);
pnt.x = (float) P.X();
pnt.y = (float) P.Y();
pnt.z = (float) P.Z();
meshIt = MeshMap.find(pnt);
if (meshIt == MeshMap.end())
{
cout << "error";
return false;
}
D1U.Cross(D1V);
D1U.Normalize();
if (aFace.Orientation() == TopAbs_FORWARD) D1U.Scale(-1.0);
normal.x = (float) D1U.X();
normal.y = (float) D1U.Y();
normal.z = (float) D1U.Z();
m_pnts[((*meshIt).second).index] = pnt;
m_nlvec[((*meshIt).second).index] = normal;
log.addSingleArrow(pnt,pnt+normal);
}
}
log.saveToFile("c:/deviation.iv");
return true;
}
bool Deviation::Compute()
{
Base::Builder3D log;
best_fit::Tesselate_Shape(m_Cad, m_MeshCad, float(0.1));
GenNormals();
//return true;
std::vector<int> FailProj;
MeshCore::MeshFacetGrid aFacetGrid(m_Mesh,10);
MeshCore::MeshAlgorithm malg(m_Mesh);
MeshCore::MeshAlgorithm malg2(m_Mesh);
MeshCore::MeshPointIterator p_it(m_MeshCad);
Base::Vector3f projPoint, distVec, nvec(0,0,0), projPoint2;
unsigned long facetIndex;
std::stringstream text;
unsigned int c=0;
int i=0;
for (p_it.Begin(); p_it.More(); p_it.Next())
{
if (malg.NearestFacetOnRay(*p_it, m_nlvec[i], aFacetGrid, projPoint, facetIndex)) // gridoptimiert
{
distVec = projPoint - *p_it;
m_nlvec[i] = distVec; // overwrites normal vector
}
else
{
if (!malg2.NearestFacetOnRay(*p_it, m_nlvec[i], projPoint, facetIndex)) // nicht gridoptimiert
{
c++;
FailProj.push_back(i);
m_nlvec[i] = nvec;
}
else
{
distVec = projPoint - *p_it;
m_nlvec[i] = distVec; // overwrites normal vector
}
}
++i;
}
for(int i=0; i<m_nlvec.size(); i++)
{
log.addSingleArrow(m_pnts[i], m_pnts[i] + m_nlvec[i]);
}
log.saveToFile("c:/deviation2.iv");
return true;
}
#include <QFile>
#include <QTextStream>
void Deviation::WriteOutput(const QString &dateiname)
{
QFile anOutputFile(dateiname);
if (!anOutputFile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&anOutputFile);
out << m_nlvec.size() << endl;
for(int i=0; i<m_nlvec.size(); i++)
{
out << m_pnts[i].x << ","
<< m_pnts[i].y << ","
<< m_pnts[i].z << ","
<< m_nlvec[i].x << ","
<< m_nlvec[i].y << ","
<< m_nlvec[i].z << endl;
}
anOutputFile.close();
}

View File

@@ -1,52 +0,0 @@
/**************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DEVIATION_H
#define DEVIATION_H
#include "best_fit.h"
#include "SpringbackCorrection.h"
#include <string.h>
#include <QString>
class CamExport Deviation : public SpringbackCorrection
{
public:
Deviation();
~Deviation();
bool GenNormals();
void ImportGeometry(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh);
void WriteOutput(const QString &dateiname);
bool Compute();
TopoDS_Shape m_Cad; // CAD-Geometry
MeshCore::MeshKernel m_MeshCad;
MeshCore::MeshKernel m_Mesh;
std::vector<Base::Vector3f> m_pnts, m_nlvec;
};
#endif //DEVIATION_H

View File

@@ -1,343 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "edgesort.h"
#include <TopExp_Explorer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <BRep_Builder.hxx>
Edgesort::Edgesort(const TopoDS_Shape& aShape)
:m_shape(aShape),m_done(false)
{
m_edges.clear();
m_EdgeBBoxMap.clear();
m_vertices.clear();
}
Edgesort::~Edgesort(void)
{
}
void Edgesort::Init()
{
Perform();
m_edges.clear();
m_edges = m_EdgeBBoxMap.begin()->second;
m_edgeIter = m_edges.begin();
}
//#include <BRepBuilder.hxx>
TopoDS_Shape Edgesort::GetDesiredCutShape(int desiredIndex)
{
m_edges.clear();
m_EdgeBBoxMap.clear();
m_vertices.clear();
Perform();
if (m_EdgeBBoxMap.size()>1)
{
if (desiredIndex == 1) //Return the smallest to return it
{
m_edges = m_EdgeBBoxMap.begin()->second;
}
else
{
m_edges = m_EdgeBBoxMap.rbegin()->second;
}
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound(aCompound);
for (m_edgeIter = m_edges.begin();m_edgeIter!=m_edges.end();++m_edgeIter)
{
aBuilder.Add(aCompound,*m_edgeIter);
}
return aCompound;
}
else
{
return m_shape;
}
//Go through the edges of the result you do not like and remove this result from the original shape
}
void Edgesort::ReInit(const TopoDS_Shape& aShape)
{
m_shape= aShape;
m_done = false;
m_edges.clear();
m_EdgeBBoxMap.clear();
m_vertices.clear();
Perform();
m_edges.clear();
m_edges = m_EdgeBBoxMap.begin()->second;
m_edgeIter = m_edges.begin();
}
bool Edgesort::More()
{
return m_edgeIter != m_edges.end();
}
bool Edgesort::MoreEdge()
{
return (m_edgeIter+1) != m_edges.end();
}
const TopoDS_Edge& Edgesort::NextEdge()
{
return *(m_edgeIter+1);
}
void Edgesort::Next()
{
++m_edgeIter;
}
const TopoDS_Edge& Edgesort::Current()
{
return *m_edgeIter;
}
void Edgesort::Perform()
{
if ( m_shape.IsNull() )
return;
//adds all the vertices to a map, and store the associated edges
TopExp_Explorer explorer;
Standard_Integer nbEdges = 0;
Standard_Integer nbNonEdges = 0;
for ( explorer.Init(m_shape,TopAbs_EDGE) ; explorer.More() ; explorer.Next() )
{
const TopoDS_Edge& currentEdge = TopoDS::Edge(explorer.Current());
if (IsValidEdge(currentEdge))
{
Perform(currentEdge);
nbEdges++;
}
else
{
nbNonEdges++;
}
}
//now, iterate through the edges to sort them
do
{
m_edges.clear();
tMapPntEdge::iterator iter = m_vertices.begin();
const gp_Pnt& firstPoint = iter->first;
gp_Pnt currentPoint = firstPoint;
Standard_Boolean toContinue;
do
{
toContinue = PerformEdges(currentPoint);
}
while (toContinue == Standard_True);
tEdgeBBoxPair aTempPair;
aTempPair.first = getBoundingBox(m_edges);
aTempPair.second = m_edges;
m_EdgeBBoxMap.insert(aTempPair);
}
while (!m_vertices.empty());
m_done = true;
}
Base::BoundBox3f Edgesort::getBoundingBox(std::vector<TopoDS_Edge>& aList)
{
std::vector<TopoDS_Edge>::iterator aListIt;
//Fill Bounding Boxes with Edges
//Therefore we have to evaluate some points on our wire and feed the BBox Algorithm
Base::BoundBox3f currentBox;
currentBox.Flush();
for (aListIt = aList.begin();aListIt!=aList.end();aListIt++)
{
BRepAdaptor_Curve curveAdaptor(*aListIt);
GCPnts_QuasiUniformDeflection aProp(curveAdaptor,0.1);
Base::Vector3f aPoint;
for (int j=1;j<=aProp.NbPoints();++j)
{
aPoint.x = aProp.Value(j).X();
aPoint.y = aProp.Value(j).Y();
aPoint.z = aProp.Value(j).Z();
currentBox.Add(aPoint);
}
}
return currentBox;
}
bool Edgesort::PerformEdges(gp_Pnt& point)
{
tMapPntEdge::iterator iter = m_vertices.find(point);
if ( iter == m_vertices.end() )
return false;
tEdgeVector& edges = iter->second;
tEdgeVector::iterator edgeIt = edges.begin();
//no more edges. pb
if ( edgeIt == edges.end() )
{
//Delete also the current vertex
m_vertices.erase(iter);
return false;
}
TopoDS_Edge theEdge = *edgeIt;
//we are storing the edge, so remove it from the vertex association
edges.erase(edgeIt);
//if no more edges, remove the vertex
if ( edges.empty() )
m_vertices.erase(iter);
TopoDS_Vertex V1,V2;
TopExp::Vertices(theEdge,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
if ( theEdge.Orientation() == TopAbs_REVERSED )
{
//switch the points
gp_Pnt tmpP = P1;
P1 = P2;
P2 = tmpP;
}
gp_Pnt nextPoint;
if ( P2.IsEqual(point,0.2) )
{
//need to reverse the edge
theEdge.Reverse();
nextPoint = P1;
}
else
{
nextPoint = P2;
}
//need to erase the edge from the second point
iter = m_vertices.find(nextPoint);
if ( iter != m_vertices.end() )
{
tEdgeVector& nextEdges = iter->second;
bool somethingRemoved = false;
for ( edgeIt = nextEdges.begin() ; edgeIt != nextEdges.end(); ++edgeIt )
{
if ( theEdge.IsSame(*edgeIt) )
{
nextEdges.erase(edgeIt);
somethingRemoved = true;
break;
}
}
}
//put the edge at the end of the list
m_edges.push_back(theEdge);
point = nextPoint;
return true;
}
void Edgesort::Perform(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return;
TopoDS_Vertex V1,V2;
TopExp::Vertices(edge,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
tEdgeVector emptyList;
std::pair<tMapPntEdge::iterator,bool> iter = m_vertices.insert(tMapPntEdgePair(P1,emptyList));
iter.first->second.push_back(edge);
iter = m_vertices.insert(tMapPntEdgePair(P2,emptyList));
iter.first->second.push_back(edge);
}
#include <BRepAdaptor_Curve.hxx>
bool Edgesort::IsValidEdge(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return false;
if ( BRep_Tool::Degenerated(edge) )
return false;
BRepAdaptor_Curve bac(edge);
Standard_Real fparam = bac.FirstParameter();
Standard_Real lparam = bac.LastParameter();
gp_Pnt fpoint = bac.Value(fparam);
gp_Pnt lpoint = bac.Value(lparam);
//do not test the distance first last in case of a full circle edge (fpoint == lastpoint)
//if ( fpoint.IsEqual(lpoint,1e-5 ) )
// return false;
gp_Pnt mpoint = bac.Value((fparam+lparam)*0.5);
Standard_Real dist = mpoint.Distance(lpoint);
if ( dist <= 1e-5 )
return false;
dist = mpoint.Distance(fpoint);
if ( dist <= 1e-5 )
return false;
return true;
}

View File

@@ -1,100 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef EDGESORT_H
#define EDGESORT_H
#include <gp_Pnt.hxx>
#include <TopoDS_Edge.hxx>
#include <Base/BoundBox.h>
#include <list>
#include <map>
struct Edgesort_gp_Pnt_Less
{
bool operator()(const gp_Pnt & _Left, const gp_Pnt & _Right) const
{
Standard_Real x1,y1,z1,x2,y2,z2;
_Left.Coord(x1,y1,z1);
_Right.Coord(x2,y2,z2);
if ( fabs(x1- x2) > 0.2 )
return x1 < x2;
else if ( fabs(y1 -y2) > 0.2 )
return y1 < y2;
else if ( fabs(z1 -z2) > 0.2 )
return z1 < z2;
return false;
}
};
struct EdgeSortBoundBox_Less
{
bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const
{
if (_Left.IsInBox(_Right)) return false;
return true;
}
};
typedef std::vector<TopoDS_Edge> tEdgeVector;
typedef std::map<gp_Pnt,tEdgeVector,Edgesort_gp_Pnt_Less> tMapPntEdge;
typedef std::pair<gp_Pnt,tEdgeVector> tMapPntEdgePair;
typedef std::map<Base::BoundBox3f,std::vector<TopoDS_Edge>,EdgeSortBoundBox_Less> tEdgeBBoxMap;
typedef std::pair<Base::BoundBox3f,std::vector<TopoDS_Edge> >tEdgeBBoxPair;
class Edgesort
{
public:
Standard_EXPORT Edgesort(const TopoDS_Shape& aShape);
Standard_EXPORT virtual ~Edgesort(void);
Standard_EXPORT void Init();
Standard_EXPORT void ReInit(const TopoDS_Shape& aShape);
Standard_EXPORT bool More();
Standard_EXPORT bool MoreEdge();
Standard_EXPORT void Next();
Standard_EXPORT const TopoDS_Edge& NextEdge();
Standard_EXPORT const TopoDS_Edge& Current();
Standard_EXPORT TopoDS_Shape GetDesiredCutShape(int desiredIndex);
private:
void Perform();
void Perform(const TopoDS_Edge& edge);
bool PerformEdges(gp_Pnt& point);
bool IsValidEdge(const TopoDS_Edge& edge);
Base::BoundBox3f getBoundingBox(std::vector<TopoDS_Edge>& aList);
TopoDS_Shape m_shape;
tMapPntEdge m_vertices;
tEdgeBBoxMap m_EdgeBBoxMap;
bool m_done;
bool m_asecondwire;
bool m_whichedgelist;
tEdgeVector m_edges;
//BoundingBox m_edges, m_edges2
tEdgeVector::const_iterator m_edgeIter;
};
#endif

View File

@@ -1,106 +0,0 @@
#include "PreCompiled.h"
#include "mergedata.h"
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
MergeData::MergeData():
m_howmanypoints(0)
{
}
MergeData::~MergeData()
{
}
bool MergeData::Einlesen (const QStringList &dateinamen)
{
for (int i=0;i<dateinamen.size();i++)
{
QFileInfo aFileInfo(dateinamen.at(i));
QString path = aFileInfo.absolutePath();
QDir::setCurrent(path);
QFile input(dateinamen.at(i));
if ( input.open ( QFile::ReadOnly ) )
{
QTextStream in ( &input );
//Check the first line for a string-flag
QString firstline = in.readLine();
if(m_howmanypoints==0)
{
m_howmanypoints = firstline.toLong();
}
else
{
if(!(m_howmanypoints == firstline.toLong()))
{
return true;
}
}
if(i==0)
{
m_mergedvalues.resize(m_howmanypoints);
for(int j=0; j<m_howmanypoints; j++)
m_mergedvalues[j].resize(6);
}
int zeile = 0;
while ( !in.atEnd() )
{
QString line = in.readLine();
QStringList fields = line.split ( QLatin1Char(','),QString::SkipEmptyParts );
if(fields.size()<5)
return true;
m_mergedvalues[zeile][0] = fields[0].toFloat();
m_mergedvalues[zeile][1] = fields[1].toFloat();
m_mergedvalues[zeile][2] = fields[2].toFloat();
m_mergedvalues[zeile][3] += fields[3].toFloat();
m_mergedvalues[zeile][4] += fields[4].toFloat();
m_mergedvalues[zeile][5] += fields[5].toFloat();
zeile++;
}
}
input.close();
}
return true;
}
bool MergeData::WriteOutput(const QString &dateiname)
{
QFile anOutputFile(dateiname);
if (!anOutputFile.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QTextStream out(&anOutputFile);
for(unsigned int i=0; i<m_mergedvalues.size(); i++)
{
out << m_mergedvalues[i][0] << " "
<< m_mergedvalues[i][1] << " "
<< m_mergedvalues[i][2] << " "
<< m_mergedvalues[i][3] << " "
<< m_mergedvalues[i][4] << " "
<< m_mergedvalues[i][5] << endl;
}
anOutputFile.close();
return true;
}

View File

@@ -1,48 +0,0 @@
/**************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Human Rezai <human@mytum.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef MERGEDATA_H
#define MERGEDATA_H
#include <QStringList>
#include <vector>
class CamExport MergeData
{
public:
MergeData();
~MergeData();
bool WriteOutput(const QString &dateiname);
void Open();
bool Einlesen(const QStringList &filenames);
private:
std::vector<std::vector<float> > m_mergedvalues;
bool m_fit;
long m_howmanypoints;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,347 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Human Rezaijafari <H.Rezai@web.de> *
* *
* This file is part of the FreeCAD CAM development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef Path_Simulate_h
#define Path_Simulate_h
#include <Base/Vector3D.h>
#include <Base/Builder3D.h>
#include <TColStd_Array1OfReal.hxx>
#include "cutting_tools.h"
#include <sstream>
//#include <Base/Builder3D.h>
/*! \brief The main class for the path_simulate routine
As it's input parameters it takes one respectively two vectors of B-Spline
Curves (describing the Tool-Paths for the IBU-simulation), two values
a_max and v_max of type double, which stands for the maximum allowable
acceleration and velocity of the tool-movement and one value m_step of
type double, specifying the step-length of the time-output-vector.
As output, it gives one respectively two output-files for the simulation
process containing a two-dimensional vector of time vs. velocity which
describes the tool-movement.
*/
class CamExport path_simulate
{
public:
/** @brief Constructor.
@param BSplineTop vector of B-Spline-Curves describing the tool-
paths of the master-tool
@param BSplineBottom vector of B-Spline-Curves describing the tool-
paths of the slave-tool
@param set a struct which also includes the parameters
a_max and v_max
*/
path_simulate(const std::vector<Handle_Geom_BSplineCurve>& BSplineTop,
const std::vector<Handle_Geom_BSplineCurve>& BSplineBottom,
struct CuttingToolsSettings& set);
~path_simulate();
/** @brief Computes all parameters of the velocity-function for the tool
movement along a straight line.
@param wirelength length of the straight line
*/
bool ParameterCalculation_Line(double wirelength);
/** @brief Computes all parameters of the velocity-function for the tool
movement along a curve-segment.
@param wirelength arc-length of the curve-segment
*/
bool ParameterCalculation_Curve(double wirelength);
/** @brief Computes output for the connection-part in xy-direction
@param outputstyle false: simulation, true: robot
*/
bool ConnectPaths_xy(bool outputstyle);
/** @brief Computes output for the connection-part in z-direction
@param outputstyle false: simulation, true: robot
*/
bool ConnectPaths_z(bool outputstyle);
/** @brief Computes output for the connection-part in all directions for
the feature-based-strategy
@param tool false: master true: slave
@param robo defines outputstyle (false: simulation
true: robot)
@param connection_type false: in 3-steps true: in 2-steps
*/
bool ConnectPaths_Feat(bool tool, bool robo, bool connection_type);
/** @brief Updates actual parameter sets */
bool UpdateParam();
/** @brief Writes output-vectors to file for the feature-based-strategy
@param anOutputFile_1 output-file for the master
@param anOutputFile_2 output-file for the slave
@param c startindex of the curve-id
@param outputstyle false: simulation, true: robot
*/
bool WriteOutput_Feat(ofstream &anOutputFile_1, ofstream &anOutputFile_2, int &c, bool outputstyle);
///** @brief Write start- and endtime for one tool-path-run (master & slave) */
// bool WriteTimes();
/** @brief Writes output-vectors to file
@param anOutputFile output-file
@param c
@param outputstyle false: simulation, true: robot
@param tool false: master, true: slave
@param beamfl specifies an additional outputvalue which
determines the waiting-status of the tool
movement
\todo undocumented parameter c
*/
bool WriteOutputSingle(ofstream &anOutputFile, int &c, bool outputstyle, bool tool, bool beamfl);
/** @brief Writes output-vectors to file
@param anOutputFile_1 output-file for the master
@param nOutputFile_2 output-file for the slave
@param c1 startindex of the curve-id for the master
@param c2 startindex of the curve-id for the slave
@param outputstyle false: simulation, true: robot
@param beamfl specifies an additional outputvalue using
spring-pretension
*/
bool WriteOutputDouble(ofstream &anOutputFile_1,ofstream &nOutputFile_2, int &c1, int &c2, bool outputstyle,bool beamfl);
/** @brief Main routine for creating the simulation output for a single
curve, including the synchronisation of master and slave <br>
CompPath() must have been called before using this function
*/
bool Gen_Path();
/** @brief Creates outputvectors for the simulation outputfor a single
curve
@param outputstyle false: simulation, true: robot
@param length defines length of the path
@param part tells us that we are generating output for a
critical part of the curve or not
@param curveType
\todo undocumented parameter curveType
*/
bool MakePathSingle(bool outputstyle, double length, bool part, bool curveType);
/** @brief Main function of the output-generation for the simulation
using the standard-strategy
*/
bool MakePathSimulate();
/** @brief Main function of the output-generation for the simulation
using the feature-based or spiral-based strategy
@param flatAreas index-vector specifying the flat areas
@param spiral specifies the strategy (true: spiral-based,
false: feature-based)
*/
bool MakePathSimulate_Feat(const std::vector<float> &flatAreas, bool spiral);
/** @brief Main function of the output-generation for the robot using the
standard-strategy*/
bool MakePathRobot();
/** @brief Main function of the output-generation for the robot using the
feature-based-strategy
*/
bool MakePathRobot_Feat(const std::vector<float> &flatAreas);
/** @brief computes path-correction after a tool-path-run
@param b false: master, true: slave
*/
bool Correction(bool b);
/** @brief Adds additional time-values to the output-vector of the
waiting tool for synchronisation
*/
bool TimeCorrection();
/** @brief Returns the next curve-index for the feature-based-strategy */
int Detect_FeatCurve(bool tool);
private:
/** @brief curve-vector for the master-tool*/
std::vector<Handle_Geom_BSplineCurve> m_BSplineTop;
/** @brief curve-vector for the slave-tool*/
std::vector<Handle_Geom_BSplineCurve> m_BSplineBottom;
/** @brief actual start-point for the connection-part*/
std::vector<gp_Pnt> m_StartPnts1;
/** @brief actual end-point for the connection-part*/
std::vector<gp_Pnt> m_StartPnts2;
// Base::Builder3D m_log;
/** @brief output-vector for the master including velocity-values for the
simulation-process */
std::vector< std::vector<Base::Vector3d> > m_Output;
/** @brief output-vector for the slave including velocity-values for the
simulation-process*/
std::vector< std::vector<Base::Vector3d> > m_Output2;
/** @brief output-vector for the master including a point-set for the
robot*/
std::vector<Base::Vector3d> m_Output_robo1;
/** @brief output-vector for the slave including a point-set for the
robot*/
std::vector<Base::Vector3d> m_Output_robo2;
/** @brief additional output-vector of the master-tool for the robot
output including values 0 and 1 */
std::vector<int> RoboFlag_Master;
/** @brief additional output-vector of the slave-tool for the robot
output including values 0 and 1 */
std::vector<int> RoboFlag_Slave;
/** @brief output-vector for the master including a time-set conform to
m_Output respectively m_Output_robo1*/
std::vector<double> m_Output_time;
/** @brief output-vector for the slave including a time-set conform to
m_Output2 respectively m_Output_robo2*/
std::vector<double> m_Output_time2;
/** @brief timestep for the simulation-output*/
double m_step;
/** @brief pointing to the knot-vector of the current B-spline Curve*/
TColStd_Array1OfReal *m_Knots;
/** @brief maximum curvature of current curve*/
double m_curMax;
/** @brief external setting-parameters*/
CuttingToolsSettings m_set;
/** @brief iterator for the master-curves*/
std::vector<Handle_Geom_BSplineCurve>::iterator m_it1; /* iterator über inner-paths */
/** @brief iterator for the slave-curves*/
std::vector<Handle_Geom_BSplineCurve>::iterator m_it2; /* iterator über outer-paths */
/** @brief sheet-thickness */
double m_blech;
/** @brief spring-pretension*/
double m_pretension;
/** @brief maximum number of output-values per file*/
int m_clip;
/** @brief flag specifies if spring-pretension is used or not*/
bool beam;
/** @brief flag specifying the used forming-strategy*/
bool m_single;
/** @brief flag specifying moving-direction (clockwise vs. anticlockwise)
*/
bool m_dir;
/** @brief vector in which the lengths of the separated curve-segments for
the master-tool are stored*/
std::vector<std::vector<double> > m_length_ma;
/** @brief vector in which the lengths of the separated curve-segments for
the slave-tool are stored*/
std::vector<std::vector<double> > m_length_sl;
/** @brief vector of acceleration-values regarding to the separated curve
segments for the master-tool*/
std::vector<std::vector<double> > m_accel_ma;
/** @brief vector of acceleration-values regarding to the separated curve
segments for the slave-tool*/
std::vector<std::vector<double> > m_accel_sl;
/** @brief Matrix of three velocity-values regarding to the curves and curve-segments for the master-tool*/
std::vector<std::vector<std::vector<double> > > m_velocity_ma;
/** @brief Matrix of three velocity-values regarding to the curves and
curve-segments for the slave-tool*/
std::vector<std::vector<std::vector<double> > > m_velocity_sl;
/** @brief maximum allowable resulting velocity of the tool*/
double m_vmax;
/** @brief maximum allowable resulting acceleration of the tool*/
double m_amax;
/** @brief pathtolerance which is set (in subject to m_vmax and m_amax)
before and after a critical region*/
double m_boundTol;
/** @brief acceleration-parameter used in GetVelocity() and GetDistance()
*/
double m_a;
/** @brief three-dimensional vector containing start-, maximum- and end-
velocity used in GetVelocity() and GetDistance()*/
double m_v[3];
/** @brief parameter of the velocity-function */
double m_vmid;
/** @brief initial start-parameter for the current master- and slave-
curves*/
std::vector<double> m_StartParam;
/** @brief timeparameter of the velocity-function*/
double m_t0;
/** @brief timeparameter of the velocity-function*/
double m_t1;
/** @brief timeparameter of the velocity-function*/
double m_t2;
/** @brief timeparameter of the velocity-function*/
double m_T;
/** @brief timeparameter of the velocity-function*/
double m_del_t; /* t_0 - starttime, T - endtime, del_t - timestep */
/** @brief returns absolute velocity at the time-value t */
double GetVelocity(double time);
/** @brief returns arc-length of the current tool-path at the time-value
t*/
double GetDistance(double t);
/** @brief determines connection-strategy for both tools*/
bool CheckConnect();
/** @brief determines connection-strategy for the specified tool
@param tool false: master, true: slave
*/
bool CheckConnect(bool tool);
/** @brief determines critical bounds of the current curve for the
specified tool
@param tool false: master, true: slave
@param knots
\todo undocumented parameter knots
*/
std::vector<std::vector<double> > CompBounds(bool tool, std::vector<double> knots);
/** @brief Generates output for the current tool-path*/
bool CompPath(bool tool);
/** @brief determines which tool should wait (feature-based-stategy only)*/
bool StartingTool();
/** @brief vector containing start- and end-times for the master-curves*/
std::vector<std::pair<float,float> > m_PathTimes_Master;
/** @brief vector containing start- and end-times for the slave-curves*/
std::vector<std::pair<float,float> > m_PathTimes_Slave;
// std::vector<double> m_times_tmp;
// std::vector<double> m_velo_tmp;
/** @brief flag specifying current connection-type*/
bool m_conn;
/** @brief flag specifying if a feature-based-strategy is used*/
bool m_Feat;
};
#endif //Path_Simulate_h

View File

@@ -1,648 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Mohamad Najib Muhammad Noor <najib_bean@yahoo.co.uk>
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/*********ROUTINE.CPP*********/
#include "PreCompiled.h"
#include <cmath>
#include "routine.h"
///*********BINDINGS********/
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/bindings/traits/ublas_matrix.hpp>
#include <boost/numeric/bindings/atlas/clapack.hpp>
using namespace boost::numeric::bindings;
using namespace boost::numeric;
/*! \brief Numerical Integration according to trapezoid rules
This routine assumes that the Intergral values are already corresponding with WithRespectTo
i.e: Intergral[i] == Intergral(WithRespectTo[i]);
Also, it is assumed that WithRespectTo are evenly spaced with it's stepWidth
*/
double Routines::TrapezoidIntergration(const std::vector<double> &WithRespectTo, const std::vector<double> &Integral)
{
m_h = 0;
m_result = 0;
m_N = Integral.size();
if (m_N==1) // trapzf(x,y) returns zero for a scalar x
{
m_result = 0;
return m_result;
}
m_h = WithRespectTo[1] - WithRespectTo[0]; /* the integration stepsize */
for (int i=1; i< m_N - 1; i++)
m_result = m_result + Integral[i];
m_result = m_h/2 * (Integral[0] + 2*(m_result) + Integral[m_N -1]);
return m_result;
}
std::vector<double> Routines::NewtonStep(std::vector<double> &F,std::vector<std::vector<double> > &DF)
{
// solves the following equation system: DF*x = F
int siz = (int) F.size();
std::vector<double> x_new(siz);
std::vector<int> piv(siz); // pivot element
ublas::matrix<double> A(siz, siz);
ublas::matrix<double> b(1, siz);
// fills blow molding matrices
for (unsigned int i=0; i<siz; ++i)
{
b(0,i) = -F[i];
for (unsigned int j=0; j<siz; ++j)
{
A(i,j) = DF[i][j];
}
}
/*cout << b(0,0) << "," << b(0,1) << "," << b(0,2) << endl;
cout << A(0,0) << "," << A(0,1) << "," << A(0,2) << endl;
cout << A(1,0) << "," << A(1,1) << "," << A(1,2) << endl;
cout << A(2,0) << "," << A(2,1) << "," << A(2,2) << endl;*/
atlas::lu_factor(A,piv); // performs LU decomposition
atlas::getrs(A,piv,b); // solves equation system A*x = b
// (b will be overwritten with the solution)
for (unsigned int i=0; i<siz; ++i)
{
x_new[i] = b(0,i);
}
return x_new;
}
/*! \brief Cramer-Rule Solver
Cramer-Rule solver for 2x2 Matrix.
RHS1 * LHS = RHS2, LHS will be computed
*/
void Routines::CramerSolve(std::vector< std::vector<double> > &RHS1, std::vector<double>& RHS2, std::vector<double> &LHS)
{
double MainMatrixDet = det2(RHS1);
std::vector< std::vector<double> > Temp(2,std::vector<double>(2,0.0));
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
Temp[i][j] = RHS1[i][j];
//first pass
for (int i = 0; i < 2; i++)
Temp[i][0] = RHS2[i];
LHS[0] = det2(Temp) / MainMatrixDet;
//restore
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
Temp[i][j] = RHS1[i][j];
//second pass
for (int i = 0; i < 2; i++)
Temp[i][1] = RHS2[i];
LHS[1] = det2(Temp) / MainMatrixDet;
}
/*! \brief Calculate angle between two vectors
Dependencies: Vector3D definitions and routines
*/
double Routines::CalcAngle(Base::Vector3f a,Base::Vector3f b,Base::Vector3f c)
{
Base::Vector3f First = a - b;
Base::Vector3f Second = c - b;
Base::Vector3f Third = c - a;
//double test1 = First.Length(), test2 = Second.Length(), test3 = Third.Length();
double UpperTerm = (First.Length() * First.Length()) + (Second.Length() *Second.Length()) - (Third.Length() * Third.Length() );
double LowerTerm = 2 * First.Length() * Second.Length() ;
double ang = acos( UpperTerm / LowerTerm );
return ang;
}
/*! \brief Algorithm A2.1 from NURBS Book Page 68*/
int Routines::FindSpan(int n, int p, double u, std::vector<double> KnotSequence)
{
if (u == KnotSequence[n+1])
return n;
int low, high, mid, i;
i = 0;
low = p;
high = n+1;
mid = (low+high) / 2;
while (u < KnotSequence[mid] || u >= KnotSequence[mid+1])
{
if (u < KnotSequence[mid])
high = mid;
else
low = mid;
mid = (low + high) / 2;
i++;
}
return mid;
}
/*! \brief Algorithm A2.4 from NURBS Book page 70*/
void Routines::Basisfun(int i, double u, int p, std::vector<double> &KnotSequence, std::vector<double> &output)
{
double temp, saved;
std::vector<double> leftie(p+1, 0.0);
std::vector<double> rightie(p+1, 0.0);
output[0] = 1.0;
for (int j = 1; j <= p; j++)
{
leftie[j] = u - KnotSequence[i+1-j];
rightie[j] = KnotSequence[i+j] - u;
saved = 0.0;
for (int r = 0; r < j; r++)
{
temp = output[r] / (rightie[r+1] + leftie[j-r]);
output[r] = saved + (rightie[r+1]*temp);
saved = leftie[j-r]*temp;
}
output[j] = saved;
}
}
/*! \brief Algorithm A2.3 from NURBS Book Page 72 */
void Routines::DersBasisFuns(int i, double u, int p, int n,
std::vector<double> &KnotSequence, std::vector< std::vector<double> > &Derivate)
{
std::vector< std::vector<double> > ndu(p+1, std::vector<double>(p+1,0.0));
std::vector< std::vector<double> > a(2, std::vector<double>(p+1,0.0));
std::vector<double> leftie(p+1, 0.0);
std::vector<double> rightie(p+1, 0.0);
ndu[0][0] = 1.0;
for (int j = 1; j <= p; j++)
{
leftie[j] = u - KnotSequence[i+1-j];
rightie[j] = KnotSequence[i+j] - u;
double saved = 0.0;
for (int r = 0; r < j; r++)
{
ndu[j][r] = rightie[r+1] + leftie[j-r];
double temp = ndu[r][j-1] / ndu[j][r];
ndu[r][j] = saved + rightie[r+1]*temp;
saved = leftie[j-r]*temp;
}
ndu[j][j] = saved;
}
for (int j = 0; j <= p; j++)
Derivate[0][j] = ndu[j][p];
for (int r = 0; r <= p; r++)
{
int j1, j2;
int s1 = 0;
int s2 = 1;
a[0][0] = 1.0;
for (int k = 1; k <= n; k++)
{
double d = 0.0;
int j;
int rk = r - k;
int pk = p - k;
if (r >= k)
{
a[s2][0] = a[s1][0] / ndu[pk+1][rk];
d += a[s2][0] * ndu[rk][pk];
}
if (rk >= -1)
j1 = 1;
else j1 = -rk;
if (r -1 <= pk)
j2 = k -1;
else j2 = p - r;
for (j = j1; j <= j2; j++)
{
a[s2][j] = (a[s1][j]-a[s1][j-1]) / ndu[pk+1][rk+j];
d += a[s2][j] * ndu[rk+j][pk];
}
if (r <= pk)
{
a[s2][k] = -a[s1][k-1] / ndu[pk+1][r];
d += a[s2][k] * ndu[r][pk];
}
Derivate[k][r] = d;
j = s1;
s1 = s2;
s2 = j;
}
}
int r = p;
for (int k = 1; k <= n; k++)
{
for (int j = 0; j <= p; j++)
Derivate[k][j] *= r;
r*= (p-k);
}
}
/*! \brief Translation from nrbeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */
void Routines::PointNrbEval(std::vector<double> &p, std::vector<double> &CurPoint, NURBS &MainNurb)
{
if (!p.empty())
p.clear();
int i = 0, j = 0;
//val = reshape(nurbs.coefs,4*num1,num2);
std::vector< std::vector<double> > CntrlPoints(((MainNurb.MaxU+1)*3), std::vector<double>((MainNurb.MaxV+1), 0.0));
for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); )
{
CntrlPoints[i][j] = MainNurb.CntrlArray[a];
CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1];
CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2];
i += 3;
a += 3;
if (i == ((MainNurb.MaxU+1)*3))
{
i = 0;
j++;
}
}
//v direction...?
i = 0;
std::vector<double> Output(CntrlPoints.size(), 0.0);
PointBSPEval(MainNurb.DegreeV, CntrlPoints, MainNurb.KnotV, Output, CurPoint[1]);
std::vector< std::vector<double> > RedoneOutput(3, std::vector<double>(MainNurb.MaxU+1, 0.0));
for (unsigned int a = 0; a < Output.size(); )
{
RedoneOutput[0][i] = Output[a];
RedoneOutput[1][i] = Output[a+1];
RedoneOutput[2][i] = Output[a+2];
a += 3;
i++;
}
std::vector<double> OutVect(4,0.0);
PointBSPEval(MainNurb.DegreeU, RedoneOutput, MainNurb.KnotU, OutVect,CurPoint[0]);
p.push_back(OutVect[0]);
p.push_back(OutVect[1]);
p.push_back(OutVect[2]);
}
/*! \brief Translation from bspeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */
void Routines::PointBSPEval(int Degree, std::vector< std::vector<double> > &Cntrl, std::vector<double> &KnotSequence,
std::vector< double > &Output, double CurEvalPoint)
{
std::vector<double> Basis(Degree+1, 0.0);
int s = FindSpan(Cntrl[0].size() - 1,Degree,CurEvalPoint,KnotSequence);
Basisfun(s,CurEvalPoint,Degree,KnotSequence,Basis);
int tmp1 = s - Degree;
for (unsigned int row = 0;row < Cntrl.size();row++)
{
double tmp2 = 0.0;
for (int i = 0; i <= Degree; i++)
tmp2 += Basis[i] *Cntrl[row][tmp1+i];
Output[row] = tmp2;
}
}
/*! \brief Translation from nrbderivate.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */
void Routines::PointNrbDerivate(NURBS MainNurb, std::vector<NURBS> &OutNurbs)
{
if (!OutNurbs.empty())
OutNurbs.clear();
NURBS Temp;
int i = 0, j = 0, k = 0;
std::vector< std::vector<double> > ControlDerivate;
std::vector<double> KnotDerivate;
std::vector< std::vector<double> > CntrlPoints(((MainNurb.MaxV+1)*3), std::vector<double>((MainNurb.MaxU+1), 0.0));
for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); )
{
CntrlPoints[i][j] = MainNurb.CntrlArray[a];
CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1];
CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2];
j++;
a += 3;
i = k*3;
if (j == (MainNurb.MaxU+1))
{
j = 0;
k++;
i = k*3;
}
}
//U derivate
bspderiv(MainNurb.DegreeU, CntrlPoints, MainNurb.KnotU, ControlDerivate, KnotDerivate);
Temp.CntrlArray.resize(ControlDerivate.size() * ControlDerivate[0].size());
i = 0, j = 0, k = 0;
for (unsigned int a = 0; a < Temp.CntrlArray.size(); )
{
Temp.CntrlArray[a] = ControlDerivate[i][j];
Temp.CntrlArray[a+1] = ControlDerivate[i+1][j];
Temp.CntrlArray[a+2] = ControlDerivate[i+2][j];
j++;
a += 3;
i = k*3;
if (j == (int)ControlDerivate[i].size())
{
j = 0;
k++;
i = k*3;
}
}
Temp.KnotU = KnotDerivate;
Temp.KnotV = MainNurb.KnotV;
Temp.MaxKnotU = Temp.KnotU.size();
Temp.MaxKnotV = Temp.KnotV.size();
Temp.MaxU = ControlDerivate[0].size();
Temp.MaxV = ControlDerivate.size() / 3;
Temp.DegreeU = Temp.MaxKnotU - Temp.MaxU - 1;
Temp.DegreeV = Temp.MaxKnotV - Temp.MaxV - 1;
Temp.MaxU--;
Temp.MaxV--;
OutNurbs.push_back(Temp);
//reset
i = 0, j = 0, k = 0;
CntrlPoints.clear();
ControlDerivate.clear();
KnotDerivate.clear();
CntrlPoints.resize((MainNurb.MaxU+1)*3);
for (unsigned int a = 0; a < CntrlPoints.size(); a++)
CntrlPoints[a].resize(MainNurb.MaxV+1);
for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); )
{
CntrlPoints[i][j] = MainNurb.CntrlArray[a];
CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1];
CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2];
i += 3;
a += 3;
if (i == ((MainNurb.MaxU+1)*3))
{
i = 0;
j++;
}
}
//V derivate
bspderiv(MainNurb.DegreeV, CntrlPoints, MainNurb.KnotV, ControlDerivate, KnotDerivate);
Temp.CntrlArray.resize(ControlDerivate.size() * ControlDerivate[0].size());
i = 0, j = 0, k = 0;
for (unsigned int a = 0; a < Temp.CntrlArray.size(); )
{
Temp.CntrlArray[a] = ControlDerivate[i][j];
Temp.CntrlArray[a+1] = ControlDerivate[i+1][j];
Temp.CntrlArray[a+2] = ControlDerivate[i+2][j];
a += 3;
i += 3;
if (i == (int)ControlDerivate.size())
{
j++;
i = 0;
}
}
Temp.KnotU = MainNurb.KnotU;
Temp.KnotV = KnotDerivate;
Temp.MaxKnotU = Temp.KnotU.size();
Temp.MaxKnotV = Temp.KnotV.size();
Temp.MaxU = ControlDerivate.size() / 3;
Temp.MaxV = ControlDerivate[0].size();
Temp.DegreeU = Temp.MaxKnotU - Temp.MaxU - 1;
Temp.DegreeV = Temp.MaxKnotV - Temp.MaxV - 1;
Temp.MaxU--;
Temp.MaxV--;
OutNurbs.push_back(Temp);
}
/*! \brief Translation from bspderiv.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */
void Routines::bspderiv(int d, std::vector< std::vector<double> > &c, std::vector<double> &k,
std::vector< std::vector<double> > &OutputC, std::vector<double> &Outputk)
{
OutputC.resize(c.size());
for (unsigned int i = 0; i < OutputC.size(); i++)
OutputC[i].resize(c[i].size()-1);
double tmp = 0.0;
for (unsigned int i = 0; i < OutputC[0].size(); i++)
{
tmp = d / (k[i+d+1]-k[i+1]);
for (unsigned int j = 0; j < OutputC.size(); j++)
OutputC[j][i] = tmp * (c[j][i+1] - c[j][i]);
}
Outputk.resize(k.size() - 2);
for (unsigned int i = 0; i < Outputk.size(); i++)
Outputk[i] = k[i+1];
}
/*! \brief Translation from nrbdeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */
void Routines::NrbDEval(NURBS &MainNurb, std::vector<NURBS> &DerivNurb, std::vector<double> &Point,
std::vector<double> &EvalPoint, std::vector<std::vector<double> > &jac)
{
if (!EvalPoint.empty())
EvalPoint.clear();
if (!jac.empty())
jac.clear();
std::vector<double> TempoPointDeriv;
PointNrbEval(EvalPoint, Point, MainNurb);
for (unsigned int i = 0; i < DerivNurb.size(); i++)
{
PointNrbEval(TempoPointDeriv, Point, DerivNurb[i]);
jac.push_back(TempoPointDeriv);
TempoPointDeriv.clear();
}
}
/*! \brief Uniform Knot Generator */
void Routines::GenerateUniformKnot(int MaxCntrl, int NurbDegree, std::vector<double> &KnotSequence)
{
if (!KnotSequence.empty())
KnotSequence.clear();
for (int i = 0; i < (MaxCntrl + NurbDegree + 2); i++)
KnotSequence.push_back(0);
for (int i = NurbDegree; i < MaxCntrl; i++)
KnotSequence[i+1] = (double)(i - NurbDegree + 1.0) / (double)(MaxCntrl - NurbDegree + 1.0);
for (unsigned int i = MaxCntrl+1; i < KnotSequence.size(); i++)
KnotSequence[i] = 1;
}
/*! \brief Find the corner points
Idea: From the neighbour list, find the shortest distance of a point to the given parameter X and Y.
Parameter X and Y are the bounding boxes parameter of the mesh (combinations of Min and Max of X and Y)
*/
unsigned long Routines::FindCorner(float ParamX, float ParamY, std::vector<unsigned long> &v_neighbour, std::vector <Base::Vector3f> &v_pnts)
{
unsigned int j = 0;
bool change = false;
//double distance = sqrt(((ParamX - ParameterMesh.GetPoint(v_neighbour[0])[0])*(ParamX - ParameterMesh.GetPoint(v_neighbour[0])[0])) +
// ((ParamY - ParameterMesh.GetPoint(v_neighbour[0])[1])*(ParamY - ParameterMesh.GetPoint(v_neighbour[0])[1])));
double distance = sqrt(((ParamX - v_pnts[0][0])*(ParamX - v_pnts[0][0])) +
((ParamY - v_pnts[0][1])*(ParamY - v_pnts[0][1])));
for (unsigned int k = 1; k < v_neighbour.size(); ++k)
{
double eps= sqrt(((ParamX - v_pnts[k][0])*(ParamX - v_pnts[k][0])) +
((ParamY - v_pnts[k][1])*(ParamY - v_pnts[k][1])));
if (eps < distance)
{
distance = eps;
j = k;
change = true;
}
}
if (change)
return v_neighbour[j];
else return v_neighbour[0];
}
/*! \brief Calculate the Area of the triangle, bounded by three vectors from origin. A (bad) diagram is included in source
code */
double Routines::AreaTriangle(Base::Vector3f &a, Base::Vector3f &b, Base::Vector3f &c)
{
/* a
* x----->x b
* \ /
* \ /
* \/
* V
* x c
*/
Base::Vector3f First = b - a;
Base::Vector3f Second = c - a;
std::vector < std::vector<double> > Matrix(2, std::vector<double>(2));
Matrix[0][0] = First.x;
Matrix[1][0] = First.y;
Matrix[0][1] = Second.x;
Matrix[1][1] = Second.y;
return (0.5 * det2(Matrix));
}
/*! \brief Knot Extension
This method will extend the knots by 2. ErrPnt will tell where the knots should be inserted, NurbDegree
and MaxCntrl will make sure that the amount of 0's and 1's are left untouched.
The new values will be calculated here and will be inserted in Extension function
*/
void Routines::ExtendKnot(double ErrPnt, int NurbDegree, int MaxCntrl, std::vector<double> &KnotSequence)
{
double tol_knot = 0.02;
int ind_1 = 0;
double new1 = 0;
int ind_2 = 0;
double new2 = 0;
bool flag = false;
if (KnotSequence.size()>40)
tol_knot = 0.015;
for (unsigned int i = NurbDegree; i < (KnotSequence.size() - NurbDegree); i++)
{
if ((KnotSequence[i] > ErrPnt) && (ErrPnt >= KnotSequence[i-1]))
{
ind_1 = i;
new1 = (KnotSequence[ind_1] + KnotSequence[ind_1-1]) / 2;
}
}
//START CHANGE
if (!flag)
{
double mid = (double)KnotSequence.size() / 2.0;
if (ind_1 == mid)
{
KnotSequence.resize(KnotSequence.size() + 2);
//MainNurb.MaxKnotU += 2;
for (int i = KnotSequence.size() - 1; i > ind_1; i--)
KnotSequence[i] = KnotSequence[i-2];
KnotSequence[ind_1] = KnotSequence[ind_1-1] + ((new1 - KnotSequence[ind_1-1]) / 2.0);
KnotSequence[ind_1+1] = new1 +((new1 - KnotSequence[ind_1-1]) / 2.0);
}
else
{
double temp = mid - ((double)ind_1);
ind_2 = (int)(mid + temp);
new2 = (KnotSequence[ind_2-1] + KnotSequence[ind_2]) / 2.0;
if (ind_1 < ind_2)
Extension(KnotSequence,ind_1,ind_2,new1,new2);
else
Extension(KnotSequence,ind_2,ind_1,new2,new1);
}
}
else
{
if (ind_1 < ind_2)
Extension(KnotSequence,ind_1,ind_2,new1,new2);
else
Extension(KnotSequence,ind_2,ind_1,new2,new1);
}
}
/*! \brief This routine is because it is done over and over again...
*/
void Routines::Extension(std::vector<double> &KnotSequence, int SmallerIndex, int LargerIndex, double SmallerIndNewValue,
double LargerIndNewValue)
{
KnotSequence.resize(KnotSequence.size() + 1);
for (int i = KnotSequence.size() - 1; i > SmallerIndex; i--)
KnotSequence[i] = KnotSequence[i-1];
KnotSequence[SmallerIndex] = SmallerIndNewValue;
LargerIndex++;
KnotSequence.resize(KnotSequence.size() + 1);
for (int i = KnotSequence.size() - 1; i > LargerIndex; i--)
KnotSequence[i] = KnotSequence[i-1];
KnotSequence[LargerIndex] = LargerIndNewValue;
}

View File

@@ -1,114 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Mohamad Najib Muhammad Noor <najib_bean@yahoo.co.uk>
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/*********ROUTINE.H**********/
#ifndef ROUTINE_H
#define ROUTINE_H
/******MAIN INCLUDE******/
#include <vector>
/********FREECAD MESH**********/
// Things from the Mesh module
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/TopoAlgorithm.h>
#include <Mod/Mesh/App/Core/Iterator.h>
#include <Mod/Mesh/App/MeshPy.h>
#include <Mod/Mesh/App/Mesh.h>
/******NURBS STRUCT*********/
/*! \brief This Nurbs struct will be used internally without any connections to the outside
program
*/
typedef struct
{
std::vector<double> CntrlArray;
std::vector<double> KnotU;
std::vector<double> KnotV;
int MaxKnotU;
int MaxKnotV;
int MaxU;
int MaxV;
int DegreeU;
int DegreeV;
}NURBS;
/*! \brief Some Mathematical Routines
This class will be inherited by the Approx class to reduce code bloat.
This class have all the self-written matrix and vector routines,
and some NURBS routines from the Nurbs Book or translated from the NURBS
Toolbox for MATLAB
*/
class CamExport Routines
{
public:
// Multi-dimensional Newton method with a fixed starting value of 0
static std::vector<double> NewtonStep(std::vector<double> &F,std::vector<std::vector<double> > &DF);
protected:
double TrapezoidIntergration(const std::vector<double> &WithRespectTo, const std::vector<double> &Intergral);
//Matrix and vectors
void CramerSolve(std::vector< std::vector<double> > &RHS1, std::vector<double>& RHS2, std::vector<double> &LHS);
double CalcAngle(Base::Vector3f a, Base::Vector3f b, Base::Vector3f c);
/*! Determinant of a 2x2 Matrix */
inline double det2(std::vector< std::vector<double> > &Matrix)
{
return ((Matrix[0][0] * Matrix[1][1]) - (Matrix[0][1] * Matrix[1][0]));
};
double AreaTriangle(Base::Vector3f &a, Base::Vector3f &b, Base::Vector3f &c);
//NURBS
int FindSpan(int n, int p, double u, std::vector<double> KnotSequence);
void DersBasisFuns(int i, double u, int p, int n,
std::vector<double> &KnotSequence, std::vector< std::vector<double> > &Derivate);
void Basisfun(int i, double u, int p, std::vector<double> &KnotSequence, std::vector<double> &output);
void NrbDEval(NURBS &MainNurb, std::vector<NURBS> &DerivNurb, std::vector<double> &Point,
std::vector<double> &EvalPoint, std::vector<std::vector<double> > &jac);
void PointNrbEval(std::vector<double> &p, std::vector<double> &CurPoint, NURBS &MainNurb);
void PointBSPEval(int DegreeU, std::vector< std::vector<double> > &Cntrl, std::vector<double> &KnotSequence,
std::vector< double > &Output, double CurEvalPoint);
void PointNrbDerivate(NURBS MainNurb, std::vector<NURBS> &OutNurbs);
void bspderiv(int d, std::vector< std::vector<double> > &c, std::vector<double> &k,
std::vector< std::vector<double> > &OutputC, std::vector<double> &Outputk);
void ExtendKnot(double ErrPnt, int NurbDegree, int MaxCntrl, std::vector<double> &KnotSequence);
void Extension(std::vector<double> &KnotSequence, int SmallerIndex, int LargerIndex, double SmallerIndNewValue,
double LargerIndNewValue);
void GenerateUniformKnot(int MaxCntrl, int NurbDegree, std::vector<double> &KnotSequence);
unsigned long FindCorner(float ParamX, float ParamY, std::vector<unsigned long> &v_neighbour, std::vector <Base::Vector3f> &v_pnts);
private:
//Variables in Use by Routine TrapezoidIntegration
double m_h, m_result;
int m_N;
};
#endif /*ROUTINE_H DEFINED*/

View File

@@ -1,78 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/**\file
\brief Mostly functors for less operators can be found here
*/
#ifndef STUFF_H
#define STUFF_H
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
/**\brief Functor to sort a pair of type pair<float,TopoDS_Wire>
Mostly used in the cutting class as a sorting of the different resulting wires is necessary if there is
more then one resulting cutting curve
\param _Left A pair which consists of a float value (mostly here the Z-Level is stored) and a TopoDS_Wire
\param _Right Exactly the same as _Left but here it is used to compare with _First
\return A Boolean Value which is either true != 0 or false == 0 depending which Z-Level is higher or lower
*/
bool inline FloatWirePairHuge(const std::pair<float,TopoDS_Wire>& _Left, const std::pair<float,TopoDS_Wire>& _Right)
{
return _Left.first > _Right.first;
}
/**\brief Functor to sort two float values
Just a test function which is able to sort also from high to low and not only from low to high
(like the less operator is normally doing it)
\param _Left A float value
\param _Right A float value for the comparison with the _Left
\return A Boolean Value which is either true != 0 or false == 0 depending which float value is higher
*/
bool inline FloatHuge(const float _Left, const float _Right)
{
return _Left > _Right;
}
/**\brief A container to have an easy access to an edge with start and endpoint*/
struct edge_container
{
TopoDS_Edge edge;
gp_Pnt firstPoint;
gp_Pnt lastPoint;
};
/**\brief A container used for projecting points on faces along a normal vector*/
struct projectPointContainer
{
gp_Pnt point;
gp_Dir normalvector;
TopoDS_Face face;
};
#endif /*DEFINE STUFF_H*/

View File

@@ -1,13 +0,0 @@
add_subdirectory(App)
if(BUILD_GUI)
add_subdirectory(Gui)
endif(BUILD_GUI)
INSTALL(
FILES
Init.py
InitGui.py
DESTINATION
Mod/Cam
)

View File

@@ -1,29 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppCam", "App\AppCam.vcproj", "{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppCamGui", "Gui\AppCamGui.vcproj", "{071D36BB-65CE-4219-847D-005D2C142D46}"
ProjectSection(ProjectDependencies) = postProject
{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59} = {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Debug|Win32.ActiveCfg = Debug|Win32
{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Debug|Win32.Build.0 = Debug|Win32
{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Release|Win32.ActiveCfg = Release|Win32
{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Release|Win32.Build.0 = Release|Win32
{071D36BB-65CE-4219-847D-005D2C142D46}.Debug|Win32.ActiveCfg = Debug|Win32
{071D36BB-65CE-4219-847D-005D2C142D46}.Debug|Win32.Build.0 = Debug|Win32
{071D36BB-65CE-4219-847D-005D2C142D46}.Release|Win32.ActiveCfg = Release|Win32
{071D36BB-65CE-4219-847D-005D2C142D46}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,77 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/WidgetFactory.h>
#include "Workbench.h"
// use a different name to CreateCommand()
void CreateCamCommands(void);
/* registration table */
static struct PyMethodDef CamGui_methods[] =
{
{
NULL, NULL
} /* end of table marker */
};
extern "C"
{
void CamGuiExport initCamGui()
{
if (!Gui::Application::Instance)
{
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
return;
}
// load dependent module
try {
Base::Interpreter().loadModule("Cam");
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
return;
}
(void) Py_InitModule("CamGui", CamGui_methods); /* mod name, table ptr */
Base::Console().Log("Loading GUI of Cam module... done\n");
CamGui::Workbench ::init();
// instantiating the commands
CreateCamCommands();
return;
}
} // extern "C"

View File

@@ -1,77 +0,0 @@
if(WIN32)
add_definitions(-DHAVE_ACOSH -DHAVE_ATANH -DHAVE_ASINH)
else(WIN32)
endif(WIN32)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
${COIN3D_INCLUDE_DIR}
${OCC_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${QT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${XercesC_INCLUDE_DIRS}
${SMSH_INCLUDE_DIR}
${SMESH_INCLUDE_DIR}
)
if(MSVC)
set(CamGui_LIBS
Cam
Mesh
PartGui
FreeCADGui
importlib_atlas.lib
importlib_umfpackamd.lib
${SMSH_LIBRARIES}
${SMESH_LIBRARIES}
)
else(MSVC)
set(CamGui_LIBS
Cam
PartGui
FreeCADGui
)
endif(MSVC)
set(CamGui_MOC_HDRS
Cutting.h
)
fc_wrap_cpp(CamGui_MOC_SRCS ${CamGui_MOC_HDRS})
SOURCE_GROUP("Moc" FILES ${CamGui_MOC_SRCS})
set(CamGui_UIC_SRCS
Cutting.ui
)
qt5_wrap_ui(CamGui_UIC_HDRS ${CamGui_UIC_SRCS})
SET(CamGui_SRCS
${CamGui_UIC_HDRS}
AppCamGui.cpp
Command.cpp
Cutting.cpp
Cutting.h
Cutting.ui
PreCompiled.cpp
PreCompiled.h
Workbench.cpp
Workbench.h
)
add_library(CamGui SHARED ${CamGui_SRCS})
target_link_libraries(CamGui ${CamGui_LIBS})
fc_target_copy_resource(CamGui
${CMAKE_SOURCE_DIR}/src/Mod/Cam
${CMAKE_BINARY_DIR}/Mod/Cam
InitGui.py)
SET_BIN_DIR(CamGui CamGui /Mod/Cam)
if(WIN32)
set_target_properties(CamGui PROPERTIES SUFFIX ".pyd")
endif(WIN32)
INSTALL(TARGETS CamGui DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -1,63 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Cutting.h"
#include <Gui/Command.h>
#include <Gui/Application.h>
#include <Gui/MainWindow.h>
#include <QPointer>
//===========================================================================
// StdCamCutting
//===========================================================================
DEF_STD_CMD(StdCamCutting);
StdCamCutting::StdCamCutting()
:Command("Cam_Cutting")
{
sGroup = QT_TR_NOOP("Tools");
sMenuText = QT_TR_NOOP("Cutting...");
sToolTipText = QT_TR_NOOP("Cutting");
sWhatsThis = "Cam_Cutting";
sStatusTip = QT_TR_NOOP("Cutting");
}
void StdCamCutting::activated(int iMsg)
{
static QPointer<QDialog> dlg = 0;
if (!dlg)
dlg = new CamGui::Cutting(Gui::getMainWindow());
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
}
void CreateCamCommands()
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new StdCamCutting());
}

View File

@@ -1,921 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "Cutting.h"
#include <Mod/Cam/App/ChangeDyna.h> //Only for Testing
#include <Mod/Cam/App/best_fit.h>
#include <Mod/Cam/App/path_simulate.h>
#include <Mod/Cam/App/SpringbackCorrection.h>
#include <Mod/Cam/App/UniGridApprox.h>
#include <Mod/Cam/App/Approx.h>
#include <Mod/Cam/App/deviation.h>
#include <QTimer>
#include <QByteArray>
#include <Base/Vector3D.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Gui/ViewProvider.h>
#include <Gui/Selection.h>
#include <Gui/Application.h>
#include <Gui/MainWindow.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <App/Document.h>
#include <Gui/Document.h>
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <Mod/Cam/App/cutting_tools.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include <Mod/Part/Gui/ViewProvider.h>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <GCPnts_QuasiUniformAbscissa.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Mod/Mesh/App/Core/Grid.h>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/SoPickedPoint.h>
#include <QMessageBox>
#include <QFileDialog>
using namespace CamGui;
Cutting::Cutting(QWidget* parent,Qt::WFlags fl)
:QDialog(parent,fl),m_Process(NULL),
m_PathSimulate(NULL),m_CuttingAlgo(NULL),
m_BestFit(NULL),m_MergeData(NULL),m_Deviation(NULL)
{
this->setupUi(this);
m_timer= false;
}
Cutting::~Cutting()
{
delete m_CuttingAlgo;
delete m_PathSimulate;
delete m_Process;
delete m_BestFit;
delete m_Deviation;
delete m_MergeData;
}
bool Cutting::getProcessOutput()
{
QByteArray result = m_Process->readAll();
if (result.contains("Error"))
{
m_Process->kill();
QMessageBox::critical(this, tr("FreeCAD CamWorkbench"),
tr("Error in generation\n"),
QMessageBox::Ok, QMessageBox::NoButton);
}
else if (result.contains("N o r m a l t e r m i n a t i o n"))
{
QMessageBox::information(this, tr("FreeCAD CamWorkbench"),
tr("Dyna-Job finished well\n"),
QMessageBox::Ok, QMessageBox::NoButton);
}
return true;
}
void Cutting::on_adaptdynainput_clicked()
{
//First we have to select the LS-Dyna Masterfile and the current working dir
QString filename, path, program;
QStringList arguments;
QString strcheck("dyna.str");
filename = QFileDialog::getOpenFileName( this, "Open Dyna.Str or Master-Key File",filename,"Ls-Dyna Keywords (*.k) (*.str)" );
if (filename.isNull())
return;
QFileInfo aFileInfo(filename);
path = aFileInfo.absolutePath();
QDir::setCurrent(path);
program = "c:/Program Files/lsdyna/ls971d";
//As the new Versions already account for a proper curve file we no longer have to adapt the input
//if we already have a str File we will not step into the next if-case
//if(!aFileInfo.fileName().contains("dyna.str"))
//{
// arguments << " i="<< aFileInfo.fileName();
// m_Process = new QProcess(this);
// m_Process->start(program, arguments);
// //Now we check if the output is written correctly
// m_Process->waitForFinished(50000);
// aFileInfo.setFile("dyna.str");
// if (aFileInfo.size() == 0) //the file does not exist
// {
// QMessageBox::critical(this, tr("FreeCAD CamWorkbench"),
// tr("Error when creating the Struct file\n"),
// QMessageBox::Ok, QMessageBox::NoButton);
// return;
// }
// else
// {
// QMessageBox::information(this, tr("FreeCAD CamWorkbench"),
// tr("Structured Dyna generated well\n"),
// QMessageBox::Ok, QMessageBox::NoButton);
// }
//}
//ChangeDyna aFileChanger;
//if (aFileChanger.Read("dyna.str"))
// start_simulation->show();
//else{
// QMessageBox::critical(this, tr("FreeCAD CamWorkbench"),
// tr("Error while parsing the str File\n"),
// QMessageBox::Ok, QMessageBox::NoButton);
// return;
//}
}
void Cutting::on_start_simulation_clicked()
{
//check if the initial process is already killed
m_Process->kill();
QString program;
QStringList arguments;
program = "c:/Program Files/lsdyna/ls971d";
arguments << " i=dyna2.str";
connect(m_Process,SIGNAL(readyReadStandardError()),this,SLOT(getProcessOutput()));
connect(m_Process,SIGNAL(readyReadStandardOutput()),this,SLOT(getProcessOutput()));
m_Process->start(program, arguments);
}
void Cutting::on_Deviation_button_clicked()
{
m_Deviation = new Deviation();
deviation_geometry1_button->setEnabled(true);
deviation_geometry2_button->setEnabled(true);
deviation_go_button->setEnabled(true);
}
void Cutting::on_deviation_geometry1_button_clicked()
{
selectShape();
}
void Cutting::on_deviation_geometry2_button_clicked()
{
selectMesh();
}
void Cutting::on_deviation_go_button_clicked()
{
QString current_filename = QFileDialog::getSaveFileName(this,"Select Deviation Files","","*.txt");
m_Deviation->ImportGeometry(m_Shape, m_Mesh);
m_Deviation->Compute();
m_Deviation->WriteOutput(current_filename);
}
void Cutting::on_error_accumulation_select_files_button_clicked()
{
m_MergeData = new MergeData();
QStringList m_dateinamen = QFileDialog::getOpenFileNames(
this,
"Select one or more files to open",
"c:",
"Deviation Files (*.txt)");
if (!m_dateinamen.isEmpty())
{
if (!m_MergeData->Einlesen(m_dateinamen))
{
QMessageBox::information(this, tr("FreeCAD CamWorkbench"),
tr("Everything OK. Output can be generated\n"),
QMessageBox::Ok, QMessageBox::NoButton);
}
}
error_accumulation_go_button->setEnabled(true);
}
void Cutting::on_error_accumulation_go_button_clicked()
{
QString current_filename = QFileDialog::getSaveFileName(this,"Select Output File","","*.txt");
m_MergeData->WriteOutput(current_filename);
}
void Cutting::selectShape()
{
if (!m_timer)
{
int check_box1=0,check_box2=0;
if (!m_Shape.IsNull())
{
check_box1 = QMessageBox::question(this, tr("FreeCAD CamWorkbench"),
tr("You have already selected a CAD-Shape.\n"
"Do you want to make a new Selection?"),
QMessageBox::Yes, QMessageBox::No);
}
else
{
check_box2 = QMessageBox::information(this, tr("FreeCAD CamWorkbench"),
tr("You have to select a CAD-Shape.\n"),
QMessageBox::Ok, QMessageBox::Cancel);
}
if ((check_box1 == QMessageBox::Yes) || (check_box2 == QMessageBox::Ok))
{
//First, remove the old selection from the Gui, so that we do not directly have the same CAD once again.
Gui::Selection().clearCompleteSelection();
//to make a Selection more easy, hide the dialog
this->hide();
QTimer::singleShot(100,this,SLOT(selectShape()));
m_timer = true;
}
}
else
{
std::vector<App::DocumentObject*> fea = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId());
if ( fea.size() == 1)
{
m_Shape = static_cast<Part::Feature*>(fea.front())->Shape.getValue();
//std::vector<Gui::SelectionSingleton::SelObj> aSelection = Gui::Selection().getSelection();
this->show();
CalculateZLevel->setEnabled(true);
CalculateFeatureBased->setEnabled(true);
CalculateSpiralBased->setEnabled(true);
m_timer = false;
}
else
{
QTimer::singleShot(100,this,SLOT(selectShape()));
m_timer = true;
}
}
}
void Cutting::selectMesh()
{
if (!m_timer)
{
int check_box1=0,check_box2=0;
if (m_Mesh.CountPoints() > 0)
{
check_box1 = QMessageBox::question(this, tr("FreeCAD CamWorkbench"),
tr("You have already selected a Mesh.\n"
"Do you want to make a new Selection?"),
QMessageBox::Yes, QMessageBox::No);
}
else
{
check_box2 = QMessageBox::information(this, tr("FreeCAD CamWorkbench"),
tr("You have to select a Mesh.\n"),
QMessageBox::Ok, QMessageBox::Cancel);
}
if ((check_box1 == QMessageBox::Yes) || (check_box2 == QMessageBox::Ok))
{
//First, remove the old selection from the Gui, so that we do not directly have the same CAD once again.
Gui::Selection().clearCompleteSelection();
//to make a Selection more easy, hide the dialog
this->hide();
QTimer::singleShot(100,this,SLOT(selectMesh()));
m_timer = true;
}
}
else
{
std::vector<App::DocumentObject*> fea = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId());
if ( fea.size() == 1)
{
m_Mesh = static_cast<Mesh::Feature*>(fea.front())->Mesh.getValue().getKernel();
//std::vector<Gui::SelectionSingleton::SelObj> aSelection = Gui::Selection().getSelection();
this->show();
m_timer = false;
}
else
{
QTimer::singleShot(100,this,SLOT(selectMesh()));
m_timer = true;
}
}
}
void Cutting::setFace(const TopoDS_Shape& aShape, const float x, const float y, const float z)
{
//check if a Shape is selected
std::vector<App::DocumentObject*> fea = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId());
if ( fea.size() == 1)
{
int test = aShape.ShapeType();
//get Hash Code of Selected Face inside the selected Shape and also the Coordinates of the click
if (aShape.ShapeType() != TopAbs_FACE)
{
QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to select a Face!!\n"));
return;
}
TopoDS_Face tempFace = TopoDS::Face(aShape);
//Now search for the Hash-Code in the m_Shape
TopExp_Explorer anExplorer;
TopoDS_Face aselectedFace;
//pickPoint.Set(x,y,z);
for (anExplorer.Init(m_Shape,TopAbs_FACE);anExplorer.More();anExplorer.Next())
{
if (tempFace.HashCode(IntegerLast()) == anExplorer.Current().HashCode(IntegerLast()))
{
if (m_selection == Springback)
(m_Spring->m_FixFaces).push_back(TopoDS::Face(anExplorer.Current()));
else if (m_selection == BestFit)
(m_BestFit->m_LowFaces).push_back(TopoDS::Face(anExplorer.Current()));
else if (m_selection == ToolpathCalculation)
m_CuttingAlgo->SetMachiningOrder(TopoDS::Face(anExplorer.Current()),x,y,z);
break;
}
}
}
}
void Cutting::on_CalculateZLevel_clicked()
{
// Instantiating Cutting class
if (m_CuttingAlgo == NULL)
m_CuttingAlgo = new cutting_tools(m_Shape);
else
{
delete m_CuttingAlgo;
m_CuttingAlgo = new cutting_tools(m_Shape);
}
m_Mode = 1;
CalculateFeatureBased->setEnabled(false);
CalculateSpiralBased->setEnabled(false);
toolpath_calculation_highest_level_button->setEnabled(true);
m_selection = ToolpathCalculation;
}
void Cutting::on_CalculateFeatureBased_clicked()
{
if (m_CuttingAlgo == NULL)
m_CuttingAlgo = new cutting_tools(m_Shape);
else
{
delete m_CuttingAlgo;
m_CuttingAlgo = new cutting_tools(m_Shape);
}
m_Mode = 2;
toolpath_calculation_highest_level_button->setEnabled(true);
m_selection = ToolpathCalculation;
CalculateZLevel->setEnabled(false);
CalculateSpiralBased->setEnabled(false);
}
void Cutting::on_CalculateSpiralBased_clicked()
{
if (m_CuttingAlgo == NULL)
m_CuttingAlgo = new cutting_tools(m_Shape);
else
{
delete m_CuttingAlgo;
m_CuttingAlgo = new cutting_tools(m_Shape);
}
m_Mode = 3;//
toolpath_calculation_highest_level_button->setEnabled(true);
m_selection = ToolpathCalculation;
CalculateZLevel->setEnabled(false);
CalculateFeatureBased->setEnabled(false);
}
void Cutting::on_select_shape_z_level_button_clicked()
{
selectShape();
}
void Cutting::on_select_shape_feature_based_button_clicked()
{
selectShape();
}
void Cutting::on_select_shape_spiral_based_button_clicked()
{
selectShape();
}
void Cutting::on_toolpath_calculation_highest_level_button_clicked()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view)
{
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this);
QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n"));
this->hide();
}
toolpath_calculation_middle_level_button->setEnabled(true);
toolpath_calculation_lowest_level_button->setEnabled(true);
}
void Cutting::on_toolpath_calculation_middle_level_button_clicked()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view)
{
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this);
QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n"));
this->hide();
}
}
void Cutting::on_toolpath_calculation_lowest_level_button_clicked()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view)
{
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this);
QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n"));
this->hide();
}
toolpath_calculation_go_button->setEnabled(true);
}
void Cutting::on_toolpath_calculation_go_button_clicked()
{
//Do the actual Cut
//First transfer the settings to the Cutting_tools class
m_CuttingAlgo->m_UserSettings = getSettings();
if (!m_CuttingAlgo->arrangecuts_ZLEVEL())
{
std::cout << "Couldn't cut properly" << std::endl;
}
bool ok = true;
try
{
switch (m_Mode)
{
case 1:
ok = m_CuttingAlgo->OffsetWires_Standard();
break;
case 2:
ok = m_CuttingAlgo->OffsetWires_FeatureBased();
break;
case 3:
ok = m_CuttingAlgo->OffsetWires_Spiral();
break;
}
}
catch (...)
{
std::cout<<"Error"<<std::endl;
}
if (!ok)
{
QMessageBox::critical(this, tr("FreeCAD CamWorkbench"),
tr("Something is wrong. Try everything again\n"),
QMessageBox::Ok, QMessageBox::NoButton);
delete m_CuttingAlgo;
m_CuttingAlgo = new cutting_tools(m_Shape);
return;
}
DisplayCAMOutput();
GenRobotOut->setEnabled(true);
GenSimOut->setEnabled(true);
}
void Cutting::on_GenSimOut_clicked()
{
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Simulation-Path Output-Directory"),"d:/",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (dir.isNull())
return;
QDir::setCurrent(dir);
if (m_PathSimulate != NULL) delete m_PathSimulate;//If it exists already
m_PathSimulate = new path_simulate(*(m_CuttingAlgo->getOutputhigh()),*(m_CuttingAlgo->getOutputlow()),m_CuttingAlgo->m_UserSettings);
switch (m_Mode)
{
case 1:
if (m_PathSimulate->MakePathSimulate())
adaptdynainput->setEnabled(true);
break;
case 2:
if (m_PathSimulate->MakePathSimulate_Feat(m_CuttingAlgo->getFlatAreas(),0))
adaptdynainput->setEnabled(true);
break;
case 3:
if (m_PathSimulate->MakePathSimulate_Feat(m_CuttingAlgo->getFlatAreas(),1))
adaptdynainput->setEnabled(true);
break;
}
}
void Cutting::on_GenRobotOut_clicked()
{
QString dir = QFileDialog::getExistingDirectory(this, tr("Select File Output-Directory"),"d:/",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
QDir::setCurrent(dir);
if (m_PathSimulate != NULL) delete m_PathSimulate;
m_PathSimulate = new path_simulate(*(m_CuttingAlgo->getOutputhigh()),*(m_CuttingAlgo->getOutputlow()),m_CuttingAlgo->m_UserSettings);
switch (m_Mode)
{
case 1:
m_PathSimulate->MakePathRobot();
break;
case 2:
m_PathSimulate->MakePathRobot_Feat(m_CuttingAlgo->getFlatAreas());
break;
}
}
const CuttingToolsSettings& Cutting::getSettings()
{
//First transfer the settings to the Cutting_tools class
m_Settings.cad_radius = cad_radius_box->value();
m_Settings.correction_factor = correction_factor_box->value();
m_Settings.level_distance = level_distance_box->value();
m_Settings.limit_angle = limit_angle_box->value();
m_Settings.sheet_thickness = sheet_thickness_box->value();
m_Settings.slave_radius = slave_radius_box->value();
m_Settings.master_radius = master_radius_box->value();
m_Settings.max_Vel = max_vel->value();
m_Settings.max_Acc = max_acc->value();
m_Settings.spring_pretension = spring_pretension->value();
m_Settings.x_offset_robot = xoffset_box->value();
m_Settings.y_offset_robot = yoffset_box->value();
m_Settings.clockwise = clockwise_checkbox->isChecked();
m_Settings.error_tolerance = error_tolerance->value();
return m_Settings;
}
void Cutting::on_BestFitButton_clicked()
{
m_selection = BestFit;
m_BestFit = new best_fit();
// Best-Fit based on Point-Clouds
m_BestFit->Initialize_Mesh_Geometrie_1();
m_BestFit->Initialize_Mesh_Geometrie_2();
m_BestFit->Perform_PointCloud();
m_BestFit->output_best_fit_mesh();
best_fit_cad_button->setEnabled(true);
}
void Cutting::on_SpringbackButton_clicked()
{
m_Spring = new SpringbackCorrection();
m_selection = Springback;
best_fit_cad_button->setEnabled(true);
}
void Cutting::on_Approximate_button_clicked()
{
m_selection = Approx;
best_fit_mesh_button->setEnabled(true);
}
void Cutting::on_best_fit_cad_button_clicked()
{
selectShape();
best_fit_mesh_button->setEnabled(true);
}
void Cutting::on_best_fit_mesh_button_clicked()
{
if(m_selection == Springback)
{
best_fit_mesh2_button->setEnabled(true);
m_Spring->Load(m_Shape);
}
selectMesh();
best_fit_go_button->setEnabled(true);
SelectFace_button->setEnabled(true);
if(m_selection == Springback)
best_fit_mesh2_button->setEnabled(true);
}
void Cutting::on_best_fit_mesh2_button_clicked()
{
m_Spring->Load(m_Mesh);
selectMesh();
}
void Cutting::on_SelectFace_button_clicked()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view)
{
Gui::View3DInventorViewer* viewer = view->getViewer();
viewer->setEditing(true);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this);
QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a face.\n"));
this->hide();
}
}
void Cutting::on_best_fit_go_button_clicked()
{
bool out = 1; //specifies whether ONLY the error vectors should be output in the case of springback
getSettings(); //First transfer the settings to the Cutting_tools class (-> m_Settings)
switch (m_selection)
{
case BestFit:
m_BestFit->Load(m_Mesh,m_Shape);
m_BestFit->Perform();
best_fit_cad_button ->setEnabled(false);
best_fit_mesh_button->setEnabled(false);
best_fit_go_button ->setEnabled(false);
m_MeshOut = m_BestFit->m_MeshWork;
m_MeshCad = m_BestFit->m_CadMesh;
DisplayMeshOutput(m_MeshOut);
//DisplayMeshOutput(m_MeshCad);
break;
case Springback:
m_Spring->Load(m_Mesh);
m_Spring->Init_Setting(m_Settings);
m_Spring->Init();
m_Spring->Perform(m_Settings.limit_angle,out);
m_MeshCad = m_Spring->m_CadMesh;
best_fit_cad_button ->setEnabled(false);
best_fit_mesh_button->setEnabled(false);
best_fit_go_button ->setEnabled(false);
if(out==0)
{
DisplayMeshOutput(m_MeshCad);
DisplayMeshOutput(m_Spring->m_Mesh_vis);
DisplayMeshOutput(m_Spring->m_Mesh_vis2);
}
best_fit_mesh2_button->setEnabled(true);
break;
case Approx:
// The file "Kleines.stl" has a point above the level ... not compatible with this Algo
/*MeshCore::MeshPointArray pnts = m_Mesh.GetPoints();
MeshCore::MeshFacetArray facets = m_Mesh.GetFacets();
for(int i=0; i<pnts.size(); ++i)
{
if(pnts[i].z >0.0)
pnts[i].z *= -1;
}
m_Mesh.Assign(pnts,facets);*/
std::vector<double> CtrlPnts, U_knot, V_knot;
int degU,degV;
m_App = new Approximate(m_Mesh,CtrlPnts,U_knot,V_knot,degU,degV,m_Settings.error_tolerance);
//m_Approx = new UniGridApprox(m_Mesh, 1);
//m_Approx->Perform(0.1);
BRepBuilderAPI_MakeFace Face(m_App->aAdaptorSurface.Surface());
m_Shape = Face.Face();
ofstream anOutputFile;
anOutputFile.open("c:/approx_log.txt");
anOutputFile << "face assigned" << endl;
DisplayMeshOutput(m_App->MeshParam);
DisplayShapeOutput();
break;
}
}
void Cutting::DisplayMeshOutput(const MeshCore::MeshKernel &mesh)
{
App::Document* doc = App::GetApplication().getActiveDocument();
App::DocumentObject* obj = doc->addObject("Mesh::Feature","Best_Fit-Mesh");
Mesh::Feature* part1 = static_cast<Mesh::Feature*>(obj);
part1->Mesh.setValue(mesh);
//doc->recompute();
}
void Cutting::DisplayShapeOutput()
{
App::Document* doc = App::GetApplication().getActiveDocument();
App::DocumentObject* obj = doc->addObject("Part::Feature","Output-Shape");
Part::Feature* part1 = static_cast<Part::Feature*>(obj);
part1->Shape.setValue(m_Shape);
//doc->recompute();
}
void Cutting::DisplayCAMOutput()
{
BRep_Builder BB;
TopoDS_Compound aCompound1,aCompound2;
BB.MakeCompound(aCompound1);
BB.MakeCompound(aCompound2);
TopoDS_Edge anEdge;
const std::vector<Handle_Geom_BSplineCurve>* topCurves;
const std::vector<Handle_Geom_BSplineCurve>* botCurves;
std::vector<Handle_Geom_BSplineCurve>::const_iterator an_it1;
topCurves = m_CuttingAlgo->getOutputhigh();
botCurves = m_CuttingAlgo->getOutputlow();
for (an_it1 = topCurves->begin();an_it1!=topCurves->end();an_it1++)
{
BB.MakeEdge(anEdge,*an_it1,0.01);
BB.Add(aCompound1,anEdge);
}
for (an_it1 = botCurves->begin();an_it1!=botCurves->end();an_it1++)
{
BB.MakeEdge(anEdge,*an_it1,0.01);
BB.Add(aCompound2,anEdge);
}
App::Document* doc = App::GetApplication().getActiveDocument();
App::DocumentObject* obj = doc->addObject("Part::Feature","Master-Tool");
App::DocumentObject* obj1 = doc->addObject("Part::Feature","Slave-Tool");
Part::Feature* part1 = static_cast<Part::Feature*>(obj);
Part::Feature* part2 = static_cast<Part::Feature*>(obj1);
part1->Shape.setValue(aCompound1);
part2->Shape.setValue(aCompound2);
//
// for (unsigned int i=0;i<aTestOutput.size();++i)
// {
// BB.Add(aCompound,anEdge);
// }
//anewCuttingEnv.OffsetWires_Standard(10.0);
//std::vector<Handle_Geom_BSplineCurve> topCurves;
//std::vector<Handle_Geom_BSplineCurve> botCurves;
//std::vector<Handle_Geom_BSplineCurve>::iterator an_it;
//topCurves = *(anewCuttingEnv.getOutputhigh());
//botCurves = *(anewCuttingEnv.getOutputlow());
ofstream anoutput;
ofstream anoutput2;
anoutput.open("c:/topCurves.txt");
anoutput2.open("c:/botCurves.txt");
for (an_it1 = topCurves->begin();an_it1!=topCurves->end();an_it1++)
{
GeomAdaptor_Curve aCurveAdaptor(*an_it1);
GCPnts_QuasiUniformDeflection aPointGenerator(aCurveAdaptor,0.1);
for (int t=1;t<=aPointGenerator.NbPoints();++t)
{
anoutput << (aPointGenerator.Value(t)).X() <<","<< (aPointGenerator.Value(t)).Y() <<","<<(aPointGenerator.Value(t)).Z()<<std::endl;
}
}
for (an_it1 = botCurves->begin();an_it1!=botCurves->end();an_it1++)
{
GeomAdaptor_Curve aCurveAdaptor(*an_it1);
GCPnts_QuasiUniformDeflection aPointGenerator(aCurveAdaptor,0.1);
for (int t=1;t<=aPointGenerator.NbPoints();++t)
{
anoutput2 << (aPointGenerator.Value(t)).X() <<","<< (aPointGenerator.Value(t)).Y() <<","<<(aPointGenerator.Value(t)).Z()<<std::endl;
}
}
anoutput.close();
anoutput2.close();
}
void Cutting::zLevelCallback(void * ud, SoEventCallback * n)
{
const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent();
Gui::View3DInventorViewer* view = reinterpret_cast<Gui::View3DInventorViewer*>(n->getUserData());
Cutting* that = reinterpret_cast<Cutting*>(ud);
// Mark all incoming mouse button events as handled, especially, to deactivate the selection node
n->getAction()->setHandled();
if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP)
{
n->setHandled();
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, that);
that->show();
}
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN)
{
const SoPickedPoint * point = n->getPickedPoint();
if (point == NULL)
{
QMessageBox::warning(Gui::getMainWindow(),"z level", "No shape picked!");
return;
}
n->setHandled();
// By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is
// really from the mesh we render and not from any other geometry
Gui::ViewProvider* vp = static_cast<Gui::ViewProvider*>(view->getViewProviderByPath(point->getPath()));
if (!vp || !vp->getTypeId().isDerivedFrom(PartGui::ViewProviderPart::getClassTypeId()))
return;
PartGui::ViewProviderPart* vpp = static_cast<PartGui::ViewProviderPart*>(vp);
std::string element = vpp->getElement(point->getDetail());
TopoDS_Shape sh = static_cast<Part::Feature*>(vpp->getObject())->
Shape.getShape().getSubShape(element.c_str());
if (!sh.IsNull())
{
// ok a shape was picked
n->setHandled();
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, that);
that->show();
SbVec3f pt = point->getPoint();
that->setFace(sh, pt[0],pt[1],pt[2]);
}
}
}
#include "moc_Cutting.cpp"

View File

@@ -1,137 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* Copyright (c) 2007 Werner Mayer <wmayer@users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef CAMGUI_CUTTING_H
#define CAMGUI_CUTTING_H
#include "ui_Cutting.h"
#include <Base/Vector3D.h>
#include <QProcess>
#include <Mod/Mesh/App/Core/Grid.h>
#include <Mod/Cam/App/cutting_tools.h>
#include <Inventor/nodes/SoEventCallback.h>
#include <Mod/Cam/App/mergedata.h>
#include <zlib.h>
class best_fit;
class cutting_tools;
class path_simulate;
class SpringbackCorrection;
class UniGridApprox;
class TopoDS_Shape;
class Approximate;
class Deviation;
class MergeData;
namespace CamGui
{
class Cutting : public QDialog, public Ui_Cutting
{
Q_OBJECT
public:
Cutting(QWidget* parent,Qt::WFlags = 0);
~Cutting();
protected Q_SLOTS:
void on_CalculateZLevel_clicked();
void on_CalculateFeatureBased_clicked();
void on_CalculateSpiralBased_clicked();
void on_select_shape_z_level_button_clicked();
void on_select_shape_feature_based_button_clicked();
void on_select_shape_spiral_based_button_clicked();
void on_toolpath_calculation_highest_level_button_clicked();
void on_toolpath_calculation_middle_level_button_clicked();
void on_toolpath_calculation_lowest_level_button_clicked();
void on_toolpath_calculation_go_button_clicked();
void on_GenSimOut_clicked();
void on_GenRobotOut_clicked();
void on_adaptdynainput_clicked();
void on_start_simulation_clicked();
void on_BestFitButton_clicked();
void on_SpringbackButton_clicked();
void on_Approximate_button_clicked();
void on_best_fit_cad_button_clicked();
void on_best_fit_mesh_button_clicked();
void on_best_fit_mesh2_button_clicked();
void on_SelectFace_button_clicked();
void on_best_fit_go_button_clicked();
void on_Deviation_button_clicked();
void on_deviation_geometry1_button_clicked();
void on_deviation_geometry2_button_clicked();
void on_deviation_go_button_clicked();
void on_error_accumulation_go_button_clicked();
void on_error_accumulation_select_files_button_clicked();
void selectShape();
void selectMesh();
bool getProcessOutput();
const CuttingToolsSettings& getSettings();
void setFace(const TopoDS_Shape &aFace, const float , const float,const float);
private:
static void zLevelCallback(void * ud, SoEventCallback * n);
void DisplayCAMOutput();
void DisplayMeshOutput(const MeshCore::MeshKernel &mesh);
void DisplayShapeOutput();
private:
SpringbackCorrection *m_Spring;
cutting_tools *m_CuttingAlgo; //Generate an instance of the cutting class on the heap
path_simulate *m_PathSimulate;
best_fit *m_BestFit;
UniGridApprox *m_Approx;
Approximate *m_App;
Deviation *m_Deviation;
MergeData *m_MergeData;
CuttingToolsSettings m_Settings;
QProcess *m_Process;
TopoDS_Shape m_Shape;
MeshCore::MeshKernel m_Mesh;
MeshCore::MeshKernel m_MeshOut;
MeshCore::MeshKernel m_MeshCad;
bool m_timer;
//1 means Standard, 2 means Feature Based, 3 means Spiral Based
unsigned int m_Mode;
enum support_selection
{
BestFit,
Springback,
Approx,
ToolpathCalculation
};
support_selection m_selection;
};
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -1,130 +0,0 @@
/***************************************************************************
* Copyright (c) 2007 Joachim Zettler <Joachim.Zettler@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef __PRECOMPILED_GUI__
#define __PRECOMPILED_GUI__
#include <FCConfig.h>
#undef QT_NO_CAST_FROM_ASCII
// Importing of App classes
#ifdef FC_OS_WIN32
# define MeshExport __declspec(dllimport)
# define PartExport __declspec(dllimport)
# define PartGuiExport __declspec(dllimport)
# define CamExport __declspec(dllimport)
# define CamGuiExport __declspec(dllexport)
#else // for Linux
# define MeshExport
# define PartExport
# define PartGuiExport
# define CamExport
# define CamGuiExport
#endif
#ifdef _MSC_VER
# pragma warning(disable : 4290)
#endif
#ifdef _PreComp_
// standard
#include <iostream>
//#include <stdio.h>
#include <assert.h>
//#include <io.h>
//#include <fcntl.h>
//#include <ctype.h>
// STL
#include <vector>
#include <list>
#include <map>
#include <string>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <bitset>
#include <Python.h>
#ifdef FC_OS_WIN32
# include <windows.h>
#endif
// Xerces
#include <xercesc/util/XercesDefs.hpp>
// OpenCasCade Base
#include <Standard_Failure.hxx>
// OpenCascade View
#include <BRepMesh_IncrementalMesh.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepBndLib.hxx>
#include <gp_Pnt.hxx>
#include <gp_Sphere.hxx>
#include <gp_Trsf.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <BRep_Tool.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Bnd_Box.hxx>
#include <BRepTools.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomLProp_SLProps.hxx>
#include <TopoDS_Face.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GCPnts_UniformDeflection.hxx>
#include <TopExp.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Poly_Polygon3D.hxx>
#include <BRepMesh.hxx>
// Qt Toolkit
#ifndef __QtAll__
# include <Gui/QtAll.h>
#endif
// Inventor
#ifndef __InventorAll__
# include <Gui/InventorAll.h>
#endif
#include <float.h>
#endif
#endif

View File

@@ -1,68 +0,0 @@
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <qobject.h>
#endif
#include "Workbench.h"
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>
using namespace CamGui;
/// @namespace CamGui @class Workbench
TYPESYSTEM_SOURCE(CamGui::Workbench, Gui::StdWorkbench)
Workbench::Workbench()
{
}
Workbench::~Workbench()
{
}
Gui::MenuItem* Workbench::setupMenuBar() const
{
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
Gui::MenuItem* item = root->findItem("&Windows");
Gui::MenuItem* cam = new Gui::MenuItem;
root->insertItem(item, cam);
cam->setCommand(QT_TR_NOOP("&Cam"));
*cam /*<< "Cam_ShapeInfo"*/ << "Cam_Cutting";
return root;
}
Gui::ToolBarItem* Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
return root;
}
Gui::ToolBarItem* Workbench::setupCommandBars() const
{
return 0;
}

View File

@@ -1,52 +0,0 @@
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <werner.wm.mayer@gmx.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef CAMGUI_WORKBENCH_H
#define CAMGUI_WORKBENCH_H
#include <Gui/Workbench.h>
namespace CamGui
{
/**
* @author Werner Mayer
*/
class CamGuiExport Workbench : public Gui::StdWorkbench
{
TYPESYSTEM_HEADER();
public:
Workbench();
virtual ~Workbench();
protected:
Gui::MenuItem* setupMenuBar() const;
Gui::ToolBarItem* setupToolBars() const;
Gui::ToolBarItem* setupCommandBars() const;
};
} // namespace CamGui
#endif // CAMGUI_WORKBENCH_H

View File

@@ -1,25 +0,0 @@
# FreeCAD init script of the Cam module
# (c) 2007 Juergen Riegel
#***************************************************************************
#* Copyright (c) 2007 Juergen Riegel <juergen.riegel@web.de> *
#* *
#* This file is Cam of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************/

View File

@@ -1,69 +0,0 @@
# Cam gui init module
# (c) 2003 Juergen Riegel
#
# Gathering all the information to start FreeCAD
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* Copyright (c) 2002 Juergen Riegel <juergen.riegel@web.de> *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD 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 Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#***************************************************************************/
class CamWorkbench ( Workbench ):
"Cam workbench object"
Icon = """
/* XPM */
static const char *Cam_Box[]={
"16 16 3 1",
". c None",
"# c #000000",
"a c #c6c642",
"................",
".......#######..",
"......#aaaaa##..",
".....#aaaaa###..",
"....#aaaaa##a#..",
"...#aaaaa##aa#..",
"..#aaaaa##aaa#..",
".########aaaa#..",
".#aaaaa#aaaaa#..",
".#aaaaa#aaaa##..",
".#aaaaa#aaa##...",
".#aaaaa#aa##....",
".#aaaaa#a##... .",
".#aaaaa###......",
".########.......",
"................"};
"""
MenuText = "Cam design"
ToolTip = "Cam"
def Initialize(self):
import CamGui
import Cam
def GetClassName(self):
return "CamGui::Workbench"
# No Workbench at the moment
Gui.addWorkbench(CamWorkbench())

View File

@@ -1,3 +0,0 @@
/** \defgroup CAM Cam
* \ingroup WORKBENCHES */

View File

@@ -1,286 +0,0 @@
# Doxyfile 1.5.6
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "FreeCAD CAM Module"
PROJECT_NUMBER = 0.1
OUTPUT_DIRECTORY = Doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = YES
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = App
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.f90 \
*.f \
*.vhd \
*.vhdl
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = ALL
TREEVIEW_WIDTH = 250
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
DOT_FONTNAME = FreeSans
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH = "C:/Program Files/Graphviz2.16/bin"
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = YES
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO