Files
EgtExchange/ImportBtlx.cpp
T
Dario Sassi 0368a42292 EgtExchange :
- in import BTL/BTLx migliorata gestione FreeContour con Pocket
- in import BTLx fatte piccole sistemazioni.
2021-01-09 19:23:33 +00:00

1400 lines
55 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 ;
// ---------------------------------------------------------
STRVECTOR ProjectAttributes = {"Architect", "Comment", "Customer", "DeliveryDate", "Editor", "ListName", "Name", "Number", "Section",
"SourceFile"} ;
STRVECTOR ProjectAttributes_other = {"GUID", "ProcessingQuality", "Recess"} ;
STRVECTOR PartAttributes = {"Annotation", "AssemblyNumber", "Comment", "ElementNumber", "EndOffset", "Group", "Layer", "Material",
"ModuleNumber", "OrderNumber", "Package", "PlaningLength", "QualityGrade", "StartOffset",
"Storey", "TimberGrade", "Weight"} ;
STRVECTOR PartAttributes_other = {"Count", "Designation", "Height", "Length", "ProcessingQuality", "Recess", "SingleMemberNumber",
"StoreyType", "Width"} ;
STRVECTOR EndTypeValues={"rectangularCut", "angledCut", "doubleCut" } ;
STRVECTOR LocationTypeValues={"bottomRail", "topRail", "bottomRailAngled", "topRailAngled", "horizontalComponent",
"verticalComponent", "angledComponent"} ;
STRVECTOR svMaterials{ "batten", "cladding", "massiveTimber", "membrane", "gypsumBoard", "gypsumFibre", "insulation", "sheetComponent",
"facadePanel", "profiledPanel", "plaster"} ;
//----------------------------------------------------------------------------
IImportBtlx*
CreateImportBtlx( void)
{
// verifico la chiave e le opzioni
if ( ! TestKeyForEEx( GetEExKey(), KEYOPT_EEX_INPADV, GetEExLogger()))
return nullptr ;
// creo l'oggetto
return static_cast<IImportBtlx*> ( new(nothrow) ImportBtlx) ;
}
//----------------------------------------------------------------------------
ImportBtlx::ImportBtlx( void)
{
}
//----------------------------------------------------------------------------
bool
ImportBtlx::Import( const string& sFile, IGeomDB* pGDB, int nFlag)
{
// log di informazioni
LOG_INFO( GetEExLogger(), ( "ImportBtlx : " + sFile).c_str())
// inizializzo il gestore geometria pezzi Btl
int nFlatVertPos = 0 ;
if (( nFlag & EIBFLAG_TS3_POS) != 0)
nFlatVertPos = 3 ;
else if (( nFlag & EIBFLAG_FLAT_POS) != 0)
nFlatVertPos = 1 ;
else if (( nFlag & EIBFLAG_VERT_POS) != 0)
nFlatVertPos = 2 ;
bool bSpecialTrim = (( nFlag & EIBFLAG_SPECIAL_TRIM) != 0) ;
bool bUseUAttr = (( nFlag & EIBFLAG_USEUATTR) != 0) ;
if ( ! m_BtlGeom.Init( pGDB, nFlatVertPos, bSpecialTrim, bUseUAttr)) {
LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") ;
return false ;
}
// scrivo nel progetto path del file
m_BtlGeom.SetUserAttribute( UATD_INFO, IKEY_BTL_PATH + ":" + sFile) ;
// inizializzo il documento
pugi::xml_document doc;
pugi::xml_parse_result ParseResult = doc.load_file( sFile.c_str()) ;
if ( ! ParseResult) {
string sError = " Error parsing file : " ;
sError += ParseResult.description() ;
LOG_ERROR( GetEExLogger(), sError.c_str()) ;
return false ;
}
// ------------- Nodo BTLX ---------------------------------
pugi::xml_node rootNode = doc.first_child() ;
string sLanguage = rootNode.attribute("Language").value() ;
if ( sLanguage != "") //se valore vuoto?
m_BtlGeom.SetUserAttribute( UATD_INFO, "Language", rootNode.attribute("Language").value()) ;
if ( rootNode.attribute("Version") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading BTLX : unknown version of BTLX") ;
return false ;
}
m_sVersion = rootNode.attribute("Version").value() ;
// ---------- Nodo FileHistory --------------------------------
pugi::xml_node fileHistory = rootNode.child( "FileHistory") ;
if ( fileHistory != nullptr)
if ( ! ReadFileHistory( fileHistory))
return false ;
//----------- Nodo Project ----------------------------------------
pugi::xml_node projectNode = rootNode.child( "Project") ;
if ( projectNode == nullptr) {
LOG_ERROR( GetEExLogger(), "Error Reading BTLX: no Project " ) ;
return false ;
}
//Lettura attributes
if ( ! ReadProjectAttributes( projectNode.first_attribute())) {
return false ;
}
//Analisi dei sottonodi
int counter_parts = 0 ; //conto i pezzi del progetto
for ( pugi::xml_node_iterator itProject = projectNode.begin(); itProject != projectNode.end(); ++itProject) {
std::string child_name = itProject->name() ;
bool bReadOk = true ;
if ( child_name == "Parts") {
for ( pugi::xml_node_iterator itParts = itProject->begin(); itParts != itProject->end(); ++itParts) {
counter_parts ++ ;
bReadOk = ReadPart( *itParts);
if ( ! bReadOk)
return false ;
}
}
else if ( child_name == "UserAttributes") {
bReadOk = ReadUserAttributes( *itProject, 0) ;
if ( ! bReadOk)
return false ;
}
else if ( child_name == "Rawparts") {
//////////
}
else if ( child_name == "Composites") {
//////////
}
else {
LOG_ERROR( GetEExLogger(), " Error Reading Project : unknown node" ) ;
}
}
if ( counter_parts == 0){
LOG_ERROR( GetEExLogger(), " Error Reading Project: no Parts " ) ;
return false ;
}
return true ;
}
//-----------------------------------------------------------------
bool
ImportBtlx::ReadFileHistory( pugi::xml_node node)
{
//Scorro tutti i sottonodi
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it ++) {
string sName , sName2, sValue ;
string sNodeName = it->name() ;
//salvo gli attributes
for ( pugi::xml_attribute attr = it->first_attribute() ; attr ; attr = attr.next_attribute()) {
sName = attr.name() ;
sValue = attr.value() ;
if ( sName != "" && sValue != "") {
if ( sNodeName == "InitialExportProgram")
sName2 = "InitialExport-" + sName ;
else if (sNodeName == "EditingProgram")
sName2 = "Editing-" + sName ;
m_BtlGeom.SetUserAttribute( UATD_INFO, sName2, sValue) ;
}
}
}
return true ;
}
//-----------------------------------------------------------------
bool
ImportBtlx::ReadProjectAttributes( pugi::xml_attribute attr)
{
// Scorro tutti gli attributes
while ( attr) {
bool bAddOk = true ;
string sName = attr.name() ;
string sValue = attr.value() ;
if ( find( ProjectAttributes.begin(), ProjectAttributes.end(), sName) != ProjectAttributes.end()) {
if ( sValue != "") //aggiungo solo se non è vuoto
bAddOk = m_BtlGeom.SetUserAttribute( UATD_INFO, attr.name(), attr.value()) ;
}
// Tratto gli attributes particolari :
else if ( find( ProjectAttributes_other.begin(), ProjectAttributes_other.end(), sName) != ProjectAttributes_other.end()) {
if ( sName == "GUID") {
if ( CheckGuid( attr.value()))
bAddOk = m_BtlGeom.SetUserAttribute( UATD_INFO, attr.name(), attr.value()) ;
else
LOG_ERROR( GetEExLogger(), " Error reading Project : GUID wrong") ;
}
else if ( sName == "ProcessingQuality") {
if ( sValue == "automatic" || sValue == "fast" || sValue == "visible")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_INFO, attr.name(), attr.value()) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Project : unknown ProcessingQuality attribute value")
return false ;
}
}
else if ( sName == "Recess") {
if ( sValue == "automatic" || sValue == "manual")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_INFO, attr.name(), attr.value()) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Project : unknown Recess attribute value")
return false ;
}
}
}
else {
string error = " Warning reading Project : " + sName + " attribute is unknown" ;
LOG_ERROR( GetEExLogger(), error.c_str()) ;
}
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Project : BtlGeom.SetUserAttribute error") ;
return false ;
}
attr = attr.next_attribute() ;
}
return true ;
}
//-----------------------------------------------------------
bool
ImportBtlx::ReadUserAttributes(pugi::xml_node node, int caller, std::vector<std::string> * pvsAttr)
{
bool bAddOk = true ;
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it ++){
// verifico che abbia i due attributi richiesti
if ( it->attribute("Name") == nullptr || it->attribute("Value") == nullptr)
LOG_ERROR( GetEExLogger(), " Error reading UserAttribute : missing required attribute") ;
string sName = it->attribute("Name").value() ;
string sValue = it->attribute("Value").value() ;
if ( sName == "" || sValue == ""){
LOG_ERROR( GetEExLogger(), " Error reading UserAttribute : attribute is empty") ;
return false ;
}
if ( caller == 0) //chiamata dal nodo project
bAddOk = m_BtlGeom.SetUserAttribute( UATD_INFO, sName, sValue) ;
else if ( caller == 1) //chiamata dal nodo part
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, sName, sValue) ;
else if ( caller == 2) //chiamata da processing
if ( pvsAttr == nullptr)
LOG_ERROR( GetEExLogger(), " Error reading UserAttribute : missing UserAttribute vector")
else
pvsAttr->emplace_back( sName + ":" + sValue) ;
if ( ! bAddOk)
LOG_ERROR( GetEExLogger(), " Error reading UserAttribute : BtlGeom.SetUserAttribute error" ) ;
}
return true ;
}
//------------------------------------------------------------------------------------
bool
ImportBtlx::ReadPart( pugi::xml_node node)
{
// Creo la parte nel BTLGeom
if ( ! m_BtlGeom.CreatePart()) {
LOG_ERROR( GetEExLogger(), " Error reading Part : m_BtlGeom.CreatePart error") ;
return false ;
}
// Analisi Attributes
bool bAttrOk = ReadPartAttributes( node.first_attribute()) ;
if ( ! bAttrOk){
return false ;
}
// Analisi nodi
for (pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it ++){
std::string name = it->name() ;
if ( name == "Camber") {
// ????????????????????
}
else if ( name == "Alignment") {
// Controllo che ci siano tutti gli attributes
if ( it->attribute("Location") == nullptr || it->attribute("Endtype") == nullptr)
LOG_ERROR( GetEExLogger(), " Error reading Part Alignment: attribute missing") ;
// Controllo che siano valori sensati
std::string sLocation = it->attribute("Location").value() ;
std::string sEndType = it->attribute("Endtype").value() ;
if ( find ( LocationTypeValues.begin() , LocationTypeValues.end() , sLocation) == LocationTypeValues.end()){
LOG_ERROR( GetEExLogger(), " Error reading Part Alignment: LocationType unknown") ;
return false ;
}
if ( find ( EndTypeValues.begin() , EndTypeValues.end() , sEndType) == EndTypeValues.end() ) {
LOG_ERROR( GetEExLogger(), " Error reading Part Alignment: Endtype unknown") ;
return false ;
}
//?????????????????????????????????
}
else if ( name == "Colour") {
Color colRes ;
// controllo ci siano tutti i parametri required
if ( it->attribute("Red") == nullptr || it->attribute("Green") == nullptr || it->attribute("Blue") == nullptr
|| it->attribute("Transparency") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Color: attribute missing") ;
return false ;
}
int nRed = Clamp( it->attribute( "Red").as_int(), 0, 255) ;
int nGreen = Clamp( it->attribute( "Green").as_int(), 0, 255) ;
int nBlue = Clamp( it->attribute( "Blue").as_int(), 0, 255) ;
int nAlpha = Clamp( it->attribute( "Transparency").as_int(), 0, 255) ;
nAlpha = nAlpha *100 /255 ; //va scalato su 100 non su 255
colRes.Set( nRed, nGreen, nBlue, nAlpha) ;
bool bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, name, ToString( colRes)) ;
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Color : m_BtlGeom.SetUserAttribute error") ;
return false ;
}
}
else if ( name == "PartOffset") {
// controllo ci siano i required attributes:
// ?????????????????????? solo Flush side è required?? Gli altri ????
if ( it->attribute("FlushSide") == nullptr ) {
LOG_ERROR( GetEExLogger(), " Error reading Part PartOffset : flush side missing") ;
return false ;
}
// Controllo sui valori :
if ( it->attribute( "FlushSide").as_int() > 4 || it->attribute( "FlushSide").as_int() < 1) {
LOG_ERROR( GetEExLogger(), " Error reading Part PartOffset : flush side value is wrong") ;
return false ;
}
//std::cout << it->attribute("OffsetSide1").as_double() << " " << it->attribute("OffsetSide2").as_double() << " " <<
// it->attribute("OffsetSide3").as_double() << " " << it->attribute("OffsetSide4").as_double() << std::endl;
//????????????????????????????
}
else if ( name == "Transformations") {
// Leggo tutte le trasformazioni
for ( pugi::xml_node_iterator itTransf = it->begin() ; itTransf != it->end() ; itTransf ++){
string sNameTransf = itTransf->name() ;
if ( sNameTransf != "Transformation"){
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : unknown transformation child") ;
return false ;
}
bool bTransfOk = ReadTransformation( *itTransf) ;
if ( ! bTransfOk)
return false ;
}
}
else if ( name == "UserAttributes") {
bool bUserAttrOk = ReadUserAttributes( *it, 1) ;
if ( ! bUserAttrOk)
return false ;
}
else if ( name == "Processings") {
ReadProcessings( *it) ;
}
else if ( name == "Outlines") {
int outline_counter = 0 ;
string OutlineName ;
for ( pugi::xml_node_iterator itOutline = it->begin() ; itOutline != it->end(); itOutline++){
LOG_ERROR( GetEExLogger(), "Outline")
if ( outline_counter > 3){ //possono essere massimo 3
LOG_ERROR( GetEExLogger(), " Error reading Part : more than 3 outlines")
return false ;
}
OutlineName = itOutline->name() ;
if ( OutlineName != "Outline"){
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown child")
return false ;
}
bool bOutlineOk = ReadOutline( *itOutline) ;
if ( ! bOutlineOk)
return false ;
outline_counter ++ ;
}
}
else if ( name == "UserReferencePlanes") {
for ( pugi::xml_node_iterator itURefPlanes = it->begin() ; itURefPlanes != it->end() ; itURefPlanes ++ ){
string nameURefPlanes = itURefPlanes->name() ;
if ( nameURefPlanes != "UserReferencePlane"){
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown UserPlane child")
return false ;
}
bool bRefPlane = ReadUserReferencePlane( *itURefPlanes) ;
if ( ! bRefPlane)
return false ;
}
}
else if ( name == "GrainDirection"){
Vector3d vtDir ;
if ( it->attribute( "X") == nullptr || it->attribute( "Y") == nullptr || it->attribute( "Z") == nullptr
|| it->attribute( "Align") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection attribute missing")
return false ;
}
vtDir.x = it->attribute( "X").as_double() ;
vtDir.y = it->attribute( "Y").as_double() ;
vtDir.z = it->attribute( "Z").as_double() ;
string sAlign = it->attribute( "Align").value() ;
if ( sAlign == "yes")
sAlign = "1" ;
else if ( sAlign == "no")
sAlign = "0" ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : GrainDirection align is unknown")
return false ;
}
m_BtlGeom.SetUserAttribute( UATD_PART, "GRAINDIRECTION", ToString( vtDir) + ";" + sAlign) ;
}
else if ( name == "MaterialClass"){
string sMaterial = it->attribute( "Group").value() ;
string sSpecification = it ->attribute( "Specification").value() ;
if ( find( svMaterials.begin(), svMaterials.end(), sMaterial) == svMaterials.end()){
LOG_ERROR( GetEExLogger(), " Error reading Part : MaterialClass group is unknown")
return false ;
}
m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALGROUP", sMaterial) ;
if ( sSpecification != "")
m_BtlGeom.SetUserAttribute( UATD_PART, "MATERIALSPECIFICATION", sSpecification) ;
}
else if ( name == "UserAttribute"){
if ( it->attribute( "Name") == nullptr || it->attribute( "")==nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part : UserAttribute attribute missing")
return false ;
}
string sName = it->attribute( "Name").value() ;
string sValue = it ->attribute( "Value").value() ;
if ( sName != "" && sValue != "")
m_BtlGeom.SetUserAttribute( UATD_PART, sName, sValue) ;
}
else if ( name == "ReferenceSide"){
string sVal = it->attribute("Side").value() ;
// Align??
m_BtlGeom.SetUserAttribute( UATD_PART, "REFERENCESIDE", sVal) ;
}
}
// inserisco eventuali contorni liberi
if ( ! m_BtlGeom.CreateFreeContours()){
LOG_ERROR ( GetEExLogger(), " Error reading Part : BtlGeom.CreateFreeContours()")
return false ;
}
// Outline
bool bOutLineOk = m_BtlGeom.UpdateOutLine() ;
if ( !bOutLineOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part : BtlGeom.UpdateOutLine error")
m_BtlGeom.ErasePart() ;
return false ;
}
LOG_ERROR( GetEExLogger(), "------END PART ---------")
return true ;
}
//-----------------------------------------------------------------------------
bool
ImportBtlx::ReadPartAttributes( pugi::xml_attribute attr)
{
bool bLength = false, bWidth = false, bHeight = false ;
double dLength, dWidth, dHeight ;
// scorro tutti gli attributes
while ( attr) {
bool bAddOk = true ;
string name = attr.name() ;
string value = attr.value() ;
if ( find( PartAttributes.begin(), PartAttributes.end(), name) != PartAttributes.end()) {
if ( value != "") //aggiungo solo se non è vuoto
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, attr.name(), attr.value()) ;
}
else if ( find( PartAttributes_other.begin(), PartAttributes_other.end(), name) != PartAttributes_other.end()) {
if ( name == "Count")
m_BtlGeom.SetPartCount( attr.as_int()) ;
else if ( name == "Designation")
m_BtlGeom.SetPartName( value) ;
else if ( name == "SingleMemberNumber")
m_BtlGeom.SetPartProdNbr( attr.as_int()) ;
else if ( name == "Length") {
dLength = attr.as_double() ;
bLength = true ;
}
else if ( name == "Width") {
dWidth = attr.as_double() ;
bWidth = true ;
}
else if ( name == "Height"){
dHeight = attr.as_double() ;
bHeight = true ;
}
else if ( name == "ProcessingQuality") {
if ( value == "automatic" || value == "fast" || value == "visible")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, attr.name(), attr.value()) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown ProcessingQuality attribute value")
return false ;
}
}
else if ( name == "Recess") {
if ( value == "automatic" || value == "manual")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, attr.name(), attr.value()) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown Recess attribute value")
return false ;
}
}
else if ( name == "StoreyType") {
if ( value == "" || value == "ceiling" || value == "roof" || value == "wall")
bAddOk = m_BtlGeom.SetUserAttribute( UATD_PART, attr.name(), attr.value()) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown StoreyType attribute value")
return false ;
}
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : unknown attribute")
}
if ( ! bAddOk){
LOG_ERROR( GetEExLogger(), " Error reading Part : BtlGeom.SetUserAttribute error")
return false ;
}
attr = attr.next_attribute() ;
}
// Creo il box
if ( bLength && bWidth && bHeight) {
if ( ! m_BtlGeom.AddPartBox( dLength, dHeight, dWidth)) {
LOG_ERROR( GetEExLogger(), " Error reading Part : BtlGeom.AddPartBox error" ) ;
return false ;
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part : no box")
m_BtlGeom.ErasePart() ;
return false ;
}
return true ;
}
//--------------------------------------------------------------------
bool
ImportBtlx::ReadTransformation( pugi::xml_node node)
{
Frame3d frRef;
string guid ;
// ID
if (node.attribute( "GUID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : GUID missing") ;
return false ;
}
if ( CheckGuid (node.attribute( "GUID").value()))
guid = node.attribute( "GUID").value() ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : GUID wrong") ;
return false ;
}
// Origine
pugi::xml_node origin = node.child( "Position").child( "ReferencePoint") ;
if ( origin == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : Origin missing") ;
return false ;
}
if ( origin.attribute( "X") == nullptr || origin.attribute("Y") == nullptr || origin.attribute("Z") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : Origin component missing") ;
return false ;
}
Point3d ptO( origin.attribute( "X").as_double(), origin.attribute( "Y").as_double(), origin.attribute( "Z").as_double()) ;
// Asse X
pugi::xml_node axisX = node.child("Position").child("XVector") ;
if ( axisX == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : X axis missing") ;
return false ;
}
if ( axisX.attribute( "X") == nullptr || axisX.attribute("Y") == nullptr || axisX.attribute("Z") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : X axis component missing") ;
return false ;
}
Vector3d vtX( axisX.attribute( "X").as_double(), axisX.attribute( "Y").as_double(), axisX.attribute( "Z").as_double()) ;
// Asse Y
pugi::xml_node axisY = node.child("Position").child("YVector") ;
if ( axisY == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : Y axis missing") ;
return false ;
}
if ( axisY.attribute( "X") == nullptr || axisY.attribute("Y") == nullptr || axisY.attribute("Z") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : Y axis component missing") ;
return false ;
}
Vector3d vtY( axisY.attribute( "X").as_double(), axisY.attribute( "Y").as_double(), axisY.attribute( "Z").as_double()) ;
frRef.Set( ptO, ptO + vtX, ptO + vtY) ;
bool bTransfOk = m_BtlGeom.AddPartTransformation( guid, frRef) ;
if ( ! bTransfOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Transformation : BtlGeom.AddPartTransformation error") ;
return false ;
}
return true ;
}
//-----------------------------------------------------------------------------
bool
ImportBtlx::CheckGuid ( std::string s)
{
vector<char> range = {'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} ;
if ( s[0] != '{' || s[37] != '}')
return false ;
for ( size_t i = 1; i < 37; i++) {
if ( i == 9 || i == 14 || i == 19 || i == 24) {
if ( s[i] != '-')
return false ;
}
else
if ( find( range.begin(), range.end(), s[i]) == range.end())
return false ;
}
return true ;
}
//--------------------------------------------------------------------
bool
ImportBtlx::ReadOutline( pugi::xml_node node)
{
FCEDEQUE dqFce ;
STRVECTOR vsUAtt , vsUAttAperture ;
if ( node.attribute( "ReferencePlaneID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : missing reference plane") ;
return false ;
}
// check sul value !!!!!!
int nSide = node.attribute( "ReferencePlaneID").as_int() ;
if ( node.attribute( "Process") != nullptr){
string Process = node.attribute("Process").value() ;
if ( Process == "no")
vsUAtt.emplace_back( "DO:0") ; //????
}
if ( node.child( "Contour") == nullptr && node.child( "DualContour") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : no contour is defined") ;
return false ;
}
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it ++){
string name = it->name() ;
if ( name == "Contour"){
dqFce.clear() ;
bool bContourOk = ReadContour( *it, dqFce, FreeContourEnt::START);
if ( ! bContourOk)
return false ;
bContourOk = m_BtlGeom.AddPartOutline( nSide, dqFce, vsUAtt) ;
if ( ! bContourOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : BtlGeom.AddPartOutline error") ;
return false ;
}
}
else if ( name == "DualContour"){
dqFce.clear() ;
bool bDualContourOk = ReadDualContour( *it, dqFce) ;
if ( ! bDualContourOk)
return false ;
bDualContourOk = m_BtlGeom.AddPartOutline( nSide, dqFce, vsUAtt) ;
if ( ! bDualContourOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : BtlGeom.AddPartOutline error") ;
return false ;
}
}
else if ( name == "Apertures"){
// //Nodo Apertures può contenere più figli di tipo Aperture:
for ( pugi::xml_node_iterator itAperture = it->begin() ; itAperture != it->end() ; itAperture++){
string nameAperture = itAperture->name() ;
if ( nameAperture != "Aperture"){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : Apertures unknown child") ;
return false ;
}
bool bApertureOk = ReadAperture( *itAperture, nSide) ;
if ( ! bApertureOk)
return false ;
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : unknown child") ;
return false ;
}
}
return true ;
}
//---------------------------------------------------------------------------
bool
ImportBtlx::ReadContour( pugi::xml_node node, FCEDEQUE& dqFce, FreeContourEnt::TYPE type)
{
Point3d PtP, PtM ;
int nFlag = -1;
double dAng = 0.0 ; //E' inclination ??? Come va inizializzato ??
// ?? double dAng = ( nFlag == FreeContourEnt::START ? FC_SIDEANG_DEF : FC_SIDEANG_NONE) ;
//StartPoint deve esserci ???
if ( node.child("StartPoint") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline Contour: StartPoint Missing") ;
return false ;
}
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end(); it ++){
string name = it->name() ;
if ( name == "StartPoint"){
if ( it->attribute("X") == nullptr || it->attribute("Y") == nullptr || it->attribute("Z") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline Contour: StartPoint component missing") ;
return false ;
}
PtP.x = node.child("StartPoint").attribute("X").as_double() ;
PtP.y = node.child("StartPoint").attribute("Y").as_double() ;
PtP.z = node.child("StartPoint").attribute("Z").as_double() ;
dqFce.emplace_back( type, PtP, Point3d(), 0.0, 0, 0) ;
}
// Line
else if ( name == "Line"){
// Gli altri attributes ??????
if ( it->attribute("Inclination") == nullptr)
dAng = 0.0 ;
else
dAng = it->attribute("Inclination").as_double() ; //check sul valore????????????????????????????
if ( it->child( "EndPoint") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline 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 Outline Contour: Line component missing") ;
return false ;
}
PtP.x = it->child( "EndPoint").attribute("X").as_double() ;
PtP.y = it->child( "EndPoint").attribute("Y").as_double() ;
PtP.z = it->child( "EndPoint").attribute("Z").as_double() ;
dqFce.emplace_back( FreeContourEnt::LINE, PtP, Point3d(), dAng, 0, 0) ;
}
// Arc
else if ( name == "Arc"){
if ( it->attribute("Inclination") == nullptr)
dAng = 0.0 ;
else
dAng = it->attribute("Inclination").as_double() ;
if ( it->child( "EndPoint") == nullptr || it->child( "PointOnArc") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline Contour: Arc Point 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 Outline Contour: Arc component missing") ;
return false ;
}
PtP.x = it->child( "EndPoint").attribute("X").as_double() ;
PtP.y = it->child( "EndPoint").attribute("Y").as_double() ;
PtP.z = 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 Outline Contour: Arc component missing") ;
return false ;
}
PtM.x = it->child( "PointOnArc").attribute("X").as_double() ;
PtM.y = it->child( "PointOnArc").attribute("Y").as_double() ;
PtM.z = it->child( "PointOnArc").attribute("Z").as_double() ;
dqFce.emplace_back( FreeContourEnt::LINE, PtP, PtM, dAng, 0, 0) ;
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Outline Contour: unknown child") ;
return false ;
}
}
return true ;
}
//---------------------------------------------------------------------------
bool
ImportBtlx::ReadDualContour( pugi::xml_node node, FCEDEQUE& dqFce)
{
// I due contour riempiono lo stesso vettore dqFace
if ( node.child("PrincipalContour") == nullptr || node.child("AssociatedContour") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : DualContour contours missing") ;
return false ;
}
// Principal Contour
bool bContourOk = ReadContour( node.child("PrincipalContour"), dqFce, FreeContourEnt::START_CNT0) ;
if ( ! bContourOk)
return false ;
// Associated Contour
bContourOk = ReadContour( node.child("AssociatedContour"), dqFce, FreeContourEnt::START_CNT1) ;
if ( ! bContourOk)
return false ;
return true ;
}
//---------------------------------------------------------------------------
bool
ImportBtlx::ReadAperture( pugi::xml_node node, int nSide)
{
STRVECTOR vsUAttAperture ;
FCEDEQUE dqFce ;
// Attribute Aperture
if ( node.attribute( "Process") != nullptr){
string Process = node.attribute("Process").value() ;
if ( Process == "no")
vsUAttAperture.emplace_back( "DO:0") ;
}
// ChildAperture sono i contour
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it++){
string name = it->name() ;
if ( name == "Contour"){
dqFce.clear() ;
bool bContourOk = ReadContour( *it, dqFce, FreeContourEnt::START);
if ( ! bContourOk)
return false ;
bContourOk = m_BtlGeom.AddPartAperture( nSide, dqFce, vsUAttAperture) ;
if ( ! bContourOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : BtlGeom.AddPartAperture error") ;
return false ;
}
}
else if ( name == "DualContour"){
dqFce.clear() ;
bool bDualContourOk = ReadDualContour( *it, dqFce) ;
if ( ! bDualContourOk)
return false ;
bDualContourOk = m_BtlGeom.AddPartAperture( nSide, dqFce, vsUAttAperture) ;
if ( ! bDualContourOk){
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : BtlGeom.AddPartAperture error") ;
return false ;
}
}
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Outline : Aperture child unknown") ;
return false ;
}
}
return true ;
}
//-----------------------------------------------------------------------------
bool
ImportBtlx::ReadUserReferencePlane( pugi::xml_node node)
{
if ( node.attribute( "ID") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part ReferencePlane : ID missing")
return false ;
}
int id = node.attribute( "ID").as_int() ;
if ( node.child( "Position") == nullptr){
LOG_ERROR( GetEExLogger(), " Error reading Part ReferencePlane : Position missing")
return false ;
}
Point3d Origin ;
Vector3d VectX, VectY ;
// Origin
if ( node.child( "Position").child("ReferencePoint") == nullptr ||
node.child( "Position").child("ReferencePoint").attribute("X") == nullptr ||
node.child( "Position").child("ReferencePoint").attribute("Y") == nullptr ||
node.child( "Position").child("ReferencePoint").attribute("Z") == nullptr ){
LOG_ERROR( GetEExLogger(), " Error reading Part ReferencePlane : ReferencePoint error")
return false ;
}
Origin.x = node.child( "Position").child("ReferencePoint").attribute("X").as_double();
Origin.y = node.child( "Position").child("ReferencePoint").attribute("Y").as_double();
Origin.z = node.child( "Position").child("ReferencePoint").attribute("Z").as_double();
// VectX
if ( node.child( "Position").child("XVector") == nullptr ||
node.child( "Position").child("XVector").attribute("X") == nullptr ||
node.child( "Position").child("XVector").attribute("Y") == nullptr ||
node.child( "Position").child("XVector").attribute("Z") == nullptr ){
LOG_ERROR( GetEExLogger(), " Error reading Part ReferencePlane : VectorX error")
return false ;
}
VectX.x = node.child( "Position").child("XVector").attribute("X").as_double();
VectX.y = node.child( "Position").child("XVector").attribute("Y").as_double();
VectX.z = node.child( "Position").child("XVector").attribute("Z").as_double();
// VectY
if ( node.child( "Position").child("YVector") == nullptr ||
node.child( "Position").child("YVector").attribute("X") == nullptr ||
node.child( "Position").child("YVector").attribute("Y") == nullptr ||
node.child( "Position").child("YVector").attribute("Z") == nullptr ){
LOG_ERROR( GetEExLogger(), " Error reading Part ReferencePlane : VectorY error")
return false ;
}
VectY.x = node.child( "Position").child("YVector").attribute("X").as_double();
VectY.y = node.child( "Position").child("YVector").attribute("Y").as_double();
VectY.z = node.child( "Position").child("YVector").attribute("Z").as_double();
Frame3d FrRef ;
FrRef.Set( Origin, VectX, VectY, VectX ^ VectY) ; //giusto il vettore z??????????????????????????????????
MapURefPlanes.emplace( id, FrRef) ;
return true ;
}
//------------------------------------------------------------------------
bool
ImportBtlx::ReadProcessings( pugi::xml_node node)
{
int curve_counter = 1 ; //serve per free contour
// Scorro tutti i processi
for ( pugi::xml_node_iterator it = node.begin() ; it != node.end() ; it ++){
string sProcessName = it->name() ;
int nGroup = 0 ;
int nProc = 0 ;
int nSide = 0 ;
INTVECTOR vnDPar ;
int nSPar ;
DBLVECTOR vdPar ;
string sPar ;
int nProcId = 0 ;
Frame3d frRef ;
STRVECTOR vsUAtt ;
string sDes ;
bool bProcessOk = false ;
bool bAdd = true ;
// Controllo che ci siano elementi required del tipo dei processi
if ( it->attribute("Name") == nullptr) {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing : missing name") ;
return false ;
}
sDes = it->attribute("Name").value() ;
// Attributi comuni a tutti i processi:
for ( pugi::xml_attribute attr = it->first_attribute() ; attr ; attr = attr.next_attribute()){
string attrName = attr.name() ;
string attrValue = attr.value() ;
if ( attrName == "ProcessingQuality") {
if ( attrValue == "automatic" || attrValue == "fast" || attrValue == "visible")
vsUAtt.emplace_back( attrName + ":" + attrValue) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Processing: unknown ProcessingQuality attribute value")
return false ;
}
}
else if ( attrName == "Recess") {
if ( attrValue == "automatic" || attrValue == "manual")
vsUAtt.emplace_back( attrName + ":" + attrValue) ;
else {
LOG_ERROR( GetEExLogger(), " Error reading Part Procesing: unknown Recess attribute value")
return false ;
}
}
else if ( attrName == "Process" && attrValue != "yes")
vsUAtt.emplace_back( "DO:0") ;
else if (attrName == "Priority")
vsUAtt.emplace_back( attrName + ":" + attrValue) ;
}
// Analizzo i sottonodi
if ( sProcessName == "UserAttributes"){
bool bReadAttrOk = ReadUserAttributes( *it, 3, &vsUAtt) ;
if ( ! bReadAttrOk)
return false ;
}
// JackRafterCut
else if ( sProcessName == "JackRafterCut"){
bProcessOk = ReadJackRafterCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// LongitudinalCut
else if ( sProcessName == "LongitudinalCut"){
bProcessOk = ReadLongitudinalCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// DoubleCut
else if ( sProcessName == "DoubleCut"){
bProcessOk = ReadDoubleCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// RidgeValleyCut
else if ( sProcessName == "RidgeValleyCut"){
bProcessOk = ReadRidgeValleyCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// SawCut
else if ( sProcessName == "SawCut"){
bProcessOk = ReadSawCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Slot
else if ( sProcessName == "Slot"){
bProcessOk = ReadSlotParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// BirdsMouth
else if ( sProcessName == "BirdsMouth"){
bProcessOk = ReadBirdsMouthParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// HipValleyRafterNotch
else if ( sProcessName == "HipValleyRafterNotch"){
bProcessOk = ReadHipValleyRafterNotchParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Lap
else if ( sProcessName == "Lap"){
bProcessOk = ReadLapParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// LogHouseHalfLap
else if ( sProcessName == "LogHouseHalfLap"){
bProcessOk = ReadLogHouseHalfLapParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// FrenchRidgeLap
else if ( sProcessName == "FrenchRidgeLap"){
bProcessOk = ReadFrenchRidgeLapParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Chamfer
else if ( sProcessName == "Chamfer"){
bProcessOk = ReadChamferParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// LogHouseJoint
else if ( sProcessName == "LogHouseJoint"){
bProcessOk = ReadLogHouseJointParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// LogHouseFront
else if ( sProcessName == "LogHouseFront"){
bProcessOk = ReadLogHouseFrontParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Pocket
else if ( sProcessName == "Pocket"){
bProcessOk = ReadPocketParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Drilling
else if ( sProcessName == "Drilling"){
bProcessOk = ReadDrillingParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Tenon
else if ( sProcessName == "Tenon"){
bProcessOk = ReadTenonParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
// LOG_ERROR( GetEExLogger(), " Tenon chiamo quello standard")
// bProcessOk = m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, 0) ;
bProcessOk = m_BtlGeom.AddTenonBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddTenonBTLX error")
return false ;
}
}
// Moritse
else if ( sProcessName == "Mortise"){
bProcessOk = ReadMortiseParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
// LOG_ERROR( GetEExLogger(), " Mortise chiamo quello standard")
// bProcessOk = m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, 0) ;
bProcessOk = m_BtlGeom.AddMortiseBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddMortiseBTLX error")
return false ;
}
}
// House
else if ( sProcessName == "House"){
//I parametri sono quasi gli stessi di Tenon, quindi chiamo la stessa funzione
bProcessOk = ReadTenonParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
//Sovrascrivo i parametri di Tenon con le piccole modifiche proprie di House
nProc = 52 ; //anche se non lo cambi, la funzione AddTenon non dovrebbe mai accorgersene (non lo usa)
bProcessOk = m_BtlGeom.AddTenonBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddHouseBTLX error")
return false ;
}
//House contiene un tenon o un dovetailtenon, va letto e aggiunto anche quello :
pugi::xml_node housetenon = it->child("Tenon") ;
if ( housetenon != nullptr){
//Con le info base dei parametri viene fatto emplace back, quindi devo farne clear, altrimenti non perdo
//quelli vecchi
vnDPar.clear() ; vdPar.clear() ; nSPar = 0 ; sPar.clear() ; vsUAtt.clear() ;
bProcessOk = ReadTenonParams( housetenon, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
bProcessOk = m_BtlGeom.AddTenonBTLX2( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddHouseBTLX error")
return false ;
}
}
//DOVETAIL TENON ??????
}
// HouseMortise
else if ( sProcessName == "HouseMortise"){
//I parametri sono quasi gli stessi di Mortise, quindi chiamo la stessa funzione
bProcessOk = ReadMortiseParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
//Sovrascrivo i parametri di Tenon con le piccole modifiche proprie di House
nProc = 53 ;
bProcessOk = m_BtlGeom.AddMortiseBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddMortiseBTLX error")
return false ;
}
//House contiene una mortise, va letto e aggiunto anche quello :
pugi::xml_node housemortise = it->child("Mortise") ;
if ( housemortise != nullptr){
//Con le info base dei parametri viene fatto emplace back, quindi devo farne clear, altrimenti non perdo
//quelli vecchi
vnDPar.clear() ; vdPar.clear() ; nSPar = 0 ; sPar.clear() ; vsUAtt.clear() ;
bProcessOk = ReadMortiseParams( housemortise, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
bProcessOk = m_BtlGeom.AddMortiseBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddMortiseBTLX error")
return false ;
}
}
//DOVETAIL TENON ??????
}
// DovetailTenon
else if ( sProcessName == "DovetailTenon"){
//I parametri sono quasi gli stessi di Mortise, quindi chiamo la stessa funzione
bProcessOk = ReadDovetailTenonParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
bProcessOk = m_BtlGeom.AddDovetailTenonBTLX2( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddDovetailTenonBTLX error")
return false ;
}
}
// DovetailMortise
else if ( sProcessName == "DovetailMortise"){
//I parametri sono quasi gli stessi di Mortise, quindi chiamo la stessa funzione
bProcessOk = ReadDovetailMortiseParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
bProcessOk = m_BtlGeom.AddDovetailMortiseBTLX( nGroup, nProc, nSide, sDes, nProcId, vnDPar, vdPar, vsUAtt) ;
bAdd = false ; //non devo aggiungere il processo una volta terminati questi if
if ( ! bProcessOk ){
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddDovetailMortiseBTLX error")
return false ;
}
}
// Marking
else if ( sProcessName == "Marking"){
bProcessOk = ReadMarkingParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Text
else if ( sProcessName == "Text"){
bProcessOk = ReadTextParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// SimpleScarf
else if ( sProcessName == "SimpleScarf"){
bProcessOk = ReadSimpleScarfParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// ScarfJoint
else if ( sProcessName == "ScarfJoint"){
bProcessOk = ReadScarfJointParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// StepJoint
else if ( sProcessName == "StepJoint"){
bProcessOk = ReadStepJointParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// StepJointNotch
else if ( sProcessName == "StepJointNotch"){
bProcessOk = ReadStepJointNotchParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Planing
else if ( sProcessName == "Planing"){
LOG_ERROR( GetEExLogger(), " Warning reading Part Process: Planing ignored")
// bProcessOk = ReadPlaningParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
// if ( ! bProcessOk)
// return false ;
}
// ProfileFront
else if ( sProcessName == "ProfileFront"){
bProcessOk = ReadProfileFrontParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// ProfileCambered
else if ( sProcessName == "ProfileCambered"){
bProcessOk = ReadProfileCamberedParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// RoundArch
else if ( sProcessName == "RoundArch"){
bProcessOk = ReadRoundArchParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// ProfileHead
else if ( sProcessName == "ProfileHead"){
bProcessOk = ReadProfileHeadParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Sphere
else if ( sProcessName == "Sphere"){
bProcessOk = ReadSphereParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// TriangleCut
else if ( sProcessName == "TriangleCut"){
bProcessOk = ReadTriangleCutParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// TyroleanDovetail
else if ( sProcessName == "TyroleanDovetail"){
bProcessOk = ReadTyroleanDovetailParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// Dovetail
else if ( sProcessName == "Dovetail"){
bProcessOk = ReadDovetailParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar) ;
if ( ! bProcessOk)
return false ;
}
// FreeContour
else if ( sProcessName == "FreeContour"){
bProcessOk = ReadFreeContourParams( *it, nGroup, nProc, nSide, vnDPar, nSPar, vdPar, sPar, curve_counter) ;
if ( ! bProcessOk)
return false ;
bAdd = false ;
}
// Aggiungo il processo
if ( bProcessOk && bAdd) {
bProcessOk = m_BtlGeom.AddProcess( nGroup, nProc, nSide, sDes, nProcId, frRef, vnDPar, nSPar, vdPar, sPar, vsUAtt, 0) ;
if ( ! bProcessOk ) {
LOG_ERROR( GetEExLogger(), " Error reading Part Process: BtlGeom.AddProcess error")
return false ;
}
}
} // end sui sottonodi di Processings
return true ;
}