Files
EgtExchange/ImportBtlxProc.cpp
T
Dario Sassi cfa1c23917 EgtExchange :
- import BTLx prima implementazione (SaraP).
2021-01-08 20:03:08 +00:00

2732 lines
145 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2020-2020
//----------------------------------------------------------------------------
// File : ImportBtlx.cpp Data : 14.12.20 Versione : 2.2l1
// Contenuto : Implementazione della classe per l'importazione BTLx.
//
//
//
// Modifiche : 14.12.20 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "pugixml.hpp"
#include "ImportBtlx.h"
#include "DllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EgtKeyCodes.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
// -----------------------------------------------------------------------------------------------------------------------------
// -------------------------------- FUNZIONI CHE LEGGONO I PARAMETRI DEI PROCESSI -------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
int
ImportBtlx::ComputeP04( STRVECTOR values)
{
if ( values.size() > 6 || values.empty()) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: P04 is not valid")
return -2 ;
}
int result = 0 ;
for ( size_t i = 0 ; i < values.size() ; i ++) {
if ( values[i] == "no")
result += static_cast<int>( pow( 2, i)) ;
else if ( values[i] != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit value is not valid")
return -2 ;
}
}
return result ;
}
// -----------------------------------------------------------------------------------------------------------------------------
int
ImportBtlx::ComputeP04( pugi::xml_node MachiningLimits)
{
string FaceLimitedStart = "yes" ;
if (MachiningLimits.attribute( "FaceLimitedStart") != nullptr)
FaceLimitedStart = MachiningLimits.attribute( "FaceLimitedStart").value() ;
string FaceLimitedEnd = "yes" ;
if (MachiningLimits.attribute( "FaceLimitedEnd") != nullptr)
FaceLimitedEnd = MachiningLimits.attribute( "FaceLimitedEnd").value() ;
string FaceLimitedFront = "yes" ;
if (MachiningLimits.attribute( "FaceLimitedFront") != nullptr)
FaceLimitedFront = MachiningLimits.attribute( "FaceLimitedFront").value() ;
string FaceLimitedBack = "yes" ;
if (MachiningLimits.attribute( "FaceLimitedBack") != nullptr)
FaceLimitedBack = MachiningLimits.attribute( "FaceLimitedBack").value() ;
string FaceLimitedBottom = "yes" ;
if (MachiningLimits.attribute( "FaceLimitedBottom") != nullptr)
FaceLimitedBottom = MachiningLimits.attribute( "FaceLimitedBottom").value() ;
string FaceLimitedTop = "no" ;
if (MachiningLimits.attribute( "FaceLimitedTop") != nullptr)
FaceLimitedTop = MachiningLimits.attribute( "FaceLimitedTop").value() ;
int result = 0 ;
if ( FaceLimitedStart == "no")
result += 1 ;
else if ( FaceLimitedStart != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
if ( FaceLimitedEnd == "no")
result += 2 ;
else if ( FaceLimitedEnd != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
if ( FaceLimitedFront == "no")
result += 4 ;
else if ( FaceLimitedFront != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
if ( FaceLimitedBack == "no")
result += 8 ;
else if ( FaceLimitedBack != "yes") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
if ( FaceLimitedBottom == "no")
result += 16 ;
else if ( FaceLimitedBottom != "yes"){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
if ( FaceLimitedTop == "no")
result += 32 ;
else if ( FaceLimitedTop != "yes"){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit is not valid")
return -2 ;
}
return result ;
}
//-------------------------------------------------------------------------------------
bool
ImportBtlx::ReadJackRafterCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "JACK RAFTER CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 10 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr ){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JaclRafterCut orientation missing")
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "start")
nGroup = 2 ;
else if ( sOrientation == "end")
nGroup = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JackRafterCut Orientation is not valid") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 5) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: JackRafterCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), 0.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "Inclination").text().get()) ;
return true ;
}
//-------------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadLongitudinalCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "LONGITUDINAL CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 10 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if (process.attribute( "ToolPosition") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut Tool position missing") ;
return false ;
}
string sToolPosition = process.attribute("ToolPosition").value() ;
if ( sToolPosition == "center")
nGroup = 0 ;
else if ( sToolPosition == "right")
nGroup = 3 ;
else if ( sToolPosition == "left")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut Tool position not valid") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 8) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LongitudinalCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), 0.0, 50000.0) ;
string sStartLimited = process.child( "StartLimited") == nullptr ? "no" : process.child( "StartLimited").text().get() ; //P04
string sEndLimited = process.child( "EndLimited") == nullptr ? "no" : process.child( "EndLimited").text().get() ;
vdPar[2] = ComputeP04( { "no", sStartLimited, sEndLimited});
if ( vdPar[2] == -2)
return false ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[3] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[4] = Clamp( std::stod( process.child( "Depth").text().get()), 0.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[5] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 100000.0) ;
if ( process.child( "AngleStart") != nullptr && process.child( "AngleStart").text().get() != "") //P13
vdPar[6] = Clamp( std::stod( process.child( "AngleStart").text().get()), 0.1, 179.9) ;
if ( process.child( "AngleEnd") != nullptr && process.child( "AngleEnd").text().get() != "") //P14
vdPar[7] = Clamp( std::stod( process.child( "AngleEnd").text().get()), 0.1, 179.9) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDoubleCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "DOUBLE CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 11 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut orientation unknown") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 6) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: DoubleCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Angle1") != nullptr && process.child( "Angle1").text().get() != "") //P06
vdPar[2] = std::stod( process.child( "Angle1").text().get()) ;
if ( process.child( "Inclination1") != nullptr && process.child( "Inclination1").text().get() != "") //P07
vdPar[3] = std::stod( process.child( "Inclination1").text().get()) ;
if ( process.child( "Angle2") != nullptr && process.child( "Angle2").text().get() != "") //P08
vdPar[4] = std::stod( process.child( "Angle2").text().get()) ;
if ( process.child( "Inclination2") != nullptr && process.child( "Inclination2").text().get() != "") //P09
vdPar[5] = std::stod( process.child( "Inclination2").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadRidgeValleyCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "RIDGE VALLEY CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 12 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 0 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 11) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: RidgeValleyCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), 0.0, 50000.0) ;
string sStartLimited = process.child( "StartLimited") == nullptr ? "no" : process.child( "StartLimited").text().get() ; //P04
string sEndLimited = process.child( "EndLimited") == nullptr ? "no" : process.child( "EndLimited").text().get() ;
vdPar[2] = ComputeP04( { "no", sStartLimited, sEndLimited});
if ( vdPar[2] == -2)
return false ;
if ( process.child( "InclinationRefSide") != nullptr && process.child( "InclinationRefSide").text().get() != "") //P07
vdPar[3] = std::stod( process.child( "InclinationRefSide").text().get()) ;
if ( process.child( "InclinationOppSide") != nullptr && process.child( "InclinationOppSide").text().get() != "") //P09
vdPar[4] = std::stod( process.child( "InclinationOppSide").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[5] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[6] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 100000.0) ;
if ( process.child( "AngleRefStart") != nullptr && process.child( "AngleRefStart").text().get() != "") //P13
vdPar[7] = Clamp( std::stod( process.child( "AngleRefStart").text().get()), 0.1, 179.9) ;
if ( process.child( "AngleRefEnd") != nullptr && process.child( "AngleRefEnd").text().get() != "") //P14
vdPar[8] = Clamp( std::stod( process.child( "AngleRefEnd").text().get()), 0.1, 179.9) ;
if ( process.child( "AngleOppStart") != nullptr && process.child( "AngleOppStart").text().get() != "") //P15
vdPar[9] = Clamp( std::stod( process.child( "AngleOppStart").text().get()), 0.1, 179.9) ;
if ( process.child( "AngleOppEnd") != nullptr && process.child( "AngleOppEnd").text().get() != "") //P16
vdPar[10] = Clamp( std::stod( process.child( "AngleOppEnd").text().get()), 0.1, 179.9) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadSawCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "SAW CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 13 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if (process.attribute( "ToolPosition") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: SawCut toolposition missing") ;
return false ;
}
string sToolPosition = process.attribute("ToolPosition").value() ;
if ( sToolPosition == "center")
nGroup = 0 ;
else if ( sToolPosition == "right")
nGroup = 3 ;
else if ( sToolPosition == "left")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: SawCut tool position unknown") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 8) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: SawCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = Clamp( std::stod( process.child( "Angle").text().get()), 0.0, 180.0) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Bevel") != nullptr && process.child( "Bevel").text().get() != "") //P08
vdPar[5] = std::stod( process.child( "Bevel").text().get()) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[6] = std::stod( process.child( "AngleRefStart").text().get()) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[7] = std::stod( process.child( "Length").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadSlotParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "SLOT") ;
//Identifico il processo con sigle usate nel btl
nProc = 16 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot orientation missing")
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else{
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot orientation unknown")
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 14) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Slot number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
if ( process.child( "MachiningLimits") != nullptr ) { //P04
vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[3] == -2)
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[4] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[5] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "AngleRefPoint") != nullptr && process.child( "AngleRefPoint").text().get() != "") //P08
vdPar[6] = std::stod( process.child( "AngleRefPoint").text().get()) ;
if ( process.child( "AngleOppPoint") != nullptr && process.child( "AngleOppPoint").text().get() != "") //P09
vdPar[7] = std::stod( process.child( "AngleOppPoint").text().get()) ;
if ( process.child( "AddAngleOppPoint") != nullptr && process.child( "AddAngleOppPoint").text().get() != "") //P10
vdPar[8] = Clamp( std::stod( process.child( "AddAngleOppPoint").text().get()), -179.9, 179.9) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[9] = std::stod( process.child( "Depth").text().get()) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[10] = std::stod( process.child( "Length").text().get()) ;
if ( process.child( "Thickness") != nullptr && process.child( "Thickness").text().get() != "") //P13
vdPar[11] = std::stod( process.child( "Thickness").text().get()) ;
//P14 ??????????????????
//P15 ???????????????????
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadBirdsMouthParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "BIRDSMOUTH") ;
//Identifico il processo con sigle usate nel btl
nProc = 20 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 13) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BirdsMouth number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
//P04 vdPar[??] ???
if ( process.child( "RafterNailHole") != nullptr && process.child( "RafterNailHole").text().get() != ""){ //P05
string sRafterNailHole = process.child( "RafterNailHole").text().get() ;
if ( sRafterNailHole == "yes")
vdPar[2] = 1 ;
else if ( sRafterNailHole == "no")
vdPar[2] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : RafterNailHole invalid paramater") ;
return false ;
}
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination1") != nullptr && process.child( "Inclination1").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "Inclination1").text().get()) ;
if ( process.child( "Inclination2") != nullptr && process.child( "Inclination2").text().get() != "") //P08
vdPar[5] = std::stod( process.child( "Inclination2").text().get()) ;
if ( process.child( "LeadAngle") != nullptr && process.child( "LeadAngle").text().get() != "") //P09
vdPar[6] = Clamp( std::stod( process.child( "LeadAngle").text().get()), 0.0, 179.9) ; //???? 0.1
if ( process.child( "LeadInclination") != nullptr && process.child( "LeadInclination").text().get() != "") //P10
vdPar[7] = Clamp( std::stod( process.child( "LeadInclination").text().get()), 0.0, 179.9) ; //????? 0.1
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[8] = std::stod( process.child( "StartDepth").text().get()) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P12
vdPar[9] = std::stod( process.child( "Depth").text().get()) ;
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P13
vdPar[10] = std::stod( process.child( "Width").text().get()) ;
if ( process.child( "HeightCounterPart") != nullptr && process.child( "HeightCounterPart").text().get() != "") //P14
vdPar[11] = std::stod( process.child( "HeightCounterPart").text().get()) ;
if ( process.child( "WidthCounterPart") != nullptr && process.child( "WidthCounterPart").text().get() != "") //P15
vdPar[12] = std::stod( process.child( "WidthCounterPart").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadHipValleyRafterNotchParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "HIP VALLEY RAFTER NOTCH") ;
//Identifico il processo con sigle usate nel btl
nProc = 25 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 9) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = std::stod( process.child( "StartX").text().get()) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = std::stod( process.child( "StartY").text().get()) ;
if ( process.child( "RafterNailHole") != nullptr && process.child( "RafterNailHole").text().get() != ""){ //P05
string sRafterNailHole = process.child( "RafterNailHole").text().get() ;
if ( sRafterNailHole == "yes")
vdPar[2] = 1 ;
else if ( sRafterNailHole == "no" || sRafterNailHole == "")
vdPar[2] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : RafterNailHole invalid paramater") ;
return false ;
}
}
if ( process.child( "AngleRefEdge") != nullptr && process.child( "AngleRefEdge").text().get() != "") //P06
vdPar[3] = std::stod( process.child( "AngleRefEdge").text().get()) ;
if ( process.child( "AngleOppEdge") != nullptr && process.child( "AngleOppEdge").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "AngleOppEdge").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P08
vdPar[5] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[6] = std::stod( process.child( "StartDepth").text().get()) ;
if ( process.child( "WidthCounterPartRefEdge") != nullptr && process.child( "WidthCounterPartRefEdge").text().get() != "") //P14
vdPar[7] = std::stod( process.child( "WidthCounterPartRefEdge").text().get()) ;
if ( process.child( "WidthCounterPartOppEdge") != nullptr && process.child( "WidthCounterPartOppEdge").text().get() != "") //P15
vdPar[8] = std::stod( process.child( "WidthCounterPartOppEdge").text().get()) ;
if ( abs( vdPar[7]) < EPS_SMALL && abs( vdPar[8]) < EPS_SMALL) {
LOG_ERROR( GetEExLogger(), " Warning reading Part Processing : RafterNailHole P14 = P15 = 0")
vdPar[7] = 0.001 ;
vdPar[8] = 0.001 ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadLapParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "LAP") ;
//Identifico il processo con sigle usate nel btl
nProc = 30 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 13) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: HipValleyRafterNotch number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
//vdPar[2] = ???????????????????????????????????????
if ( process.child( "MachiningLimits") != nullptr ) { //P04
vdPar[3] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[3] == -2)
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[4] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[5] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Slope") != nullptr && process.child( "Slope").text().get() != "") //P08
vdPar[6] = std::stod( process.child( "Slope").text().get()) ;
if ( process.child( "LeadAngle") != nullptr && process.child( "LeadAngle").text().get() != "") //P09
vdPar[7] = Clamp( std::stod( process.child( "LeadAngle").text().get()), 0.1, 179.9) ;
if ( process.child( "LeadInclination") != nullptr && process.child( "LeadInclination").text().get() != "") //P10
vdPar[8] = Clamp( std::stod( process.child( "LeadInclination").text().get()), 0.1, 179.9) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[9] = Clamp( std::stod( process.child( "Depth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[10] = std::stod( process.child( "Length").text().get()) ;
//vdPar[11] = ??????????????????????????????????????????
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P14
vdPar[12] = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadLogHouseHalfLapParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "LOH HOUSE HALF LAP") ;
//Identifico il processo con sigle usate nel btl
nProc = 33 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 5) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseHalfLap number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[1] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "DepthRefSide") != nullptr && process.child( "DepthRefSide").text().get() != "") //P11
vdPar[2] = Clamp( std::stod( process.child( "DepthRefSide").text().get()), 0.0, 50000.0) ;
if ( process.child( "DepthOppSide") != nullptr && process.child( "DepthOppSide").text().get() != "") //P12
vdPar[3] = Clamp( std::stod( process.child( "DepthOppSide").text().get()), 0.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[4] = std::stod( process.child( "Length").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadFrenchRidgeLapParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "FRENCH RIDGE LAP") ;
//Identifico il processo con sigle usate nel btl
nProc = 33 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 4) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "RefPosition") != nullptr){ //P02
string sRefPosition = process.child( "RefPosition").text().get() ;
if ( sRefPosition == "refedge" || sRefPosition == "")
vdPar[1] = 0 ;
else if ( sRefPosition == "oppedge")
vdPar[1] = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap RefPosition unknown") ;
return false ;
}
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[2] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "DrillholeDiam") != nullptr && process.child( "DrillholeDiam").text().get() != "") //P13
vdPar[3] = std::stod( process.child( "DrillholeDiam").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadChamferParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "CHAMFER") ;
//Identifico il processo con sigle usate nel btl
nProc = 36 ;
//Chamfer non ha un reference plane
nSide = 3 ;
nGroup = 4 ; //fingo che orientation sia start
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 5) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Chamfer number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
string sCamferEdge12 = process.child( "ChamferEdge12") == nullptr ? "yes" : process.child( "ChamferEdge12").text().get() ; //P04
string sCamferEdge23 = process.child( "ChamferEdge23") == nullptr ? "yes" : process.child( "ChamferEdge23").text().get() ;
string sCamferEdge34 = process.child( "ChamferEdge34") == nullptr ? "yes" : process.child( "ChamferEdge34").text().get() ;
string sCamferEdge41 = process.child( "ChamferEdge34") == nullptr ? "yes" : process.child( "ChamferEdge41").text().get() ;
STRVECTOR values = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ;
vdPar[1] = 0.0 ;
for ( size_t i = 0 ; i < values.size() ; i++){
if ( values[i] == "yes")
vdPar[1] += static_cast<int>(pow( 2, i)) ;
else if ( values[i] != "no"){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ChamferEdge value is not valid")
return false ;
}
}
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[2] = std::stod( process.child( "Depth").text().get()) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[3] = std::stod( process.child( "Length").text().get()) ;
string sChamferExit = process.child( "ChamferExit").text().get() ;
if ( sChamferExit == "orthogonal")
vdPar[4] = 0 ;
else if ( sChamferExit == "angular")
vdPar[4] = 1 ;
else if ( sChamferExit == "round")
vdPar[4] = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Chamfer ExitType unknown") ;
return false ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadLogHouseJointParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "LOG HOUSE JOINT") ;
//Identifico il processo con sigle usate nel btl
nProc = 36 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 15) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "DepthSideLaps") != nullptr && process.child( "DepthSideLaps").text().get() != "") //P03
vdPar[1] = std::stod( process.child( "DepthSideLaps").text().get()) ;
string sLapPosition = process.child( "LapPosition").text().get() ; //P04
if ( sLapPosition == "symmetric")
vdPar[2] = 0 ;
else if ( sLapPosition == "forward")
vdPar[2] = 1 ;
else if ( sLapPosition == "backward")
vdPar[2] = 2;
else{
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint LapPosition unknown") ;
return false ;
}
string sDrillHole = process.child( "DrillHole").text().get() ; //P05
if ( sDrillHole == "no" || sDrillHole == "")
vdPar[3] = 0 ;
else if ( sDrillHole == "yes")
vdPar[3] = 1 ;
else{
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseJoint DrillHole unknown") ;
return false ;
}
if ( process.child( "DepthRefSide") != nullptr && process.child( "DepthRefSide").text().get() != "") //P08
vdPar[4] = std::stod( process.child( "DepthRefSide").text().get()) ;
if ( process.child( "LengthRefSide") != nullptr && process.child( "LengthRefSide").text().get() != "") //P09
vdPar[5] = std::stod( process.child( "LengthRefSide").text().get()) ;
if ( process.child( "DepthOppSide") != nullptr && process.child( "DepthOppSide").text().get() != "") //P10
vdPar[6] =std::stod( process.child( "DepthOppSide").text().get()) ;
if ( process.child( "LengthOppSide") != nullptr && process.child( "LengthOppSide").text().get() != "") //P11
vdPar[7] = std::stod( process.child( "LengthOppSide").text().get()) ;
if ( process.child( "DepthRefEdge") != nullptr && process.child( "DepthRefEdge").text().get() != "") //P12
vdPar[8] = std::stod( process.child( "DepthRefEdge").text().get()) ;
if ( process.child( "LengthRefEdge") != nullptr && process.child( "LengthRefEdge").text().get() != "") //P13
vdPar[9] = std::stod( process.child( "LengthRefEdge").text().get()) ;
if ( process.child( "DepthOppEdge") != nullptr && process.child( "DepthOppEdge").text().get() != "") //P14
vdPar[10] = std::stod( process.child( "DepthOppEdge").text().get()) ;
if ( process.child( "LengthOppEdge") != nullptr && process.child( "LengthOppEdge").text().get() != "") //P15
vdPar[11] = std::stod( process.child( "LengthOppEdge").text().get()) ;
if ( process.child( "ArcDepth") != nullptr && process.child( "ArcDepth").text().get() != "") //P16
vdPar[12] = Clamp( std::stod( process.child( "ArcDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "ArcRadius") != nullptr && process.child( "ArcRadius").text().get() != "") //P17
vdPar[13] = Clamp( std::stod( process.child( "ArcRadius").text().get()), 0.0, 50000.0) ;
if ( process.child( "ArcCenter") != nullptr && process.child( "ArcCenter").text().get() != "") //P17
vdPar[14] = Clamp( std::stod( process.child( "ArcCenter").text().get()), 0.0, 50000.0) ;
string sArcRefEdgeStart = process.child( "ArcRefEdgeStart") == nullptr ? "no" : process.child( "ArcRefEdgeStart").text().get() ;
string sArcOppEdgeStart = process.child( "ArcOppEdgeStart") == nullptr ? "no" : process.child( "ArcOppEdgeStart").text().get() ;
string sArcRefEdgeEnd = process.child( "ArcRefEdgeEnd") == nullptr ? "no" : process.child( "ArcRefEdgeEnd").text().get() ;
string sArcOppEdgeEnd = process.child( "ArcOppEdgeEnd") == nullptr ? "no" : process.child( "ArcOppEdgeEnd").text().get() ;
vdPar[15] = ComputeP04( { sArcOppEdgeEnd, sArcOppEdgeStart, sArcRefEdgeEnd, sArcRefEdgeStart}) ;
if ( vdPar[15] == -2)
return false ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadLogHouseFrontParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "LOG HOUSE FRONT") ;
//Identifico il processo con sigle usate nel btl
nProc = 38 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 7) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
string sRefSideOnly = process.child( "RefSideOnly").text().get() ; //P04
if ( sRefSideOnly == "yes")
vdPar[1] = 0 ;
else if ( sRefSideOnly == "no" || sRefSideOnly == "")
vdPar[1] = 1 ;
else{
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: LogHouseFront RefSideOnly unknown") ;
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[2] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[3] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
if ( process.child( "DepthOppEdge") != nullptr && process.child( "DepthOppEdge").text().get() != "") //P12
vdPar[4] = Clamp( std::stod( process.child( "DepthOppEdge").text().get()), 0.0, 50000.0) ;
if ( process.child( "DepthRefEdge") != nullptr && process.child( "DepthRefEdge").text().get() != "") //P13
vdPar[5] = Clamp( std::stod( process.child( "DepthRefEdge").text().get()), 0.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P15
vdPar[6] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadPocketParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "POCKET") ;
//Identifico il processo con sigle usate nel btl
nProc = 39 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 9) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Pocket number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "MachiningLimits") != nullptr ) { //P04
vdPar[2] = ComputeP04( process.child( "MachiningLimits")) ;
if ( vdPar[2] == -2)
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Slope") != nullptr && process.child( "Slope").text().get() != "") //P08
vdPar[5] = std::stod( process.child( "Slope").text().get());
if ( process.child( "InternalAngle") != nullptr && process.child( "InternalAngle").text().get() != "") //P10
vdPar[6] = std::stod( process.child( "InternalAngle").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[7] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[8] = std::stod( process.child( "Length").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDrillingParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "DRILLING") ;
//Identifico il processo con sigle usate nel btl
nProc = 40 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 7) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Drilling number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
// vdPar[2] = ??????????????? //P03
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = Clamp( std::stod( process.child( "Angle").text().get()), 0.0, 360.0) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[4] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[5] = Clamp( std::stod( process.child( "Depth").text().get()), 0.0, 50000.0) ;
if ( process.child( "Diameter") != nullptr && process.child( "Diameter").text().get() != "") //P12
vdPar[6] = Clamp( std::stod( process.child( "Diameter").text().get()), 0.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadTenonParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "TENON") ;
//Identifico il processo con sigle usate nel btl
nProc = 50 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
if ( process.child( "Orientation") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FrenchRidgeLap orientation missing") ;
return false ;
}
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 12) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
string sShape = process.child( "Shape").text().get() ; //P04
if ( sShape == "automatic" || sShape == "")
vdPar[2] = 0 ;
else if ( sShape == "square")
vdPar[2] = 1;
else if ( sShape == "round")
vdPar[2] = 2;
else if ( sShape == "rounded")
vdPar[2] = 3;
else if ( sShape == "radius")
vdPar[2] = 4;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
}
string sChamfer = process.child( "Chamfer").text().get() ; //P05
if ( sChamfer == "no")
vdPar[3] = 0 ;
else if ( sShape == "yes")
vdPar[3] = 1;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Chamfer is unknown") ;
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[4] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[5] = std::stod( process.child( "Inclination").text().get()) ;
if ( process.child( "Rotation") != nullptr && process.child( "Rotation").text().get() != "") //P08
vdPar[6] = std::stod( process.child( "Rotation").text().get()) ;
if ( process.child( "ShapeRadius") != nullptr && process.child( "ShapeRadius").text().get() != "") //P10
vdPar[7] = Clamp( std::stod( process.child( "ShapeRadius").text().get()), 0.0, 1000.0) ;
if ( process.child( "Height") != nullptr && process.child( "Height").text().get() != "") //P11
vdPar[8] = Clamp( std::stod( process.child( "Height").text().get()), 0.0, 1000.0) ;
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P12
vdPar[9] = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 1000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P14
vdPar[10] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P15
vdPar[11] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
else
vdPar[11] = 80.0 ; //valore di default
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadMortiseParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "MORTISE") ;
//Identifico il processo con sigle usate nel btl
nProc = 50 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 3 ; // ?????????????????????????????????????
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 14) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Mortise number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
string sShape = process.child( "Shape").text().get() ; //P04
if ( sShape == "automatic" || sShape == "")
vdPar[3] = 0 ;
else if ( sShape == "square")
vdPar[3] = 1;
else if ( sShape == "round")
vdPar[3] = 2;
else if ( sShape == "rounded")
vdPar[3] = 3;
else if ( sShape == "radius")
vdPar[3] = 4;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[4] = Clamp( std::stod( process.child( "Angle").text().get()), -180.0, 180.0) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P08
vdPar[6] = Clamp( std::stod( process.child( "Inclination").text().get()), 0.1, 179.9) ;
if ( process.child( "ShapeRadius") != nullptr && process.child( "ShapeRadius").text().get() != "") //P10
vdPar[7] = Clamp( std::stod( process.child( "ShapeRadius").text().get()), 0.0, 1000.0) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[8] = Clamp( std::stod( process.child( "Depth").text().get()), 0.0, 1000.0) ;
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P12
vdPar[9] = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 1000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[10] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
//P13 = vdPar[10] non ha lo stesso significato del BTL, riempio questa casella al posto di un altra tra 5 11 e 12 a caso
if ( process.child( "Slope") != nullptr && process.child( "Slope").text().get() != "") //P16
vdPar[13] = Clamp( std::stod( process.child( "Slope").text().get()), 0.1, 179.9) ;
//vdPar[5] vdPar[11] vdPar[12] ( P7, P14 e P15) non servono, lascio i valori di default
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDovetailTenonParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "DOVETAIL TENON") ;
//Identifico il processo con sigle usate nel btl
nProc = 55 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "start")
nGroup = 2 ;
else if ( sOrientation == "end")
nGroup = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Orientation unknown") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 12) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Mortise number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "")
vdPar[10] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
string sShape = process.child( "Shape").text().get() ; //P04
if ( sShape == "automatic" || sShape == "")
vdPar[2] = 0 ;
else if ( sShape == "square")
vdPar[2] = 1;
else if ( sShape == "round")
vdPar[2] = 2;
else if ( sShape == "rounded")
vdPar[2] = 3;
else if ( sShape == "radius")
vdPar[2] = 4;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon Shape is unknown") ;
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = Clamp( std::stod( process.child( "Angle").text().get()), -180.0, 180.0) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P08
vdPar[4] = Clamp( std::stod( process.child( "Inclination").text().get()), 0.1, 179.9) ;
if ( process.child( "Rotation") != nullptr && process.child( "Rotation").text().get() != "") //P08
vdPar[5] = Clamp( std::stod( process.child( "Rotation").text().get()), 0.1, 179.9) ;
if ( process.child( "ShapeRadius") != nullptr && process.child( "ShapeRadius").text().get() != "") //P10
vdPar[9] = Clamp( std::stod( process.child( "ShapeRadius").text().get()), 0.0, 1000.0) ;
if ( process.child( "Height") != nullptr && process.child( "Height").text().get() != "") //P11
vdPar[8] = Clamp( std::stod( process.child( "Height").text().get()), 0.0, 1000.0) ;
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P12
vdPar[6] = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 1000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[11] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
//P13 = vdPar[10] non ha lo stesso significato del BTL, riempio questa casella al posto di un altra tra 5 11 e 12 a caso
if ( process.child( "ConeAngle") != nullptr && process.child( "ConeAngle").text().get() != "") //P16
vdPar[7] = Clamp( std::stod( process.child( "ConeAngle").text().get()), 0.1, 179.9) ;
//vdPar[5] vdPar[11] vdPar[12] ( P7, P14 e P15) non servono, lascio i valori di default
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDovetailMortiseParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "DOVETAIL MORTISE") ;
//Identifico il processo con sigle usate nel btl
nProc = 55 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ; //manca orientation
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 14) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Mortise number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "")
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 50000.0) ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[5] = Clamp( std::stod( process.child( "Angle").text().get()), -180.0, 180.0) ;
if ( process.child( "Width") != nullptr && process.child( "Width").text().get() != "") //P12
vdPar[7] = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 1000.0) ;
if ( process.child( "ConeAngle") != nullptr && process.child( "ConeAngle").text().get() != "") //P16
vdPar[8] = Clamp( std::stod( process.child( "ConeAngle").text().get()), 0.1, 179.9) ;
if ( process.child( "Height") != nullptr && process.child( "Height").text().get() != "") //P11
vdPar[9] = Clamp( std::stod( process.child( "Height").text().get()), 0.0, 1000.0) ;
if ( process.child( "ShapeRadius") != nullptr && process.child( "ShapeRadius").text().get() != "") //P10
vdPar[10] = Clamp( std::stod( process.child( "ShapeRadius").text().get()), 0.0, 1000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[11] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
//Inclination??
string sLimitedBottom = process.child( "LengthLimitedBottom").text().get() ;
if ( sLimitedBottom == "yes")
vdPar[3] = 0 ;
else if ( sLimitedBottom == "no")
vdPar[3] = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Mortise LengthLimitedBottom unkown")
return false ;
}
string sLimitationTop = process.child( "LimitationTop").text().get() ;
if ( sLimitationTop == "unlimited")
vdPar[4] = 0 ;
else if ( sLimitationTop == "pocket")
vdPar[4] = 1 ;
else if ( sLimitationTop != "limited") {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail Mortise LimitationTop unkown")
return false ;
}
//vdPar[5] vdPar[11] vdPar[12] ( P7, P14 e P15) non servono, lascio i valori di default
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadMarkingParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "MARKING") ;
//Identifico il processo con sigle usate nel btl
nProc = 60 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 8) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
vdPar[2] = 0 ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[3] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "InteriorAngle") != nullptr && process.child( "InteriorAngle").text().get() != "") //P13
vdPar[4] = Clamp( std::stod( process.child( "InteriorAngle").text().get()), 0.0, 50000.0) ;
//Se non ci fosse???
double dMWidth = Clamp( std::stod( process.child( "Width").text().get()), 0.0, 50000.0) ;
double dMLength = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
if ( abs( vdPar[3]) < EPS_ANG_SMALL || abs( vdPar[3] -180) < EPS_ANG_SMALL) {
LOG_ERROR ( GetEExLogger() , "Horizontal line")
return false ;
}
vdPar[5] = dMWidth * sin( vdPar[4]*DEGTORAD) / sin( vdPar[3]*DEGTORAD) ;
vdPar[6] = dMLength * sin( vdPar[3]*DEGTORAD) ;
nSPar = 1 ;
sPar = "" ; //P15
string sStyle = process.child( "Style").text().get() ;
if ( sStyle == "double"){
vdPar[4] = 0 ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadTextParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "TEXT") ;
//Identifico il processo con sigle usate nel btl
nProc = 61 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 8) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[2] = Clamp( std::stod( process.child( "Angle").text().get()), -180.0, 180.0) ;
if ( process.child( "TextHeight") != nullptr && process.child( "TextHeight").text().get() != "") //P13
vdPar[7] = Clamp( std::stod( process.child( "TextHeight").text().get()), 0.0, 50000.0) ;
nSPar = 1 ;
sPar = process.child( "Text").text().get() ; //P15
string sVAlignment = process.child( "AlignmentVertical").text().get() ; //P09
if ( sVAlignment == "bottom" || sVAlignment == "")
vdPar[3] = 0 ;
else if ( sVAlignment == "middle")
vdPar[3] = 1;
else if ( sVAlignment == "top")
vdPar[3] = 2;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text Vertical Alignment is unknown") ;
return false ;
}
string sHAlignment = process.child( "AlignmentHorizontal").text().get() ; //P10
if ( sHAlignment == "left" || sHAlignment == "")
vdPar[4] = 0 ;
else if ( sHAlignment == "middle")
vdPar[4] = 1;
else if ( sHAlignment == "right")
vdPar[4] = 2;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text Horizontal Alignment is unknown") ;
return false ;
}
string sMAlignment = process.child( "AlignmentMultiline").text().get() ; //P11
if ( sMAlignment == "left" || sMAlignment == "")
vdPar[5] = 0 ;
else if ( sMAlignment == "middle")
vdPar[5] = 1;
else if ( sMAlignment == "right")
vdPar[5] = 2;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text Multiline Alignment is unknown") ;
return false ;
}
string sStackedMarking = process.child( "StackedMarking").text().get() ; //P12
if ( sStackedMarking == "no")
vdPar[6] = 0 ;
else if ( sStackedMarking == "yes")
vdPar[6] = 1;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text StackedMarking is unknown") ;
return false ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadSimpleScarfParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "SIMPLE SCARF") ;
//Identifico il processo con sigle usate nel btl
nProc = 70 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 6) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: SimpleScarf number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "DepthRefSide") != nullptr && process.child( "DepthRefSide").text().get() != "") //P11
vdPar[1] = std::stod( process.child( "DepthRefSide").text().get()) ;
if ( process.child( "DepthOppSide") != nullptr && process.child( "DepthOppSide").text().get() != "") //P12
vdPar[2] = std::stod( process.child( "DepthOppSide").text().get()) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[3] = std::stod( process.child( "Length").text().get()) ;
if ( process.child( "DrillHoleDiam1") != nullptr && process.child( "DrillHoleDiam1").text().get() != "") //P14
vdPar[4] = std::stod( process.child( "DrillHoleDiam1").text().get()) ;
if ( process.child( "DrillHoleDiam2") != nullptr && process.child( "DrillHoleDiam2").text().get() != "") //P15
vdPar[5] = std::stod( process.child( "DrillHoleDiam2").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadScarfJointParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "SCARF JOINT") ;
//Identifico il processo con sigle usate nel btl
nProc = 71 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tenon orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 9) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ScarfJoint number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "Inclination") != nullptr && process.child( "Inclination").text().get() != "") //P07
vdPar[1] = std::stod( process.child( "Inclination").text().get()) ;
string sScarfShape = process.child( "ScarfShape").text().get() ; //P09
if ( sScarfShape == "classic")
vdPar[2] = 0 ;
else if ( sScarfShape == "refside" || sScarfShape == "") //se non esiste metto il valore di default
vdPar[2] = 1 ;
else if ( sScarfShape == "baseside")
vdPar[2] = -1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ScarfJoint ScarfShape is unknown") ;
return false ;
}
if ( process.child( "LapLength") != nullptr && process.child( "LapLength").text().get() != "") //P10
vdPar[3] = std::stod( process.child( "LapLength").text().get()) ;
if ( process.child( "LapDepth") != nullptr && process.child( "LapDepth").text().get() != "") //P11
vdPar[4] = std::stod( process.child( "LapDepth").text().get()) ;
if ( process.child( "DepthOppSide") != nullptr && process.child( "DepthOppSide").text().get() != "") //P12
vdPar[5] = std::stod( process.child( "DepthOppSide").text().get()) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[6] = std::stod( process.child( "Length").text().get()) ;
if ( process.child( "DrillHoleDiam1") != nullptr && process.child( "DrillHoleDiam1").text().get() != "") //P14
vdPar[7] = std::stod( process.child( "DrillHoleDiam1").text().get()) ;
if ( process.child( "DrillHoleDiam2") != nullptr && process.child( "DrillHoleDiam2").text().get() != "") //P15
vdPar[8] = std::stod( process.child( "DrillHoleDiam2").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadStepJointParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "STEP JOINT") ;
//Identifico il processo con sigle usate nel btl
nProc = 80 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 1 ;
else if ( sOrientation == "start")
nGroup = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Step Joint orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 7) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: StepJoint number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
string sStepShape = process.child( "StepShape").text().get() ; //P09
// if ( sStepShape == "double" || sStepShape == "")
// vdPar[1] = 0 ;
// else if ( sStepShape == "step")
// vdPar[1] = 1 ;
// else if ( sStepShape == "heel")
// vdPar[1] = -1 ;
// else {
// LOG_ERROR( GetEExLogger(), " Error reading Part Processing: StepJointNotch StepShape is unknown") ;
// return false ;
// }
if ( process.child( "StrutInclination") != nullptr && process.child( "StrutInclination").text().get() != "") //P07
vdPar[2] = std::stod( process.child( "StrutInclination").text().get()) ;
if ( process.child( "StepDepth") != nullptr && process.child( "StepDepth").text().get() != "") //P11
vdPar[3] = std::stod( process.child( "StepDepth").text().get()) ;
if ( process.child( "HeelDepth") != nullptr && process.child( "HeelDepth").text().get() != "") //P12
vdPar[4] = std::stod( process.child( "HeelDepth").text().get()) ;
if ( process.child( "TenonHeight") != nullptr && process.child( "TenonHeight").text().get() != "") //P14
vdPar[5] = std::stod( process.child( "TenonHeight").text().get()) ;
if ( process.child( "TenonWidth") != nullptr && process.child( "TenonWidth").text().get() != "") //P15
vdPar[6] = std::stod( process.child( "TenonWidth").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadStepJointNotchParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "STEP JOINT NOTCH") ;
//Identifico il processo con sigle usate nel btl
nProc = 80 ;
if ( process.attribute("ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing reference plane") ;
return false ;
}
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Step Joint Notch orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 10) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: StepJoint number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
string sStepShape = process.child( "StepShape").text().get() ; //P09
// if ( sStepShape == "double" || sStepShape == "")
// vdPar[2] = 0 ;
// else if ( sStepShape == "step")
// vdPar[2] = 1 ;
// else if ( sStepShape == "heel")
// vdPar[2] = -1 ;
// else {
// LOG_ERROR( GetEExLogger(), " Error reading Part Processing: StepJointNotch StepShape is unknown") ;
// return false ;
// }
if ( process.child( "StrutInclination") != nullptr && process.child( "StrutInclination").text().get() != "") //P07
vdPar[3] = std::stod( process.child( "StrutInclination").text().get()) ;
if ( process.child( "NotchWidth") != nullptr && process.child( "NotchWidth").text().get() != "") //P10
vdPar[4] = std::stod( process.child( "NotchWidth").text().get()) ;
if ( process.child( "StepDepth") != nullptr && process.child( "StepDepth").text().get() != "") //P11
vdPar[5] = std::stod( process.child( "StepDepth").text().get()) ;
if ( process.child( "HeelDepth") != nullptr && process.child( "HeelDepth").text().get() != "") //P12
vdPar[6] = std::stod( process.child( "HeelDepth").text().get()) ;
if ( process.child( "StrutHeight") != nullptr && process.child( "StrutHeight").text().get() != "") //P13
vdPar[7] = std::stod( process.child( "StrutHeight").text().get()) ;
if ( process.child( "MortiseHeight") != nullptr && process.child( "MortiseHeight").text().get() != "") //P14
vdPar[8] = std::stod( process.child( "MortiseHeight").text().get()) ;
if ( process.child( "MortiseWidth") != nullptr && process.child( "MortiseWidth").text().get() != "") //P15
vdPar[9] =std::stod( process.child( "MortiseWidth").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadPlaningParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "PLANING") ;
//Identifico il processo con sigle usate nel btl
nProc = 90 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 4) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Text number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
//testo vuoto???
string PlaneSide1 = process.child( "PlaneSide1") == nullptr ? "yes" : process.child( "PlaneSide1").text().get() ; //P04
string PlaneSide2 = process.child( "PlaneSide2") == nullptr ? "yes" : process.child( "PlaneSide2").text().get() ;
string PlaneSide3 = process.child( "PlaneSide3") == nullptr ? "yes" : process.child( "PlaneSide3").text().get() ;
string PlaneSide4 = process.child( "PlaneSide4") == nullptr ? "yes" : process.child( "PlaneSide4").text().get() ;
vdPar[1] = ComputeP04( { PlaneSide1, PlaneSide2, PlaneSide3, PlaneSide4}) ;
if ( vdPar[1] == -2)
return false ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P11
vdPar[2] = Clamp( std::stod( process.child( "Depth").text().get()), 0.0, 50.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[3] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 100000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadProfileFrontParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, string& sPar)
{
LOG_ERROR( GetEExLogger(), "PROFILE FRONT") ;
// Identifico il processo con sigle usate nel btl
nProc = 100 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileFront orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 7) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileFront number of parameters is wrong") ;
return false ;
}
// Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "Depth") != nullptr && process.child( "Depth").text().get() != "") //P03
vdPar[1] = Clamp( std::stod( process.child( "Depth").text().get()), 0.0, 1000.0) ;
if ( process.child( "Rotation1") != nullptr && process.child( "Rotation1").text().get() != "") //P06
vdPar[2] = std::stod( process.child( "Rotation1").text().get()) ;
if ( process.child( "Rotation2") != nullptr && process.child( "Rotation2").text().get() != "") //P07
vdPar[3] = std::stod( process.child( "Rotation2").text().get()) ;
if ( process.child( "StartRotation") != nullptr && process.child( "StartRotation").text().get() != "") //P08
vdPar[4] = Clamp( std::stod( process.child( "StartRotation").text().get()), -90.0, 90.0) ;
if ( process.child( "Radius1") != nullptr && process.child( "Radius1").text().get() != "") //P11
vdPar[5] = Clamp( std::stod( process.child( "Radius1").text().get()), 0.0, 1000.0) ;
if ( process.child( "Radius2") != nullptr && process.child( "Radius2").text().get() != "") //P12
vdPar[6] = Clamp( std::stod( process.child( "Radius2").text().get()), 0.0, 1000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadProfileCamberedParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "PROFILE CAMBERED") ;
//Identifico il processo con sigle usate nel btl
nProc = 103 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 7) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P10
vdPar[1] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 100000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P11
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), 0.0, 1000.0) ;
if ( process.child( "MaxDepth") != nullptr && process.child( "MaxDepth").text().get() != "") //P12
vdPar[3] = Clamp( std::stod( process.child( "MaxDepth").text().get()), 0.0, 1000.0) ;
if ( process.child( "MinDepth") != nullptr && process.child( "MinDepth").text().get() != "") //P13
vdPar[4] = Clamp( std::stod( process.child( "MinDepth").text().get()), 0.0, 1000.0) ;
if ( process.child( "EndDepth") != nullptr && process.child( "EndDepth").text().get() != "") //P14
vdPar[5] = Clamp( std::stod( process.child( "EndDepth").text().get()), 0.0, 1000.0) ;
string sPremill = process.child( "Premill").text().get() ; //P15
if ( sPremill == "round")
vdPar[6] = 0 ;
else if ( sPremill == "angular" || sPremill == "")
vdPar[6] = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileCambered Premill unknown") ;
return false ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadRoundArchParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "ROUND ARCH") ;
//Identifico il processo con sigle usate nel btl
nProc = 104 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 3) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: RoundARch number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "Camber") != nullptr && process.child( "Camber").text().get() != "") //P11
vdPar[1] = Clamp( std::stod( process.child( "Camber").text().get()), 0.0, 1000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P12
vdPar[2] = std::stod( process.child( "Length").text().get()) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadProfileHeadParams( pugi::xml_node process,
int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, string& sPar)
{
LOG_ERROR( GetEExLogger(), "PROFILE HEAD") ;
// Identifico il processo con sigle usate nel btl
nProc = 106 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
string sOrientation = process.child( "Orientation").text().get() ;
if ( sOrientation == "end")
nGroup = 3 ;
else if ( sOrientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileHead orientation unknwon") ;
return false ;
}
// Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 16) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ProfileHead number of parameters is wrong") ;
return false ;
}
// Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") // P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
// Tipologia archi P04
string sArc1Shape = process.child( "Arc1").attribute("ArcShape").value() ;
string sArc2Shape = process.child( "Arc2").attribute("ArcShape").value() ;
vdPar[1] = 0 ;
if ( sArc1Shape != "concave")
vdPar[1] += 1 ;
if ( sArc2Shape != "concave")
vdPar[1] += 2 ;
if ( process.child( "LapLength") != nullptr && process.child( "LapLength").text().get() != "") //P09
vdPar[2] =std::stod( process.child( "LapLength").text().get()) ;
if ( process.child( "LapHeight") != nullptr && process.child( "LapHeight").text().get() != "") //P10
vdPar[3] = std::stod( process.child( "LapHeight").text().get()) ;
// Arc 1
if ( process.child( "Arc1") != nullptr && process.child( "Arc1").attribute("Displacement") != nullptr) //P11
vdPar[4] = process.child( "Arc1").attribute("Displacement").as_double() ;
if ( process.child( "Arc1") != nullptr && process.child( "Arc1").attribute("LapLength") != nullptr) //P15
vdPar[8] = process.child( "Arc1").attribute("LapLength").as_double() ;
if ( process.child( "Arc1") != nullptr && process.child( "Arc1").attribute("LapHeight") != nullptr) //P16
vdPar[9] = process.child( "Arc1").attribute("LapHeight").as_double() ;
if ( process.child( "Arc1").child("QuarterArc") != nullptr){
vdPar[5] = process.child( "Arc1").child("QuarterArc").attribute("Radius").as_double() ; //P12
vdPar[6] = 0.0 ; //P13
vdPar[7] = 0.0 ; //P14
}
else if ( process.child( "Arc1").child("Segment") != nullptr){
vdPar[5] = process.child( "Arc1").child("Segment").attribute("Length").as_double() ; //P12
vdPar[6] = process.child( "Arc1").child("Segment").attribute("Height").as_double() ; //P13 //P13
vdPar[7] = process.child( "Arc1").child("Segment").attribute("Camber").as_double() ; //P14 //P14
}
else { //se non c' lascio tutto a zero (non default??)
vdPar[5] = 0.0 ;
vdPar[6] = 0.0 ;
vdPar[7] = 0.0 ;
}
//Arc2
if ( process.child ("Arc2") == nullptr){ //devi riempire i parametri a 0 non lasciare quelli di default
vdPar[10] = 0.0 ;
vdPar[11] = 0.0 ;
vdPar[12] = 0.0 ;
vdPar[13] = 0.0 ;
vdPar[14] = 0.0 ;
vdPar[15] = 0.0 ;
}
if ( process.child( "Arc2") != nullptr && process.child( "Arc2").attribute("Displacement") != nullptr) //P17
vdPar[10] = process.child( "Arc2").attribute("Displacement").as_double() ;
if ( process.child( "Arc2") != nullptr && process.child( "Arc2").attribute("LapLength") != nullptr) //P21
vdPar[14] = process.child( "Arc2").attribute("LapLength").as_double() ;
if ( process.child( "Arc2") != nullptr && process.child( "Arc2").attribute("LapHeight") != nullptr) //P22
vdPar[15] = process.child( "Arc2").attribute("LapHeight").as_double() ;
if ( process.child( "Arc2").child("QuarterArc") != nullptr){
vdPar[11] = process.child( "Arc2").child("QuarterArc").attribute("Radius").as_double() ; //P18
vdPar[12] = 0.0 ; //P19
vdPar[13] = 0.0 ; //P20
}
else if ( process.child( "Arc2").child("Segment") != nullptr){
vdPar[11] = process.child( "Arc2").child("Segment").attribute("Length").as_double() ; //P18
vdPar[12] = process.child( "Arc2").child("Segment").attribute("Height").as_double() ; //P19 //P13
vdPar[13] = process.child( "Arc2").child("Segment").attribute("Camber").as_double() ; //P20 //P14
}
// Se non tocca il lato non si vede
if ( nGroup == 3) {
double dPartLen = m_BtlGeom.GetCurrPartLength() ;
if ( abs( vdPar[0] - dPartLen) > EPS_SMALL) {
vdPar[2] += ( dPartLen - vdPar[0]) ;
vdPar[0] = dPartLen ;
}
}
else {
if ( abs( vdPar[0] - 0) > EPS_SMALL) {
vdPar[2] += ( 0 - vdPar[0]) ;
vdPar[0] = 0 ;
}
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadSphereParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "SPHERE") ;
//Identifico il processo con sigle usate nel btl
nProc = 107 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
std::string orientation = process.child("Orientation").text().get() ;
if ( orientation == "end")
nGroup = 3 ;
else if ( orientation == "start")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Sphere orientation unknwon") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 6) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Sphere number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Radius") != nullptr && process.child( "Radius").text().get() != "") //P11
vdPar[3] = Clamp( std::stod( process.child( "Radius").text().get()), 0.0, 50000.0) ;
if ( process.child( "StartOffset") != nullptr && process.child( "StartOffset").text().get() != "") //P12
vdPar[4] = Clamp( std::stod( process.child( "StartOffset").text().get()), 0.0, 50000.0) ;
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P13
vdPar[5] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadTriangleCutParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "TRG CUT") ;
//Identifico il processo con sigle usate nel btl
nProc = 120 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
nGroup = 4 ;
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 9) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: TriangleCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = Clamp( std::stod( process.child( "StartX").text().get()), -100000.0, 100000.0) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = Clamp( std::stod( process.child( "StartY").text().get()), -50000.0, 50000.0) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = Clamp( std::stod( process.child( "StartDepth").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal1X") != nullptr && process.child( "Normal1X").text().get() != "") //P10
vdPar[3] = Clamp( std::stod( process.child( "Normal1X").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal1Y") != nullptr && process.child( "Normal1Y").text().get() != "") //P11
vdPar[4] = Clamp( std::stod( process.child( "Normal1Y").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal1Z") != nullptr && process.child( "Normal1Z").text().get() != "") //P12
vdPar[5] = Clamp( std::stod( process.child( "Normal1Z").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal2X") != nullptr && process.child( "Normal2X").text().get() != "") //P13
vdPar[6] = Clamp( std::stod( process.child( "Normal2X").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal2Y") != nullptr && process.child( "Normal2Y").text().get() != "") //P14
vdPar[7] = Clamp( std::stod( process.child( "Normal2Y").text().get()), -50000.0, 50000.0) ;
if ( process.child( "Normal2Z") != nullptr && process.child( "Normal2Z").text().get() != "") //P15
vdPar[8] = Clamp( std::stod( process.child( "Normal2Z").text().get()), -50000.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadTyroleanDovetailParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "TYROLEAN DOVETAIL") ;
//Identifico il processo con sigle usate nel btl
nProc = 136 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
string sCutOff = process.child("CutOff").text().get() ;
if ( sCutOff == "")
sCutOff = "no" ; //se non ci fosse, valore di default
if( sOrientation == "end" && sCutOff == "yes")
nGroup = 1 ;
else if (sOrientation == "start" && sCutOff == "yes")
nGroup = 2 ;
else if (sOrientation == "end" && sCutOff == "no")
nGroup = 3 ;
else if (sOrientation == "start" && sCutOff == "yes")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail group not defined") ;
return false ;
}
//Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 15) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: TriangleCut number of parameters is wrong") ;
return false ;
}
//Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = std::stod( process.child( "StartX").text().get()) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = std::stod( process.child( "StartY").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = std::stod( process.child( "StartDepth").text().get()) ;
string sLapPosition = process.child( "LapPosition").text().get() ; //P04
if ( sLapPosition == "refedge" || sLapPosition == "") //????????????????????????????????????
vdPar[3] = 1 ;
else if ( sLapPosition == "oppedge")
vdPar[3] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail LapPosition unknown") ;
return false ;
}
string sLapExit = process.child( "LapExit").text().get() ; //P05
if ( sLapExit == "none")
vdPar[4] = 0 ;
else if ( sLapExit == "mitre" || sLapExit == "")
vdPar[4] = -1 ;
else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ;
else
vdPar[4] = 10.0 ; //valore di default
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail LapExit unknown") ;
return false ;
}
if ( process.child( "Angle") != nullptr && process.child( "Angle").text().get() != "") //P06
vdPar[5] = std::stod( process.child( "Angle").text().get()) ;
if ( process.child( "Slope") != nullptr && process.child( "Slope").text().get() != "") //P09
vdPar[8] = std::stod( process.child( "Slope").text().get()) ;
if ( process.child( "Height") != nullptr && process.child( "Height").text().get() != "") //P11
vdPar[9] = std::stod( process.child( "Height").text().get()) ;
string sShape = process.child( "Shape").text().get() ; //P14
if ( sShape == "straigth")
vdPar[12] = 1 ;
else if ( sShape == "angular" || sShape == "")
vdPar[12] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail Shape unknown") ;
return false ;
}
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P15
vdPar[13] = Clamp( std::stod( process.child( "Length").text().get()), 0.0, 50000.0) ;
string sProcessSide = process.child( "ProcessSide").text().get() ; //P16
if ( sProcessSide == "both" || sProcessSide == "")
vdPar[14] = 0 ;
else if ( sProcessSide == "refside")
vdPar[14] = 1 ;
else if ( sProcessSide == "oppside")
vdPar[14] = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail Shape unknown") ;
return false ;
}
if ( process.child( "Frosh").child("Width") != nullptr && process.child( "Frosh").child("Width").text().get() != "")
vdPar[6] = Clamp( std::stod( process.child( "Frosh").child("Width").text().get()), 0.0, 50000.0) ;
if ( process.child( "Frosh").child("Depth") != nullptr && process.child( "Frosh").child("Depth").text().get() != "")
vdPar[7] = Clamp( std::stod( process.child( "Frosh").child("Depth").text().get()), 0.0, 50000.0) ;
if ( process.child("Klingschrot").child("Radius") != nullptr && process.child("Klingschrot").child("Radius").text().get() != "")
vdPar[10] = Clamp( std::stod( process.child("Klingschrot").child("Radius").text().get()), 0.0, 50000.0) ;
if ( process.child("Klingschrot").child("ArcLength") != nullptr && process.child("Klingschrot").child("ArcLength").text().get() != "")
vdPar[11] = Clamp( std::stod( process.child("Klingschrot").child("ArcLength").text().get()), 0.0, 50000.0) ;
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar)
{
LOG_ERROR( GetEExLogger(), "DOVETAIL") ;
//Identifico il processo con sigle usate nel btl
nProc = 138 ;
nSide = process.attribute("ReferencePlaneID").as_int() ;
string sOrientation = process.child("Orientation").text().get() ;
string sCutOff = process.child("CutOff").text().get() ;
if ( sCutOff == "")
sCutOff = "no" ; //se non ci fosse, valore di default
if( sOrientation == "end" && sCutOff == "yes")
nGroup = 1 ;
else if (sOrientation == "start" && sCutOff == "yes")
nGroup = 2 ;
else if (sOrientation == "end" && sCutOff == "no")
nGroup = 3 ;
else if (sOrientation == "start" && sCutOff == "yes")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail group not defined") ;
return false ;
}
// Inizializzo i vettori dei parametri
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 11) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail number of parameters is wrong") ;
return false ;
}
// Riempio i vettori dei parametri vdPar, se qualche valore non ci fosse lascio quello di default
if ( process.child( "StartX") != nullptr && process.child( "StartX").text().get() != "") //P01
vdPar[0] = std::stod( process.child( "StartX").text().get()) ;
if ( process.child( "StartY") != nullptr && process.child( "StartY").text().get() != "") //P02
vdPar[1] = std::stod( process.child( "StartY").text().get()) ;
if ( process.child( "StartDepth") != nullptr && process.child( "StartDepth").text().get() != "") //P03
vdPar[2] = std::stod( process.child( "StartDepth").text().get()) ;
string sLapPosition = process.child( "LapPosition").text().get() ;
LOG_ERROR( GetEExLogger(), sLapPosition.c_str()) ;//P04
if ( sLapPosition == "refedge" || sLapPosition == "") //????????????????????????????????????
vdPar[3] = 1 ;
else if ( sLapPosition == "oppedge")
vdPar[3] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Dovetail LapPosition unknown") ;
return false ;
}
string sLapExit = process.child( "LapExit").text().get() ; //P05
if ( sLapExit == "none")
vdPar[4] = 0 ;
else if ( sLapExit == "mitre" || sLapExit == "")
vdPar[4] = -1 ;
else if ( sLapExit == "rebate") {
if ( process.child( "RebateLength") != nullptr)
vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ;
else
vdPar[4] = 10.0 ; //valore di default
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail LapExit unknown") ;
return false ;
}
if ( process.child( "Slope") != nullptr && process.child( "Slope").text().get() != "") //P09
vdPar[5] = std::stod( process.child( "Slope").text().get()) ;
if ( process.child( "HeightRefSide") != nullptr && process.child( "HeightRefSide").text().get() != "") //P11
vdPar[6] = std::stod( process.child( "HeightRefSide").text().get()) ;
if ( process.child( "HeightOppSide") != nullptr && process.child( "HeightOppSide").text().get() != "") //P12
vdPar[7] = std::stod( process.child( "HeightOppSide").text().get()) ;
string sShape = process.child( "Shape").text().get() ; //P14
if ( sShape == "european" || sShape == "")
vdPar[8] = 0 ;
else if ( sShape == "american")
vdPar[8] = 1 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail Shape unknown") ;
return false ;
}
if ( process.child( "Length") != nullptr && process.child( "Length").text().get() != "") //P09
vdPar[9] = std::stod( process.child( "Length").text().get()) ;
string sProcessSide = process.child( "ProcessSide").text().get() ; //P16
if ( sProcessSide == "both" || sProcessSide == "")
vdPar[10] = 0 ;
else if ( sProcessSide == "refside")
vdPar[10] = 1 ;
else if ( sProcessSide == "oppside")
vdPar[10] = 2 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Tyrolean Dovetail Shape unknown") ;
return false ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadFreeContourParams( pugi::xml_node process,
int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar,
DBLVECTOR& vdPar, std::string& sPar, int& curve_counter)
{
LOG_ERROR( GetEExLogger(), "FREE CONTOUR") ;
// Identifico il processo con sigle usate nel btl
nProc = 250 ;
nSide = process.attribute( "ReferencePlaneID").as_int() ;
string sToolPosition = process.attribute( "ToolPosition").value() ;
if ( sToolPosition == "left")
nGroup = 3 ;
else if (sToolPosition == "center")
nGroup = 0 ;
else if (sToolPosition == "right")
nGroup = 4 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: Free Contour group not defined") ;
return false ;
}
// Inizializzo i vettori dei parametri
for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it ++ ){
// Ricreo i contenitori dei parametri
vnDPar.clear() ; nSPar = 0 ; vdPar.clear() ; sPar.clear() ;
bool bParamsInfoOk = m_BtlGeom.GetProcessParamInfos( nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bParamsInfoOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: BtlGeom.GetProcessParamInfos") ;
return false ;
}
if ( vdPar.size() != 11) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FreeContour number of parameters is wrong") ;
return false ;
}
string sCounterSink = process.attribute("CounterSink").value() ;
if ( sCounterSink == "yes")
vdPar[5] = 1 ;
else if ( sCounterSink == "no")
vdPar[5] = 0 ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: FreeContour CounterSink is wrong") ;
return false ;
}
// Studio i nodi
string itName = it->name() ;
bool bContOk = true ;
if ( itName == "Contour") {
bContOk = ReadSContourParams( *it, 0, 0, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar, curve_counter) ;
if ( ! bContOk)
return false ;
}
else if ( itName == "DualContour") {
bContOk = ReadDContourParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar, curve_counter) ;
if ( ! bContOk)
return false ;
}
else {
LOG_ERROR ( GetEExLogger(), " Error reading Part Processing: FreeContour type is wrong")
return false ;
}
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadSContourParams( pugi::xml_node process, int nType, int nOtherId,
int& nGroup, int& nProc, int& nSide,
INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, string& sPar, int& curve_counter)
{
// Parametri propri del contour che non cambiano
string sDepthBounded = process.attribute("DepthBounded").value() ;
if ( sDepthBounded == "no")
vdPar[3] = 0 ;
else
vdPar[3] = process.attribute("Depth").as_double() ;
int contour_counter = 0 ;
for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it++)
contour_counter ++ ;
int i = 0 ;
for ( pugi::xml_node_iterator it = process.begin() ; it != process.end() ; it++) {
// Reinizializzo i parametri
vdPar[0] = 0.0 ; vdPar[1] = 0.0 ; vdPar[2] = 0.0; vdPar[6] = 0.0 ; vdPar[8] = 0.0 ; vdPar[9] = 0.0 ; vdPar[10] = 0.0 ;
vdPar[4] = process.attribute("Inclination").as_double() ;
i++ ;
if ( i != contour_counter)
vdPar[7] = curve_counter + 1 ;
else
vdPar[7] = 0 ;
string sName = it->name() ;
// START POINT
if ( sName == "StartPoint") {
vdPar[6] = nType ;
if ( nType == 100 || nType == 101) { //salvo id del contour associato
vdPar[4] = nOtherId ;
}
if ( it->attribute("X") == nullptr || it->attribute("Y") == nullptr || it->attribute("Z") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour StartPoint component missing") ;
return false ;
}
vdPar[0] = it->attribute("X").as_double() ;
vdPar[1] = it->attribute("Y").as_double() ;
vdPar[2] = it->attribute("Z").as_double() ;
}
// LINE
else if ( sName == "Line") {
vdPar[6] = 1 ;
if ( it->child( "EndPoint") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Line EndPoint missing") ;
return false ;
}
if ( it->child( "EndPoint").attribute("X") == nullptr ||it->child( "EndPoint").attribute("Y") == nullptr ||
it->child( "EndPoint").attribute("Z") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Line EndPoint component missing") ;
return false ;
}
vdPar[0] = it->child( "EndPoint").attribute("X").as_double() ;
vdPar[1] = it->child( "EndPoint").attribute("Y").as_double() ;
vdPar[2] = it->child( "EndPoint").attribute("Z").as_double() ;
}
// ARC
else if ( sName == "Arc") {
vdPar[6] = 2 ;
if ( it->child( "EndPoint") == nullptr || it->child( "PointOnArc") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Arc EndPoint missing") ;
return false ;
}
if ( it->child( "EndPoint").attribute("X") == nullptr ||
it->child( "EndPoint").attribute("Y") == nullptr ||
it->child( "EndPoint").attribute("Z") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Arc end point component missing") ;
return false ;
}
vdPar[0] = it->child( "EndPoint").attribute("X").as_double() ;
vdPar[1] = it->child( "EndPoint").attribute("Y").as_double() ;
vdPar[2] = it->child( "EndPoint").attribute("Z").as_double() ;
if ( it->child( "PointOnArc").attribute("X") == nullptr ||
it->child( "PointOnArc").attribute("Y") == nullptr ||
it->child( "PointOnArc").attribute("Z") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Arc component missing") ;
return false ;
}
vdPar[8] = it->child( "PointOnArc").attribute("X").as_double() ;
vdPar[9] = it->child( "PointOnArc").attribute("Y").as_double() ;
vdPar[10] = it->child( "PointOnArc").attribute("Z").as_double() ;
}
else {
LOG_ERROR ( GetEExLogger(), " Error reading Part Process: FreeContour Contour element unknown")
return false ;
}
Frame3d frRef ;
// Se riferimento non una delle facce, lo cerco fra UserReferencePlanes
if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_RIGHT) {
// se non esiste, errore
if ( MapURefPlanes.find( nSide) == MapURefPlanes.end()) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: FreeContour Contour Reference Plane unknown")
return false ;
}
frRef = MapURefPlanes[nSide] ;
}
string sDes ;
STRVECTOR vsUAtt ;
bool bProcessOk = m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, curve_counter, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, 0) ;
if ( ! bProcessOk) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddProcess error")
return false ;
}
curve_counter ++ ;
}
return true ;
}
//---------------------------------------------------------------------------------------------------------------------------
bool
ImportBtlx::ReadDContourParams( pugi::xml_node process,
int& nGroup, int& nProc, int& nSide, INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar, int& curve_counter)
{
if ( process.child("PrincipalContour") == nullptr || process.child("AssociatedContour") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: DualContour contour missing")
return false ;
}
// Principal Contour
int nPrincipalId = curve_counter + 1 ;
int nPrincipalContCurves = 0 ;
// conto il numero di curve nel PrincipalContour
for ( pugi::xml_node_iterator it = process.child( "PrincipalContour").child( "Contour").begin() ;
it != process.child( "PrincipalContour").child( "Contour").end() ; it ++)
nPrincipalContCurves ++ ;
bool bContourOk = ReadSContourParams( process.child( "PrincipalContour"), 100, curve_counter + nPrincipalContCurves,
nGroup, nProc, nSide, vnDPar, nSPar,vdPar, sPar, curve_counter) ;
if ( ! bContourOk)
return false ;
// Associated Contour
bContourOk = ReadSContourParams( process.child( "AssociatedContour"), 101, nPrincipalId,
nGroup, nProc, nSide, vnDPar, nSPar,vdPar, sPar, curve_counter) ;
if ( ! bContourOk)
return false ;
return true ;
}