From 4c457b5ed3fc81f0d6bd2907f8617da41cf6c413 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 18 Jul 2021 10:06:48 -0400 Subject: [PATCH] More NULL expunging. --- .../include/geometry/polygon_triangulation.h | 8 +- libs/kimath/include/geometry/shape.h | 2 +- .../include/geometry/shape_index_list.h | 3 +- libs/kimath/src/geometry/shape_file_io.cpp | 14 +- libs/kimath/src/geometry/shape_poly_set.cpp | 29 +- libs/kiplatform/gtk/app.cpp | 4 +- libs/kiplatform/gtk/ui.cpp | 9 +- libs/kiplatform/msw/environment.cpp | 14 +- libs/sexpr/sexpr_parser.cpp | 4 +- .../dialogs/dialogs_for_printing.cpp | 12 +- .../dialogs/properties_frame.cpp | 78 +++-- pagelayout_editor/pl_editor.cpp | 31 +- pcb_calculator/class_regulator_data.h | 8 +- pcb_calculator/datafile_read_write.cpp | 32 +- pcb_calculator/pcb_calculator.cpp | 26 +- pcb_calculator/pcb_calculator_frame.cpp | 55 ++-- pcb_calculator/regulators_funct.cpp | 121 ++++---- pcb_calculator/transline_dlg_funct.cpp | 77 ++--- pcb_calculator/transline_ident.cpp | 80 +++-- pcb_calculator/transline_ident.h | 22 +- plugins/3d/idf/s3d_plugin_idf.cpp | 175 ++++++----- plugins/3d/oce/loadmodel.cpp | 249 +++++++-------- plugins/3d/oce/oce.cpp | 36 ++- plugins/3d/vrml/v1/vrml1_base.cpp | 183 ++++++----- plugins/3d/vrml/v1/vrml1_coords.cpp | 57 ++-- plugins/3d/vrml/v1/vrml1_faceset.cpp | 102 +++---- plugins/3d/vrml/v1/vrml1_group.cpp | 63 ++-- plugins/3d/vrml/v1/vrml1_matbinding.cpp | 58 ++-- plugins/3d/vrml/v1/vrml1_material.cpp | 118 ++++---- plugins/3d/vrml/v1/vrml1_node.cpp | 108 ++++--- plugins/3d/vrml/v1/vrml1_node.h | 240 ++++++++------- plugins/3d/vrml/v1/vrml1_separator.cpp | 57 ++-- plugins/3d/vrml/v1/vrml1_shapehints.cpp | 68 ++--- plugins/3d/vrml/v1/vrml1_switch.cpp | 56 ++-- plugins/3d/vrml/v1/vrml1_transform.cpp | 79 ++--- plugins/3d/vrml/v2/vrml2_appearance.cpp | 165 +++++----- plugins/3d/vrml/v2/vrml2_base.cpp | 285 +++++++++--------- plugins/3d/vrml/v2/vrml2_box.cpp | 75 +++-- plugins/3d/vrml/v2/vrml2_color.cpp | 54 ++-- plugins/3d/vrml/v2/vrml2_coords.cpp | 53 ++-- plugins/3d/vrml/v2/vrml2_faceset.cpp | 253 ++++++++-------- plugins/3d/vrml/v2/vrml2_inline.cpp | 79 +++-- plugins/3d/vrml/v2/vrml2_lineset.cpp | 123 ++++---- plugins/3d/vrml/v2/vrml2_material.cpp | 90 +++--- plugins/3d/vrml/v2/vrml2_node.cpp | 71 ++--- plugins/3d/vrml/v2/vrml2_norms.cpp | 48 ++- plugins/3d/vrml/v2/vrml2_pointset.cpp | 113 ++++--- plugins/3d/vrml/v2/vrml2_shape.cpp | 158 +++++----- plugins/3d/vrml/v2/vrml2_switch.cpp | 87 +++--- plugins/3d/vrml/v2/vrml2_transform.cpp | 100 +++--- plugins/3d/vrml/vrml.cpp | 56 ++-- plugins/3d/vrml/wrlfacet.cpp | 33 +- plugins/3d/vrml/wrlproc.cpp | 65 ++-- plugins/3d/vrml/x3d.cpp | 30 +- plugins/3d/vrml/x3d/x3d_appearance.cpp | 72 ++--- plugins/3d/vrml/x3d/x3d_base.cpp | 17 +- plugins/3d/vrml/x3d/x3d_coords.cpp | 32 +- plugins/3d/vrml/x3d/x3d_ifaceset.cpp | 83 +++-- plugins/3d/vrml/x3d/x3d_ops.cpp | 41 +-- plugins/3d/vrml/x3d/x3d_shape.cpp | 108 ++++--- plugins/3d/vrml/x3d/x3d_transform.cpp | 66 ++-- plugins/ldr/3d/pluginldr3D.cpp | 280 ++++++++--------- plugins/ldr/pluginldr.cpp | 225 +++++++------- 63 files changed, 2501 insertions(+), 2639 deletions(-) diff --git a/libs/kimath/include/geometry/polygon_triangulation.h b/libs/kimath/include/geometry/polygon_triangulation.h index 2896aec1a3..d97ce95aa9 100644 --- a/libs/kimath/include/geometry/polygon_triangulation.h +++ b/libs/kimath/include/geometry/polygon_triangulation.h @@ -154,10 +154,10 @@ private: if( nextZ ) nextZ->prevZ = prevZ; - next = NULL; - prev = NULL; - nextZ = NULL; - prevZ = NULL; + next = nullptr; + prev = nullptr; + nextZ = nullptr; + prevZ = nullptr; } void updateOrder() diff --git a/libs/kimath/include/geometry/shape.h b/libs/kimath/include/geometry/shape.h index d926b55eb1..7a65d85449 100644 --- a/libs/kimath/include/geometry/shape.h +++ b/libs/kimath/include/geometry/shape.h @@ -139,7 +139,7 @@ public: virtual SHAPE* Clone() const { assert( false ); - return NULL; + return nullptr; }; /** diff --git a/libs/kimath/include/geometry/shape_index_list.h b/libs/kimath/include/geometry/shape_index_list.h index a65f0654a5..c38b55e9ae 100644 --- a/libs/kimath/include/geometry/shape_index_list.h +++ b/libs/kimath/include/geometry/shape_index_list.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -275,7 +276,7 @@ public: const query_iterator qend() { - return query_iterator( m_shapes.end(), m_shapes.end(), NULL, 0, false ); + return query_iterator( m_shapes.end(), m_shapes.end(), nullptr, 0, false ); } iterator begin() diff --git a/libs/kimath/src/geometry/shape_file_io.cpp b/libs/kimath/src/geometry/shape_file_io.cpp index 7c4f1796eb..8a4a25a589 100644 --- a/libs/kimath/src/geometry/shape_file_io.cpp +++ b/libs/kimath/src/geometry/shape_file_io.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -30,6 +30,7 @@ #include #include + SHAPE_FILE_IO::SHAPE_FILE_IO() { m_groupActive = false; @@ -37,6 +38,7 @@ SHAPE_FILE_IO::SHAPE_FILE_IO() m_file = stdout; } + SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MODE aMode ) { m_groupActive = false; @@ -54,7 +56,7 @@ SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MO } else { - m_file = NULL; + m_file = nullptr; } m_mode = aMode; @@ -84,7 +86,7 @@ SHAPE* SHAPE_FILE_IO::Read() do { if (fscanf(m_file, "%s", tmp) != 1) - return NULL; + return nullptr; if( !strcmp( tmp, "shape" ) break; @@ -92,7 +94,7 @@ SHAPE* SHAPE_FILE_IO::Read() int type; - SHAPE *rv = NULL; + SHAPE *rv = nullptr; fscanf(m_file,"%d %s", &type, tmp); @@ -104,14 +106,14 @@ SHAPE* SHAPE_FILE_IO::Read() } if(!rv) - return NULL; + return nullptr; rv.Parse ( ) fprintf(m_file,"shape %d %s %s\n", aShape->Type(), aName.c_str(), sh.c_str() ); */ assert( false ); - return NULL; + return nullptr; } diff --git a/libs/kimath/src/geometry/shape_poly_set.cpp b/libs/kimath/src/geometry/shape_poly_set.cpp index e9dafbf0ae..80c69b4d8a 100644 --- a/libs/kimath/src/geometry/shape_poly_set.cpp +++ b/libs/kimath/src/geometry/shape_poly_set.cpp @@ -105,7 +105,7 @@ SHAPE* SHAPE_POLY_SET::Clone() const bool SHAPE_POLY_SET::GetRelativeIndices( int aGlobalIdx, - SHAPE_POLY_SET::VERTEX_INDEX* aRelativeIndices ) const + SHAPE_POLY_SET::VERTEX_INDEX* aRelativeIndices ) const { int polygonIdx = 0; unsigned int contourIdx = 0; @@ -652,7 +652,8 @@ void SHAPE_POLY_SET::booleanOp( ClipperLib::ClipType aType, const SHAPE_POLY_SET CLIPPER_Z_VALUE zval = newIntersectPoints.at( pt ); // Fixup arc end points to match the new intersection points found in clipper - //@todo consider editing the intersection point to be the "true" arc intersection + // @todo consider editing the intersection point to be the "true" arc + // intersection. if( poly[i].IsSharedPt( j ) ) { poly[i].amendArcEnd( shape.first, pt ); @@ -845,7 +846,7 @@ struct FractureEdge { FractureEdge( int y = 0 ) : m_connected( false ), - m_next( NULL ) + m_next( nullptr ) { m_p1.x = m_p2.y = y; } @@ -854,7 +855,7 @@ struct FractureEdge m_connected( connected ), m_p1( p1 ), m_p2( p2 ), - m_next( NULL ) + m_next( nullptr ) { } @@ -880,7 +881,7 @@ static int processEdge( FractureEdgeSet& edges, FractureEdge* edge ) int min_dist = std::numeric_limits::max(); int x_nearest = 0; - FractureEdge* e_nearest = NULL; + FractureEdge* e_nearest = nullptr; for( FractureEdge* e : edges ) { @@ -951,7 +952,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths ) { FractureEdgeSet edges; FractureEdgeSet border_edges; - FractureEdge* root = NULL; + FractureEdge* root = nullptr; bool first = true; @@ -965,7 +966,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths ) const std::vector& points = path.CPoints(); int pointCount = points.size(); - FractureEdge* prev = NULL, * first_edge = NULL; + FractureEdge* prev = nullptr, * first_edge = nullptr; int x_min = std::numeric_limits::max(); @@ -980,7 +981,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths ) // Do not use path.CPoint() here; open-coding it using the local variables "points" // and "pointCount" gives a non-trivial performance boost to zone fill times. FractureEdge* fe = new FractureEdge( first, points[ i ], - points[ i+1 == pointCount ? 0 : i+1 ] ); + points[ i+1 == pointCount ? 0 : i+1 ] ); if( !root ) root = fe; @@ -1015,7 +1016,7 @@ void SHAPE_POLY_SET::fractureSingle( POLYGON& paths ) { int x_min = std::numeric_limits::max(); - FractureEdge* smallestX = NULL; + FractureEdge* smallestX = nullptr; // find the left-most hole edge and merge with the outline for( FractureEdge* border_edge : border_edges ) @@ -1274,7 +1275,7 @@ int SHAPE_POLY_SET::NormalizeAreaOutlines() Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); - // If any hole, substract it to main outline + // If any hole, subtract it to main outline if( holesBuffer.OutlineCount() ) { holesBuffer.Simplify( SHAPE_POLY_SET::PM_FAST ); @@ -2022,7 +2023,8 @@ SHAPE_POLY_SET SHAPE_POLY_SET::Fillet( int aRadius, int aErrorMax ) SHAPE_POLY_SET::POLYGON SHAPE_POLY_SET::chamferFilletPolygon( CORNER_MODE aMode, - unsigned int aDistance, int aIndex, int aErrorMax ) + unsigned int aDistance, + int aIndex, int aErrorMax ) { // Null segments create serious issues in calculations. Remove them: RemoveNullSegments(); @@ -2204,6 +2206,7 @@ SHAPE_POLY_SET &SHAPE_POLY_SET::operator=( const SHAPE_POLY_SET& aOther ) return *this; } + MD5_HASH SHAPE_POLY_SET::GetHash() const { if( !m_hash.IsValid() ) @@ -2323,7 +2326,7 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition ) if( aPartition ) { - // This partitions into regularly-sized grids (1cm in pcbnew) + // This partitions into regularly-sized grids (1cm in Pcbnew) SHAPE_POLY_SET flattened( *this ); flattened.ClearArcs(); partitionPolyIntoRegularCellGrid( flattened, 1e7, tmpSet ); @@ -2344,7 +2347,7 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition ) m_triangulatedPolys.push_back( std::make_unique() ); PolygonTriangulation tess( *m_triangulatedPolys.back() ); - // If the tesselation fails, we re-fracture the polygon, which will + // If the tessellation fails, we re-fracture the polygon, which will // first simplify the system before fracturing and removing the holes // This may result in multiple, disjoint polygons. if( !tess.TesselatePolygon( tmpSet.Polygon( 0 ).front() ) ) diff --git a/libs/kiplatform/gtk/app.cpp b/libs/kiplatform/gtk/app.cpp index 67c24353ed..4a769712bf 100644 --- a/libs/kiplatform/gtk/app.cpp +++ b/libs/kiplatform/gtk/app.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Mark Roszko -* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. +* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -41,7 +41,7 @@ bool KIPLATFORM::APP::Init() { #if !defined( KICAD_SHOW_GTK_MESSAGES ) // Attach a logger that will consume the annoying GTK error messages - g_log_set_writer_func( nullLogWriter, NULL, NULL ); + g_log_set_writer_func( nullLogWriter, nullptr, nullptr ); #endif return true; diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index 00e392e58f..c4367019a4 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Ian McInerney - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -90,7 +90,8 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor ) void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice ) { - // This function is based on the code inside the function post_process_ui in gtkfilechooserwidget.c + // This function is based on the code inside the function post_process_ui in + // gtkfilechooserwidget.c GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) ); if( !cells ) @@ -101,7 +102,7 @@ void KIPLATFORM::UI::EllipsizeChoiceBox( wxChoice* aChoice ) if( !cell ) return; - g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, NULL ); + g_object_set( G_OBJECT( cell ), "ellipsize", PANGO_ELLIPSIZE_END, nullptr ); // Only the list of cells must be freed, the renderer isn't ours to free g_list_free( cells ); @@ -114,7 +115,7 @@ double KIPLATFORM::UI::GetSystemScaleFactor( const wxWindow* aWindow ) GtkWidget* widget = static_cast( aWindow->GetHandle() ); - if( widget && gtk_check_version( 3, 10, 0 ) == NULL ) + if( widget && gtk_check_version( 3, 10, 0 ) == nullptr ) val = gtk_widget_get_scale_factor( widget ); return val; diff --git a/libs/kiplatform/msw/environment.cpp b/libs/kiplatform/msw/environment.cpp index 7700098472..11e768d47a 100644 --- a/libs/kiplatform/msw/environment.cpp +++ b/libs/kiplatform/msw/environment.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Ian McInerney - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -44,10 +44,10 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) SHFILEOPSTRUCT fileOp; ::ZeroMemory( &fileOp, sizeof( fileOp ) ); - fileOp.hwnd = NULL; // Set to null since there is no progress dialog + fileOp.hwnd = nullptr; // Set to null since there is no progress dialog fileOp.wFunc = FO_DELETE; fileOp.pFrom = temp.c_str(); - fileOp.pTo = NULL; // Set to to NULL since we aren't moving the file + fileOp.pTo = nullptr; // Set to to NULL since we aren't moving the file fileOp.fFlags = FOF_ALLOWUNDO | FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT; int eVal = SHFileOperation( &fileOp ); @@ -70,7 +70,7 @@ bool KIPLATFORM::ENV::IsNetworkPath( const wxString& aPath ) wxString KIPLATFORM::ENV::GetDocumentsPath() { - // If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get() + // If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get() // complains about not existing app. so use a dummy app if( wxTheApp == nullptr ) { @@ -84,7 +84,7 @@ wxString KIPLATFORM::ENV::GetDocumentsPath() wxString KIPLATFORM::ENV::GetUserConfigPath() { - // If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get() + // If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get() // complains about not existing app. so use a dummy app if( wxTheApp == nullptr ) { @@ -100,9 +100,9 @@ wxString KIPLATFORM::ENV::GetUserCachePath() { // Unfortunately AppData/Local is the closest analog to "Cache" directories of other platforms - // Make sure we dont include the "appinfo" (appended app name) + // Make sure we don't include the "appinfo" (appended app name) - // If called by a python script in stand-alone (outside kicad), wxStandardPaths::Get() + // If called by a python script in stand-alone (outside KiCad), wxStandardPaths::Get() // complains about not existing app. so use a dummy app if( wxTheApp == nullptr ) { diff --git a/libs/sexpr/sexpr_parser.cpp b/libs/sexpr/sexpr_parser.cpp index ae2feda990..45f4420852 100644 --- a/libs/sexpr/sexpr_parser.cpp +++ b/libs/sexpr/sexpr_parser.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Mark Roszko - * Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -118,7 +118,7 @@ namespace SEXPR } else if( *it == ')' ) { - return NULL; + return nullptr; } else if( *it == '"' ) { diff --git a/pagelayout_editor/dialogs/dialogs_for_printing.cpp b/pagelayout_editor/dialogs/dialogs_for_printing.cpp index 3f7628a830..c5dd3719f5 100644 --- a/pagelayout_editor/dialogs/dialogs_for_printing.cpp +++ b/pagelayout_editor/dialogs/dialogs_for_printing.cpp @@ -6,7 +6,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * @author Jean-Pierre Charras, jp.charras at wanadoo.fr * @@ -57,7 +57,7 @@ public: PLEDITOR_PRINTOUT( PL_EDITOR_FRAME* aParent, const wxString& aTitle ) : wxPrintout( aTitle ) { - wxASSERT( aParent != NULL ); + wxASSERT( aParent != nullptr ); m_parent = aParent; } @@ -93,9 +93,10 @@ public: if( show ) { bool centre = false; + if( s_size.x == 0 || s_size.y == 0 ) { - s_size = (m_parent->GetSize() * 3) / 4; + s_size = ( m_parent->GetSize() * 3 ) / 4; s_pos = wxDefaultPosition; centre = true; } @@ -115,6 +116,7 @@ public: ret = wxPreviewFrame::Show( show ); } + return ret; } @@ -154,9 +156,7 @@ void PLEDITOR_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, *maxPage = *selPageTo = 2; } -/* - * This is the real print function: print the active screen - */ + void PLEDITOR_PRINTOUT::PrintPage( int aPageNum ) { wxPoint tmp_startvisu; diff --git a/pagelayout_editor/dialogs/properties_frame.cpp b/pagelayout_editor/dialogs/properties_frame.cpp index bb40b11644..f95e3befb7 100644 --- a/pagelayout_editor/dialogs/properties_frame.cpp +++ b/pagelayout_editor/dialogs/properties_frame.cpp @@ -38,25 +38,39 @@ PROPERTIES_FRAME::PROPERTIES_FRAME( PL_EDITOR_FRAME* aParent ) : PANEL_PROPERTIES_BASE( aParent ), m_scintillaTricks( nullptr ), - m_textCtrlTextSizeXBinder( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX, m_TextTextSizeXUnits ), - m_textCtrlTextSizeYBinder( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY, m_TextTextSizeYUnits ), - m_textCtrlConstraintXBinder( aParent, m_staticTextConstraintX, m_textCtrlConstraintX, m_TextConstraintXUnits ), - m_textCtrlConstraintYBinder( aParent, m_staticTextConstraintY, m_textCtrlConstraintY, m_TextConstraintYUnits ), + m_textCtrlTextSizeXBinder( aParent, m_staticTextTsizeX, m_textCtrlTextSizeX, + m_TextTextSizeXUnits ), + m_textCtrlTextSizeYBinder( aParent, m_staticTextTsizeY, m_textCtrlTextSizeY, + m_TextTextSizeYUnits ), + m_textCtrlConstraintXBinder( aParent, m_staticTextConstraintX, m_textCtrlConstraintX, + m_TextConstraintXUnits ), + m_textCtrlConstraintYBinder( aParent, m_staticTextConstraintY, m_textCtrlConstraintY, + m_TextConstraintYUnits ), m_textCtrlPosXBinder( aParent, m_staticTextPosX, m_textCtrlPosX, m_TextPosXUnits ), m_textCtrlPosYBinder( aParent, m_staticTextPosY, m_textCtrlPosY, m_TextPosYUnits ), m_textCtrlEndXBinder( aParent, m_staticTextEndX, m_textCtrlEndX, m_TextEndXUnits ), m_textCtrlEndYBinder( aParent, m_staticTextEndY, m_textCtrlEndY, m_TextEndYUnits ), m_textCtrlStepXBinder( aParent, m_staticTextStepX, m_textCtrlStepX, m_TextStepXUnits ), m_textCtrlStepYBinder( aParent, m_staticTextStepY, m_textCtrlStepY, m_TextStepYUnits ), - m_textCtrlDefaultTextSizeXBinder( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX, m_TextDefaultTextSizeXUnits ), - m_textCtrlDefaultTextSizeYBinder( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY, m_TextDefaultTextSizeYUnits ), - m_textCtrlDefaultLineWidthBinder( aParent, m_staticTextDefLineW, m_textCtrlDefaultLineWidth, m_TextDefaultLineWidthUnits ), - m_textCtrlDefaultTextThicknessBinder( aParent, m_staticTextDefTextThickness, m_textCtrlDefaultTextThickness, m_TextDefaultTextThicknessUnits ), - m_textCtrlLeftMarginBinder( aParent, m_staticTextLeftMargin, m_textCtrlLeftMargin, m_TextLeftMarginUnits ), - m_textCtrlRightMarginBinder( aParent, m_staticTextDefRightMargin, m_textCtrlRightMargin, m_TextRightMarginUnits ), - m_textCtrlTopMarginBinder( aParent, m_staticTextTopMargin, m_textCtrlTopMargin, m_TextTopMarginUnits ), - m_textCtrlBottomMarginBinder( aParent, m_staticTextBottomMargin, m_textCtrlBottomMargin, m_TextBottomMarginUnits ), - m_textCtrlThicknessBinder( aParent, m_staticTextThickness, m_textCtrlThickness, m_TextLineThicknessUnits ) + m_textCtrlDefaultTextSizeXBinder( aParent, m_staticTextDefTsX, m_textCtrlDefaultTextSizeX, + m_TextDefaultTextSizeXUnits ), + m_textCtrlDefaultTextSizeYBinder( aParent, m_staticTextDefTsY, m_textCtrlDefaultTextSizeY, + m_TextDefaultTextSizeYUnits ), + m_textCtrlDefaultLineWidthBinder( aParent, m_staticTextDefLineW, + m_textCtrlDefaultLineWidth, m_TextDefaultLineWidthUnits ), + m_textCtrlDefaultTextThicknessBinder( aParent, m_staticTextDefTextThickness, + m_textCtrlDefaultTextThickness, + m_TextDefaultTextThicknessUnits ), + m_textCtrlLeftMarginBinder( aParent, m_staticTextLeftMargin, m_textCtrlLeftMargin, + m_TextLeftMarginUnits ), + m_textCtrlRightMarginBinder( aParent, m_staticTextDefRightMargin, m_textCtrlRightMargin, + m_TextRightMarginUnits ), + m_textCtrlTopMarginBinder( aParent, m_staticTextTopMargin, m_textCtrlTopMargin, + m_TextTopMarginUnits ), + m_textCtrlBottomMarginBinder( aParent, m_staticTextBottomMargin, m_textCtrlBottomMargin, + m_TextBottomMarginUnits ), + m_textCtrlThicknessBinder( aParent, m_staticTextThickness, m_textCtrlThickness, + m_TextLineThicknessUnits ) { m_parent = aParent; @@ -102,7 +116,6 @@ wxSize PROPERTIES_FRAME::GetMinSize() const } -// Data transfer from general properties to widgets void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel() { DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); @@ -120,13 +133,17 @@ void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel() m_textCtrlDefaultTextThicknessBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.m_DefaultTextThickness ) ); - m_textCtrlLeftMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetLeftMargin() ) ); - m_textCtrlRightMarginBinder.SetDoubleValue(From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetRightMargin() ) ); - m_textCtrlTopMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetTopMargin() ) ); - m_textCtrlBottomMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, model.GetBottomMargin() ) ); + m_textCtrlLeftMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, + model.GetLeftMargin() ) ); + m_textCtrlRightMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, + model.GetRightMargin() ) ); + m_textCtrlTopMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, + model.GetTopMargin() ) ); + m_textCtrlBottomMarginBinder.SetDoubleValue( From_User_Unit( EDA_UNITS::MILLIMETRES, + model.GetBottomMargin() ) ); } -// Data transfer from widgets to general properties + bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral() { DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); @@ -159,7 +176,6 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral() } -// Data transfer from item to widgets in properties frame void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) { if( !aItem ) @@ -221,6 +237,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) { DS_DATA_ITEM_TEXT* item = static_cast( aItem ); item->m_FullText = item->m_TextBase; + // Replace our '\' 'n' sequence by the EOL char item->ReplaceAntiSlashSequence(); m_stcText->SetValue( item->m_FullText ); @@ -266,6 +283,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON ) { DS_DATA_ITEM_POLYGONS* item = static_cast( aItem ); + // Rotation (poly and text) msg.Printf( wxT("%.3f"), item->m_Orient ); m_textCtrlRotation->SetValue( msg ); @@ -274,6 +292,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP ) { DS_DATA_ITEM_BITMAP* item = static_cast( aItem ); + // select definition in PPI msg.Printf( wxT("%d"), item->GetPPI() ); m_textCtrlBitmapDPI->SetValue( msg ); @@ -284,7 +303,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) m_SizerTextOptions->Show( aItem->GetType() == DS_DATA_ITEM::DS_TEXT ); m_sbSizerEndPosition->Show( aItem->GetType() == DS_DATA_ITEM::DS_SEGMENT - || aItem->GetType() == DS_DATA_ITEM::DS_RECT ); + || aItem->GetType() == DS_DATA_ITEM::DS_RECT ); m_textCtrlThicknessBinder.Show( aItem->GetType() != DS_DATA_ITEM::DS_BITMAP ); @@ -324,13 +343,13 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) // until the frame is resized). Joys of multiplatform dev. m_swItemProperties->Fit(); #endif + // send a size event to be sure scrollbars will be added/removed as needed m_swItemProperties->PostSizeEvent(); m_swItemProperties->Refresh(); } -// Event function called by clicking on the OK button void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event ) { PL_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool(); @@ -344,6 +363,7 @@ void PROPERTIES_FRAME::OnAcceptPrms( wxCommandEvent& event ) { DS_DATA_ITEM* dataItem = drawItem->GetPeer(); CopyPrmsFromPanelToItem( dataItem ); + // Be sure what is displayed is what is set for item // (mainly, texts can be modified if they contain "\n") CopyPrmsFromItemToPanel( dataItem ); @@ -379,10 +399,9 @@ void PROPERTIES_FRAME::OnSetDefaultValues( wxCommandEvent& event ) } -// Data transfer from properties frame to item parameters bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) { - if( aItem == NULL ) + if( aItem == nullptr ) return false; wxString msg; @@ -399,7 +418,8 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) } // Import thickness - aItem->m_LineWidth = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlThicknessBinder.GetValue() ); + aItem->m_LineWidth = To_User_Unit( EDA_UNITS::MILLIMETRES, + m_textCtrlThicknessBinder.GetValue() ); // Import Start point aItem->m_Pos.m_Pos.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlPosXBinder.GetValue() ); @@ -431,8 +451,10 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) msg.ToLong( &itmp ); aItem->m_RepeatCount = itmp; - aItem->m_IncrementVector.x = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepXBinder.GetValue() ); - aItem->m_IncrementVector.y = To_User_Unit( EDA_UNITS::MILLIMETRES, m_textCtrlStepYBinder.GetValue() ); + aItem->m_IncrementVector.x = To_User_Unit( EDA_UNITS::MILLIMETRES, + m_textCtrlStepXBinder.GetValue() ); + aItem->m_IncrementVector.y = To_User_Unit( EDA_UNITS::MILLIMETRES, + m_textCtrlStepYBinder.GetValue() ); if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT ) { @@ -456,7 +478,7 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) switch( m_choiceVjustify->GetSelection() ) { - case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break; + case 0: item->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; break; case 1: item->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; break; case 2: item->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; break; } diff --git a/pagelayout_editor/pl_editor.cpp b/pagelayout_editor/pl_editor.cpp index 8c94258133..6370031a8e 100644 --- a/pagelayout_editor/pl_editor.cpp +++ b/pagelayout_editor/pl_editor.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Jean-Pierre Charras, jp.charras at wanadoo.fr * * This program is free software; you can redistribute it and/or @@ -49,42 +50,41 @@ static struct IFACE : public KIFACE_I void OnKifaceEnd() override; - wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override + wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, + int aCtlBits = 0 ) override { switch( aClassId ) { case FRAME_PL_EDITOR: - { - PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent ); - return frame; - } + { + PL_EDITOR_FRAME* frame = new PL_EDITOR_FRAME( aKiway, aParent ); + return frame; break; + } default: ; } - return NULL; + return nullptr; } /** - * Function IfaceOrAddress - * return a pointer to the requested object. The safest way to use this - * is to retrieve a pointer to a static instance of an interface, similar to - * how the KIFACE interface is exported. But if you know what you are doing + * Return a pointer to the requested object. + * + * The safest way to use this is to retrieve a pointer to a static instance of an interface, + * similar to how the KIFACE interface is exported. But if you know what you are doing * use it to retrieve anything you want. * * @param aDataId identifies which object you want the address of. - * - * @return void* - and must be cast into the know type. + * @return the object requested and must be cast into the know type. */ void* IfaceOrAddress( int aDataId ) override { - return NULL; + return nullptr; } /** - * Function SaveFileAs * Saving a file under a different name is delegated to the various KIFACEs because * the project doesn't know the internal format of the various files (which may have * paths in them that need updating). @@ -97,10 +97,13 @@ static struct IFACE : public KIFACE_I } // namespace + using namespace PGE; + static PGM_BASE* process; + KIFACE_I& Kiface() { return kiface; } diff --git a/pcb_calculator/class_regulator_data.h b/pcb_calculator/class_regulator_data.h index 3c7fcf95b6..d62eee846b 100644 --- a/pcb_calculator/class_regulator_data.h +++ b/pcb_calculator/class_regulator_data.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2021 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -76,13 +76,15 @@ public: { // add new item an try to keep alphabetic order, // and because name have numbers inside, use a KiCad compare function - // that handles number as numbers not ascii chars + // that handles number as numbers not ASCII chars unsigned ii = 0; + for( ; ii < m_List.size(); ii++ ) { if( UTIL::RefDesStringCompare( aItem->m_Name, m_List[ii]->m_Name ) < 0 ) break; } + m_List.insert( m_List.begin() + ii, aItem ); } @@ -95,7 +97,7 @@ public: return m_List[ii]; } } - return NULL; + return nullptr; } void Remove( const wxString & aRegName ) diff --git a/pcb_calculator/datafile_read_write.cpp b/pcb_calculator/datafile_read_write.cpp index fae14d812c..b2c752d098 100644 --- a/pcb_calculator/datafile_read_write.cpp +++ b/pcb_calculator/datafile_read_write.cpp @@ -6,7 +6,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -50,7 +50,7 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile() { FILE* file = wxFopen( GetDataFilename(), wxT( "rt" ) ); - if( file == NULL ) + if( file == nullptr ) return false; // Switch the locale to standard C (needed to read/write floating point numbers) @@ -84,6 +84,7 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile() return true; } + bool PCB_CALCULATOR_FRAME::WriteDataFile() { // Switch the locale to standard C (needed to read/write floating point numbers) @@ -117,11 +118,13 @@ PCB_CALCULATOR_DATAFILE::PCB_CALCULATOR_DATAFILE( REGULATOR_LIST * aList ) m_list = aList; } + static const char* regtype_str[] = { "normal", "3terminal" }; + int PCB_CALCULATOR_DATAFILE::WriteHeader( OUTPUTFORMATTER* aFormatter ) const { int nestlevel = 0; @@ -141,6 +144,7 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter, { // Write regulators list: aFormatter->Print( aNestLevel++, "(%s\n", getTokenName( T_regulators ) ); + for( unsigned ii = 0; ii < m_list->m_List.size(); ii++ ) { REGULATOR_DATA * item = m_list->m_List[ii]; @@ -148,15 +152,18 @@ void PCB_CALCULATOR_DATAFILE::Format( OUTPUTFORMATTER* aFormatter, aFormatter->Quotew(item->m_Name ).c_str() ); aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_vref ), item->m_Vref ); + if( item->m_Iadj != 0 && item->m_Type == 1) { aFormatter->Print( aNestLevel+1, "(%s %g)\n", getTokenName( T_reg_iadj ), item->m_Iadj ); } + aFormatter->Print( aNestLevel+1, "(%s %s)\n", getTokenName( T_reg_type ), regtype_str[item->m_Type] ); aFormatter->Print( aNestLevel, ")\n" ); - } + } + aFormatter->Print( --aNestLevel, ")\n" ); } @@ -167,16 +174,14 @@ void PCB_CALCULATOR_DATAFILE::Parse( PCB_CALCULATOR_DATAFILE_PARSER* aParser ) } - -// PCB_CALCULATOR_DATAFILE_PARSER - PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( LINE_READER* aReader ) : PCB_CALCULATOR_DATAFILE_LEXER( aReader ) { } -PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, const wxString& aSource ) : +PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, + const wxString& aSource ) : PCB_CALCULATOR_DATAFILE_LEXER( aLine, aSource ) { } @@ -185,6 +190,7 @@ PCB_CALCULATOR_DATAFILE_PARSER::PCB_CALCULATOR_DATAFILE_PARSER( char* aLine, con void PCB_CALCULATOR_DATAFILE_PARSER::Parse( PCB_CALCULATOR_DATAFILE* aDataList ) { T token; + while( ( token = NextTok() ) != T_EOF) { if( token == T_LEFT ) @@ -200,6 +206,7 @@ void PCB_CALCULATOR_DATAFILE_PARSER::Parse( PCB_CALCULATOR_DATAFILE* aDataList ) } } + void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFILE* aDataList ) { T token; @@ -236,28 +243,34 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL { case T_reg_vref: // the voltage reference value token = NextTok(); + if( token != T_NUMBER ) Expecting( T_NUMBER ); + sscanf( CurText(), "%lf" , &vref); NeedRIGHT(); break; case T_reg_iadj: // the Iadj reference value token = NextTok(); + if( token != T_NUMBER ) Expecting( T_NUMBER ); + sscanf( CurText(), "%lf" , &iadj); NeedRIGHT(); break; case T_reg_type: // type: normal or 3 terminal reg token = NextTok(); - if( strcasecmp( CurText(), regtype_str[0] ) == 0 ) + + if( strcasecmp( CurText(), regtype_str[0] ) == 0 ) type = 0; else if( strcasecmp( CurText(), regtype_str[1] ) == 0 ) type = 1; else Unexpected( CurText() ); + NeedRIGHT(); break; @@ -271,7 +284,8 @@ void PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr( PCB_CALCULATOR_DATAFIL { if( type != 1 ) iadj = 0.0; - REGULATOR_DATA * new_item = new REGULATOR_DATA(name, vref, type, iadj ); + + REGULATOR_DATA* new_item = new REGULATOR_DATA( name, vref, type, iadj ); aDataList->m_list->Add( new_item ); } } diff --git a/pcb_calculator/pcb_calculator.cpp b/pcb_calculator/pcb_calculator.cpp index fb098efb1c..04f57b7167 100644 --- a/pcb_calculator/pcb_calculator.cpp +++ b/pcb_calculator/pcb_calculator.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2015 jean-pierre.charras - * Copyright (C) 2015 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,10 +26,7 @@ #include "pcb_calculator_settings.h" // Pcb_calculator data file extension: -const wxString PcbCalcDataFileExt( wxT("pcbcalc") ); - - -// PCB_CALCULATOR_APP +const wxString PcbCalcDataFileExt( wxT( "pcbcalc" ) ); namespace PCBCALC { @@ -46,35 +43,38 @@ static struct IFACE : public KIFACE_I void OnKifaceEnd() override; - wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override + wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, + int aCtlBits = 0 ) override { return new PCB_CALCULATOR_FRAME( aKiway, aParent ); } /** - * Function IfaceOrAddress - * return a pointer to the requested object. The safest way to use this - * is to retrieve a pointer to a static instance of an interface, similar to - * how the KIFACE interface is exported. But if you know what you are doing + * Return a pointer to the requested object. + * + * The safest way to use this is to retrieve a pointer to a static instance of an interface, + * similar to how the KIFACE interface is exported. But if you know what you are doing * use it to retrieve anything you want. * * @param aDataId identifies which object you want the address of. - * - * @return void* - and must be cast into the know type. + * @return the requested object and must be cast into the know type. */ void* IfaceOrAddress( int aDataId ) override { - return NULL; + return nullptr; } } kiface( "pcb_calculator", KIWAY::FACE_PCB_CALCULATOR ); + } // namespace + using namespace PCBCALC; static PGM_BASE* process; + KIFACE_I& Kiface() { return kiface; } diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 200164a15b..b58081a21d 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2015 jean-pierre.charras - * Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +28,8 @@ // extension of pcb_calculator data filename: -const wxString DataFileNameExt( wxT("pcbcalc") ); +const wxString DataFileNameExt( wxT( "pcbcalc" ) ); + PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_CALCULATOR_FRAME_BASE( aParent ), @@ -40,9 +41,9 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_bpButtonSynthetize->SetBitmap( KiBitmap( BITMAPS::small_up ) ); SetKiway( this, aKiway ); - m_currTransLine = NULL; + m_currTransLine = nullptr; m_currTransLineType = DEFAULT_TYPE; - m_currAttenuator = NULL; + m_currAttenuator = nullptr; m_RegulatorListChanged = false; m_TWMode = TW_MASTER_CURRENT; m_TWNested = false; @@ -52,16 +53,16 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Populate transline list ordered like in dialog menu list const static TRANSLINE_TYPE_ID tltype_list[8] = - { - MICROSTRIP_TYPE, - CPW_TYPE, - GROUNDED_CPW_TYPE, - RECTWAVEGUIDE_TYPE, - COAX_TYPE, - C_MICROSTRIP_TYPE, - STRIPLINE_TYPE, - TWISTEDPAIR_TYPE - }; + { + MICROSTRIP_TYPE, + CPW_TYPE, + GROUNDED_CPW_TYPE, + RECTWAVEGUIDE_TYPE, + COAX_TYPE, + C_MICROSTRIP_TYPE, + STRIPLINE_TYPE, + TWISTEDPAIR_TYPE + }; for( int ii = 0; ii < 8; ii++ ) m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) ); @@ -277,7 +278,7 @@ void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event ) void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { - if( aCfg == NULL ) + if( aCfg == nullptr ) return; EDA_BASE_FRAME::LoadSettings( aCfg ); @@ -321,7 +322,7 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { - if( aCfg == NULL ) + if( aCfg == nullptr ) return; EDA_BASE_FRAME::SaveSettings( aCfg ); @@ -355,11 +356,6 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) } -/** - * Function OnTranslineAnalyse - * Run a new analyse for the current transline with current parameters - * and displays the electrical parameters - */ void PCB_CALCULATOR_FRAME::OnTranslineAnalyse( wxCommandEvent& event ) { if( m_currTransLine ) @@ -370,11 +366,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineAnalyse( wxCommandEvent& event ) } -/** - * Function OnTranslineSynthetize - * Run a new synthezis for the current transline with current parameters - * and displays the geometrical parameters - */ void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event ) { if( m_currTransLine ) @@ -385,9 +376,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSynthetize( wxCommandEvent& event ) } -/* returns the full filename of the selected pcb_calculator data file - * the extension file is forced - */ const wxString PCB_CALCULATOR_FRAME::GetDataFilename() { if( m_regulators_fileNameCtrl->GetValue().IsEmpty() ) @@ -399,15 +387,12 @@ const wxString PCB_CALCULATOR_FRAME::GetDataFilename() } -/* Initialize the full filename of the selected pcb_calculator data file - * force the standard extension of the file (.pcbcalc) - * aFilename = the full filename, with or without extension - */ -void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString & aFilename) +void PCB_CALCULATOR_FRAME::SetDataFilename( const wxString& aFilename ) { if( aFilename.IsEmpty() ) + { m_regulators_fileNameCtrl->SetValue( wxEmptyString ); - + } else { wxFileName fn( aFilename ); diff --git a/pcb_calculator/regulators_funct.cpp b/pcb_calculator/regulators_funct.cpp index 7f92c91669..b4fc154e53 100644 --- a/pcb_calculator/regulators_funct.cpp +++ b/pcb_calculator/regulators_funct.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,21 +63,22 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() { switch( m_choiceRegType->GetSelection() ) { - default: - case 0: - m_bitmapRegul4pins->Show( true ); - m_bitmapRegul3pins->Show( false ); - m_RegulIadjValue->Enable( false ); - m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R2" ) ); - break; + default: + case 0: + m_bitmapRegul4pins->Show( true ); + m_bitmapRegul3pins->Show( false ); + m_RegulIadjValue->Enable( false ); + m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R2" ) ); + break; - case 1: - m_bitmapRegul4pins->Show( false ); - m_bitmapRegul3pins->Show( true ); - m_RegulIadjValue->Enable( true ); - m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) ); - break; + case 1: + m_bitmapRegul4pins->Show( false ); + m_bitmapRegul3pins->Show( true ); + m_RegulIadjValue->Enable( true ); + m_RegulFormula->SetLabel( wxT( "Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) ); + break; } + // The new icon size must be taken in account m_panelRegulators->GetSizer()->Layout(); @@ -100,6 +101,7 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) { wxString name = m_choiceRegulatorSelector->GetStringSelection(); REGULATOR_DATA * item = m_RegulatorList.GetReg( name ); + if( item ) { m_lastSelectedRegulatorName = item->m_Name; @@ -111,16 +113,12 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) m_RegulIadjValue->SetValue( value ); } - // Call RegulatorPageUpdate to enable/sisable tools, + // Call RegulatorPageUpdate to enable/disable tools, // even if no item selected RegulatorPageUpdate(); } -/* - * Called when ckicking on button Browse: - * Select a new data file, and load it on request - */ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) { wxString fullfilename = GetDataFilename(); @@ -143,6 +141,7 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) return; SetDataFilename( fullfilename ); + if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file { if( wxMessageBox( _("Do you want to load this file and replace current regulator list?" ) ) @@ -157,7 +156,6 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); SelectLastSelectedRegulator(); } - else { wxString msg; @@ -172,6 +170,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) DIALOG_REGULATOR_FORM dlg( this, wxEmptyString ); if( dlg.ShowModal() != wxID_OK ) return; + if( !dlg.IsOK() ) { wxMessageBox( _("Bad or missing parameters!") ); @@ -181,7 +180,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData(); // Add new item, if not existing - if( m_RegulatorList.GetReg( new_item->m_Name ) == NULL ) + if( m_RegulatorList.GetReg( new_item->m_Name ) == nullptr ) { // Add item in list m_RegulatorList.Add( new_item ); @@ -203,12 +202,14 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event ) { wxString name = m_choiceRegulatorSelector->GetStringSelection(); REGULATOR_DATA * item = m_RegulatorList.GetReg( name ); - if( item == NULL ) + + if( item == nullptr ) return; DIALOG_REGULATOR_FORM dlg( this, name ); dlg.CopyRegulatorDataToDialog( item ); + if( dlg.ShowModal() != wxID_OK ) return; @@ -232,6 +233,7 @@ void PCB_CALCULATOR_FRAME::OnRemoveRegulator( wxCommandEvent& event ) m_RegulatorListChanged = true; m_choiceRegulatorSelector->Clear(); m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); + if( m_lastSelectedRegulatorName == name ) m_lastSelectedRegulatorName.Empty(); @@ -243,14 +245,17 @@ void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator() { // Find last selected in regulator list: int idx = -1; - if( ! m_lastSelectedRegulatorName.IsEmpty() ) + + if( !m_lastSelectedRegulatorName.IsEmpty() ) { for( unsigned ii = 0; ii < m_RegulatorList.GetCount(); ii++ ) + { if( m_RegulatorList.m_List[ii]->m_Name == m_lastSelectedRegulatorName ) { idx = ii; break; } + } } m_choiceRegulatorSelector->SetSelection( idx ); @@ -259,18 +264,22 @@ void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator() } -// Calculate a value from the 3 other values -// Vref is given by the regulator properties, so -// we can calculate only R1, R2 or Vout void PCB_CALCULATOR_FRAME::RegulatorsSolve() { int id; + if( m_rbRegulR1->GetValue() ) + { id = 0; // for R1 calculation + } else if( m_rbRegulR2->GetValue() ) + { id = 1; // for R2 calculation + } else if( m_rbRegulVout->GetValue() ) + { id = 2; // for Vout calculation + } else { wxMessageBox( wxT("Selection error" ) ); @@ -297,9 +306,8 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve() txt = m_RegulVoutValue->GetValue(); vout = DoubleFromString(txt); - // Some tests: - if( vout < vref && id != 2) + if( vout < vref && id != 2 ) { m_RegulMessage->SetLabel( _("Vout must be greater than vref" ) ); return; @@ -307,11 +315,11 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve() if( vref == 0.0 ) { - m_RegulMessage->SetLabel( _("Vref set to 0 !" ) ); + m_RegulMessage->SetLabel( _( "Vref set to 0 !" ) ); return; } - if( (r1 < 0 && id != 0 ) || (r2 <= 0 && id != 1) ) + if( ( r1 < 0 && id != 0 ) || ( r2 <= 0 && id != 1 ) ) { m_RegulMessage->SetLabel( _("Incorrect value for R1 R2" ) ); return; @@ -323,52 +331,45 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve() // 3 terminal regulator txt = m_RegulIadjValue->GetValue(); double iadj = DoubleFromString(txt); + // iadj is given in micro amp, so convert it in amp. iadj /= 1000000; switch( id ) { - case 0: - r1 = vref * r2 / ( vout - vref - (r2 * iadj) ); - break; + case 0: + r1 = vref * r2 / ( vout - vref - ( r2 * iadj ) ); + break; - case 1: - r2 = ( vout - vref ) / ( iadj + (vref/r1) ); - break; + case 1: + r2 = ( vout - vref ) / ( iadj + ( vref / r1 ) ); + break; - case 2: - vout = vref * (r1 + r2) / r1; - vout += r2 * iadj; - break; + case 2: + vout = vref * ( r1 + r2 ) / r1; + vout += r2 * iadj; + break; } } else { // Standard 4 terminal regulator switch( id ) { - case 0: - r1 = ( vout / vref - 1 ) * r2; - break; - - case 1: - r2 = r1 / ( vout / vref - 1); - break; - - case 2: - vout = vref * (r1 + r2) / r2; - break; + case 0: r1 = ( vout / vref - 1 ) * r2; break; + case 1: r2 = r1 / ( vout / vref - 1 ); break; + case 2: vout = vref * ( r1 + r2 ) / r2; break; } } - // write values to panel: - txt.Printf(wxT("%g"), r1 / r1scale ); - m_RegulR1Value->SetValue(txt); - txt.Printf(wxT("%g"), r2 / r2scale); - m_RegulR2Value->SetValue(txt); - txt.Printf(wxT("%g"), vref); - m_RegulVrefValue->SetValue(txt); - txt.Printf(wxT("%g"), vout); - m_RegulVoutValue->SetValue(txt); + // write values to panel: + txt.Printf( wxT( "%g" ), r1 / r1scale ); + m_RegulR1Value->SetValue( txt ); + txt.Printf( wxT( "%g" ), r2 / r2scale ); + m_RegulR2Value->SetValue( txt ); + txt.Printf( wxT( "%g" ), vref ); + m_RegulVrefValue->SetValue( txt ); + txt.Printf( wxT( "%g" ), vout ); + m_RegulVoutValue->SetValue( txt ); } diff --git a/pcb_calculator/transline_dlg_funct.cpp b/pcb_calculator/transline_dlg_funct.cpp index 4eebc0a7de..33e60b83ec 100644 --- a/pcb_calculator/transline_dlg_funct.cpp +++ b/pcb_calculator/transline_dlg_funct.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2011 jean-pierre.charras - * Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,7 +35,7 @@ extern double DoubleFromString( const wxString& TextValue ); // A helper function to find the choice in a list of values // return true if a index in aList that matches aValue is found. -static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx ) +static bool findMatch( wxArrayString& aList, const wxString& aValue, int& aIdx ) { bool success = false; // Find the previous choice index: @@ -108,11 +108,6 @@ static bool findMatch(wxArrayString& aList, const wxString& aValue, int& aIdx ) } -/** - * Function OnEpsilonR_Button - * Shows a list of current relative dielectric constant(Er) - * and set the selected value in main dialog frame - */ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event ) { wxArrayString list = StandardRelativeDielectricConstantList(); @@ -131,11 +126,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event ) } -/** - * Function OnTanD_Button - * Shows a list of current dielectric loss factor (tangent delta) - * and set the selected value in main dialog frame - */ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event ) { wxArrayString list = StandardLossTangentList(); @@ -147,18 +137,13 @@ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event ) findMatch( list, prevChoiceStr, prevChoice ); int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Dielectric Loss Factor" ), list, - prevChoice, NULL ); + prevChoice, nullptr ); if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled. m_Value_TanD->SetValue( list.Item( index ).BeforeFirst( ' ' ) ); } -/** - * Function OnTranslineRho_Button - * Shows a list of current Specific resistance list (rho) - * and set the selected value in main dialog frame - */ void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event ) { wxArrayString list = StandardResistivityList(); @@ -170,7 +155,7 @@ void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event ) findMatch( list, prevChoiceStr, prevChoice ); int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Specific Resistance" ), list, - prevChoice, NULL ); + prevChoice, nullptr ); if( index >= 0 && !list.Item( index ).IsEmpty() ) // i.e. non canceled. m_Value_Rho->SetValue( list.Item( index ).BeforeFirst( ' ' ) ); @@ -186,14 +171,6 @@ struct DLG_PRM_DATA }; -/** - * Function TranslineTypeSelection - * Must be called after selection of a new transline. - * Update all values, labels and tool tips of parameters needed - * by the new transline - * Irrelevant parameters texts are blanked. - * @param aType = the transline_type_id of the new selected transline -*/ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType ) { m_currTransLineType = aType; @@ -221,17 +198,19 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType wxStaticText* left_msg_list[] = { m_left_message1, m_left_message2, m_left_message3, m_left_message4, m_left_message5, - m_left_message6, m_left_message7, NULL + m_left_message6, m_left_message7, nullptr }; + wxStaticText* msg_list[] = { - m_Message1, m_Message2, m_Message3, m_Message4, m_Message5, m_Message6, m_Message7, NULL + m_Message1, m_Message2, m_Message3, m_Message4, m_Message5, m_Message6, m_Message7, nullptr }; unsigned jj = 0; + for( ; jj < tr_ident->m_Messages.GetCount(); jj++ ) { - if( left_msg_list[jj] == NULL ) + if( left_msg_list[jj] == nullptr ) break; left_msg_list[jj]->SetLabel( tr_ident->m_Messages[jj] ); @@ -246,12 +225,12 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType } -// Init parameters dialog items + // Init parameters dialog items struct DLG_PRM_DATA substrateprms[] = { - { m_EpsilonR_label, m_Value_EpsilonR, NULL }, - { m_TanD_label, m_Value_TanD, NULL }, - { m_Rho_label, m_Value_Rho, NULL }, + { m_EpsilonR_label, m_Value_EpsilonR, nullptr }, + { m_TanD_label, m_Value_TanD, nullptr }, + { m_Rho_label, m_Value_Rho, nullptr }, { m_substrate_prm4_label, m_Substrate_prm4_Value, m_SubsPrm4_choiceUnit }, { m_substrate_prm5_label, m_Substrate_prm5_Value, m_SubsPrm5_choiceUnit }, { m_substrate_prm6_label, m_Substrate_prm6_Value, m_SubsPrm6_choiceUnit }, @@ -259,7 +238,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType { m_substrate_prm8_label, m_Substrate_prm8_Value, m_SubsPrm8_choiceUnit }, { m_substrate_prm9_label, m_Substrate_prm9_Value, m_SubsPrm9_choiceUnit } }; - #define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0])) + +#define substrateprms_cnt (sizeof(substrateprms)/sizeof(substrateprms[0])) struct DLG_PRM_DATA physprms[] = { @@ -267,7 +247,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType { m_phys_prm2_label, m_Phys_prm2_Value, m_choiceUnit_Param2 }, { m_phys_prm3_label, m_Phys_prm3_Value, m_choiceUnit_Param3 } }; - #define physprms_cnt (sizeof(physprms)/sizeof(physprms[0])) + +#define physprms_cnt (sizeof(physprms)/sizeof(physprms[0])) struct DLG_PRM_DATA elecprms[] = { @@ -275,13 +256,15 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType { m_elec_prm2_label, m_Elec_prm2_Value, m_choiceUnit_ElecPrm2 }, { m_elec_prm3_label, m_Elec_prm3_Value, m_choiceUnit_ElecPrm3 } }; - #define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0])) + +#define elecprms_cnt (sizeof(elecprms)/sizeof(elecprms[0])) struct DLG_PRM_DATA frequencyprms[] = { { m_Frequency_label,m_Value_Frequency_Ctrl, m_choiceUnit_Frequency } }; - #define frequencyprms_cnt (sizeof(frequencyprms)/sizeof(frequencyprms[0])) + +#define frequencyprms_cnt (sizeof(frequencyprms)/sizeof(frequencyprms[0])) unsigned idxsubs = 0; unsigned idxphys = 0; @@ -291,7 +274,8 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType for( unsigned ii = 0; ii < tr_ident->GetPrmsCount(); ii++ ) { TRANSLINE_PRM* prm = tr_ident->GetPrm( ii ); - struct DLG_PRM_DATA * data = NULL; + struct DLG_PRM_DATA * data = nullptr; + switch( prm->m_Type ) { case PRM_TYPE_SUBS: @@ -408,11 +392,7 @@ void PCB_CALCULATOR_FRAME::TranslineTypeSelection( enum TRANSLINE_TYPE_ID aType } } -/** - * Function TransfDlgDataToTranslineParams - * Read values entered in dialog frame, and copy these values - * in current transline parameters, converted in normalized units - */ + void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams() { TRANSLINE_IDENT* tr_ident = m_transline_list[m_currTransLineType]; @@ -437,10 +417,6 @@ void PCB_CALCULATOR_FRAME::TransfDlgDataToTranslineParams() } -/** - * Function OnTranslineSelection - * Called on new transmission line selection - */ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event ) { enum TRANSLINE_TYPE_ID id = (enum TRANSLINE_TYPE_ID) event.GetSelection(); @@ -454,11 +430,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event ) } -/** - * Function OnTransLineResetButtonClick - * Called when the user clicks the reset button. This sets - * the parameters to their default values. - */ void PCB_CALCULATOR_FRAME::OnTransLineResetButtonClick( wxCommandEvent& event ) { TranslineTypeSelection( DEFAULT_TYPE ); diff --git a/pcb_calculator/transline_ident.cpp b/pcb_calculator/transline_ident.cpp index d5c58ca89c..10589e3c47 100644 --- a/pcb_calculator/transline_ident.cpp +++ b/pcb_calculator/transline_ident.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras - * Copyright (C) 2004-2014 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -42,16 +42,9 @@ #include "transline_ident.h" -/* - * TRANSLINE_PRM - * A class to handle one parameter of transline - */ -TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, - const char* aKeywordCfg, - const wxString& aDlgLabel, - const wxString& aToolTip, - double aValue, - bool aConvUnit ) +TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg, + const wxString& aDlgLabel, const wxString& aToolTip, + double aValue, bool aConvUnit ) { m_Type = aType; m_Id = aId; @@ -60,8 +53,8 @@ TRANSLINE_PRM::TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, m_ToolTip = aToolTip; m_Value = aValue; m_ConvUnit = aConvUnit; - m_ValueCtrl = NULL; - m_UnitCtrl = NULL; + m_ValueCtrl = nullptr; + m_UnitCtrl = nullptr; m_UnitSelection = 0; m_NormalizedValue = 0; } @@ -85,23 +78,11 @@ double TRANSLINE_PRM::FromUserUnit() } -/* - * TRANSLINE_IDENT - * A class to handle a list of parameters of a given transline - * Important note: - * the first string of TRANSLINE_PRM (m_KeyWord) is a keyword in config file. - * it can contain only ASCII7 chars - * the second string of TRANSLINE_PRM (m_DlgLabel) is a string translated for dialog, - * so mark it for translation (m_KeyWord and m_DlgLabel are usually the same in English) - * and of course do not mark translatable m_DlgLabel that obviously cannot be translated, - * like "H" or "H_t" - */ - TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) { m_Type = aType; // The type of transline handled - m_Icon = NULL; // An xpm icon to display in dialogs - m_TLine = NULL; // The TRANSLINE itself + m_Icon = nullptr; // An xpm icon to display in dialogs + m_TLine = nullptr; // The TRANSLINE itself m_HasPrmSelection = false; // true if selection of parameters must be enabled in dialog menu // Add common prms: @@ -118,7 +99,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) // Default value is for copper AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, RHO_PRM, "Rho", wxT( "ρ" ), - _( "Electrical resistivity or specific electrical resistance of conductor (ohm*meter)" ), + _( "Electrical resistivity or specific electrical resistance of " + "conductor (ohm*meter)" ), 1.72e-8, false ) ); // Default value is in GHz @@ -149,10 +131,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) "Rough", _( "Roughness" ), _( "Conductor roughness" ), 0.0, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM, - "mu Rel S", wxString::Format( wxT( "μ(%s)" ), _( "substrate" ) ), + "mu Rel S", wxString::Format( wxT( "μ(%s)" ), + _( "substrate" ) ), _( "Relative permeability (mu) of substrate" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -183,7 +167,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM, "T", "T", _( "Strip thickness" ), 0.035, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -216,7 +201,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM, "T", "T", _( "Strip thickness" ), 0.035, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -248,10 +234,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) m_Messages.Add( _( "TM-modes:" ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM, - "mu Rel I", wxString::Format( wxT( "μ(%s)" ), _( "insulator" ) ), + "mu Rel I", wxString::Format( wxT( "μ(%s)" ), + _( "insulator" ) ), _( "Relative permeability (mu) of insulator" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -281,10 +269,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) m_Messages.Add( _( "TM-modes:" ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MUR_PRM, - "mu Rel I", wxString::Format( wxT( "μ(%s)" ), _( "insulator" ) ), + "mu Rel I", wxString::Format( wxT( "μ(%s)" ), + _( "insulator" ) ), _( "Relative permeability (mu) of insulator" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -327,7 +317,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) "Rough", _( "Roughness" ), _( "Conductor roughness" ), 0.0, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); @@ -340,10 +331,12 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_E_PRM, "Zeven", _( "Zeven" ), - _( "Even mode impedance (lines driven by common voltages)" ), 50.0, true ) ); + _( "Even mode impedance (lines driven by common voltages)" ), + 50.0, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, Z0_O_PRM, "Zodd", _( "Zodd" ), - _( "Odd mode impedance (lines driven by opposite (differential) voltages)" ), 50.0, true ) ); + _( "Odd mode impedance (lines driven by opposite " + "(differential) voltages)" ), 50.0, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_ELEC, ANG_L_PRM, "Ang_l", "Ang_l", _( "Electrical length" ), 0.0, true ) ); @@ -366,7 +359,8 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, T_PRM, "T", "T", _( "Strip thickness" ), 0.035, true ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_WIDTH_PRM, @@ -395,11 +389,13 @@ TRANSLINE_IDENT::TRANSLINE_IDENT( enum TRANSLINE_TYPE_ID aType ) "Twists", _( "Twists" ), _( "Number of twists per length" ), 0.0, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, MURC_PRM, - "mu Rel C", wxString::Format( wxT( "μ(%s)" ), _( "conductor" ) ), + "mu Rel C", wxString::Format( wxT( "μ(%s)" ), + _( "conductor" ) ), _( "Relative permeability (mu) of conductor" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_SUBS, TWISTEDPAIR_EPSILONR_ENV_PRM, - "ErEnv", wxString::Format( wxT( "εr(%s)" ), _( "environment" ) ), + "ErEnv", wxString::Format( wxT( "εr(%s)" ), + _( "environment" ) ), _( "Relative permittivity of environment" ), 1, false ) ); AddPrm( new TRANSLINE_PRM( PRM_TYPE_PHYS, PHYS_DIAM_IN_PRM, diff --git a/pcb_calculator/transline_ident.h b/pcb_calculator/transline_ident.h index bfb5484f21..a9277846c2 100644 --- a/pcb_calculator/transline_ident.h +++ b/pcb_calculator/transline_ident.h @@ -53,6 +53,10 @@ enum PRM_TYPE { PRM_TYPE_FREQUENCY }; + +/** + * A class to handle one parameter of transline. + */ class TRANSLINE_PRM { public: @@ -62,12 +66,10 @@ public: * @param aDlgLabel is a I18n string used to identify the parameter in dialog. * usually aDlgLabel is same as aKeywordCfg, but translatable. */ - TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, - const char* aKeywordCfg = "", + TRANSLINE_PRM( PRM_TYPE aType, PRMS_ID aId, const char* aKeywordCfg = "", const wxString& aDlgLabel = wxEmptyString, const wxString& aToolTip = wxEmptyString, - double aValue = 0.0, - bool aConvUnit = false ); + double aValue = 0.0, bool aConvUnit = false ); double ToUserUnit(); double FromUserUnit(); @@ -86,8 +88,14 @@ public: }; -// A class to handle the list of available transm. lines -// with messages, tooptips ... +/** + * A class to handle a list of parameters of a given transline. + * + * @note The first string of TRANSLINE_PRM (m_KeyWord) is a keyword in config file. + * It can contain only ASCII7 chars. The second string of TRANSLINE_PRM is a + * string translated for dialog so mark it for translation. Do not mark translatable + * m_DlgLabel that obviously cannot be translated, like "H" or "H_t". + */ class TRANSLINE_IDENT { public: @@ -105,7 +113,7 @@ public: if( aIdx < m_prms_List.size() ) return m_prms_List[aIdx]; else - return NULL; + return nullptr; } unsigned GetPrmsCount() const diff --git a/plugins/3d/idf/s3d_plugin_idf.cpp b/plugins/3d/idf/s3d_plugin_idf.cpp index 273cb249dd..95c6114e05 100644 --- a/plugins/3d/idf/s3d_plugin_idf.cpp +++ b/plugins/3d/idf/s3d_plugin_idf.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2017 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -52,24 +53,41 @@ // read and instantiate an IDF component outline static SCENEGRAPH* loadIDFOutline( const wxString& aFileName ); + + // read and render an IDF board assembly static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ); + + // model a single extruded outline // idxColor = color index to use // aParent = parent SCENEGRAPH object, if any static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE* aParent ); + + // model the board extrusion static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent ); + + // model all included components static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent ); + + // model any .OTHER_OUTLINE items static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent ); + + // convert the IDF outline to VRML intermediate data static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >* items ); + + // convert IDF segment data to VRML segment data static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg ); + + // convert the VRML intermediate data into SG* data -static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, double bottom ); +static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, + double bottom ); class LOCALESWITCH @@ -105,63 +123,63 @@ static SGNODE* getColor( IFSG_SHAPE& shape, int colorIdx ) // green for PCB material.SetSpecular( 0.13f, 0.81f, 0.22f ); material.SetDiffuse( 0.13f, 0.81f, 0.22f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; case 1: // magenta material.SetSpecular( 0.8f, 0.0f, 0.8f ); material.SetDiffuse( 0.6f, 0.0f, 0.6f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; case 2: // red material.SetSpecular( 0.69f, 0.14f, 0.14f ); material.SetDiffuse( 0.69f, 0.14f, 0.14f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; case 3: // orange material.SetSpecular( 1.0f, 0.44f, 0.0f ); material.SetDiffuse( 1.0f, 0.44f, 0.0f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; case 4: // yellow material.SetSpecular( 0.93f, 0.94f, 0.16f ); material.SetDiffuse( 0.93f, 0.94f, 0.16f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; case 5: // blue material.SetSpecular( 0.1f, 0.11f, 0.88f ); material.SetDiffuse( 0.1f, 0.11f, 0.88f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; default: // violet material.SetSpecular( 0.32f, 0.07f, 0.64f ); material.SetDiffuse( 0.32f, 0.07f, 0.64f ); + // default ambient intensity material.SetShininess( 0.3f ); - break; } @@ -178,8 +196,8 @@ const char* GetKicadPluginName( void ) } -void GetPluginVersion( unsigned char* Major, - unsigned char* Minor, unsigned char* Patch, unsigned char* Revision ) +void GetPluginVersion( unsigned char* Major, unsigned char* Minor, unsigned char* Patch, + unsigned char* Revision ) { if( Major ) *Major = PLUGIN_3D_IDF_MAJOR; @@ -192,10 +210,9 @@ void GetPluginVersion( unsigned char* Major, if( Revision ) *Revision = PLUGIN_3D_IDF_REVNO; - - return; } + // number of extensions supported #ifdef _WIN32 #define NEXTS 2 @@ -203,12 +220,15 @@ void GetPluginVersion( unsigned char* Major, #define NEXTS 4 #endif + // number of filter sets supported #define NFILS 2 + static char ext0[] = "idf"; static char ext1[] = "emn"; + #ifdef _WIN32 static char fil0[] = "IDF (*.idf)|*.idf"; static char fil1[] = "IDF BRD v2/v3 (*.emn)|*.emn"; @@ -235,8 +255,6 @@ static struct FILE_DATA extensions[2] = ext2; extensions[3] = ext3; #endif - - return; } } file_data; @@ -251,7 +269,7 @@ int GetNExtensions( void ) char const* GetModelExtension( int aIndex ) { if( aIndex < 0 || aIndex >= NEXTS ) - return NULL; + return nullptr; return file_data.extensions[aIndex]; } @@ -266,7 +284,7 @@ int GetNFilters( void ) char const* GetFileFilter( int aIndex ) { if( aIndex < 0 || aIndex >= NFILS ) - return NULL; + return nullptr; return file_data.filters[aIndex]; } @@ -281,15 +299,15 @@ bool CanRender( void ) SCENEGRAPH* Load( char const* aFileName ) { - if( NULL == aFileName ) - return NULL; + if( nullptr == aFileName ) + return nullptr; wxFileName fname; fname.Assign( wxString::FromUTF8Unchecked( aFileName ) ); wxString ext = fname.GetExt(); - SCENEGRAPH* data = NULL; + SCENEGRAPH* data = nullptr; if( !ext.Cmp( wxT( "idf" ) ) || !ext.Cmp( wxT( "IDF" ) ) ) { @@ -302,16 +320,16 @@ SCENEGRAPH* Load( char const* aFileName ) } // DEBUG: WRITE OUT IDF FILE TO CONFIRM NORMALS - #if defined( DEBUG_IDF ) && DEBUG_IDF > 3 +#if defined( DEBUG_IDF ) && DEBUG_IDF > 3 if( data ) { wxFileName fn( aFileName ); wxString output = wxT( "_idf-" ); output.append( fn.GetName() ); - output.append( wxT(".wrl") ); - S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*)(data), true, true ); + output.append( wxT( ".wrl" ) ); + S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*) ( data ), true, true ); } - #endif +#endif return data; } @@ -339,28 +357,28 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >* if( nvcont < 0 ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] cannot create an outline"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( (*scont)->size() < 1 ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] invalid contour: no vertices"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -369,20 +387,21 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >* eseg = (*scont)->end(); iseg = 0; + while( sseg != eseg ) { lseg = **sseg; if( !addSegment( model, &lseg, nvcont, iseg ) ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] cannot add segment"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -409,14 +428,14 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg { if( iseg != 0 ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] adding a circle to an existing vertex list"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -437,9 +456,10 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg } -static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, double bottom ) +static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, double top, + double bottom ) { - vpcb.Tesselate( NULL ); + vpcb.Tesselate( nullptr ); std::vector< double > vertices; std::vector< int > idxPlane; std::vector< int > idxSide; @@ -453,30 +473,30 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do if( !vpcb.Get3DTriangles( vertices, idxPlane, idxSide, top, bottom ) ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] no vertex data"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( ( idxPlane.size() % 3 ) || ( idxSide.size() % 3 ) ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } std::vector< SGPOINT > vlist; @@ -487,14 +507,24 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do vlist.emplace_back( vertices[j], vertices[j+1], vertices[j+2] ); // create the intermediate scenegraph - IFSG_TRANSFORM* tx0 = new IFSG_TRANSFORM( aParent ); // tx0 = Transform for this outline - IFSG_SHAPE* shape = new IFSG_SHAPE( *tx0 ); // shape will hold (a) all vertices and (b) a local list of normals - IFSG_FACESET* face = new IFSG_FACESET( *shape ); // this face shall represent the top and bottom planes - IFSG_COORDS* cp = new IFSG_COORDS( *face ); // coordinates for all faces + IFSG_TRANSFORM* tx0 = new IFSG_TRANSFORM( aParent ); // tx0 = Transform for this outline + + // shape will hold (a) all vertices and (b) a local list of normals + IFSG_SHAPE* shape = new IFSG_SHAPE( *tx0 ); + + // this face shall represent the top and bottom planes + IFSG_FACESET* face = new IFSG_FACESET( *shape ); + + // coordinates for all faces + IFSG_COORDS* cp = new IFSG_COORDS( *face ); cp->SetCoordsList( nvert, &vlist[0] ); - IFSG_COORDINDEX* coordIdx = new IFSG_COORDINDEX( *face ); // coordinate indices for top and bottom planes only + + // coordinate indices for top and bottom planes only. + IFSG_COORDINDEX* coordIdx = new IFSG_COORDINDEX( *face ); coordIdx->SetIndices( idxPlane.size(), &idxPlane[0] ); - IFSG_NORMALS* norms = new IFSG_NORMALS( *face ); // normals for the top and bottom planes + + // normals for the top and bottom planes. + IFSG_NORMALS* norms = new IFSG_NORMALS( *face ); // number of TOP (and bottom) vertices j = nvert / 2; @@ -573,16 +603,16 @@ static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE* if( !getOutlineModel( vpcb, outline->GetOutlines() ) ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] no valid outline data"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } vpcb.EnsureWinding( 0, false ); @@ -607,13 +637,13 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName ) { LOCALESWITCH switcher; IDF3_BOARD brd( IDF3::CAD_ELEC ); - IDF3_COMP_OUTLINE* outline = NULL; + IDF3_COMP_OUTLINE* outline = nullptr; outline = brd.GetComponentOutline( aFileName ); - if( NULL == outline ) + if( nullptr == outline ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -623,12 +653,12 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName ) ostr << aFileName << "'"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - SCENEGRAPH* data = addOutline( outline, -1, NULL ); + SCENEGRAPH* data = addOutline( outline, -1, nullptr ); return data; } @@ -642,7 +672,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ) // note: if the IDF model is defective no outline substitutes shall be made if( !brd.ReadFile( aFileName, true ) ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -651,9 +681,9 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ) ostr << " * [INFO] IDF file '" << aFileName.ToUTF8() << "'"; wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } IFSG_TRANSFORM tx0( true ); @@ -663,7 +693,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ) bool noComp = false; bool noOther = false; - if( NULL == makeBoard( brd, topNode ) ) + if( nullptr == makeBoard( brd, topNode ) ) noBoard = true; if( !makeComponents( brd, topNode ) ) @@ -675,7 +705,7 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ) if( noBoard && noComp && noOther ) { tx0.Destroy(); - return NULL; + return nullptr; } return (SCENEGRAPH*) topNode; @@ -684,18 +714,18 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName ) static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent ) { - if( NULL == aParent ) - return NULL; + if( nullptr == aParent ) + return nullptr; VRML_LAYER vpcb; // check if no board outline if( brd.GetBoardOutlinesSize() < 1 ) - return NULL; + return nullptr; if( !getOutlineModel( vpcb, brd.GetBoardOutline()->GetOutlines() ) ) - return NULL; + return nullptr; vpcb.EnsureWinding( 0, false ); @@ -747,7 +777,7 @@ static SCENEGRAPH* makeBoard( IDF3_BOARD& brd, SGNODE* aParent ) static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent ) { - if( NULL == aParent ) + if( nullptr == aParent ) return false; int ncomponents = 0; @@ -798,28 +828,27 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent ) pout = (IDF3_COMP_OUTLINE*)((*so)->GetOutline()); - if( NULL == pout ) + if( nullptr == pout ) { ++so; continue; } dataItem = dataMap.find( pout->GetUID() ); - SCENEGRAPH* sg = NULL; + SCENEGRAPH* sg = nullptr; if( dataItem == dataMap.end() ) { - sg = addOutline( pout, -1, NULL ); + sg = addOutline( pout, -1, nullptr ); - if( NULL == sg ) + if( nullptr == sg ) { ++so; continue; } ++ncomponents; - dataMap.insert( std::pair< std::string, SGNODE* > - ( pout->GetUID(), (SGNODE*)sg ) ); + dataMap.insert( std::pair< std::string, SGNODE* >( pout->GetUID(), (SGNODE*)sg ) ); } else { @@ -830,7 +859,7 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent ) IFSG_TRANSFORM txN( false ); txN.Attach( (SGNODE*)sg ); - if( NULL == txN.GetParent() ) + if( nullptr == txN.GetParent() ) tx0.AddChildNode( txN ); else tx0.AddRefNode( txN ); @@ -869,7 +898,7 @@ static bool makeComponents( IDF3_BOARD& brd, SGNODE* aParent ) static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent ) { - if( NULL == aParent ) + if( nullptr == aParent ) return false; VRML_LAYER vpcb; @@ -922,7 +951,7 @@ static bool makeOtherOutlines( IDF3_BOARD& brd, SGNODE* aParent ) top = bot + pout->GetThickness(); } - if( NULL == vrmlToSG( vpcb, -1, aParent, top, bot ) ) + if( nullptr == vrmlToSG( vpcb, -1, aParent, top, bot ) ) { vpcb.Clear(); ++sc; diff --git a/plugins/3d/oce/loadmodel.cpp b/plugins/3d/oce/loadmodel.cpp index 3c11770f1b..0aae47134f 100644 --- a/plugins/3d/oce/loadmodel.cpp +++ b/plugins/3d/oce/loadmodel.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo - * Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -96,13 +96,16 @@ typedef std::pair< std::string, std::vector< SGNODE* > > NODEITEM; struct DATA; bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items ); + std::vector< SGNODE* >* items ); + bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items ); + std::vector< SGNODE* >* items ); + bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items, Quantity_Color* color ); + std::vector< SGNODE* >* items, Quantity_Color* color ); + struct DATA { @@ -120,8 +123,8 @@ struct DATA DATA() { - scene = NULL; - defaultColor = NULL; + scene = nullptr; + defaultColor = nullptr; refColor.SetValues( Quantity_NOC_BLACK ); renderBoth = false; hasSolid = false; @@ -137,7 +140,7 @@ struct DATA while( sC != eC ) { - if( NULL == S3D::GetSGNodeParent( sC->second ) ) + if( nullptr == S3D::GetSGNodeParent( sC->second ) ) S3D::DestroyNode( sC->second ); ++sC; @@ -146,7 +149,7 @@ struct DATA colors.clear(); } - if( defaultColor && NULL == S3D::GetSGNodeParent( defaultColor ) ) + if( defaultColor && nullptr == S3D::GetSGNodeParent( defaultColor ) ) S3D::DestroyNode(defaultColor); // destroy any faces with no parent @@ -157,7 +160,7 @@ struct DATA while( sF != eF ) { - if( NULL == S3D::GetSGNodeParent( sF->second ) ) + if( nullptr == S3D::GetSGNodeParent( sF->second ) ) S3D::DestroyNode( sF->second ); ++sF; @@ -179,7 +182,7 @@ struct DATA while( sV != eV ) { - if( NULL == S3D::GetSGNodeParent( *sV ) ) + if( nullptr == S3D::GetSGNodeParent( *sV ) ) S3D::DestroyNode( *sV ); ++sV; @@ -194,14 +197,12 @@ struct DATA if( scene ) S3D::DestroyNode(scene); - - return; } // find collection of tagged nodes bool GetShape( const std::string& id, std::vector< SGNODE* >*& listPtr ) { - listPtr = NULL; + listPtr = nullptr; NODEMAP::iterator item; item = shapes.find( id ); @@ -219,7 +220,7 @@ struct DATA item = faces.find( id ); if( item == faces.end() ) - return NULL; + return nullptr; return item->second; } @@ -227,7 +228,7 @@ struct DATA // return color if found; if not found, create SGAPPEARANCE SGNODE* GetColor( Quantity_Color* colorObj ) { - if( NULL == colorObj ) + if( nullptr == colorObj ) { if( defaultColor ) return defaultColor; @@ -279,7 +280,7 @@ FormatType fileType( const char* aFileName ) return FMT_NONE; if( fname.GetExt().MakeUpper().EndsWith( "STPZ" ) || - fname.GetExt().MakeUpper().EndsWith( "GZ" ) ) + fname.GetExt().MakeUpper().EndsWith( "GZ" ) ) return FMT_STPZ; char iline[82]; @@ -344,8 +345,6 @@ void getTag( TDF_Label& label, std::string& aTag ) aTag.append( 1, *bI ); ++bI; } - - return; } @@ -372,7 +371,7 @@ bool getColor( DATA& data, TDF_Label label, Quantity_Color& color ) void addItems( SGNODE* parent, std::vector< SGNODE* >* lp ) { - if( NULL == lp ) + if( nullptr == lp ) return; std::vector< SGNODE* >::iterator sL = lp->begin(); @@ -383,19 +382,17 @@ void addItems( SGNODE* parent, std::vector< SGNODE* >* lp ) { item = *sL; - if( NULL == S3D::GetSGNodeParent( item ) ) + if( nullptr == S3D::GetSGNodeParent( item ) ) S3D::AddSGNodeChild( parent, item ); else S3D::AddSGNodeRef( parent, item ); ++sL; } - - return; } -bool readIGES( Handle(TDocStd_Document)& m_doc, const char* fname ) +bool readIGES( Handle( TDocStd_Document ) & m_doc, const char* fname ) { IGESCAFControl_Reader reader; IFSelect_ReturnStatus stat = reader.ReadFile( fname ); @@ -441,9 +438,9 @@ bool readSTEP( Handle(TDocStd_Document)& m_doc, const char* fname ) return false; // set other translation options - reader.SetColorMode(true); // use model colors - reader.SetNameMode(false); // don't use label names - reader.SetLayerMode(false); // ignore LAYER data + reader.SetColorMode( true ); // use model colors + reader.SetNameMode( false ); // don't use label names + reader.SetLayerMode( false ); // ignore LAYER data if ( !reader.Transfer( m_doc ) ) { @@ -539,27 +536,30 @@ SCENEGRAPH* LoadModel( char const* filename ) switch( modelFmt ) { - case FMT_IGES: - data.renderBoth = true; + case FMT_IGES: + data.renderBoth = true; - if( !readIGES( data.m_doc, filename ) ) - return NULL; - break; + if( !readIGES( data.m_doc, filename ) ) + return nullptr; - case FMT_STEP: - if( !readSTEP( data.m_doc, filename ) ) - return NULL; - break; + break; - case FMT_STPZ: - if( !readSTEPZ( data.m_doc, filename ) ) - return NULL; - break; + case FMT_STEP: + if( !readSTEP( data.m_doc, filename ) ) + return nullptr; + + break; + + case FMT_STPZ: + if( !readSTEPZ( data.m_doc, filename ) ) + return nullptr; + + break; - default: - return NULL; - break; + default: + return nullptr; + break; } data.m_assy = XCAFDoc_DocumentTool::ShapeTool( data.m_doc->Main() ); @@ -579,21 +579,21 @@ SCENEGRAPH* LoadModel( char const* filename ) while( id <= nshapes ) { - TopoDS_Shape shape = data.m_assy->GetShape( frshapes.Value(id) ); + TopoDS_Shape shape = data.m_assy->GetShape( frshapes.Value( id ) ); - if ( !shape.IsNull() && processNode( shape, data, data.scene, NULL ) ) + if ( !shape.IsNull() && processNode( shape, data, data.scene, nullptr ) ) ret = true; ++id; }; if( !ret ) - return NULL; + return nullptr; SCENEGRAPH* scene = (SCENEGRAPH*)data.scene; // DEBUG: WRITE OUT VRML2 FILE TO CONFIRM STRUCTURE - #if ( defined( DEBUG_OCE ) && DEBUG_OCE > 3 ) +#if ( defined( DEBUG_OCE ) && DEBUG_OCE > 3 ) if( data.scene ) { wxFileName fn( wxString::FromUTF8Unchecked( filename ) ); @@ -605,20 +605,20 @@ SCENEGRAPH* LoadModel( char const* filename ) output = wxT( "_iges-" ); output.append( fn.GetName() ); - output.append( wxT(".wrl") ); + output.append( wxT( ".wrl" ) ); S3D::WriteVRML( output.ToUTF8(), true, data.scene, true, true ); } - #endif +#endif // set to NULL to prevent automatic destruction of the scene data - data.scene = NULL; + data.scene = nullptr; return scene; } bool processShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items, Quantity_Color* color ) + std::vector< SGNODE* >* items, Quantity_Color* color ) { TopoDS_Iterator it; bool ret = false; @@ -636,13 +636,13 @@ bool processShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items ) + std::vector< SGNODE* >* items ) { TDF_Label label; data.hasSolid = true; std::string partID; Quantity_Color col; - Quantity_Color* lcolor = NULL; + Quantity_Color* lcolor = nullptr; // Search the whole model first to make sure something exists (may or may not have color) if( !data.m_assy->Search( shape, label ) ) @@ -666,7 +666,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, if( !found_color ) { if( data.m_assy->Search( shape, label, Standard_False, Standard_True, Standard_True ) && - getColor( data, label, col ) ) + getColor( data, label, col ) ) { found_color = true; lcolor = &col; @@ -676,19 +676,22 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, // If the components do not have color information, search all components without location if( !found_color ) { - if( data.m_assy->Search( shape, label, Standard_False, Standard_False, Standard_True ) && - getColor( data, label, col ) ) + if( data.m_assy->Search( shape, label, Standard_False, Standard_False, + Standard_True ) && + getColor( data, label, col ) ) { found_color = true; lcolor = &col; } } - // Our last chance to find the color looks for color as a subshape of top-level simple shapes + // Our last chance to find the color looks for color as a subshape of top-level simple + // shapes. if( !found_color ) { - if( data.m_assy->Search( shape, label, Standard_False, Standard_False, Standard_False ) && - getColor( data, label, col ) ) + if( data.m_assy->Search( shape, label, Standard_False, Standard_False, + Standard_False ) && + getColor( data, label, col ) ) { found_color = true; lcolor = &col; @@ -716,7 +719,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, childNode.SetRotation( SGVECTOR( axis.X(), axis.Y(), axis.Z() ), angle ); } - std::vector< SGNODE* >* component = NULL; + std::vector< SGNODE* >* component = nullptr; if( !partID.empty() ) data.GetShape( partID, component ); @@ -725,7 +728,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, { addItems( pptr, component ); - if( NULL != items ) + if( nullptr != items ) items->push_back( pptr ); } @@ -742,7 +745,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, if( !ret ) childNode.Destroy(); - else if( NULL != items ) + else if( nullptr != items ) items->push_back( pptr ); return ret; @@ -750,7 +753,7 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items ) + std::vector< SGNODE* >* items ) { TopoDS_Iterator it; IFSG_TRANSFORM childNode( parent ); @@ -778,35 +781,39 @@ bool processComp( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, switch( stype ) { - case TopAbs_COMPOUND: - case TopAbs_COMPSOLID: - if( processComp( subShape, data, pptr, items ) ) - ret = true; - break; + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + if( processComp( subShape, data, pptr, items ) ) + ret = true; - case TopAbs_SOLID: - if( processSolid( subShape, data, pptr, items ) ) - ret = true; - break; + break; - case TopAbs_SHELL: - if( processShell( subShape, data, pptr, items, NULL ) ) - ret = true; - break; + case TopAbs_SOLID: + if( processSolid( subShape, data, pptr, items ) ) + ret = true; - case TopAbs_FACE: - if( processFace( TopoDS::Face( subShape ), data, pptr, items, NULL ) ) - ret = true; - break; + break; - default: - break; + case TopAbs_SHELL: + if( processShell( subShape, data, pptr, items, nullptr ) ) + ret = true; + + break; + + case TopAbs_FACE: + if( processFace( TopoDS::Face( subShape ), data, pptr, items, nullptr ) ) + ret = true; + + break; + + default: + break; } } if( !ret ) childNode.Destroy(); - else if( NULL != items ) + else if( nullptr != items ) items->push_back( pptr ); return ret; @@ -822,29 +829,33 @@ bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, switch( stype ) { - case TopAbs_COMPOUND: - case TopAbs_COMPSOLID: - if( processComp( shape, data, parent, items ) ) - ret = true; - break; + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + if( processComp( shape, data, parent, items ) ) + ret = true; - case TopAbs_SOLID: - if( processSolid( shape, data, parent, items ) ) - ret = true; - break; + break; - case TopAbs_SHELL: - if( processShell( shape, data, parent, items, NULL ) ) - ret = true; - break; + case TopAbs_SOLID: + if( processSolid( shape, data, parent, items ) ) + ret = true; - case TopAbs_FACE: - if( processFace( TopoDS::Face( shape ), data, parent, items, NULL ) ) - ret = true; - break; + break; - default: - break; + case TopAbs_SHELL: + if( processShell( shape, data, parent, items, nullptr ) ) + ret = true; + + break; + + case TopAbs_FACE: + if( processFace( TopoDS::Face( shape ), data, parent, items, nullptr ) ) + ret = true; + + break; + + default: + break; } return ret; @@ -852,13 +863,13 @@ bool processNode( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, - std::vector< SGNODE* >* items, Quantity_Color* color ) + std::vector< SGNODE* >* items, Quantity_Color* color ) { if( Standard_True == face.IsNull() ) return false; bool reverse = ( face.Orientation() == TopAbs_REVERSED ); - SGNODE* ashape = NULL; + SGNODE* ashape = nullptr; std::string partID; TDF_Label label; @@ -877,12 +888,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, if( ashape ) { - if( NULL == S3D::GetSGNodeParent( ashape ) ) + if( nullptr == S3D::GetSGNodeParent( ashape ) ) S3D::AddSGNodeChild( parent, ashape ); else S3D::AddSGNodeRef( parent, ashape ); - if( NULL != items ) + if( nullptr != items ) items->push_back( ashape ); if( useBothSides ) @@ -891,12 +902,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, id2.append( "b" ); SGNODE* shapeB = data.GetFace( id2 ); - if( NULL == S3D::GetSGNodeParent( shapeB ) ) + if( nullptr == S3D::GetSGNodeParent( shapeB ) ) S3D::AddSGNodeChild( parent, shapeB ); else S3D::AddSGNodeRef( parent, shapeB ); - if( NULL != items ) + if( nullptr != items ) items->push_back( shapeB ); } @@ -905,12 +916,12 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, TopLoc_Location loc; Standard_Boolean isTessellate (Standard_False); - Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation( face, loc ); + Handle( Poly_Triangulation ) triangulation = BRep_Tool::Triangulation( face, loc ); if( triangulation.IsNull() || triangulation->Deflection() > USER_PREC + Precision::Confusion() ) isTessellate = Standard_True; - if (isTessellate) + if( isTessellate ) { BRepMesh_IncrementalMesh IM(face, USER_PREC, Standard_False, USER_ANGLE ); triangulation = BRep_Tool::Triangulation( face, loc ); @@ -944,7 +955,7 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, IFSG_COORDS vcoords( vface ); IFSG_COORDINDEX coordIdx( vface ); - if( NULL == S3D::GetSGNodeParent( ocolor ) ) + if( nullptr == S3D::GetSGNodeParent( ocolor ) ) S3D::AddSGNodeChild( vshape.GetRawPtr(), ocolor ); else S3D::AddSGNodeRef( vshape.GetRawPtr(), ocolor ); @@ -957,13 +968,13 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, std::vector< int > indices2; gp_Trsf tx; - for(int i = 1; i <= triangulation->NbNodes(); i++) + for( int i = 1; i <= triangulation->NbNodes(); i++ ) { gp_XYZ v( arrPolyNodes(i).Coord() ); vertices.emplace_back( v.X(), v.Y(), v.Z() ); } - for(int i = 1; i <= triangulation->NbTriangles(); i++) + for( int i = 1; i <= triangulation->NbTriangles(); i++ ) { int a, b, c; arrTriangles( i ).Get( a, b, c ); @@ -974,7 +985,9 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, int tmp = b - 1; b = c - 1; c = tmp; - } else { + } + else + { b--; c--; } @@ -993,12 +1006,11 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, vcoords.SetCoordsList( vertices.size(), &vertices[0] ); coordIdx.SetIndices( indices.size(), &indices[0] ); - vface.CalcNormals( NULL ); + vface.CalcNormals( nullptr ); vshape.SetParent( parent ); if( !partID.empty() ) - data.faces.insert( std::pair< std::string, - SGNODE* >( partID, vshape.GetRawPtr() ) ); + data.faces.insert( std::pair< std::string, SGNODE* >( partID, vshape.GetRawPtr() ) ); // The outer surface of an IGES model is indeterminate so // we must render both sides of a surface. @@ -1014,12 +1026,11 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, vcoords2.SetCoordsList( vertices.size(), &vertices[0] ); coordIdx2.SetIndices( indices2.size(), &indices2[0] ); - vface2.CalcNormals( NULL ); + vface2.CalcNormals( nullptr ); vshape2.SetParent( parent ); if( !partID.empty() ) - data.faces.insert( std::pair< std::string, - SGNODE* >( id2, vshape2.GetRawPtr() ) ); + data.faces.insert( std::pair< std::string, SGNODE* >( id2, vshape2.GetRawPtr() ) ); } return true; diff --git a/plugins/3d/oce/oce.cpp b/plugins/3d/oce/oce.cpp index 7d31715cdd..017b0c5a56 100644 --- a/plugins/3d/oce/oce.cpp +++ b/plugins/3d/oce/oce.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo - * Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,8 +23,7 @@ */ /* - * Description: - * This plugin implements a STEP/IGES model renderer for KiCad via OCE + * This plugin implements a STEP/IGES model renderer for KiCad via OCE */ #include @@ -66,6 +65,7 @@ void GetPluginVersion( unsigned char* Major, return; } + static struct FILE_DATA { std::vector extensions; @@ -75,13 +75,21 @@ static struct FILE_DATA { #ifdef _WIN32 extensions = { "stp","step","stpz","stp.gz","step.gz","igs","iges" }; - filters = { "STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz", - "IGES (*.igs;*.iges)|*.igs;*.iges" }; + filters = { + "STEP (*.stp;*.step;*.stpz;*.stp.gz;*.step.gz)|*.stp;*.step;*.stpz;*stp.gz;*.step.gz", + "IGES (*.igs;*.iges)|*.igs;*.iges" }; #else - extensions = { "stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ","igs","IGS","iges","IGES" }; - filters = { "STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;*.STEP.GZ)" - "|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;*.STEP.GZ", - "IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES" }; + extensions = { + "stp","STP","stpZ","stpz","STPZ","step","STEP","stp.gz","STP.GZ","step.gz","STEP.GZ", + "igs","IGS","iges","IGES" + }; + + filters = { + "STEP (*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;*.step.gz;" + "*.STEP.GZ)|*.stp;*.STP;*.stpZ;*.stpz;*.STPZ;*.step;*.STEP;*.stp.gz;*.STP.GZ;" + "*.step.gz;*.STEP.GZ", + "IGES (*.igs;*.IGS;*.iges;*.IGES)|*.igs;*.IGS;*.iges;*.IGES" + }; #endif } @@ -97,7 +105,7 @@ int GetNExtensions( void ) char const* GetModelExtension( int aIndex ) { if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) ) - return NULL; + return nullptr; return file_data.extensions[aIndex].c_str(); } @@ -112,7 +120,7 @@ int GetNFilters( void ) char const* GetFileFilter( int aIndex ) { if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) ) - return NULL; + return nullptr; return file_data.filters[aIndex].c_str(); } @@ -127,13 +135,13 @@ bool CanRender( void ) SCENEGRAPH* Load( char const* aFileName ) { - if( NULL == aFileName ) - return NULL; + if( nullptr == aFileName ) + return nullptr; wxString fname = wxString::FromUTF8Unchecked( aFileName ); if( !wxFileName::FileExists( fname ) ) - return NULL; + return nullptr; return LoadModel( aFileName ); } diff --git a/plugins/3d/vrml/v1/vrml1_base.cpp b/plugins/3d/vrml/v1/vrml1_base.cpp index 6d93eca45a..05da220190 100644 --- a/plugins/3d/vrml/v1/vrml1_base.cpp +++ b/plugins/3d/vrml/v1/vrml1_base.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,7 +39,7 @@ #include "plugins/3dapi/ifsg_all.h" -WRL1BASE::WRL1BASE() : WRL1NODE( NULL ) +WRL1BASE::WRL1BASE() : WRL1NODE( nullptr ) { m_Type = WRL1NODES::WRL1_BASE; m_dictionary = new NAMEREGISTER; @@ -48,26 +49,22 @@ WRL1BASE::WRL1BASE() : WRL1NODE( NULL ) WRL1BASE::~WRL1BASE() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying virtual base node\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] Destroying virtual base node" ); cancelDict(); - return; } -// functions inherited from WRL1NODE bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to set parent on WRL1BASE node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -75,14 +72,14 @@ bool WRL1BASE::SetParent( WRL1NODE* aParent, bool /* doUnlink */ ) std::string WRL1BASE::GetName( void ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to extract name from virtual base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return std::string( "" ); } @@ -90,14 +87,14 @@ std::string WRL1BASE::GetName( void ) bool WRL1BASE::SetName( const std::string& aName ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to set name on virtual base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -107,14 +104,14 @@ bool WRL1BASE::Read( WRLPROC& proc ) { if( proc.GetVRMLType() != WRLVERSION::VRML_V1 ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] no open file or file is not a VRML1 file"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -129,9 +126,9 @@ bool WRL1BASE::Read( WRLPROC& proc ) size_t line, column; proc.GetFilePosData( line, column ); - if( !ReadNode( proc, this, NULL ) ) + if( !ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -139,7 +136,7 @@ bool WRL1BASE::Read( WRLPROC& proc ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -147,14 +144,14 @@ bool WRL1BASE::Read( WRLPROC& proc ) if( !proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -165,19 +162,19 @@ bool WRL1BASE::Read( WRLPROC& proc ) bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; if( !aParent ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invoked with NULL parent"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -186,14 +183,14 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -201,23 +198,23 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode WRL1NODE* ref = aParent->FindNode( glob ); // return 'true' - the file may be defective but it may still be somewhat OK - if( NULL == ref ) + if( nullptr == ref ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] node '" << glob << "' not found"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return true; } if( !aParent->AddRefNode( ref ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -226,12 +223,12 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ostr << aParent->GetNodeTypeName( aParent->GetNodeType() ); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = ref; return true; @@ -240,36 +237,36 @@ bool WRL1BASE::implementUse( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; - if( NULL == aParent ) + if( nullptr == aParent ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - ostr << " * [BUG] invalid parent pointer (NULL)"; + ostr << " * [BUG] invalid parent pointer (nullptr)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } std::string glob; - WRL1NODE* lnode = NULL; + WRL1NODE* lnode = nullptr; if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -279,12 +276,12 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode if( ReadNode( proc, aParent, &lnode ) ) { - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = lnode; if( lnode && !lnode->SetName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; size_t line, column; @@ -294,7 +291,7 @@ bool WRL1BASE::implementDef( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -319,19 +316,19 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) // must always check the value of aNode when the function returns // 'true' since it will be NULL if the node type is not supported. - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; - if( NULL == aParent ) + if( nullptr == aParent ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invalid parent pointer (NULL)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -341,7 +338,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) if( !proc.eof() ) { std::ostringstream ostr; @@ -349,7 +346,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif return false; } @@ -362,14 +359,14 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { if( !implementUse( proc, aParent, aNode ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -381,14 +378,14 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { if( !implementDef( proc, aParent, aNode ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -401,13 +398,13 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) size_t column = 0; proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif switch( ntype ) { @@ -486,7 +483,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) if( !proc.DiscardNode() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -495,11 +492,11 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) ostr << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) else { std::ostringstream ostr; @@ -507,7 +504,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) ostr << line << ", col " << column << " (currently unsupported)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif break; } @@ -519,7 +516,7 @@ bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { // this function makes no sense in the base node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -527,7 +524,7 @@ bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [BUG] this method must never be invoked on a WRL1BASE object"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -535,8 +532,8 @@ bool WRL1BASE::Read( WRLPROC& proc, WRL1BASE* aTopNode ) bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1GROUP* np = new WRL1GROUP( m_dictionary, aParent ); @@ -546,7 +543,7 @@ bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -555,8 +552,8 @@ bool WRL1BASE::readGroup( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) bool WRL1BASE::readSeparator( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1SEPARATOR* np = new WRL1SEPARATOR( m_dictionary, aParent ); @@ -566,7 +563,7 @@ bool WRL1BASE::readSeparator( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -583,7 +580,7 @@ bool WRL1BASE::readSwitch( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -592,8 +589,8 @@ bool WRL1BASE::readSwitch( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1MATERIAL* np = new WRL1MATERIAL( m_dictionary, aParent ); @@ -603,7 +600,7 @@ bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -612,8 +609,8 @@ bool WRL1BASE::readMaterial( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1MATBINDING* np = new WRL1MATBINDING( m_dictionary, aParent ); @@ -623,7 +620,7 @@ bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -632,8 +629,8 @@ bool WRL1BASE::readMatBinding( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1COORDS* np = new WRL1COORDS( m_dictionary, aParent ); @@ -643,7 +640,7 @@ bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -652,8 +649,8 @@ bool WRL1BASE::readCoords( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1FACESET* np = new WRL1FACESET( m_dictionary, aParent ); @@ -663,7 +660,7 @@ bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -672,8 +669,8 @@ bool WRL1BASE::readFaceSet( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1TRANSFORM* np = new WRL1TRANSFORM( m_dictionary, aParent ); @@ -683,7 +680,7 @@ bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -692,8 +689,8 @@ bool WRL1BASE::readTransform( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL1SHAPEHINTS* np = new WRL1SHAPEHINTS( m_dictionary, aParent ); @@ -703,7 +700,7 @@ bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL1NODE*) np; return true; @@ -712,20 +709,20 @@ bool WRL1BASE::readShapeHints( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNod SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating VRML1 Base with " << m_Items.size(); ostr << " items"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_Items.empty() ) - return NULL; + return nullptr; if( m_Items.size() == 1 ) - return (*m_Items.begin())->TranslateToSG( NULL, NULL ); + return (*m_Items.begin())->TranslateToSG( nullptr, nullptr ); // Note: according to the VRML1 specification, a file may contain // only one grouping node at the top level. The following code @@ -743,7 +740,7 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ ) while( sI != eI ) { - if( NULL != (*sI)->TranslateToSG( node, &m_current ) ) + if( nullptr != (*sI)->TranslateToSG( node, &m_current ) ) hasContent = true; ++sI; @@ -752,7 +749,7 @@ SGNODE* WRL1BASE::TranslateToSG( SGNODE* aParent, WRL1STATUS* /*sp*/ ) if( !hasContent ) { txNode.Destroy(); - return NULL; + return nullptr; } return node; diff --git a/plugins/3d/vrml/v1/vrml1_coords.cpp b/plugins/3d/vrml/v1/vrml1_coords.cpp index 0d0c59c6d9..abeb6d1034 100644 --- a/plugins/3d/vrml/v1/vrml1_coords.cpp +++ b/plugins/3d/vrml/v1/vrml1_coords.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL1COORDS::WRL1COORDS( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { m_Type = WRL1NODES::WRL1_COORDINATE3; - return; } @@ -43,20 +43,16 @@ WRL1COORDS::WRL1COORDS( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_COORDINATE3; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1COORDS::~WRL1COORDS() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate3 node\n" ); - #endif - - return; +#endif } @@ -64,14 +60,14 @@ bool WRL1COORDS::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -81,14 +77,14 @@ bool WRL1COORDS::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -103,7 +99,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -111,14 +107,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -127,7 +123,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column << "\n"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -143,14 +139,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -162,7 +158,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFVec3f( points ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -172,14 +168,14 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -188,12 +184,12 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - // assuming legacy kicad expectation of 1U = 0.1 inch, + // assuming legacy KiCad expectation of 1U = 0.1 inch, // convert to mm to meet the expectations of the SG structure std::vector< WRLVEC3F >::iterator sP = points.begin(); std::vector< WRLVEC3F >::iterator eP = points.end(); @@ -214,7 +210,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -223,7 +219,7 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -233,29 +229,26 @@ void WRL1COORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize ) { if( points.size() < 3 ) { - aCoordList = NULL; + aCoordList = nullptr; aListSize = 0; return; } aCoordList = &points[0]; aListSize = points.size(); - return; } SGNODE* WRL1COORDS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif - return NULL; + return nullptr; } sp->coord = this; - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v1/vrml1_faceset.cpp b/plugins/3d/vrml/v1/vrml1_faceset.cpp index e54a50f16b..6425c86dbe 100644 --- a/plugins/3d/vrml/v1/vrml1_faceset.cpp +++ b/plugins/3d/vrml/v1/vrml1_faceset.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,8 +38,6 @@ WRL1FACESET::WRL1FACESET( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { m_Type = WRL1NODES::WRL1_INDEXEDFACESET; - - return; } @@ -48,16 +47,14 @@ WRL1FACESET::WRL1FACESET( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_INDEXEDFACESET; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1FACESET::~WRL1FACESET() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying IndexedFaceSet with " << m_Children.size(); @@ -65,9 +62,7 @@ WRL1FACESET::~WRL1FACESET() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -75,14 +70,14 @@ bool WRL1FACESET::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -92,14 +87,14 @@ bool WRL1FACESET::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -114,7 +109,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -122,14 +117,14 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -138,7 +133,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -156,14 +151,14 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -178,7 +173,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFInt( coordIndex ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -188,7 +183,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -197,7 +192,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFInt( matIndex ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -207,7 +202,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -216,7 +211,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFInt( normIndex ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -226,7 +221,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -235,7 +230,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFInt( texIndex ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -245,14 +240,14 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -261,7 +256,7 @@ bool WRL1FACESET::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -276,44 +271,40 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) // note: m_sgNode is unused because we cannot manage everything // with a single reused transform due to the fact that VRML1 // may use a MatrixTransformation entity which is impossible to - // decompose into Rotate,Scale,Transform via an anlytic expression. + // decompose into Rotate,Scale,Transform via an analytic expression. if( !m_Parent ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: no parent node\n" ); - #endif - return NULL; + return nullptr; } else { - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif - return NULL; + return nullptr; } } m_current = *sp; - if( NULL == m_current.coord || NULL == m_current.mat ) + if( nullptr == m_current.coord || nullptr == m_current.mat ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) - if( NULL == m_current.coord ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) + if( nullptr == m_current.coord ) { wxLogTrace( MASK_VRML, " * [INFO] bad model: no vertex set\n" ); } - if( NULL == m_current.mat ) + if( nullptr == m_current.mat ) { wxLogTrace( MASK_VRML, " * [INFO] bad model: no material set\n" ); } - #endif +#endif - return NULL; + return nullptr; } WRLVEC3F* pcoords; @@ -324,20 +315,20 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( coordsize < 3 || vsize < 3 ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << " * [INFO] bad model: coordsize, indexsize = " << coordsize; ostr << ", " << vsize; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } // 1. create the vertex/normals/colors lists - SGNODE* sgcolor = NULL; + SGNODE* sgcolor = nullptr; WRL1_BINDING mbind = m_current.matbind; size_t matSize = matIndex.size(); @@ -352,9 +343,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( matIndex.empty() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: per face indexed but no indices\n" ); - #endif // support bad models by temporarily switching bindings mbind = WRL1_BINDING::BIND_OVERALL; @@ -373,7 +362,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) // copy the data into FACET structures SHAPE lShape; - FACET* fp = NULL; + FACET* fp = nullptr; size_t iCoord; int idx; // coordinate index size_t cidx = 0; // color index @@ -388,10 +377,10 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( idx < 0 ) { - if( NULL != fp ) + if( nullptr != fp ) { if( fp->HasMinPoints() ) - fp = NULL; + fp = nullptr; else fp->Init(); } @@ -403,7 +392,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( idx >= (int)coordsize ) continue; - if( NULL == fp ) + if( nullptr == fp ) fp = lShape.NewFacet(); // push the vertex value and index @@ -425,10 +414,10 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( idx < 0 ) { - if( NULL != fp ) + if( nullptr != fp ) { if( fp->HasMinPoints() ) - fp = NULL; + fp = nullptr; else fp->Init(); } @@ -444,7 +433,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( idx >= (int)coordsize ) continue; - if( NULL == fp ) + if( nullptr == fp ) fp = lShape.NewFacet(); // push the vertex value and index @@ -476,6 +465,7 @@ SGNODE* WRL1FACESET::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) break; case WRL1_BINDING::BIND_PER_FACE_INDEXED: + if( !fp->HasColors() ) { if( cidx >= matSize ) diff --git a/plugins/3d/vrml/v1/vrml1_group.cpp b/plugins/3d/vrml/v1/vrml1_group.cpp index fcffaada7d..27017e3f37 100644 --- a/plugins/3d/vrml/v1/vrml1_group.cpp +++ b/plugins/3d/vrml/v1/vrml1_group.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,7 +40,6 @@ WRL1GROUP::WRL1GROUP( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { m_Type = WRL1NODES::WRL1_GROUP; - return; } @@ -49,16 +49,14 @@ WRL1GROUP::WRL1GROUP( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_GROUP; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1GROUP::~WRL1GROUP() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Group with " << m_Children.size(); @@ -66,25 +64,22 @@ WRL1GROUP::~WRL1GROUP() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } -// functions inherited from WRL1NODE bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -96,7 +91,7 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -104,14 +99,14 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -120,7 +115,7 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -137,9 +132,9 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) proc.GetFilePosData( line, column ); - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -147,7 +142,7 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -163,7 +158,7 @@ bool WRL1GROUP::Read( WRLPROC& proc, WRL1BASE* aTopNode ) SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Group with " << m_Children.size(); @@ -172,34 +167,32 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) ostr << m_Items.size() << " items)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( !m_Parent ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] Group has no parent"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( WRL1NODES::WRL1_BASE != m_Parent->GetNodeType() ) { - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif - return NULL; + return nullptr; } } - else if( NULL == sp ) + else if( nullptr == sp ) { m_current.Init(); sp = &m_current; @@ -207,9 +200,9 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -217,9 +210,9 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } IFSG_TRANSFORM txNode( aParent ); @@ -232,7 +225,7 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) while( sI != eI ) { - if( NULL != (*sI)->TranslateToSG( node, sp ) ) + if( nullptr != (*sI)->TranslateToSG( node, sp ) ) hasContent = true; ++sI; @@ -241,7 +234,7 @@ SGNODE* WRL1GROUP::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( !hasContent ) { txNode.Destroy(); - return NULL; + return nullptr; } return node; diff --git a/plugins/3d/vrml/v1/vrml1_matbinding.cpp b/plugins/3d/vrml/v1/vrml1_matbinding.cpp index 0344a1c53a..eda002acdf 100644 --- a/plugins/3d/vrml/v1/vrml1_matbinding.cpp +++ b/plugins/3d/vrml/v1/vrml1_matbinding.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,7 +36,6 @@ WRL1MATBINDING::WRL1MATBINDING( NAMEREGISTER* aDictionary ) : WRL1NODE( aDiction { m_binding = WRL1_BINDING::BIND_OVERALL; m_Type = WRL1NODES::WRL1_MATERIALBINDING; - return; } @@ -46,20 +46,14 @@ WRL1MATBINDING::WRL1MATBINDING( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_MATERIALBINDING; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1MATBINDING::~WRL1MATBINDING() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) wxLogTrace( MASK_VRML, " * [INFO] Destroying MaterialBinding node\n" ); - #endif - - return; } @@ -67,14 +61,14 @@ bool WRL1MATBINDING::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -84,14 +78,14 @@ bool WRL1MATBINDING::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -99,16 +93,16 @@ bool WRL1MATBINDING::AddChildNode( WRL1NODE* aNode ) bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -120,7 +114,7 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -128,14 +122,14 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -144,7 +138,7 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -162,21 +156,21 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( glob.compare( "value" ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -185,21 +179,21 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -250,7 +244,7 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -259,7 +253,7 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif m_binding = WRL1_BINDING::BIND_OVERALL; } @@ -271,16 +265,14 @@ bool WRL1MATBINDING::Read( WRLPROC& proc, WRL1BASE* aTopNode ) SGNODE* WRL1MATBINDING::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) - wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" ); - return NULL; + return nullptr; } sp->matbind = m_binding; - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v1/vrml1_material.cpp b/plugins/3d/vrml/v1/vrml1_material.cpp index a35a178468..fe81cdd5b2 100644 --- a/plugins/3d/vrml/v1/vrml1_material.cpp +++ b/plugins/3d/vrml/v1/vrml1_material.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,61 +34,54 @@ WRL1MATERIAL::WRL1MATERIAL( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { - colors[0] = NULL; - colors[1] = NULL; + colors[0] = nullptr; + colors[1] = nullptr; m_Type = WRL1NODES::WRL1_MATERIAL; - return; } WRL1MATERIAL::WRL1MATERIAL( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : WRL1NODE( aDictionary ) { - colors[0] = NULL; - colors[1] = NULL; + colors[0] = nullptr; + colors[1] = nullptr; m_Type = WRL1NODES::WRL1_MATERIAL; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1MATERIAL::~WRL1MATERIAL() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node" ); // destroy any orphaned color nodes for( int i = 0; i < 2; ++i ) { - if( NULL != colors[i] ) + if( nullptr != colors[i] ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying SGCOLOR #" << i; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - if( NULL == S3D::GetSGNodeParent( colors[i] ) ) + if( nullptr == S3D::GetSGNodeParent( colors[i] ) ) S3D::DestroyNode( colors[i] ); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] destroyed SGCOLOR #" << i; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif } } - - return; } @@ -95,14 +89,14 @@ bool WRL1MATERIAL::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -112,14 +106,14 @@ bool WRL1MATERIAL::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -127,16 +121,16 @@ bool WRL1MATERIAL::AddChildNode( WRL1NODE* aNode ) bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - ostr << " * [BUG] aTopNode is NULL"; + ostr << " * [BUG] aTopNode is nullptr"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -148,7 +142,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -156,14 +150,14 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -172,7 +166,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -190,14 +184,14 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -216,7 +210,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFVec3f( specularColor ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -226,7 +220,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -235,7 +229,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFVec3f( diffuseColor ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -245,7 +239,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -254,7 +248,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFVec3f( emissiveColor ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -264,7 +258,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -273,7 +267,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFFloat( shininess ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -283,7 +277,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -292,7 +286,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFFloat( transparency ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -302,7 +296,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -311,7 +305,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadMFVec3f( ambientColor ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -321,14 +315,14 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -337,7 +331,7 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -349,18 +343,16 @@ bool WRL1MATERIAL::Read( WRLPROC& proc, WRL1BASE* aTopNode ) SGNODE* WRL1MATERIAL::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) - wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" ); - return NULL; + return nullptr; } sp->mat = this; - return NULL; + return nullptr; } @@ -372,7 +364,7 @@ SGNODE* WRL1MATERIAL::GetAppearance( int aIndex ) if( aIndex != 0 && aIndex != 1 ) aIndex = 0; - if( NULL != colors[ aIndex ] ) + if( nullptr != colors[ aIndex ] ) return colors[ aIndex ]; IFSG_APPEARANCE app( true ); @@ -475,7 +467,7 @@ SGNODE* WRL1MATERIAL::GetAppearance( int aIndex ) void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex ) { - if( NULL == aColor ) + if( nullptr == aColor ) return; // Calculate the color based on the given index using the formula: @@ -639,8 +631,6 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex ) checkRange( green ); checkRange( blue ); aColor->SetColor( red, green, blue ); - - return; } @@ -650,32 +640,28 @@ void WRL1MATERIAL::checkRange( float& aValue ) aValue = 0.0; else if( aValue > 1.0 ) aValue = 1.0; - - return; } void WRL1MATERIAL::Reclaim( SGNODE* aColor ) { - if( NULL == aColor ) + if( nullptr == aColor ) return; if( aColor == colors[0] ) { - if( NULL == S3D::GetSGNodeParent( aColor ) ) + if( nullptr == S3D::GetSGNodeParent( aColor ) ) { - colors[0] = NULL; + colors[0] = nullptr; S3D::DestroyNode( aColor ); } return; } - if( aColor == colors[1] && NULL == S3D::GetSGNodeParent( aColor ) ) + if( aColor == colors[1] && nullptr == S3D::GetSGNodeParent( aColor ) ) { - colors[1] = NULL; + colors[1] = nullptr; S3D::DestroyNode( aColor ); } - - return; } diff --git a/plugins/3d/vrml/v1/vrml1_node.cpp b/plugins/3d/vrml/v1/vrml1_node.cpp index 431bc2b575..85a9926a8e 100644 --- a/plugins/3d/vrml/v1/vrml1_node.cpp +++ b/plugins/3d/vrml/v1/vrml1_node.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -71,14 +72,14 @@ bool NAMEREGISTER::DelName( const std::string& aName, WRL1NODE* aNode ) WRL1NODE* NAMEREGISTER::FindName( const std::string& aName ) { if( aName.empty() ) - return NULL; + return nullptr; std::map< std::string, WRL1NODE* >::iterator ir = reg.find( aName ); if( ir != reg.end() ) return ir->second; - return NULL; + return nullptr; } @@ -86,14 +87,16 @@ typedef std::pair< std::string, WRL1NODES > NODEITEM; typedef std::map< std::string, WRL1NODES > NODEMAP; static NODEMAP nodenames; + #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) std::string WRL1NODE::tabs = ""; #endif + WRL1NODE::WRL1NODE( NAMEREGISTER* aDictionary ) { - m_sgNode = NULL; - m_Parent = NULL; + m_sgNode = nullptr; + m_Parent = nullptr; m_Type = WRL1NODES::WRL1_END; m_dictionary = aDictionary; @@ -135,14 +138,12 @@ WRL1NODE::WRL1NODE( NAMEREGISTER* aDictionary ) nodenames.insert( NODEITEM( "WWWAnchor", WRL1NODES::WRL1_WWWANCHOR ) ); nodenames.insert( NODEITEM( "WWWInline", WRL1NODES::WRL1_WWWINLINE ) ); } - - return; } WRL1NODE::~WRL1NODE() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] ^^ Destroying Type " << m_Type << " with " << m_Children.size(); @@ -150,7 +151,7 @@ WRL1NODE::~WRL1NODE() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif m_Items.clear(); @@ -163,13 +164,13 @@ WRL1NODE::~WRL1NODE() std::list< WRL1NODE* >::iterator sBP = m_BackPointers.begin(); std::list< WRL1NODE* >::iterator eBP = m_BackPointers.end(); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) int acc = 0; - #endif +#endif while( sBP != eBP ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) ++acc; do { std::ostringstream ostr; @@ -177,16 +178,16 @@ WRL1NODE::~WRL1NODE() ostr << acc; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif (*sBP)->unlinkRefNode( this ); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] " << tabs << "Type " << m_Type << " has unlinked ref #"; ostr << acc; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif ++sBP; } @@ -195,49 +196,54 @@ WRL1NODE::~WRL1NODE() std::list< WRL1NODE* >::iterator sC = m_Children.begin(); std::list< WRL1NODE* >::iterator eC = m_Children.end(); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) std::string otabs = tabs; tabs.append( " " ); - #endif +#endif while( sC != eC ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) ++acc; + do { std::ostringstream ostr; ostr << " * [INFO] " << otabs << "Type " << m_Type << " is Deleting child #"; ostr << acc; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - (*sC)->SetParent( NULL, false ); - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#endif + + (*sC)->SetParent( nullptr, false ); + +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] " << otabs << "Type " << m_Type << " has unlinked child #"; ostr << acc; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif + delete *sC; - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) + +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] " << otabs << "Type " << m_Type << " has deleted child #"; ostr << acc; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif + ++sC; } - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) tabs = otabs; - #endif +#endif m_Children.clear(); - return; } @@ -252,11 +258,10 @@ void WRL1NODE::cancelDict( void ) ++sC; } - if( m_Type == WRL1NODES::WRL1_BASE && NULL != m_dictionary ) + if( m_Type == WRL1NODES::WRL1_BASE && nullptr != m_dictionary ) delete m_dictionary; - m_dictionary = NULL; - return; + m_dictionary = nullptr; } @@ -278,8 +283,6 @@ void WRL1NODE::addNodeRef( WRL1NODE* aNode ) } m_BackPointers.push_back( aNode ); - - return; } @@ -294,16 +297,14 @@ void WRL1NODE::delNodeRef( WRL1NODE* aNode ) return; } - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] delNodeRef() did not find its target"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -332,14 +333,14 @@ bool WRL1NODE::SetName( const std::string& aName ) if( isdigit( aName[0] ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] invalid node name '" << aName << "' (begins with digit)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -353,7 +354,7 @@ bool WRL1NODE::SetName( const std::string& aName ) if( std::string::npos != aName.find_first_of( BAD_CHARS1 ) || std::string::npos != aName.find_first_of( BAD_CHARS2 ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -361,7 +362,7 @@ bool WRL1NODE::SetName( const std::string& aName ) ostr << "' (contains invalid character)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -415,8 +416,8 @@ std::string WRL1NODE::GetError( void ) WRL1NODE* WRL1NODE::FindNode( const std::string& aNodeName ) { - if( NULL == m_dictionary ) - return NULL; + if( nullptr == m_dictionary ) + return nullptr; return m_dictionary->FindName( aNodeName ); } @@ -427,12 +428,12 @@ bool WRL1NODE::SetParent( WRL1NODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -443,14 +444,14 @@ bool WRL1NODE::AddChildNode( WRL1NODE* aNode ) { if( aNode->GetNodeType() == WRL1NODES::WRL1_BASE ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to add a base node to another node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -478,30 +479,30 @@ bool WRL1NODE::AddChildNode( WRL1NODE* aNode ) bool WRL1NODE::AddRefNode( WRL1NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed as node pointer"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( aNode->GetNodeType() == WRL1NODES::WRL1_BASE ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to add a base node ref to another base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -533,8 +534,6 @@ void WRL1NODE::unlinkChildNode( const WRL1NODE* aNode ) ++sL; } - - return; } @@ -554,15 +553,12 @@ void WRL1NODE::unlinkRefNode( const WRL1NODE* aNode ) ++sL; } - - return; } void WRL1NODE::addItem( WRL1NODE* aNode ) { m_Items.push_back( aNode ); - return; } @@ -581,6 +577,4 @@ void WRL1NODE::delItem( const WRL1NODE* aNode ) ++sL; } - - return; } diff --git a/plugins/3d/vrml/v1/vrml1_node.h b/plugins/3d/vrml/v1/vrml1_node.h index a82c725b2f..17dbcfd6c3 100644 --- a/plugins/3d/vrml/v1/vrml1_node.h +++ b/plugins/3d/vrml/v1/vrml1_node.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -67,16 +68,22 @@ struct WRL1STATUS { // material WRL1MATERIAL* mat; + // normals WRL1NODE* norm; + // coordinate3 WRL1COORDS* coord; + // material binding WRL1_BINDING matbind; + // normal binding WRL1_BINDING normbind; + // transform glm::mat4 txmatrix; + // winding order of vertices WRL1_ORDER order; @@ -91,11 +98,11 @@ struct WRL1STATUS void Init() { - mat = NULL; + mat = nullptr; matbind = WRL1_BINDING::BIND_OVERALL; - norm = NULL; + norm = nullptr; normbind = WRL1_BINDING::BIND_DEFAULT; - coord = NULL; + coord = nullptr; txmatrix = glm::scale( glm::mat4( 1.0 ), glm::vec3( 1.0 ) ); order = WRL1_ORDER::ORD_UNKNOWN; creaseLimit = 0.878f; @@ -105,11 +112,118 @@ struct WRL1STATUS /** - * WRL1NODE - * represents the base class of all VRML1 nodes + * The base class of all VRML1 nodes */ class WRL1NODE { +public: +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) + static std::string tabs; +#endif + + // cancel the dictionary pointer; for internal use only + void cancelDict( void ); + + /** + * Return the ID based on the given \a aNodeName or WRL1_INVALID (WRL1_END) + * if no such node name exists. + */ + WRL1NODES getNodeTypeID( const std::string& aNodeName ); + + /** + * Remove references to an owned child; it is invoked by the child upon destruction + * to ensure that the parent has no invalid references. + * + * @param aNode is the child which is being deleted. + */ + virtual void unlinkChildNode( const WRL1NODE* aNode ); + + /** + * Remove pointers to a referenced node; it is invoked by the referenced node + * upon destruction to ensure that the referring node has no invalid references. + * + * @param aNode is the node which is being deleted. + */ + virtual void unlinkRefNode( const WRL1NODE* aNode ); + + /** + * Add a pointer to a node which references, but does not own, this node. + * + * Such back-pointers are required to ensure that invalidated references + * are removed when a node is deleted + * + * @param aNode is the node holding a reference to this object. + */ + void addNodeRef( WRL1NODE* aNode ); + + /** + * Remove a pointer to a node which references, but does not own, this node. + * + * @param aNode is the node holding a reference to this object. + */ + void delNodeRef( WRL1NODE* aNode ); + +public: + WRL1NODE( NAMEREGISTER* aDictionary ); + virtual ~WRL1NODE(); + + // read data via the given file processor and WRL1BASE object + virtual bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) = 0; + + /** + * Return the type of this node instance. + */ + WRL1NODES GetNodeType( void ) const; + + /** + * Return a pointer to the parent SGNODE of this object or NULL if the object has no + * parent (ie. top level transform). + */ + WRL1NODE* GetParent( void ) const; + + /** + * Set the parent WRL1NODE of this object. + * + * @param aParent [in] is the desired parent node. + * @param doUnlink indicates that the child must be unlinked from the parent + * @return true if the operation succeeds; false if the given node is not allowed to + * be a parent to the derived object. + */ + virtual bool SetParent( WRL1NODE* aParent, bool doUnlink = true ); + + virtual std::string GetName( void ); + virtual bool SetName( const std::string& aName ); + + const char* GetNodeTypeName( WRL1NODES aNodeType ) const; + + size_t GetNItems( void ) const; + + /** + * Search the tree of linked nodes and returns a reference to the current node with the + * given name. + * + * The reference is then typically added to another node via AddRefNode(). + * + * @param aNodeName is the name of the node to search for. + * @return is a valid node pointer on success, otherwise NULL. + */ + virtual WRL1NODE* FindNode( const std::string& aNodeName ); + + virtual bool AddChildNode( WRL1NODE* aNode ); + + virtual bool AddRefNode( WRL1NODE* aNode ); + + std::string GetError( void ); + + /** + * Produce a representation of the data using the intermediate scenegraph structures of the + * kicad_3dsg library. + * + * @param aParent is a pointer to the parent SG node. + * @return is non-NULL on success. + */ + virtual SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) = 0; + private: void addItem( WRL1NODE* aNode ); void delItem( const WRL1NODE* aNode ); @@ -136,122 +250,6 @@ protected: // dictionary must be propagated to all children as well - perhaps // this is best done via a SetDictionary() function. NAMEREGISTER* m_dictionary; - -public: - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) - static std::string tabs; - #endif - - // cancel the dictionary pointer; for internal use only - void cancelDict( void ); - - /** - * Function getNodeTypeID - * returns the ID based on the given aNodeName or WRL1_INVALID (WRL1_END) - * if no such node name exists - */ - WRL1NODES getNodeTypeID( const std::string& aNodeName ); - - /** - * Function unlinkChild - * removes references to an owned child; it is invoked by the child upon destruction - * to ensure that the parent has no invalid references. - * - * @param aNode is the child which is being deleted - */ - virtual void unlinkChildNode( const WRL1NODE* aNode ); - - /** - * Function unlinkRef - * removes pointers to a referenced node; it is invoked by the referenced node - * upon destruction to ensure that the referring node has no invalid references. - * - * @param aNode is the node which is being deleted - */ - virtual void unlinkRefNode( const WRL1NODE* aNode ); - - /** - * Function addNodeRef - * adds a pointer to a node which references, but does not own, this node. - * Such back-pointers are required to ensure that invalidated references - * are removed when a node is deleted - * - * @param aNode is the node holding a reference to this object - */ - void addNodeRef( WRL1NODE* aNode ); - - /** - * Function delNodeRef - * removes a pointer to a node which references, but does not own, this node. - * - * @param aNode is the node holding a reference to this object - */ - void delNodeRef( WRL1NODE* aNode ); - -public: - WRL1NODE( NAMEREGISTER* aDictionary ); - virtual ~WRL1NODE(); - - // read data via the given file processor and WRL1BASE object - virtual bool Read( WRLPROC& proc, WRL1BASE* aTopNode ) = 0; - - /** - * Function GetNodeType - * returns the type of this node instance - */ - WRL1NODES GetNodeType( void ) const; - - /** - * Function GetParent - * returns a pointer to the parent SGNODE of this object - * or NULL if the object has no parent (ie. top level transform) - */ - WRL1NODE* GetParent( void ) const; - - /** - * Function SetParent - * sets the parent WRL1NODE of this object. - * - * @param aParent [in] is the desired parent node - * @param doUnlink indicates that the child must be unlinked from the parent - * @return true if the operation succeeds; false if - * the given node is not allowed to be a parent to - * the derived object. - */ - virtual bool SetParent( WRL1NODE* aParent, bool doUnlink = true ); - - virtual std::string GetName( void ); - virtual bool SetName( const std::string& aName ); - - const char* GetNodeTypeName( WRL1NODES aNodeType ) const; - - size_t GetNItems( void ) const; - - /** - * Function FindNode searches the tree of linked nodes and returns a - * reference to the current node with the given name. The reference - * is then typically added to another node via AddRefNode(). - * - * @param aNodeName is the name of the node to search for - * @return is a valid node pointer on success, otherwise NULL - */ - virtual WRL1NODE* FindNode( const std::string& aNodeName ); - - virtual bool AddChildNode( WRL1NODE* aNode ); - - virtual bool AddRefNode( WRL1NODE* aNode ); - - std::string GetError( void ); - - /** - * Function TranslateToSG - * produces a representation of the data using the intermediate - * scenegraph structures of the kicad_3dsg library. - * - * @param aParent is a pointer to the parent SG node - * @return is non-NULL on success - */ - virtual SGNODE* TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) = 0; }; #endif // VRML1_NODE_H diff --git a/plugins/3d/vrml/v1/vrml1_separator.cpp b/plugins/3d/vrml/v1/vrml1_separator.cpp index 84e10042dd..8f68213841 100644 --- a/plugins/3d/vrml/v1/vrml1_separator.cpp +++ b/plugins/3d/vrml/v1/vrml1_separator.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL1SEPARATOR::WRL1SEPARATOR( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { m_Type = WRL1NODES::WRL1_SEPARATOR; - return; } @@ -43,16 +43,14 @@ WRL1SEPARATOR::WRL1SEPARATOR( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_SEPARATOR; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1SEPARATOR::~WRL1SEPARATOR() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Separator with " << m_Children.size(); @@ -60,25 +58,22 @@ WRL1SEPARATOR::~WRL1SEPARATOR() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } -// functions inherited from WRL1NODE bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -90,7 +85,7 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -98,14 +93,14 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -114,7 +109,7 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -131,9 +126,9 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) proc.GetFilePosData( line, column ); - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -141,7 +136,7 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -157,7 +152,7 @@ bool WRL1SEPARATOR::Read( WRLPROC& proc, WRL1BASE* aTopNode ) SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Separator with " << m_Children.size(); @@ -166,32 +161,32 @@ SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) ostr << m_Items.size() << " items)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( !m_Parent ) { - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] Separator has no parent"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - if( sp != NULL ) + if( sp != nullptr ) m_current = *sp; else m_current.Init(); S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -199,9 +194,9 @@ SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } IFSG_TRANSFORM txNode( aParent ); @@ -214,7 +209,7 @@ SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) while( sI != eI ) { - if( NULL != (*sI)->TranslateToSG( node, &m_current ) ) + if( nullptr != (*sI)->TranslateToSG( node, &m_current ) ) hasContent = true; ++sI; @@ -223,7 +218,7 @@ SGNODE* WRL1SEPARATOR::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( !hasContent ) { txNode.Destroy(); - return NULL; + return nullptr; } return node; diff --git a/plugins/3d/vrml/v1/vrml1_shapehints.cpp b/plugins/3d/vrml/v1/vrml1_shapehints.cpp index aede21411e..9bfa9c24ba 100644 --- a/plugins/3d/vrml/v1/vrml1_shapehints.cpp +++ b/plugins/3d/vrml/v1/vrml1_shapehints.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,7 +38,6 @@ WRL1SHAPEHINTS::WRL1SHAPEHINTS( NAMEREGISTER* aDictionary ) : WRL1NODE( aDiction m_order = WRL1_ORDER::ORD_UNKNOWN; m_Type = WRL1NODES::WRL1_SHAPEHINTS; m_crease = 0.733f; // approx 42 degrees; this is larger than VRML spec. - return; } @@ -49,20 +49,14 @@ WRL1SHAPEHINTS::WRL1SHAPEHINTS( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_crease = 0.733f; // approx 42 degrees; this is larger than VRML spec. m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1SHAPEHINTS::~WRL1SHAPEHINTS() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) wxLogTrace( MASK_VRML, " * [INFO] Destroying ShapeHints node\n" ); - #endif - - return; } @@ -70,14 +64,14 @@ bool WRL1SHAPEHINTS::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -87,14 +81,14 @@ bool WRL1SHAPEHINTS::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -102,16 +96,16 @@ bool WRL1SHAPEHINTS::AddChildNode( WRL1NODE* aNode ) bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -123,7 +117,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -131,14 +125,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -147,7 +141,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -165,14 +159,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -187,14 +181,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -207,7 +201,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) m_order = WRL1_ORDER::ORD_CCW; else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -216,7 +210,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -225,14 +219,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -245,14 +239,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -267,14 +261,14 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadSFFloat( tmp ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -288,7 +282,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -297,7 +291,7 @@ bool WRL1SHAPEHINTS::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -312,13 +306,11 @@ SGNODE* WRL1SHAPEHINTS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) // note: this is not fully implemented since it is unlikely we shall // ever make use of the fields shapeType, faceType, and creaseAngle - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif - return NULL; + return nullptr; } sp->order = m_order; @@ -327,5 +319,5 @@ SGNODE* WRL1SHAPEHINTS::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) if( sp->creaseLimit < 0.0 ) sp->creaseLimit = 0.0; - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v1/vrml1_switch.cpp b/plugins/3d/vrml/v1/vrml1_switch.cpp index d8d29cd5a2..8b1f539a92 100644 --- a/plugins/3d/vrml/v1/vrml1_switch.cpp +++ b/plugins/3d/vrml/v1/vrml1_switch.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,8 +36,6 @@ WRL1SWITCH::WRL1SWITCH( NAMEREGISTER* aDictionary ) : WRL1NODE( aDictionary ) { m_Type = WRL1NODES::WRL1_SWITCH; whichChild = -1; - - return; } @@ -47,16 +46,14 @@ WRL1SWITCH::WRL1SWITCH( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Parent = aParent; whichChild = -1; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL1SWITCH::~WRL1SWITCH() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Switch with " << m_Children.size(); @@ -64,13 +61,10 @@ WRL1SWITCH::~WRL1SWITCH() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } -// functions inherited from WRL1NODE bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { /* @@ -82,16 +76,16 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) * } */ - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -103,7 +97,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -111,14 +105,14 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -127,7 +121,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -148,14 +142,14 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -164,7 +158,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFInt( whichChild ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -174,7 +168,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -182,7 +176,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) continue; } - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -191,16 +185,16 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } proc.GetFilePosData( line, column ); - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -208,7 +202,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -224,7 +218,7 @@ bool WRL1SWITCH::Read( WRLPROC& proc, WRL1BASE* aTopNode ) SGNODE* WRL1SWITCH::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Switch with " << m_Children.size(); @@ -233,15 +227,15 @@ SGNODE* WRL1SWITCH::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) ostr << m_Items.size() << " items)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_Items.empty() ) - return NULL; + return nullptr; if( whichChild < 0 || whichChild >= (int)m_Items.size() ) - return NULL; + return nullptr; - if( sp == NULL ) + if( sp == nullptr ) { m_current.Init(); sp = &m_current; diff --git a/plugins/3d/vrml/v1/vrml1_transform.cpp b/plugins/3d/vrml/v1/vrml1_transform.cpp index bacbb088d6..c2badbde9f 100644 --- a/plugins/3d/vrml/v1/vrml1_transform.cpp +++ b/plugins/3d/vrml/v1/vrml1_transform.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,7 +44,7 @@ WRL1TRANSFORM::WRL1TRANSFORM( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : m_Type = WRL1NODES::WRL1_TRANSFORM; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return; @@ -52,7 +53,7 @@ WRL1TRANSFORM::WRL1TRANSFORM( NAMEREGISTER* aDictionary, WRL1NODE* aParent ) : WRL1TRANSFORM::~WRL1TRANSFORM() { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Transform with " << m_Children.size(); @@ -60,9 +61,7 @@ WRL1TRANSFORM::~WRL1TRANSFORM() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -80,16 +79,16 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) * } */ - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -118,7 +117,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -126,14 +125,14 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -142,7 +141,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -160,14 +159,14 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -185,7 +184,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFVec3f( center ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -195,7 +194,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -209,7 +208,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFRotation( rotation ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -219,7 +218,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -228,7 +227,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFVec3f( scale ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -238,7 +237,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -247,7 +246,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFRotation( scaleOrientation ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -257,7 +256,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -266,7 +265,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) { if( !proc.ReadSFVec3f( translation ) ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -276,7 +275,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -288,7 +287,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) } else { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) +#if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -297,7 +296,7 @@ bool WRL1TRANSFORM::Read( WRLPROC& proc, WRL1BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -311,14 +310,14 @@ bool WRL1TRANSFORM::AddRefNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -328,14 +327,14 @@ bool WRL1TRANSFORM::AddChildNode( WRL1NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML1 +#ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -343,19 +342,17 @@ bool WRL1TRANSFORM::AddChildNode( WRL1NODE* aNode ) SGNODE* WRL1TRANSFORM::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) { - if( NULL == m_Parent ) - return NULL; + if( nullptr == m_Parent ) + return nullptr; if( WRL1NODES::WRL1_BASE == m_Parent->GetNodeType() ) - return NULL; + return nullptr; - if( NULL == sp ) + if( nullptr == sp ) { - #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) - wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] bad model: no base data given" ); - return NULL; + return nullptr; } // rotation @@ -365,20 +362,24 @@ SGNODE* WRL1TRANSFORM::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) rZ = rotation.z; rW = rotation.w; glm::mat4 rM = glm::rotate( glm::mat4( 1.0f ), rW, glm::vec3( rX, rY, rZ ) ); + // translation float dX, dY, dZ; dX = translation.x; dY = translation.y; dZ = translation.z; glm::mat4 tM = glm::translate( glm::mat4( 1.0f ), glm::vec3( dX, dY, dZ ) ); + // center dX = center.x; dY = center.y; dZ = center.z; glm::mat4 cM = glm::translate( glm::mat4( 1.0f ), glm::vec3( dX, dY, dZ ) ); glm::mat4 ncM = glm::translate( glm::mat4( 1.0f ), glm::vec3( -dX, -dY, -dZ ) ); + // scale glm::mat4 sM = glm::scale( glm::mat4( 1.0 ), glm::vec3( scale.x, scale.y, scale.z ) ); + // scaleOrientation rX = scaleOrientation.x; rY = scaleOrientation.y; @@ -391,5 +392,5 @@ SGNODE* WRL1TRANSFORM::TranslateToSG( SGNODE* aParent, WRL1STATUS* sp ) // tx' = tM * cM * rM * srM * sM * nsrM * ncM sp->txmatrix = sp->txmatrix * tM * cM * rM * srM * sM * nsrM * ncM; - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v2/vrml2_appearance.cpp b/plugins/3d/vrml/v2/vrml2_appearance.cpp index 9d66b19bae..c6894e9cb8 100644 --- a/plugins/3d/vrml/v2/vrml2_appearance.cpp +++ b/plugins/3d/vrml/v2/vrml2_appearance.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,32 +34,29 @@ WRL2APPEARANCE::WRL2APPEARANCE() : WRL2NODE() { - material = NULL; - texture = NULL; - textureTransform = NULL; + material = nullptr; + texture = nullptr; + textureTransform = nullptr; m_Type = WRL2NODES::WRL2_APPEARANCE; - return; } WRL2APPEARANCE::WRL2APPEARANCE( WRL2NODE* aParent ) : WRL2NODE() { - material = NULL; - texture = NULL; - textureTransform = NULL; + material = nullptr; + texture = nullptr; + textureTransform = nullptr; m_Type = WRL2NODES::WRL2_APPEARANCE; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2APPEARANCE::~WRL2APPEARANCE() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Appearance with " << m_Children.size(); @@ -66,7 +64,7 @@ WRL2APPEARANCE::~WRL2APPEARANCE() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif } @@ -94,7 +92,7 @@ bool WRL2APPEARANCE::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_SHAPE - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) return true; return false; @@ -103,16 +101,16 @@ bool WRL2APPEARANCE::isDangling( void ) bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -121,7 +119,7 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -129,23 +127,23 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_MATERIAL == type ) { - if( NULL != material ) + if( nullptr != material ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple material nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -156,16 +154,16 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_TEXTURETRANSFORM == type ) { - if( NULL != textureTransform ) + if( nullptr != textureTransform ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple textureTransform nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -174,16 +172,16 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) return WRL2NODE::AddRefNode( aNode ); } - if( NULL != texture ) + if( nullptr != texture ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple texture nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -195,16 +193,16 @@ bool WRL2APPEARANCE::AddRefNode( WRL2NODE* aNode ) bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -213,7 +211,7 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -221,23 +219,23 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_MATERIAL == type ) { - if( NULL != material ) + if( nullptr != material ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple material nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -248,16 +246,16 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_TEXTURETRANSFORM == type ) { - if( NULL != textureTransform ) + if( nullptr != textureTransform ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple textureTransform nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -266,16 +264,16 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) return WRL2NODE::AddChildNode( aNode ); } - if( NULL != texture ) + if( nullptr != texture ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple texture nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -287,16 +285,16 @@ bool WRL2APPEARANCE::AddChildNode( WRL2NODE* aNode ) bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -308,7 +306,7 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -316,14 +314,14 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -332,7 +330,7 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -350,14 +348,14 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -371,55 +369,55 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !glob.compare( "material" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read material information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "texture" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read texture information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "textureTransform" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read textureTransform information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -428,7 +426,7 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -440,14 +438,14 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent ) { - if( NULL == material && NULL == texture ) - return NULL; + if( nullptr == material && nullptr == texture ) + return nullptr; S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -455,12 +453,12 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Appearance with " << m_Children.size(); @@ -468,28 +466,28 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } return m_sgNode; } - if( NULL != texture ) + if( nullptr != texture ) { // use a default gray appearance IFSG_APPEARANCE matNode( aParent ); @@ -512,41 +510,38 @@ SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent ) void WRL2APPEARANCE::unlinkChildNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() == this ) { if( aNode == material ) - material = NULL; + material = nullptr; else if( aNode == texture ) - texture = NULL; + texture = nullptr; else if( aNode == textureTransform ) - textureTransform = NULL; + textureTransform = nullptr; } WRL2NODE::unlinkChildNode( aNode ); - return; } void WRL2APPEARANCE::unlinkRefNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() != this ) { if( aNode == material ) - material = NULL; + material = nullptr; else if( aNode == texture ) - texture = NULL; + texture = nullptr; else if( aNode == textureTransform ) - textureTransform = NULL; - + textureTransform = nullptr; } WRL2NODE::unlinkRefNode( aNode ); - return; } diff --git a/plugins/3d/vrml/v2/vrml2_base.cpp b/plugins/3d/vrml/v2/vrml2_base.cpp index 548242db74..a6626f4fe3 100644 --- a/plugins/3d/vrml/v2/vrml2_base.cpp +++ b/plugins/3d/vrml/v2/vrml2_base.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -47,11 +48,11 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ); + WRL2BASE::WRL2BASE() : WRL2NODE() { m_useInline = false; m_Type = WRL2NODES::WRL2_BASE; - return; } @@ -65,29 +66,26 @@ WRL2BASE::~WRL2BASE() SGNODE* np = iS->second; // destroy any orphaned Inline{} node data - if( np && NULL == S3D::GetSGNodeParent( np ) ) + if( np && nullptr == S3D::GetSGNodeParent( np ) ) S3D::DestroyNode( np ); ++iS; } m_inlineModels.clear(); - - return; } -// functions inherited from WRL2NODE bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to set parent on WRL2BASE node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -96,7 +94,6 @@ bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ ) void WRL2BASE::SetEnableInline( bool enable ) { m_useInline = enable; - return; } @@ -109,7 +106,7 @@ bool WRL2BASE::GetEnableInline( void ) SGNODE* WRL2BASE::GetInlineData( const std::string& aName ) { if( aName.empty() ) - return NULL; + return nullptr; std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName ); @@ -121,7 +118,7 @@ SGNODE* WRL2BASE::GetInlineData( const std::string& aName ) if( aName.compare( 0, 7, "file://" ) == 0 ) { if( aName.length() <= 7 ) - return NULL; + return nullptr; tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() ); } @@ -142,16 +139,16 @@ SGNODE* WRL2BASE::GetInlineData( const std::string& aName ) if( !fn.Normalize() ) { - m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, NULL ) ); - return NULL; + m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, nullptr ) ); + return nullptr; } SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), false ); - if( NULL == sp ) + if( nullptr == sp ) { - m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, NULL ) ); - return NULL; + m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, nullptr ) ); + return nullptr; } m_inlineModels.insert( std::pair< std::string, SGNODE* >( aName, (SGNODE*)sp ) ); @@ -162,14 +159,14 @@ SGNODE* WRL2BASE::GetInlineData( const std::string& aName ) std::string WRL2BASE::GetName( void ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to extract name from virtual base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return std::string( "" ); } @@ -177,14 +174,14 @@ std::string WRL2BASE::GetName( void ) bool WRL2BASE::SetName( const std::string& aName ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to set name on virtual base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -194,19 +191,19 @@ bool WRL2BASE::Read( WRLPROC& proc ) { if( proc.GetVRMLType() != WRLVERSION::VRML_V2 ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] no open file or file is not a VRML2 file"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - WRL2NODE* node = NULL; + WRL2NODE* node = nullptr; m_dir = proc.GetParentDir(); while( ReadNode( proc, this, &node ) && !proc.eof() ); @@ -227,19 +224,19 @@ bool WRL2BASE::isDangling( void ) bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; if( !aParent ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invoked with NULL parent"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -248,38 +245,38 @@ bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - WRL2NODE* ref = aParent->FindNode( glob, NULL ); + WRL2NODE* ref = aParent->FindNode( glob, nullptr ); // return 'true' - the file may be defective but it may still be somewhat OK - if( NULL == ref ) + if( nullptr == ref ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] node '" << glob << "' not found"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return true; } if( !aParent->AddRefNode( ref ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -288,12 +285,12 @@ bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ostr << aParent->GetNodeTypeName( aParent->GetNodeType() ); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = ref; return true; @@ -302,36 +299,36 @@ bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; - if( NULL == aParent ) + if( nullptr == aParent ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invalid parent pointer (NULL)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } std::string glob; - WRL2NODE* lnode = NULL; + WRL2NODE* lnode = nullptr; if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -341,12 +338,12 @@ bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode if( ReadNode( proc, aParent, &lnode ) ) { - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = lnode; if( lnode && !lnode->SetName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; size_t line, column; @@ -356,7 +353,7 @@ bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -376,19 +373,19 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // must always check the value of aNode when the function returns // 'true' since it will be NULL if the node type is not supported. - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; - if( NULL == aParent ) + if( nullptr == aParent ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invalid parent pointer (NULL)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -398,7 +395,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) if( !proc.eof() ) { std::ostringstream ostr; @@ -406,7 +403,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif return false; } @@ -426,14 +423,14 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { if( !implementUse( proc, aParent, aNode ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -445,14 +442,14 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { if( !implementDef( proc, aParent, aNode ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -465,14 +462,14 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { if( !proc.ReadName( glob ) || !proc.DiscardList() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -485,14 +482,14 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -505,14 +502,14 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -525,13 +522,13 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) size_t column = 0; proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif switch( ntype ) { @@ -563,18 +560,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // XXX - IMPLEMENT if( !proc.DiscardNode() ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << " * [INFO] FAIL: discard " << glob << " node at l"; ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { do { @@ -584,7 +581,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); } - #endif +#endif break; @@ -599,18 +596,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // XXX - IMPLEMENT if( !proc.DiscardNode() ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << " * [INFO] FAIL: discard " << glob << " node at l"; ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { std::ostringstream ostr; @@ -618,7 +615,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif break; @@ -626,18 +623,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // XXX - IMPLEMENT if( !proc.DiscardNode() ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << " * [INFO] FAIL: discard " << glob << " node at l"; ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { do { @@ -647,7 +644,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); } - #endif +#endif break; @@ -655,18 +652,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // XXX - IMPLEMENT if( !proc.DiscardNode() ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << " * [INFO] FAIL: discard " << glob << " node at l"; ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { std::ostringstream ostr; @@ -674,7 +671,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif break; @@ -724,18 +721,18 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) // XXX - IMPLEMENT if( !proc.DiscardNode() ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << " * [INFO] FAIL: discard " << glob << " node at l"; ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { std::ostringstream ostr; @@ -743,7 +740,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif break; @@ -814,7 +811,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) if( !proc.DiscardNode() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -823,11 +820,11 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 else { std::ostringstream ostr; @@ -835,7 +832,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << line << ", c" << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } - #endif +#endif break; } @@ -847,7 +844,7 @@ bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { // this function makes no sense in the base node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -855,7 +852,7 @@ bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [BUG] this method must never be invoked on a WRL2BASE object"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -863,8 +860,8 @@ bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent ); @@ -874,7 +871,7 @@ bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -883,8 +880,8 @@ bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2SHAPE* np = new WRL2SHAPE( aParent ); @@ -894,7 +891,7 @@ bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -903,8 +900,8 @@ bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent ); @@ -914,7 +911,7 @@ bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNod return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -923,8 +920,8 @@ bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNod bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2MATERIAL* np = new WRL2MATERIAL( aParent ); @@ -934,7 +931,7 @@ bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -943,8 +940,8 @@ bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2FACESET* np = new WRL2FACESET( aParent ); @@ -954,7 +951,7 @@ bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -963,8 +960,8 @@ bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2LINESET* np = new WRL2LINESET( aParent ); @@ -974,7 +971,7 @@ bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -983,8 +980,8 @@ bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2POINTSET* np = new WRL2POINTSET( aParent ); @@ -994,7 +991,7 @@ bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1003,8 +1000,8 @@ bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2COORDS* np = new WRL2COORDS( aParent ); @@ -1014,7 +1011,7 @@ bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1023,8 +1020,8 @@ bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2NORMS* np = new WRL2NORMS( aParent ); @@ -1034,7 +1031,7 @@ bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1043,8 +1040,8 @@ bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2COLOR* np = new WRL2COLOR( aParent ); @@ -1054,7 +1051,7 @@ bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1063,8 +1060,8 @@ bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2BOX* np = new WRL2BOX( aParent ); @@ -1074,7 +1071,7 @@ bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1083,8 +1080,8 @@ bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; WRL2SWITCH* np = new WRL2SWITCH( aParent ); @@ -1094,7 +1091,7 @@ bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1103,8 +1100,8 @@ bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) { - if( NULL != aNode ) - *aNode = NULL; + if( nullptr != aNode ) + *aNode = nullptr; if( !m_useInline ) { @@ -1114,7 +1111,7 @@ bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) if( !proc.DiscardNode() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -1123,7 +1120,7 @@ bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) ostr << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -1139,7 +1136,7 @@ bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) return false; } - if( NULL != aNode ) + if( nullptr != aNode ) *aNode = (WRL2NODE*) np; return true; @@ -1149,13 +1146,13 @@ bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode ) SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent ) { if( m_Children.empty() ) - return NULL; + return nullptr; S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -1163,24 +1160,24 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -1209,7 +1206,7 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent ) IFSG_TRANSFORM wrapper( topNode.GetRawPtr() ); SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() ); - if( NULL != pshape ) + if( nullptr != pshape ) test = true; else wrapper.Destroy(); @@ -1222,7 +1219,7 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent ) case WRL2NODES::WRL2_SWITCH: case WRL2NODES::WRL2_INLINE: - if( NULL != (*sC)->TranslateToSG( topNode.GetRawPtr() ) ) + if( nullptr != (*sC)->TranslateToSG( topNode.GetRawPtr() ) ) test = true; break; @@ -1237,7 +1234,7 @@ SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent ) if( false == test ) { topNode.Destroy(); - return NULL; + return nullptr; } m_sgNode = topNode.GetRawPtr(); diff --git a/plugins/3d/vrml/v2/vrml2_box.cpp b/plugins/3d/vrml/v2/vrml2_box.cpp index 40245143ab..d98d7eaea1 100644 --- a/plugins/3d/vrml/v2/vrml2_box.cpp +++ b/plugins/3d/vrml/v2/vrml2_box.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,8 +38,6 @@ WRL2BOX::WRL2BOX() : WRL2NODE() size.x = 2.0; size.y = 2.0; size.z = 2.0; - - return; } @@ -50,20 +49,14 @@ WRL2BOX::WRL2BOX( WRL2NODE* aParent ) : WRL2NODE() size.y = 2.0; size.z = 2.0; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2BOX::~WRL2BOX() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Box node\n" ); - #endif - - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Box node" ); } @@ -71,7 +64,7 @@ bool WRL2BOX::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_SHAPE - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) return true; return false; @@ -87,7 +80,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -95,14 +88,14 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -111,7 +104,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -127,14 +120,14 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -146,7 +139,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( size ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -156,7 +149,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -166,7 +159,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -175,14 +168,14 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( size.x < 1e-6 || size.y < 1e-6 || size.z < 1e-6 ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -191,7 +184,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif } if( proc.Peek() == '}' ) @@ -202,7 +195,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -211,7 +204,7 @@ bool WRL2BOX::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -221,14 +214,14 @@ bool WRL2BOX::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -238,14 +231,14 @@ bool WRL2BOX::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -255,9 +248,9 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) { S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -265,28 +258,28 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } // do not render a bad box if( size.x < 1e-6 || size.y < 1e-6 || size.z < 1e-6 ) - return NULL; + return nullptr; if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -301,6 +294,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) std::vector< SGVECTOR > norms; std::vector< int > idx; int base = 0; + // top vertices.emplace_back( -x, -y, z ); vertices.emplace_back( x, -y, z ); @@ -317,6 +311,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) idx.push_back( base + 2 ); idx.push_back( base + 3 ); base += 4; + // bottom vertices.emplace_back( -x, -y, -z ); vertices.emplace_back( x, -y, -z ); @@ -333,6 +328,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) idx.push_back( base + 3 ); idx.push_back( base + 2 ); base += 4; + // front vertices.emplace_back( -x, -y, z ); vertices.emplace_back( -x, -y, -z ); @@ -349,6 +345,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) idx.push_back( base + 2 ); idx.push_back( base + 3 ); base += 4; + // back vertices.emplace_back( -x, y, z ); vertices.emplace_back( -x, y, -z ); @@ -365,6 +362,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) idx.push_back( base + 3 ); idx.push_back( base + 2 ); base += 4; + // left vertices.emplace_back( -x, -y, -z ); vertices.emplace_back( -x, -y, z ); @@ -381,6 +379,7 @@ SGNODE* WRL2BOX::TranslateToSG( SGNODE* aParent ) idx.push_back( base + 2 ); idx.push_back( base + 3 ); base += 4; + // right vertices.emplace_back( x, -y, -z ); vertices.emplace_back( x, -y, z ); diff --git a/plugins/3d/vrml/v2/vrml2_color.cpp b/plugins/3d/vrml/v2/vrml2_color.cpp index 34bd2c2e56..4076a907dd 100644 --- a/plugins/3d/vrml/v2/vrml2_color.cpp +++ b/plugins/3d/vrml/v2/vrml2_color.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL2COLOR::WRL2COLOR() : WRL2NODE() { m_Type = WRL2NODES::WRL2_COLOR; - return; } @@ -42,20 +42,14 @@ WRL2COLOR::WRL2COLOR( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_COLOR; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2COLOR::~WRL2COLOR() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Color node\n" ); - #endif - - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Color node" ); } @@ -63,7 +57,7 @@ bool WRL2COLOR::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_INDEXEDFACESET - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) return true; return false; @@ -74,14 +68,14 @@ bool WRL2COLOR::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -91,14 +85,14 @@ bool WRL2COLOR::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -113,7 +107,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -121,14 +115,14 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -137,7 +131,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -153,14 +147,14 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -172,7 +166,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFVec3f( colors ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -182,14 +176,14 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -198,7 +192,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -211,7 +205,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -220,7 +214,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -229,7 +223,7 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2COLOR::TranslateToSG( SGNODE* aParent ) { // any data manipulation must be performed by the parent node - return NULL; + return nullptr; } @@ -255,8 +249,6 @@ void WRL2COLOR::GetColor( int aIndex, float& red, float& green, float& blue ) red = colors[aIndex].x; green = colors[aIndex].y; blue = colors[aIndex].z; - - return; } @@ -264,13 +256,11 @@ void WRL2COLOR::GetColors( WRLVEC3F*& aColorList, size_t& aListSize) { if( colors.empty() ) { - aColorList = NULL; + aColorList = nullptr; aListSize = 0; return; } aColorList = &colors[0]; aListSize = colors.size(); - - return; } diff --git a/plugins/3d/vrml/v2/vrml2_coords.cpp b/plugins/3d/vrml/v2/vrml2_coords.cpp index 96cb319214..cca0e55227 100644 --- a/plugins/3d/vrml/v2/vrml2_coords.cpp +++ b/plugins/3d/vrml/v2/vrml2_coords.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL2COORDS::WRL2COORDS() : WRL2NODE() { m_Type = WRL2NODES::WRL2_COORDINATE; - return; } @@ -42,20 +42,14 @@ WRL2COORDS::WRL2COORDS( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_COORDINATE; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2COORDS::~WRL2COORDS() { -#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate node\n" ); -#endif - - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate node" ); } @@ -63,7 +57,7 @@ bool WRL2COORDS::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_INDEXEDFACESET - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) return true; return false; @@ -74,14 +68,14 @@ bool WRL2COORDS::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -91,14 +85,14 @@ bool WRL2COORDS::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable\n"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -113,7 +107,7 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -121,14 +115,14 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -137,7 +131,7 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -153,14 +147,14 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -172,7 +166,7 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFVec3f( points ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -182,26 +176,26 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad Coordinate at line " << line << ", column "; ostr << column << "\n"; ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; } - // assuming legacy kicad expectation of 1U = 0.1 inch, + // assuming legacy KiCad expectation of 1U = 0.1 inch, // convert to mm to meet the expectations of the SG structure std::vector< WRLVEC3F >::iterator sP = points.begin(); std::vector< WRLVEC3F >::iterator eP = points.end(); @@ -222,7 +216,7 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -231,7 +225,7 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -241,19 +235,18 @@ void WRL2COORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize ) { if( points.size() < 3 ) { - aCoordList = NULL; + aCoordList = nullptr; aListSize = 0; return; } aCoordList = &points[0]; aListSize = points.size(); - return; } SGNODE* WRL2COORDS::TranslateToSG( SGNODE* aParent ) { // any data manipulation must be performed by the parent node - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v2/vrml2_faceset.cpp b/plugins/3d/vrml/v2/vrml2_faceset.cpp index 8f093dfb60..9c1920a0d0 100644 --- a/plugins/3d/vrml/v2/vrml2_faceset.cpp +++ b/plugins/3d/vrml/v2/vrml2_faceset.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,8 +39,6 @@ WRL2FACESET::WRL2FACESET() : WRL2NODE() { setDefaults(); m_Type = WRL2NODES::WRL2_INDEXEDFACESET; - - return; } @@ -49,16 +48,14 @@ WRL2FACESET::WRL2FACESET( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_INDEXEDFACESET; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2FACESET::~WRL2FACESET() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying IndexedFaceSet with " << m_Children.size(); @@ -66,18 +63,16 @@ WRL2FACESET::~WRL2FACESET() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } void WRL2FACESET::setDefaults( void ) { - color = NULL; - coord = NULL; - normal = NULL; - texCoord = NULL; + color = nullptr; + coord = nullptr; + normal = nullptr; + texCoord = nullptr; ccw = true; colorPerVertex = true; @@ -119,7 +114,7 @@ bool WRL2FACESET::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_SHAPE - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) return true; return false; @@ -128,16 +123,16 @@ bool WRL2FACESET::isDangling( void ) bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -146,7 +141,7 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -154,23 +149,23 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -181,16 +176,16 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -201,16 +196,16 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_NORMAL == type ) { - if( NULL != normal ) + if( nullptr != normal ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple normal nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -221,28 +216,28 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_TEXTURECOORDINATE != type ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] unexpected code branch"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - if( NULL != texCoord ) + if( nullptr != texCoord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple texCoord nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -254,16 +249,16 @@ bool WRL2FACESET::AddRefNode( WRL2NODE* aNode ) bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -272,7 +267,7 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -280,23 +275,23 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -307,16 +302,16 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -327,16 +322,16 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_NORMAL == type ) { - if( NULL != normal ) + if( nullptr != normal ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple normal nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -347,28 +342,28 @@ bool WRL2FACESET::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_TEXTURECOORDINATE != type ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] unexpected code branch"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - if( NULL != texCoord ) + if( nullptr != texCoord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple texCoord nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -388,7 +383,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -396,14 +391,14 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -412,7 +407,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -430,14 +425,14 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -467,7 +462,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( ccw ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -477,7 +472,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -486,7 +481,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( colorPerVertex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -496,7 +491,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -505,7 +500,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( convex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -515,7 +510,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -524,7 +519,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( normalPerVertex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -534,7 +529,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -543,7 +538,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( solid ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -553,7 +548,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -562,7 +557,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFFloat( creaseAngle ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -572,7 +567,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'\n"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -588,7 +583,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFInt( colorIndex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -598,7 +593,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -607,7 +602,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFInt( coordIndex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -617,7 +612,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -626,7 +621,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFInt( normalIndex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -636,78 +631,78 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "color" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read color node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "coord" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read coord node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "normal" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read normal node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "texCoord" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read texCoord node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -716,7 +711,7 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -730,9 +725,9 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) { S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -740,12 +735,12 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating IndexedFaceSet with " << m_Children.size(); @@ -754,21 +749,21 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) ostr << coordIndex.size() << " coord indices"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -777,15 +772,15 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) size_t vsize = coordIndex.size(); - if( NULL == coord || vsize < 3 ) - return NULL; + if( nullptr == coord || vsize < 3 ) + return nullptr; WRLVEC3F* pcoords; size_t coordsize; ((WRL2COORDS*) coord)->GetCoords( pcoords, coordsize ); if( coordsize < 3 ) - return NULL; + return nullptr; // check that all indices are valid for( size_t idx = 0; idx < vsize; ++idx ) @@ -794,17 +789,17 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) continue; if( coordIndex[idx] >= (int)coordsize ) - return NULL; + return nullptr; } SHAPE lShape; - FACET* fp = NULL; + FACET* fp = nullptr; size_t iCoord; int idx; // coordinate index size_t cidx = 0; // color index SGCOLOR pc1; - if( NULL == color ) + if( nullptr == color ) { // no per-vertex colors; we can save a few CPU cycles for( iCoord = 0; iCoord < vsize; ++iCoord ) @@ -813,10 +808,10 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) if( idx < 0 ) { - if( NULL != fp ) + if( nullptr != fp ) { if( fp->HasMinPoints() ) - fp = NULL; + fp = nullptr; else fp->Init(); } @@ -828,7 +823,7 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) if( idx >= (int)coordsize ) continue; - if( NULL == fp ) + if( nullptr == fp ) fp = lShape.NewFacet(); // push the vertex value and index @@ -846,10 +841,10 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) if( idx < 0 ) { - if( NULL != fp ) + if( nullptr != fp ) { if( fp->HasMinPoints() ) - fp = NULL; + fp = nullptr; else fp->Init(); } @@ -864,7 +859,7 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) if( idx >= (int)coordsize ) continue; - if( NULL == fp ) + if( nullptr == fp ) fp = lShape.NewFacet(); // push the vertex value and index @@ -912,12 +907,12 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) } } - SGNODE* np = NULL; + SGNODE* np = nullptr; if( ccw ) - np = lShape.CalcShape( aParent, NULL, WRL1_ORDER::ORD_CCW, creaseLimit, true ); + np = lShape.CalcShape( aParent, nullptr, WRL1_ORDER::ORD_CCW, creaseLimit, true ); else - np = lShape.CalcShape( aParent, NULL, WRL1_ORDER::ORD_CLOCKWISE, creaseLimit, true ); + np = lShape.CalcShape( aParent, nullptr, WRL1_ORDER::ORD_CLOCKWISE, creaseLimit, true ); return np; } @@ -925,54 +920,50 @@ SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent ) void WRL2FACESET::unlinkChildNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() == this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; + coord = nullptr; else if( aNode == normal ) - normal = NULL; + normal = nullptr; else if( aNode == texCoord ) - texCoord = NULL; - + texCoord = nullptr; } WRL2NODE::unlinkChildNode( aNode ); - return; } void WRL2FACESET::unlinkRefNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() != this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; + coord = nullptr; else if( aNode == normal ) - normal = NULL; + normal = nullptr; else if( aNode == texCoord ) - texCoord = NULL; - + texCoord = nullptr; } WRL2NODE::unlinkRefNode( aNode ); - return; } bool WRL2FACESET::HasColors( void ) { - if( NULL == color ) + if( nullptr == color ) return false; - return ((WRL2COLOR*) color)->HasColors(); + return ( (WRL2COLOR*) color )->HasColors(); } diff --git a/plugins/3d/vrml/v2/vrml2_inline.cpp b/plugins/3d/vrml/v2/vrml2_inline.cpp index 55753404b2..cd87ffc759 100644 --- a/plugins/3d/vrml/v2/vrml2_inline.cpp +++ b/plugins/3d/vrml/v2/vrml2_inline.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,34 +34,26 @@ WRL2INLINE::WRL2INLINE() : WRL2NODE() { - m_VRML2Base = NULL; + m_VRML2Base = nullptr; m_Type = WRL2NODES::WRL2_INLINE; - m_Parent = NULL; - - return; + m_Parent = nullptr; } WRL2INLINE::WRL2INLINE( WRL2NODE* aParent ) : WRL2NODE() { - m_VRML2Base = NULL; + m_VRML2Base = nullptr; m_Type = WRL2NODES::WRL2_INLINE; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2INLINE::~WRL2INLINE() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) wxLogTrace( MASK_VRML, " * [INFO] Destroying Inline node\n" ); - #endif - - return; } @@ -73,7 +66,7 @@ bool WRL2INLINE::isDangling( void ) bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { - if( aTopNode == NULL || aTopNode->GetNodeType() != WRL2NODES::WRL2_BASE ) + if( aTopNode == nullptr || aTopNode->GetNodeType() != WRL2NODES::WRL2_BASE ) return false; m_VRML2Base = aTopNode; @@ -83,7 +76,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -91,14 +84,14 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -107,7 +100,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -126,14 +119,14 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -145,7 +138,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFString( url ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -155,7 +148,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -164,7 +157,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( bboxCenter ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -174,7 +167,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -183,7 +176,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( bboxSize ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -193,14 +186,14 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -209,7 +202,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -217,7 +210,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -226,7 +219,7 @@ bool WRL2INLINE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -236,14 +229,14 @@ bool WRL2INLINE::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -253,14 +246,14 @@ bool WRL2INLINE::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable\n"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -268,17 +261,17 @@ bool WRL2INLINE::AddChildNode( WRL2NODE* aNode ) SGNODE* WRL2INLINE::TranslateToSG( SGNODE* aParent ) { - if( NULL == aParent || NULL == m_VRML2Base ) - return NULL; + if( nullptr == aParent || nullptr == m_VRML2Base ) + return nullptr; if( url.empty() ) - return NULL; + return nullptr; S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); if( ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -286,25 +279,25 @@ SGNODE* WRL2INLINE::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } SGNODE* np = m_VRML2Base->GetInlineData( url.front() ); - if( NULL == np ) - return NULL; + if( nullptr == np ) + return nullptr; bool OK = false; - if( NULL == S3D::GetSGNodeParent( np ) ) + if( nullptr == S3D::GetSGNodeParent( np ) ) OK = S3D::AddSGNodeChild( aParent, np ); else OK = S3D::AddSGNodeRef( aParent, np ); if( !OK ) - return NULL; + return nullptr; return np; } diff --git a/plugins/3d/vrml/v2/vrml2_lineset.cpp b/plugins/3d/vrml/v2/vrml2_lineset.cpp index 24cb2e39d1..9f596081b7 100644 --- a/plugins/3d/vrml/v2/vrml2_lineset.cpp +++ b/plugins/3d/vrml/v2/vrml2_lineset.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,8 +38,6 @@ WRL2LINESET::WRL2LINESET() : WRL2NODE() { setDefaults(); m_Type = WRL2NODES::WRL2_INDEXEDLINESET; - - return; } @@ -48,16 +47,14 @@ WRL2LINESET::WRL2LINESET( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_INDEXEDLINESET; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2LINESET::~WRL2LINESET() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying IndexedLineSet with " << m_Children.size(); @@ -65,16 +62,14 @@ WRL2LINESET::~WRL2LINESET() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } void WRL2LINESET::setDefaults( void ) { - color = NULL; - coord = NULL; + color = nullptr; + coord = nullptr; colorPerVertex = true; } @@ -104,7 +99,7 @@ bool WRL2LINESET::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_SHAPE - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) return true; return false; @@ -113,16 +108,16 @@ bool WRL2LINESET::isDangling( void ) bool WRL2LINESET::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -131,7 +126,7 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -139,23 +134,23 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -166,16 +161,16 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -190,16 +185,16 @@ bool WRL2LINESET::AddRefNode( WRL2NODE* aNode ) bool WRL2LINESET::AddChildNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -208,7 +203,7 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -216,23 +211,23 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -243,16 +238,16 @@ bool WRL2LINESET::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -275,7 +270,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -283,14 +278,14 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -299,7 +294,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -317,14 +312,14 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -345,7 +340,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFBool( colorPerVertex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -355,7 +350,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -364,7 +359,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFInt( colorIndex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -374,7 +369,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -383,7 +378,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFInt( coordIndex ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -393,46 +388,46 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "color" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read color node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "coord" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read coord node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -441,7 +436,7 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -454,51 +449,47 @@ bool WRL2LINESET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2LINESET::TranslateToSG( SGNODE* aParent ) { // note: there are no plans to support drawing of lines - return NULL; + return nullptr; } void WRL2LINESET::unlinkChildNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() == this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; - + coord = nullptr; } WRL2NODE::unlinkChildNode( aNode ); - return; } void WRL2LINESET::unlinkRefNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() != this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; - + coord = nullptr; } WRL2NODE::unlinkRefNode( aNode ); - return; } bool WRL2LINESET::HasColors( void ) { - if( NULL == color ) + if( nullptr == color ) return false; return ((WRL2COLOR*) color)->HasColors(); diff --git a/plugins/3d/vrml/v2/vrml2_material.cpp b/plugins/3d/vrml/v2/vrml2_material.cpp index 2aa3a89768..1edc419339 100644 --- a/plugins/3d/vrml/v2/vrml2_material.cpp +++ b/plugins/3d/vrml/v2/vrml2_material.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,7 +36,6 @@ WRL2MATERIAL::WRL2MATERIAL() : WRL2NODE() { setDefaults(); m_Type = WRL2NODES::WRL2_MATERIAL; - return; } @@ -45,20 +45,14 @@ WRL2MATERIAL::WRL2MATERIAL( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_MATERIAL; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2MATERIAL::~WRL2MATERIAL() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node\n" ); - #endif - - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Material node" ); } @@ -78,8 +72,6 @@ void WRL2MATERIAL::setDefaults( void ) ambientIntensity = 0.2f; shininess = 0.2f; transparency = 0.0f; - - return; } @@ -87,7 +79,7 @@ bool WRL2MATERIAL::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2NODES::WRL2_APPEARANCE - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_APPEARANCE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_APPEARANCE ) return true; return false; @@ -98,14 +90,14 @@ bool WRL2MATERIAL::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -115,14 +107,14 @@ bool WRL2MATERIAL::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -130,16 +122,16 @@ bool WRL2MATERIAL::AddChildNode( WRL2NODE* aNode ) bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -151,7 +143,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -159,14 +151,14 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -175,7 +167,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -193,14 +185,14 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -219,7 +211,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( specularColor ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -229,7 +221,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -238,7 +230,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( diffuseColor ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -248,7 +240,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -257,7 +249,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( emissiveColor ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -267,7 +259,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -276,7 +268,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFFloat( shininess ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -286,7 +278,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -295,7 +287,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFFloat( transparency ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -305,7 +297,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -314,7 +306,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFFloat( ambientIntensity ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -324,14 +316,14 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -340,7 +332,7 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -354,9 +346,9 @@ SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent ) { S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -364,12 +356,12 @@ SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Material with " << m_Children.size(); @@ -377,21 +369,21 @@ SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } diff --git a/plugins/3d/vrml/v2/vrml2_node.cpp b/plugins/3d/vrml/v2/vrml2_node.cpp index 4d028f7b2d..3dcff1555a 100644 --- a/plugins/3d/vrml/v2/vrml2_node.cpp +++ b/plugins/3d/vrml/v2/vrml2_node.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,8 +45,8 @@ static NODEMAP nodenames; WRL2NODE::WRL2NODE() { - m_sgNode = NULL; - m_Parent = NULL; + m_sgNode = nullptr; + m_Parent = nullptr; m_Type = WRL2NODES::WRL2_END; if( badNames.empty() ) @@ -98,12 +99,14 @@ WRL2NODE::WRL2NODE() nodenames.insert( NODEITEM( "NavigationInfo", WRL2NODES::WRL2_NAVIGATIONINFO ) ); nodenames.insert( NODEITEM( "Normal", WRL2NODES::WRL2_NORMAL ) ); nodenames.insert( NODEITEM( "NormalInterpolator", WRL2NODES::WRL2_NORMALINTERPOLATOR ) ); - nodenames.insert( NODEITEM( "OrientationInterpolator", WRL2NODES::WRL2_ORIENTATIONINTERPOLATOR ) ); + nodenames.insert( NODEITEM( "OrientationInterpolator", + WRL2NODES::WRL2_ORIENTATIONINTERPOLATOR ) ); nodenames.insert( NODEITEM( "PixelTexture", WRL2NODES::WRL2_PIXELTEXTURE ) ); nodenames.insert( NODEITEM( "PlaneSensor", WRL2NODES::WRL2_PLANESENSOR ) ); nodenames.insert( NODEITEM( "PointLight", WRL2NODES::WRL2_POINTLIGHT ) ); nodenames.insert( NODEITEM( "PointSet", WRL2NODES::WRL2_POINTSET ) ); - nodenames.insert( NODEITEM( "PositionInterpolator", WRL2NODES::WRL2_POSITIONINTERPOLATOR ) ); + nodenames.insert( NODEITEM( "PositionInterpolator", + WRL2NODES::WRL2_POSITIONINTERPOLATOR ) ); nodenames.insert( NODEITEM( "ProximitySensor", WRL2NODES::WRL2_PROXIMITYSENSOR ) ); nodenames.insert( NODEITEM( "ScalarInterpolator", WRL2NODES::WRL2_SCALARINTERPOLATOR ) ); nodenames.insert( NODEITEM( "Script", WRL2NODES::WRL2_SCRIPT ) ); @@ -123,8 +126,6 @@ WRL2NODE::WRL2NODE() nodenames.insert( NODEITEM( "VisibilitySensor", WRL2NODES::WRL2_VISIBILITYSENSOR ) ); nodenames.insert( NODEITEM( "WorldInfo", WRL2NODES::WRL2_WORLDINFO ) ); } - - return; } @@ -157,13 +158,12 @@ WRL2NODE::~WRL2NODE() while( sC != eC ) { - (*sC)->SetParent( NULL, false ); + (*sC)->SetParent( nullptr, false ); delete *sC; ++sC; } m_Children.clear(); - return; } @@ -180,8 +180,6 @@ void WRL2NODE::addNodeRef( WRL2NODE* aNode ) return; m_BackPointers.push_back( aNode ); - - return; } @@ -196,16 +194,14 @@ void WRL2NODE::delNodeRef( WRL2NODE* aNode ) return; } - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] delNodeRef() did not find its target"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -236,14 +232,14 @@ bool WRL2NODE::SetName( const std::string& aName ) if( item != badNames.end() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] invalid node name '" << *item << "' (matches restricted word)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -251,14 +247,14 @@ bool WRL2NODE::SetName( const std::string& aName ) if( isdigit( aName[0] ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] invalid node name '" << *item << "' (begins with digit)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -273,7 +269,7 @@ bool WRL2NODE::SetName( const std::string& aName ) if( std::string::npos != aName.find_first_of( BAD_CHARS1 ) || std::string::npos != aName.find_first_of( BAD_CHARS2 ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -281,7 +277,7 @@ bool WRL2NODE::SetName( const std::string& aName ) ostr << "' (contains invalid character)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -327,7 +323,7 @@ std::string WRL2NODE::GetError( void ) WRL2NODE* WRL2NODE::FindNode( const std::string& aNodeName, const WRL2NODE *aCaller ) { if( aNodeName.empty() ) - return NULL; + return nullptr; if( !m_Name.compare( aNodeName ) ) return this; @@ -335,7 +331,7 @@ WRL2NODE* WRL2NODE::FindNode( const std::string& aNodeName, const WRL2NODE *aCal std::list< WRL2NODE* >::iterator sLA = m_Children.begin(); std::list< WRL2NODE* >::iterator eLA = m_Children.end(); - WRL2NODE* psg = NULL; + WRL2NODE* psg = nullptr; while( sLA != eLA ) { @@ -343,17 +339,18 @@ WRL2NODE* WRL2NODE::FindNode( const std::string& aNodeName, const WRL2NODE *aCal { psg = (*sLA)->FindNode( aNodeName, this ); - if( NULL != psg) + if( nullptr != psg ) return psg; } + ++sLA; } - if( NULL != m_Parent && aCaller != m_Parent ) + if( nullptr != m_Parent && aCaller != m_Parent ) return m_Parent->FindNode( aNodeName, this ); - return NULL; + return nullptr; } @@ -362,12 +359,12 @@ bool WRL2NODE::SetParent( WRL2NODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -376,19 +373,19 @@ bool WRL2NODE::SetParent( WRL2NODE* aParent, bool doUnlink ) bool WRL2NODE::AddChildNode( WRL2NODE* aNode ) { - if( aNode == NULL ) + if( aNode == nullptr ) return false; if( aNode->GetNodeType() == WRL2NODES::WRL2_BASE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to add a base node to another node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -415,30 +412,30 @@ bool WRL2NODE::AddChildNode( WRL2NODE* aNode ) bool WRL2NODE::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed as node pointer"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( aNode->GetNodeType() == WRL2NODES::WRL2_BASE ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] attempting to add a base node ref to another base node"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -476,8 +473,6 @@ void WRL2NODE::unlinkChildNode( const WRL2NODE* aNode ) ++sL; } - - return; } @@ -496,6 +491,4 @@ void WRL2NODE::unlinkRefNode( const WRL2NODE* aNode ) ++sL; } - - return; } diff --git a/plugins/3d/vrml/v2/vrml2_norms.cpp b/plugins/3d/vrml/v2/vrml2_norms.cpp index 7eb0a7f0e0..857e0920bf 100644 --- a/plugins/3d/vrml/v2/vrml2_norms.cpp +++ b/plugins/3d/vrml/v2/vrml2_norms.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL2NORMS::WRL2NORMS() : WRL2NODE() { m_Type = WRL2NODES::WRL2_NORMAL; - return; } @@ -42,20 +42,14 @@ WRL2NORMS::WRL2NORMS( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_NORMAL; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2NORMS::~WRL2NORMS() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 3 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Normal node\n" ); - #endif - - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Normal node" ); } @@ -63,7 +57,7 @@ bool WRL2NORMS::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_INDEXEDFACESET - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_INDEXEDFACESET ) return true; return false; @@ -74,14 +68,14 @@ bool WRL2NORMS::AddRefNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr<< " * [BUG] AddRefNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -91,14 +85,14 @@ bool WRL2NORMS::AddChildNode( WRL2NODE* aNode ) { // this node may not own or reference any other node - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr<< " * [BUG] AddChildNode is not applicable"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -113,7 +107,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -121,14 +115,14 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr<< line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< proc.GetError() << "\n"; @@ -137,7 +131,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -153,14 +147,14 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr<< proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -172,7 +166,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadMFVec3f( vectors ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -182,14 +176,14 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr<< " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -198,7 +192,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr<< " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -211,7 +205,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) proc.GetFilePosData( line, column ); - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr<< __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -220,7 +214,7 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr<< " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -229,5 +223,5 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2NORMS::TranslateToSG( SGNODE* aParent ) { // any data manipulation must be performed by the parent node - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/v2/vrml2_pointset.cpp b/plugins/3d/vrml/v2/vrml2_pointset.cpp index 1ff3130640..d1862ccbed 100644 --- a/plugins/3d/vrml/v2/vrml2_pointset.cpp +++ b/plugins/3d/vrml/v2/vrml2_pointset.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,8 +38,6 @@ WRL2POINTSET::WRL2POINTSET() : WRL2NODE() { setDefaults(); m_Type = WRL2NODES::WRL2_POINTSET; - - return; } @@ -48,16 +47,14 @@ WRL2POINTSET::WRL2POINTSET( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_POINTSET; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2POINTSET::~WRL2POINTSET() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying PointSet with " << m_Children.size(); @@ -65,16 +62,14 @@ WRL2POINTSET::~WRL2POINTSET() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } void WRL2POINTSET::setDefaults( void ) { - color = NULL; - coord = NULL; + color = nullptr; + coord = nullptr; } @@ -102,8 +97,7 @@ bool WRL2POINTSET::checkNodeType( WRL2NODES aType ) bool WRL2POINTSET::isDangling( void ) { // this node is dangling unless it has a parent of type WRL2_SHAPE - - if( NULL == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) + if( nullptr == m_Parent || m_Parent->GetNodeType() != WRL2NODES::WRL2_SHAPE ) return true; return false; @@ -112,16 +106,16 @@ bool WRL2POINTSET::isDangling( void ) bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -130,7 +124,7 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -138,23 +132,23 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -165,16 +159,16 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -189,16 +183,16 @@ bool WRL2POINTSET::AddRefNode( WRL2NODE* aNode ) bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -207,7 +201,7 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -215,23 +209,23 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_COLOR == type ) { - if( NULL != color ) + if( nullptr != color ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple color nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -242,16 +236,16 @@ bool WRL2POINTSET::AddChildNode( WRL2NODE* aNode ) if( WRL2NODES::WRL2_COORDINATE == type ) { - if( NULL != coord ) + if( nullptr != coord ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple coordinate nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -274,7 +268,7 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -282,14 +276,14 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -298,7 +292,7 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -316,14 +310,14 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -336,39 +330,39 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !glob.compare( "color" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read color node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "coord" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read coord node information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -377,7 +371,7 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -390,52 +384,49 @@ bool WRL2POINTSET::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2POINTSET::TranslateToSG( SGNODE* aParent ) { // note: there are no plans to support drawing of points - return NULL; + return nullptr; } void WRL2POINTSET::unlinkChildNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() == this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; - + coord = nullptr; } WRL2NODE::unlinkChildNode( aNode ); - return; } void WRL2POINTSET::unlinkRefNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode->GetParent() != this ) { if( aNode == color ) - color = NULL; + color = nullptr; else if( aNode == coord ) - coord = NULL; + coord = nullptr; } WRL2NODE::unlinkRefNode( aNode ); - return; } bool WRL2POINTSET::HasColors( void ) { - if( NULL == color ) + if( nullptr == color ) return false; - return ((WRL2COLOR*) color)->HasColors(); + return ( (WRL2COLOR*) color )->HasColors(); } diff --git a/plugins/3d/vrml/v2/vrml2_shape.cpp b/plugins/3d/vrml/v2/vrml2_shape.cpp index b1e39eebc4..7d0dd3cf00 100644 --- a/plugins/3d/vrml/v2/vrml2_shape.cpp +++ b/plugins/3d/vrml/v2/vrml2_shape.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,30 +35,27 @@ WRL2SHAPE::WRL2SHAPE() : WRL2NODE() { - appearance = NULL; - geometry = NULL; + appearance = nullptr; + geometry = nullptr; m_Type = WRL2NODES::WRL2_SHAPE; - return; } WRL2SHAPE::WRL2SHAPE( WRL2NODE* aParent ) : WRL2NODE() { - appearance = NULL; - geometry = NULL; + appearance = nullptr; + geometry = nullptr; m_Type = WRL2NODES::WRL2_SHAPE; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2SHAPE::~WRL2SHAPE() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Shape with " << m_Children.size(); @@ -65,9 +63,7 @@ WRL2SHAPE::~WRL2SHAPE() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -77,7 +73,7 @@ bool WRL2SHAPE::isDangling( void ) // WRL2_TRANSFORM // WRL2_SWITCH - if( NULL == m_Parent + if( nullptr == m_Parent || ( m_Parent->GetNodeType() != WRL2NODES::WRL2_TRANSFORM && m_Parent->GetNodeType() != WRL2NODES::WRL2_SWITCH ) ) return true; @@ -88,16 +84,16 @@ bool WRL2SHAPE::isDangling( void ) bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -106,7 +102,7 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -114,23 +110,23 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_APPEARANCE == type ) { - if( NULL != appearance ) + if( nullptr != appearance ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple appearance nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -139,16 +135,16 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) return WRL2NODE::AddRefNode( aNode ); } - if( NULL != geometry ) + if( nullptr != geometry ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple geometry nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -160,16 +156,16 @@ bool WRL2SHAPE::AddRefNode( WRL2NODE* aNode ) bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed for aNode"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -178,7 +174,7 @@ bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode ) if( !checkNodeType( type ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -186,23 +182,23 @@ bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode ) ostr << aNode->GetNodeTypeName( type ) << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( WRL2NODES::WRL2_APPEARANCE == type ) { - if( NULL != appearance ) + if( nullptr != appearance ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple appearance nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -211,16 +207,16 @@ bool WRL2SHAPE::AddChildNode( WRL2NODE* aNode ) return WRL2NODE::AddChildNode( aNode ); } - if( NULL != geometry ) + if( nullptr != geometry ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] bad file format; multiple geometry nodes"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -258,16 +254,16 @@ bool WRL2SHAPE::checkNodeType( WRL2NODES aType ) bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -279,7 +275,7 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -287,14 +283,14 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -303,7 +299,7 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -321,14 +317,14 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -341,39 +337,39 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !glob.compare( "appearance" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read appearance information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else if( !glob.compare( "geometry" ) ) { - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not read geometry information"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -382,7 +378,7 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -394,8 +390,8 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) { - if( NULL == geometry ) - return NULL; + if( nullptr == geometry ) + return nullptr; WRL2NODES geomType = geometry->GetNodeType(); @@ -404,14 +400,14 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) case WRL2NODES::WRL2_INDEXEDLINESET: case WRL2NODES::WRL2_POINTSET: case WRL2NODES::WRL2_TEXT: - return NULL; + return nullptr; break; default: break; } - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Shape with " << m_Children.size(); @@ -419,7 +415,7 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif bool vcolors = false; @@ -427,20 +423,20 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) vcolors = ((WRL2FACESET*)geometry)->HasColors(); // if there is no appearance, make use of the per vertex colors if available - if( NULL == appearance ) + if( nullptr == appearance ) { if( WRL2NODES::WRL2_INDEXEDFACESET != geometry->GetNodeType() ) - return NULL; + return nullptr; if( !vcolors ) - return NULL; + return nullptr; } S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -448,24 +444,24 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -477,26 +473,26 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) SGNODE* pShape = shNode.GetRawPtr(); SGNODE* pGeom = geometry->TranslateToSG( pShape ); - if( NULL == pGeom ) + if( nullptr == pGeom ) { // this can happen if a VRML file contains // empty point or index sets shNode.Destroy(); - return NULL; + return nullptr; } - SGNODE* pApp = NULL; + SGNODE* pApp = nullptr; - if( NULL != appearance ) + if( nullptr != appearance ) pApp = appearance->TranslateToSG( pShape ); - if( NULL != appearance && NULL == pApp ) + if( nullptr != appearance && nullptr == pApp ) { IFSG_FACESET tmp( false ); tmp.Attach( pGeom ); tmp.Destroy(); shNode.Destroy(); - return NULL; + return nullptr; } m_sgNode = shNode.GetRawPtr(); @@ -507,29 +503,27 @@ SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent ) void WRL2SHAPE::unlinkChildNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode == appearance ) - appearance = NULL; + appearance = nullptr; else if( aNode == geometry ) - geometry = NULL; + geometry = nullptr; WRL2NODE::unlinkChildNode( aNode ); - return; } void WRL2SHAPE::unlinkRefNode( const WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode == appearance ) - appearance = NULL; + appearance = nullptr; else if( aNode == geometry ) - geometry = NULL; + geometry = nullptr; WRL2NODE::unlinkRefNode( aNode ); - return; } diff --git a/plugins/3d/vrml/v2/vrml2_switch.cpp b/plugins/3d/vrml/v2/vrml2_switch.cpp index 637b9e541b..a1aea6f3e9 100644 --- a/plugins/3d/vrml/v2/vrml2_switch.cpp +++ b/plugins/3d/vrml/v2/vrml2_switch.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,8 +35,6 @@ WRL2SWITCH::WRL2SWITCH() : WRL2NODE() { m_Type = WRL2NODES::WRL2_SWITCH; whichChoice = -1; - - return; } @@ -45,16 +44,14 @@ WRL2SWITCH::WRL2SWITCH( WRL2NODE* aParent ) : WRL2NODE() m_Parent = aParent; whichChoice = -1; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2SWITCH::~WRL2SWITCH() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Switch with " << m_Children.size(); @@ -62,9 +59,7 @@ WRL2SWITCH::~WRL2SWITCH() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -87,16 +82,16 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) * } */ - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - ostr << " * [BUG] aTopNode is NULL"; + ostr << " * [BUG] aTopNode is nullptr"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -108,7 +103,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -116,14 +111,14 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -132,7 +127,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -150,14 +145,14 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -172,7 +167,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFInt( whichChoice ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -182,7 +177,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -194,7 +189,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -203,7 +198,7 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -215,16 +210,16 @@ bool WRL2SWITCH::Read( WRLPROC& proc, WRL2BASE* aTopNode ) bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed as node pointer"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -234,12 +229,12 @@ bool WRL2SWITCH::AddRefNode( WRL2NODE* aNode ) { WRL2NODE* np = aNode->GetParent(); - if( NULL != np ) + if( nullptr != np ) aNode->SetParent( this ); if( !WRL2NODE::AddChildNode( aNode ) ) { - aNode->SetParent( NULL ); + aNode->SetParent( nullptr ); return false; } } @@ -260,7 +255,7 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -268,12 +263,12 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } - WRL2NODE* child = NULL; + WRL2NODE* child = nullptr; if( '[' != tok ) { @@ -281,7 +276,7 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) if( !aTopNode->ReadNode( proc, this, &child ) ) return false; - if( NULL != child ) + if( nullptr != child ) choices.push_back( child ); if( proc.Peek() == ',' ) @@ -303,7 +298,7 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) if( !aTopNode->ReadNode( proc, this, &child ) ) return false; - if( NULL != child ) + if( nullptr != child ) choices.push_back( child ); if( proc.Peek() == ',' ) @@ -317,7 +312,7 @@ bool WRL2SWITCH::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Switch with " << m_Children.size(); @@ -325,22 +320,20 @@ SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( choices.empty() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Switch translation: no choices\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] Switch translation: no choices" ); - return NULL; + return nullptr; } S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -348,23 +341,23 @@ SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( whichChoice < 0 || whichChoice >= (int)choices.size() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Switch translation: no choice (choices = "; ostr << choices.size() << "), whichChoice = " << whichChoice; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } WRL2NODES type = choices[whichChoice]->GetNodeType(); @@ -378,7 +371,7 @@ SGNODE* WRL2SWITCH::TranslateToSG( SGNODE* aParent ) break; default: - return NULL; + return nullptr; } return choices[whichChoice]->TranslateToSG( aParent ); diff --git a/plugins/3d/vrml/v2/vrml2_transform.cpp b/plugins/3d/vrml/v2/vrml2_transform.cpp index 0387aa28b0..56e8fbf944 100644 --- a/plugins/3d/vrml/v2/vrml2_transform.cpp +++ b/plugins/3d/vrml/v2/vrml2_transform.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +34,6 @@ WRL2TRANSFORM::WRL2TRANSFORM() : WRL2NODE() { m_Type = WRL2NODES::WRL2_TRANSFORM; - return; } @@ -42,16 +42,14 @@ WRL2TRANSFORM::WRL2TRANSFORM( WRL2NODE* aParent ) : WRL2NODE() m_Type = WRL2NODES::WRL2_TRANSFORM; m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } WRL2TRANSFORM::~WRL2TRANSFORM() { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Transform with " << m_Children.size(); @@ -59,9 +57,7 @@ WRL2TRANSFORM::~WRL2TRANSFORM() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif - - return; +#endif } @@ -92,16 +88,16 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) * } */ - if( NULL == aTopNode ) + if( nullptr == aTopNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] aTopNode is NULL"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -132,7 +128,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -140,14 +136,14 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } if( '{' != tok ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; @@ -156,7 +152,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << "' at line " << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -174,14 +170,14 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) if( !proc.ReadName( glob ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -200,7 +196,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( center ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -210,7 +206,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -224,7 +220,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFRotation( rotation ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -234,7 +230,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -243,7 +239,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( scale ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -253,7 +249,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -262,7 +258,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFRotation( scaleOrientation ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -272,7 +268,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -281,7 +277,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) { if( !proc.ReadSFVec3f( translation ) ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -291,7 +287,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] message: '" << proc.GetError() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -308,7 +304,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) } else { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -317,7 +313,7 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << " * [INFO] file: '" << proc.GetFileName() << "'"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -329,16 +325,16 @@ bool WRL2TRANSFORM::Read( WRLPROC& proc, WRL2BASE* aTopNode ) bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] NULL passed as node pointer"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -349,13 +345,13 @@ bool WRL2TRANSFORM::AddRefNode( WRL2NODE* aNode ) { WRL2NODE* np = aNode->GetParent(); - if( NULL != np ) + if( nullptr != np ) aNode->SetParent( this ); if( !WRL2NODE::AddChildNode( aNode ) ) { - aNode->SetParent( NULL ); + aNode->SetParent( nullptr ); return false; } } @@ -376,7 +372,7 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) if( proc.eof() ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -384,7 +380,7 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) ostr << line << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return false; } @@ -392,7 +388,7 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) if( '[' != tok ) { // since there are no delimiters we expect a single child - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) return false; if( proc.Peek() == ',' ) @@ -411,7 +407,7 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) break; } - if( !aTopNode->ReadNode( proc, this, NULL ) ) + if( !aTopNode->ReadNode( proc, this, nullptr ) ) return false; if( proc.Peek() == ',' ) @@ -425,7 +421,7 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode ) SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent ) { - #if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) +#if defined( DEBUG_VRML2 ) && ( DEBUG_VRML2 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Transform with " << m_Children.size(); @@ -433,16 +429,16 @@ SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_Children.empty() && m_Refs.empty() ) - return NULL; + return nullptr; S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_VRML2 +#ifdef DEBUG_VRML2 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -450,24 +446,24 @@ SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -500,7 +496,7 @@ SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent ) case WRL2NODES::WRL2_INLINE: case WRL2NODES::WRL2_TRANSFORM: - if( NULL != (*sC)->TranslateToSG( txNode.GetRawPtr() ) ) + if( nullptr != (*sC)->TranslateToSG( txNode.GetRawPtr() ) ) test = true; break; @@ -519,14 +515,14 @@ SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent ) if( false == test ) { txNode.Destroy(); - return NULL; + return nullptr; } txNode.SetScale( SGPOINT( scale.x, scale.y, scale.z ) ); txNode.SetCenter( SGPOINT( center.x, center.y, center.z ) ); txNode.SetTranslation( SGPOINT( translation.x, translation.y, translation.z ) ); txNode.SetScaleOrientation( SGVECTOR( scaleOrientation.x, scaleOrientation.y, - scaleOrientation.z ), scaleOrientation.w ); + scaleOrientation.z ), scaleOrientation.w ); txNode.SetRotation( SGVECTOR( rotation.x, rotation.y, rotation.z), rotation.w ); m_sgNode = txNode.GetRawPtr(); diff --git a/plugins/3d/vrml/vrml.cpp b/plugins/3d/vrml/vrml.cpp index d633e2e9ef..0e42e4ed13 100644 --- a/plugins/3d/vrml/vrml.cpp +++ b/plugins/3d/vrml/vrml.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo - * Copyright (C) 2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,11 +24,11 @@ /* * Description: - * This plugin implements the legacy kicad VRML1/VRML2 and X3D parsers + * This plugin implements the legacy KiCad VRML1/VRML2 and X3D parsers * The plugin will invoke a VRML1 or VRML2 parser depending on the * identifying information in the file header: * - * #VRML V1.0 ascii + * #VRML V1.0 ASCII * #VRML V2.0 utf8 */ @@ -61,8 +61,8 @@ const char* GetKicadPluginName( void ) } -void GetPluginVersion( unsigned char* Major, - unsigned char* Minor, unsigned char* Patch, unsigned char* Revision ) +void GetPluginVersion( unsigned char* Major, unsigned char* Minor, unsigned char* Patch, + unsigned char* Revision ) { if( Major ) *Major = PLUGIN_VRML_MAJOR; @@ -111,7 +111,7 @@ int GetNExtensions( void ) char const* GetModelExtension( int aIndex ) { if( aIndex < 0 || aIndex >= int( file_data.extensions.size() ) ) - return NULL; + return nullptr; return file_data.extensions[aIndex].c_str(); } @@ -126,7 +126,7 @@ int GetNFilters( void ) char const* GetFileFilter( int aIndex ) { if( aIndex < 0 || aIndex >= int( file_data.filters.size() ) ) - return NULL; + return nullptr; return file_data.filters[aIndex].c_str(); } @@ -147,7 +147,7 @@ class LOCALESWITCH public: LOCALESWITCH() { - m_locale = setlocale( LC_NUMERIC, NULL ); + m_locale = setlocale( LC_NUMERIC, nullptr ); setlocale( LC_NUMERIC, "C" ); } @@ -160,8 +160,8 @@ public: SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) { - FILE_LINE_READER* modelFile = NULL; - SCENEGRAPH* scene = NULL; + FILE_LINE_READER* modelFile = nullptr; + SCENEGRAPH* scene = nullptr; wxString filename = aFileName; wxFileName tmpfilename; @@ -217,7 +217,7 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) catch( IO_ERROR & ) { wxLogError( wxS( " * " ) + _( "[INFO] load failed: input line too long\n" ) ); - return NULL; + return nullptr; } @@ -230,26 +230,26 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) if( proc.GetVRMLType() == WRLVERSION::VRML_V1 ) { - wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 1.0 file\n" ); + wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 1.0 file" ); WRL1BASE* bp = new WRL1BASE; if( !bp->Read( proc ) ) { - wxLogTrace( MASK_VRML, " * [INFO] load failed\n" ); + wxLogTrace( MASK_VRML, " * [INFO] load failed" ); } else { - wxLogTrace( MASK_VRML, " * [INFO] load completed\n" ); + wxLogTrace( MASK_VRML, " * [INFO] load completed" ); - scene = (SCENEGRAPH*)bp->TranslateToSG( NULL, NULL ); + scene = (SCENEGRAPH*)bp->TranslateToSG( nullptr, nullptr ); } delete bp; } else { - wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 2.0 file\n" ); + wxLogTrace( MASK_VRML, " * [INFO] Processing VRML 2.0 file" ); WRL2BASE* bp = new WRL2BASE; @@ -258,25 +258,25 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) if( !bp->Read( proc ) ) { - wxLogTrace( MASK_VRML, " * [INFO] load failed\n" ); + wxLogTrace( MASK_VRML, " * [INFO] load failed" ); } else { - wxLogTrace( MASK_VRML, " * [INFO] load completed\n" ); + wxLogTrace( MASK_VRML, " * [INFO] load completed" ); // for now we recalculate all normals per-vertex per-face - scene = (SCENEGRAPH*)bp->TranslateToSG( NULL ); + scene = (SCENEGRAPH*)bp->TranslateToSG( nullptr ); } delete bp; } - if( NULL != modelFile ) + if( nullptr != modelFile ) delete modelFile; // DEBUG: WRITE OUT VRML2 FILE TO CONFIRM STRUCTURE - #if ( defined( DEBUG_VRML1 ) && DEBUG_VRML1 > 3 ) \ - || ( defined( DEBUG_VRML2 ) && DEBUG_VRML2 > 3 ) +#if ( defined( DEBUG_VRML1 ) && DEBUG_VRML1 > 3 ) \ + || ( defined( DEBUG_VRML2 ) && DEBUG_VRML2 > 3 ) if( scene ) { wxFileName fn( wxString::FromUTF8Unchecked( aFileName ) ); @@ -291,7 +291,7 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) output.append( wxT(".wrl") ); S3D::WriteVRML( output.ToUTF8(), true, (SGNODE*)(scene), true, true ); } - #endif +#endif return scene; } @@ -299,7 +299,7 @@ SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline ) SCENEGRAPH* LoadX3D( const wxString& aFileName ) { - SCENEGRAPH* scene = NULL; + SCENEGRAPH* scene = nullptr; X3DPARSER model; scene = model.Load( aFileName ); @@ -309,17 +309,17 @@ SCENEGRAPH* LoadX3D( const wxString& aFileName ) SCENEGRAPH* Load( char const* aFileName ) { - if( NULL == aFileName ) - return NULL; + if( nullptr == aFileName ) + return nullptr; wxString fname = wxString::FromUTF8Unchecked( aFileName ); if( !wxFileName::FileExists( fname ) ) - return NULL; + return nullptr; LOCALESWITCH switcher; - SCENEGRAPH* scene = NULL; + SCENEGRAPH* scene = nullptr; wxString ext = wxFileName( fname ).GetExt(); if( ext == "x3d" || ext == "X3D" ) diff --git a/plugins/3d/vrml/wrlfacet.cpp b/plugins/3d/vrml/wrlfacet.cpp index fb0ba1e5bc..62f214e1b7 100644 --- a/plugins/3d/vrml/wrlfacet.cpp +++ b/plugins/3d/vrml/wrlfacet.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016-2017 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -123,16 +124,16 @@ static float VCalcCosAngle( const WRLVEC3F& p1, const WRLVEC3F& p2, const WRLVEC // place a limit to prevent calculations from blowing up if( dn < LOWER_LIMIT ) { - if( (p12 + p13 - p23) < FLT_EPSILON ) + if( ( p12 + p13 - p23 ) < FLT_EPSILON ) return -1.0f; - if( (p12 + p13 - p23) > FLT_EPSILON ) + if( ( p12 + p13 - p23 ) > FLT_EPSILON ) return 1.0f; return 0.0f; } - float cosAngle = (p12 + p13 - p23) / dn; + float cosAngle = ( p12 + p13 - p23 ) / dn; // check the domain; errors in the cosAngle calculation // can result in domain errors @@ -167,8 +168,6 @@ void FACET::Init() face_normal.y = 0.0; face_normal.z = 0.0; maxIdx = 0; - - return; } @@ -200,8 +199,6 @@ void FACET::AddVertex( WRLVEC3F& aVertex, int aIndex ) if( aIndex > maxIdx ) maxIdx = aIndex; - - return; } @@ -386,8 +383,8 @@ void FACET::CalcVertexNormal( int aIndex, std::list< FACET* > &aFacetList, float // normalize the vector float dn = sqrtf( norms[idx].x * norms[idx].x - + norms[idx].y * norms[idx].y - + norms[idx].z * norms[idx].z ); + + norms[idx].y * norms[idx].y + + norms[idx].z * norms[idx].z ); if( dn > LOWER_LIMIT ) { @@ -410,8 +407,6 @@ void FACET::CalcVertexNormal( int aIndex, std::list< FACET* > &aFacetList, float ++idx; ++sI; } - - return; } @@ -466,7 +461,7 @@ bool FACET::GetFaceNormal( WRLVEC3F& aNorm ) bool FACET::GetData( std::vector< WRLVEC3F >& aVertexList, std::vector< WRLVEC3F >& aNormalsList, - std::vector< SGCOLOR >& aColorsList, WRL1_ORDER aVertexOrder ) + std::vector< SGCOLOR >& aColorsList, WRL1_ORDER aVertexOrder ) { // if no normals are calculated we simply return if( norms.empty() ) @@ -663,8 +658,6 @@ void FACET::CollectVertices( std::vector< std::list< FACET* > >& aFacetList ) aFacetList[*sI].push_back( this ); ++sI; } - - return; } @@ -681,8 +674,6 @@ void FACET::Renormalize( float aMaxValue ) vnweight[i].y /= aMaxValue; vnweight[i].z /= aMaxValue; } - - return; } @@ -711,10 +702,10 @@ FACET* SHAPE::NewFacet() SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrder, - float aCreaseLimit, bool isVRML2 ) + float aCreaseLimit, bool isVRML2 ) { if( facets.empty() || !facets.front()->HasMinPoints() ) - return NULL; + return nullptr; std::vector< std::list< FACET* > > flist; @@ -744,7 +735,7 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd ++maxIdx; if( maxIdx < 3 ) - return NULL; + return nullptr; flist.resize( maxIdx ); @@ -790,7 +781,7 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd flist.clear(); if( vertices.size() < 3 ) - return NULL; + return nullptr; IFSG_SHAPE shapeNode( false ); @@ -800,7 +791,7 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd if( aColor ) { - if( NULL == S3D::GetSGNodeParent( aColor ) ) + if( nullptr == S3D::GetSGNodeParent( aColor ) ) shapeNode.AddChildNode( aColor ); else shapeNode.AddRefNode( aColor ); diff --git a/plugins/3d/vrml/wrlproc.cpp b/plugins/3d/vrml/wrlproc.cpp index ee192ef489..22887b38a5 100644 --- a/plugins/3d/vrml/wrlproc.cpp +++ b/plugins/3d/vrml/wrlproc.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,22 +29,31 @@ #include #include "wrlproc.h" -#define GETLINE do {\ - try { \ - char* cp = m_file->ReadLine(); \ - if( NULL == cp ) { \ - m_eof = true; \ - m_buf.clear(); \ - } else { \ - m_buf = cp; \ - m_bufpos = 0; \ - } \ - m_fileline = m_file->LineNumber(); \ - } catch( ... ) { \ - m_error = " * [INFO] input line too long"; \ - m_eof = true; \ - m_buf.clear(); \ - } } while( 0 ) +#define GETLINE \ + do \ + { \ + try \ + { \ + char* cp = m_file->ReadLine(); \ + if( nullptr == cp ) \ + { \ + m_eof = true; \ + m_buf.clear(); \ + } \ + else \ + { \ + m_buf = cp; \ + m_bufpos = 0; \ + } \ + m_fileline = m_file->LineNumber(); \ + } \ + catch( ... ) \ + { \ + m_error = " * [INFO] input line too long"; \ + m_eof = true; \ + m_buf.clear(); \ + } \ + } while( 0 ) WRLPROC::WRLPROC( LINE_READER* aLineReader ) @@ -54,7 +64,7 @@ WRLPROC::WRLPROC( LINE_READER* aLineReader ) m_bufpos = 0; m_file = aLineReader; - if( NULL == aLineReader ) + if( nullptr == aLineReader ) { m_eof = true; return; @@ -119,14 +129,11 @@ WRLPROC::WRLPROC( LINE_READER* aLineReader ) m_error.append( m_filename ); m_error.append( 1, '\'' ); m_badchars.clear(); - - return; } WRLPROC::~WRLPROC() { - return; } @@ -227,7 +234,7 @@ WRLVERSION WRLPROC::GetVRMLType( void ) const char* WRLPROC::GetParentDir( void ) { if( m_filedir.empty() ) - return NULL; + return nullptr; return m_filedir.c_str(); } @@ -620,7 +627,8 @@ bool WRLPROC::ReadString( std::string& aSFString ) if( !EatSpace() ) { std::ostringstream ostr; - ostr << "invalid VRML file; expecting string at line " << ifline << " but found nothing"; + ostr << "invalid VRML file; expecting string at line " << ifline << + " but found nothing"; m_error = ostr.str(); return false; @@ -677,7 +685,6 @@ bool WRLPROC::ReadString( std::string& aSFString ) m_error = ostr.str(); return false; - } } @@ -730,13 +737,21 @@ bool WRLPROC::ReadSFBool( bool& aSFBool ) return false; if( !tmp.compare( "0" ) ) + { aSFBool = false; + } else if( !tmp.compare( "1" ) ) + { aSFBool = true; + } else if( !tmp.compare( "TRUE" ) ) + { aSFBool = true; + } else if( !tmp.compare( "FALSE" ) ) + { aSFBool = false; + } else { std::ostringstream ostr; @@ -1477,7 +1492,6 @@ bool WRLPROC::ReadMFFloat( std::vector< float >& aMFFloat ) if( ',' == m_buf[m_bufpos] ) Pop(); - } ++m_bufpos; @@ -1813,7 +1827,6 @@ bool WRLPROC::ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f ) if( ',' == m_buf[m_bufpos] ) Pop(); - } ++m_bufpos; @@ -2008,6 +2021,4 @@ void WRLPROC::Pop( void ) { if( m_bufpos < m_buf.size() ) ++m_bufpos; - - return; } diff --git a/plugins/3d/vrml/x3d.cpp b/plugins/3d/vrml/x3d.cpp index 3b9cd92eee..1a9a548c0c 100644 --- a/plugins/3d/vrml/x3d.cpp +++ b/plugins/3d/vrml/x3d.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Cirilo Bernardo * Copyright (C) 2013 Tuomas Vaherkoski - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ /* * Description: - * This plugin implements the legacy kicad X3D parser. + * This plugin implements the legacy KiCad X3D parser. * Due to the rare use of X3D models, this plugin is a simple * reimplementation of the legacy x3dmodelparser.cpp and is not * intended to be a compliant X3D implementation. @@ -49,23 +49,21 @@ SCENEGRAPH* X3DPARSER::Load( const wxString& aFileName ) wxXmlDocument doc; if( !stream.IsOk() || !doc.Load( stream ) ) - return NULL; + return nullptr; if( doc.GetRoot()->GetName() != wxT( "X3D" ) ) - return NULL; + return nullptr; NODE_LIST children; // VRML Grouping Nodes at top level if( !getGroupingNodes( doc.GetRoot(), children ) ) - return NULL; + return nullptr; X3D_DICT dictionary; // dictionary for USE/DEF implementation X3DNODE* topNode = new X3DTRANSFORM; bool ok = false; - for( NODE_LIST::iterator node_it = children.begin(); - node_it != children.end(); - ++node_it ) + for( NODE_LIST::iterator node_it = children.begin(); node_it != children.end(); ++node_it ) { wxXmlNode* node = *node_it; wxString name = node->GetName(); @@ -81,10 +79,10 @@ SCENEGRAPH* X3DPARSER::Load( const wxString& aFileName ) } } - SCENEGRAPH* sp = NULL; + SCENEGRAPH* sp = nullptr; if( ok ) - sp = (SCENEGRAPH*) topNode->TranslateToSG( NULL ); + sp = (SCENEGRAPH*) topNode->TranslateToSG( nullptr ); delete topNode; return sp; @@ -94,11 +92,9 @@ SCENEGRAPH* X3DPARSER::Load( const wxString& aFileName ) bool X3DPARSER::getGroupingNodes( wxXmlNode* aNode, std::vector& aResult ) { aResult.clear(); - wxXmlNode* scene = NULL; + wxXmlNode* scene = nullptr; - for( wxXmlNode* child = aNode->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = aNode->GetChildren(); child != nullptr; child = child->GetNext() ) { if( child->GetName() == "Scene" ) { @@ -107,12 +103,10 @@ bool X3DPARSER::getGroupingNodes( wxXmlNode* aNode, std::vector& aRe } } - if( NULL == scene ) + if( nullptr == scene ) return false; - for( wxXmlNode* child = scene->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = scene->GetChildren(); child != nullptr; child = child->GetNext() ) { const wxString& name = child->GetName(); diff --git a/plugins/3d/vrml/x3d/x3d_appearance.cpp b/plugins/3d/vrml/x3d/x3d_appearance.cpp index b9580c8570..2f0e72594b 100644 --- a/plugins/3d/vrml/x3d/x3d_appearance.cpp +++ b/plugins/3d/vrml/x3d/x3d_appearance.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -45,7 +46,7 @@ X3DAPP::X3DAPP( X3DNODE* aParent ) : X3DNODE() m_Type = X3D_APPEARANCE; init(); - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES ptype = aParent->GetNodeType(); @@ -53,7 +54,7 @@ X3DAPP::X3DAPP( X3DNODE* aParent ) : X3DNODE() m_Parent = aParent; } - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return; @@ -62,9 +63,7 @@ X3DAPP::X3DAPP( X3DNODE* aParent ) : X3DNODE() X3DAPP::~X3DAPP() { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Appearance\n" ); - #endif + wxLogTrace( MASK_VRML, " * [INFO] Destroying Appearance" ); if( !m_MatName.empty() && m_Dict ) m_Dict->DelName( m_MatName, this ); @@ -106,9 +105,7 @@ void X3DAPP::readFields( wxXmlNode* aNode ) wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -121,7 +118,7 @@ void X3DAPP::readFields( wxXmlNode* aNode ) { X3DNODE* np = m_Dict->FindName( prop->GetValue() ); - if( NULL != np && np->GetNodeType() == X3D_APPEARANCE ) + if( nullptr != np && np->GetNodeType() == X3D_APPEARANCE ) { X3DAPP* ap = (X3DAPP*) np; diffuseColor = ap->diffuseColor; @@ -133,35 +130,42 @@ void X3DAPP::readFields( wxXmlNode* aNode ) } } else if( pname == "diffuseColor" ) + { X3D::ParseSFVec3( prop->GetValue(), diffuseColor ); + } else if( pname == "emissiveColor" ) + { X3D::ParseSFVec3( prop->GetValue(), emissiveColor ); + } else if( pname == "specularColor" ) + { X3D::ParseSFVec3( prop->GetValue(), specularColor ); + } else if( pname == "ambientIntensity" ) + { X3D::ParseSFFloat( prop->GetValue(), ambientIntensity ); + } else if( pname == "shininess" ) + { X3D::ParseSFFloat( prop->GetValue(), shininess ); + } else if( pname == "transparency" ) + { X3D::ParseSFFloat( prop->GetValue(), transparency ); - + } } - - return; } bool X3DAPP::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) { - if( NULL == aTopNode || NULL == aNode ) + if( nullptr == aTopNode || nullptr == aNode ) return false; m_Dict = &aDict; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -172,18 +176,16 @@ bool X3DAPP::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) } } - wxXmlNode* pmat = NULL; + wxXmlNode* pmat = nullptr; - for( wxXmlNode* child = aNode->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = aNode->GetChildren(); child != nullptr; child = child->GetNext() ) { if( child->GetName() == "Material" ) pmat = child; } - if( NULL == pmat ) + if( nullptr == pmat ) return false; readFields( pmat ); @@ -200,7 +202,7 @@ bool X3DAPP::SetParent( X3DNODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES nt = aParent->GetNodeType(); @@ -208,19 +210,19 @@ bool X3DAPP::SetParent( X3DNODE* aParent, bool doUnlink ) return false; } - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; } - bool X3DAPP::AddChildNode( X3DNODE* aNode ) +bool X3DAPP::AddChildNode( X3DNODE* aNode ) { return false; } @@ -236,20 +238,20 @@ SGNODE* X3DAPP::TranslateToSG( SGNODE* aParent ) { S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_X3D +#ifdef DEBUG_X3D std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] Appearance does not have a Shape parent (parent ID: "; ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); - #endif +#endif - return NULL; + return nullptr; } - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Appearance with " << m_Children.size(); @@ -257,21 +259,21 @@ SGNODE* X3DAPP::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } diff --git a/plugins/3d/vrml/x3d/x3d_base.cpp b/plugins/3d/vrml/x3d/x3d_base.cpp index 3de01dcdea..c0c40d1728 100644 --- a/plugins/3d/vrml/x3d/x3d_base.cpp +++ b/plugins/3d/vrml/x3d/x3d_base.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -67,23 +68,23 @@ bool X3D_DICT::DelName( const wxString& aName, X3DNODE* aNode ) X3DNODE* X3D_DICT::FindName( const wxString& aName ) { if( aName.empty() ) - return NULL; + return nullptr; std::map< wxString, X3DNODE* >::iterator ir = reg.find( aName ); if( ir != reg.end() ) return ir->second; - return NULL; + return nullptr; } X3DNODE::X3DNODE() { m_Type = X3D_INVALID; - m_Parent = NULL; - m_sgNode = NULL; - m_Dict = NULL; + m_Parent = nullptr; + m_sgNode = nullptr; + m_Dict = nullptr; return; } @@ -91,7 +92,7 @@ X3DNODE::X3DNODE() X3DNODE::~X3DNODE() { - if( !m_Name.empty() && NULL != m_Dict ) + if( !m_Name.empty() && nullptr != m_Dict ) m_Dict->DelName( m_Name, this ); return; @@ -172,12 +173,12 @@ void X3DNODE::delNodeRef( X3DNODE* aNode ) return; } - #ifdef DEBUG_X3D +#ifdef DEBUG_X3D std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] delNodeRef() did not find its target"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); - #endif +#endif return; } diff --git a/plugins/3d/vrml/x3d/x3d_coords.cpp b/plugins/3d/vrml/x3d/x3d_coords.cpp index ca7f53271e..6e713cac22 100644 --- a/plugins/3d/vrml/x3d/x3d_coords.cpp +++ b/plugins/3d/vrml/x3d/x3d_coords.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,8 +34,6 @@ X3DCOORDS::X3DCOORDS() : X3DNODE() { m_Type = X3D_COORDINATE; - - return; } @@ -42,7 +41,7 @@ X3DCOORDS::X3DCOORDS( X3DNODE* aParent ) : X3DNODE() { m_Type = X3D_COORDINATE; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES ptype = aParent->GetNodeType(); @@ -50,33 +49,26 @@ X3DCOORDS::X3DCOORDS( X3DNODE* aParent ) : X3DNODE() m_Parent = aParent; } - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } X3DCOORDS::~X3DCOORDS() { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) - wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate\n" ); - #endif - return; + wxLogTrace( MASK_VRML, " * [INFO] Destroying Coordinate" ); } bool X3DCOORDS::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) { - if( NULL == aTopNode || NULL == aNode ) + if( nullptr == aTopNode || nullptr == aNode ) return false; m_Dict = &aDict; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -124,7 +116,6 @@ bool X3DCOORDS::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) ++i; } - } } @@ -143,7 +134,7 @@ bool X3DCOORDS::SetParent( X3DNODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES nt = aParent->GetNodeType(); @@ -151,12 +142,12 @@ bool X3DCOORDS::SetParent( X3DNODE* aParent, bool doUnlink ) return false; } - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -179,18 +170,17 @@ void X3DCOORDS::GetCoords( WRLVEC3F*& aCoordList, size_t& aListSize ) { if( points.size() < 3 ) { - aCoordList = NULL; + aCoordList = nullptr; aListSize = 0; return; } aCoordList = &points[0]; aListSize = points.size(); - return; } SGNODE* X3DCOORDS::TranslateToSG( SGNODE* aParent ) { - return NULL; + return nullptr; } diff --git a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp index 6463d1deab..be027d0f9e 100644 --- a/plugins/3d/vrml/x3d/x3d_ifaceset.cpp +++ b/plugins/3d/vrml/x3d/x3d_ifaceset.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,7 +39,7 @@ X3DIFACESET::X3DIFACESET() : X3DNODE() { m_Type = X3D_INDEXED_FACE_SET; - coord = NULL; + coord = nullptr; init(); return; @@ -48,10 +49,10 @@ X3DIFACESET::X3DIFACESET() : X3DNODE() X3DIFACESET::X3DIFACESET( X3DNODE* aParent ) : X3DNODE() { m_Type = X3D_INDEXED_FACE_SET; - coord = NULL; + coord = nullptr; init(); - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES ptype = aParent->GetNodeType(); @@ -59,7 +60,7 @@ X3DIFACESET::X3DIFACESET( X3DNODE* aParent ) : X3DNODE() m_Parent = aParent; } - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return; @@ -68,9 +69,9 @@ X3DIFACESET::X3DIFACESET( X3DNODE* aParent ) : X3DNODE() X3DIFACESET::~X3DIFACESET() { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) wxLogTrace( MASK_VRML, " * [INFO] Destroying IndexedFaceSet\n" ); - #endif +#endif return; } @@ -78,7 +79,7 @@ X3DIFACESET::~X3DIFACESET() void X3DIFACESET::init() { - coord = NULL; + coord = nullptr; ccw = true; creaseAngle = 0.733f; // approx 42 degrees; this is larger than VRML spec. @@ -96,9 +97,7 @@ void X3DIFACESET::readFields( wxXmlNode* aNode ) wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -108,7 +107,9 @@ void X3DIFACESET::readFields( wxXmlNode* aNode ) m_Dict->AddName( m_Name, this ); } else if( pname == "ccw" ) + { X3D::ParseSFBool( prop->GetValue(), ccw ); + } else if( pname == "creaseAngle" ) { X3D::ParseSFFloat( prop->GetValue(), creaseAngle ); @@ -139,16 +140,14 @@ void X3DIFACESET::readFields( wxXmlNode* aNode ) bool X3DIFACESET::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) { - if( NULL == aTopNode || NULL == aNode ) + if( nullptr == aTopNode || nullptr == aNode ) return false; m_Dict = &aDict; readFields( aNode ); bool ok = false; - for( wxXmlNode* child = aNode->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = aNode->GetChildren(); child != nullptr; child = child->GetNext() ) { if( child->GetName() == "Coordinate" ) ok = X3D::ReadCoordinates( child, this, aDict ); @@ -171,7 +170,7 @@ bool X3DIFACESET::SetParent( X3DNODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES nt = aParent->GetNodeType(); @@ -179,12 +178,12 @@ bool X3DIFACESET::SetParent( X3DNODE* aParent, bool doUnlink ) return false; } - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -193,7 +192,7 @@ bool X3DIFACESET::SetParent( X3DNODE* aParent, bool doUnlink ) bool X3DIFACESET::AddChildNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; if( aNode->GetNodeType() != X3D_COORDINATE ) @@ -202,7 +201,7 @@ bool X3DIFACESET::AddChildNode( X3DNODE* aNode ) if( aNode == coord ) return true; - if( NULL != coord ) + if( nullptr != coord ) return false; m_Children.push_back( aNode ); @@ -217,7 +216,7 @@ bool X3DIFACESET::AddChildNode( X3DNODE* aNode ) bool X3DIFACESET::AddRefNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; if( aNode->GetNodeType() != X3D_COORDINATE ) @@ -226,7 +225,7 @@ bool X3DIFACESET::AddRefNode( X3DNODE* aNode ) if( aNode == coord ) return true; - if( NULL != coord ) + if( nullptr != coord ) return false; m_Refs.push_back( aNode ); @@ -240,9 +239,9 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) { S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_SHAPE ) + if( nullptr != aParent && ptype != S3D::SGTYPE_SHAPE ) { - #ifdef DEBUG_X3D +#ifdef DEBUG_X3D do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -250,12 +249,12 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating IndexedFaceSet with " << m_Children.size(); @@ -264,21 +263,21 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) ostr << coordIndex.size() << " coord indices"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -287,15 +286,15 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) size_t vsize = coordIndex.size(); - if( NULL == coord || vsize < 3 ) - return NULL; + if( nullptr == coord || vsize < 3 ) + return nullptr; WRLVEC3F* pcoords; size_t coordsize; ((X3DCOORDS*) coord)->GetCoords( pcoords, coordsize ); if( coordsize < 3 ) - return NULL; + return nullptr; // check that all indices are valid for( size_t idx = 0; idx < vsize; ++idx ) @@ -304,11 +303,11 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) continue; if( coordIndex[idx] >= (int)coordsize ) - return NULL; + return nullptr; } SHAPE lShape; - FACET* fp = NULL; + FACET* fp = nullptr; size_t iCoord; int idx; // coordinate index @@ -319,10 +318,10 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) if( idx < 0 ) { - if( NULL != fp ) + if( nullptr != fp ) { if( fp->HasMinPoints() ) - fp = NULL; + fp = nullptr; else fp->Init(); } @@ -334,19 +333,19 @@ SGNODE* X3DIFACESET::TranslateToSG( SGNODE* aParent ) if( idx >= (int)coordsize ) continue; - if( NULL == fp ) + if( nullptr == fp ) fp = lShape.NewFacet(); // push the vertex value and index fp->AddVertex( pcoords[idx], idx ); } - SGNODE* np = NULL; + SGNODE* np = nullptr; if( ccw ) - np = lShape.CalcShape( aParent, NULL, WRL1_ORDER::ORD_CCW, creaseLimit, true ); + np = lShape.CalcShape( aParent, nullptr, WRL1_ORDER::ORD_CCW, creaseLimit, true ); else - np = lShape.CalcShape( aParent, NULL, WRL1_ORDER::ORD_CLOCKWISE, creaseLimit, true ); + np = lShape.CalcShape( aParent, nullptr, WRL1_ORDER::ORD_CLOCKWISE, creaseLimit, true ); return np; } diff --git a/plugins/3d/vrml/x3d/x3d_ops.cpp b/plugins/3d/vrml/x3d/x3d_ops.cpp index a4aee2aa81..fface45a57 100644 --- a/plugins/3d/vrml/x3d/x3d_ops.cpp +++ b/plugins/3d/vrml/x3d/x3d_ops.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,14 +34,12 @@ bool X3D::ReadTransform( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { // note: we must have a parent or else we will have a memory leak - if( NULL == aParent || NULL == aNode ) + if( nullptr == aParent || nullptr == aNode ) return false; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -48,7 +47,7 @@ bool X3D::ReadTransform( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { X3DNODE* np = aDict.FindName( prop->GetValue() ); - if( NULL == np ) + if( nullptr == np ) return false; if( !aParent->AddRefNode( np ) ) @@ -80,14 +79,12 @@ bool X3D::ReadSwitch( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) bool X3D::ReadShape( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { // note: we must have a parent or else we will have a memory leak - if( NULL == aParent || NULL == aNode ) + if( nullptr == aParent || nullptr == aNode ) return false; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -95,7 +92,7 @@ bool X3D::ReadShape( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { X3DNODE* np = aDict.FindName( prop->GetValue() ); - if( NULL == np ) + if( nullptr == np ) return false; if( !aParent->AddRefNode( np ) ) @@ -120,14 +117,12 @@ bool X3D::ReadShape( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) bool X3D::ReadAppearance( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { // note: we must have a parent or else we will have a memory leak - if( NULL == aParent || NULL == aNode ) + if( nullptr == aParent || nullptr == aNode ) return false; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -135,7 +130,7 @@ bool X3D::ReadAppearance( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { X3DNODE* np = aDict.FindName( prop->GetValue() ); - if( NULL == np ) + if( nullptr == np ) return false; if( !aParent->AddRefNode( np ) ) @@ -160,14 +155,12 @@ bool X3D::ReadAppearance( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) bool X3D::ReadIndexedFaceSet( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { // note: we must have a parent or else we will have a memory leak - if( NULL == aParent || NULL == aNode ) + if( nullptr == aParent || nullptr == aNode ) return false; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -175,7 +168,7 @@ bool X3D::ReadIndexedFaceSet( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDic { X3DNODE* np = aDict.FindName( prop->GetValue() ); - if( NULL == np ) + if( nullptr == np ) return false; if( !aParent->AddRefNode( np ) ) @@ -200,14 +193,12 @@ bool X3D::ReadIndexedFaceSet( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDic bool X3D::ReadCoordinates( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { // note: we must have a parent or else we will have a memory leak - if( NULL == aParent || NULL == aNode ) + if( nullptr == aParent || nullptr == aNode ) return false; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -215,7 +206,7 @@ bool X3D::ReadCoordinates( wxXmlNode* aNode, X3DNODE* aParent, X3D_DICT& aDict ) { X3DNODE* np = aDict.FindName( prop->GetValue() ); - if( NULL == np ) + if( nullptr == np ) return false; if( !aParent->AddRefNode( np ) ) diff --git a/plugins/3d/vrml/x3d/x3d_shape.cpp b/plugins/3d/vrml/x3d/x3d_shape.cpp index 93d07f980b..419a3f5bb0 100644 --- a/plugins/3d/vrml/x3d/x3d_shape.cpp +++ b/plugins/3d/vrml/x3d/x3d_shape.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,20 +35,18 @@ X3DSHAPE::X3DSHAPE() : X3DNODE() { m_Type = X3D_SHAPE; - appearance = NULL; - geometry = NULL; - - return; + appearance = nullptr; + geometry = nullptr; } X3DSHAPE::X3DSHAPE( X3DNODE* aParent ) : X3DNODE() { m_Type = X3D_SHAPE; - appearance = NULL; - geometry = NULL; + appearance = nullptr; + geometry = nullptr; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES ptype = aParent->GetNodeType(); @@ -55,16 +54,14 @@ X3DSHAPE::X3DSHAPE( X3DNODE* aParent ) : X3DNODE() m_Parent = aParent; } - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); - - return; } X3DSHAPE::~X3DSHAPE() { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Shape with " << m_Children.size(); @@ -72,7 +69,7 @@ X3DSHAPE::~X3DSHAPE() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return; } @@ -80,18 +77,16 @@ X3DSHAPE::~X3DSHAPE() bool X3DSHAPE::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) { - if( NULL == aTopNode || NULL == aNode ) + if( nullptr == aTopNode || nullptr == aNode ) return false; - if( NULL != appearance || NULL != geometry ) + if( nullptr != appearance || nullptr != geometry ) return false; m_Dict = &aDict; wxXmlAttribute* prop; - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -102,20 +97,17 @@ bool X3DSHAPE::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) } } - for( wxXmlNode* child = aNode->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = aNode->GetChildren(); child != nullptr; child = child->GetNext() ) { wxString name = child->GetName(); - if( name == "Appearance" && NULL == appearance ) + if( name == "Appearance" && nullptr == appearance ) X3D::ReadAppearance( child, this, aDict ); - else if( name == "IndexedFaceSet" && NULL == geometry ) + else if( name == "IndexedFaceSet" && nullptr == geometry ) X3D::ReadIndexedFaceSet( child, this, aDict ); - } - if( NULL == appearance || NULL == geometry ) + if( nullptr == appearance || nullptr == geometry ) return false; if( !SetParent( aTopNode ) ) @@ -130,7 +122,7 @@ bool X3DSHAPE::SetParent( X3DNODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES nt = aParent->GetNodeType(); @@ -138,12 +130,12 @@ bool X3DSHAPE::SetParent( X3DNODE* aParent, bool doUnlink ) return false; } - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -152,7 +144,7 @@ bool X3DSHAPE::SetParent( X3DNODE* aParent, bool doUnlink ) bool X3DSHAPE::AddChildNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; X3DNODES tchild = aNode->GetNodeType(); @@ -173,23 +165,27 @@ bool X3DSHAPE::AddChildNode( X3DNODE* aNode ) if( X3D_APPEARANCE == tchild ) { - if( NULL == appearance ) + if( nullptr == appearance ) { m_Children.push_back( aNode ); appearance = aNode; } else + { return false; + } } else { - if( NULL == geometry ) + if( nullptr == geometry ) { m_Children.push_back( aNode ); geometry = aNode; } else + { return false; + } } if( aNode->GetParent() != this ) @@ -201,7 +197,7 @@ bool X3DSHAPE::AddChildNode( X3DNODE* aNode ) bool X3DSHAPE::AddRefNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; X3DNODES tchild = aNode->GetNodeType(); @@ -222,25 +218,29 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode ) if( X3D_APPEARANCE == tchild ) { - if( NULL == appearance ) + if( nullptr == appearance ) { m_Refs.push_back( aNode ); aNode->addNodeRef( this ); appearance = aNode; } else + { return false; + } } else { - if( NULL == geometry ) + if( nullptr == geometry ) { m_Refs.push_back( aNode ); aNode->addNodeRef( this ); geometry = aNode; } else + { return false; + } } return true; @@ -249,10 +249,10 @@ bool X3DSHAPE::AddRefNode( X3DNODE* aNode ) SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) { - if( NULL == geometry || NULL == appearance ) - return NULL; + if( nullptr == geometry || nullptr == appearance ) + return nullptr; - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Shape with " << m_Children.size(); @@ -260,13 +260,13 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_X3D +#ifdef DEBUG_X3D do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -274,24 +274,24 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -304,7 +304,7 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) SGNODE* pGeom = geometry->TranslateToSG( pShape ); SGNODE* pApp = appearance->TranslateToSG( pShape ); - if( NULL == pApp || NULL == pGeom ) + if( nullptr == pApp || nullptr == pGeom ) { if( pGeom ) { @@ -321,7 +321,7 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) } shNode.Destroy(); - return NULL; + return nullptr; } m_sgNode = shNode.GetRawPtr(); @@ -332,29 +332,27 @@ SGNODE* X3DSHAPE::TranslateToSG( SGNODE* aParent ) void X3DSHAPE::unlinkChildNode( const X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode == appearance ) - appearance = NULL; + appearance = nullptr; else if( aNode == geometry ) - geometry = NULL; + geometry = nullptr; X3DNODE::unlinkChildNode( aNode ); - return; } void X3DSHAPE::unlinkRefNode( const X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return; if( aNode == appearance ) - appearance = NULL; + appearance = nullptr; else if( aNode == geometry ) - geometry = NULL; + geometry = nullptr; X3DNODE::unlinkRefNode( aNode ); - return; } diff --git a/plugins/3d/vrml/x3d/x3d_transform.cpp b/plugins/3d/vrml/x3d/x3d_transform.cpp index 262db573f7..4d3387b5d4 100644 --- a/plugins/3d/vrml/x3d/x3d_transform.cpp +++ b/plugins/3d/vrml/x3d/x3d_transform.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -44,7 +45,7 @@ X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE() m_Type = X3D_TRANSFORM; init(); - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES ptype = aParent->GetNodeType(); @@ -52,7 +53,7 @@ X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE() m_Parent = aParent; } - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return; @@ -61,7 +62,7 @@ X3DTRANSFORM::X3DTRANSFORM( X3DNODE* aParent ) : X3DNODE() X3DTRANSFORM::~X3DTRANSFORM() { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Destroying Transform with " << m_Children.size(); @@ -69,7 +70,7 @@ X3DTRANSFORM::~X3DTRANSFORM() ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif return; } @@ -117,9 +118,7 @@ void X3DTRANSFORM::readFields( wxXmlNode* aNode ) // legacy behavior of 1 X3D unit = 0.1 inch; the SG* // classes expect all units in mm. - for( prop = aNode->GetAttributes(); - prop != NULL; - prop = prop->GetNext() ) + for( prop = aNode->GetAttributes(); prop != nullptr; prop = prop->GetNext() ) { const wxString& pname = prop->GetName(); @@ -134,35 +133,36 @@ void X3DTRANSFORM::readFields( wxXmlNode* aNode ) center *= 2.54; } else if( pname == "scale" ) + { X3D::ParseSFVec3( prop->GetValue(), scale ); + } else if( pname == "translation" ) { X3D::ParseSFVec3( prop->GetValue(), translation ); translation *= 2.54; } else if( pname == "rotation" ) + { X3D::ParseSFRotation( prop->GetValue(), rotation ); + } else if( pname == "scaleOrientation" ) + { X3D::ParseSFRotation( prop->GetValue(), scaleOrientation ); - + } } - - return; } bool X3DTRANSFORM::Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) { - if( NULL == aTopNode || NULL == aNode ) + if( nullptr == aTopNode || nullptr == aNode ) return false; m_Dict = &aDict; readFields( aNode ); bool ok = false; - for( wxXmlNode* child = aNode->GetChildren(); - child != NULL; - child = child->GetNext() ) + for( wxXmlNode* child = aNode->GetChildren(); child != nullptr; child = child->GetNext() ) { wxString name = child->GetName(); @@ -190,7 +190,7 @@ bool X3DTRANSFORM::SetParent( X3DNODE* aParent, bool doUnlink ) if( aParent == m_Parent ) return true; - if( NULL != aParent ) + if( nullptr != aParent ) { X3DNODES nt = aParent->GetNodeType(); @@ -198,12 +198,12 @@ bool X3DTRANSFORM::SetParent( X3DNODE* aParent, bool doUnlink ) return false; } - if( NULL != m_Parent && doUnlink ) + if( nullptr != m_Parent && doUnlink ) m_Parent->unlinkChildNode( this ); m_Parent = aParent; - if( NULL != m_Parent ) + if( nullptr != m_Parent ) m_Parent->AddChildNode( this ); return true; @@ -212,7 +212,7 @@ bool X3DTRANSFORM::SetParent( X3DNODE* aParent, bool doUnlink ) bool X3DTRANSFORM::AddChildNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; X3DNODES tchild = aNode->GetNodeType(); @@ -242,7 +242,7 @@ bool X3DTRANSFORM::AddChildNode( X3DNODE* aNode ) bool X3DTRANSFORM::AddRefNode( X3DNODE* aNode ) { - if( NULL == aNode ) + if( nullptr == aNode ) return false; X3DNODES tchild = aNode->GetNodeType(); @@ -270,7 +270,7 @@ bool X3DTRANSFORM::AddRefNode( X3DNODE* aNode ) SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) { - #if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) +#if defined( DEBUG_X3D ) && ( DEBUG_X3D > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Translating Transform with " << m_Children.size(); @@ -278,16 +278,16 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) ostr << m_BackPointers.size() << " backpointers"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif if( m_Children.empty() && m_Refs.empty() ) - return NULL; + return nullptr; S3D::SGTYPES ptype = S3D::GetSGNodeType( aParent ); - if( NULL != aParent && ptype != S3D::SGTYPE_TRANSFORM ) + if( nullptr != aParent && ptype != S3D::SGTYPE_TRANSFORM ) { - #ifdef DEBUG_X3D +#ifdef DEBUG_X3D do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; @@ -295,24 +295,24 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) ostr << ptype << ")"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif - return NULL; + return nullptr; } if( m_sgNode ) { - if( NULL != aParent ) + if( nullptr != aParent ) { - if( NULL == S3D::GetSGNodeParent( m_sgNode ) + if( nullptr == S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeChild( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } else if( aParent != S3D::GetSGNodeParent( m_sgNode ) && !S3D::AddSGNodeRef( aParent, m_sgNode ) ) { - return NULL; + return nullptr; } } @@ -344,7 +344,7 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) case X3D_SWITCH: case X3D_TRANSFORM: - if( NULL != (*sC)->TranslateToSG( txNode.GetRawPtr() ) ) + if( nullptr != (*sC)->TranslateToSG( txNode.GetRawPtr() ) ) test = true; break; @@ -363,7 +363,7 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) if( false == test ) { txNode.Destroy(); - return NULL; + return nullptr; } txNode.SetScale( SGPOINT( scale.x, scale.y, scale.z ) ); @@ -371,7 +371,7 @@ SGNODE* X3DTRANSFORM::TranslateToSG( SGNODE* aParent ) txNode.SetTranslation( SGPOINT( translation.x, translation.y, translation.z ) ); txNode.SetScaleOrientation( SGVECTOR( scaleOrientation.x, scaleOrientation.y, scaleOrientation.z ), scaleOrientation.w ); - txNode.SetRotation( SGVECTOR( rotation.x, rotation.y, rotation.z), rotation.w ); + txNode.SetRotation( SGVECTOR( rotation.x, rotation.y, rotation.z ), rotation.w ); m_sgNode = txNode.GetRawPtr(); diff --git a/plugins/ldr/3d/pluginldr3D.cpp b/plugins/ldr/3d/pluginldr3D.cpp index 33c0451380..2038da58b4 100644 --- a/plugins/ldr/3d/pluginldr3D.cpp +++ b/plugins/ldr/3d/pluginldr3D.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,12 +39,12 @@ KICAD_PLUGIN_LDR_3D::KICAD_PLUGIN_LDR_3D() { ok = false; - m_getNExtensions = NULL; - m_getModelExtension = NULL; - m_getNFilters = NULL; - m_getFileFilter = NULL; - m_canRender = NULL; - m_load = NULL; + m_getNExtensions = nullptr; + m_getModelExtension = nullptr; + m_getNFilters = nullptr; + m_getFileFilter = nullptr; + m_canRender = nullptr; + m_load = nullptr; return; } @@ -73,13 +74,13 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName ) m_error = ostr.str(); } - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] failed on file " << aFullFileName.ToUTF8() << "\n"; ostr << " * [INFO] error: " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; } @@ -94,128 +95,128 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName ) LINK_ITEM( m_canRender, PLUGIN_3D_CAN_RENDER, "CanRender" ); LINK_ITEM( m_load, PLUGIN_3D_LOAD, "Load" ); - #ifdef DEBUG - bool fail = false; +#ifdef DEBUG + bool fail = false; - if( !m_getNExtensions ) + if( !m_getNExtensions ) + { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetNExtensions')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; + } + + if( !m_getModelExtension ) + { + if( !fail ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetNExtensions')"; + wxString errmsg = "incompatible plugin (missing function 'GetModelExtension')"; ostr << errmsg.ToUTF8() << "\n"; ostr << "'" << aFullFileName.ToUTF8() << "'"; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); fail = true; } - - if( !m_getModelExtension ) + else { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetModelExtension')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetModelExtension'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + wxString errmsg = "missing function 'GetModelExtension'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } + } - if( !m_getNFilters ) + if( !m_getNFilters ) + { + if( !fail ) { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetNFilters')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetNFilters'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetNFilters')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; } - - if( !m_getFileFilter ) + else { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetFileFilter')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetFileFilter'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + wxString errmsg = "missing function 'GetNFilters'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } + } - if( !m_canRender ) + if( !m_getFileFilter ) + { + if( !fail ) { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'CanRender')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'CanRender'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetFileFilter')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; } - - if( !m_load ) + else { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'Load')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'Load'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + wxString errmsg = "missing function 'GetFileFilter'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } + } - #endif + if( !m_canRender ) + { + if( !fail ) + { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'CanRender')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; + } + else + { + std::ostringstream ostr; + wxString errmsg = "missing function 'CanRender'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + } + + if( !m_load ) + { + if( !fail ) + { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'Load')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + else + { + std::ostringstream ostr; + wxString errmsg = "missing function 'Load'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + } + +#endif if( !m_getNExtensions || !m_getModelExtension || !m_getNFilters - || !m_getFileFilter || !m_canRender || !m_load ) + || !m_getFileFilter || !m_canRender || !m_load ) { Close(); @@ -233,7 +234,7 @@ bool KICAD_PLUGIN_LDR_3D::Open( const wxString& aFullFileName ) void KICAD_PLUGIN_LDR_3D::Close( void ) { - #ifdef DEBUG +#ifdef DEBUG if( ok ) { std::ostringstream ostr; @@ -241,15 +242,15 @@ void KICAD_PLUGIN_LDR_3D::Close( void ) ostr << " * [INFO] closing plugin"; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } - #endif +#endif ok = false; - m_getNExtensions = NULL; - m_getModelExtension = NULL; - m_getNFilters = NULL; - m_getFileFilter = NULL; - m_canRender = NULL; - m_load = NULL; + m_getNExtensions = nullptr; + m_getModelExtension = nullptr; + m_getNFilters = nullptr; + m_getFileFilter = nullptr; + m_canRender = nullptr; + m_load = nullptr; close(); return; @@ -257,7 +258,7 @@ void KICAD_PLUGIN_LDR_3D::Close( void ) void KICAD_PLUGIN_LDR_3D::GetLoaderVersion( unsigned char* Major, unsigned char* Minor, - unsigned char* Patch, unsigned char* Revision ) const + unsigned char* Patch, unsigned char* Revision ) const { if( Major ) *Major = PLUGIN_3D_MAJOR; @@ -275,7 +276,6 @@ void KICAD_PLUGIN_LDR_3D::GetLoaderVersion( unsigned char* Major, unsigned char* } -// these functions are shadows of the 3D Plugin functions from 3d_plugin.h int KICAD_PLUGIN_LDR_3D::GetNExtensions( void ) { m_error.clear(); @@ -288,16 +288,16 @@ int KICAD_PLUGIN_LDR_3D::GetNExtensions( void ) return 0; } - if( NULL == m_getNExtensions ) + if( nullptr == m_getNExtensions ) { m_error = "[BUG] GetNExtensions is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return 0; } @@ -315,21 +315,21 @@ char const* KICAD_PLUGIN_LDR_3D::GetModelExtension( int aIndex ) if( m_error.empty() ) m_error = "[INFO] no open plugin / plugin could not be opened"; - return NULL; + return nullptr; } - if( NULL == m_getModelExtension ) + if( nullptr == m_getModelExtension ) { m_error = "[BUG] GetModelExtension is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif - return NULL; + return nullptr; } return m_getModelExtension( aIndex ); @@ -348,16 +348,16 @@ int KICAD_PLUGIN_LDR_3D::GetNFilters( void ) return 0; } - if( NULL == m_getNFilters ) + if( nullptr == m_getNFilters ) { m_error = "[BUG] GetNFilters is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return 0; } @@ -375,21 +375,21 @@ char const* KICAD_PLUGIN_LDR_3D::GetFileFilter( int aIndex ) if( m_error.empty() ) m_error = "[INFO] no open plugin / plugin could not be opened"; - return NULL; + return nullptr; } - if( NULL == m_getFileFilter ) + if( nullptr == m_getFileFilter ) { m_error = "[BUG] GetFileFilter is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif - return NULL; + return nullptr; } return m_getFileFilter( aIndex ); @@ -408,16 +408,16 @@ bool KICAD_PLUGIN_LDR_3D::CanRender( void ) return false; } - if( NULL == m_canRender ) + if( nullptr == m_canRender ) { m_error = "[BUG] CanRender is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; } @@ -435,21 +435,21 @@ SCENEGRAPH* KICAD_PLUGIN_LDR_3D::Load( char const* aFileName ) if( m_error.empty() ) m_error = "[INFO] no open plugin / plugin could not be opened"; - return NULL; + return nullptr; } - if( NULL == m_load ) + if( nullptr == m_load ) { m_error = "[BUG] Load is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif - return NULL; + return nullptr; } return m_load( aFileName ); diff --git a/plugins/ldr/pluginldr.cpp b/plugins/ldr/pluginldr.cpp index 0328501a33..b7c237d775 100644 --- a/plugins/ldr/pluginldr.cpp +++ b/plugins/ldr/pluginldr.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Cirilo Bernardo + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -34,11 +35,11 @@ KICAD_PLUGIN_LDR::KICAD_PLUGIN_LDR() { ok = false; - m_getPluginClass = NULL; - m_getClassVersion = NULL; - m_checkClassVersion = NULL; - m_getPluginName = NULL; - m_getVersion = NULL; + m_getPluginClass = nullptr; + m_getClassVersion = nullptr; + m_checkClassVersion = nullptr; + m_getPluginName = nullptr; + m_getVersion = nullptr; return; } @@ -67,12 +68,12 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC if( !m_PluginLoader.IsLoaded() ) { - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * could not open file: '" << aFullFileName.ToUTF8() << "'"; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; } @@ -82,104 +83,104 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC LINK_ITEM( m_getPluginName, GET_PLUGIN_NAME, "GetKicadPluginName" ); LINK_ITEM( m_getVersion, GET_VERSION, "GetPluginVersion" ); - #ifdef DEBUG - bool fail = false; +#ifdef DEBUG + bool fail = false; - if( !m_getPluginClass ) + if( !m_getPluginClass ) + { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginClass')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; + } + + if( !m_getClassVersion ) + { + if( !fail ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginClass')"; + wxString errmsg = "incompatible plugin (missing function 'GetClassVersion')"; ostr << errmsg.ToUTF8() << "\n"; ostr << "'" << aFullFileName.ToUTF8() << "'"; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); fail = true; } - - if( !m_getClassVersion ) + else { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetClassVersion')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetClassVersion'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + wxString errmsg = "missing function 'GetClassVersion'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } + } - if( !m_checkClassVersion ) + if( !m_checkClassVersion ) + { + if( !fail ) { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'CheckClassVersion')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'CheckClassVersion'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'CheckClassVersion')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; } - - if( !m_getPluginName ) + else { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginName')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - fail = true; - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetKicadPluginName'"; - ostr << errmsg.ToUTF8(); - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + wxString errmsg = "missing function 'CheckClassVersion'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } + } - if( !m_getVersion ) + if( !m_getPluginName ) + { + if( !fail ) { - if( !fail ) - { - std::ostringstream ostr; - ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; - wxString errmsg = "incompatible plugin (missing function 'GetVersion')"; - ostr << errmsg.ToUTF8() << "\n"; - ostr << "'" << aFullFileName.ToUTF8() << "'"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } - else - { - std::ostringstream ostr; - wxString errmsg = "missing function 'GetVersion'"; - ostr << errmsg.ToUTF8() << "\n"; - wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - } + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetKicadPluginName')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + fail = true; } + else + { + std::ostringstream ostr; + wxString errmsg = "missing function 'GetKicadPluginName'"; + ostr << errmsg.ToUTF8(); + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + } - #endif + if( !m_getVersion ) + { + if( !fail ) + { + std::ostringstream ostr; + ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; + wxString errmsg = "incompatible plugin (missing function 'GetVersion')"; + ostr << errmsg.ToUTF8() << "\n"; + ostr << "'" << aFullFileName.ToUTF8() << "'"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + else + { + std::ostringstream ostr; + wxString errmsg = "missing function 'GetVersion'"; + ostr << errmsg.ToUTF8() << "\n"; + wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); + } + } + +#endif if( !m_getPluginClass || !m_getClassVersion || !m_checkClassVersion || !m_getPluginName || !m_getVersion ) @@ -204,7 +205,7 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC if( pclassName ) m_error.append( pclassName ); else - m_error.append( "NULL" ); + m_error.append( "nullptr" ); m_error.append( ")" ); @@ -252,19 +253,19 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC m_fileName = aFullFileName; - #ifdef DEBUG +#ifdef DEBUG do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] opened plugin " << m_fileName.ToUTF8(); char const* cp = m_getPluginName(); - if( NULL != cp ) + if( nullptr != cp ) ostr << " * [INFO] plugin name: '" << cp << "'\n"; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); } while( 0 ); - #endif +#endif ok = true; @@ -284,11 +285,11 @@ bool KICAD_PLUGIN_LDR::open( const wxString& aFullFileName, const char* aPluginC void KICAD_PLUGIN_LDR::close( void ) { ok = false; - m_getPluginClass = NULL; - m_getClassVersion = NULL; - m_checkClassVersion = NULL; - m_getPluginName = NULL; - m_getVersion = NULL; + m_getPluginClass = nullptr; + m_getClassVersion = nullptr; + m_checkClassVersion = nullptr; + m_getPluginName = nullptr; + m_getVersion = nullptr; m_PluginLoader.Unload(); return; @@ -323,10 +324,10 @@ char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void ) if( m_error.empty() ) m_error = "[INFO] no open plugin / plugin could not be opened"; - return NULL; + return nullptr; } - if( NULL == m_getPluginClass ) + if( nullptr == m_getPluginClass ) { m_error = "[BUG] GetPluginClass is not linked"; @@ -337,7 +338,7 @@ char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void ) wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); #endif - return NULL; + return nullptr; } return m_getPluginClass(); @@ -345,7 +346,7 @@ char const* KICAD_PLUGIN_LDR::GetKicadPluginClass( void ) bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Minor, - unsigned char* Patch, unsigned char* Revision ) + unsigned char* Patch, unsigned char* Revision ) { m_error.clear(); @@ -374,7 +375,7 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min return false; } - if( NULL == m_checkClassVersion ) + if( nullptr == m_checkClassVersion ) { m_error = "[BUG] CheckClassVersion is not linked"; @@ -407,7 +408,7 @@ bool KICAD_PLUGIN_LDR::GetClassVersion( unsigned char* Major, unsigned char* Min bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Minor, - unsigned char Patch, unsigned char Revision ) + unsigned char Patch, unsigned char Revision ) { m_error.clear(); @@ -419,16 +420,16 @@ bool KICAD_PLUGIN_LDR::CheckClassVersion( unsigned char Major, unsigned char Min return false; } - if( NULL == m_checkClassVersion ) + if( nullptr == m_checkClassVersion ) { m_error = "[BUG] CheckClassVersion is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; } @@ -446,21 +447,21 @@ const char* KICAD_PLUGIN_LDR::GetKicadPluginName( void ) if( m_error.empty() ) m_error = "[INFO] no open plugin / plugin could not be opened"; - return NULL; + return nullptr; } - if( NULL == m_getPluginName ) + if( nullptr == m_getPluginName ) { m_error = "[BUG] GetKicadPluginName is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif - return NULL; + return nullptr; } return m_getPluginName(); @@ -468,7 +469,7 @@ const char* KICAD_PLUGIN_LDR::GetKicadPluginName( void ) bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor, - unsigned char* Patch, unsigned char* Revision ) + unsigned char* Patch, unsigned char* Revision ) { m_error.clear(); @@ -480,16 +481,16 @@ bool KICAD_PLUGIN_LDR::GetVersion( unsigned char* Major, unsigned char* Minor, return false; } - if( NULL == m_getVersion ) + if( nullptr == m_getVersion ) { m_error = "[BUG] GetKicadPluginName is not linked"; - #ifdef DEBUG +#ifdef DEBUG std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << m_error; wxLogTrace( MASK_PLUGINLDR, "%s\n", ostr.str().c_str() ); - #endif +#endif return false; }