KiCad PCB EDA Suite
export_vrml.cpp File Reference
#include <cmath>
#include <exception>
#include <fstream>
#include <iomanip>
#include <vector>
#include <wx/dir.h>
#include "3d_cache/3d_cache.h"
#include "3d_cache/3d_info.h"
#include "class_board.h"
#include "class_edge_mod.h"
#include "class_module.h"
#include "class_pcb_text.h"
#include "class_track.h"
#include "class_zone.h"
#include "convert_to_biu.h"
#include "draw_graphic_text.h"
#include "macros.h"
#include "pgm_base.h"
#include "plugins/3dapi/ifsg_all.h"
#include "streamwrapper.h"
#include "vrml_layer.h"
#include "pcb_edit_frame.h"
#include "../../kicad/kicad.h"
#include <zone_filler.h>

Go to the source code of this file.

Classes

struct  VRML_COLOR
 
class  MODEL_VRML
 

Macros

#define MIN_VRML_LINEWIDTH   0.12
 
#define ART_OFFSET   0.025
 
#define PLATE_OFFSET   0.005
 

Enumerations

enum  VRML_COLOR_INDEX {
  VRML_COLOR_NONE = -1, VRML_COLOR_PCB = 0, VRML_COLOR_TRACK, VRML_COLOR_SILK,
  VRML_COLOR_TIN, VRML_COLOR_LAST
}
 

Functions

static bool GetLayer (MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
 
static void create_vrml_shell (IFSG_TRANSFORM &PcbOutput, VRML_COLOR_INDEX colorID, VRML_LAYER *layer, double top_z, double bottom_z)
 
static void create_vrml_plane (IFSG_TRANSFORM &PcbOutput, VRML_COLOR_INDEX colorID, VRML_LAYER *layer, double aHeight, bool aTopPlane)
 
static void write_triangle_bag (std::ostream &aOut_file, VRML_COLOR &aColor, VRML_LAYER *aLayer, bool aPlane, bool aTop, double aTop_z, double aBottom_z)
 
static void write_layers (MODEL_VRML &aModel, BOARD *aPcb, const char *aFileName, OSTREAM *aOutputFile)
 
static void compute_layer_Zs (MODEL_VRML &aModel, BOARD *pcb)
 
static void export_vrml_line (MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
 
static void export_vrml_circle (MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
 
static void export_vrml_arc (MODEL_VRML &aModel, LAYER_NUM layer, double centerx, double centery, double arc_startx, double arc_starty, double width, double arc_angle)
 
static void export_vrml_drawsegment (MODEL_VRML &aModel, DRAWSEGMENT *drawseg)
 
static void vrml_text_callback (int x0, int y0, int xf, int yf)
 
static void export_vrml_pcbtext (MODEL_VRML &aModel, TEXTE_PCB *text)
 
static void export_vrml_drawings (MODEL_VRML &aModel, BOARD *pcb)
 
static void export_vrml_board (MODEL_VRML &aModel, BOARD *aPcb)
 
static void export_round_padstack (MODEL_VRML &aModel, BOARD *pcb, double x, double y, double r, LAYER_NUM bottom_layer, LAYER_NUM top_layer, double hole)
 
static void export_vrml_via (MODEL_VRML &aModel, BOARD *aPcb, const VIA *aVia)
 
static void export_vrml_tracks (MODEL_VRML &aModel, BOARD *pcb)
 
static void export_vrml_zones (MODEL_VRML &aModel, BOARD *aPcb)
 
static void export_vrml_text_module (TEXTE_MODULE *module)
 
static void export_vrml_edge_module (MODEL_VRML &aModel, EDGE_MODULE *aOutline, MODULE *aModule)
 
static void export_vrml_padshape (MODEL_VRML &aModel, VRML_LAYER *aTinLayer, D_PAD *aPad)
 
static void export_vrml_pad (MODEL_VRML &aModel, BOARD *aPcb, D_PAD *aPad)
 
static void build_quat (double x, double y, double z, double a, double q[4])
 
static void from_quat (double q[4], double rot[4])
 
static void compose_quat (double q1[4], double q2[4], double qr[4])
 
static void export_vrml_module (MODEL_VRML &aModel, BOARD *aPcb, MODULE *aModule, std::ostream *aOutputFile)
 
static SGNODEgetSGColor (VRML_COLOR_INDEX colorIdx)
 

Variables

static S3D_CACHEcache
 
static bool USE_INLINES
 
static bool USE_DEFS
 
static bool USE_RELPATH
 
static double WORLD_SCALE = 1.0
 
static double BOARD_SCALE
 
static const int PRECISION = 6
 
static wxString SUBDIR_3D
 
static wxString PROJ_DIR
 
static VRML_COLOR colors [VRML_COLOR_LAST]
 
static SGNODEsgmaterial [VRML_COLOR_LAST] = { NULL }
 
static MODEL_VRMLmodel_vrml
 

Macro Definition Documentation

#define ART_OFFSET   0.025

Definition at line 58 of file export_vrml.cpp.

Referenced by compute_layer_Zs(), and write_layers().

#define MIN_VRML_LINEWIDTH   0.12

Definition at line 55 of file export_vrml.cpp.

Referenced by MODEL_VRML::MODEL_VRML().

#define PLATE_OFFSET   0.005

Definition at line 60 of file export_vrml.cpp.

Referenced by export_vrml_pad().

Enumeration Type Documentation

Enumerator
VRML_COLOR_NONE 
VRML_COLOR_PCB 
VRML_COLOR_TRACK 
VRML_COLOR_SILK 
VRML_COLOR_TIN 
VRML_COLOR_LAST 

Definition at line 129 of file export_vrml.cpp.

Function Documentation

static void build_quat ( double  x,
double  y,
double  z,
double  a,
double  q[4] 
)
static

Definition at line 1278 of file export_vrml.cpp.

Referenced by export_vrml_module().

1279 {
1280  double sina = sin( a / 2 );
1281 
1282  q[0] = x * sina;
1283  q[1] = y * sina;
1284  q[2] = z * sina;
1285  q[3] = cos( a / 2 );
1286 }
static void compose_quat ( double  q1[4],
double  q2[4],
double  qr[4] 
)
static

Definition at line 1302 of file export_vrml.cpp.

Referenced by export_vrml_module().

1303 {
1304  double tmp[4];
1305 
1306  tmp[0] = q2[3] * q1[0] + q2[0] * q1[3] + q2[1] * q1[2] - q2[2] * q1[1];
1307  tmp[1] = q2[3] * q1[1] + q2[1] * q1[3] + q2[2] * q1[0] - q2[0] * q1[2];
1308  tmp[2] = q2[3] * q1[2] + q2[2] * q1[3] + q2[0] * q1[1] - q2[1] * q1[0];
1309  tmp[3] = q2[3] * q1[3] - q2[0] * q1[0] - q2[1] * q1[1] - q2[2] * q1[2];
1310 
1311  qr[0] = tmp[0];
1312  qr[1] = tmp[1];
1313  qr[2] = tmp[2];
1314  qr[3] = tmp[3];
1315 }
static void compute_layer_Zs ( MODEL_VRML aModel,
BOARD pcb 
)
static

Definition at line 561 of file export_vrml.cpp.

References LSET::AllCuMask(), ART_OFFSET, B_Adhes, B_Mask, B_Paste, B_SilkS, BOARD_SCALE, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Mask, F_Paste, F_SilkS, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), MODEL_VRML::m_brd_thickness, and MODEL_VRML::SetLayerZ().

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

562 {
563  int copper_layers = pcb->GetCopperLayerCount();
564 
565  // We call it 'layer' thickness, but it's the whole board thickness!
567  double half_thickness = aModel.m_brd_thickness / 2;
568 
569  // Compute each layer's Z value, more or less like the 3d view
570  for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
571  {
572  PCB_LAYER_ID i = *seq;
573 
574  if( i < copper_layers )
575  aModel.SetLayerZ( i, half_thickness - aModel.m_brd_thickness * i / (copper_layers - 1) );
576  else
577  aModel.SetLayerZ( i, - half_thickness ); // bottom layer
578  }
579 
580  /* To avoid rounding interference, we apply an epsilon to each
581  * successive layer */
582  double epsilon_z = Millimeter2iu( ART_OFFSET ) * BOARD_SCALE;
583  aModel.SetLayerZ( B_Paste, -half_thickness - epsilon_z * 4 );
584  aModel.SetLayerZ( B_Adhes, -half_thickness - epsilon_z * 3 );
585  aModel.SetLayerZ( B_SilkS, -half_thickness - epsilon_z * 2 );
586  aModel.SetLayerZ( B_Mask, -half_thickness - epsilon_z );
587  aModel.SetLayerZ( F_Mask, half_thickness + epsilon_z );
588  aModel.SetLayerZ( F_SilkS, half_thickness + epsilon_z * 2 );
589  aModel.SetLayerZ( F_Adhes, half_thickness + epsilon_z * 3 );
590  aModel.SetLayerZ( F_Paste, half_thickness + epsilon_z * 4 );
591  aModel.SetLayerZ( Dwgs_User, half_thickness + epsilon_z * 5 );
592  aModel.SetLayerZ( Cmts_User, half_thickness + epsilon_z * 6 );
593  aModel.SetLayerZ( Eco1_User, half_thickness + epsilon_z * 7 );
594  aModel.SetLayerZ( Eco2_User, half_thickness + epsilon_z * 8 );
595  aModel.SetLayerZ( Edge_Cuts, 0 );
596 }
void SetLayerZ(LAYER_NUM aLayer, double aValue)
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
static double BOARD_SCALE
Definition: export_vrml.cpp:67
int GetCopperLayerCount() const
Function GetCopperLayerCount.
PCB_LAYER_ID
A quick note on layer IDs:
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
double m_brd_thickness
#define ART_OFFSET
Definition: export_vrml.cpp:58
static void create_vrml_plane ( IFSG_TRANSFORM PcbOutput,
VRML_COLOR_INDEX  colorID,
VRML_LAYER *  layer,
double  aHeight,
bool  aTopPlane 
)
static

Definition at line 1676 of file export_vrml.cpp.

References IFSG_NORMALS::AddNormal(), IFSG_NODE::GetRawPtr(), getSGColor(), S3D::GetSGNodeParent(), IFSG_COORDS::SetCoordsList(), and IFSG_INDEX::SetIndices().

Referenced by GetLayer(), and write_layers().

1678 {
1679  std::vector< double > vertices;
1680  std::vector< int > idxPlane;
1681  std::vector< int > idxSide;
1682 
1683  if( !(*layer).Get2DTriangles( vertices, idxPlane, top_z, aTopPlane ) )
1684  {
1685 #ifdef DEBUG
1686  do {
1687  std::ostringstream ostr;
1688  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1689  ostr << " * [INFO] no vertex data";
1690  wxLogDebug( "%s\n", ostr.str().c_str() );
1691  } while( 0 );
1692 #endif
1693 
1694  return;
1695  }
1696 
1697  if( ( idxPlane.size() % 3 ) || ( idxSide.size() % 3 ) )
1698  {
1699 #ifdef DEBUG
1700  do {
1701  std::ostringstream ostr;
1702  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1703  ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
1704  wxLogDebug( "%s\n", ostr.str().c_str() );
1705  } while( 0 );
1706 #endif
1707 
1708  throw( std::runtime_error( "[BUG] index lists are not a multiple of 3 (not a triangle list)" ) );
1709  }
1710 
1711  std::vector< SGPOINT > vlist;
1712  size_t nvert = vertices.size() / 3;
1713  size_t j = 0;
1714 
1715  for( size_t i = 0; i < nvert; ++i, j+= 3 )
1716  vlist.push_back( SGPOINT( vertices[j], vertices[j+1], vertices[j+2] ) );
1717 
1718  // create the intermediate scenegraph
1719  IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline
1720  IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals
1721  IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes
1722  IFSG_COORDS cp( face ); // coordinates for all faces
1723  cp.SetCoordsList( nvert, &vlist[0] );
1724  IFSG_COORDINDEX coordIdx( face ); // coordinate indices for top and bottom planes only
1725  coordIdx.SetIndices( idxPlane.size(), &idxPlane[0] );
1726  IFSG_NORMALS norms( face ); // normals for the top and bottom planes
1727 
1728  // set the normals
1729  if( aTopPlane )
1730  {
1731  for( size_t i = 0; i < nvert; ++i )
1732  norms.AddNormal( 0.0, 0.0, 1.0 );
1733  }
1734  else
1735  {
1736  for( size_t i = 0; i < nvert; ++i )
1737  norms.AddNormal( 0.0, 0.0, -1.0 );
1738  }
1739 
1740  // assign a color from the palette
1741  SGNODE* modelColor = getSGColor( colorID );
1742 
1743  if( NULL != modelColor )
1744  {
1745  if( NULL == S3D::GetSGNodeParent( modelColor ) )
1746  shape.AddChildNode( modelColor );
1747  else
1748  shape.AddRefNode( modelColor );
1749  }
1750 
1751  return;
1752 }
SGNODE * GetRawPtr(void)
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:66
Class IFSG_COORDS is the wrapper for SGCOORDS.
Definition: ifsg_coords.h:40
Class IFSG_COORDINDEX is the wrapper for SGCOORDINDEX.
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:636
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
Class IFSG_NORMALS is the wrapper for the SGNORMALS class.
Definition: ifsg_normals.h:40
static SGNODE * getSGColor(VRML_COLOR_INDEX colorIdx)
Class IFSG_FACESET is the wrapper for the SGFACESET class.
Definition: ifsg_faceset.h:40
Class IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH...
Class IFSG_SHAPE is the wrapper for the SGSHAPE class.
Definition: ifsg_shape.h:40
static void create_vrml_shell ( IFSG_TRANSFORM PcbOutput,
VRML_COLOR_INDEX  colorID,
VRML_LAYER *  layer,
double  top_z,
double  bottom_z 
)
static

Definition at line 1755 of file export_vrml.cpp.

References IFSG_COORDS::AddCoord(), IFSG_INDEX::AddIndex(), IFSG_NORMALS::AddNormal(), S3D::CalcTriNorm(), IFSG_NODE::GetRawPtr(), getSGColor(), S3D::GetSGNodeParent(), IFSG_COORDS::NewNode(), IFSG_NORMALS::NewNode(), IFSG_COORDINDEX::NewNode(), IFSG_FACESET::NewNode(), IFSG_COORDS::SetCoordsList(), IFSG_INDEX::SetIndices(), and SGVECTOR::SetVector().

Referenced by GetLayer(), and write_layers().

1757 {
1758  std::vector< double > vertices;
1759  std::vector< int > idxPlane;
1760  std::vector< int > idxSide;
1761 
1762  if( top_z < bottom_z )
1763  {
1764  double tmp = top_z;
1765  top_z = bottom_z;
1766  bottom_z = tmp;
1767  }
1768 
1769  if( !(*layer).Get3DTriangles( vertices, idxPlane, idxSide, top_z, bottom_z ) )
1770  {
1771 #ifdef DEBUG
1772  do {
1773  std::ostringstream ostr;
1774  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1775  ostr << " * [INFO] no vertex data";
1776  wxLogDebug( "%s\n", ostr.str().c_str() );
1777  } while( 0 );
1778 #endif
1779 
1780  return;
1781  }
1782 
1783  if( ( idxPlane.size() % 3 ) || ( idxSide.size() % 3 ) )
1784  {
1785 #ifdef DEBUG
1786  do {
1787  std::ostringstream ostr;
1788  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
1789  ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
1790  wxLogDebug( "%s\n", ostr.str().c_str() );
1791  } while( 0 );
1792 #endif
1793 
1794  throw( std::runtime_error( "[BUG] index lists are not a multiple of 3 (not a triangle list)" ) );
1795  }
1796 
1797  std::vector< SGPOINT > vlist;
1798  size_t nvert = vertices.size() / 3;
1799  size_t j = 0;
1800 
1801  for( size_t i = 0; i < nvert; ++i, j+= 3 )
1802  vlist.push_back( SGPOINT( vertices[j], vertices[j+1], vertices[j+2] ) );
1803 
1804  // create the intermediate scenegraph
1805  IFSG_TRANSFORM tx0( PcbOutput.GetRawPtr() ); // tx0 = Transform for this outline
1806  IFSG_SHAPE shape( tx0 ); // shape will hold (a) all vertices and (b) a local list of normals
1807  IFSG_FACESET face( shape ); // this face shall represent the top and bottom planes
1808  IFSG_COORDS cp( face ); // coordinates for all faces
1809  cp.SetCoordsList( nvert, &vlist[0] );
1810  IFSG_COORDINDEX coordIdx( face ); // coordinate indices for top and bottom planes only
1811  coordIdx.SetIndices( idxPlane.size(), &idxPlane[0] );
1812  IFSG_NORMALS norms( face ); // normals for the top and bottom planes
1813 
1814  // number of TOP (and bottom) vertices
1815  j = nvert / 2;
1816 
1817  // set the TOP normals
1818  for( size_t i = 0; i < j; ++i )
1819  norms.AddNormal( 0.0, 0.0, 1.0 );
1820 
1821  // set the BOTTOM normals
1822  for( size_t i = 0; i < j; ++i )
1823  norms.AddNormal( 0.0, 0.0, -1.0 );
1824 
1825  // assign a color from the palette
1826  SGNODE* modelColor = getSGColor( colorID );
1827 
1828  if( NULL != modelColor )
1829  {
1830  if( NULL == S3D::GetSGNodeParent( modelColor ) )
1831  shape.AddChildNode( modelColor );
1832  else
1833  shape.AddRefNode( modelColor );
1834  }
1835 
1836  // create a second shape describing the vertical walls of the extrusion
1837  // using per-vertex-per-face-normals
1838  shape.NewNode( tx0 );
1839  shape.AddRefNode( modelColor ); // set the color to be the same as the top/bottom
1840  face.NewNode( shape );
1841  cp.NewNode( face ); // new vertex list
1842  norms.NewNode( face ); // new normals list
1843  coordIdx.NewNode( face ); // new index list
1844 
1845  // populate the new per-face vertex list and its indices and normals
1846  std::vector< int >::iterator sI = idxSide.begin();
1847  std::vector< int >::iterator eI = idxSide.end();
1848 
1849  size_t sidx = 0; // index to the new coord set
1850  SGPOINT p1, p2, p3;
1851  SGVECTOR vnorm;
1852 
1853  while( sI != eI )
1854  {
1855  p1 = vlist[*sI];
1856  cp.AddCoord( p1 );
1857  ++sI;
1858 
1859  p2 = vlist[*sI];
1860  cp.AddCoord( p2 );
1861  ++sI;
1862 
1863  p3 = vlist[*sI];
1864  cp.AddCoord( p3 );
1865  ++sI;
1866 
1867  vnorm.SetVector( S3D::CalcTriNorm( p1, p2, p3 ) );
1868  norms.AddNormal( vnorm );
1869  norms.AddNormal( vnorm );
1870  norms.AddNormal( vnorm );
1871 
1872  coordIdx.AddIndex( (int)sidx );
1873  ++sidx;
1874  coordIdx.AddIndex( (int)sidx );
1875  ++sidx;
1876  coordIdx.AddIndex( (int)sidx );
1877  ++sidx;
1878  }
1879 }
SGNODE * GetRawPtr(void)
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:66
Class IFSG_COORDS is the wrapper for SGCOORDS.
Definition: ifsg_coords.h:40
Class IFSG_COORDINDEX is the wrapper for SGCOORDINDEX.
void SetVector(double aXVal, double aYVal, double aZVal)
Definition: sg_base.cpp:292
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:636
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
Class IFSG_NORMALS is the wrapper for the SGNORMALS class.
Definition: ifsg_normals.h:40
static SGNODE * getSGColor(VRML_COLOR_INDEX colorIdx)
SGLIB_API SGVECTOR CalcTriNorm(const SGPOINT &p1, const SGPOINT &p2, const SGPOINT &p3)
Function CalcTriNorm returns the normal vector of a triangle described by vertices p1...
Definition: ifsg_api.cpp:606
Class IFSG_FACESET is the wrapper for the SGFACESET class.
Definition: ifsg_faceset.h:40
Class IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH...
Class IFSG_SHAPE is the wrapper for the SGSHAPE class.
Definition: ifsg_shape.h:40
static void export_round_padstack ( MODEL_VRML aModel,
BOARD pcb,
double  x,
double  y,
double  r,
LAYER_NUM  bottom_layer,
LAYER_NUM  top_layer,
double  hole 
)
static

Definition at line 893 of file export_vrml.cpp.

References B_Cu, F_Cu, MODEL_VRML::m_bot_copper, MODEL_VRML::m_holes, MODEL_VRML::m_plainPCB, and MODEL_VRML::m_top_copper.

Referenced by export_vrml_via().

897 {
898  LAYER_NUM layer = top_layer;
899  bool thru = true;
900 
901  // if not a thru hole do not put a hole in the board
902  if( top_layer != F_Cu || bottom_layer != B_Cu )
903  thru = false;
904 
905  if( thru && hole > 0 )
906  aModel.m_holes.AddCircle( x, -y, hole, true );
907 
908  if( aModel.m_plainPCB )
909  return;
910 
911  while( 1 )
912  {
913  if( layer == B_Cu )
914  {
915  aModel.m_bot_copper.AddCircle( x, -y, r );
916 
917  if( hole > 0 && !thru )
918  aModel.m_bot_copper.AddCircle( x, -y, hole, true );
919 
920  }
921  else if( layer == F_Cu )
922  {
923  aModel.m_top_copper.AddCircle( x, -y, r );
924 
925  if( hole > 0 && !thru )
926  aModel.m_top_copper.AddCircle( x, -y, hole, true );
927 
928  }
929 
930  if( layer == bottom_layer )
931  break;
932 
933  layer = bottom_layer;
934  }
935 }
VRML_LAYER m_holes
VRML_LAYER m_bot_copper
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
VRML_LAYER m_top_copper
static void export_vrml_arc ( MODEL_VRML aModel,
LAYER_NUM  layer,
double  centerx,
double  centery,
double  arc_startx,
double  arc_starty,
double  width,
double  arc_angle 
)
static

Definition at line 655 of file export_vrml.cpp.

References GetLayer(), and MODEL_VRML::m_minLineWidth.

Referenced by export_vrml_drawsegment(), and export_vrml_edge_module().

659 {
660  VRML_LAYER* vlayer;
661 
662  if( !GetLayer( aModel, layer, &vlayer ) )
663  return;
664 
665  if( width < aModel.m_minLineWidth )
666  width = aModel.m_minLineWidth;
667 
668  centery = -centery;
669  arc_starty = -arc_starty;
670 
671  if( !vlayer->AddArc( centerx, centery, arc_startx, arc_starty, width, -arc_angle, false ) )
672  throw( std::runtime_error( vlayer->GetError() ) );
673 
674 }
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
double m_minLineWidth
static void export_vrml_board ( MODEL_VRML aModel,
BOARD aPcb 
)
static

Definition at line 835 of file export_vrml.cpp.

References BOARD_SCALE, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), BOARD::GetBoardPolygonOutlines(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), MODEL_VRML::m_board, MODEL_VRML::m_holes, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

836 {
837  SHAPE_POLY_SET pcbOutlines; // stores the board main outlines
838  wxString msg;
839 
840  if( !aPcb->GetBoardPolygonOutlines( pcbOutlines, &msg ) )
841  {
842  msg << "\n\n" <<
843  _( "Unable to calculate the board outlines; fall back to using the board boundary box." );
844  wxMessageBox( msg );
845  }
846 
847  int seg;
848 
849  for( int cnt = 0; cnt < pcbOutlines.OutlineCount(); cnt++ )
850  {
851  const SHAPE_LINE_CHAIN& outline = pcbOutlines.COutline( cnt );
852 
853  seg = aModel.m_board.NewContour();
854 
855  for( int j = 0; j < outline.PointCount(); j++ )
856  {
857  aModel.m_board.AddVertex( seg, (double)outline.CPoint(j).x * BOARD_SCALE,
858  -((double)outline.CPoint(j).y * BOARD_SCALE ) );
859 
860  }
861 
862  aModel.m_board.EnsureWinding( seg, false );
863 
864  // Generate holes:
865  for( int ii = 0; ii < pcbOutlines.HoleCount( cnt ); ii++ )
866  {
867  const SHAPE_LINE_CHAIN& hole = pcbOutlines.Hole( cnt, ii );
868 
869  seg = aModel.m_holes.NewContour();
870 
871  if( seg < 0 )
872  {
873  msg << "\n\n" <<
874  _( "VRML Export Failed: Could not add holes to contours." );
875  wxMessageBox( msg );
876 
877  return;
878  }
879 
880  for( int j = 0; j < hole.PointCount(); j++ )
881  {
882  aModel.m_holes.AddVertex( seg, (double)hole.CPoint(j).x * BOARD_SCALE,
883  -((double)hole.CPoint(j).y * BOARD_SCALE ) );
884 
885  }
886 
887  aModel.m_holes.EnsureWinding( seg, true );
888  }
889  }
890 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=NULL)
Function GetBoardPolygonOutlines Extracts the board outlines and build a closed polygon from lines...
int PointCount() const
Function PointCount()
VRML_LAYER m_holes
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Returns the reference to aHole-th hole in the aIndex-th outline
int OutlineCount() const
Returns the number of outlines in the set
Class SHAPE_POLY_SET.
VRML_LAYER m_board
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Class SHAPE_LINE_CHAIN.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
static void export_vrml_circle ( MODEL_VRML aModel,
LAYER_NUM  layer,
double  startx,
double  starty,
double  endx,
double  endy,
double  width 
)
static

Definition at line 624 of file export_vrml.cpp.

References Distance(), GetLayer(), and MODEL_VRML::m_minLineWidth.

Referenced by export_vrml_edge_module().

627 {
628  VRML_LAYER* vlayer;
629 
630  if( !GetLayer( aModel, layer, &vlayer ) )
631  return;
632 
633  if( width < aModel.m_minLineWidth )
634  width = aModel.m_minLineWidth;
635 
636  starty = -starty;
637  endy = -endy;
638 
639  double hole, radius;
640 
641  radius = Distance( startx, starty, endx, endy ) + ( width / 2);
642  hole = radius - width;
643 
644  if( !vlayer->AddCircle( startx, starty, radius, false ) )
645  throw( std::runtime_error( vlayer->GetError() ) );
646 
647  if( hole > 0.0001 )
648  {
649  if( !vlayer->AddCircle( startx, starty, hole, true ) )
650  throw( std::runtime_error( vlayer->GetError() ) );
651  }
652 }
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
double m_minLineWidth
double Distance(double x1, double y1, double x2, double y2)
static void export_vrml_drawings ( MODEL_VRML aModel,
BOARD pcb 
)
static

Definition at line 807 of file export_vrml.cpp.

References B_Cu, B_SilkS, BOARD::Drawings(), export_vrml_drawsegment(), export_vrml_pcbtext(), F_Cu, F_SilkS, PCB_LINE_T, and PCB_TEXT_T.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

808 {
809  // draw graphic items
810  for( auto drawing : pcb->Drawings() )
811  {
812  PCB_LAYER_ID layer = drawing->GetLayer();
813 
814  if( layer != F_Cu && layer != B_Cu && layer != B_SilkS && layer != F_SilkS )
815  continue;
816 
817  switch( drawing->Type() )
818  {
819  case PCB_LINE_T:
820  export_vrml_drawsegment( aModel, (DRAWSEGMENT*) drawing );
821  break;
822 
823  case PCB_TEXT_T:
824  export_vrml_pcbtext( aModel, (TEXTE_PCB*) drawing );
825  break;
826 
827  default:
828  break;
829  }
830  }
831 }
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
PCB_LAYER_ID
A quick note on layer IDs:
static void export_vrml_drawsegment(MODEL_VRML &aModel, DRAWSEGMENT *drawseg)
static void export_vrml_pcbtext(MODEL_VRML &aModel, TEXTE_PCB *text)
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:251
static void export_vrml_drawsegment ( MODEL_VRML aModel,
DRAWSEGMENT drawseg 
)
static

Definition at line 677 of file export_vrml.cpp.

References BOARD_SCALE, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), Edge_Cuts, export_vrml_arc(), export_vrml_line(), SHAPE_POLY_SET::Fracture(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetLayer(), GetLayer(), DRAWSEGMENT::GetPolyShape(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), SHAPE_POLY_SET::Inflate(), DRAWSEGMENT::IsPolyShapeValid(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_LINE_CHAIN::PointCount(), S_ARC, S_CIRCLE, S_POLYGON, wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by export_vrml_drawings().

678 {
679  LAYER_NUM layer = drawseg->GetLayer();
680  double w = drawseg->GetWidth() * BOARD_SCALE;
681  double x = drawseg->GetStart().x * BOARD_SCALE;
682  double y = drawseg->GetStart().y * BOARD_SCALE;
683  double xf = drawseg->GetEnd().x * BOARD_SCALE;
684  double yf = drawseg->GetEnd().y * BOARD_SCALE;
685  double r = sqrt( pow( x - xf, 2 ) + pow( y - yf, 2 ) );
686 
687  // Items on the edge layer are handled elsewhere; just return
688  if( layer == Edge_Cuts )
689  return;
690 
691  switch( drawseg->GetShape() )
692  {
693  case S_ARC:
694  export_vrml_arc( aModel, layer,
695  (double) drawseg->GetCenter().x * BOARD_SCALE,
696  (double) drawseg->GetCenter().y * BOARD_SCALE,
697  (double) drawseg->GetArcStart().x * BOARD_SCALE,
698  (double) drawseg->GetArcStart().y * BOARD_SCALE,
699  w, drawseg->GetAngle() / 10 );
700  break;
701 
702  case S_CIRCLE:
703  // Break circles into two 180 arcs to prevent the vrml hole from obscuring objects
704  // within the hole area of the circle.
705  export_vrml_arc( aModel, layer, x, y, x, y-r, w, 180.0 );
706  export_vrml_arc( aModel, layer, x, y, x, y+r, w, 180.0 );
707  break;
708 
709  case S_POLYGON:
710  if( drawseg->IsPolyShapeValid() )
711  {
712  VRML_LAYER* vlayer;
713 
714  if( !GetLayer( aModel, layer, &vlayer ) )
715  break;
716 
717  SHAPE_POLY_SET shape = drawseg->GetPolyShape();
718 
719  const int circleSegmentsCount = 16;
720 
721  if( drawseg->GetWidth() )
722  {
723  shape.Inflate( drawseg->GetWidth()/2, circleSegmentsCount );
725  }
726 
727  const SHAPE_LINE_CHAIN& outline = shape.COutline( 0 );
728 
729  int seg = vlayer->NewContour();
730 
731  for( int j = 0; j < outline.PointCount(); j++ )
732  {
733  if( !vlayer->AddVertex( seg, (double)outline.CPoint( j ).x * BOARD_SCALE,
734  -((double)outline.CPoint( j ).y * BOARD_SCALE ) ) )
735  throw( std::runtime_error( vlayer->GetError() ) );
736 
737  }
738 
739  vlayer->EnsureWinding( seg, false );
740  }
741  break;
742 
743  default:
744  export_vrml_line( aModel, layer, x, y, xf, yf, w );
745  break;
746  }
747 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
const wxPoint GetCenter() const override
Function GetCenter()
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int PointCount() const
Function PointCount()
polygon (not yet used for tracks, but could be in microwave apps)
bool IsPolyShapeValid() const
const wxPoint & GetArcStart() const
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static void export_vrml_arc(MODEL_VRML &aModel, LAYER_NUM layer, double centerx, double centery, double arc_startx, double arc_starty, double width, double arc_angle)
SHAPE_POLY_SET & GetPolyShape()
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
double GetAngle() const
Class SHAPE_LINE_CHAIN.
int GetWidth() const
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
static void export_vrml_line(MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
static void export_vrml_edge_module ( MODEL_VRML aModel,
EDGE_MODULE aOutline,
MODULE aModule 
)
static

Definition at line 1043 of file export_vrml.cpp.

References BOARD_SCALE, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), export_vrml_arc(), export_vrml_circle(), export_vrml_line(), SHAPE_POLY_SET::Fracture(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetEnd(), BOARD_ITEM::GetLayer(), GetLayer(), MODULE::GetOrientationRadians(), DRAWSEGMENT::GetPolyShape(), MODULE::GetPosition(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), SHAPE_POLY_SET::Inflate(), DRAWSEGMENT::IsPolyShapeValid(), SHAPE_POLY_SET::Move(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::Rotate(), S_ARC, S_CIRCLE, S_POLYGON, S_SEGMENT, wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by export_vrml_module().

1045 {
1046  LAYER_NUM layer = aOutline->GetLayer();
1047  double x = aOutline->GetStart().x * BOARD_SCALE;
1048  double y = aOutline->GetStart().y * BOARD_SCALE;
1049  double xf = aOutline->GetEnd().x * BOARD_SCALE;
1050  double yf = aOutline->GetEnd().y * BOARD_SCALE;
1051  double w = aOutline->GetWidth() * BOARD_SCALE;
1052 
1053  switch( aOutline->GetShape() )
1054  {
1055  case S_SEGMENT:
1056  export_vrml_line( aModel, layer, x, y, xf, yf, w );
1057  break;
1058 
1059  case S_ARC:
1060  export_vrml_arc( aModel, layer, x, y, xf, yf, w, aOutline->GetAngle() / 10 );
1061  break;
1062 
1063  case S_CIRCLE:
1064  export_vrml_circle( aModel, layer, x, y, xf, yf, w );
1065  break;
1066 
1067  case S_POLYGON:
1068  if( aOutline->IsPolyShapeValid() )
1069  {
1070  VRML_LAYER* vl;
1071 
1072  if( !GetLayer( aModel, layer, &vl ) )
1073  break;
1074 
1075  SHAPE_POLY_SET shape = aOutline->GetPolyShape();
1076 
1077  const int circleSegmentsCount = 16;
1078 
1079  if( aOutline->GetWidth() )
1080  {
1081  shape.Inflate( aOutline->GetWidth()/2, circleSegmentsCount );
1083  }
1084 
1085  shape.Rotate( -aModule->GetOrientationRadians(), VECTOR2I( 0, 0 ) );
1086  shape.Move( aModule->GetPosition() );
1087 
1088  const SHAPE_LINE_CHAIN& outline = shape.COutline( 0 );
1089 
1090  int nvert = outline.PointCount() - 1;
1091  int i = 0;
1092 
1093  if( nvert < 3 ) break;
1094 
1095  int seg = vl->NewContour();
1096 
1097  if( seg < 0 )
1098  break;
1099 
1100  while( i < nvert )
1101  {
1102  x = outline.CPoint( i ).x * BOARD_SCALE;
1103  y = - ( outline.CPoint( i ).y * BOARD_SCALE );
1104 
1105  if( !vl->AddVertex( seg, x, y ) )
1106  throw( std::runtime_error( vl->GetError() ) );
1107 
1108  ++i;
1109  }
1110  vl->EnsureWinding( seg, false );
1111  }
1112  break;
1113 
1114  default:
1115  break;
1116  }
1117 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int PointCount() const
Function PointCount()
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
bool IsPolyShapeValid() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
static void export_vrml_circle(MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
STROKE_T GetShape() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
void Move(const VECTOR2I &aVector) override
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static void export_vrml_arc(MODEL_VRML &aModel, LAYER_NUM layer, double centerx, double centery, double arc_startx, double arc_starty, double width, double arc_angle)
SHAPE_POLY_SET & GetPolyShape()
double GetOrientationRadians() const
Definition: class_module.h:188
void Fracture(POLYGON_MODE aFastMode)
Converts a set of polygons with holes to a singe outline with "slits"/"fractures" connecting the oute...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
double GetAngle() const
Class SHAPE_LINE_CHAIN.
int GetWidth() const
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
static void export_vrml_line(MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
void Rotate(double aAngle, const VECTOR2I &aCenter)
Function Rotate rotates all vertices by a given angle.
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const wxPoint GetPosition() const override
Definition: class_module.h:181
static void export_vrml_line ( MODEL_VRML aModel,
LAYER_NUM  layer,
double  startx,
double  starty,
double  endx,
double  endy,
double  width 
)
static

Definition at line 599 of file export_vrml.cpp.

References PNS::angle(), Distance(), GetLayer(), and MODEL_VRML::m_minLineWidth.

Referenced by export_vrml_drawsegment(), export_vrml_edge_module(), export_vrml_tracks(), and vrml_text_callback().

602 {
603  VRML_LAYER* vlayer;
604 
605  if( !GetLayer( aModel, layer, &vlayer ) )
606  return;
607 
608  if( width < aModel.m_minLineWidth)
609  width = aModel.m_minLineWidth;
610 
611  starty = -starty;
612  endy = -endy;
613 
614  double angle = atan2( endy - starty, endx - startx ) * 180.0 / M_PI;
615  double length = Distance( startx, starty, endx, endy ) + width;
616  double cx = ( startx + endx ) / 2.0;
617  double cy = ( starty + endy ) / 2.0;
618 
619  if( !vlayer->AddSlot( cx, cy, length, width, angle, false ) )
620  throw( std::runtime_error( vlayer->GetError() ) );
621 }
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
double m_minLineWidth
double Distance(double x1, double y1, double x2, double y2)
static void export_vrml_module ( MODEL_VRML aModel,
BOARD aPcb,
MODULE aModule,
std::ostream *  aOutputFile 
)
static

Definition at line 1318 of file export_vrml.cpp.

References abs, IFSG_NODE::AddChildNode(), IFSG_NODE::AddRefNode(), B_Cu, BOARD_SCALE, build_quat(), compose_quat(), DECIDEG2RAD(), DEG2RAD(), export_vrml_edge_module(), export_vrml_pad(), export_vrml_text_module(), from_quat(), GetChars(), BOARD_ITEM::GetLayer(), MODEL_VRML::GetLayerZ(), MODULE::GetOrientation(), MODULE::GetPosition(), IFSG_NODE::GetRawPtr(), S3D_CACHE::GetResolver(), S3D::GetSGNodeParent(), MODULE::GraphicalItemsList(), EDA_TEXT::IsVisible(), S3D_CACHE::Load(), MODEL_VRML::m_components, MODEL_VRML::m_OutputPCB, MODEL_VRML::m_plainPCB, MODEL_VRML::m_tx, MODEL_VRML::m_ty, MODULE::Models(), BOARD_ITEM::Next(), D_PAD::Next(), MODULE::PadsList(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PRECISION, MODULE::Reference(), S3D_FILENAME_RESOLVER::ResolvePath(), RotatePoint(), IFSG_TRANSFORM::SetRotation(), IFSG_TRANSFORM::SetScale(), IFSG_TRANSFORM::SetTranslation(), SUBDIR_3D, TO_UTF8, USE_DEFS, USE_INLINES, USE_RELPATH, MODULE::Value(), S3D::WriteVRML(), wxPoint::x, SGPOINT::x, and wxPoint::y.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

1320 {
1321  if( !aModel.m_plainPCB )
1322  {
1323  // Reference and value
1324  if( aModule->Reference().IsVisible() )
1325  export_vrml_text_module( &aModule->Reference() );
1326 
1327  if( aModule->Value().IsVisible() )
1328  export_vrml_text_module( &aModule->Value() );
1329 
1330  // Export module edges
1331  for( EDA_ITEM* item = aModule->GraphicalItemsList(); item; item = item->Next() )
1332  {
1333  switch( item->Type() )
1334  {
1335  case PCB_MODULE_TEXT_T:
1336  export_vrml_text_module( static_cast<TEXTE_MODULE*>( item ) );
1337  break;
1338 
1339  case PCB_MODULE_EDGE_T:
1340  export_vrml_edge_module( aModel, static_cast<EDGE_MODULE*>( item ),
1341  aModule );
1342  break;
1343 
1344  default:
1345  break;
1346  }
1347  }
1348  }
1349 
1350  // Export pads
1351  for( D_PAD* pad = aModule->PadsList(); pad; pad = pad->Next() )
1352  export_vrml_pad( aModel, aPcb, pad );
1353 
1354  bool isFlipped = aModule->GetLayer() == B_Cu;
1355 
1356  // Export the object VRML model(s)
1357  auto sM = aModule->Models().begin();
1358  auto eM = aModule->Models().end();
1359 
1360  wxFileName subdir( SUBDIR_3D, "" );
1361 
1362  while( sM != eM )
1363  {
1364  SGNODE* mod3d = (SGNODE*) cache->Load( sM->m_Filename );
1365 
1366  if( NULL == mod3d )
1367  {
1368  ++sM;
1369  continue;
1370  }
1371 
1372  /* Calculate 3D shape rotation:
1373  * this is the rotation parameters, with an additional 180 deg rotation
1374  * for footprints that are flipped
1375  * When flipped, axis rotation is the horizontal axis (X axis)
1376  */
1377  double rotx = -sM->m_Rotation.x;
1378  double roty = -sM->m_Rotation.y;
1379  double rotz = -sM->m_Rotation.z;
1380 
1381  if( isFlipped )
1382  {
1383  rotx += 180.0;
1384  roty = -roty;
1385  rotz = -rotz;
1386  }
1387 
1388  // Do some quaternion munching
1389  double q1[4], q2[4], rot[4];
1390  build_quat( 1, 0, 0, DEG2RAD( rotx ), q1 );
1391  build_quat( 0, 1, 0, DEG2RAD( roty ), q2 );
1392  compose_quat( q1, q2, q1 );
1393  build_quat( 0, 0, 1, DEG2RAD( rotz ), q2 );
1394  compose_quat( q1, q2, q1 );
1395 
1396  // Note here aModule->GetOrientation() is in 0.1 degrees,
1397  // so module rotation has to be converted to radians
1398  build_quat( 0, 0, 1, DECIDEG2RAD( aModule->GetOrientation() ), q2 );
1399  compose_quat( q1, q2, q1 );
1400  from_quat( q1, rot );
1401 
1402  double offsetFactor = 1000.0f * IU_PER_MILS / 25.4f;
1403 
1404  // adjust 3D shape local offset position
1405  // they are given in mm, so they are converted in board IU.
1406  double offsetx = sM->m_Offset.x * offsetFactor;
1407  double offsety = sM->m_Offset.y * offsetFactor;
1408  double offsetz = sM->m_Offset.z * offsetFactor;
1409 
1410  if( isFlipped )
1411  offsetz = -offsetz;
1412  else // In normal mode, Y axis is reversed in Pcbnew.
1413  offsety = -offsety;
1414 
1415  RotatePoint( &offsetx, &offsety, aModule->GetOrientation() );
1416 
1417  SGPOINT trans;
1418  trans.x = ( offsetx + aModule->GetPosition().x ) * BOARD_SCALE + aModel.m_tx;
1419  trans.y = -(offsety + aModule->GetPosition().y) * BOARD_SCALE - aModel.m_ty;
1420  trans.z = (offsetz * BOARD_SCALE ) + aModel.GetLayerZ( aModule->GetLayer() );
1421 
1422  if( USE_INLINES )
1423  {
1424  wxFileName srcFile = cache->GetResolver()->ResolvePath( sM->m_Filename );
1425  wxFileName dstFile;
1426  dstFile.SetPath( SUBDIR_3D );
1427  dstFile.SetName( srcFile.GetName() );
1428  dstFile.SetExt( "wrl" );
1429 
1430  // copy the file if necessary
1431  wxDateTime srcModTime = srcFile.GetModificationTime();
1432  wxDateTime destModTime = srcModTime;
1433 
1434  destModTime.SetToCurrent();
1435 
1436  if( dstFile.FileExists() )
1437  destModTime = dstFile.GetModificationTime();
1438 
1439  if( srcModTime != destModTime )
1440  {
1441  wxLogDebug( "Copying 3D model %s to %s.",
1442  GetChars( srcFile.GetFullPath() ),
1443  GetChars( dstFile.GetFullPath() ) );
1444 
1445  wxString fileExt = srcFile.GetExt();
1446  fileExt.LowerCase();
1447 
1448  // copy VRML models and use the scenegraph library to
1449  // translate other model types
1450  if( fileExt == "wrl" )
1451  {
1452  if( !wxCopyFile( srcFile.GetFullPath(), dstFile.GetFullPath() ) )
1453  continue;
1454  }
1455  else
1456  {
1457  if( !S3D::WriteVRML( dstFile.GetFullPath().ToUTF8(), true, mod3d, USE_DEFS, true ) )
1458  continue;
1459  }
1460  }
1461 
1462  (*aOutputFile) << "Transform {\n";
1463 
1464  // only write a rotation if it is >= 0.1 deg
1465  if( std::abs( rot[3] ) > 0.0001745 )
1466  {
1467  (*aOutputFile) << " rotation " << std::setprecision( 5 );
1468  (*aOutputFile) << rot[0] << " " << rot[1] << " " << rot[2] << " " << rot[3] << "\n";
1469  }
1470 
1471  (*aOutputFile) << " translation " << std::setprecision( PRECISION );
1472  (*aOutputFile) << trans.x << " ";
1473  (*aOutputFile) << trans.y << " ";
1474  (*aOutputFile) << trans.z << "\n";
1475 
1476  (*aOutputFile) << " scale ";
1477  (*aOutputFile) << sM->m_Scale.x << " ";
1478  (*aOutputFile) << sM->m_Scale.y << " ";
1479  (*aOutputFile) << sM->m_Scale.z << "\n";
1480 
1481  (*aOutputFile) << " children [\n Inline {\n url \"";
1482 
1483  if( USE_RELPATH )
1484  {
1485  wxFileName tmp = dstFile;
1486  tmp.SetExt( "" );
1487  tmp.SetName( "" );
1488  tmp.RemoveLastDir();
1489  dstFile.MakeRelativeTo( tmp.GetPath() );
1490  }
1491 
1492  wxString fn = dstFile.GetFullPath();
1493  fn.Replace( "\\", "/" );
1494  (*aOutputFile) << TO_UTF8( fn ) << "\"\n } ]\n";
1495  (*aOutputFile) << " }\n";
1496  }
1497  else
1498  {
1499  IFSG_TRANSFORM* modelShape = new IFSG_TRANSFORM( aModel.m_OutputPCB.GetRawPtr() );
1500 
1501  // only write a rotation if it is >= 0.1 deg
1502  if( std::abs( rot[3] ) > 0.0001745 )
1503  modelShape->SetRotation( SGVECTOR( rot[0], rot[1], rot[2] ), rot[3] );
1504 
1505  modelShape->SetTranslation( trans );
1506  modelShape->SetScale( SGPOINT( sM->m_Scale.x, sM->m_Scale.y, sM->m_Scale.z ) );
1507 
1508  if( NULL == S3D::GetSGNodeParent( mod3d ) )
1509  {
1510  aModel.m_components.push_back( mod3d );
1511  modelShape->AddChildNode( mod3d );
1512  }
1513  else
1514  {
1515  modelShape->AddRefNode( mod3d );
1516  }
1517 
1518  }
1519 
1520  ++sM;
1521  }
1522 }
bool SetTranslation(const SGPOINT &aTranslation)
static double BOARD_SCALE
Definition: export_vrml.cpp:67
static void export_vrml_pad(MODEL_VRML &aModel, BOARD *aPcb, D_PAD *aPad)
SGNODE * GetRawPtr(void)
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:66
TEXTE_MODULE & Reference()
Definition: class_module.h:501
static S3D_CACHE * cache
Definition: export_vrml.cpp:62
double x
Definition: sg_base.h:70
static void compose_quat(double q1[4], double q2[4], double qr[4])
static bool USE_INLINES
Definition: export_vrml.cpp:63
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool AddRefNode(SGNODE *aNode)
Function AddRefNode adds a reference to an existing node which is not owned by (not a child of) this ...
Definition: ifsg_node.cpp:199
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition: ifsg_api.cpp:636
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
bool SetScale(const SGPOINT &aScale)
IFSG_TRANSFORM m_OutputPCB
#define abs(a)
Definition: auxiliary.h:84
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static void export_vrml_text_module(TEXTE_MODULE *module)
bool AddChildNode(SGNODE *aNode)
Function AddChildNode adds a node as a child owned by this node.
Definition: ifsg_node.cpp:249
SGLIB_API bool WriteVRML(const char *filename, bool overwrite, SGNODE *aTopNode, bool reuse, bool renameNodes)
Function WriteVRML writes out the given node and its subnodes to a VRML2 file.
Definition: ifsg_api.cpp:81
static void build_quat(double x, double y, double z, double a, double q[4])
BOARD_ITEM * Next() const
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
double GetOrientation() const
Definition: class_module.h:186
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:500
D_PAD * Next() const
Definition: class_pad.h:160
static bool USE_RELPATH
Definition: export_vrml.cpp:65
bool SetRotation(const SGVECTOR &aRotationAxis, double aAngle)
static wxString SUBDIR_3D
Definition: export_vrml.cpp:69
S3D_FILENAME_RESOLVER * GetResolver(void)
Definition: 3d_cache.cpp:739
std::list< SGNODE * > m_components
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
std::list< MODULE_3D_SETTINGS > & Models()
Definition: class_module.h:176
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
double DEG2RAD(double deg)
Definition: trigo.h:199
wxString ResolvePath(const wxString &aFileName)
Function ResolvePath determines the full path of the given file name.
bool IsVisible() const
Definition: eda_text.h:174
Class IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH...
double DECIDEG2RAD(double deg)
Definition: trigo.h:203
static void from_quat(double q[4], double rot[4])
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
static const int PRECISION
Definition: export_vrml.cpp:68
static bool USE_DEFS
Definition: export_vrml.cpp:64
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:163
DLIST< D_PAD > & PadsList()
Definition: class_module.h:160
static void export_vrml_edge_module(MODEL_VRML &aModel, EDGE_MODULE *aOutline, MODULE *aModule)
SCENEGRAPH * Load(const wxString &aModelFile)
Function Load attempts to load the scene data for a model; it will consult the internal cache list an...
Definition: 3d_cache.cpp:271
const wxPoint GetPosition() const override
Definition: class_module.h:181
double GetLayerZ(LAYER_NUM aLayer)
static void export_vrml_pad ( MODEL_VRML aModel,
BOARD aPcb,
D_PAD aPad 
)
static

Definition at line 1204 of file export_vrml.cpp.

References B_Cu, BOARD_SCALE, export_vrml_padshape(), F_Cu, D_PAD::GetAttribute(), D_PAD::GetDrillShape(), D_PAD::GetDrillSize(), D_PAD::GetLayerSet(), D_PAD::GetOrientation(), D_PAD::GetPosition(), MODEL_VRML::m_bot_tin, MODEL_VRML::m_holes, MODEL_VRML::m_plainPCB, MODEL_VRML::m_plated_holes, MODEL_VRML::m_top_tin, min, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_OBLONG, PLATE_OFFSET, wxPoint::x, and wxPoint::y.

Referenced by export_vrml_module().

1205 {
1206  double hole_drill_w = (double) aPad->GetDrillSize().x * BOARD_SCALE / 2.0;
1207  double hole_drill_h = (double) aPad->GetDrillSize().y * BOARD_SCALE / 2.0;
1208  double hole_drill = std::min( hole_drill_w, hole_drill_h );
1209  double hole_x = aPad->GetPosition().x * BOARD_SCALE;
1210  double hole_y = aPad->GetPosition().y * BOARD_SCALE;
1211 
1212  // Export the hole on the edge layer
1213  if( hole_drill > 0 )
1214  {
1215  bool pth = false;
1216 
1217  if( ( aPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
1218  && !aModel.m_plainPCB )
1219  pth = true;
1220 
1221  if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1222  {
1223  // Oblong hole (slot)
1224 
1225  if( pth )
1226  {
1227  aModel.m_holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0 + PLATE_OFFSET,
1228  hole_drill_h * 2.0 + PLATE_OFFSET,
1229  aPad->GetOrientation()/10.0, true, true );
1230 
1231  aModel.m_plated_holes.AddSlot( hole_x, -hole_y,
1232  hole_drill_w * 2.0, hole_drill_h * 2.0,
1233  aPad->GetOrientation()/10.0, true, false );
1234  }
1235  else
1236  {
1237  aModel.m_holes.AddSlot( hole_x, -hole_y, hole_drill_w * 2.0, hole_drill_h * 2.0,
1238  aPad->GetOrientation()/10.0, true, false );
1239 
1240  }
1241  }
1242  else
1243  {
1244  // Drill a round hole
1245 
1246  if( pth )
1247  {
1248  aModel.m_holes.AddCircle( hole_x, -hole_y, hole_drill + PLATE_OFFSET, true, true );
1249  aModel.m_plated_holes.AddCircle( hole_x, -hole_y, hole_drill, true, false );
1250  }
1251  else
1252  {
1253  aModel.m_holes.AddCircle( hole_x, -hole_y, hole_drill, true, false );
1254  }
1255 
1256  }
1257  }
1258 
1259  if( aModel.m_plainPCB )
1260  return;
1261 
1262  // The pad proper, on the selected layers
1263  LSET layer_mask = aPad->GetLayerSet();
1264 
1265  if( layer_mask[B_Cu] )
1266  {
1267  export_vrml_padshape( aModel, &aModel.m_bot_tin, aPad );
1268  }
1269 
1270  if( layer_mask[F_Cu] )
1271  {
1272  export_vrml_padshape( aModel, &aModel.m_top_tin, aPad );
1273  }
1274 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:398
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
VRML_LAYER m_bot_tin
VRML_LAYER m_plated_holes
VRML_LAYER m_holes
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:381
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
static void export_vrml_padshape(MODEL_VRML &aModel, VRML_LAYER *aTinLayer, D_PAD *aPad)
Class LSET is a set of PCB_LAYER_IDs.
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:395
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
#define PLATE_OFFSET
Definition: export_vrml.cpp:60
const wxPoint GetPosition() const override
Definition: class_pad.h:220
VRML_LAYER m_top_tin
#define min(a, b)
Definition: auxiliary.h:85
static void export_vrml_padshape ( MODEL_VRML aModel,
VRML_LAYER *  aTinLayer,
D_PAD aPad 
)
static

Definition at line 1120 of file export_vrml.cpp.

References BOARD_SCALE, D_PAD::GetDelta(), D_PAD::GetOrientation(), D_PAD::GetShape(), D_PAD::GetSize(), PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_TRAPEZOID, RotatePoint(), D_PAD::ShapePos(), wxPoint::x, and wxPoint::y.

Referenced by export_vrml_pad().

1121 {
1122  // The (maybe offset) pad position
1123  wxPoint pad_pos = aPad->ShapePos();
1124  double pad_x = pad_pos.x * BOARD_SCALE;
1125  double pad_y = pad_pos.y * BOARD_SCALE;
1126  wxSize pad_delta = aPad->GetDelta();
1127 
1128  double pad_dx = pad_delta.x * BOARD_SCALE / 2.0;
1129  double pad_dy = pad_delta.y * BOARD_SCALE / 2.0;
1130 
1131  double pad_w = aPad->GetSize().x * BOARD_SCALE / 2.0;
1132  double pad_h = aPad->GetSize().y * BOARD_SCALE / 2.0;
1133 
1134  switch( aPad->GetShape() )
1135  {
1136  case PAD_SHAPE_CIRCLE:
1137 
1138  if( !aTinLayer->AddCircle( pad_x, -pad_y, pad_w, false ) )
1139  throw( std::runtime_error( aTinLayer->GetError() ) );
1140 
1141  break;
1142 
1143  case PAD_SHAPE_OVAL:
1144 
1145  if( !aTinLayer->AddSlot( pad_x, -pad_y, pad_w * 2.0, pad_h * 2.0,
1146  aPad->GetOrientation()/10.0, false ) )
1147  throw( std::runtime_error( aTinLayer->GetError() ) );
1148 
1149  break;
1150 
1151  case PAD_SHAPE_RECT:
1152  // Just to be sure :D
1153  pad_dx = 0;
1154  pad_dy = 0;
1155 
1156  case PAD_SHAPE_TRAPEZOID:
1157  {
1158  double coord[8] =
1159  {
1160  -pad_w + pad_dy, -pad_h - pad_dx,
1161  -pad_w - pad_dy, pad_h + pad_dx,
1162  +pad_w - pad_dy, -pad_h + pad_dx,
1163  +pad_w + pad_dy, pad_h - pad_dx
1164  };
1165 
1166  for( int i = 0; i < 4; i++ )
1167  {
1168  RotatePoint( &coord[i * 2], &coord[i * 2 + 1], aPad->GetOrientation() );
1169  coord[i * 2] += pad_x;
1170  coord[i * 2 + 1] += pad_y;
1171  }
1172 
1173  int lines;
1174 
1175  lines = aTinLayer->NewContour();
1176 
1177  if( lines < 0 )
1178  throw( std::runtime_error( aTinLayer->GetError() ) );
1179 
1180  if( !aTinLayer->AddVertex( lines, coord[0], -coord[1] ) )
1181  throw( std::runtime_error( aTinLayer->GetError() ) );
1182 
1183  if( !aTinLayer->AddVertex( lines, coord[4], -coord[5] ) )
1184  throw( std::runtime_error( aTinLayer->GetError() ) );
1185 
1186  if( !aTinLayer->AddVertex( lines, coord[6], -coord[7] ) )
1187  throw( std::runtime_error( aTinLayer->GetError() ) );
1188 
1189  if( !aTinLayer->AddVertex( lines, coord[2], -coord[3] ) )
1190  throw( std::runtime_error( aTinLayer->GetError() ) );
1191 
1192  if( !aTinLayer->EnsureWinding( lines, false ) )
1193  throw( std::runtime_error( aTinLayer->GetError() ) );
1194 
1195  break;
1196  }
1197 
1198  default:
1199  break;
1200  }
1201 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
const wxSize & GetSize() const
Definition: class_pad.h:269
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
const wxSize & GetDelta() const
Definition: class_pad.h:272
wxPoint ShapePos() const
Definition: class_pad.cpp:500
static void export_vrml_pcbtext ( MODEL_VRML aModel,
TEXTE_PCB text 
)
static

Definition at line 764 of file export_vrml.cpp.

References BLACK, color, DrawGraphicText(), EDA_TEXT::GetHorizJustify(), BOARD_ITEM::GetLayer(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), MODEL_VRML::m_text_layer, MODEL_VRML::m_text_width, vrml_text_callback(), and wxStringSplit().

Referenced by export_vrml_drawings().

765 {
766  model_vrml->m_text_layer = text->GetLayer();
768 
769  wxSize size = text->GetTextSize();
770 
771  if( text->IsMirrored() )
772  size.x = -size.x;
773 
774  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by DrawGraphicText
775 
776  if( text->IsMultilineAllowed() )
777  {
778  wxArrayString strings_list;
779  wxStringSplit( text->GetShownText(), strings_list, '\n' );
780  std::vector<wxPoint> positions;
781  positions.reserve( strings_list.Count() );
782  text->GetPositionsOfLinesOfMultilineText( positions, strings_list.Count() );
783 
784  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
785  {
786  wxString& txt = strings_list.Item( ii );
787  DrawGraphicText( NULL, NULL, positions[ii], color,
788  txt, text->GetTextAngle(), size,
789  text->GetHorizJustify(), text->GetVertJustify(),
790  text->GetThickness(), text->IsItalic(),
791  true,
793  }
794  }
795  else
796  {
797  DrawGraphicText( NULL, NULL, text->GetTextPos(), color,
798  text->GetShownText(), text->GetTextAngle(), size,
799  text->GetHorizJustify(), text->GetVertJustify(),
800  text->GetThickness(), text->IsItalic(),
801  true,
803  }
804 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:137
bool IsMultilineAllowed() const
Definition: eda_text.h:186
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int color
Definition: DXF_plotter.cpp:62
static MODEL_VRML * model_vrml
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:188
double GetTextAngle() const
Definition: eda_text.h:162
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:133
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:314
LAYER_NUM m_text_layer
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:189
bool IsMirrored() const
Definition: eda_text.h:177
static void vrml_text_callback(int x0, int y0, int xf, int yf)
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:213
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
static void export_vrml_text_module ( TEXTE_MODULE module)
static

Definition at line 1021 of file export_vrml.cpp.

References BLACK, DrawGraphicText(), TEXTE_MODULE::GetDrawRotation(), EDA_TEXT::GetHorizJustify(), BOARD_ITEM::GetLayer(), TEXTE_MODULE::GetShownText(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), MODEL_VRML::m_text_layer, MODEL_VRML::m_text_width, and vrml_text_callback().

Referenced by export_vrml_module().

1022 {
1023  if( module->IsVisible() )
1024  {
1025  wxSize size = module->GetTextSize();
1026 
1027  if( module->IsMirrored() )
1028  size.x = -size.x; // Text is mirrored
1029 
1030  model_vrml->m_text_layer = module->GetLayer();
1031  model_vrml->m_text_width = module->GetThickness();
1032 
1033  DrawGraphicText( NULL, NULL, module->GetTextPos(), BLACK,
1034  module->GetShownText(), module->GetDrawRotation(), size,
1035  module->GetHorizJustify(), module->GetVertJustify(),
1036  module->GetThickness(), module->IsItalic(),
1037  true,
1039  }
1040 }
double GetDrawRotation() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static MODEL_VRML * model_vrml
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:188
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
LAYER_NUM m_text_layer
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:189
bool IsMirrored() const
Definition: eda_text.h:177
bool IsVisible() const
Definition: eda_text.h:174
static void vrml_text_callback(int x0, int y0, int xf, int yf)
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:213
static void export_vrml_tracks ( MODEL_VRML aModel,
BOARD pcb 
)
static

Definition at line 958 of file export_vrml.cpp.

References B_Cu, BOARD_SCALE, export_vrml_line(), export_vrml_via(), F_Cu, MODEL_VRML::m_plainPCB, BOARD::m_Track, TRACK::Next(), and PCB_VIA_T.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

959 {
960  for( TRACK* track = pcb->m_Track; track; track = track->Next() )
961  {
962  if( track->Type() == PCB_VIA_T )
963  {
964  export_vrml_via( aModel, pcb, (const VIA*) track );
965  }
966  else if( ( track->GetLayer() == B_Cu || track->GetLayer() == F_Cu )
967  && !aModel.m_plainPCB )
968  export_vrml_line( aModel, track->GetLayer(),
969  track->GetStart().x * BOARD_SCALE,
970  track->GetStart().y * BOARD_SCALE,
971  track->GetEnd().x * BOARD_SCALE,
972  track->GetEnd().y * BOARD_SCALE,
973  track->GetWidth() * BOARD_SCALE );
974  }
975 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
TRACK * Next() const
Definition: class_track.h:99
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
static void export_vrml_via(MODEL_VRML &aModel, BOARD *aPcb, const VIA *aVia)
DLIST< TRACK > m_Track
Definition: class_board.h:246
static void export_vrml_line(MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
static void export_vrml_via ( MODEL_VRML aModel,
BOARD aPcb,
const VIA aVia 
)
static

Definition at line 938 of file export_vrml.cpp.

References B_Cu, BOARD_SCALE, export_round_padstack(), F_Cu, VIA::GetDrillValue(), TRACK::GetStart(), TRACK::GetWidth(), VIA::LayerPair(), wxPoint::x, and wxPoint::y.

Referenced by export_vrml_tracks().

939 {
940  double x, y, r, hole;
941  PCB_LAYER_ID top_layer, bottom_layer;
942 
943  hole = aVia->GetDrillValue() * BOARD_SCALE / 2.0;
944  r = aVia->GetWidth() * BOARD_SCALE / 2.0;
945  x = aVia->GetStart().x * BOARD_SCALE;
946  y = aVia->GetStart().y * BOARD_SCALE;
947  aVia->LayerPair( &top_layer, &bottom_layer );
948 
949  // do not render a buried via
950  if( top_layer != F_Cu && bottom_layer != B_Cu )
951  return;
952 
953  // Export the via padstack
954  export_round_padstack( aModel, aPcb, x, y, r, bottom_layer, top_layer, hole );
955 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
PCB_LAYER_ID
A quick note on layer IDs:
const wxPoint & GetStart() const
Definition: class_track.h:122
static void export_round_padstack(MODEL_VRML &aModel, BOARD *pcb, double x, double y, double r, LAYER_NUM bottom_layer, LAYER_NUM top_layer, double hole)
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
int GetWidth() const
Definition: class_track.h:116
static void export_vrml_zones ( MODEL_VRML aModel,
BOARD aPcb 
)
static

Definition at line 978 of file export_vrml.cpp.

References BOARD_SCALE, SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE_FILLER::Fill(), BOARD::GetArea(), BOARD::GetAreaCount(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetLayer(), GetLayer(), ZONE_CONTAINER::IsFilled(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), ZONE_CONTAINER::SetFillMode(), VECTOR2< T >::x, VECTOR2< T >::y, and ZFM_POLYGONS.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

979 {
980 
981  for( int ii = 0; ii < aPcb->GetAreaCount(); ii++ )
982  {
983  ZONE_CONTAINER* zone = aPcb->GetArea( ii );
984 
985  VRML_LAYER* vl;
986 
987  if( !GetLayer( aModel, zone->GetLayer(), &vl ) )
988  continue;
989 
990  // fixme: this modifies the board where it shouldn't, but I don't have the time
991  // to clean this up - TW
992  if( !zone->IsFilled() )
993  {
994  ZONE_FILLER filler( aPcb );
995  zone->SetFillMode( ZFM_POLYGONS ); // use filled polygons
996  filler.Fill( { zone } );
997  }
998 
999  const SHAPE_POLY_SET& poly = zone->GetFilledPolysList();
1000 
1001  for( int i = 0; i < poly.OutlineCount(); i++ )
1002  {
1003  const SHAPE_LINE_CHAIN& outline = poly.COutline( i );
1004 
1005  int seg = vl->NewContour();
1006 
1007  for( int j = 0; j < outline.PointCount(); j++ )
1008  {
1009  if( !vl->AddVertex( seg, (double)outline.CPoint( j ).x * BOARD_SCALE,
1010  -((double)outline.CPoint( j ).y * BOARD_SCALE ) ) )
1011  throw( std::runtime_error( vl->GetError() ) );
1012 
1013  }
1014 
1015  vl->EnsureWinding( seg, false );
1016  }
1017  }
1018 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
int PointCount() const
Function PointCount()
bool IsFilled() const
Definition: class_zone.h:189
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:171
int OutlineCount() const
Returns the number of outlines in the set
Class SHAPE_POLY_SET.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1011
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:534
void SetFillMode(ZONE_FILL_MODE aFillMode)
Definition: class_zone.h:174
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:982
Class SHAPE_LINE_CHAIN.
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
static void from_quat ( double  q[4],
double  rot[4] 
)
static

Definition at line 1290 of file export_vrml.cpp.

Referenced by export_vrml_module().

1291 {
1292  rot[3] = acos( q[3] ) * 2;
1293 
1294  for( int i = 0; i < 3; i++ )
1295  {
1296  rot[i] = q[i] / sin( rot[3] / 2 );
1297  }
1298 }
static bool GetLayer ( MODEL_VRML aModel,
LAYER_NUM  layer,
VRML_LAYER **  vlayer 
)
static

Definition at line 287 of file export_vrml.cpp.

References B_Cu, B_SilkS, create_vrml_plane(), create_vrml_shell(), F_Cu, F_SilkS, MODEL_VRML::m_bot_copper, MODEL_VRML::m_bot_silk, MODEL_VRML::m_top_copper, and MODEL_VRML::m_top_silk.

Referenced by BuildBoardPolygonOutlines(), export_vrml_arc(), export_vrml_circle(), export_vrml_drawsegment(), export_vrml_edge_module(), export_vrml_line(), export_vrml_zones(), GERBER_DRAW_ITEM::GetNetAttributes(), mpWindow::GetPopupMenu(), SCH_COLLECTOR::IsCorner(), MODULE::IsFlipped(), mpWindow::IsLayerVisible(), DRAWING_TOOL::PlaceDXF(), PCB_EDIT_FRAME::Process_Special_Functions(), GERBVIEW_SELECTION_TOOL::selectVisually(), and mpWindow::SetLayerVisible().

288 {
289  switch( layer )
290  {
291  case B_Cu:
292  *vlayer = &aModel.m_bot_copper;
293  break;
294 
295  case F_Cu:
296  *vlayer = &aModel.m_top_copper;
297  break;
298 
299  case B_SilkS:
300  *vlayer = &aModel.m_bot_silk;
301  break;
302 
303  case F_SilkS:
304  *vlayer = &aModel.m_top_silk;
305  break;
306 
307  default:
308  return false;
309  }
310 
311  return true;
312 }
VRML_LAYER m_bot_silk
VRML_LAYER m_top_silk
VRML_LAYER m_bot_copper
VRML_LAYER m_top_copper
static SGNODE* getSGColor ( VRML_COLOR_INDEX  colorIdx)
static

Definition at line 1649 of file export_vrml.cpp.

References VRML_COLOR::ambient, VRML_COLOR::diffuse_blu, VRML_COLOR::diffuse_grn, VRML_COLOR::diffuse_red, IFSG_NODE::GetRawPtr(), IFSG_APPEARANCE::SetAmbient(), IFSG_APPEARANCE::SetDiffuse(), IFSG_APPEARANCE::SetShininess(), IFSG_APPEARANCE::SetSpecular(), IFSG_APPEARANCE::SetTransparency(), VRML_COLOR::shiny, VRML_COLOR::spec_blu, VRML_COLOR::spec_grn, VRML_COLOR::spec_red, VRML_COLOR::transp, VRML_COLOR_LAST, and VRML_COLOR_PCB.

Referenced by create_vrml_plane(), and create_vrml_shell().

1650 {
1651  if( colorIdx == -1 )
1652  colorIdx = VRML_COLOR_PCB;
1653  else if( colorIdx == VRML_COLOR_LAST )
1654  return NULL;
1655 
1656  if( sgmaterial[colorIdx] )
1657  return sgmaterial[colorIdx];
1658 
1659  IFSG_APPEARANCE vcolor( (SGNODE*) NULL );
1660  VRML_COLOR* cp = &colors[colorIdx];
1661 
1662  vcolor.SetSpecular( cp->spec_red, cp->spec_grn, cp->spec_blu );
1663  vcolor.SetDiffuse( cp->diffuse_red, cp->diffuse_grn, cp->diffuse_blu );
1664  vcolor.SetShininess( cp->shiny );
1665  // NOTE: XXX - replace with a better equation; using this definition
1666  // of ambient will not yield the best results
1667  vcolor.SetAmbient( cp->ambient, cp->ambient, cp->ambient );
1668  vcolor.SetTransparency( cp->transp );
1669 
1670  sgmaterial[colorIdx] = vcolor.GetRawPtr();
1671 
1672  return sgmaterial[colorIdx];
1673 }
float transp
Definition: export_vrml.cpp:87
static SGNODE * sgmaterial[VRML_COLOR_LAST]
Class SGNODE represents the base class of all Scene Graph nodes.
Definition: sg_node.h:76
float spec_blu
Definition: export_vrml.cpp:80
float ambient
Definition: export_vrml.cpp:86
float diffuse_grn
Definition: export_vrml.cpp:75
float spec_red
Definition: export_vrml.cpp:78
float spec_grn
Definition: export_vrml.cpp:79
float diffuse_red
Definition: export_vrml.cpp:74
float diffuse_blu
Definition: export_vrml.cpp:76
static VRML_COLOR colors[VRML_COLOR_LAST]
static void vrml_text_callback ( int  x0,
int  y0,
int  xf,
int  yf 
)
static

Definition at line 752 of file export_vrml.cpp.

References BOARD_SCALE, export_vrml_line(), MODEL_VRML::m_text_layer, and MODEL_VRML::m_text_width.

Referenced by export_vrml_pcbtext(), and export_vrml_text_module().

753 {
754  LAYER_NUM m_text_layer = model_vrml->m_text_layer;
755  int m_text_width = model_vrml->m_text_width;
756 
757  export_vrml_line( *model_vrml, m_text_layer,
758  x0 * BOARD_SCALE, y0 * BOARD_SCALE,
759  xf * BOARD_SCALE, yf * BOARD_SCALE,
760  m_text_width * BOARD_SCALE );
761 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
static MODEL_VRML * model_vrml
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
LAYER_NUM m_text_layer
static void export_vrml_line(MODEL_VRML &aModel, LAYER_NUM layer, double startx, double starty, double endx, double endy, double width)
static void write_layers ( MODEL_VRML aModel,
BOARD aPcb,
const char *  aFileName,
OSTREAM aOutputFile 
)
static

Definition at line 420 of file export_vrml.cpp.

References ART_OFFSET, B_Cu, B_SilkS, BOARD_SCALE, create_vrml_plane(), create_vrml_shell(), F_Cu, F_SilkS, MODEL_VRML::GetColor(), MODEL_VRML::GetLayerZ(), IFSG_NODE::GetRawPtr(), MODEL_VRML::m_board, MODEL_VRML::m_bot_copper, MODEL_VRML::m_bot_silk, MODEL_VRML::m_bot_tin, MODEL_VRML::m_brd_thickness, MODEL_VRML::m_holes, MODEL_VRML::m_OutputPCB, MODEL_VRML::m_plainPCB, MODEL_VRML::m_plated_holes, MODEL_VRML::m_top_copper, MODEL_VRML::m_top_silk, MODEL_VRML::m_top_tin, USE_DEFS, USE_INLINES, VRML_COLOR_PCB, VRML_COLOR_SILK, VRML_COLOR_TIN, VRML_COLOR_TRACK, write_triangle_bag(), and S3D::WriteVRML().

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

422 {
423  // VRML_LAYER board;
424  aModel.m_board.Tesselate( &aModel.m_holes );
425  double brdz = aModel.m_brd_thickness / 2.0
426  - ( Millimeter2iu( ART_OFFSET / 2.0 ) ) * BOARD_SCALE;
427 
428  if( USE_INLINES )
429  {
430  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_PCB ),
431  &aModel.m_board, false, false, brdz, -brdz );
432  }
433  else
434  {
435  create_vrml_shell( aModel.m_OutputPCB, VRML_COLOR_PCB, &aModel.m_board, brdz, -brdz );
436  }
437 
438  if( aModel.m_plainPCB )
439  {
440  if( !USE_INLINES )
441  S3D::WriteVRML( aFileName, true, aModel.m_OutputPCB.GetRawPtr(), USE_DEFS, true );
442 
443  return;
444  }
445 
446  // VRML_LAYER m_top_copper;
447  aModel.m_top_copper.Tesselate( &aModel.m_holes );
448 
449  if( USE_INLINES )
450  {
451  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_TRACK ),
452  &aModel.m_top_copper, true, true,
453  aModel.GetLayerZ( F_Cu ), 0 );
454  }
455  else
456  {
458  aModel.GetLayerZ( F_Cu ), true );
459  }
460 
461  // VRML_LAYER m_top_tin;
462  aModel.m_top_tin.Tesselate( &aModel.m_holes );
463 
464  if( USE_INLINES )
465  {
466  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_TIN ),
467  &aModel.m_top_tin, true, true,
468  aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
469  0 );
470  }
471  else
472  {
474  aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
475  true );
476  }
477 
478  // VRML_LAYER m_bot_copper;
479  aModel.m_bot_copper.Tesselate( &aModel.m_holes );
480 
481  if( USE_INLINES )
482  {
483  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_TRACK ),
484  &aModel.m_bot_copper, true, false,
485  aModel.GetLayerZ( B_Cu ), 0 );
486  }
487  else
488  {
490  aModel.GetLayerZ( B_Cu ), false );
491  }
492 
493  // VRML_LAYER m_bot_tin;
494  aModel.m_bot_tin.Tesselate( &aModel.m_holes );
495 
496  if( USE_INLINES )
497  {
498  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_TIN ),
499  &aModel.m_bot_tin, true, false,
500  aModel.GetLayerZ( B_Cu )
501  - Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
502  0 );
503  }
504  else
505  {
507  aModel.GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
508  false );
509  }
510 
511  // VRML_LAYER PTH;
512  aModel.m_plated_holes.Tesselate( NULL, true );
513 
514  if( USE_INLINES )
515  {
516  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_TIN ),
517  &aModel.m_plated_holes, false, false,
518  aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
519  aModel.GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE );
520  }
521  else
522  {
524  aModel.GetLayerZ( F_Cu ) + Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE,
525  aModel.GetLayerZ( B_Cu ) - Millimeter2iu( ART_OFFSET / 2.0 ) * BOARD_SCALE );
526  }
527 
528  // VRML_LAYER m_top_silk;
529  aModel.m_top_silk.Tesselate( &aModel.m_holes );
530 
531  if( USE_INLINES )
532  {
533  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_SILK ), &aModel.m_top_silk,
534  true, true, aModel.GetLayerZ( F_SilkS ), 0 );
535  }
536  else
537  {
539  aModel.GetLayerZ( F_SilkS ), true );
540  }
541 
542  // VRML_LAYER m_bot_silk;
543  aModel.m_bot_silk.Tesselate( &aModel.m_holes );
544 
545  if( USE_INLINES )
546  {
547  write_triangle_bag( *aOutputFile, aModel.GetColor( VRML_COLOR_SILK ), &aModel.m_bot_silk,
548  true, false, aModel.GetLayerZ( B_SilkS ), 0 );
549  }
550  else
551  {
553  aModel.GetLayerZ( B_SilkS ), false );
554  }
555 
556  if( !USE_INLINES )
557  S3D::WriteVRML( aFileName, true, aModel.m_OutputPCB.GetRawPtr(), true, true );
558 }
static double BOARD_SCALE
Definition: export_vrml.cpp:67
SGNODE * GetRawPtr(void)
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:66
static bool USE_INLINES
Definition: export_vrml.cpp:63
VRML_LAYER m_bot_tin
VRML_LAYER m_plated_holes
VRML_LAYER m_holes
static void create_vrml_plane(IFSG_TRANSFORM &PcbOutput, VRML_COLOR_INDEX colorID, VRML_LAYER *layer, double aHeight, bool aTopPlane)
static void write_triangle_bag(std::ostream &aOut_file, VRML_COLOR &aColor, VRML_LAYER *aLayer, bool aPlane, bool aTop, double aTop_z, double aBottom_z)
IFSG_TRANSFORM m_OutputPCB
SGLIB_API bool WriteVRML(const char *filename, bool overwrite, SGNODE *aTopNode, bool reuse, bool renameNodes)
Function WriteVRML writes out the given node and its subnodes to a VRML2 file.
Definition: ifsg_api.cpp:81
VRML_LAYER m_bot_silk
VRML_LAYER m_top_silk
VRML_LAYER m_board
VRML_LAYER m_bot_copper
static void create_vrml_shell(IFSG_TRANSFORM &PcbOutput, VRML_COLOR_INDEX colorID, VRML_LAYER *layer, double top_z, double bottom_z)
double m_brd_thickness
static bool USE_DEFS
Definition: export_vrml.cpp:64
VRML_LAYER m_top_copper
VRML_LAYER m_top_tin
VRML_COLOR & GetColor(VRML_COLOR_INDEX aIndex)
double GetLayerZ(LAYER_NUM aLayer)
#define ART_OFFSET
Definition: export_vrml.cpp:58
static void write_triangle_bag ( std::ostream &  aOut_file,
VRML_COLOR aColor,
VRML_LAYER *  aLayer,
bool  aPlane,
bool  aTop,
double  aTop_z,
double  aBottom_z 
)
static

Definition at line 320 of file export_vrml.cpp.

References VRML_COLOR::ambient, VRML_COLOR::diffuse_blu, VRML_COLOR::diffuse_grn, VRML_COLOR::diffuse_red, VRML_COLOR::emit_blu, VRML_COLOR::emit_grn, VRML_COLOR::emit_red, PRECISION, VRML_COLOR::shiny, VRML_COLOR::spec_blu, VRML_COLOR::spec_grn, VRML_COLOR::spec_red, and VRML_COLOR::transp.

Referenced by write_layers().

323 {
324  /* A lot of nodes are not required, but blender sometimes chokes
325  * without them */
326  static const char* shape_boiler[] =
327  {
328  "Transform {\n",
329  " children [\n",
330  " Group {\n",
331  " children [\n",
332  " Shape {\n",
333  " appearance Appearance {\n",
334  " material Material {\n",
335  0, // Material marker
336  " }\n",
337  " }\n",
338  " geometry IndexedFaceSet {\n",
339  " solid TRUE\n",
340  " coord Coordinate {\n",
341  " point [\n",
342  0, // Coordinates marker
343  " ]\n",
344  " }\n",
345  " coordIndex [\n",
346  0, // Index marker
347  " ]\n",
348  " }\n",
349  " }\n",
350  " ]\n",
351  " }\n",
352  " ]\n",
353  "}\n",
354  0 // End marker
355  };
356 
357  int marker_found = 0, lineno = 0;
358 
359  while( marker_found < 4 )
360  {
361  if( shape_boiler[lineno] )
362  aOut_file << shape_boiler[lineno];
363  else
364  {
365  marker_found++;
366 
367  switch( marker_found )
368  {
369  case 1: // Material marker
370  aOut_file << " diffuseColor " << std::setprecision(3);
371  aOut_file << aColor.diffuse_red << " ";
372  aOut_file << aColor.diffuse_grn << " ";
373  aOut_file << aColor.diffuse_blu << "\n";
374 
375  aOut_file << " specularColor ";
376  aOut_file << aColor.spec_red << " ";
377  aOut_file << aColor.spec_grn << " ";
378  aOut_file << aColor.spec_blu << "\n";
379 
380  aOut_file << " emissiveColor ";
381  aOut_file << aColor.emit_red << " ";
382  aOut_file << aColor.emit_grn << " ";
383  aOut_file << aColor.emit_blu << "\n";
384 
385  aOut_file << " ambientIntensity " << aColor.ambient << "\n";
386  aOut_file << " transparency " << aColor.transp << "\n";
387  aOut_file << " shininess " << aColor.shiny << "\n";
388  break;
389 
390  case 2:
391 
392  if( aPlane )
393  aLayer->WriteVertices( aTop_z, aOut_file, PRECISION );
394  else
395  aLayer->Write3DVertices( aTop_z, aBottom_z, aOut_file, PRECISION );
396 
397  aOut_file << "\n";
398  break;
399 
400  case 3:
401 
402  if( aPlane )
403  aLayer->WriteIndices( aTop, aOut_file );
404  else
405  aLayer->Write3DIndices( aOut_file );
406 
407  aOut_file << "\n";
408  break;
409 
410  default:
411  break;
412  }
413  }
414 
415  lineno++;
416  }
417 }
float transp
Definition: export_vrml.cpp:87
float spec_blu
Definition: export_vrml.cpp:80
float ambient
Definition: export_vrml.cpp:86
float diffuse_grn
Definition: export_vrml.cpp:75
float spec_red
Definition: export_vrml.cpp:78
float spec_grn
Definition: export_vrml.cpp:79
float emit_grn
Definition: export_vrml.cpp:83
float emit_blu
Definition: export_vrml.cpp:84
float diffuse_red
Definition: export_vrml.cpp:74
static const int PRECISION
Definition: export_vrml.cpp:68
float emit_red
Definition: export_vrml.cpp:82
float diffuse_blu
Definition: export_vrml.cpp:76

Variable Documentation

MODEL_VRML* model_vrml
static

Definition at line 282 of file export_vrml.cpp.

const int PRECISION = 6
static
wxString PROJ_DIR
static

Definition at line 70 of file export_vrml.cpp.

Referenced by PCB_EDIT_FRAME::ExportVRML_File().

SGNODE* sgmaterial[VRML_COLOR_LAST] = { NULL }
static

Definition at line 140 of file export_vrml.cpp.

wxString SUBDIR_3D
static

Definition at line 69 of file export_vrml.cpp.

Referenced by export_vrml_module(), and PCB_EDIT_FRAME::ExportVRML_File().

bool USE_DEFS
static
bool USE_INLINES
static
bool USE_RELPATH
static

Definition at line 65 of file export_vrml.cpp.

Referenced by export_vrml_module(), and PCB_EDIT_FRAME::ExportVRML_File().

double WORLD_SCALE = 1.0
static

Definition at line 66 of file export_vrml.cpp.

Referenced by PCB_EDIT_FRAME::ExportVRML_File(), and MODEL_VRML::SetScale().