+ unify DLL export defines to namespace names

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-10-10 13:44:52 +00:00
commit 120ca87015
4155 changed files with 2965978 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Python.h>
#endif
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <JtTk/JtkEntityFactory.h>
extern struct PyMethodDef JtReader_methods[];
extern "C" {
void AppJtReaderExport initJtReader() {
(void) Py_InitModule("JtReader", JtReader_methods); /* mod name, table ptr */
// load dependend module
Base::Interpreter().loadModule("Mesh");
// Initialize JtTk
JtkEntityFactory::init();
// Note, non-evaluation JT Open Toolkit licensees must uncomment the
// following line, inserting their "Sold_To_ID". Each licensee has a
// unique Sold_To_ID issued by UGS Corp.
//
JtkEntityFactory::registerCustomer( 1103193 );
//JtkEntityFactory::registerCustomer(1103103);
Base::Console().Log("Loading JtReader module... done\n");
return;
}
} // extern "C" {

View File

@@ -0,0 +1,237 @@
/***************************************************************************
* Copyright (c) Juergen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Python.h>
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <App/Application.h>
#include <App/Document.h>
#include <Mod/Mesh/App/Core/MeshKernel.h>
#include <Mod/Mesh/App/Core/Elements.h>
#include <Mod/Mesh/App/MeshPy.h>
#include <Mod/Mesh/App/MeshPy.h>
#include <Mod/Mesh/App/MeshFeature.h>
#include "JtReader.h"
using std::vector;
using namespace MeshCore;
//using namespace JtReader;
/* module functions */
static PyObject * read(PyObject *self, PyObject *args)
{
const char* Name;
if (! PyArg_ParseTuple(args, "s",&Name))
return NULL;
PY_TRY {
std::auto_ptr<MeshCore::MeshKernel> apcKernel(new MeshCore::MeshKernel());
readFile(Name,0);
vector<MeshGeomFacet> facets;
facets.resize(iterSize());
const SimpleMeshFacet* It=iterStart();
int i=0;
while(It=iterGetNext())
{
facets[i]._aclPoints[0].x = It->p1[0];
facets[i]._aclPoints[0].y = It->p1[1];
facets[i]._aclPoints[0].z = It->p1[2];
facets[i]._aclPoints[1].x = It->p2[0];
facets[i]._aclPoints[1].y = It->p2[1];
facets[i]._aclPoints[1].z = It->p2[2];
facets[i]._aclPoints[2].x = It->p3[0];
facets[i]._aclPoints[2].y = It->p3[1];
facets[i]._aclPoints[2].z = It->p3[2];
}
clearData();
(*apcKernel) = facets;
return new Mesh::MeshPy(new Mesh::MeshObject(*(apcKernel.release())));
} PY_CATCH;
Py_Return;
}
static PyObject *
open(PyObject *self, PyObject *args)
{
const char* Name;
if (! PyArg_ParseTuple(args, "s",&Name))
return NULL;
PY_TRY {
//Base::Console().Log("Open in Mesh with %s",Name);
Base::FileInfo file(Name);
// extract ending
if(file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
if(file.hasExtension("jt"))
{
// create new document and add Import feature
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
Mesh::Feature *pcFeature = (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str());
std::auto_ptr<MeshCore::MeshKernel> apcKernel(new MeshCore::MeshKernel());
readFile(Name,0);
vector<MeshGeomFacet> facets;
facets.resize(iterSize());
const SimpleMeshFacet* It=iterStart();
int i=0;
while(It=iterGetNext())
{
facets[i]._aclPoints[0].x = It->p1[0];
facets[i]._aclPoints[0].y = It->p1[1];
facets[i]._aclPoints[0].z = It->p1[2];
facets[i]._aclPoints[1].x = It->p2[0];
facets[i]._aclPoints[1].y = It->p2[1];
facets[i]._aclPoints[1].z = It->p2[2];
facets[i]._aclPoints[2].x = It->p3[0];
facets[i]._aclPoints[2].y = It->p3[1];
facets[i]._aclPoints[2].z = It->p3[2];
i++;
}
clearData();
(*apcKernel) = facets;
pcFeature->Mesh.setValue(*(apcKernel.get()));
//pcFeature->FileName.setValue( Name );
pcDoc->recompute();
}
else
{
Py_Error(PyExc_Exception,"unknown file ending");
}
} PY_CATCH;
Py_Return;
}
/* module functions */
static PyObject *
insert(PyObject *self, PyObject *args)
{
const char* Name;
const char* DocName;
if (! PyArg_ParseTuple(args, "ss",&Name,&DocName))
return NULL;
PY_TRY {
Base::FileInfo file(Name);
// extract ending
if(file.extension() == "")
Py_Error(PyExc_Exception,"no file ending");
if(file.hasExtension("jt") )
{
// add Import feature
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
if (!pcDoc)
{
char szBuf[200];
snprintf(szBuf, 200, "Import called to the non-existing document '%s'", DocName);
Py_Error(PyExc_Exception,szBuf);
}
readFile(Name,0);
vector<MeshGeomFacet> facets;
if(iterSize()>0){
facets.resize(iterSize());
const SimpleMeshFacet* It=iterStart();
int i=0;
while(It=iterGetNext())
{
facets[i]._aclPoints[0].x = It->p1[0];
facets[i]._aclPoints[0].y = It->p1[1];
facets[i]._aclPoints[0].z = It->p1[2];
facets[i]._aclPoints[1].x = It->p2[0];
facets[i]._aclPoints[1].y = It->p2[1];
facets[i]._aclPoints[1].z = It->p2[2];
facets[i]._aclPoints[2].x = It->p3[0];
facets[i]._aclPoints[2].y = It->p3[1];
facets[i]._aclPoints[2].z = It->p3[2];
i++;
}
clearData();
Mesh::Feature *pcFeature = (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str());
std::auto_ptr<MeshCore::MeshKernel> apcKernel(new MeshCore::MeshKernel());
(*apcKernel) = facets;
pcFeature->Mesh.setValue(*(apcKernel.get()));
//pcDoc->recompute();
}else{
clearData();
//Py_Error(PyExc_Exception,"No Mesh in file");
Base::Console().Warning("No Mesh in file: %s\n",Name);
}
}
else
{
Py_Error(PyExc_Exception,"unknown file ending");
}
} PY_CATCH;
Py_Return;
}
/* registration table */
struct PyMethodDef JtReader_methods[] = {
{"open" ,open , Py_NEWARGS, "open a jt file in a new Document"},
{"insert" ,insert, Py_NEWARGS, "isert a jt file in a existing document"},
{"read" ,read, Py_NEWARGS, "Read a Mesh from a jt file and returns a Mesh object."},
{NULL, NULL}
};

View File

@@ -0,0 +1,725 @@
/***************************************************************************
* Copyright (c) Juergen Riegel 2007 <juergen.riegel@web.de> *
* LGPL *
***************************************************************************/
#include <sys/types.h>
#include <string.h>
#include <strstream>
#include <vector>
#include <JtTk/JtkCADImporter.h>
#include <JtTk/JtkCADExporter.h>
#include <JtTk/JtkTraverser.h>
#include <JtTk/JtkEntityFactory.h>
#include <JtTk/JtkAttrib.h>
#include <JtTk/JtkStandard.h>
using std::string;
using std::vector;
using std::strstream;
#include "JtReader.h"
int my_level = 0;
bool want_details = false;
int iLod = 0;
strstream InfoOut;
vector<SimpleMeshFacet> result;
vector<SimpleMeshFacet>::const_iterator resultIt;
#define indent(i) {for(int l=0; l < i; l++) InfoOut << " ";}
void printXform(JtkTransform *partXform, int level)
{
float *elements= NULL;
indent(level);
InfoOut << "JtkTRANSFORM\n";
partXform->getTElements(elements);
if( elements )
{
indent(level+1);
InfoOut << elements[0] << ", " << elements[1] << ", "
<< elements[2] << ", " << elements[3] << "\n";
indent(level+1);
InfoOut << elements[4] << ", " << elements[5] << ", "
<< elements[6] << ", " << elements[7] << "\n";
indent(level+1);
InfoOut << elements[8] << ", " << elements[9] << ", "
<< elements[10] << ", " << elements[11] << "\n";
indent(level+1);
InfoOut << elements[12] << ", " << elements[13] << ", "
<< elements[14] << ", " << elements[15] << "\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( elements );
#else
delete [] elements;
#endif
}
}
void printMaterial(JtkMaterial *partMaterial, int level)
{
float *ambient= NULL,
*diffuse= NULL,
*specular= NULL,
*emission= NULL,
shininess= -999.0;
indent(level);
InfoOut << "JtkMATERIAL\n";
partMaterial->getAmbientColor(ambient);
if( ambient )
{
indent(level+1);
InfoOut << "ambient = ( " << ambient[0] << ", " << ambient[1] << ", "
<< ambient[2] << ", " << ambient[3] << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( ambient );
#else
delete [] ambient;
#endif
}
partMaterial->getDiffuseColor(diffuse);
if( diffuse )
{
indent(level+1);
InfoOut << "diffuse = ( " << diffuse[0] << ", " << diffuse[1] << ", "
<< diffuse[2] << ", " << diffuse[3] << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( diffuse );
#else
delete [] diffuse;
#endif
}
partMaterial->getSpecularColor(specular);
if( specular )
{
indent(level+1);
InfoOut << "specular = ( " << specular[0] << ", " << specular[1] << ", "
<< specular[2] << ", " << specular[3] << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( specular );
#else
delete [] specular;
#endif
}
partMaterial->getEmissionColor(emission);
if( emission )
{
indent(level+1);
InfoOut << "emission = ( " << emission[0] << ", " << emission[1] << ", "
<< emission[2] << ", " << emission[3] << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( emission );
#else
delete [] emission;
#endif
}
partMaterial->getShininess(shininess);
if( shininess != -999.0 )
{
indent(level+1);
InfoOut << "shininess = " << shininess << "\n";
}
}
void printBrep(JtkBrep *partBrep, int level)
{
indent(level);
InfoOut << "JtkBREP\n";
}
void printWrep(JtkWrep *partWrep, int level)
{
indent(level);
InfoOut << "JtkWREP\n";
}
void printShape(JtkShape *partShape, int level)
{
indent(level);
InfoOut << "JtkSHAPE\n";
for(int set=0; set < partShape->numOfSets(); set++)
{
indent(level+1);
InfoOut << "geom set #" << set << ":\n";
float *vertex= NULL,
*normal= NULL,
*color= NULL,
*texture= NULL;
int vertexCount= -1,
normCount= -1,
colorCount= -1,
textCount= -1;
partShape->getInternal(vertex, vertexCount, normal, normCount,
color, colorCount, texture, textCount, set);
if( vertex && (vertexCount > 0) )
{
indent(level+2);
InfoOut << "vertices = ( ";
for(int elems=0; elems < vertexCount*3; elems++)
{
InfoOut << ((elems != 0) ? ", " : "") << vertex[elems];
}
InfoOut << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( vertex );
#else
delete [] vertex;
#endif
}
if( normal && (normCount > 0) )
{
indent(level+2);
InfoOut << "normals = ( ";
for(int elems=0; elems < normCount*3; elems++)
{
InfoOut << ((elems != 0) ? ", " : "") << normal[elems];
}
InfoOut << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( normal );
#else
delete [] normal;
#endif
}
if( color && (colorCount > 0) )
{
indent(level+2);
InfoOut << "color = ( ";
for(int elems=0; elems < colorCount*3; elems++)
{
InfoOut << ((elems != 0) ? ", " : "") << color[elems];
}
InfoOut << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( color );
#else
delete [] color;
#endif
}
if( texture && (textCount > 0) )
{
indent(level+2);
InfoOut << "texture = ( ";
for(int elems=0; elems < textCount; elems++)
{
InfoOut << ((elems != 0) ? ", " : "") << texture[elems];
}
InfoOut << " )\n";
#ifdef _DEBUG
JtkEntityFactory::deleteMemory( texture );
#else
delete [] texture;
#endif
}
}
}
int myPreactionCB_PrintName(JtkHierarchy *CurrNode, int level, JtkClientData*)
{
indent(level);
my_level++;
switch (CurrNode->typeID())
{
case JtkEntity::JtkNONE:
InfoOut << "JtkNONE\n";
break;
case JtkEntity::JtkBREP:
InfoOut << "JtkBREP\n";
break;
case JtkEntity::JtkREGION:
InfoOut << "JtkREGION\n";
break;
case JtkEntity::JtkSHELL:
InfoOut << "JtkSHELL\n";
break;
case JtkEntity::JtkLOOP:
InfoOut << "JtkLOOP\n";
break;
case JtkEntity::JtkCOEDGE:
InfoOut << "JtkCOEDGE\n";
break;
case JtkEntity::JtkEDGE:
InfoOut << "JtkEDGE\n";
break;
case JtkEntity::JtkVERTEX:
InfoOut << "JtkVERTEX\n";
break;
case JtkEntity::JtkNURBSSURFACE:
InfoOut << "JtkNURBSSURFACE\n";
break;
case JtkEntity::JtkUVCURVE:
InfoOut << "JtkUVCURVE\n";
break;
case JtkEntity::JtkXYZCURVE:
InfoOut << "JtkXYZCURVE\n";
break;
case JtkEntity::JtkTRISTRIPSET:
InfoOut << "JtkTRISTRIPSET\n";
break;
case JtkEntity::JtkPOINTSET:
InfoOut << "JtkPOINTSET\n";
break;
case JtkEntity::JtkLINESTRIPSET:
InfoOut << "JtkLINESTRIPSET\n";
break;
case JtkEntity::JtkPOLYGONSET:
InfoOut << "JtkPOLYGONSET\n";
break;
case JtkEntity::JtkPOINT:
InfoOut << "JtkPOINT\n";
break;
case JtkEntity::JtkMATERIAL:
InfoOut << "JtkMATERIAL\n";
break;
case JtkEntity::JtkTRANSFORM:
InfoOut << "JtkTRANSFORM\n";
break;
case JtkEntity::JtkPROPERTY:
InfoOut << "JtkPROPERTY\n";
break;
case JtkEntity::JtkPART:
{
InfoOut << "JtkPART: ";
InfoOut << CurrNode->name() << "\n";
if( want_details )
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
printXform(partXform, level+1);
}
JtkMaterial *partMaterial= NULL;
((JtkPart*) CurrNode)->getMaterial(partMaterial);
if( partMaterial )
{
printMaterial(partMaterial, level+1);
}
JtkBrep *partBrep= NULL;
((JtkPart*) CurrNode)->getBrep(partBrep);
if( partBrep )
{
printBrep(partBrep, level+1);
}
JtkWrep *partWrep= NULL;
((JtkPart*) CurrNode)->getWrep(partWrep);
if( partWrep )
{
printWrep(partWrep, level+1);
}
int partNumShapeLODs= -1;
partNumShapeLODs= ((JtkPart*) CurrNode)->numPolyLODs();
for(int lod=0; lod < partNumShapeLODs; lod++)
{
indent(level+1);
InfoOut << "LOD#" << lod << ":\n";
int partNumShapes= -1;
partNumShapes= ((JtkPart*) CurrNode)->numPolyShapes(lod);
for(int shNum=0; shNum < partNumShapes; shNum++)
{
indent(level+2);
InfoOut << "Shape#" << shNum << ":\n";
JtkShape *partShape= NULL;
((JtkPart*) CurrNode)->getPolyShape(partShape, lod, shNum);
if( partShape )
{
printShape(partShape, level+3);
}
}
}
}
}
break;
case JtkEntity::JtkASSEMBLY:
{
InfoOut << "JtkASSEMBLY: ";
InfoOut << CurrNode->name() << "("
<< ((JtkAssembly*) CurrNode)->numChildren()
<< " children)\n";
if( want_details )
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
printXform(partXform, level+1);
}
JtkMaterial *partMaterial= NULL;
((JtkPart*) CurrNode)->getMaterial(partMaterial);
if( partMaterial )
{
printMaterial(partMaterial, level+1);
}
}
}
break;
case JtkEntity::JtkINSTANCE:
{
InfoOut << "JtkINSTANCE: ";
InfoOut << CurrNode->name() << "\n";
if( want_details )
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
printXform(partXform, level+1);
}
JtkMaterial *partMaterial= NULL;
((JtkPart*) CurrNode)->getMaterial(partMaterial);
if( partMaterial )
{
printMaterial(partMaterial, level+1);
}
}
}
break;
case JtkEntity::JtkCLIENTDATA:
InfoOut << "JtkCLIENTDATA\n";
break;
case JtkEntity::JtkWIRE:
InfoOut << "JtkWIRE\n";
break;
}
return( Jtk_OK );
}
void insertShapeFaces(JtkShape *partShape)
{
for(int set=0; set < partShape->numOfSets(); set++)
{
float *vertex= NULL,
*normal= NULL,
*color= NULL,
*texture= NULL;
int vertexCount= -1,
normCount= -1,
colorCount= -1,
textCount= -1;
partShape->getInternal(vertex, vertexCount, normal, normCount, color, colorCount, texture, textCount, set);
if(normCount < 3)
return;
if( vertex && (vertexCount > 0) && normal && (normCount > 0) )
{
for(int i = 0 ; i< vertexCount-2; i++)
{
SimpleMeshFacet temp;
temp.n[0] = normal[i*3+0];
temp.n[1] = normal[i*3+1];
temp.n[2] = normal[i*3+2];
temp.p1[0]= vertex[i*3+0];
temp.p1[1]= vertex[i*3+1];
temp.p1[2]= vertex[i*3+2];
temp.p2[0]= vertex[i*3+3];
temp.p2[1]= vertex[i*3+4];
temp.p2[2]= vertex[i*3+5];
temp.p3[0]= vertex[i*3+6];
temp.p3[1]= vertex[i*3+7];
temp.p3[2]= vertex[i*3+8];
result.push_back(temp);
/*
file << " facet normal "<< normal[i*3+0] << " " << normal[i*3+1] << " " << normal[i*3+2] << " " << endl;
file << " outer loop" << endl;
file << " vertex " << vertex[i*3+0] << " " << vertex[i*3+1] << " " << vertex[i*3+2] << " " << endl;
file << " vertex " << vertex[i*3+3] << " " << vertex[i*3+4] << " " << vertex[i*3+5] << " " << endl;
file << " vertex " << vertex[i*3+6] << " " << vertex[i*3+7] << " " << vertex[i*3+8] << " " << endl;
file << " endloop" << endl;
file << " endfacet" << endl;
*/
}
}
#ifdef _DEBUG
if (vertex) JtkEntityFactory::deleteMemory( vertex );
if (vertex) JtkEntityFactory::deleteMemory( normal );
if (color) JtkEntityFactory::deleteMemory( color );
if (texture) JtkEntityFactory::deleteMemory( texture );
#else
if (vertex) delete [] vertex;
if (vertex) delete [] normal;
if (color) delete [] color;
if (texture)delete [] texture;
#endif
}
}
int myPreactionCB_CollectFacets(JtkHierarchy *CurrNode, int level, JtkClientData*)
{
switch (CurrNode->typeID())
{
case JtkEntity::JtkPART:
{
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
printXform(partXform, level+1);
}
int partNumShapeLODs= -1;
partNumShapeLODs= ((JtkPart*) CurrNode)->numPolyLODs();
for(int lod=0; lod < partNumShapeLODs; lod++)
{
indent(level+1);
InfoOut << "LOD#" << lod << ":\n";
if(iLod!=lod && iLod!=-1)
continue;
int partNumShapes= -1;
partNumShapes= ((JtkPart*) CurrNode)->numPolyShapes(lod);
for(int shNum=0; shNum < partNumShapes; shNum++)
{
indent(level+2);
InfoOut << "Shape#" << shNum << ":\n";
JtkShape *partShape= NULL;
((JtkPart*) CurrNode)->getPolyShape(partShape, lod, shNum);
if( partShape )
{
insertShapeFaces(partShape);
}
}
}
}
}
break;
case JtkEntity::JtkASSEMBLY:
{
InfoOut << "JtkASSEMBLY: ";
InfoOut << CurrNode->name() << "("
<< ((JtkAssembly*) CurrNode)->numChildren()
<< " children)\n";
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
}
}
}
break;
case JtkEntity::JtkINSTANCE:
{
{
JtkTransform *partXform= NULL;
((JtkPart*) CurrNode)->getTransform(partXform);
if( partXform )
{
}
}
}
break;
}
return( Jtk_OK );
}
/* Interface functions */
void testLicence(void)
{
// Try to create an JtkCADExporter to test for JT write/general licensing
JtkCADExporter *jtwriter = NULL;
jtwriter = JtkEntityFactory::createCADExporter();
if( !jtwriter )
{
cerr << "No export license found.\n";
exit(1);
}
else
{
jtwriter->ref();
jtwriter->unref();
jtwriter = NULL;
}
// Try to create an JtkCADImporter to test for JT read licensing
JtkCADImporter *jtreader = NULL;
jtreader = JtkEntityFactory::createCADImporter();
if( !jtreader )
{
cerr << "No import license found.\n";
exit(1);
}
else
{
jtreader->ref();
jtreader->unref();
jtreader = NULL;
}
}
void readFile(const char* FileName, int iLods)
{
iLod = iLods;
testLicence();
JtkCADImporter* importer= NULL;
importer= JtkEntityFactory::createCADImporter();
if( importer )
{
importer->ref();
importer->setShapeLoadOption(JtkCADImporter::JtkALL_LODS);
importer->setBrepLoadOption(JtkCADImporter::JtkTESS_AND_BREP);
JtkHierarchy *root= NULL;
root= importer->import(FileName);
if( root ) {
root->ref();
JtkTraverser* trav = JtkEntityFactory::createTraverser();
trav->setupPreActionCallback(myPreactionCB_CollectFacets);
if( trav ) {
trav->ref();
trav->traverseGraph(root);
trav->unref();
trav = NULL;
} else {
throw "Unable to create JtkTraverser.\n";
}
root->unref();
root = NULL;
}else{
throw "Unable in find root node. Check file...\n";
}
importer->unref();
importer = NULL;
}
else
{
throw "Unable to create JtkCADImporter. Check license...\n";
}
// Uninitialize JtTk
//JtkEntityFactory::fini();
}
const SimpleMeshFacet* iterStart(void)
{
resultIt = result.begin();
if(resultIt != result.end())
return &(*(resultIt));
else
return 0;
}
const SimpleMeshFacet* iterGetNext(void)
{
if(++resultIt != result.end())
return &(*(resultIt));
else
return 0;
}
unsigned int iterSize(void)
{
return (unsigned int) result.size();
}
/** clears the internal structure */
void clearData(void)
{
result.clear();
resultIt = result.begin();
InfoOut.clear();
my_level = 0;
}

View File

@@ -0,0 +1,36 @@
/***************************************************************************
* Copyright (c) Juergen Riegel 2007 <juergen.riegel@web.de> *
* LGPL *
***************************************************************************/
#ifndef __JtReader_h__
#define __JtReader_h__
/** simple facet structure */
struct SimpleMeshFacet {
float p1[3],p2[3],p3[3],n[3];
};
/** Reads a JT File an build up the internal data structure
* imports all the meshes of all Parts, recursing the Assamblies.
*/
void readFile(const char* FileName, int iLods = 0);
/** Write the read Part to a file */
void writeAsciiSTL(const char* FileName);
/** start the iterator on the result */
const SimpleMeshFacet* iterStart(void);
/** get the faces or 0 at end */
const SimpleMeshFacet* iterGetNext(void);
/** size of the result */
unsigned int iterSize(void);
/** clears the internal structure */
void clearData(void);
#endif // __JtReader_h__

View File

@@ -0,0 +1,52 @@
lib_LTLIBRARIES=libJtReader.la JtReader.la
BUILT_SOURCES=\
FreeCADpov.h
libJtReader_la_SOURCES=\
PreCompiled.cpp \
PreCompiled.h \
FreeCADpov.h: FreeCADpov
$(PYTHON) $(top_srcdir)/src/Tools/PythonToCPP.py $< $@
# the library search path.
libJtReader_la_LDFLAGS = -L../../../Base -L../../../App -L../../Part/App -L/usr/X11R6/lib -L$(OCC_LIB) \
$(all_libraries) -version-info @LIB_CURRENT@:@LIB_REVISION@:@LIB_AGE@
libJtReader_la_CPPFLAGS = -DAppPartExport= -DAppJtReaderExport= -DFeatureRayExportPov=
libJtReader_la_LIBADD = \
-lxerces-c \
-l@PYTHON_LIB@ \
-lFreeCADBase \
-lFreeCADApp
#--------------------------------------------------------------------------------------
# Loader of libJtReader
JtReader_la_SOURCES=\
AppJtReader.cpp
# the library search path.
JtReader_la_LDFLAGS = $(libJtReader_la_LDFLAGS) -module -avoid-version
JtReader_la_CPPFLAGS = $(libJtReader_la_CPPFLAGS)
JtReader_la_LIBADD = \
$(libJtReader_la_LIBADD) \
-lJtReader
#--------------------------------------------------------------------------------------
# set the include path found by configure
AM_CXXFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src $(all_includes)
libdir = $(prefix)/Mod/JtReader
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
CMakeLists.txt

View File

@@ -0,0 +1,7 @@
/***************************************************************************
* Copyright (c) Juergen Riegel 2007 <juergen.riegel@web.de> *
* LGPL *
***************************************************************************/
#include "PreCompiled.h"

View File

@@ -0,0 +1,69 @@
/***************************************************************************
* Copyright (c) Juergen Riegel 2007 <juergen.riegel@web.de> *
* LGPL *
***************************************************************************/
#ifndef __PRECOMPILED__
#define __PRECOMPILED__
#include <FCConfig.h>
// Importing of App classes
#ifdef FC_OS_WIN32
# define MeshExport __declspec(dllimport)
# define AppJtReaderExport __declspec(dllexport)
#else // for Linux
# define MeshExport
# define AppJtReaderExport
#endif
#ifdef _PreComp_
/// here get the warnings of to long specifieres disabled (needed for VC6)
#ifdef _MSC_VER
# pragma warning( disable : 4251 )
# pragma warning( disable : 4503 )
# pragma warning( disable : 4275 )
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
#endif
// standard
#include <stdio.h>
#include <assert.h>
// STL
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <bitset>
// Xerces
#include <xercesc/util/XercesDefs.hpp>
#endif //_PreComp_
#endif

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppJtReader", "App\AppJtReader.vcproj", "{E62A766A-E6A5-4065-B2F9-561D6A787EF0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E62A766A-E6A5-4065-B2F9-561D6A787EF0}.Debug|Win32.ActiveCfg = Debug|Win32
{E62A766A-E6A5-4065-B2F9-561D6A787EF0}.Debug|Win32.Build.0 = Debug|Win32
{E62A766A-E6A5-4065-B2F9-561D6A787EF0}.Release|Win32.ActiveCfg = Release|Win32
{E62A766A-E6A5-4065-B2F9-561D6A787EF0}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

11
src/Mod/JtReader/Init.py Normal file
View File

@@ -0,0 +1,11 @@
# FreeCAD init script of the JtReader module
# (c) 2007 Juergen Riegel LGPL
# Get the Parameter Group of this module
ParGrp = App.ParamGet("System parameter:Modules").GetGroup("JtReader")
# Append the open handler
FreeCAD.EndingAdd("JtOpen (*.jt)","JtReader")

View File

@@ -0,0 +1,70 @@
# Raytracing gui init module
# (c) 2003 Juergen Riegel
#
# Gathering all the information to start FreeCAD
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU General Public License (GPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
#* *
#* FreeCAD is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Library General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
class RaytracingWorkbench ( Workbench ):
"Raytracing workbench object"
Icon = """
/* XPM */
static char *arrows[]={
"16 16 3 1",
"# c None",
". c None",
"a c #0000FF",
"...........##...",
"...........#a#..",
"...##.......#a#a",
"..aaa#.......#aa",
"..#aaa#......#aa",
"...#aaa#........",
"....#aaa#.......",
".....#aaa#...#..",
"......#aaa#.##..",
".......#aaa#a#..",
"........#aaaa#..",
"##.......#aaa#..",
"#a#.....#aaaa#..",
".#a##...#aaaa#..",
"..#aa...........",
"..aaa..........."};
"""
MenuText = "Raytracing"
ToolTip = "Raytracing workbench"
def Initialize(self):
# load the module
import PartGui
import RaytracingGui
def GetClassName(self):
return "RaytracingGui::Workbench"
Gui.addWorkbench(RaytracingWorkbench())

View File

@@ -0,0 +1,9 @@
SUBDIRS=App Gui
# Change data dir from default ($(prefix)/share) to $(prefix)
datadir = $(prefix)/Mod/JtReader
data_DATA = Init.py InitGui.py
EXTRA_DIST = \
$(data_DATA)