Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
cd18ff17
Commit
cd18ff17
authored
Mar 28, 2013
by
Wayne Stambaugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix X3D patch commit coding policy issues.
parent
3c037a3c
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
266 additions
and
228 deletions
+266
-228
3d_read_mesh.cpp
3d-viewer/3d_read_mesh.cpp
+17
-12
modelparsers.h
3d-viewer/modelparsers.h
+36
-20
vrmlmodelparser.cpp
3d-viewer/vrmlmodelparser.cpp
+14
-25
x3dmodelparser.cpp
3d-viewer/x3dmodelparser.cpp
+150
-117
common_plot_functions.cpp
common/common_plot_functions.cpp
+1
-1
wxPcbStruct.h
include/wxPcbStruct.h
+11
-0
export_vrml.cpp
pcbnew/export_vrml.cpp
+37
-53
No files found.
3d-viewer/3d_read_mesh.cpp
View file @
cd18ff17
...
...
@@ -41,16 +41,17 @@
// Imported function:
extern
void
Set_Object_Data
(
std
::
vector
<
S3D_VERTEX
>&
aVertices
,
double
aBiuTo3DUnits
);
S3D_MODEL_PARSER
*
S3D_MODEL_PARSER
::
Create
(
S3D_MASTER
*
aMaster
,
const
wxString
aExtension
)
{
if
(
aExtension
==
wxT
(
"x3d"
)
)
{
return
new
X3D_MODEL_PARSER
(
aMaster
);
return
new
X3D_MODEL_PARSER
(
aMaster
);
}
else
if
(
aExtension
==
wxT
(
"wrl"
)
)
{
return
new
VRML_MODEL_PARSER
(
aMaster
);
return
new
VRML_MODEL_PARSER
(
aMaster
);
}
else
{
...
...
@@ -58,6 +59,7 @@ S3D_MODEL_PARSER* S3D_MODEL_PARSER::Create( S3D_MASTER* aMaster,
}
}
int
S3D_MASTER
::
ReadData
()
{
wxFileName
fn
;
...
...
@@ -69,16 +71,17 @@ int S3D_MASTER::ReadData()
}
wxString
shape3DNname
=
m_Shape3DName
;
#ifdef __WINDOWS__
shape3DNname
.
Replace
(
wxT
(
"/"
),
wxT
(
"
\\
"
)
);
shape3DNname
.
Replace
(
wxT
(
"/"
),
wxT
(
"
\\
"
)
);
#else
shape3DNname
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
shape3DNname
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
#endif
if
(
wxFileName
::
FileExists
(
shape3DNname
)
)
{
FullFilename
=
shape3DNname
;
fn
.
Assign
(
FullFilename
);
fn
.
Assign
(
FullFilename
);
}
else
{
...
...
@@ -94,10 +97,11 @@ int S3D_MASTER::ReadData()
}
wxString
extension
=
fn
.
GetExt
();
S3D_MODEL_PARSER
*
parser
=
S3D_MODEL_PARSER
::
Create
(
this
,
extension
);
if
(
parser
)
S3D_MODEL_PARSER
*
parser
=
S3D_MODEL_PARSER
::
Create
(
this
,
extension
);
if
(
parser
)
{
parser
->
Load
(
FullFilename
);
parser
->
Load
(
FullFilename
);
delete
parser
;
return
0
;
}
...
...
@@ -109,6 +113,7 @@ int S3D_MASTER::ReadData()
return
-
1
;
}
int
STRUCT_3D_SHAPE
::
ReadData
(
FILE
*
file
,
int
*
LineNum
)
{
char
line
[
512
];
...
...
3d-viewer/modelparsers.h
View file @
cd18ff17
...
...
@@ -49,8 +49,8 @@ class X3D_MODEL_PARSER;
class
S3D_MODEL_PARSER
{
public
:
S3D_MODEL_PARSER
(
S3D_MASTER
*
aMaster
)
:
master
(
aMaster
)
S3D_MODEL_PARSER
(
S3D_MASTER
*
aMaster
)
:
master
(
aMaster
)
{}
virtual
~
S3D_MODEL_PARSER
()
...
...
@@ -64,19 +64,18 @@ public:
/**
* Function Create
* Factory method for creating concrete 3D model parsers
* Notice that the caller is responible to delete created parser.
* Notice that the caller is respon
s
ible to delete created parser.
*
* @param aMaster is master object that the parser will fill.
* @param aExtension is file extension of the file you are going to parse.
*/
static
S3D_MODEL_PARSER
*
Create
(
S3D_MASTER
*
aMaster
,
const
wxString
aExtension
);
static
S3D_MODEL_PARSER
*
Create
(
S3D_MASTER
*
aMaster
,
const
wxString
aExtension
);
/**
* Function Load
*
* Concrete parsers should implement this function
*/
virtual
void
Load
(
const
wxString
aFilename
)
=
0
;
virtual
void
Load
(
const
wxString
aFilename
)
=
0
;
private
:
S3D_MASTER
*
master
;
...
...
@@ -92,9 +91,9 @@ class wxXmlNode;
class
X3D_MODEL_PARSER
:
public
S3D_MODEL_PARSER
{
public
:
X3D_MODEL_PARSER
(
S3D_MASTER
*
aMaster
);
X3D_MODEL_PARSER
(
S3D_MASTER
*
aMaster
);
~
X3D_MODEL_PARSER
();
void
Load
(
const
wxString
aFilename
);
void
Load
(
const
wxString
aFilename
);
typedef
std
::
map
<
wxString
,
wxString
>
PROPERTY_MAP
;
typedef
std
::
vector
<
wxXmlNode
*
>
NODE_LIST
;
...
...
@@ -107,8 +106,7 @@ public:
* @param aName is the name of node you try to find
* @param aResult contains found nodes
*/
static
void
GetChildsByName
(
wxXmlNode
*
aParent
,
const
wxString
aName
,
NODE_LIST
&
aResult
);
static
void
GetChildsByName
(
wxXmlNode
*
aParent
,
const
wxString
aName
,
NODE_LIST
&
aResult
);
/**
* Function GetNodeProperties
...
...
@@ -116,7 +114,7 @@ public:
*
* @param aProps contains map of found properties
*/
static
void
GetNodeProperties
(
wxXmlNode
*
aNode
,
PROPERTY_MAP
&
aProps
);
static
void
GetNodeProperties
(
wxXmlNode
*
aNode
,
PROPERTY_MAP
&
aProps
);
/**
* Return string representing x3d file in vrml format
...
...
@@ -126,17 +124,16 @@ public:
wxString
VRML_representation
();
private
:
std
::
vector
<
wxString
>
vrml_materials
;
std
::
vector
<
wxString
>
vrml_points
;
std
::
vector
<
wxString
>
vrml_coord_indexes
;
std
::
vector
<
wxString
>
vrml_materials
;
std
::
vector
<
wxString
>
vrml_points
;
std
::
vector
<
wxString
>
vrml_coord_indexes
;
void
readTransform
(
wxXmlNode
*
aTransformNode
);
void
readMaterial
(
wxXmlNode
*
aMatNode
);
void
readIndexedFaceSet
(
wxXmlNode
*
aFaceNode
,
PROPERTY_MAP
&
aTransfromProps
);
void
readIndexedFaceSet
(
wxXmlNode
*
aFaceNode
,
PROPERTY_MAP
&
aTransfromProps
);
bool
parseDoubleTriplet
(
const
wxString
&
aData
,
S3D_VERTEX
&
aResult
);
void
rotate
(
S3D_VERTEX
&
aCoordinate
,
S3D_VERTEX
&
aRotAxis
,
double
angle
);
void
rotate
(
S3D_VERTEX
&
aCoordinate
,
S3D_VERTEX
&
aRotAxis
,
double
angle
);
};
/**
...
...
@@ -146,9 +143,9 @@ private:
class
VRML_MODEL_PARSER
:
public
S3D_MODEL_PARSER
{
public
:
VRML_MODEL_PARSER
(
S3D_MASTER
*
aMaster
);
VRML_MODEL_PARSER
(
S3D_MASTER
*
aMaster
);
~
VRML_MODEL_PARSER
();
void
Load
(
const
wxString
aFilename
);
void
Load
(
const
wxString
aFilename
);
private
:
/**
...
...
@@ -170,7 +167,26 @@ private:
int
readShape
(
FILE
*
file
,
int
*
LineNum
);
int
readAppearance
(
FILE
*
file
,
int
*
LineNum
);
int
readGeometry
(
FILE
*
file
,
int
*
LineNum
);
void
readCoordsList
(
FILE
*
file
,
char
*
text_buffer
,
std
::
vector
<
double
>&
aList
,
int
*
LineNum
);
/**
* Function ReadCoordList
* reads 3D coordinate lists like:
* coord Coordinate { point [
* -5.24489 6.57640e-3 -9.42129e-2,
* -5.11821 6.57421e-3 0.542654,
* -3.45868 0.256565 1.32000 ] }
* or:
* normal Normal { vector [
* 0.995171 -6.08102e-6 9.81541e-2,
* 0.923880 -4.09802e-6 0.382683,
* 0.707107 -9.38186e-7 0.707107]
* }
*
* text_buffer contains the first line of this node :
* "coord Coordinate { point ["
*/
void
readCoordsList
(
FILE
*
file
,
char
*
text_buffer
,
std
::
vector
<
double
>&
aList
,
int
*
LineNum
);
};
#endif // MODELPARSERS_H
3d-viewer/vrmlmodelparser.cpp
View file @
cd18ff17
...
...
@@ -40,14 +40,16 @@
// separator chars
static
const
char
*
sep_chars
=
"
\t\n\r
"
;
VRML_MODEL_PARSER
::
VRML_MODEL_PARSER
(
S3D_MASTER
*
aMaster
)
:
S3D_MODEL_PARSER
(
aMaster
)
VRML_MODEL_PARSER
::
VRML_MODEL_PARSER
(
S3D_MASTER
*
aMaster
)
:
S3D_MODEL_PARSER
(
aMaster
)
{}
VRML_MODEL_PARSER
::~
VRML_MODEL_PARSER
()
{}
void
VRML_MODEL_PARSER
::
Load
(
const
wxString
aFilename
)
void
VRML_MODEL_PARSER
::
Load
(
const
wxString
aFilename
)
{
char
line
[
1024
],
*
text
;
FILE
*
file
;
...
...
@@ -67,7 +69,7 @@ void VRML_MODEL_PARSER::Load(const wxString aFilename)
{
text
=
strtok
(
line
,
sep_chars
);
if
(
stricmp
(
text
,
"DEF"
)
==
0
||
stricmp
(
text
,
"Group"
)
==
0
)
if
(
stricmp
(
text
,
"DEF"
)
==
0
||
stricmp
(
text
,
"Group"
)
==
0
)
{
while
(
GetLine
(
file
,
line
,
&
LineNum
,
512
)
)
{
...
...
@@ -91,6 +93,7 @@ void VRML_MODEL_PARSER::Load(const wxString aFilename)
SetLocaleTo_Default
();
// revert to the current locale
}
int
VRML_MODEL_PARSER
::
readMaterial
(
FILE
*
file
,
int
*
LineNum
)
{
char
line
[
512
],
*
text
,
*
command
;
...
...
@@ -258,7 +261,8 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
if
(
*
text
==
'}'
)
{
err
=
0
;
break
;
err
=
0
;
break
;
}
if
(
stricmp
(
text
,
"material"
)
==
0
)
...
...
@@ -278,24 +282,8 @@ int VRML_MODEL_PARSER::readAppearance( FILE* file, int* LineNum )
#define BUFSIZE 2000
/**
* Function ReadCoordList
* reads 3D coordinate lists like:
* coord Coordinate { point [
* -5.24489 6.57640e-3 -9.42129e-2,
* -5.11821 6.57421e-3 0.542654,
* -3.45868 0.256565 1.32000 ] }
* or:
* normal Normal { vector [
* 0.995171 -6.08102e-6 9.81541e-2,
* 0.923880 -4.09802e-6 0.382683,
* 0.707107 -9.38186e-7 0.707107]
* }
*
* text_buffer contains the first line of this node :
* "coord Coordinate { point ["
*/
void
VRML_MODEL_PARSER
::
readCoordsList
(
FILE
*
file
,
char
*
text_buffer
,
std
::
vector
<
double
>&
aList
,
int
*
LineNum
)
void
VRML_MODEL_PARSER
::
readCoordsList
(
FILE
*
file
,
char
*
text_buffer
,
std
::
vector
<
double
>&
aList
,
int
*
LineNum
)
{
unsigned
int
ii
=
0
,
jj
=
0
;
char
*
text
;
...
...
@@ -399,6 +387,7 @@ int VRML_MODEL_PARSER::readGeometry( FILE* file, int* LineNum )
else
{
}
continue
;
}
...
...
3d-viewer/x3dmodelparser.cpp
View file @
cd18ff17
This diff is collapsed.
Click to expand it.
common/common_plot_functions.cpp
View file @
cd18ff17
...
...
@@ -59,7 +59,7 @@ void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
int
iusPerMil
=
plotter
->
GetIUsPerDecimil
()
*
10
;
wxSize
pageSize
=
aPageInfo
.
GetSizeMils
();
// in mils
int
xg
,
yg
;
int
refx
,
refy
;
//
int refx, refy;
wxPoint
pos
,
end
,
ref
;
wxString
msg
;
wxSize
text_size
;
...
...
include/wxPcbStruct.h
View file @
cd18ff17
...
...
@@ -905,6 +905,17 @@ public:
/**
* Function ExportVRML_File
* Creates the file(s) exporting current BOARD to a VRML file.
*
* @note When copying 3D shapes files, the new filename is build from the full path
* name, changing the separators by underscore. This is needed because files
* with the same shortname can exist in different directories
* @note ExportVRML_File generates coordinates in board units (BIU) inside the file.
* @todo Use mm inside the file. A general scale transform is applied to the whole
* file (1.0 to have the actual WRML unit im mm, 0.001 to have the actual WRML
* unit in meters.
* @note For 3D models built by a 3D modeler, the unit is 0,1 inches. A specfic scale
* is applied to 3D models to convert them to internal units.
*
* @param aFullFileName = the full filename of the file to create
* @param aMMtoWRMLunit = the VRML scaling factor:
* 1.0 to export in mm. 0.001 for meters
...
...
pcbnew/export_vrml.cpp
View file @
cd18ff17
...
...
@@ -257,6 +257,7 @@ static void write_triangle_bag( FILE* output_file, int color_index, //{{{
"}
\n
"
,
0
// End marker
};
int
marker_found
=
0
,
lineno
=
0
;
while
(
marker_found
<
4
)
...
...
@@ -554,6 +555,7 @@ static void export_vrml_arc( int layer, double centerx, double centery,
ring
.
bag
(
layer
,
false
);
}
static
void
export_vrml_varc
(
TRIANGLEBAG
&
triangles
,
int
top_layer
,
int
bottom_layer
,
double
centerx
,
double
centery
,
...
...
@@ -961,10 +963,10 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* aPad ) //{{{
{
int
coord
[
8
]
=
{
KiROUND
(
-
pad_w
-
pad_dy
),
KiROUND
(
+
pad_h
+
pad_dx
),
KiROUND
(
-
pad_w
+
pad_dy
),
KiROUND
(
-
pad_h
-
pad_dx
),
KiROUND
(
+
pad_w
-
pad_dy
),
KiROUND
(
+
pad_h
-
pad_dx
),
KiROUND
(
+
pad_w
+
pad_dy
),
KiROUND
(
-
pad_h
+
pad_dx
),
KiROUND
(
-
pad_w
-
pad_dy
),
KiROUND
(
+
pad_h
+
pad_dx
),
KiROUND
(
-
pad_w
+
pad_dy
),
KiROUND
(
-
pad_h
-
pad_dx
),
KiROUND
(
+
pad_w
-
pad_dy
),
KiROUND
(
+
pad_h
-
pad_dx
),
KiROUND
(
+
pad_w
+
pad_dy
),
KiROUND
(
-
pad_h
+
pad_dx
),
};
for
(
int
i
=
0
;
i
<
4
;
i
++
)
...
...
@@ -1043,11 +1045,11 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
switch
(
item
->
Type
()
)
{
case
PCB_MODULE_TEXT_T
:
export_vrml_text_module
(
dynamic_cast
<
TEXTE_MODULE
*>
(
item
)
);
export_vrml_text_module
(
dynamic_cast
<
TEXTE_MODULE
*>
(
item
)
);
break
;
case
PCB_MODULE_EDGE_T
:
export_vrml_edge_module
(
dynamic_cast
<
EDGE_MODULE
*>
(
item
)
);
export_vrml_edge_module
(
dynamic_cast
<
EDGE_MODULE
*>
(
item
)
);
break
;
default:
...
...
@@ -1078,13 +1080,13 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
fname
=
vrmlm
->
m_Shape3DName
;
}
fname
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
fname
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
wxString
source_fname
=
fname
;
if
(
aExport3DFiles
)
// Change illegal characters in short filename
{
ChangeIllegalCharacters
(
fname
,
true
);
fname
=
a3D_Subdir
+
wxT
(
"/"
)
+
fname
;
fname
=
a3D_Subdir
+
wxT
(
"/"
)
+
fname
;
if
(
!
wxFileExists
(
fname
)
)
wxCopyFile
(
source_fname
,
fname
);
...
...
@@ -1153,12 +1155,12 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
if
(
fname
.
EndsWith
(
wxT
(
"x3d"
)
)
)
{
X3D_MODEL_PARSER
*
parser
=
new
X3D_MODEL_PARSER
(
vrmlm
);
X3D_MODEL_PARSER
*
parser
=
new
X3D_MODEL_PARSER
(
vrmlm
);
if
(
parser
)
if
(
parser
)
{
// embed x3d model in vrml format
parser
->
Load
(
fname
);
parser
->
Load
(
fname
);
fprintf
(
aOutputFile
,
" children [
\n
%s ]
\n
"
,
TO_UTF8
(
parser
->
VRML_representation
()
)
);
fprintf
(
aOutputFile
,
" }
\n
"
);
...
...
@@ -1187,28 +1189,7 @@ static void write_and_empty_triangle_bag( FILE* output_file, TRIANGLEBAG& triang
}
}
/* ExportVRML_File
* Creates the file(s) exporting current BOARD to a VRML file.
* aFullFileName = the full filename of the file to create
* aMMtoWRMLunit = the general WRML scaling factor. 1.0 to export in mm
* @param aExport3DFiles = true to copy 3D shapes in the subdir a3D_Subdir
* a3D_Subdir = sub directory where 3D shapes files are copied
* used only when aExport3DFiles == true
*/
/* Note1:
* When copying 3D shapes files, the new filename is build from
* the full path name, changing the separators by underscore.
* this is needed because files with the same shortname can exist in different directories
* Note 2:
* ExportVRML_File generates coordinates in board units (BIU) inside the file.
* (TODO: use mm inside the file)
* A general scale transform is applied to the whole file
* (1.0 to have the actual WRML unit im mm, 0.001 to have the actual WRML unit im meter
* Note 3:
* For 3D models built by a 3D modeler, the unit is 0,1 inch
* A specfic scale is applied to 3D models to convert them to BIU
*
*/
bool
PCB_EDIT_FRAME
::
ExportVRML_File
(
const
wxString
&
aFullFileName
,
double
aMMtoWRMLunit
,
bool
aExport3DFiles
,
const
wxString
&
a3D_Subdir
)
...
...
@@ -1218,6 +1199,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
BOARD
*
pcb
=
GetBoard
();
output_file
=
wxFopen
(
aFullFileName
,
wxT
(
"wt"
)
);
if
(
output_file
==
NULL
)
return
false
;
...
...
@@ -1227,7 +1209,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
// Begin with the usual VRML boilerplate
wxString
name
=
aFullFileName
;
name
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
name
.
Replace
(
wxT
(
"
\\
"
),
wxT
(
"/"
)
);
ChangeIllegalCharacters
(
name
,
false
);
fprintf
(
output_file
,
"#VRML V2.0 utf8
\n
"
"WorldInfo {
\n
"
...
...
@@ -1275,6 +1257,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
* is 2.54 * aMMtoWRMLunit
*/
double
wrml_3D_models_scaling_factor
=
2.54
*
aMMtoWRMLunit
;
// Export footprints
for
(
MODULE
*
module
=
pcb
->
m_Modules
;
module
!=
0
;
module
=
module
->
Next
()
)
export_vrml_module
(
pcb
,
module
,
output_file
,
...
...
@@ -1307,6 +1290,7 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
return
true
;
}
/*
* some characters cannot be used in filenames,
* this function change them to "_"
...
...
@@ -1314,8 +1298,8 @@ bool PCB_EDIT_FRAME::ExportVRML_File( const wxString & aFullFileName,
static
void
ChangeIllegalCharacters
(
wxString
&
aFileName
,
bool
aDirSepIsIllegal
)
{
if
(
aDirSepIsIllegal
)
aFileName
.
Replace
(
wxT
(
"/"
),
wxT
(
"_"
)
);
aFileName
.
Replace
(
wxT
(
"/"
),
wxT
(
"_"
)
);
aFileName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
aFileName
.
Replace
(
wxT
(
":"
),
wxT
(
"_"
)
);
aFileName
.
Replace
(
wxT
(
" "
),
wxT
(
"_"
)
);
aFileName
.
Replace
(
wxT
(
":"
),
wxT
(
"_"
)
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment