summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-14 23:14:16 +0000
committerKarl Berry <karl@freefriends.org>2010-06-14 23:14:16 +0000
commitc2175edc7aa44ca0b526f008d473d6f8a8ac4933 (patch)
treed6c491676b413ad1922481f8c3fc7b64c3afc0a5 /Build/source/utils/asymptote/prc
parent5d08e9ff4fe5fc836d237ea08e82c82b27d558a2 (diff)
asy 1.98
git-svn-id: svn://tug.org/texlive/trunk@18982 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/prc')
-rw-r--r--Build/source/utils/asymptote/prc/PRC.h1
-rw-r--r--Build/source/utils/asymptote/prc/PRCbitStream.cc5
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.cc228
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.h120
-rw-r--r--Build/source/utils/asymptote/prc/test.cc40
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.cc388
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.h421
7 files changed, 683 insertions, 520 deletions
diff --git a/Build/source/utils/asymptote/prc/PRC.h b/Build/source/utils/asymptote/prc/PRC.h
index da1aff7ef9c..eee8dcf928d 100644
--- a/Build/source/utils/asymptote/prc/PRC.h
+++ b/Build/source/utils/asymptote/prc/PRC.h
@@ -3,6 +3,7 @@
#include <stdint.h>
+//const uint32_t PRCVersion=7094; // For Adobe Reader 8 or later
const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later
// from Adobe's documentation
diff --git a/Build/source/utils/asymptote/prc/PRCbitStream.cc b/Build/source/utils/asymptote/prc/PRCbitStream.cc
index 5df27320e45..6ee4d8b45e7 100644
--- a/Build/source/utils/asymptote/prc/PRCbitStream.cc
+++ b/Build/source/utils/asymptote/prc/PRCbitStream.cc
@@ -270,6 +270,11 @@ PRCbitStream& PRCbitStream::operator <<(double value)
PRCbitStream& PRCbitStream::operator <<(const char* s)
{
+ if (s == NULL)
+ {
+ writeBit(false); // string is NULL
+ return *this;
+ }
string str(s);
*this << str;
return *this;
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.cc b/Build/source/utils/asymptote/prc/oPRCFile.cc
index 37397b1e675..bef8191d703 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.cc
+++ b/Build/source/utils/asymptote/prc/oPRCFile.cc
@@ -50,7 +50,6 @@
using std::string;
using namespace std;
-using namespace std::tr1;
void PRCCompressedSection::write(ostream &out)
{
@@ -81,12 +80,12 @@ void PRCGlobalsSection::writeData()
uint32_t i=0; // universal index for PRC standard compatibility
out << (uint32_t)PRC_TYPE_ASM_FileStructureGlobals;
- SingleAttributeData value = {PRCVersion};
- SingleAttribute sa(false,EMPTY_ATTRIBUTE_TITLE,KEPRCModellerAttributeTypeInt,value);
- AttributeTitle iv; iv.text = "__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion";
- Attribute a(false,iv,1,&sa);
- Attributes as(1,&a);
- ContentPRCBase(&as).write(out);
+ PRCSingleAttribute sa((int32_t)PRCVersion);
+ PRCAttribute a("__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion");
+ a.addKey(sa);
+ ContentPRCBase cb;
+ cb.addAttribute(a);
+ cb.serializeContentPRCBase(out);
out << numberOfReferencedFileStructures; // no referencing of file structures
out << tessellationChordHeightRatio;
out << tessellationAngleDegrees;
@@ -122,7 +121,7 @@ void PRCGlobalsSection::writeData()
out << (uint32_t)1 // number of line patterns hard coded for now
<< (uint32_t)PRC_TYPE_GRAPH_LinePattern;
- ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out);
+ ContentPRCBase("",true,makeCADID(),0,makePRCID()).serializeContentPRCBase(out);
out << (uint32_t)0 // number of lengths
<< 0.0 // phase
<< false; // is real length
@@ -146,7 +145,7 @@ void PRCTreeSection::writeData()
{
out << (uint32_t)(PRC_TYPE_ASM_FileStructureTree);
- EMPTY_CONTENTPRCBASE.write(out);
+ EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
uint32_t number_of_part_definitions = part_definitions.size();
WriteUnsignedInteger (number_of_part_definitions)
@@ -164,7 +163,7 @@ void PRCTreeSection::writeData()
// File Structure Internal Data
out << (uint32_t)(PRC_TYPE_ASM_FileStructure);
- EMPTY_CONTENTPRCBASE.write(out);
+ EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
out << makePRCID(); // next available index
out << (uint32_t)1; // product occurrence index
@@ -175,7 +174,7 @@ void PRCTessellationSection::writeData()
{
out << (uint32_t)(PRC_TYPE_ASM_FileStructureTessellation);
- EMPTY_CONTENTPRCBASE.write(out);
+ EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
const uint32_t number_of_tessellations = tessellations.size();
WriteUnsignedInteger (number_of_tessellations)
for (uint32_t i=0;i<number_of_tessellations;i++)
@@ -187,7 +186,7 @@ void PRCGeometrySection::writeData()
{
WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureGeometry)
- EMPTY_CONTENTPRCBASE.write(out);
+ EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
const uint32_t number_of_contexts = fileStructure->contexts.size();
WriteUnsignedInteger (number_of_contexts)
for (uint32_t i=0;i<number_of_contexts;i++)
@@ -200,7 +199,7 @@ void PRCExtraGeometrySection::writeData()
{
WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureExtraGeometry)
- EMPTY_CONTENTPRCBASE.write(out);
+ EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
const uint32_t number_of_contexts = fileStructure->contexts.size();
WriteUnsignedInteger (number_of_contexts)
for (uint32_t i=0;i<number_of_contexts;i++)
@@ -219,12 +218,12 @@ void PRCModelFile::writeData()
out << (uint32_t)(0); // number of schemas
out << (uint32_t)(PRC_TYPE_ASM_ModelFile);
- SingleAttributeData value = {PRCVersion};
- SingleAttribute sa(false,EMPTY_ATTRIBUTE_TITLE,KEPRCModellerAttributeTypeInt,value);
- AttributeTitle at; at.text = "__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion";
- Attribute a(false,at,1,&sa);
- Attributes as(1,&a);
- ContentPRCBase(&as,"PRC file").write(out);
+ PRCSingleAttribute sa((int32_t)PRCVersion);
+ PRCAttribute a("__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion");
+ a.addKey(sa);
+ ContentPRCBase cb("PRC file");
+ cb.addAttribute(a);
+ cb.serializeContentPRCBase(out);
writeUnit(out,true,unit); // unit is specified, and happens to come from a CAD file
@@ -410,7 +409,7 @@ uint32_t PRCHeader::getSize()
return size;
}
-void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence)
+void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence)
{
const string& name = group.name;
@@ -550,15 +549,15 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
if(!group.wires.empty())
{
- PRCTopoContext *wireContext = new PRCTopoContext;
- uint32_t context_index = addTopoContext(wireContext);
- for(PRCwireList::const_iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++)
+ PRCTopoContext *wireContext = NULL;
+ uint32_t context_index = getTopoContext(wireContext);
+ for(PRCwireList::iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++)
{
- PRCSingleWireBody *wireBody = new PRCSingleWireBody;
- const uint32_t wire_body_index = wireContext->addSingleWireBody(wireBody);
PRCWireEdge *wireEdge = new PRCWireEdge;
+ wireEdge->curve_3d = wit->curve;
+ PRCSingleWireBody *wireBody = new PRCSingleWireBody;
wireBody->setWireEdge(wireEdge);
- wireEdge->setCurve(wit->curve);
+ const uint32_t wire_body_index = wireContext->addSingleWireBody(wireBody);
PRCWire *wire = new PRCWire();
wire->index_of_line_style = wit->style;
wire->context_id = context_index;
@@ -569,7 +568,7 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
}
}
- const PRCfaceList &faces = group.faces;
+ PRCfaceList &faces = group.faces;
if(!faces.empty())
{
bool same_color = true;
@@ -580,23 +579,27 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
same_color = false;
break;
}
- PRCTopoContext *context = new PRCTopoContext;
+ PRCTopoContext *context = NULL;
+ const uint32_t context_index = getTopoContext(context);
context->granularity = group.options.granularity;
- const uint32_t context_index = addTopoContext(context);
+ // Acrobat 9 also does the following:
+ // context->tolerance = group.options.granularity;
+ // context->have_smallest_face_thickness = true;
+ // context->smallest_thickness = group.options.granularity;
PRCShell *shell = new PRCShell;
- for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++)
+ for(PRCfaceList::iterator fit=faces.begin(); fit!=faces.end(); fit++)
{
if(fit->transform || group.options.do_break ||
(fit->transparent && !group.options.no_break))
{
- PRCBrepData *body = new PRCBrepData;
- const uint32_t body_index = context->addBrepData(body);
- PRCConnex *connex = new PRCConnex;
- body->addConnex(connex);
PRCShell *shell = new PRCShell;
- connex->addShell(shell);
shell->addFace(fit->face);
+ PRCConnex *connex = new PRCConnex;
+ connex->addShell(shell);
+ PRCBrepData *body = new PRCBrepData;
+ body->addConnex(connex);
+ const uint32_t body_index = context->addBrepData(body);
PRCBrepModel *brepmodel = new PRCBrepModel();
brepmodel->index_of_line_style = fit->style;
@@ -621,11 +624,11 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
}
else
{
- PRCBrepData *body = new PRCBrepData;
- const uint32_t body_index = context->addBrepData(body);
PRCConnex *connex = new PRCConnex;
- body->addConnex(connex);
connex->addShell(shell);
+ PRCBrepData *body = new PRCBrepData;
+ body->addConnex(connex);
+ const uint32_t body_index = context->addBrepData(body);
PRCBrepModel *brepmodel = new PRCBrepModel();
if(same_color)
brepmodel->index_of_line_style = style;
@@ -636,7 +639,7 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
}
}
- const PRCcompfaceList &compfaces = group.compfaces;
+ PRCcompfaceList &compfaces = group.compfaces;
if(!compfaces.empty())
{
bool same_color = true;
@@ -647,9 +650,8 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
same_color = false;
break;
}
- PRCTopoContext *context = new PRCTopoContext;
- context->granularity = group.options.granularity;
- const uint32_t context_index = addTopoContext(context);
+ PRCTopoContext *context = NULL;
+ const uint32_t context_index = getTopoContext(context);
PRCCompressedBrepData *body = new PRCCompressedBrepData;
body->serial_tolerance=group.options.compression;
@@ -661,12 +663,12 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
(fit->transparent && !group.options.no_break))
{
PRCCompressedBrepData *body = new PRCCompressedBrepData;
- const uint32_t body_index = context->addCompressedBrepData(body);
body->face.push_back(fit->face);
body->serial_tolerance=group.options.compression;
body->brep_data_compressed_tolerance=2.8346456*
group.options.compression;
+ const uint32_t body_index = context->addCompressedBrepData(body);
PRCBrepModel *brepmodel = new PRCBrepModel();
brepmodel->index_of_line_style = fit->style;
@@ -702,7 +704,7 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
PRCProductOccurrence *product_occurrence = new PRCProductOccurrence(name);
- for(PRCgroupList::const_iterator it=group.groupList.begin(); it!=group.groupList.end(); it++)
+ for(PRCgroupList::iterator it=group.groupList.begin(); it!=group.groupList.end(); it++)
{
doGroup(*it, part_definition, product_occurrence);
}
@@ -719,6 +721,7 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
if(part_definition->representation_item.front()->index_local_coordinate_system==m1)
part_definition->representation_item.front()->index_local_coordinate_system = addTransform(group.transform);
parent_part_definition->addRepresentationItem(part_definition->representation_item.front());
+ part_definition->representation_item.clear();
delete product_occurrence;
delete part_definition;
}
@@ -729,14 +732,15 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
{
PRCSet *set = new PRCSet(name);
set->index_local_coordinate_system = addTransform(group.transform);
- for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
+ for(PRCRepresentationItemList::iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
set->addRepresentationItem(*it);
+ part_definition->representation_item.clear();
parent_part_definition->addSet(set);
delete product_occurrence;
delete part_definition;
}
// Third option - create product
- else
+ else if ( !product_occurrence->index_son_occurrence.empty() || !part_definition->representation_item.empty())
{
if (part_definition->representation_item.empty())
delete part_definition;
@@ -744,7 +748,7 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
product_occurrence->index_part = addPartDefinition(part_definition);
if (group.transform) {
product_occurrence->location = group.transform;
- product_occurrence->has_location = true;
+ group.transform = NULL;
}
if (parent_product_occurrence) {
parent_product_occurrence->index_son_occurrence.push_back(addProductOccurrence(product_occurrence));
@@ -753,6 +757,12 @@ void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_def
addProductOccurrence(product_occurrence);
}
}
+ // Last case - absolutely nothing to do
+ else
+ {
+ delete product_occurrence;
+ delete part_definition;
+ }
}
@@ -944,7 +954,7 @@ uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t siz
uint32_t PRCFileStructure::addTextureDefinition(PRCTextureDefinition *pTextureDefinition)
{
- globals.texture_definitions.push_back(PRCpTextureDefinition(pTextureDefinition));
+ globals.texture_definitions.push_back(pTextureDefinition);
return globals.texture_definitions.size()-1;
}
@@ -997,7 +1007,7 @@ uint32_t oPRCFile::addColour(const RGBAColour &colour)
return style_index;
}
-uint32_t oPRCFile::addTransform(const PRCpGeneralTransformation3d &transform)
+uint32_t oPRCFile::addTransform(PRCGeneralTransformation3d*& transform)
{
if(!transform)
return m1;
@@ -1008,6 +1018,7 @@ uint32_t oPRCFile::addTransform(const PRCpGeneralTransformation3d &transform)
coordinateSystem->axis_set = transform;
const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem);
transformMap.insert(make_pair(*transform,coordinate_system_index));
+ transform = NULL;
return coordinate_system_index;
}
@@ -1047,13 +1058,18 @@ uint32_t oPRCFile::addMaterial(const PRCmaterial &material)
bool isid(const double t[][4])
{
- return(
- t[0][0]==1 && t[0][1]==0 && t[0][2]==0 && t[0][3]==0 &&
- t[1][0]==0 && t[1][1]==1 && t[1][2]==0 && t[1][3]==0 &&
- t[2][0]==0 && t[2][1]==0 && t[2][2]==1 && t[2][3]==0 &&
- t[3][0]==0 && t[3][1]==0 && t[3][2]==0 && t[3][3]==1 );
+ return t == NULL ||
+ (t[0][0]==1 && t[0][1]==0 && t[0][2]==0 && t[0][3]==0 &&
+ t[1][0]==0 && t[1][1]==1 && t[1][2]==0 && t[1][3]==0 &&
+ t[2][0]==0 && t[2][1]==0 && t[2][2]==1 && t[2][3]==0 &&
+ t[3][0]==0 && t[3][1]==0 && t[3][2]==0 && t[3][3]==1);
+}
+bool isid(const double t[])
+{
+ return(isid((double (*)[4])t));
}
+
void oPRCFile::begingroup(const char *name, PRCoptions *options,
const double t[][4])
{
@@ -1065,7 +1081,7 @@ void oPRCFile::begingroup(const char *name, PRCoptions *options,
group.name=name;
if(options) group.options=*options;
if(t&&!isid(t))
- group.transform.reset(new PRCGeneralTransformation3d(t));
+ group.transform = new PRCGeneralTransformation3d(t);
}
void oPRCFile::endgroup()
@@ -1087,7 +1103,7 @@ PRCgroup& oPRCFile::findGroup()
group.wires.push_back(PRCwire()); \
PRCwire &wire = group.wires.back(); \
curvtype *curve = new curvtype; \
- wire.curve.reset(curve); \
+ wire.curve = curve; \
wire.style = addColour(c);
#define ADDFACE(surftype) \
@@ -1095,8 +1111,8 @@ PRCgroup& oPRCFile::findGroup()
group.faces.push_back(PRCface()); \
PRCface& face = group.faces.back(); \
surftype *surface = new surftype; \
- face.face.reset(new PRCFace); \
- face.face->setSurface(surface); \
+ face.face = new PRCFace; \
+ face.face->base_surface = surface; \
face.transparent = m.alpha < 1.0; \
face.style = addMaterial(m);
@@ -1105,7 +1121,7 @@ PRCgroup& oPRCFile::findGroup()
group.compfaces.push_back(PRCcompface()); \
PRCcompface& face = group.compfaces.back(); \
PRCCompressedFace *compface = new PRCCompressedFace; \
- face.face.reset(compface); \
+ face.face = compface; \
face.transparent = m.alpha < 1.0; \
face.style = addMaterial(m);
@@ -1288,7 +1304,7 @@ void oPRCFile::addSurface(uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
#define SETTRANSF \
if(t&&!isid(t)) \
- face.transform.reset(new PRCGeneralTransformation3d(t)); \
+ face.transform = new PRCGeneralTransformation3d(t); \
if(origin) surface->origin.Set(origin[0],origin[1],origin[2]); \
if(x_axis) surface->x_axis.Set(x_axis[0],x_axis[1],x_axis[2]); \
if(y_axis) surface->y_axis.Set(y_axis[0],y_axis[1],y_axis[2]); \
@@ -1316,7 +1332,7 @@ void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], b
center_curve->point[i].Set(cP[i][0],cP[i][1],cP[i][2]);
center_curve->interval.min = 0;
center_curve->interval.max = center_curve->point.size()-1;
- surface->setCenterCurve(center_curve);
+ surface->center_curve = center_curve;
PRCPolyLine *origin_curve = new PRCPolyLine;
origin_curve->point.resize(n);
@@ -1324,12 +1340,12 @@ void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], b
origin_curve->point[i].Set(oP[i][0],oP[i][1],oP[i][2]);
origin_curve->interval.min = 0;
origin_curve->interval.max = origin_curve->point.size()-1;
- surface->setOriginCurve(origin_curve);
+ surface->origin_curve = origin_curve;
surface->uv_domain.min.x = 0;
surface->uv_domain.max.x = 2*pi;
- surface->uv_domain.min.y = center_curve->interval.min;
- surface->uv_domain.max.y = center_curve->interval.max;
+ surface->uv_domain.min.y = 0;
+ surface->uv_domain.max.y = n-1;
}
else
{
@@ -1345,7 +1361,7 @@ void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], b
for(uint32_t i = 1; i < 3+CENTER_NUMBER_OF_POINTS; ++i)
center_curve->knot[i] = (i+2)/3; // integer division is intentional
center_curve->knot[3+CENTER_NUMBER_OF_POINTS] = (3+CENTER_NUMBER_OF_POINTS+1)/3;
- surface->setCenterCurve(center_curve);
+ surface->center_curve = center_curve;
PRCNURBSCurve *origin_curve = new PRCNURBSCurve;
origin_curve->is_rational = false;
@@ -1359,7 +1375,7 @@ void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], b
for(size_t i = 1; i < 3+ORIGIN_NUMBER_OF_POINTS; ++i)
origin_curve->knot[i] = (i+2)/3; // integer division is intentional
origin_curve->knot[3+ORIGIN_NUMBER_OF_POINTS] = (3+ORIGIN_NUMBER_OF_POINTS+1)/3;
- surface->setOriginCurve(origin_curve);
+ surface->origin_curve = origin_curve;
surface->uv_domain.min.x = 0;
surface->uv_domain.max.x = 2*pi;
@@ -1396,10 +1412,10 @@ void oPRCFile::addDisk(double radius, const PRCmaterial &m, PRCFACETRANSFORM)
SETTRANSF
PRCCircle *first_curve = new PRCCircle;
first_curve->radius = radius;
- surface->setFirstCurve(first_curve);
+ surface->first_curve = first_curve;
PRCCircle *second_curve = new PRCCircle;
second_curve->radius = 0;
- surface->setSecondCurve(second_curve);
+ surface->second_curve = second_curve;
surface->uv_domain.min.x = 0;
surface->uv_domain.max.x = 1;
@@ -1437,85 +1453,107 @@ void oPRCFile::addTorus(double major_radius, double minor_radius, double angle1,
#undef ADDWIRE
#undef SETTRANSF
-uint32_t PRCFileStructure::addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric)
+uint32_t PRCFileStructure::addMaterialGeneric(PRCMaterialGeneric*& pMaterialGeneric)
{
- globals.materials.push_back(PRCpMaterial(pMaterialGeneric));
+ globals.materials.push_back(pMaterialGeneric);
+ pMaterialGeneric = NULL;
return globals.materials.size()-1;
}
-uint32_t PRCFileStructure::addTextureApplication(PRCTextureApplication *pTextureApplication)
+uint32_t PRCFileStructure::addTextureApplication(PRCTextureApplication*& pTextureApplication)
{
- globals.materials.push_back(PRCpMaterial(pTextureApplication));
+ globals.materials.push_back(pTextureApplication);
+ pTextureApplication = NULL;
return globals.materials.size()-1;
}
-uint32_t PRCFileStructure::addStyle(PRCStyle *pStyle)
+uint32_t PRCFileStructure::addStyle(PRCStyle*& pStyle)
{
- globals.styles.push_back(PRCpStyle(pStyle));
+ globals.styles.push_back(pStyle);
+ pStyle = NULL;
return globals.styles.size()-1;
}
-uint32_t PRCFileStructure::addPartDefinition(PRCPartDefinition *pPartDefinition)
+uint32_t PRCFileStructure::addPartDefinition(PRCPartDefinition*& pPartDefinition)
{
- tree.part_definitions.push_back(PRCpPartDefinition(pPartDefinition));
+ tree.part_definitions.push_back(pPartDefinition);
+ pPartDefinition = NULL;
return tree.part_definitions.size()-1;
}
-uint32_t PRCFileStructure::addProductOccurrence(PRCProductOccurrence *pProductOccurrence)
+uint32_t PRCFileStructure::addProductOccurrence(PRCProductOccurrence*& pProductOccurrence)
{
- tree.product_occurrences.push_back(PRCpProductOccurrence(pProductOccurrence));
+ tree.product_occurrences.push_back(pProductOccurrence);
+ pProductOccurrence = NULL;
return tree.product_occurrences.size()-1;
}
-uint32_t PRCFileStructure::addTopoContext(PRCTopoContext *pTopoContext)
+uint32_t PRCFileStructure::addTopoContext(PRCTopoContext*& pTopoContext)
{
- contexts.push_back(PRCpTopoContext(pTopoContext));
+ contexts.push_back(pTopoContext);
+ pTopoContext = NULL;
return contexts.size()-1;
}
-uint32_t PRCFileStructure::add3DTess(PRC3DTess *p3DTess)
+uint32_t PRCFileStructure::getTopoContext(PRCTopoContext*& pTopoContext)
{
- tessellations.tessellations.push_back(PRCpTess(p3DTess));
+ pTopoContext = new PRCTopoContext;
+ contexts.push_back(pTopoContext);
+ return contexts.size()-1;
+}
+
+uint32_t PRCFileStructure::add3DTess(PRC3DTess*& p3DTess)
+{
+ tessellations.tessellations.push_back(p3DTess);
+ p3DTess = NULL;
return tessellations.tessellations.size()-1;
}
-uint32_t PRCFileStructure::add3DWireTess(PRC3DWireTess *p3DWireTess)
+uint32_t PRCFileStructure::add3DWireTess(PRC3DWireTess*& p3DWireTess)
{
- tessellations.tessellations.push_back(PRCpTess(p3DWireTess));
+ tessellations.tessellations.push_back(p3DWireTess);
+ p3DWireTess = NULL;
return tessellations.tessellations.size()-1;
}
/*
-uint32_t PRCFileStructure::addMarkupTess(PRCMarkupTess *pMarkupTess)
+uint32_t PRCFileStructure::addMarkupTess(PRCMarkupTess*& pMarkupTess)
{
- tessellations.tessellations.push_back(PRCpTess(pMarkupTess));
+ tessellations.tessellations.push_back(pMarkupTess);
+ pMarkupTess = NULL;
return tessellations.tessellations.size()-1;
}
-uint32_t PRCFileStructure::addMarkup(PRCMarkup *pMarkup)
+uint32_t PRCFileStructure::addMarkup(PRCMarkup*& pMarkup)
{
- tree.markups.push_back(PRCpMarkup(pMarkup));
+ tree.markups.push_back(pMarkup);
+ pMarkup = NULL;
return tree.markups.size()-1;
}
-uint32_t PRCFileStructure::addAnnotationItem(PRCAnnotationItem *pAnnotationItem)
+uint32_t PRCFileStructure::addAnnotationItem(PRCAnnotationItem*& pAnnotationItem)
{
- tree.annotation_entities.push_back(PRCpAnnotationItem(pAnnotationItem));
+ tree.annotation_entities.push_back(pAnnotationItem);
+ pAnnotationItem = NULL;
return tree.annotation_entities.size()-1;
}
*/
-uint32_t PRCFileStructure::addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem)
+uint32_t PRCFileStructure::addCoordinateSystem(PRCCoordinateSystem*& pCoordinateSystem)
{
- globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem));
+ globals.reference_coordinate_systems.push_back(pCoordinateSystem);
+ pCoordinateSystem = NULL;
return globals.reference_coordinate_systems.size()-1;
}
-uint32_t PRCFileStructure::addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem)
+uint32_t PRCFileStructure::addCoordinateSystemUnique(PRCCoordinateSystem*& pCoordinateSystem)
{
for(uint32_t i = 0; i < globals.reference_coordinate_systems.size(); ++i)
{
- if(*(globals.reference_coordinate_systems[i])==*pCoordinateSystem)
+ if(*(globals.reference_coordinate_systems[i])==*pCoordinateSystem) {
+ pCoordinateSystem = NULL;
return i;
+ }
}
- globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem));
+ globals.reference_coordinate_systems.push_back(pCoordinateSystem);
+ pCoordinateSystem = NULL;
return globals.reference_coordinate_systems.size()-1;
}
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.h b/Build/source/utils/asymptote/prc/oPRCFile.h
index 647f57c7d52..48683bf36da 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.h
+++ b/Build/source/utils/asymptote/prc/oPRCFile.h
@@ -115,30 +115,30 @@ typedef std::list<PRCtessline> PRCtesslineList;
struct PRCface
{
+ PRCface() : transform(NULL), face(NULL) {}
uint32_t style;
bool transparent;
- PRCpGeneralTransformation3d transform;
- PRCpFace face;
+ PRCGeneralTransformation3d* transform;
+ PRCFace* face;
};
-typedef std::tr1::shared_ptr <PRCface> PRCpface;
typedef std::vector <PRCface> PRCfaceList;
struct PRCcompface
{
+ PRCcompface() : face(NULL) {}
uint32_t style;
bool transparent;
- PRCpCompressedFace face;
+ PRCCompressedFace* face;
};
-typedef std::tr1::shared_ptr <PRCcompface> PRCpcompface;
typedef std::vector <PRCcompface> PRCcompfaceList;
struct PRCwire
{
+ PRCwire() : style(m1), transform(NULL), curve(NULL) {}
uint32_t style;
- PRCpGeneralTransformation3d transform;
- PRCpCurve curve;
+ PRCGeneralTransformation3d* transform;
+ PRCCurve* curve;
};
-typedef std::tr1::shared_ptr <PRCwire> PRCpwire;
typedef std::vector <PRCwire> PRCwireList;
typedef std::map <uint32_t,std::vector<PRCVector3d> > PRCpointsetMap;
@@ -163,8 +163,8 @@ public:
class PRCgroup
{
public:
- PRCgroup() {}
- PRCgroup(const std::string &name) : name(name) {}
+ PRCgroup() : transform(NULL) {}
+ PRCgroup(const std::string &name) : name(name), transform(NULL) {}
PRCfaceList faces;
PRCcompfaceList compfaces;
PRCtessrectangleList rectangles;
@@ -173,7 +173,7 @@ class PRCgroup
PRCpointsetMap points;
std::string name;
std::list<PRCgroup> groupList;
- PRCpGeneralTransformation3d transform;
+ PRCGeneralTransformation3d* transform;
PRCoptions options;
};
typedef std::list<PRCgroup> PRCgroupList;
@@ -216,6 +216,21 @@ class PRCGlobalsSection : public PRCCompressedSection
defaultFontFamilyName(""),
numberOfFillPatterns(0),
userData(0,0),index(i) {}
+ virtual ~PRCGlobalsSection() {
+ for(PRCTextureDefinitionList::iterator i = texture_definitions.begin();
+ i != texture_definitions.end(); i++)
+ delete *i;
+ for(PRCMaterialList::iterator i = materials.begin();
+ i != materials.end(); i++)
+ delete *i;
+ for(PRCStyleList::iterator i = styles.begin();
+ i != styles.end(); i++)
+ delete *i;
+ for(PRCCoordinateSystemList::iterator i =
+ reference_coordinate_systems.begin();
+ i != reference_coordinate_systems.end(); i++)
+ delete *i;
+ }
uint32_t numberOfReferencedFileStructures;
double tessellationChordHeightRatio;
double tessellationAngleDegrees;
@@ -239,6 +254,12 @@ class PRCTreeSection : public PRCCompressedSection
public:
PRCTreeSection(PRCFileStructure *fs, uint32_t i) :
PRCCompressedSection(fs),unit(1),index(i) {}
+ virtual ~PRCTreeSection()
+ {
+ for(PRCPartDefinitionList::iterator it=part_definitions.begin(); it!=part_definitions.end(); ++it) delete *it;
+ for(PRCProductOccurrenceList::iterator it=product_occurrences.begin(); it!=product_occurrences.end(); ++it) delete *it;
+ }
+
PRCPartDefinitionList part_definitions;
PRCProductOccurrenceList product_occurrences;
/*
@@ -256,6 +277,11 @@ class PRCTessellationSection : public PRCCompressedSection
public:
PRCTessellationSection(PRCFileStructure *fs, uint32_t i) :
PRCCompressedSection(fs),index(i) {}
+ virtual ~PRCTessellationSection() {
+ for(PRCTessList::iterator it=tessellations.begin();
+ it!=tessellations.end(); ++it)
+ delete *it;
+ }
PRCTessList tessellations;
private:
uint32_t index;
@@ -267,6 +293,7 @@ class PRCGeometrySection : public PRCCompressedSection
public:
PRCGeometrySection(PRCFileStructure *fs, uint32_t i) :
PRCCompressedSection(fs),index(i) {}
+ virtual ~PRCGeometrySection() {}
private:
uint32_t index;
virtual void writeData();
@@ -277,6 +304,7 @@ class PRCExtraGeometrySection : public PRCCompressedSection
public:
PRCExtraGeometrySection(PRCFileStructure *fs, uint32_t i) :
PRCCompressedSection(fs),index(i) {}
+ virtual ~PRCExtraGeometrySection() {}
private:
uint32_t index;
virtual void writeData();
@@ -287,6 +315,7 @@ class PRCModelFile : public PRCCompressedSection
public:
PRCModelFile(oPRCFile *p) : PRCCompressedSection(p), unit(1) {}
double unit;
+ virtual ~PRCModelFile() {}
private:
virtual void writeData();
};
@@ -333,6 +362,12 @@ class PRCFileStructure
std::list<PRCUncompressedFile> uncompressedFiles;
PRCTopoContextList contexts;
+ ~PRCFileStructure () {
+ for(PRCTopoContextList::iterator i = contexts.begin();
+ i != contexts.end(); i++)
+ delete *i;
+ }
+
PRCGlobalsSection globals;
PRCTreeSection tree;
PRCTessellationSection tessellations;
@@ -349,21 +384,22 @@ class PRCFileStructure
uint32_t addTextureDefinition(PRCTextureDefinition *pTextureDefinition);
uint32_t addRgbColor(const PRCRgbColor &color);
uint32_t addRgbColorUnique(const PRCRgbColor &color);
- uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric);
- uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication);
- uint32_t addStyle(PRCStyle *pStyle);
- uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition);
- uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence);
- uint32_t addTopoContext(PRCTopoContext *pTopoContext);
- uint32_t add3DTess(PRC3DTess *p3DTess);
- uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess);
+ uint32_t addMaterialGeneric(PRCMaterialGeneric*& pMaterialGeneric);
+ uint32_t addTextureApplication(PRCTextureApplication*& pTextureApplication);
+ uint32_t addStyle(PRCStyle*& pStyle);
+ uint32_t addPartDefinition(PRCPartDefinition*& pPartDefinition);
+ uint32_t addProductOccurrence(PRCProductOccurrence*& pProductOccurrence);
+ uint32_t addTopoContext(PRCTopoContext*& pTopoContext);
+ uint32_t getTopoContext(PRCTopoContext*& pTopoContext);
+ uint32_t add3DTess(PRC3DTess*& p3DTess);
+ uint32_t add3DWireTess(PRC3DWireTess*& p3DWireTess);
/*
- uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess);
- uint32_t addMarkup(PRCMarkup *pMarkup);
- uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem);
+ uint32_t addMarkupTess(PRCMarkupTess*& pMarkupTess);
+ uint32_t addMarkup(PRCMarkup*& pMarkup);
+ uint32_t addAnnotationItem(PRCAnnotationItem*& pAnnotationItem);
*/
- uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem);
- uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem);
+ uint32_t addCoordinateSystem(PRCCoordinateSystem*& pCoordinateSystem);
+ uint32_t addCoordinateSystemUnique(PRCCoordinateSystem*& pCoordinateSystem);
};
class PRCFileStructureInformation
@@ -461,11 +497,11 @@ class oPRCFile
PRCtransformMap transformMap;
std::stack<PRCgroupList::iterator> currentGroups;
PRCgroup& findGroup();
- void doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence);
+ void doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence);
uint32_t addColor(const PRCRgbColor &color);
uint32_t addColour(const RGBAColour &colour);
uint32_t addMaterial(const PRCmaterial &material);
- uint32_t addTransform(const PRCpGeneralTransformation3d &transform);
+ uint32_t addTransform(PRCGeneralTransformation3d*& transform);
void addPoint(const double P[3], const RGBAColour &c);
void addLine(uint32_t n, const double P[][3], const RGBAColour &c);
void addBezierCurve(uint32_t n, const double cP[][3], const RGBAColour &c);
@@ -488,11 +524,11 @@ class oPRCFile
uint32_t addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *picture, uint32_t width=0, uint32_t height=0,
std::string name="", uint32_t fileStructure=0)
{ return fileStructures[fileStructure]->addPicture(format, size, picture, width, height, name); }
- uint32_t addTextureDefinition(PRCTextureDefinition *pTextureDefinition, uint32_t fileStructure=0)
+ uint32_t addTextureDefinition(PRCTextureDefinition*& pTextureDefinition, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addTextureDefinition(pTextureDefinition);
}
- uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication, uint32_t fileStructure=0)
+ uint32_t addTextureApplication(PRCTextureApplication*& pTextureApplication, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addTextureApplication(pTextureApplication);
}
@@ -506,54 +542,58 @@ class oPRCFile
{
return fileStructures[fileStructure]->addRgbColorUnique(color);
}
- uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric,
+ uint32_t addMaterialGeneric(PRCMaterialGeneric*& pMaterialGeneric,
uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addMaterialGeneric(pMaterialGeneric);
}
- uint32_t addStyle(PRCStyle *pStyle, uint32_t fileStructure=0)
+ uint32_t addStyle(PRCStyle*& pStyle, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addStyle(pStyle);
}
- uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition, uint32_t fileStructure=0)
+ uint32_t addPartDefinition(PRCPartDefinition*& pPartDefinition, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addPartDefinition(pPartDefinition);
}
- uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence, uint32_t fileStructure=0)
+ uint32_t addProductOccurrence(PRCProductOccurrence*& pProductOccurrence, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addProductOccurrence(pProductOccurrence);
}
- uint32_t addTopoContext(PRCTopoContext *pTopoContext, uint32_t fileStructure=0)
+ uint32_t addTopoContext(PRCTopoContext*& pTopoContext, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addTopoContext(pTopoContext);
}
- uint32_t add3DTess(PRC3DTess *p3DTess, uint32_t fileStructure=0)
+ uint32_t getTopoContext(PRCTopoContext*& pTopoContext, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->getTopoContext(pTopoContext);
+ }
+ uint32_t add3DTess(PRC3DTess*& p3DTess, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->add3DTess(p3DTess);
}
- uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess, uint32_t fileStructure=0)
+ uint32_t add3DWireTess(PRC3DWireTess*& p3DWireTess, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->add3DWireTess(p3DWireTess);
}
/*
- uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess, uint32_t fileStructure=0)
+ uint32_t addMarkupTess(PRCMarkupTess*& pMarkupTess, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addMarkupTess(pMarkupTess);
}
- uint32_t addMarkup(PRCMarkup *pMarkup, uint32_t fileStructure=0)
+ uint32_t addMarkup(PRCMarkup*& pMarkup, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addMarkup(pMarkup);
}
- uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem, uint32_t fileStructure=0)
+ uint32_t addAnnotationItem(PRCAnnotationItem*& pAnnotationItem, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addAnnotationItem(pAnnotationItem);
}
*/
- uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0)
+ uint32_t addCoordinateSystem(PRCCoordinateSystem*& pCoordinateSystem, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addCoordinateSystem(pCoordinateSystem);
}
- uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0)
+ uint32_t addCoordinateSystemUnique(PRCCoordinateSystem*& pCoordinateSystem, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addCoordinateSystemUnique(pCoordinateSystem);
}
diff --git a/Build/source/utils/asymptote/prc/test.cc b/Build/source/utils/asymptote/prc/test.cc
index 4b0cadfc8a8..98a6c226c43 100644
--- a/Build/source/utils/asymptote/prc/test.cc
+++ b/Build/source/utils/asymptote/prc/test.cc
@@ -27,6 +27,8 @@
using namespace std;
+extern const double pi;
+
int main()
{
oPRCFile file("test.prc");
@@ -296,8 +298,8 @@ if(1) {
double points[NUMBER_OF_POINTS][3];
for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
{
- points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
- points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
+ points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*pi);
+ points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*pi);
points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0;
}
const size_t NUMBER_OF_WIRES = 2;
@@ -472,21 +474,21 @@ if(1) {
PRCFace *face = new PRCFace;
shell->addFace(face,2);
PRCRuled *surface = new PRCRuled;
- face->setSurface(surface);
+ face->base_surface=surface;
PRCCircle *first_curve = new PRCCircle;
first_curve->radius = 1;
- surface->setFirstCurve(first_curve);
+ surface->first_curve=first_curve;
PRCCircle *second_curve = new PRCCircle;
second_curve->radius = 0;
- surface->setSecondCurve(second_curve);
+ surface->second_curve=second_curve;
surface->uv_domain.min.x = 0;
surface->uv_domain.max.x = 1;
surface->uv_domain.min.y = 0;
- surface->uv_domain.max.y = 2*M_PI;
+ surface->uv_domain.max.y = 2*pi;
surface->parameterization_on_v_coeff_a = -1;
- surface->parameterization_on_v_coeff_b = 2*M_PI;
+ surface->parameterization_on_v_coeff_b = 2*pi;
surface->has_transformation = true;
surface->geometry_is_2D = false;
@@ -573,8 +575,8 @@ if(1) {
qoints[3][0] = 0; qoints[3][1] = 0; qoints[3][2] = 1;
// for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
// {
-// points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
-// points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
+// points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*pi);
+// points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*pi);
// points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0;
// }
@@ -598,7 +600,7 @@ if(1) {
PRCFace *face = new PRCFace;
shell->addFace(face);
PRCBlend01 *surface = new PRCBlend01;
- face->setSurface(surface);
+ face->base_surface=surface;
PRCNURBSCurve *center_curve = new PRCNURBSCurve;
center_curve->is_rational = false;
@@ -607,7 +609,7 @@ if(1) {
center_curve->control_point.push_back(PRCControlPoint(points[i][0]+0.0,points[i][1],points[i][2]));
for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
center_curve->knot.push_back(knots[i]);
- surface->setCenterCurve(center_curve);
+ surface->center_curve=center_curve;
PRCNURBSCurve *origin_curve = new PRCNURBSCurve;
origin_curve->is_rational = false;
@@ -616,10 +618,10 @@ if(1) {
origin_curve->control_point.push_back(PRCControlPoint(points[i][0]*1.01+0.0,points[i][1]*1.01,points[i][2]));
for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
origin_curve->knot.push_back(knots[i]);
- surface->setOriginCurve(origin_curve);
+ surface->origin_curve=origin_curve;
surface->uv_domain.min.x = 0;
- surface->uv_domain.max.x = 2*M_PI;
+ surface->uv_domain.max.x = 2*pi;
surface->uv_domain.min.y = 1; // first knot
surface->uv_domain.max.y = 2; // last knot
PRCBrepModel *brepmodel = new PRCBrepModel("Tube");
@@ -671,7 +673,7 @@ if(1) {
uint32_t Origin_curve_body_index = tubeContext->addSingleWireBody(OriginCurveBody);
PRCWireEdge *OriginCurveEdge = new PRCWireEdge;
OriginCurveBody->setWireEdge(OriginCurveEdge);
- OriginCurveEdge->setCurve(Origin_curve);
+// OriginCurveEdge->origin_curve=Origin_curve;
PRCWire *OriginCurveWire = new PRCWire("OriginCurveWire");
OriginCurveWire->index_of_line_style = 0;
OriginCurveWire->context_id = context_index;
@@ -682,7 +684,7 @@ if(1) {
uint32_t Center_curve_body_index = tubeContext->addSingleWireBody(CenterCurveBody);
PRCWireEdge *CenterCurveEdge = new PRCWireEdge;
CenterCurveBody->setWireEdge(CenterCurveEdge);
- CenterCurveEdge->setCurve(Center_curve);
+// CenterCurveEdge->setCurve(Center_curve);
PRCWire *CenterCurveWire = new PRCWire("CenterCurveWire");
CenterCurveWire->index_of_line_style = 0;
CenterCurveWire->context_id = context_index;
@@ -702,7 +704,7 @@ if(1) {
uint32_t compositeCenter_curve_body_index = tubeContext->addSingleWireBody(compositeCenterCurveBody);
PRCWireEdge *compositeCenterCurveEdge = new PRCWireEdge;
compositeCenterCurveBody->setWireEdge(compositeCenterCurveEdge);
- compositeCenterCurveEdge->setCurve(compositeCenter_curve);
+// compositeCenterCurveEdge->setCurve(compositeCenter_curve);
PRCWire *compositeCenterCurveWire = new PRCWire("compositeCenterCurveWire");
compositeCenterCurveWire->index_of_line_style = 0;
compositeCenterCurveWire->context_id = context_index;
@@ -722,7 +724,7 @@ if(1) {
uint32_t compositeOrigin_curve_body_index = tubeContext->addSingleWireBody(compositeOriginCurveBody);
PRCWireEdge *compositeOriginCurveEdge = new PRCWireEdge;
compositeOriginCurveBody->setWireEdge(compositeOriginCurveEdge);
- compositeOriginCurveEdge->setCurve(compositeOrigin_curve);
+// compositeOriginCurveEdge->setCurve(compositeOrigin_curve);
PRCWire *compositeOriginCurveWire = new PRCWire("compositeOriginCurveWire");
compositeOriginCurveWire->index_of_line_style = 0;
compositeOriginCurveWire->context_id = context_index;
@@ -738,10 +740,10 @@ if(1) {
PRCFace *cface = new PRCFace;
cshell->addFace(cface);
PRCBlend01 *csurface = new PRCBlend01;
- cface->setSurface(csurface);
+ cface->base_surface=csurface;
csurface->uv_domain.min.x = 0;
- csurface->uv_domain.max.x = 2*M_PI;
+ csurface->uv_domain.max.x = 2*pi;
csurface->uv_domain.min.y = 0; // first knot
csurface->uv_domain.max.y = 2; // last knot
csurface->center_curve = compositeCenterCurveEdge->curve_3d;
diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc
index eb7141d3315..1f3175053fc 100644
--- a/Build/source/utils/asymptote/prc/writePRC.cc
+++ b/Build/source/utils/asymptote/prc/writePRC.cc
@@ -31,6 +31,85 @@
using namespace std;
+// Count leading zeros.
+uint32_t CLZ(uint32_t a)
+{
+#ifdef __GNUC__
+ return __builtin_clz(a);
+#else
+// find the log base 2 of a 32-bit integer
+ static const int MultiplyDeBruijnBitPosition[32] = {
+ 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
+ 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
+ };
+
+ a |= a >> 1; // first round down to one less than a power of 2
+ a |= a >> 2;
+ a |= a >> 4;
+ a |= a >> 8;
+ a |= a >> 16;
+
+ return 31-MultiplyDeBruijnBitPosition[(unsignedInt)(a * 0x07C4ACDDU) >> 27];
+#endif
+}
+
+// Portable integer implementation of ceil(log2(x)).
+uint32_t Log2(uint32_t x)
+{
+ assert(x != 0);
+ uint32_t L=31-CLZ(x);
+ return ((uint32_t) 1 << L == x) ? L : L+1;
+}
+
+#define WriteUnsignedInteger( value ) pbs << (uint32_t)(value);
+#define WriteInteger( value ) pbs << (int32_t)(value);
+#define WriteCharacter( value ) pbs << (uint8_t)(value);
+#define WriteDouble( value ) pbs << (double)(value);
+#define WriteBit( value ) pbs << (bool)(value);
+#define WriteBoolean( value ) pbs << (bool)(value);
+#define WriteString( value ) pbs << (value);
+#define SerializeContentPRCBase serializeContentPRCBase(pbs);
+#define SerializeGraphics serializeGraphics(pbs);
+#define SerializePRCBaseWithGraphics { serializeContentPRCBase(pbs); serializeGraphics(pbs); }
+#define SerializeRepresentationItemContent serializeRepresentationItemContent(pbs);
+#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(pbs);
+#define SerializeMarkup( value ) (value).serializeMarkup(pbs);
+#define SerializeReferenceUniqueIdentifier( value ) (value).serializeReferenceUniqueIdentifier(pbs);
+#define SerializeContentBaseTessData serializeContentBaseTessData(pbs);
+#define SerializeTessFace( value ) (value)->serializeTessFace(pbs);
+#define SerializeUserData UserData(0,0).write(pbs);
+#define SerializeLineAttr( value ) pbs << (uint32_t)((value)+1);
+#define SerializeVector3d( value ) (value).serializeVector3d(pbs);
+#define SerializeVector2d( value ) (value).serializeVector2d(pbs);
+#define SerializeName( value ) writeName(pbs, (value));
+#define SerializeInterval( value ) (value).serializeInterval(pbs);
+// #define SerializeBoundingBox( value ) (value).serializeBoundingBox(pbs);
+#define SerializeDomain( value ) (value).serializeDomain(pbs);
+#define SerializeParameterization serializeParameterization(pbs);
+#define SerializeUVParameterization serializeUVParameterization(pbs);
+#define SerializeTransformation serializeTransformation(pbs);
+#define SerializeBaseTopology serializeBaseTopology(pbs);
+#define SerializeBaseGeometry serializeBaseGeometry(pbs);
+#define SerializePtrCurve( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeCurve(pbs);}
+#define SerializePtrSurface( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeSurface(pbs);}
+#define SerializePtrTopology( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeTopoItem(pbs);}
+#define SerializeContentCurve serializeContentCurve(pbs);
+#define SerializeContentWireEdge serializeContentWireEdge(pbs);
+#define SerializeContentBody serializeContentBody(pbs);
+#define SerializeTopoContext serializeTopoContext(pbs);
+#define SerializeContextAndBodies( value ) (value).serializeContextAndBodies(pbs);
+#define SerializeBody( value ) (value)->serializeBody(pbs);
+#define ResetCurrentGraphics resetGraphics();
+#define SerializeContentSurface serializeContentSurface(pbs);
+#define SerializeCompressedUniqueId( value ) (value).serializeCompressedUniqueId(pbs);
+#define SerializeUnit( value ) (value).serializeUnit(pbs);
+#define SerializeBoundingBox serializeBoundingBox(pbs);
+#define SerializeAttributeEntry serializeAttributeEntry(pbs);
+#define SerializeContentSingleAttribute( value ) (value).serializeSingleAttribute(pbs);
+#define SerializeAttribute( value ) (value).serializeAttribute(pbs);
+#define SerializeAttributeData serializeAttributes(pbs);
+
+
double PRCVector3d::Length()
{
return sqrt(x*x+y*y+z*z);
@@ -60,111 +139,77 @@ void UserData::write(PRCbitStream &pbs)
}
}
-void SingleAttribute::write(PRCbitStream &pbs)
+void PRCAttributeEntry::serializeAttributeEntry(PRCbitStream &pbs) const
{
- pbs << titleIsInteger;
- if(titleIsInteger)
- pbs << title.integer;
- else
- pbs << title.text;
- pbs << type;
- switch(type)
+ WriteBoolean (title_is_integer)
+ if (title_is_integer)
+ WriteUnsignedInteger (title_integer)
+ else
+ WriteString (title_text)
+}
+
+void PRCSingleAttribute::serializeSingleAttribute(PRCbitStream &pbs) const
+{
+ SerializeAttributeEntry
+ WriteUnsignedInteger (type)
+ switch (type)
{
case KEPRCModellerAttributeTypeInt:
- pbs << data.integer;
+ WriteInteger (value.integer)
break;
case KEPRCModellerAttributeTypeReal:
- pbs << data.real;
+ WriteDouble (value.real)
break;
case KEPRCModellerAttributeTypeTime:
- pbs << data.time;
+ WriteUnsignedInteger (value.time)
break;
case KEPRCModellerAttributeTypeString:
- pbs << data.text;
- break;
+ WriteString (value_text)
+ break;
default:
break;
}
}
-void Attribute::write(PRCbitStream &pbs)
+void PRCAttribute::serializeAttribute(PRCbitStream &pbs) const
{
- pbs << (uint32_t)PRC_TYPE_MISC_Attribute;
- pbs << titleIsInteger;
- if(titleIsInteger)
- pbs << title.integer;
- else
- pbs << title.text;
- pbs << sizeOfAttributeKeys;
- for(uint32_t i = 0; i < sizeOfAttributeKeys; ++i)
- {
- singleAttributes[i].write(pbs);
- }
+ WriteUnsignedInteger (PRC_TYPE_MISC_Attribute)
+
+ SerializeAttributeEntry
+ const uint32_t size_of_attribute_keys = attribute_keys.size();
+ WriteUnsignedInteger (size_of_attribute_keys)
+ for(uint32_t i=0;i<size_of_attribute_keys;i++)
+ SerializeContentSingleAttribute (attribute_keys[i])
}
-void Attributes::write(PRCbitStream &pbs)
+void PRCAttributes::serializeAttributes(PRCbitStream &pbs) const
{
- pbs << numberOfAttributes;
- for(uint32_t i = 0; i < numberOfAttributes; ++i)
+ if (attributes.empty()) { // shortcut for most typical case
+ const uint32_t number_of_attributes = 0;
+ WriteUnsignedInteger (number_of_attributes)
+ return;
+ }
+ const uint32_t number_of_attributes = attributes.size();
+ WriteUnsignedInteger (number_of_attributes)
+ for(PRCAttributeList::const_iterator it = attributes.begin(); it != attributes.end(); ++it)
{
- attributes[i].write(pbs);
+ SerializeAttribute(*it)
}
}
-void ContentPRCBase::write(PRCbitStream &pbs)
+void ContentPRCBase::serializeContentPRCBase(PRCbitStream &pbs)
{
- attributes->write(pbs);
- writeName(pbs,name);
- if(eligibleForReference)
+ SerializeAttributeData
+
+ SerializeName (name)
+ if (type_eligible_for_reference)
{
- pbs << CADID << CADPersistentID << PRCID;
+ WriteUnsignedInteger (CAD_identifier)
+ WriteUnsignedInteger (CAD_persistent_identifier)
+ WriteUnsignedInteger (PRC_unique_identifier)
}
}
-#define WriteUnsignedInteger( value ) pbs << (uint32_t)(value);
-#define WriteInteger( value ) pbs << (int32_t)(value);
-#define WriteCharacter( value ) pbs << (uint8_t)(value);
-#define WriteDouble( value ) pbs << (double)(value);
-#define WriteBit( value ) pbs << (bool)(value);
-#define WriteBoolean( value ) pbs << (bool)(value);
-#define WriteString( value ) pbs << (value);
-#define SerializeContentPRCBase write(pbs);
-#define SerializeGraphics serializeGraphics(pbs);
-#define SerializePRCBaseWithGraphics { write(pbs); serializeGraphics(pbs); }
-#define SerializeRepresentationItemContent serializeRepresentationItemContent(pbs);
-#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(pbs);
-#define SerializeMarkup( value ) (value).serializeMarkup(pbs);
-#define SerializeReferenceUniqueIdentifier( value ) (value).serializeReferenceUniqueIdentifier(pbs);
-#define SerializeContentBaseTessData serializeContentBaseTessData(pbs);
-#define SerializeTessFace( value ) (value)->serializeTessFace(pbs);
-#define SerializeUserData UserData(0,0).write(pbs);
-#define SerializeLineAttr( value ) pbs << (uint32_t)((value)+1);
-#define SerializeVector3d( value ) (value).serializeVector3d(pbs);
-#define SerializeVector2d( value ) (value).serializeVector2d(pbs);
-#define SerializeName( value ) writeName(pbs, (value));
-#define SerializeInterval( value ) (value).serializeInterval(pbs);
-// #define SerializeBoundingBox( value ) (value).serializeBoundingBox(pbs);
-#define SerializeDomain( value ) (value).serializeDomain(pbs);
-#define SerializeParameterization serializeParameterization(pbs);
-#define SerializeUVParameterization serializeUVParameterization(pbs);
-#define SerializeTransformation serializeTransformation(pbs);
-#define SerializeAttributeData if(attributes) attributes->write(pbs); else WriteUnsignedInteger (0)
-#define SerializeBaseTopology serializeBaseTopology(pbs);
-#define SerializeBaseGeometry serializeBaseGeometry(pbs);
-#define SerializePtrCurve( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeCurve(pbs);}
-#define SerializePtrSurface( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeSurface(pbs);}
-#define SerializePtrTopology( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeTopoItem(pbs);}
-#define SerializeContentCurve serializeContentCurve(pbs);
-#define SerializeContentWireEdge serializeContentWireEdge(pbs);
-#define SerializeContentBody serializeContentBody(pbs);
-#define SerializeTopoContext serializeTopoContext(pbs);
-#define SerializeContextAndBodies( value ) (value).serializeContextAndBodies(pbs);
-#define SerializeBody( value ) (value)->serializeBody(pbs);
-#define ResetCurrentGraphics resetGraphics();
-#define SerializeContentSurface serializeContentSurface(pbs);
-#define SerializeCompressedUniqueId( value ) (value).serializeCompressedUniqueId(pbs);
-#define SerializeUnit( value ) (value).serializeUnit(pbs);
-#define SerializeBoundingBox serializeBoundingBox(pbs);
bool IsCompressedType(uint32_t type)
{
@@ -341,10 +386,7 @@ void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
WriteCharacter (additional_3)
}
-AttributeTitle EMPTY_ATTRIBUTE_TITLE = {(char*)""};
-Attribute EMPTY_ATTRIBUTE(false,EMPTY_ATTRIBUTE_TITLE,0,NULL);
-Attributes EMPTY_ATTRIBUTES(0,0);
-ContentPRCBase EMPTY_CONTENTPRCBASE(&EMPTY_ATTRIBUTES);
+ContentPRCBase EMPTY_CONTENTPRCBASE;
std::string currentName;
void writeName(PRCbitStream &pbs,const std::string &name)
@@ -531,51 +573,52 @@ void PRCSet::serializeSet(PRCbitStream &pbs)
SerializeUserData
}
-uint32_t PRCSet::addBrepModel(PRCBrepModel *pBrepModel)
-{
- elements.push_back(PRCpRepresentationItem(pBrepModel));
- return elements.size()-1;
-}
-
-uint32_t PRCSet::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel)
+uint32_t PRCSet::addBrepModel(PRCBrepModel*& pBrepModel)
{
- elements.push_back(PRCpRepresentationItem(pPolyBrepModel));
+ elements.push_back(pBrepModel);
+ pBrepModel = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addPointSet(PRCPointSet *pPointSet)
+uint32_t PRCSet::addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel)
{
- elements.push_back(PRCpRepresentationItem(pPointSet));
+ elements.push_back(pPolyBrepModel);
+ pPolyBrepModel = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addSet(PRCSet *pSet)
+uint32_t PRCSet::addPointSet(PRCPointSet*& pPointSet)
{
- elements.push_back(PRCpRepresentationItem(pSet));
+ elements.push_back(pPointSet);
+ pPointSet = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addWire(PRCWire *pWire)
+uint32_t PRCSet::addSet(PRCSet*& pSet)
{
- elements.push_back(PRCpRepresentationItem(pWire));
+ elements.push_back(pSet);
+ pSet = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addPolyWire(PRCPolyWire *pPolyWire)
+uint32_t PRCSet::addWire(PRCWire*& pWire)
{
- elements.push_back(PRCpRepresentationItem(pPolyWire));
+ elements.push_back(pWire);
+ pWire = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addRepresentationItem(PRCRepresentationItem *pRepresentationItem)
+uint32_t PRCSet::addPolyWire(PRCPolyWire*& pPolyWire)
{
- elements.push_back(PRCpRepresentationItem(pRepresentationItem));
+ elements.push_back(pPolyWire);
+ pPolyWire = NULL;
return elements.size()-1;
}
-uint32_t PRCSet::addRepresentationItem(PRCpRepresentationItem pRepresentationItem)
+uint32_t PRCSet::addRepresentationItem(PRCRepresentationItem*& pRepresentationItem)
{
elements.push_back(pRepresentationItem);
+ pRepresentationItem = NULL;
return elements.size()-1;
}
@@ -850,9 +893,10 @@ void PRC3DTess::serialize3DTess(PRCbitStream &pbs)
WriteDouble (texture_coordinate[i])
}
-void PRC3DTess::addTessFace(PRCTessFace *pTessFace)
+void PRC3DTess::addTessFace(PRCTessFace*& pTessFace)
{
- face_tessellation.push_back(PRCpTessFace(pTessFace));
+ face_tessellation.push_back(pTessFace);
+ pTessFace = NULL;
}
void PRC3DWireTess::serialize3DWireTess(PRCbitStream &pbs)
@@ -1205,13 +1249,13 @@ void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep
const uint32_t number_of_knots_in_u = 4; // 0011 or 00001111 knot vector - just 2 spans
WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_u - 2, 16)
- uint32_t number_bit = degree_in_u ? ceil( log2( degree_in_u + 2 ) ) : 2;
+ uint32_t number_bit = degree_in_u ? Log2( degree_in_u + 2 ) : 2;
WriteBoolean (false) // Multiplicity_is_already_stored - no
WriteUnsignedIntegerWithVariableBitNumber( degree_in_u+1,number_bit)
WriteBoolean (true) // Multiplicity_is_already_stored - yes
const uint32_t number_of_knots_in_v = 4; // 0011 or 00001111 knot vector - just 2 spans
WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_v - 2, 16)
- number_bit = degree_in_v ? ceil( log2( degree_in_v + 2 ) ) : 2;
+ number_bit = degree_in_v ? Log2( degree_in_v + 2 ) : 2;
WriteBoolean (false) // Multiplicity_is_already_stored - no
WriteUnsignedIntegerWithVariableBitNumber( degree_in_v+1,number_bit)
WriteBoolean (true) // Multiplicity_is_already_stored - yes
@@ -1499,15 +1543,10 @@ void PRCShell::serializeShell(PRCbitStream &pbs)
}
}
-void PRCShell::addFace(PRCFace *pFace, uint8_t orientation)
-{
- face.push_back(PRCpFace(pFace));
- orientation_surface_with_shell.push_back(orientation);
-}
-
-void PRCShell::addFace(const PRCpFace &pFace, uint8_t orientation)
+void PRCShell::addFace(PRCFace*& pFace, uint8_t orientation)
{
face.push_back(pFace);
+ pFace = NULL;
orientation_surface_with_shell.push_back(orientation);
}
@@ -1525,9 +1564,10 @@ void PRCConnex::serializeConnex(PRCbitStream &pbs)
}
}
-void PRCConnex::addShell(PRCShell *pShell)
+void PRCConnex::addShell(PRCShell*& pShell)
{
- shell.push_back(PRCpShell(pShell));
+ shell.push_back(pShell);
+ pShell = NULL;
}
#define have_bbox( behavior ) (behavior!=0)
@@ -1548,9 +1588,10 @@ void PRCBrepData::serializeBrepData(PRCbitStream &pbs)
}
#undef have_bbox
-void PRCBrepData::addConnex(PRCConnex *pConnex)
+void PRCBrepData::addConnex(PRCConnex*& pConnex)
{
- connex.push_back(PRCpConnex(pConnex));
+ connex.push_back(pConnex);
+ pConnex = NULL;
}
void PRCContentWireEdge::serializeContentWireEdge(PRCbitStream &pbs)
@@ -1699,9 +1740,9 @@ void PRCTopoContext::serializeContextGraphics(PRCbitStream &pbs)
bool has_graphics = false;
for (i=0;i<number_of_body;i++)
{
- if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepData && dynamic_cast<PRCBrepData*>(body[i].get()))
+ if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepData && dynamic_cast<PRCBrepData*>(body[i]))
{
- PRCBrepData *body_i = dynamic_cast<PRCBrepData*>(body[i].get());
+ PRCBrepData *body_i = dynamic_cast<PRCBrepData*>(body[i]);
for (j=0;j<body_i->connex.size();j++)
{
for(k=0;k<body_i->connex[j]->shell.size();k++)
@@ -1714,9 +1755,9 @@ void PRCTopoContext::serializeContextGraphics(PRCbitStream &pbs)
}
}
}
- else if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepDataCompress && dynamic_cast<PRCCompressedBrepData*>(body[i].get()))
+ else if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepDataCompress && dynamic_cast<PRCCompressedBrepData*>(body[i]))
{
- PRCCompressedBrepData *body_i = dynamic_cast<PRCCompressedBrepData*>(body[i].get());
+ PRCCompressedBrepData *body_i = dynamic_cast<PRCCompressedBrepData*>(body[i]);
for( l=0;l<body_i->face.size();l++)
{
element.push_back( body_i->face[l] );
@@ -1745,29 +1786,27 @@ void PRCTopoContext::serializeContextGraphics(PRCbitStream &pbs)
}
}
-uint32_t PRCTopoContext::addSingleWireBody(PRCSingleWireBody *pSingleWireBody)
+uint32_t PRCTopoContext::addSingleWireBody(PRCSingleWireBody*& pSingleWireBody)
{
- body.push_back(PRCpBody(pSingleWireBody));
+ body.push_back(pSingleWireBody);
+ pSingleWireBody = NULL;
return body.size()-1;
}
-uint32_t PRCTopoContext::addBrepData(PRCBrepData *pBrepData)
+uint32_t PRCTopoContext::addBrepData(PRCBrepData*& pBrepData)
{
- body.push_back(PRCpBody(pBrepData));
+ body.push_back(pBrepData);
+ pBrepData = NULL;
return body.size()-1;
}
-uint32_t PRCTopoContext::addCompressedBrepData(PRCCompressedBrepData *pCompressedBrepData)
+uint32_t PRCTopoContext::addCompressedBrepData(PRCCompressedBrepData*& pCompressedBrepData)
{
- body.push_back(PRCpBody(pCompressedBrepData));
+ body.push_back(pCompressedBrepData);
+ pCompressedBrepData = NULL;
return body.size()-1;
}
-void PRCSingleWireBody::setWireEdge(PRCWireEdge *wireEdge)
-{
- wire_edge.reset(wireEdge);
-}
-
void PRCSingleWireBody::serializeSingleWireBody(PRCbitStream &pbs)
{
WriteUnsignedInteger ( PRC_TYPE_TOPO_SingleWireBody)
@@ -1824,6 +1863,7 @@ void PRCProductOccurrence::serializeProductOccurrence(PRCbitStream &pbs)
WriteCharacter (product_information_flags)
WriteInteger (product_load_status)
+ const bool has_location = location != NULL;
WriteBit (has_location)
if (has_location)
location->serializeTransformation3d (pbs);
@@ -1845,73 +1885,73 @@ void PRCProductOccurrence::serializeProductOccurrence(PRCbitStream &pbs)
SerializeUserData
}
-uint32_t PRCPartDefinition::addBrepModel(PRCBrepModel *pBrepModel)
-{
- representation_item.push_back(PRCpRepresentationItem(pBrepModel));
- return representation_item.size()-1;
-}
-
-uint32_t PRCPartDefinition::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel)
+uint32_t PRCPartDefinition::addBrepModel(PRCBrepModel*& pBrepModel)
{
- representation_item.push_back(PRCpRepresentationItem(pPolyBrepModel));
- return representation_item.size()-1;
+ representation_item.push_back(pBrepModel);
+ pBrepModel = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addPointSet(PRCPointSet *pPointSet)
+uint32_t PRCPartDefinition::addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel)
{
- representation_item.push_back(PRCpRepresentationItem(pPointSet));
- return representation_item.size()-1;
+ representation_item.push_back(pPolyBrepModel);
+ pPolyBrepModel = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addSet(PRCSet *pSet)
+uint32_t PRCPartDefinition::addPointSet(PRCPointSet*& pPointSet)
{
- representation_item.push_back(PRCpRepresentationItem(pSet));
- return representation_item.size()-1;
+ representation_item.push_back(pPointSet);
+ pPointSet = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addWire(PRCWire *pWire)
+uint32_t PRCPartDefinition::addSet(PRCSet*& pSet)
{
- representation_item.push_back(PRCpRepresentationItem(pWire));
- return representation_item.size()-1;
+ representation_item.push_back(pSet);
+ pSet = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addPolyWire(PRCPolyWire *pPolyWire)
+uint32_t PRCPartDefinition::addWire(PRCWire*& pWire)
{
- representation_item.push_back(PRCpRepresentationItem(pPolyWire));
- return representation_item.size()-1;
+ representation_item.push_back(pWire);
+ pWire = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addRepresentationItem(PRCRepresentationItem *pRepresentationItem)
+uint32_t PRCPartDefinition::addPolyWire(PRCPolyWire*& pPolyWire)
{
- representation_item.push_back(PRCpRepresentationItem(pRepresentationItem));
- return representation_item.size()-1;
+ representation_item.push_back(pPolyWire);
+ pPolyWire = NULL;
+ return representation_item.size()-1;
}
-uint32_t PRCPartDefinition::addRepresentationItem(PRCpRepresentationItem pRepresentationItem)
+uint32_t PRCPartDefinition::addRepresentationItem(PRCRepresentationItem*& pRepresentationItem)
{
- representation_item.push_back(pRepresentationItem);
- return representation_item.size()-1;
+ representation_item.push_back(pRepresentationItem);
+ pRepresentationItem = NULL;
+ return representation_item.size()-1;
}
-
void PRCPartDefinition::serializePartDefinition(PRCbitStream &pbs)
{
- WriteUnsignedInteger ( PRC_TYPE_ASM_PartDefinition )
+ WriteUnsignedInteger ( PRC_TYPE_ASM_PartDefinition )
- SerializePRCBaseWithGraphics
- SerializeBoundingBox
+ SerializePRCBaseWithGraphics
+ SerializeBoundingBox
- uint32_t number_of_representation_items = representation_item.size();
- WriteUnsignedInteger (number_of_representation_items)
- for (uint32_t i=0;i<number_of_representation_items;i++)
- SerializeRepresentationItem (representation_item[i])
+ uint32_t number_of_representation_items = representation_item.size();
+ WriteUnsignedInteger (number_of_representation_items)
+ for (uint32_t i=0;i<number_of_representation_items;i++)
+ SerializeRepresentationItem (representation_item[i])
- // SerializeMarkups (markups)
- WriteUnsignedInteger (0) // number_of_linked_items
- WriteUnsignedInteger (0) // number_of_leaders
- WriteUnsignedInteger (0) // number_of_markups
- WriteUnsignedInteger (0) // number_of_annotation_entities
-
- WriteUnsignedInteger (0) // number_of_views
- SerializeUserData
+ // SerializeMarkups (markups)
+ WriteUnsignedInteger (0) // number_of_linked_items
+ WriteUnsignedInteger (0) // number_of_leaders
+ WriteUnsignedInteger (0) // number_of_markups
+ WriteUnsignedInteger (0) // number_of_annotation_entities
+
+ WriteUnsignedInteger (0) // number_of_views
+ SerializeUserData
}
diff --git a/Build/source/utils/asymptote/prc/writePRC.h b/Build/source/utils/asymptote/prc/writePRC.h
index 18c616ccfac..2ec5ebc427d 100644
--- a/Build/source/utils/asymptote/prc/writePRC.h
+++ b/Build/source/utils/asymptote/prc/writePRC.h
@@ -22,13 +22,11 @@
#define __WRITE_PRC_H
#include <string>
#include <vector>
+#include <deque>
+#include <list>
+#include <ext/slist>
#include <map>
#include <iostream>
-#if defined(_MSC_VER)
-#include <memory>
-#else
-#include <tr1/memory>
-#endif
#include "PRCbitStream.h"
#include "PRC.h"
#include <float.h>
@@ -132,72 +130,123 @@ class UserData
uint8_t* data;
};
-union SingleAttributeData
-{
- int32_t integer;
- double real;
- uint32_t time;
- const char *text;
-};
-
-union AttributeTitle
+struct PRCAttributeEntry
{
- const char *text;
- uint32_t integer;
+ PRCAttributeEntry() : title_is_integer(false) {}
+ PRCAttributeEntry(uint32_t integer) : title_is_integer(true)
+ {
+ title_integer = integer;
+ }
+ PRCAttributeEntry(const std::string &text) : title_is_integer(false)
+ {
+ title_text = text;
+ }
+ void serializeAttributeEntry(PRCbitStream&) const;
+ bool title_is_integer;
+ std::string title_text;
+ uint32_t title_integer;
};
-class SingleAttribute
+class PRCSingleAttribute : public PRCAttributeEntry
{
public:
- SingleAttribute() {}
- SingleAttribute(bool b,AttributeTitle t,uint32_t y,SingleAttributeData d) :
- titleIsInteger(b), title(t), type(y), data(d) {}
- void write(PRCbitStream&);
- private:
- bool titleIsInteger;
- AttributeTitle title;
- uint32_t type;
- SingleAttributeData data;
+ PRCSingleAttribute() : type(KEPRCModellerAttributeTypeNull) {}
+ PRCSingleAttribute(int32_t integer) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeInt)
+ {
+ value.integer = integer;
+ }
+ PRCSingleAttribute(double real) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeReal)
+ {
+ value.real = real;
+ }
+ PRCSingleAttribute(uint32_t time) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeTime)
+ {
+ value.time = time;
+ }
+ PRCSingleAttribute(const std::string &text) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeString)
+ {
+ value_text = text;}
+ PRCSingleAttribute(uint32_t title, int32_t integer) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeInt)
+ {
+ value.integer = integer;
+ }
+ PRCSingleAttribute(uint32_t title, double real) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeReal)
+ {
+ value.real = real;
+ }
+ PRCSingleAttribute(uint32_t title, uint32_t time) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeTime)
+ {
+ value.time = time;
+ }
+ PRCSingleAttribute(uint32_t title, const std::string &text) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeString)
+ {
+ value_text = text;
+ }
+ PRCSingleAttribute(const std::string title, int32_t integer) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeInt)
+ {
+ value.integer = integer;
+ }
+ PRCSingleAttribute(const std::string title, double real) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeReal)
+ {
+ value.real = real;
+ }
+ PRCSingleAttribute(const std::string title, uint32_t time) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeTime)
+ {
+ value.time = time;
+ }
+ PRCSingleAttribute(const std::string title, const std::string &text) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeString)
+ {
+ value_text = text;
+ }
+ void serializeSingleAttribute(PRCbitStream&) const;
+ EPRCModellerAttributeType type;
+ union PRCSingleAttributeData
+ {
+ int32_t integer;
+ double real;
+ uint32_t time;
+ } value;
+ std::string value_text;
};
-class Attribute
+class PRCAttribute : public PRCAttributeEntry
{
public:
- Attribute(bool t,AttributeTitle v, uint32_t s, SingleAttribute* sa) :
- titleIsInteger(t),title(v), sizeOfAttributeKeys(s), singleAttributes(sa)
- {}
- void write(PRCbitStream &);
- private:
- bool titleIsInteger;
- AttributeTitle title;
- uint32_t sizeOfAttributeKeys;
- SingleAttribute *singleAttributes;
-};
+ PRCAttribute() : PRCAttributeEntry() {}
+ PRCAttribute(uint32_t title) : PRCAttributeEntry(title) {}
+ PRCAttribute(const std::string title) : PRCAttributeEntry(title) {}
+ void serializeAttribute(PRCbitStream &) const;
+ PRCSingleAttribute& newKey() { attribute_keys.resize(attribute_keys.size()+1); return attribute_keys.back(); }
+ void addKey(const PRCSingleAttribute &key) { attribute_keys.push_back(key); }
+ std::deque<PRCSingleAttribute> attribute_keys;
+};
+#ifdef __GNUC__
+typedef __gnu_cxx::slist<PRCAttribute> PRCAttributeList;
+#else
+typedef std::list<PRCAttribute> PRCAttributeList;
+#endif
-class Attributes
+class PRCAttributes
{
public:
- Attributes(uint32_t n, Attribute* a) : numberOfAttributes(n), attributes(a)
- {}
- void write(PRCbitStream&);
- private:
- uint32_t numberOfAttributes;
- Attribute *attributes;
+ void serializeAttributes(PRCbitStream&) const;
+ PRCAttribute& newAttribute() { attributes.push_front(PRCAttribute()); return attributes.front(); }
+ void addAttribute(const PRCAttribute &attribute) { attributes.push_front(attribute); }
+ PRCAttributeList attributes;
};
-class ContentPRCBase
+class ContentPRCBase : public PRCAttributes
{
public:
- ContentPRCBase(Attributes *a, std::string n="",bool efr = false,
- uint32_t ci = 0, uint32_t cpi = 0, uint32_t pi = 0) :
- attributes(a),name(n),eligibleForReference(efr),CADID(ci),
- CADPersistentID(cpi),PRCID(pi) {}
- void write(PRCbitStream&);
- uint32_t getPRCID() { return PRCID; }
- Attributes *attributes;
- std::string name;
- bool eligibleForReference;
- uint32_t CADID, CADPersistentID, PRCID;
+ ContentPRCBase(std::string n="",bool efr = false,
+ uint32_t ci = 0, uint32_t cpi = 0, uint32_t pi = 0) :
+ name(n),type_eligible_for_reference(efr),CAD_identifier(ci),
+ CAD_persistent_identifier(cpi),PRC_unique_identifier(pi) {}
+ void serializeContentPRCBase(PRCbitStream&);
+ uint32_t getPRCID() { return PRC_unique_identifier; }
+ std::string name;
+ bool type_eligible_for_reference;
+ uint32_t CAD_identifier, CAD_persistent_identifier, PRC_unique_identifier;
};
class PRCReferenceUniqueIdentifier
@@ -212,11 +261,7 @@ public:
uint32_t unique_identifier;
};
-extern AttributeTitle EMPTY_ATTRIBUTE_TITLE;
-extern Attribute EMPTY_ATTRIBUTE;
-extern Attributes EMPTY_ATTRIBUTES;
extern ContentPRCBase EMPTY_CONTENTPRCBASE;
-extern ContentPRCBase EMPTY_CONTENTPRCBASE_WITH_REFERENCE;
extern std::string currentName;
void writeName(PRCbitStream&,const std::string&);
@@ -260,7 +305,7 @@ class PRCPicture : public ContentPRCBase
{
public:
PRCPicture(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
+ ContentPRCBase(n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
void serializePicture(PRCbitStream&);
EPRCPictureDataFormat format;
uint32_t uncompressed_file_index;
@@ -283,7 +328,7 @@ class PRCTextureDefinition : public ContentPRCBase
{
public:
PRCTextureDefinition(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE),
texture_mapping_attribute_intensity(1.0), texture_mapping_attribute_components(PRC_TEXTURE_MAPPING_COMPONENTS_RGBA),
texture_function(KEPRCTextureFunction_Modulate), texture_applying_mode(PRC_TEXTURE_APPLYING_MODE_NONE),
texture_wrapping_mode_S(KEPRCTextureWrappingMode_Unknown), texture_wrapping_mode_T(KEPRCTextureWrappingMode_Unknown) // ,
@@ -312,22 +357,21 @@ public:
// double Y_homegeneous_coord;
// double origin_homegeneous_coord;
};
-typedef std::tr1::shared_ptr <PRCTextureDefinition> PRCpTextureDefinition;
-typedef std::vector <PRCpTextureDefinition> PRCTextureDefinitionList;
+typedef std::deque <PRCTextureDefinition*> PRCTextureDefinitionList;
class PRCMaterial
{
public:
+ virtual ~PRCMaterial() {}
virtual void serializeMaterial(PRCbitStream&) = 0;
};
-typedef std::tr1::shared_ptr <PRCMaterial> PRCpMaterial;
-typedef std::vector <PRCpMaterial> PRCMaterialList;
+typedef std::deque <PRCMaterial*> PRCMaterialList;
class PRCMaterialGeneric : public ContentPRCBase, public PRCMaterial
{
public:
PRCMaterialGeneric(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
ambient(m1), diffuse(m1), emissive(m1), specular(m1),
shininess(0.0),
ambient_alpha(1.0), diffuse_alpha(1.0), emissive_alpha(1.0), specular_alpha(1.0)
@@ -356,7 +400,7 @@ class PRCTextureApplication : public ContentPRCBase, public PRCMaterial
{
public:
PRCTextureApplication(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
material_generic_index(m1), texture_definition_index(m1),
next_texture_index(m1), UV_coordinates_index(0)
{}
@@ -372,7 +416,7 @@ class PRCStyle : public ContentPRCBase
{
public:
PRCStyle(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1),
is_material(false), color_material_index(m1), is_transparency_defined(false), transparency(255), additional(0)
{}
void serializeCategory1LineStyle(PRCbitStream&);
@@ -385,8 +429,7 @@ public:
uint8_t transparency;
uint8_t additional;
};
-typedef std::tr1::shared_ptr <PRCStyle> PRCpStyle;
-typedef std::vector <PRCpStyle> PRCStyleList;
+typedef std::deque <PRCStyle*> PRCStyleList;
class PRCTessFace
{
@@ -408,8 +451,7 @@ public:
std::vector<uint8_t> rgba_vertices;
uint32_t behaviour;
};
-typedef std::tr1::shared_ptr <PRCTessFace> PRCpTessFace;
-typedef std::vector <PRCpTessFace> PRCTessFaceList;
+typedef std::deque <PRCTessFace*> PRCTessFaceList;
class PRCContentBaseTessData
{
@@ -424,10 +466,10 @@ public:
class PRCTess : public PRCContentBaseTessData
{
public:
+ virtual ~PRCTess() {}
virtual void serializeBaseTessData(PRCbitStream &pbs) = 0;
};
-typedef std::tr1::shared_ptr <PRCTess> PRCpTess;
-typedef std::vector <PRCpTess> PRCTessList;
+typedef std::deque <PRCTess*> PRCTessList;
class PRC3DTess : public PRCTess
{
@@ -436,9 +478,10 @@ public:
has_faces(false), has_loops(false),
crease_angle(25.8419)
{}
+ ~PRC3DTess() { for(PRCTessFaceList::iterator it=face_tessellation.begin(); it!=face_tessellation.end(); ++it) delete *it; }
void serialize3DTess(PRCbitStream&);
void serializeBaseTessData(PRCbitStream &pbs) { serialize3DTess(pbs); }
- void addTessFace(PRCTessFace *pTessFace);
+ void addTessFace(PRCTessFace*& pTessFace);
bool has_faces;
bool has_loops;
@@ -490,8 +533,7 @@ public:
uint32_t index_of_line_style;
uint16_t behaviour_bit_field;
};
-typedef std::tr1::shared_ptr <PRCGraphics> PRCpGraphics;
-typedef std::vector <PRCpGraphics> PRCGraphicsList;
+typedef std::deque <PRCGraphics*> PRCGraphicsList;
void writeGraphics(PRCbitStream&,const PRCGraphics&,bool=false);
@@ -499,7 +541,7 @@ class PRCMarkup: public PRCGraphics, public ContentPRCBase
{
public:
PRCMarkup(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {}
void serializeMarkup(PRCbitStream&);
EPRCMarkupType type;
@@ -508,26 +550,24 @@ public:
// vector<PRCReferenceUniqueIdentifier> leaders;
uint32_t index_tessellation;
};
-typedef std::tr1::shared_ptr <PRCMarkup> PRCpMarkup;
-typedef std::vector <PRCpMarkup> PRCMarkupList;
+typedef std::deque <PRCMarkup*> PRCMarkupList;
class PRCAnnotationItem: public PRCGraphics, public ContentPRCBase
{
public:
PRCAnnotationItem(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {}
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()) {}
void serializeAnnotationItem(PRCbitStream&);
void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); }
PRCReferenceUniqueIdentifier markup;
};
-typedef std::tr1::shared_ptr <PRCAnnotationItem> PRCpAnnotationItem;
-typedef std::vector <PRCpAnnotationItem> PRCAnnotationItemList;
+typedef std::deque <PRCAnnotationItem*> PRCAnnotationItemList;
class PRCRepresentationItemContent: public PRCGraphics, public ContentPRCBase
{
public:
PRCRepresentationItemContent(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
index_local_coordinate_system(m1), index_tessellation(m1) {}
void serializeRepresentationItemContent(PRCbitStream&);
uint32_t index_local_coordinate_system;
@@ -539,10 +579,10 @@ class PRCRepresentationItem : public PRCRepresentationItemContent
public:
PRCRepresentationItem(std::string n="") :
PRCRepresentationItemContent(n) {}
+ virtual ~PRCRepresentationItem() {}
virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0;
};
-typedef std::tr1::shared_ptr <PRCRepresentationItem> PRCpRepresentationItem;
-typedef std::vector <PRCpRepresentationItem> PRCRepresentationItemList;
+typedef std::deque <PRCRepresentationItem*> PRCRepresentationItemList;
class PRCBrepModel : public PRCRepresentationItem
{
@@ -576,7 +616,6 @@ public:
void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); }
std::vector<PRCVector3d> point;
};
-typedef std::tr1::shared_ptr <PRCPointSet> PRCpPointSet;
class PRCWire : public PRCRepresentationItem
{
@@ -604,26 +643,26 @@ class PRCSet : public PRCRepresentationItem
public:
PRCSet(std::string n="") :
PRCRepresentationItem(n) {}
+ ~PRCSet() { for(PRCRepresentationItemList::iterator it=elements.begin(); it!=elements.end(); ++it) delete *it; }
void serializeSet(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeSet(pbs); }
- uint32_t addBrepModel(PRCBrepModel *pBrepModel);
- uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel);
- uint32_t addPointSet(PRCPointSet *pPointSet);
- uint32_t addSet(PRCSet *pSet);
- uint32_t addWire(PRCWire *pWire);
- uint32_t addPolyWire(PRCPolyWire *pPolyWire);
- uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem);
- uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem);
+ uint32_t addBrepModel(PRCBrepModel*& pBrepModel);
+ uint32_t addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel);
+ uint32_t addPointSet(PRCPointSet*& pPointSet);
+ uint32_t addSet(PRCSet*& pSet);
+ uint32_t addWire(PRCWire*& pWire);
+ uint32_t addPolyWire(PRCPolyWire*& pPolyWire);
+ uint32_t addRepresentationItem(PRCRepresentationItem*& pRepresentationItem);
PRCRepresentationItemList elements;
};
class PRCTransformation3d
{
public:
+ virtual ~PRCTransformation3d() {}
virtual void serializeTransformation3d(PRCbitStream&) const =0;
};
-typedef std::tr1::shared_ptr <PRCTransformation3d> PRCpTransformation3d;
-typedef std::vector <PRCpTransformation3d> PRCTransformation3dList;
+typedef std::deque <PRCTransformation3d*> PRCTransformation3dList;
class PRCGeneralTransformation3d : public PRCTransformation3d
{
@@ -714,8 +753,7 @@ public:
mat[3][0]==0 && mat[3][1]==0 && mat[3][2]==0 && mat[3][3]==1 );
}
};
-typedef std::tr1::shared_ptr <PRCGeneralTransformation3d> PRCpGeneralTransformation3d;
-typedef std::vector <PRCpGeneralTransformation3d> PRCGeneralTransformation3dList;
+typedef std::deque <PRCGeneralTransformation3d> PRCGeneralTransformation3dList;
class PRCCartesianTransformation3d : public PRCTransformation3d
{
@@ -765,18 +803,20 @@ class PRCCoordinateSystem : public PRCRepresentationItem
{
public:
PRCCoordinateSystem(std::string n="") :
- PRCRepresentationItem(n) {}
+ PRCRepresentationItem(n), axis_set(NULL) {}
+ ~PRCCoordinateSystem() { delete axis_set; }
void serializeCoordinateSystem(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); }
- PRCpTransformation3d axis_set;
+ void setAxisSet(PRCTransformation3d*& transform) { axis_set = transform; transform = NULL; }
+ PRCTransformation3d *axis_set;
bool operator==(const PRCCoordinateSystem &t) const
{
if(index_local_coordinate_system!=t.index_local_coordinate_system)
return false;
- PRCGeneralTransformation3d* axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(axis_set.get());
- PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(t.axis_set.get());
- PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(axis_set.get());
- PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(t.axis_set.get());
+ PRCGeneralTransformation3d* axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(axis_set);
+ PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(t.axis_set);
+ PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(axis_set);
+ PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(t.axis_set);
if(axis_set_general!=NULL)
return (t_axis_set_general!=NULL?(*axis_set_general==*t_axis_set_general):false);
if(axis_set_cartesian!=NULL)
@@ -784,8 +824,7 @@ public:
return false;
}
};
-typedef std::tr1::shared_ptr <PRCCoordinateSystem> PRCpCoordinateSystem;
-typedef std::vector <PRCpCoordinateSystem> PRCCoordinateSystemList;
+typedef std::deque <PRCCoordinateSystem*> PRCCoordinateSystemList;
struct PRCFontKey
{
@@ -804,16 +843,15 @@ public:
};
// Topology
-class PRCBaseGeometry
+class PRCBaseGeometry : public PRCAttributes
{
public:
PRCBaseGeometry() :
- base_information(false) {}
- PRCBaseGeometry(Attributes *a, std::string n="", uint32_t id = 0) :
- base_information(true),attributes(a),name(n),identifier(id) {}
+ base_information(false), identifier(0) {}
+ PRCBaseGeometry(std::string n, uint32_t id = 0) :
+ base_information(true),name(n),identifier(id) {}
void serializeBaseGeometry(PRCbitStream&);
bool base_information;
- Attributes *attributes;
std::string name;
uint32_t identifier;
};
@@ -895,7 +933,7 @@ public:
PRCContentSurface() :
PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone) {}
PRCContentSurface(std::string n) :
- PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone) {}
+ PRCBaseGeometry(n,makeCADID()),extend_info(KEPRCExtendTypeNone) {}
void serializeContentSurface(PRCbitStream&);
EPRCExtendType extend_info;
};
@@ -907,10 +945,9 @@ public:
PRCContentSurface() {}
PRCSurface(std::string n) :
PRCContentSurface(n) {}
+ virtual ~PRCSurface() {}
virtual void serializeSurface(PRCbitStream &pbs) = 0;
};
-typedef std::tr1::shared_ptr <PRCSurface> PRCpSurface;
-typedef std::vector <PRCpSurface> PRCSurfaceList;
class PRCNURBSSurface : public PRCSurface
{
@@ -937,7 +974,7 @@ public:
PRCContentCurve() :
PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone), is_3d(true) {}
PRCContentCurve(std::string n) :
- PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone), is_3d(true) {}
+ PRCBaseGeometry(n,makeCADID()),extend_info(KEPRCExtendTypeNone), is_3d(true) {}
void serializeContentCurve(PRCbitStream&);
EPRCExtendType extend_info;
bool is_3d;
@@ -950,10 +987,10 @@ public:
PRCContentCurve() {}
PRCCurve(std::string n) :
PRCContentCurve(n) {}
+ virtual ~PRCCurve() {}
virtual void serializeCurve(PRCbitStream &pbs) = 0;
};
-typedef std::tr1::shared_ptr <PRCCurve> PRCpCurve;
-typedef std::vector <PRCpCurve> PRCCurveList;
+typedef std::deque <PRCCurve*> PRCCurveList;
class PRCNURBSCurve : public PRCCurve
{
@@ -1014,32 +1051,34 @@ class PRCBlend01 : public PRCSurface, public PRCTransformation, public PRCUVPara
{
public:
PRCBlend01() :
- PRCSurface() {}
+ PRCSurface(), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {}
PRCBlend01(std::string n) :
- PRCSurface(n) {}
+ PRCSurface(n), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {}
+ ~PRCBlend01() { delete center_curve; delete origin_curve; delete tangent_curve; }
void serializeBlend01(PRCbitStream &pbs);
void serializeSurface(PRCbitStream &pbs) { serializeBlend01(pbs); }
- void setCenterCurve(PRCCurve *curve) { center_curve.reset(curve); }
- void setOriginCurve(PRCCurve *curve) { origin_curve.reset(curve); }
- void setTangentCurve(PRCCurve *curve) { tangent_curve.reset(curve); }
- PRCpCurve center_curve;
- PRCpCurve origin_curve;
- PRCpCurve tangent_curve;
+// void setCenterCurve (PRCCurve*& curve) { center_curve = curve; curve = NULL; }
+// void setOriginCurve (PRCCurve*& curve) { origin_curve = curve; curve = NULL; }
+// void setTangentCurve(PRCCurve*& curve) { tangent_curve = curve; curve = NULL; }
+ PRCCurve* center_curve;
+ PRCCurve* origin_curve;
+ PRCCurve* tangent_curve;
};
class PRCRuled : public PRCSurface, public PRCTransformation, public PRCUVParameterization
{
public:
PRCRuled() :
- PRCSurface() {}
+ PRCSurface(), first_curve(NULL), second_curve(NULL) {}
PRCRuled(std::string n) :
PRCSurface(n) {}
+ ~PRCRuled() { delete first_curve; delete second_curve; }
void serializeRuled(PRCbitStream &pbs);
void serializeSurface(PRCbitStream &pbs) { serializeRuled(pbs); }
- void setFirstCurve(PRCCurve *curve) { first_curve.reset(curve); }
- void setSecondCurve(PRCCurve *curve) { second_curve.reset(curve); }
- PRCpCurve first_curve;
- PRCpCurve second_curve;
+// void setFirstCurve(PRCCurve*& curve) { first_curve = curve; curve = NULL; }
+// void setSecondCurve(PRCCurve*& curve) { second_curve = curve; curve = NULL; }
+ PRCCurve* first_curve;
+ PRCCurve* second_curve;
};
class PRCSphere : public PRCSurface, public PRCTransformation, public PRCUVParameterization
@@ -1079,16 +1118,15 @@ public:
double minor_radius;
};
-class PRCBaseTopology
+class PRCBaseTopology : public PRCAttributes
{
public:
PRCBaseTopology() :
- base_information(false),attributes(NULL),identifier(0) {}
- PRCBaseTopology(Attributes *a, std::string n="", uint32_t id = 0) :
- base_information(true),attributes(a),name(n),identifier(id) {}
+ base_information(false),identifier(0) {}
+ PRCBaseTopology(std::string n, uint32_t id = 0) :
+ base_information(true),name(n),identifier(id) {}
void serializeBaseTopology(PRCbitStream&);
bool base_information;
- Attributes *attributes;
std::string name;
uint32_t identifier;
};
@@ -1096,9 +1134,9 @@ public:
class PRCTopoItem
{
public:
+ virtual ~PRCTopoItem() {}
virtual void serializeTopoItem(PRCbitStream&)=0;
};
-typedef std::tr1::shared_ptr <PRCTopoItem> PRCpTopoItem;
class PRCContentBody: public PRCBaseTopology
{
@@ -1106,7 +1144,7 @@ public:
PRCContentBody() :
PRCBaseTopology(), behavior(0) {}
PRCContentBody(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), behavior(0) {}
+ PRCBaseTopology(n,makeCADID()), behavior(0) {}
void serializeContentBody(PRCbitStream&);
uint8_t behavior;
};
@@ -1120,26 +1158,26 @@ public:
PRCContentBody(), topo_item_type(tit) {}
PRCBody(uint32_t tit, std::string n) :
PRCContentBody(n), topo_item_type(tit) {}
+ virtual ~PRCBody() {}
virtual void serializeBody(PRCbitStream &pbs) = 0;
void serializeTopoItem(PRCbitStream &pbs) { serializeBody(pbs); }
uint32_t serialType() { return topo_item_type; }
virtual double serialTolerance() { return 0; }
const uint32_t topo_item_type;
};
-typedef std::tr1::shared_ptr <PRCBody> PRCpBody;
-typedef std::vector <PRCpBody> PRCBodyList;
+typedef std::deque <PRCBody*> PRCBodyList;
class PRCContentWireEdge : public PRCBaseTopology
{
public:
PRCContentWireEdge() :
- PRCBaseTopology(), has_curve_trim_interval(false) {}
+ PRCBaseTopology(), curve_3d(NULL), has_curve_trim_interval(false) {}
PRCContentWireEdge(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), has_curve_trim_interval(false) {}
+ PRCBaseTopology(n,makeCADID()), curve_3d(NULL), has_curve_trim_interval(false) {}
+ ~PRCContentWireEdge() { delete curve_3d; }
void serializeContentWireEdge(PRCbitStream &pbs);
- void setCurve(PRCCurve *pCurve) { curve_3d.reset(pCurve); }
- void setCurve(PRCpCurve pCurve) { curve_3d = pCurve; }
- PRCpCurve curve_3d;
+// void setCurve(PRCCurve*& curve) { curve_3d = curve; curve = NULL; }
+ PRCCurve* curve_3d;
bool has_curve_trim_interval;
PRCInterval curve_trim_interval;
};
@@ -1155,27 +1193,28 @@ class PRCSingleWireBody : public PRCBody
{
public:
PRCSingleWireBody() :
- PRCBody(PRC_TYPE_TOPO_SingleWireBody) {}
+ PRCBody(PRC_TYPE_TOPO_SingleWireBody), wire_edge(NULL) {}
PRCSingleWireBody(std::string n) :
- PRCBody(PRC_TYPE_TOPO_SingleWireBody, n) {}
+ PRCBody(PRC_TYPE_TOPO_SingleWireBody, n), wire_edge(NULL) {}
+ ~PRCSingleWireBody() { delete wire_edge; }
void serializeSingleWireBody(PRCbitStream &pbs);
void serializeBody(PRCbitStream &pbs) { serializeSingleWireBody(pbs); }
- void setWireEdge(PRCWireEdge *wireEdge);
-// void setEdge(const PRCEdge &edge);
- PRCpTopoItem wire_edge;
+ void setWireEdge(PRCWireEdge*& wireEdge) { wire_edge = wireEdge; wireEdge = NULL; }
+ PRCWireEdge* wire_edge;
};
class PRCFace : public PRCBaseTopology, public PRCTopoItem, public PRCGraphics
{
public:
PRCFace() :
- PRCBaseTopology(), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
+ PRCBaseTopology(), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
PRCFace(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
+ PRCBaseTopology(n,makeCADID()), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
+ ~PRCFace() { delete base_surface; }
void serializeFace(PRCbitStream &pbs);
void serializeTopoItem(PRCbitStream &pbs) { serializeFace(pbs); }
- void setSurface(PRCSurface *pSurface) { base_surface.reset(pSurface); }
- PRCpSurface base_surface;
+ void setBaseSurface(PRCSurface*& surface) { base_surface = surface; surface = NULL; }
+ PRCSurface *base_surface;
const bool have_surface_trim_domain;
PRCDomain surface_trim_domain;
const bool have_tolerance;
@@ -1184,8 +1223,7 @@ public:
const int32_t outer_loop_index;
// PRCLoopList loop;
};
-typedef std::tr1::shared_ptr <PRCFace> PRCpFace;
-typedef std::vector <PRCpFace> PRCFaceList;
+typedef std::deque <PRCFace*> PRCFaceList;
class PRCShell : public PRCBaseTopology, public PRCTopoItem
{
@@ -1193,17 +1231,16 @@ public:
PRCShell() :
PRCBaseTopology(), shell_is_closed(false) {}
PRCShell(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), shell_is_closed(false) {}
+ PRCBaseTopology(n,makeCADID()), shell_is_closed(false) {}
+ ~PRCShell() { for(PRCFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; }
void serializeShell(PRCbitStream &pbs);
void serializeTopoItem(PRCbitStream &pbs) { serializeShell(pbs); }
- void addFace(PRCFace *pFace, uint8_t orientation=2);
- void addFace(const PRCpFace &pFace, uint8_t orientation=2);
+ void addFace(PRCFace*& pFace, uint8_t orientation=2);
bool shell_is_closed;
PRCFaceList face;
std::vector<uint8_t> orientation_surface_with_shell;
};
-typedef std::tr1::shared_ptr <PRCShell> PRCpShell;
-typedef std::vector <PRCpShell> PRCShellList;
+typedef std::deque <PRCShell*> PRCShellList;
class PRCConnex : public PRCBaseTopology, public PRCTopoItem
{
@@ -1211,14 +1248,14 @@ public:
PRCConnex() :
PRCBaseTopology() {}
PRCConnex(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()) {}
+ PRCBaseTopology(n,makeCADID()) {}
+ ~PRCConnex() { for(PRCShellList::iterator it=shell.begin(); it!=shell.end(); ++it) delete *it; }
void serializeConnex(PRCbitStream &pbs);
void serializeTopoItem(PRCbitStream &pbs) { serializeConnex(pbs); }
- void addShell(PRCShell *pShell);
+ void addShell(PRCShell*& pShell);
PRCShellList shell;
};
-typedef std::tr1::shared_ptr <PRCConnex> PRCpConnex;
-typedef std::vector <PRCpConnex> PRCConnexList;
+typedef std::deque <PRCConnex*> PRCConnexList;
class PRCBrepData : public PRCBody, public PRCBoundingBox
{
@@ -1227,9 +1264,10 @@ public:
PRCBody(PRC_TYPE_TOPO_BrepData) {}
PRCBrepData(std::string n) :
PRCBody(PRC_TYPE_TOPO_BrepData, n) {}
+ ~PRCBrepData() { for(PRCConnexList::iterator it=connex.begin(); it!=connex.end(); ++it) delete *it; }
void serializeBrepData(PRCbitStream &pbs);
void serializeBody(PRCbitStream &pbs) { serializeBrepData(pbs); }
- void addConnex(PRCConnex *pConnex);
+ void addConnex(PRCConnex*& pConnex);
PRCConnexList connex;
};
@@ -1240,7 +1278,7 @@ public:
PRCCompressedFace() :
PRCBaseTopology(), orientation_surface_with_shell(true), degree(0) {}
PRCCompressedFace(std::string n) :
- PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), orientation_surface_with_shell(true), degree(0) {}
+ PRCBaseTopology(n,makeCADID()), orientation_surface_with_shell(true), degree(0) {}
void serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance);
void serializeContentCompressedFace(PRCbitStream &pbs);
void serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance);
@@ -1249,8 +1287,7 @@ public:
uint32_t degree;
std::vector<PRCVector3d> control_point;
};
-typedef std::tr1::shared_ptr <PRCCompressedFace> PRCpCompressedFace;
-typedef std::vector <PRCpCompressedFace> PRCCompressedFaceList;
+typedef std::deque <PRCCompressedFace*> PRCCompressedFaceList;
// For now - treat just the case of one connex/one shell
class PRCCompressedBrepData : public PRCBody
@@ -1260,6 +1297,7 @@ public:
PRCBody(PRC_TYPE_TOPO_BrepDataCompress), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
PRCCompressedBrepData(std::string n) :
PRCBody(PRC_TYPE_TOPO_BrepDataCompress, n), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
+ ~PRCCompressedBrepData() { for(PRCCompressedFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; }
void serializeCompressedBrepData(PRCbitStream &pbs);
void serializeBody(PRCbitStream &pbs) { serializeCompressedBrepData(pbs); }
void serializeCompressedShell(PRCbitStream &pbs);
@@ -1273,15 +1311,16 @@ class PRCTopoContext : public ContentPRCBase
{
public:
PRCTopoContext(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n), behaviour(0), /* granularity(0), */ tolerance(0),
+ ContentPRCBase(n), behaviour(0), granularity(1), tolerance(0),
have_smallest_face_thickness(false), smallest_thickness(0), have_scale(false), scale(1) {}
+ ~PRCTopoContext() { for(PRCBodyList::iterator it=body.begin(); it!=body.end(); ++it) delete *it; }
void serializeTopoContext(PRCbitStream&);
void serializeContextAndBodies(PRCbitStream&);
void serializeGeometrySummary(PRCbitStream&);
void serializeContextGraphics(PRCbitStream&);
- uint32_t addSingleWireBody(PRCSingleWireBody *body);
- uint32_t addBrepData(PRCBrepData *body);
- uint32_t addCompressedBrepData(PRCCompressedBrepData *body);
+ uint32_t addSingleWireBody(PRCSingleWireBody*& body);
+ uint32_t addBrepData(PRCBrepData*& body);
+ uint32_t addCompressedBrepData(PRCCompressedBrepData*& body);
uint8_t behaviour;
double granularity;
double tolerance;
@@ -1291,8 +1330,7 @@ public:
double scale;
PRCBodyList body;
};
-typedef std::tr1::shared_ptr <PRCTopoContext> PRCpTopoContext;
-typedef std::vector <PRCpTopoContext> PRCTopoContextList;
+typedef std::deque <PRCTopoContext*> PRCTopoContextList;
class PRCUniqueId
{
@@ -1318,12 +1356,14 @@ class PRCProductOccurrence: public PRCGraphics, public ContentPRCBase
{
public:
PRCProductOccurrence(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
index_part(m1),
index_prototype(m1), prototype_in_same_file_structure(true),
index_external_data(m1), external_data_in_same_file_structure(true),
product_behaviour(0), product_information_flags(0), product_load_status(KEPRCProductLoadStatus_Loaded),
- has_location(false) {}
+ location(NULL) {}
+ ~PRCProductOccurrence() { delete location; }
+ void setLocation(PRCGeneralTransformation3d*& transform) { location = transform; transform = NULL; }
void serializeProductOccurrence(PRCbitStream&);
uint32_t index_part;
uint32_t index_prototype;
@@ -1337,29 +1377,26 @@ public:
PRCUnit unit_information;
uint8_t product_information_flags;
EPRCProductLoadStatus product_load_status;
- bool has_location;
- PRCpGeneralTransformation3d location;
+ PRCGeneralTransformation3d *location;
};
-typedef std::tr1::shared_ptr <PRCProductOccurrence> PRCpProductOccurrence;
-typedef std::vector <PRCpProductOccurrence> PRCProductOccurrenceList;
+typedef std::deque <PRCProductOccurrence*> PRCProductOccurrenceList;
class PRCPartDefinition: public PRCGraphics, public ContentPRCBase, public PRCBoundingBox
{
public:
PRCPartDefinition(std::string n="") :
- ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {}
+ ContentPRCBase(n,true,makeCADID(),0,makePRCID()) {}
+ ~PRCPartDefinition() { for(PRCRepresentationItemList::iterator it=representation_item.begin(); it!=representation_item.end(); ++it) delete *it; }
void serializePartDefinition(PRCbitStream&);
- uint32_t addBrepModel(PRCBrepModel *pBrepModel);
- uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel);
- uint32_t addPointSet(PRCPointSet *pPointSet);
- uint32_t addSet(PRCSet *pSet);
- uint32_t addWire(PRCWire *pWire);
- uint32_t addPolyWire(PRCPolyWire *pPolyWire);
- uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem);
- uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem);
+ uint32_t addBrepModel(PRCBrepModel*& pBrepModel);
+ uint32_t addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel);
+ uint32_t addPointSet(PRCPointSet*& pPointSet);
+ uint32_t addSet(PRCSet*& pSet);
+ uint32_t addWire(PRCWire*& pWire);
+ uint32_t addPolyWire(PRCPolyWire*& pPolyWire);
+ uint32_t addRepresentationItem(PRCRepresentationItem*& pRepresentationItem);
PRCRepresentationItemList representation_item;
};
-typedef std::tr1::shared_ptr <PRCPartDefinition> PRCpPartDefinition;
-typedef std::vector <PRCpPartDefinition> PRCPartDefinitionList;
+typedef std::deque <PRCPartDefinition*> PRCPartDefinitionList;
#endif //__WRITE_PRC_H