summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-11 00:21:50 +0000
committerKarl Berry <karl@freefriends.org>2009-09-11 00:21:50 +0000
commitf06a2c99f2a8bbd8f641712c772179e8ed9ce14f (patch)
treefcf4f2b9d0492da04d9bf3761fbce51fb316024f /Build/source/utils/asymptote/prc
parentd4c54e52fe8e42b8ce9b160c70d897bb1d06eee7 (diff)
asymptote 1.86
git-svn-id: svn://tug.org/texlive/trunk@15218 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/prc')
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.cc22
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.h60
2 files changed, 58 insertions, 24 deletions
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.cc b/Build/source/utils/asymptote/prc/oPRCFile.cc
index 77e28d76061..a9d6b2e2156 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.cc
+++ b/Build/source/utils/asymptote/prc/oPRCFile.cc
@@ -20,9 +20,23 @@
#include "oPRCFile.h"
#include <time.h>
+#include <sstream>
using std::string;
+static const string EntityName[]={"line","curve","surface"};
+
+std::string Name(oPRCFile *p, Entity e, std::string s)
+{
+ if(s.empty()) {
+ uint32_t i=++(p->count[e]);
+ std::ostringstream buf;
+ buf << EntityName[e] << "-" << i;
+ return buf.str();
+ }
+ return s;
+}
+
uint32_t PRCentity::getGraphicsIndex()
{
if(useMaterial)
@@ -34,7 +48,7 @@ uint32_t PRCentity::getGraphicsIndex()
void PRCline::writeRepresentationItem(PRCbitStream &out,uint32_t index)
{
out << (uint32_t)(PRC_TYPE_RI_Curve);
- ContentPRCBase(&EMPTY_ATTRIBUTES,"line",true,makeCADID(),0,makePRCID()).write(out);
+ ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
writeGraphics(out,m1,getGraphicsIndex(),1);
out << (uint32_t)0 // index_local_coordinate_system+1
<< (uint32_t)0; // index_tessellation
@@ -102,7 +116,7 @@ void PRCline::writeExtraGeometryContext(PRCbitStream &out)
void PRCcurve::writeRepresentationItem(PRCbitStream &out,uint32_t index)
{
out << (uint32_t)(PRC_TYPE_RI_Curve);
- ContentPRCBase(&EMPTY_ATTRIBUTES,"curve",true,makeCADID(),0,makePRCID()).write(out);
+ ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
writeGraphics(out,m1,getGraphicsIndex(),1);
out << (uint32_t)0 // index_local_coordinate_system+1
<< (uint32_t)0; // index_tessellation
@@ -180,7 +194,7 @@ void PRCcurve::writeExtraGeometryContext(PRCbitStream &out)
void PRCsurface::writeRepresentationItem(PRCbitStream &out,uint32_t index)
{
out << (uint32_t)(PRC_TYPE_RI_BrepModel);
- ContentPRCBase(&EMPTY_ATTRIBUTES,"surface",true,makeCADID(),0,makePRCID()).write(out);
+ ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
writeGraphics(out,0,getGraphicsIndex(),1);
out << (uint32_t)0 // index_local_coordinate_system+1
<< (uint32_t)0; // index_tessellation
@@ -440,7 +454,7 @@ void PRCTreeSection::writeData()
at.text = "__PRC_RESERVED_ATTRIBUTE_A3DF_ProductInformation";
Attribute attr(false,at,3,sas);
Attributes attrs(1,&attr);
- ContentPRCBase(&attrs,"Unknown",true,makeCADID(),0,makePRCID()).write(out);
+ ContentPRCBase(&attrs,"root",true,makeCADID(),0,makePRCID()).write(out);
writeGraphics(out,m1,m1,1,true);
out << (uint32_t)1 // index_part+1
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.h b/Build/source/utils/asymptote/prc/oPRCFile.h
index 1714c60492e..3dd5f856e54 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.h
+++ b/Build/source/utils/asymptote/prc/oPRCFile.h
@@ -36,6 +36,10 @@
class oPRCFile;
+enum Entity {LINE=0,CURVE,SURFACE,nEntity};
+
+std::string Name(oPRCFile *p, Entity e, std::string s);
+
struct RGBAColour
{
RGBAColour(double r=0.0, double g=0.0, double b=0.0, double a=1.0) :
@@ -67,10 +71,12 @@ struct PRCMaterial
class PRCentity
{
public:
- PRCentity(oPRCFile *p,const RGBAColour &c, double scale = 1.0) :
- colour(c), useMaterial(false), scale(scale), parent(p) {}
- PRCentity(oPRCFile *p,const PRCMaterial &m, double scale = 1.0) :
- material(m), useMaterial(true), scale(scale), parent(p) {}
+ PRCentity(oPRCFile *p,const RGBAColour &c, double scale = 1.0,
+ std::string name = "") :
+ colour(c), useMaterial(false), scale(scale), name(name), parent(p) {}
+ PRCentity(oPRCFile *p,const PRCMaterial &m, double scale = 1.0,
+ std::string name = "") :
+ material(m), useMaterial(true), scale(scale), name(name), parent(p) {}
uint32_t getGraphicsIndex();
virtual void writeRepresentationItem(PRCbitStream&,uint32_t) = 0;
virtual void writeTopologicalContext(PRCbitStream&) = 0;
@@ -79,6 +85,7 @@ class PRCentity
PRCMaterial material;
bool useMaterial;
double scale;
+ std::string name;
virtual ~PRCentity() {}
protected:
oPRCFile *parent;
@@ -91,8 +98,8 @@ class PRCsurface : public PRCentity
PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
double cP[][3], double *kU, double *kV, const RGBAColour &c,
double scale = 1.0, bool iR = false, double w[] = 0,
- double g = 0) :
- PRCentity(p,c,scale), degreeU(dU), degreeV(dV),
+ double g = 0, std::string name = "") :
+ PRCentity(p,c,scale,Name(p,SURFACE,name)), degreeU(dU), degreeV(dV),
numberOfControlPointsU(nU), numberOfControlPointsV(nV),
knotsU(kU), knotsV(kV), controlPoints(cP),
isRational(iR), weights(w), granularity(g) {}
@@ -100,8 +107,8 @@ class PRCsurface : public PRCentity
PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
double cP[][3], double *kU, double *kV, const PRCMaterial &m,
double scale = 1.0, bool iR = false, double w[] = 0,
- double g = 0) :
- PRCentity(p,m,scale), degreeU(dU), degreeV(dV),
+ double g = 0, std::string name = "") :
+ PRCentity(p,m,scale,Name(p,SURFACE,name)), degreeU(dU), degreeV(dV),
numberOfControlPointsU(nU), numberOfControlPointsV(nV),
knotsU(kU), knotsV(kV), controlPoints(cP),
isRational(iR), weights(w), granularity(g) {}
@@ -130,12 +137,12 @@ class PRCline : public PRCentity
public:
// constructor with colour
PRCline(oPRCFile *p, uint32_t n, double P[][3], const RGBAColour &c,
- double scale = 1.0) :
- PRCentity(p,c,scale), numberOfPoints(n), points(P) {}
+ double scale = 1.0, std::string name="") :
+ PRCentity(p,c,scale,Name(p,LINE,name)), numberOfPoints(n), points(P) {}
// constructor with material
PRCline(oPRCFile *p, uint32_t n, double P[][3], const PRCMaterial &m,
- double scale = 1.0) :
- PRCentity(p,m,scale), numberOfPoints(n), points(P) {}
+ double scale = 1.0, std::string name = "") :
+ PRCentity(p,m,scale,Name(p,LINE,name)), numberOfPoints(n), points(P) {}
virtual void writeRepresentationItem(PRCbitStream&,uint32_t);
virtual void writeTopologicalContext(PRCbitStream&);
virtual void writeExtraGeometryContext(PRCbitStream&);
@@ -150,15 +157,17 @@ class PRCcurve : public PRCentity
// constructor with colour
PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k,
const RGBAColour &c, double scale = 1.0, bool iR = false,
- double w[] = 0) :
- PRCentity(p,c,scale), degree(d), numberOfControlPoints(n), knots(k),
- controlPoints(cP), isRational(iR), weights(w) {}
+ double w[] = 0, std::string name="") :
+ PRCentity(p,c,scale,Name(p,CURVE,name)), degree(d),
+ numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR),
+ weights(w) {}
// constructor with material
PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k,
const PRCMaterial &m, double scale = 1.0, bool iR = false,
- double w[] = 0) :
- PRCentity(p,m,scale), degree(d), numberOfControlPoints(n), knots(k),
- controlPoints(cP), isRational(iR), weights(w) {}
+ double w[] = 0, std::string name = "") :
+ PRCentity(p,m,scale,Name(p,CURVE,name)), degree(d),
+ numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR),
+ weights(w) {}
virtual void writeRepresentationItem(PRCbitStream&,uint32_t);
virtual void writeTopologicalContext(PRCbitStream&);
virtual void writeExtraGeometryContext(PRCbitStream&);
@@ -357,12 +366,18 @@ class oPRCFile
oPRCFile(std::ostream &os, uint32_t n=1) :
number_of_file_structures(n),
fileStructures(new PRCFileStructure*[n]),modelFile(this),
- fout(NULL),output(os) {}
+ fout(NULL),output(os) {
+ for(size_t i=0; i < nEntity; ++i)
+ count[i]=0;
+ }
oPRCFile(const std::string &name, uint32_t n=1) :
number_of_file_structures(n),
fileStructures(new PRCFileStructure*[n]),modelFile(this),
- fout(new std::ofstream(name.c_str())),output(*fout) {}
+ fout(new std::ofstream(name.c_str())),output(*fout) {
+ for(size_t i=0; i < nEntity; ++i)
+ count[i]=0;
+ }
~oPRCFile()
{
@@ -373,11 +388,16 @@ class oPRCFile
delete fout;
}
+ void begingroup(std::string name) {}
+ void endgroup() {}
+
bool add(PRCentity*);
bool finish();
uint32_t getColourIndex(const RGBAColour&);
uint32_t getMaterialIndex(const PRCMaterial&);
uint32_t getSize();
+
+ uint32_t count[nEntity];
const uint32_t number_of_file_structures;
PRCFileStructure **fileStructures;