summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-02 23:03:22 +0000
committerKarl Berry <karl@freefriends.org>2013-04-02 23:03:22 +0000
commit324efbd652f973cd70f42fe08c665c518995bcbe (patch)
tree818ae382dfa133f3dcceec8e12e4cbd42be8bcf4 /Build/source/utils/asymptote/prc
parentbbf699abe485e707133ff3ba502119f261f27269 (diff)
asy 2.21 sources (no runtime update)
git-svn-id: svn://tug.org/texlive/trunk@29618 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/prc')
-rw-r--r--Build/source/utils/asymptote/prc/Makefile12
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.cc841
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.h418
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.cc127
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.h264
5 files changed, 1228 insertions, 434 deletions
diff --git a/Build/source/utils/asymptote/prc/Makefile b/Build/source/utils/asymptote/prc/Makefile
index af1a50084dd..a7f603b93f1 100644
--- a/Build/source/utils/asymptote/prc/Makefile
+++ b/Build/source/utils/asymptote/prc/Makefile
@@ -7,14 +7,14 @@ MAKEDEPEND = $(CFLAGS) -O0 -M -DDEPEND
FILES = PRCbitStream oPRCFile PRCdouble writePRC
-test: $(FILES:=.o) test.cc
- $(CXX) $(CFLAGS) -o test $(FILES:=.o) test.cc -lz
+test: $(FILES:=.o) test.o
+ $(CXX) $(CFLAGS) -o test $(FILES:=.o) test.o -lz
-test_tess: $(FILES:=.o) test_tess.cc
- $(CXX) $(CFLAGS) -o test_tess $(FILES:=.o) test_tess.cc -lz
+test_tess: $(FILES:=.o) test_tess.o
+ $(CXX) $(CFLAGS) -o test_tess $(FILES:=.o) test_tess.o -lz
-test_mesh: $(FILES:=.o) test_mesh.cc
- $(CXX) $(CFLAGS) -o test_mesh $(FILES:=.o) test_mesh.cc -lz
+test_mesh: $(FILES:=.o) test_mesh.o
+ $(CXX) $(CFLAGS) -o test_mesh $(FILES:=.o) test_mesh.o -lz
.SUFFIXES: .c .cc .o .d
.cc.o:
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.cc b/Build/source/utils/asymptote/prc/oPRCFile.cc
index b8014544d4a..10f9431652c 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.cc
+++ b/Build/source/utils/asymptote/prc/oPRCFile.cc
@@ -24,6 +24,7 @@
#include <sstream>
#include <iostream>
#include <fstream>
+#include <iomanip>
#include <string>
#include <zlib.h>
#include <string.h>
@@ -46,7 +47,7 @@
#define SerializeMaterial( value ) (value)->serializeMaterial(out);
#define SerializeUserData UserData(0,0).write(out);
-#define SerializeEmptyContentPRCBase EMPTY_CONTENTPRCBASE.serializeContentPRCBase(out);
+#define SerializeEmptyContentPRCBase ContentPRCBase(PRC_TYPE_ROOT_PRCBase).serializeContentPRCBase(out);
#define SerializeCategory1LineStyle( value ) (value)->serializeCategory1LineStyle(out);
#define SerializeCoordinateSystem( value ) (value)->serializeCoordinateSystem(out);
#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(out);
@@ -94,7 +95,7 @@ void PRCFileStructure::serializeFileStructureGlobals(PRCbitStream &out)
PRCSingleAttribute sa((int32_t)PRCVersion);
PRCAttribute a("__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion");
a.addKey(sa);
- ContentPRCBase cb;
+ ContentPRCBase cb(PRC_TYPE_ROOT_PRCBase);
cb.addAttribute(a);
cb.serializeContentPRCBase(out);
WriteUnsignedInteger (number_of_referenced_file_structures)
@@ -132,12 +133,10 @@ void PRCFileStructure::serializeFileStructureGlobals(PRCbitStream &out)
for (uint32_t i=0;i<number_of_materials;i++)
SerializeMaterial (materials[i])
- out << (uint32_t)1 // number of line patterns hard coded for now
- << (uint32_t)PRC_TYPE_GRAPH_LinePattern;
- ContentPRCBase("",true,makeCADID(),0,makePRCID()).serializeContentPRCBase(out);
- out << (uint32_t)0 // number of lengths
- << 0.0 // phase
- << false; // is real length
+ // number of line patterns hard coded for now
+ const uint32_t number_of_line_patterns = 1;
+ WriteUnsignedInteger (number_of_line_patterns)
+ PRCLinePattern().serializeLinePattern(out);
const uint32_t number_of_styles = styles.size();
WriteUnsignedInteger (number_of_styles)
@@ -161,12 +160,12 @@ void PRCFileStructure::serializeFileStructureTree(PRCbitStream &out)
SerializeEmptyContentPRCBase
- uint32_t number_of_part_definitions = part_definitions.size();
+ const uint32_t number_of_part_definitions = part_definitions.size();
WriteUnsignedInteger (number_of_part_definitions)
for (uint32_t i=0;i<number_of_part_definitions;i++)
SerializePartDefinition (part_definitions[i])
- uint32_t number_of_product_occurrences = product_occurrences.size();
+ const uint32_t number_of_product_occurrences = product_occurrences.size();
WriteUnsignedInteger (number_of_product_occurrences)
for (uint32_t i=0;i<number_of_product_occurrences;i++)
{
@@ -239,7 +238,7 @@ void oPRCFile::serializeModelFileData(PRCbitStream &out)
PRCSingleAttribute sa((int32_t)PRCVersion);
PRCAttribute a("__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion");
a.addKey(sa);
- ContentPRCBase cb("PRC file");
+ ContentPRCBase cb(PRC_TYPE_ROOT_PRCBase,"PRC file");
cb.addAttribute(a);
cb.serializeContentPRCBase(out);
@@ -400,11 +399,14 @@ uint32_t PRCHeader::getSize()
return size;
}
-void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence)
+void oPRCFile::doGroup(PRCgroup& group)
{
const string& name = group.name;
- PRCPartDefinition *part_definition = new PRCPartDefinition;
+ PRCProductOccurrence*& product_occurrence = group.product_occurrence;
+ PRCProductOccurrence*& parent_product_occurrence = group.parent_product_occurrence;
+ PRCPartDefinition*& part_definition = group.part_definition;
+ PRCPartDefinition*& parent_part_definition = group.parent_part_definition;
if(group.options.tess)
{
@@ -438,8 +440,8 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
tess->wire_indexes.push_back(pPoint->second);
else
{
- uint32_t point_index = m1;
- points.insert(make_pair(lit->point[i],(point_index = tess->coordinates.size())));
+ const uint32_t point_index = tess->coordinates.size();
+ points.insert(make_pair(lit->point[i],point_index));
tess->wire_indexes.push_back(point_index);
tess->coordinates.push_back(lit->point[i].x);
tess->coordinates.push_back(lit->point[i].y);
@@ -476,6 +478,7 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
}
map<PRCVector3d,uint32_t> points;
PRC3DTess *tess = new PRC3DTess();
+ tess->crease_angle = group.options.crease_angle;
PRCTessFace *tessFace = new PRCTessFace();
tessFace->used_entities_flag=PRC_FACETESSDATA_Triangle;
uint32_t triangles = 0;
@@ -533,6 +536,145 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
}
}
+ if(!group.quads.empty())
+ {
+ map<PRCVector3d,uint32_t> points;
+ PRC3DTess *tess = new PRC3DTess();
+ tess->crease_angle = group.options.crease_angle;
+ PRCTessFace *tessFace = new PRCTessFace();
+ tessFace->used_entities_flag=PRC_FACETESSDATA_Triangle;
+ uint32_t triangles = 0;
+
+ tessFace->is_rgba = false;
+ for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++)
+ {
+ const RGBAColour* C = qit->colours;
+ if(C[0].A != 1.0 || C[1].A != 1.0 || C[2].A != 1.0 || C[3].A != 1.0)
+ {
+ tessFace->is_rgba = true;
+ break;
+ }
+ }
+ bool same_colour = true;
+ const RGBAColour& colour = group.quads.front().colours[0];
+ for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++)
+ {
+ const RGBAColour* C = qit->colours;
+ if(colour!=C[0] || colour!=C[1] || colour!=C[2] || colour!=C[3])
+ {
+ same_colour = false;
+ break;
+ }
+ }
+
+ for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++)
+ {
+ const RGBAColour* C = qit->colours;
+ const bool degenerate = (qit->vertices[0]==qit->vertices[1]);
+ uint32_t vertex_indices[4];
+ for(size_t i = (degenerate?1:0); i < 4; ++i)
+ {
+ map<PRCVector3d,uint32_t>::const_iterator pPoint = points.find(qit->vertices[i]);
+ if(pPoint!=points.end())
+ vertex_indices[i] = pPoint->second;
+ else
+ {
+ points.insert(make_pair(qit->vertices[i],(vertex_indices[i] = tess->coordinates.size())));
+ tess->coordinates.push_back(qit->vertices[i].x);
+ tess->coordinates.push_back(qit->vertices[i].y);
+ tess->coordinates.push_back(qit->vertices[i].z);
+ }
+ }
+ if(degenerate)
+ {
+ tess->triangulated_index.push_back(vertex_indices[1]);
+ tess->triangulated_index.push_back(vertex_indices[2]);
+ tess->triangulated_index.push_back(vertex_indices[3]);
+ triangles++;
+ if(!same_colour)
+ {
+ tessFace->rgba_vertices.push_back(byte(C[1].R));
+ tessFace->rgba_vertices.push_back(byte(C[1].G));
+ tessFace->rgba_vertices.push_back(byte(C[1].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[1].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[2].R));
+ tessFace->rgba_vertices.push_back(byte(C[2].G));
+ tessFace->rgba_vertices.push_back(byte(C[2].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[2].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[3].R));
+ tessFace->rgba_vertices.push_back(byte(C[3].G));
+ tessFace->rgba_vertices.push_back(byte(C[3].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[3].A));
+ }
+ }
+ else
+ {
+ tess->triangulated_index.push_back(vertex_indices[0]);
+ tess->triangulated_index.push_back(vertex_indices[2]);
+ tess->triangulated_index.push_back(vertex_indices[3]);
+ triangles++;
+ if(!same_colour)
+ {
+ tessFace->rgba_vertices.push_back(byte(C[0].R));
+ tessFace->rgba_vertices.push_back(byte(C[0].G));
+ tessFace->rgba_vertices.push_back(byte(C[0].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[0].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[2].R));
+ tessFace->rgba_vertices.push_back(byte(C[2].G));
+ tessFace->rgba_vertices.push_back(byte(C[2].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[2].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[3].R));
+ tessFace->rgba_vertices.push_back(byte(C[3].G));
+ tessFace->rgba_vertices.push_back(byte(C[3].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[3].A));
+ }
+ tess->triangulated_index.push_back(vertex_indices[3]);
+ tess->triangulated_index.push_back(vertex_indices[1]);
+ tess->triangulated_index.push_back(vertex_indices[0]);
+ triangles++;
+ if(!same_colour)
+ {
+ tessFace->rgba_vertices.push_back(byte(C[3].R));
+ tessFace->rgba_vertices.push_back(byte(C[3].G));
+ tessFace->rgba_vertices.push_back(byte(C[3].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[3].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[1].R));
+ tessFace->rgba_vertices.push_back(byte(C[1].G));
+ tessFace->rgba_vertices.push_back(byte(C[1].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[1].A));
+
+ tessFace->rgba_vertices.push_back(byte(C[0].R));
+ tessFace->rgba_vertices.push_back(byte(C[0].G));
+ tessFace->rgba_vertices.push_back(byte(C[0].B));
+ if(tessFace->is_rgba)
+ tessFace->rgba_vertices.push_back(byte(C[0].A));
+ }
+ }
+ }
+ tessFace->sizes_triangulated.push_back(triangles);
+ tess->addTessFace(tessFace);
+ const uint32_t tess_index = add3DTess(tess);
+ PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
+ polyBrepModel->index_tessellation = tess_index;
+ polyBrepModel->is_closed = group.options.closed;
+ if(same_colour)
+ polyBrepModel->index_of_line_style = addColour(colour);
+ part_definition->addPolyBrepModel(polyBrepModel);
+ }
+
if(!group.points.empty())
{
for(PRCpointsetMap::const_iterator pit=group.points.begin(); pit!=group.points.end(); pit++)
@@ -556,6 +698,7 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
{
for(std::vector<PRCPolyBrepModel*>::iterator pit=group.polymodels.begin(); pit!=group.polymodels.end(); pit++)
{
+ (*pit)->is_closed = group.options.closed;
part_definition->addPolyBrepModel(*pit);
}
}
@@ -571,7 +714,7 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
if(!group.wires.empty())
{
PRCTopoContext *wireContext = NULL;
- uint32_t context_index = getTopoContext(wireContext);
+ const uint32_t context_index = getTopoContext(wireContext);
for(PRCwireList::iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++)
{
PRCWireEdge *wireEdge = new PRCWireEdge;
@@ -593,7 +736,7 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
if(!faces.empty())
{
bool same_color = true;
- uint32_t style = faces.front().style;
+ const uint32_t style = faces.front().style;
for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++)
if(style!=fit->style)
{
@@ -664,7 +807,7 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
if(!compfaces.empty())
{
bool same_color = true;
- uint32_t style = compfaces.front().style;
+ const uint32_t style = compfaces.front().style;
for(PRCcompfaceList::const_iterator fit=compfaces.begin(); fit!=compfaces.end(); fit++)
if(style!=fit->style)
{
@@ -723,14 +866,20 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
}
}
- PRCProductOccurrence *product_occurrence = new PRCProductOccurrence(name);
-
- for(PRCgroupList::iterator it=group.groupList.begin(); it!=group.groupList.end(); it++)
+ // Simplify and reduce to as simple entities as possible
+ // products with named representation items can not be reduced to sets, since
+ // outside references are already set
+ bool nonamedparts = true;
+ for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
{
- doGroup(*it, part_definition, product_occurrence);
+ if (!(*it)->name.empty())
+ {
+ nonamedparts = false;
+ break;
}
-
- // Simplify and reduce to as simple entities as possible
+ }
+ lastgroupname.clear();
+ lastgroupnames.clear();
// First option - reduce to one element in parent
if (parent_part_definition && product_occurrence->index_son_occurrence.empty() &&
part_definition->representation_item.size() == 1 &&
@@ -741,32 +890,52 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
part_definition->representation_item.front()->name = name;
if(part_definition->representation_item.front()->index_local_coordinate_system==m1)
part_definition->representation_item.front()->index_local_coordinate_system = addTransform(group.transform);
+ lastgroupname = calculate_unique_name(part_definition->representation_item.front(), parent_product_occurrence);
parent_part_definition->addRepresentationItem(part_definition->representation_item.front());
part_definition->representation_item.clear();
- delete product_occurrence;
- delete part_definition;
+ delete product_occurrence; product_occurrence = NULL;
+ delete part_definition; part_definition = NULL;
}
// Second option - reduce to a set
else if (parent_part_definition && product_occurrence->index_son_occurrence.empty() &&
!part_definition->representation_item.empty() &&
- !group.options.do_break )
+ !group.options.do_break && nonamedparts)
{
PRCSet *set = new PRCSet(name);
set->index_local_coordinate_system = addTransform(group.transform);
+ lastgroupname = calculate_unique_name(set, parent_product_occurrence);
for(PRCRepresentationItemList::iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
+ {
+ lastgroupnames.push_back(calculate_unique_name(*it, parent_product_occurrence));
set->addRepresentationItem(*it);
+ }
part_definition->representation_item.clear();
parent_part_definition->addSet(set);
- delete product_occurrence;
- delete part_definition;
+ delete product_occurrence; product_occurrence = NULL;
+ delete part_definition; part_definition = NULL;
}
// Third option - create product
else if ( !product_occurrence->index_son_occurrence.empty() || !part_definition->representation_item.empty())
{
- if (part_definition->representation_item.empty())
- delete part_definition;
+ // if everything is enclosed in one group - drop the root group
+ if (parent_product_occurrence == NULL && group.transform == NULL &&
+ part_definition->representation_item.empty() && product_occurrence->index_son_occurrence.size()==1) {
+ delete part_definition; part_definition = NULL;
+ delete product_occurrence; product_occurrence = NULL;
+ }
else
+ {
+ lastgroupname = calculate_unique_name(product_occurrence, NULL);
+ if (part_definition->representation_item.empty()) {
+ delete part_definition; part_definition = NULL;
+ }
+ else
+ {
+ for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
+ if ((*it)->name.empty())
+ lastgroupnames.push_back(calculate_unique_name(*it, product_occurrence));
product_occurrence->index_part = addPartDefinition(part_definition);
+ }
if (group.transform) {
product_occurrence->location = group.transform;
group.transform = NULL;
@@ -778,19 +947,61 @@ void oPRCFile::doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definitio
addProductOccurrence(product_occurrence);
}
}
+ }
// Last case - absolutely nothing to do
else
{
- delete product_occurrence;
- delete part_definition;
+ delete product_occurrence; product_occurrence = NULL;
+ delete part_definition; part_definition = NULL;
}
}
+std::string oPRCFile::calculate_unique_name(const ContentPRCBase *prc_entity,const ContentPRCBase *prc_occurence)
+{
+ std::stringstream ss (std::stringstream::in | std::stringstream::out);
+ uint8_t *serialization_buffer = NULL;
+ PRCbitStream serialization(serialization_buffer,0u);
+ const PRCFileStructure *pfile_structure = fileStructures[0];
+ const PRCUniqueId& uuid = pfile_structure->file_structure_uuid;
+// ConvertUniqueIdentifierToString (prc_entity)
+// SerializeCompressedUniqueId (file_structure)
+ serialization << uuid.id0 << uuid.id1 << uuid.id2 << uuid.id3;
+// WriteUnsignedInteger (type)
+ serialization << prc_entity->getType();
+// WriteUnsignedInteger (unique_identifier)
+ serialization << prc_entity->getPRCID();
+ if (prc_occurence)
+ {
+// serialization_buffer = Flush serialization (serialization)
+ {
+ const uint32_t size_serialization = serialization.getSize();
+ while(size_serialization == serialization.getSize())
+ serialization << false;
+ }
+// ConvertUniqueIdentifierToString (prc_occurrence_unique_id)
+// SerializeCompressedUniqueId (file_structure)
+ serialization << uuid.id0 << uuid.id1 << uuid.id2 << uuid.id3;
+// WriteUnsignedInteger (type)
+ serialization << (uint32_t)PRC_TYPE_ASM_ProductOccurence;
+// WriteUnsignedInteger (unique_identifier)
+ serialization << prc_occurence->getPRCID();
+ }
+ ss << (prc_entity->name.empty()?"node":prc_entity->name) << '.';
+ const uint32_t size_serialization = serialization.getSize();
+ for(size_t j=0; j<size_serialization; j++)
+ ss << hex << setfill('0') << setw(2) << (uint32_t)(serialization_buffer[j]);
+
+ return ss.str();
+}
+
bool oPRCFile::finish()
{
- rootGroup.name = "root";
- doGroup(rootGroup, NULL, NULL);
+ if(groups.size()!=1) {
+ fputs("begingroup without matching endgroup",stderr);
+ exit(1);
+ }
+ doGroup(groups.top());
// write each section's bit data
fileStructures[0]->prepare();
@@ -861,22 +1072,40 @@ uint32_t oPRCFile::getSize()
uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *p, uint32_t width, uint32_t height, string name)
{
+ uint8_t *data = NULL;
+ uint32_t components=0;
+ PRCPicture picture(name);
if(size==0 || p==NULL)
{ cerr << "image not set" << endl; return m1; }
- PRCPicture picture(name);
PRCUncompressedFile* uncompressed_file = new PRCUncompressedFile;
- uint32_t components=0;
- uint8_t *data = NULL;
+ if(format==KEPRCPicture_PNG || format==KEPRCPicture_JPG)
+ {
+ data = new uint8_t[size];
+ memcpy(data, p, size);
+ uncompressed_files.push_back(uncompressed_file);
+ uncompressed_files.back()->file_size = size;
+ uncompressed_files.back()->data = data;
+ picture.format = format;
+ picture.uncompressed_file_index = uncompressed_files.size()-1;
+ picture.pixel_width = 0; // width and height are ignored for JPG and PNG pictures - but let us keep things clean
+ picture.pixel_height = 0;
+ pictures.push_back(picture);
+ return pictures.size()-1;
+ }
+
switch(format)
{
case KEPRCPicture_BITMAP_RGB_BYTE:
- components = 3;
+ components = 3; break;
case KEPRCPicture_BITMAP_RGBA_BYTE:
- components = 4;
+ components = 4; break;
case KEPRCPicture_BITMAP_GREY_BYTE:
- components = 1;
+ components = 1; break;
case KEPRCPicture_BITMAP_GREYA_BYTE:
- components = 2;
+ components = 2; break;
+ default:
+ { cerr << "unknown picture format" << endl; return m1; }
+ }
if(width==0 || height==0)
{ cerr << "width or height parameter not set" << endl; return m1; }
if (size < width*height*components)
@@ -935,27 +1164,6 @@ uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t siz
picture.pixel_height = height;
pictures.push_back(picture);
return pictures.size()-1;
- break;
-
- case KEPRCPicture_PNG:
- case KEPRCPicture_JPG:
- data = new uint8_t[size];
- memcpy(data, p, size);
- uncompressed_files.push_back(uncompressed_file);
- uncompressed_files.back()->file_size = size;
- uncompressed_files.back()->data = data;
- picture.format = format;
- picture.uncompressed_file_index = uncompressed_files.size()-1;
- picture.pixel_width = 0; // width and height are ignored for JPG and PNG pictures - but let us keep things clean
- picture.pixel_height = 0;
- pictures.push_back(picture);
- return pictures.size()-1;
- break;
-
- default:
- { cerr << "unknown picture format" << endl; return m1; }
- }
- return m1;
}
uint32_t PRCFileStructure::addTextureDefinition(PRCTextureDefinition*& pTextureDefinition)
@@ -985,11 +1193,10 @@ uint32_t PRCFileStructure::addRgbColorUnique(const PRCRgbColor &color)
uint32_t oPRCFile::addColor(const PRCRgbColor &color)
{
PRCcolorMap::const_iterator pColor = colorMap.find(color);
- uint32_t color_index = m1;
if(pColor!=colorMap.end())
return pColor->second;
// color_index = addRgbColorUnique(color);
- color_index = fileStructures[0]->addRgbColor(color);
+ const uint32_t color_index = fileStructures[0]->addRgbColor(color);
colorMap.insert(make_pair(color,color_index));
return color_index;
}
@@ -1043,106 +1250,213 @@ uint32_t oPRCFile::addTransform(PRCGeneralTransformation3d*& transform)
if(pTransform!=transformMap.end())
return pTransform->second;
PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem();
+ bool transform_replaced = false;
+ if( transform->M(0,1)==0 && transform->M(0,2)==0 &&
+ transform->M(1,0)==0 && transform->M(1,2)==0 &&
+ transform->M(2,0)==0 && transform->M(2,1)==0 &&
+ transform->M(3,0)==0 && transform->M(3,1)==0 && transform->M(3,2)==0 && transform->M(3,3)==1 )
+ {
+ transform_replaced = true;
+ PRCCartesianTransformation3d *carttransform = new PRCCartesianTransformation3d;
+// if(transform->M(0,3)==0 && transform->M(1,3)==0 && transform->M(1,3)==0 &&
+// transform->M(0,0)==1 && transform->M(1,1)==1 && transform->M(2,2)==1 )
+// carttransform->behaviour = PRC_TRANSFORMATION_Identity;
+ if(transform->M(0,3)!=0 || transform->M(1,3)!=0 || transform->M(2,3)!=0)
+ {
+ carttransform->behaviour |= PRC_TRANSFORMATION_Translate;
+ carttransform->origin.Set(transform->M(0,3),transform->M(1,3),transform->M(2,3));
+ }
+ if(transform->M(0,0)!=transform->M(1,1) || transform->M(0,0)!=transform->M(2,2))
+ {
+ carttransform->behaviour |= PRC_TRANSFORMATION_NonUniformScale;
+ carttransform->scale.Set(transform->M(0,0),transform->M(1,1),transform->M(2,2));
+ }
+ else
+ if(transform->M(0,0)!=1)
+ {
+ carttransform->behaviour |= PRC_TRANSFORMATION_Scale;
+ carttransform->uniform_scale=transform->M(0,0);
+ }
+ coordinateSystem->axis_set = carttransform;
+ }
+ else
coordinateSystem->axis_set = transform;
const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem);
transformMap.insert(make_pair(*transform,coordinate_system_index));
+ if(transform_replaced)
+ delete transform;
transform = NULL;
return coordinate_system_index;
}
-uint32_t oPRCFile::addMaterial(const PRCmaterial &material)
+uint32_t oPRCFile::addTransform(const double* t)
+{
+ if(!t)
+ return m1;
+ PRCGeneralTransformation3d* transform = new PRCGeneralTransformation3d(t);
+ return addTransform(transform);
+}
+
+uint32_t oPRCFile::addTransform(const double origin[3], const double x_axis[3], const double y_axis[3], double scale)
+{
+ PRCCartesianTransformation3d* transform = new PRCCartesianTransformation3d(origin, x_axis, y_axis, scale);
+ if(transform->behaviour==PRC_TRANSFORMATION_Identity)
+ return m1;
+ PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem();
+ coordinateSystem->axis_set = transform;
+ const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem);
+ return coordinate_system_index;
+}
+
+uint32_t oPRCFile::addMaterial(const PRCmaterial& m)
+{
+ uint32_t material_index = m1;
+ const PRCmaterialgeneric materialgeneric(m);
+ PRCmaterialgenericMap::const_iterator pMaterialgeneric = materialgenericMap.find(materialgeneric);
+ if(pMaterialgeneric!=materialgenericMap.end())
+ material_index = pMaterialgeneric->second;
+ else
{
- PRCmaterialMap::const_iterator pMaterial = materialMap.find(material);
- if(pMaterial!=materialMap.end())
- return pMaterial->second;
PRCMaterialGeneric *materialGeneric = new PRCMaterialGeneric();
- const PRCRgbColor ambient(material.ambient.R, material.ambient.G, material.ambient.B);
+ const PRCRgbColor ambient(m.ambient.R, m.ambient.G, m.ambient.B);
materialGeneric->ambient = addColor(ambient);
- const PRCRgbColor diffuse(material.diffuse.R, material.diffuse.G, material.diffuse.B);
+ const PRCRgbColor diffuse(m.diffuse.R, m.diffuse.G, m.diffuse.B);
materialGeneric->diffuse = addColor(diffuse);
- const PRCRgbColor emissive(material.emissive.R, material.emissive.G, material.emissive.B);
+ const PRCRgbColor emissive(m.emissive.R, m.emissive.G, m.emissive.B);
+
materialGeneric->emissive = addColor(emissive);
- const PRCRgbColor specular(material.specular.R, material.specular.G, material.specular.B);
+ const PRCRgbColor specular(m.specular.R, m.specular.G, m.specular.B);
materialGeneric->specular = addColor(specular);
- materialGeneric->shininess = material.shininess;
- materialGeneric->ambient_alpha = material.ambient.A;
- materialGeneric->diffuse_alpha = material.diffuse.A;
- materialGeneric->emissive_alpha = material.emissive.A;
- materialGeneric->specular_alpha = material.specular.A;
- const uint32_t material_index = addMaterialGeneric(materialGeneric);
- PRCStyle *style = new PRCStyle();
- style->line_width = 0.0;
- style->is_vpicture = false;
- style->line_pattern_vpicture_index = 0;
- style->is_material = true;
- style->is_transparency_defined = (material.alpha < 1.0);
- style->transparency = (uint8_t)(material.alpha * 256);
- style->additional = 0;
- if(material.picture!=NULL && material.picture_width!=0 && material.picture_height!=0)
+
+ materialGeneric->shininess = m.shininess;
+ materialGeneric->ambient_alpha = m.ambient.A;
+ materialGeneric->diffuse_alpha = m.diffuse.A;
+ materialGeneric->emissive_alpha = m.emissive.A;
+ materialGeneric->specular_alpha = m.specular.A;
+ material_index = addMaterialGeneric(materialGeneric);
+ materialgenericMap.insert(make_pair(materialgeneric,material_index));
+ }
+ uint32_t color_material_index = m1;
+ if(m.picture_data!=NULL)
{
- const uint32_t picture_index =
- addPicture((material.picture_rgba?KEPRCPicture_BITMAP_RGBA_BYTE:KEPRCPicture_BITMAP_RGB_BYTE),
- material.picture_width*material.picture_height*(material.picture_rgba?4:3),material.picture,material.picture_width,material.picture_height);
- PRCTextureDefinition *textureDefinition = new PRCTextureDefinition;
- textureDefinition->picture_index = picture_index;
- textureDefinition->texture_function = material.picture_replace ? KEPRCTextureFunction_Replace : KEPRCTextureFunction_Modulate;
- textureDefinition->texture_wrapping_mode_S = KEPRCTextureWrappingMode_ClampToEdge;
- textureDefinition->texture_wrapping_mode_T = KEPRCTextureWrappingMode_ClampToEdge;
- textureDefinition->texture_mapping_attribute_components = material.picture_rgba ? PRC_TEXTURE_MAPPING_COMPONENTS_RGBA : PRC_TEXTURE_MAPPING_COMPONENTS_RGB;
- const uint32_t texture_definition_index = addTextureDefinition(textureDefinition);
- PRCTextureApplication *textureApplication = new PRCTextureApplication;
- textureApplication->material_generic_index = material_index;
- textureApplication->texture_definition_index = texture_definition_index;
- const uint32_t texture_application_index = addTextureApplication(textureApplication);
- style->color_material_index = texture_application_index;
+ uint32_t picture_index = m1;
+ PRCpicture picture(m);
+ PRCpictureMap::const_iterator pPicture = pictureMap.find(picture);
+ if(pPicture!=pictureMap.end())
+ picture_index = pPicture->second;
+ else
+ {
+ picture_index = addPicture(picture);
+ uint8_t* data = new uint8_t[picture.size];
+ memcpy(data,picture.data,picture.size);
+ picture.data = data;
+ pictureMap.insert(make_pair(picture,picture_index));
+ }
+
+ uint32_t texture_definition_index = m1;
+ PRCtexturedefinition texturedefinition(picture_index, m);
+ PRCtexturedefinitionMap::const_iterator pTexturedefinition = texturedefinitionMap.find(texturedefinition);
+ if(pTexturedefinition!=texturedefinitionMap.end())
+ texture_definition_index = pTexturedefinition->second;
+ else
+ {
+ PRCTextureDefinition *TextureDefinition = new PRCTextureDefinition;
+ if (m.picture_size==216688 && m.picture_format==KEPRCPicture_JPG)
+ TextureDefinition->texture_mapping_attribute=PRC_TEXTURE_MAPPING_OPACITY;
+ TextureDefinition->picture_index = picture_index;
+ TextureDefinition->texture_function = m.picture_replace ? KEPRCTextureFunction_Replace : KEPRCTextureFunction_Modulate;
+ TextureDefinition->texture_wrapping_mode_S = m.picture_repeat ? KEPRCTextureWrappingMode_Repeat : KEPRCTextureWrappingMode_ClampToEdge;
+ TextureDefinition->texture_wrapping_mode_T = m.picture_repeat ? KEPRCTextureWrappingMode_Repeat : KEPRCTextureWrappingMode_ClampToEdge;
+ TextureDefinition->texture_mapping_attribute_components = (m.picture_format==KEPRCPicture_BITMAP_RGB_BYTE || m.picture_format==KEPRCPicture_JPG) ? PRC_TEXTURE_MAPPING_COMPONENTS_RGB : PRC_TEXTURE_MAPPING_COMPONENTS_RGBA;
+ texture_definition_index = addTextureDefinition(TextureDefinition);
+ texturedefinitionMap.insert(make_pair(texturedefinition,texture_definition_index));
+ }
+
+ uint32_t texture_application_index = m1;
+ const PRCtextureapplication textureapplication(material_index, texture_definition_index);
+ PRCtextureapplicationMap::const_iterator pTextureapplication = textureapplicationMap.find(textureapplication);
+ if(pTextureapplication!=textureapplicationMap.end())
+ texture_application_index = pTextureapplication->second;
+ else
+ {
+ PRCTextureApplication *TextureApplication = new PRCTextureApplication;
+ TextureApplication->material_generic_index = material_index;
+ TextureApplication->texture_definition_index = texture_definition_index;
+ texture_application_index = addTextureApplication(TextureApplication);
+ textureapplicationMap.insert(make_pair(textureapplication,texture_application_index));
+ }
+
+ color_material_index = texture_application_index;
}
else
- style->color_material_index = material_index;
- const uint32_t style_index = addStyle(style);
- materialMap.insert(make_pair(material,style_index));
- return style_index;
-}
+ color_material_index = material_index;
-bool isid(const double t[][4])
-{
- 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);
+ uint32_t style_index = m1;
+ PRCstyle style(0,m.alpha,true,color_material_index);
+ PRCstyleMap::const_iterator pStyle = styleMap.find(style);
+ if(pStyle!=styleMap.end())
+ style_index = pStyle->second;
+ else
+ {
+ PRCStyle *Style = new PRCStyle();
+ Style->line_width = 0.0;
+ Style->is_vpicture = false;
+ Style->line_pattern_vpicture_index = 0;
+ Style->is_material = true;
+ Style->is_transparency_defined = (m.alpha < 1.0);
+ Style->transparency = (uint8_t)(m.alpha * 256);
+ Style->additional = 0;
+ Style->color_material_index = color_material_index;
+ style_index = addStyle(Style);
+ styleMap.insert(make_pair(style,style_index));
+ }
+// materialMap.insert(make_pair(material,style_index));
+ return style_index;
}
-bool isid(const double t[])
+
+bool isid(const double* t)
{
- return(isid((double (*)[4])t));
+ return(
+ t[0]==1 && t[4]==0 && t[ 8]==0 && t[12]==0 &&
+ t[1]==0 && t[5]==1 && t[ 9]==0 && t[13]==0 &&
+ t[2]==0 && t[6]==0 && t[10]==1 && t[14]==0 &&
+ t[3]==0 && t[7]==0 && t[11]==0 && t[15]==1 );
}
-
void oPRCFile::begingroup(const char *name, PRCoptions *options,
- const double t[][4])
+ const double* t)
{
- if(currentGroups.empty())
- currentGroups.push(rootGroup.groupList.insert(rootGroup.groupList.end(),PRCgroup()));
- else
- currentGroups.push(currentGroups.top()->groupList.insert(currentGroups.top()->groupList.end(),PRCgroup()));
- PRCgroup &group = *(currentGroups.top());
+ const PRCgroup &parent_group = groups.top();
+ groups.push(PRCgroup());
+ PRCgroup &group = groups.top();
group.name=name;
if(options) group.options=*options;
if(t&&!isid(t))
group.transform = new PRCGeneralTransformation3d(t);
+ group.product_occurrence = new PRCProductOccurrence(name);
+ group.parent_product_occurrence = parent_group.product_occurrence;
+ group.part_definition = new PRCPartDefinition;
+ group.parent_part_definition = parent_group.part_definition;
}
void oPRCFile::endgroup()
{
- if(!currentGroups.empty())
- currentGroups.pop();
+ if(groups.size()<2) {
+ fputs("begingroup without matching endgroup",stderr);
+ exit(1);
+ }
+ doGroup(groups.top());
+ groups.pop();
+
+// std::cout << lastgroupname << std::endl;
+// for(std::vector<std::string>::const_iterator it=lastgroupnames.begin(); it!=lastgroupnames.end(); it++)
+// std::cout << " " << *it << std::endl;
+
}
PRCgroup& oPRCFile::findGroup()
{
- if(!currentGroups.empty())
- return *(currentGroups.top());
- else
- return rootGroup;
+ return groups.top();
}
#define ADDWIRE(curvtype) \
@@ -1186,21 +1500,75 @@ void oPRCFile::addPoints(uint32_t n, const double P[][3], const RGBAColour &c, d
PRCPointSet *pointset = new PRCPointSet();
group.pointsets.push_back(pointset);
pointset->index_of_line_style = addColourWidth(c,w);
+ pointset->point.reserve(n);
for(uint32_t i=0; i<n; i++)
pointset->point.push_back(PRCVector3d(P[i][0],P[i][1],P[i][2]));
}
+void oPRCFile::useMesh(uint32_t tess_index, uint32_t style_index, const double origin[3], const double x_axis[3], const double y_axis[3], double scale)
+{
+ PRCgroup &group = findGroup();
+ PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
+ polyBrepModel->index_local_coordinate_system = addTransform(origin, x_axis, y_axis, scale);
+ polyBrepModel->index_tessellation = tess_index;
+ polyBrepModel->is_closed = group.options.closed;
+ polyBrepModel->index_of_line_style = style_index;
+ group.polymodels.push_back(polyBrepModel);
+}
+
+void oPRCFile::useMesh(uint32_t tess_index, uint32_t style_index, const double* t)
+{
+ PRCgroup &group = findGroup();
+ PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
+ polyBrepModel->index_local_coordinate_system = addTransform(t);
+ polyBrepModel->index_tessellation = tess_index;
+ polyBrepModel->is_closed = group.options.closed;
+ polyBrepModel->index_of_line_style = style_index;
+ group.polymodels.push_back(polyBrepModel);
+}
+
+void oPRCFile::useLines(uint32_t tess_index, uint32_t style_index, const double origin[3], const double x_axis[3], const double y_axis[3], double scale)
+{
+ PRCgroup &group = findGroup();
+ PRCPolyWire *polyWire = new PRCPolyWire();
+ polyWire->index_local_coordinate_system = addTransform(origin, x_axis, y_axis, scale);
+ polyWire->index_tessellation = tess_index;
+ polyWire->index_of_line_style = style_index;
+ group.polywires.push_back(polyWire);
+}
+
+void oPRCFile::useLines(uint32_t tess_index, uint32_t style_index, const double* t)
+{
+ PRCgroup &group = findGroup();
+ PRCPolyWire *polyWire = new PRCPolyWire();
+ polyWire->index_local_coordinate_system = addTransform(t);
+ polyWire->index_tessellation = tess_index;
+ polyWire->index_of_line_style = style_index;
+ group.polywires.push_back(polyWire);
+}
+
void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial &m,
uint32_t nN, const double N[][3], const uint32_t NI[][3],
uint32_t nT, const double T[][2], const uint32_t TI[][3],
uint32_t nC, const RGBAColour C[], const uint32_t CI[][3],
- uint32_t nM, const PRCmaterial M[], const uint32_t MI[])
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca)
{
if(nP==0 || P==NULL || nI==0 || PI==NULL)
return;
- PRCgroup &group = findGroup();
+ const uint32_t tess_index = createTriangleMesh(nP, P, nI, PI, m, nN, N, NI, nT, T, TI, nC, C, CI, nM, M, MI, ca);
+ useMesh(tess_index,m1);
+}
- const bool triangle_color = (nM != 0 && M != NULL && MI != NULL);
+uint32_t oPRCFile::createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const uint32_t style_index,
+ uint32_t nN, const double N[][3], const uint32_t NI[][3],
+ uint32_t nT, const double T[][2], const uint32_t TI[][3],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][3],
+ uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca)
+{
+ if(nP==0 || P==NULL || nI==0 || PI==NULL)
+ return m1;
+
+ const bool triangle_color = (nS != 0 && S != NULL && SI != NULL);
const bool vertex_color = (nC != 0 && C != NULL && CI != NULL);
const bool has_normals = (nN != 0 && N != NULL && NI != NULL);
const bool textured = (nT != 0 && T != NULL && TI != NULL);
@@ -1209,6 +1577,7 @@ void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const
PRCTessFace *tessFace = new PRCTessFace();
tessFace->used_entities_flag = textured ? PRC_FACETESSDATA_TriangleTextured : PRC_FACETESSDATA_Triangle;
tessFace->number_of_texture_coordinate_indexes = textured ? 1 : 0;
+ tess->coordinates.reserve(3*nP);
for(uint32_t i=0; i<nP; i++)
{
tess->coordinates.push_back(P[i][0]);
@@ -1216,18 +1585,27 @@ void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const
tess->coordinates.push_back(P[i][2]);
}
if(has_normals)
+ {
+ tess->normal_coordinate.reserve(3*nN);
for(uint32_t i=0; i<nN; i++)
{
tess->normal_coordinate.push_back(N[i][0]);
tess->normal_coordinate.push_back(N[i][1]);
tess->normal_coordinate.push_back(N[i][2]);
}
+ }
+ else
+ tess->crease_angle = ca;
if(textured)
+ {
+ tess->texture_coordinate.reserve(2*nT);
for(uint32_t i=0; i<nT; i++)
{
tess->texture_coordinate.push_back(T[i][0]);
tess->texture_coordinate.push_back(T[i][1]);
}
+ }
+ tess->triangulated_index.reserve(3*nI+(has_normals?3:0)*nI+(textured?3:0)*nI);
for(uint32_t i=0; i<nI; i++)
{
if(has_normals)
@@ -1249,18 +1627,14 @@ void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const
tessFace->sizes_triangulated.push_back(nI);
if(triangle_color)
{
-#ifdef __GNUC__
- uint32_t styles[nM];
-#else
- std::vector<uint32_t> styles(nM);
-#endif
- for(uint32_t i=0; i<nM; i++)
- styles[i] = addMaterial(M[i]);
+ tessFace->line_attributes.reserve(nI);
for(uint32_t i=0; i<nI; i++)
- tessFace->line_attributes.push_back(styles[MI[i]]);
+ tessFace->line_attributes.push_back(SI[i]);
+ }
+ else if (style_index != m1 )
+ {
+ tessFace->line_attributes.push_back(style_index);
}
- else
- tessFace->line_attributes.push_back(addMaterial(m));
if(vertex_color)
{
tessFace->is_rgba=false;
@@ -1271,6 +1645,7 @@ void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const
break;
}
+ tessFace->rgba_vertices.reserve((tessFace->is_rgba?4:3)*3*nI);
for(uint32_t i=0; i<nI; i++)
{
tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].R));
@@ -1292,25 +1667,31 @@ void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const
}
tess->addTessFace(tessFace);
const uint32_t tess_index = add3DTess(tess);
- PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
- polyBrepModel->index_tessellation = tess_index;
- polyBrepModel->is_closed = group.options.closed;
-// if(!triangle_color)
-// polyBrepModel->index_of_line_style = addMaterial(m);
- group.polymodels.push_back(polyBrepModel);
+ return tess_index;
}
void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], const PRCmaterial &m,
uint32_t nN, const double N[][3], const uint32_t NI[][4],
uint32_t nT, const double T[][2], const uint32_t TI[][4],
uint32_t nC, const RGBAColour C[], const uint32_t CI[][4],
- uint32_t nM, const PRCmaterial M[], const uint32_t MI[])
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca)
{
if(nP==0 || P==NULL || nI==0 || PI==NULL)
return;
- PRCgroup &group = findGroup();
+ const uint32_t tess_index = createQuadMesh(nP, P, nI, PI, m, nN, N, NI, nT, T, TI, nC, C, CI, nM, M, MI, ca);
+ useMesh(tess_index,m1);
+}
- const bool triangle_color = (nM != 0 && M != NULL && MI != NULL);
+uint32_t oPRCFile::createQuadMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], uint32_t style_index,
+ uint32_t nN, const double N[][3], const uint32_t NI[][4],
+ uint32_t nT, const double T[][2], const uint32_t TI[][4],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][4],
+ uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca)
+{
+ if(nP==0 || P==NULL || nI==0 || PI==NULL)
+ return m1;
+
+ const bool triangle_color = (nS != 0 && S != NULL && SI != NULL);
const bool vertex_color = (nC != 0 && C != NULL && CI != NULL);
const bool has_normals = (nN != 0 && N != NULL && NI != NULL);
const bool textured = (nT != 0 && T != NULL && TI != NULL);
@@ -1319,6 +1700,7 @@ void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uin
PRCTessFace *tessFace = new PRCTessFace();
tessFace->used_entities_flag = textured ? PRC_FACETESSDATA_TriangleTextured : PRC_FACETESSDATA_Triangle;
tessFace->number_of_texture_coordinate_indexes = textured ? 1 : 0;
+ tess->coordinates.reserve(3*nP);
for(uint32_t i=0; i<nP; i++)
{
tess->coordinates.push_back(P[i][0]);
@@ -1326,18 +1708,27 @@ void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uin
tess->coordinates.push_back(P[i][2]);
}
if(has_normals)
+ {
+ tess->normal_coordinate.reserve(3*nN);
for(uint32_t i=0; i<nN; i++)
{
tess->normal_coordinate.push_back(N[i][0]);
tess->normal_coordinate.push_back(N[i][1]);
tess->normal_coordinate.push_back(N[i][2]);
}
+ }
+ else
+ tess->crease_angle = ca;
if(textured)
+ {
+ tess->texture_coordinate.reserve(2*nT);
for(uint32_t i=0; i<nT; i++)
{
tess->texture_coordinate.push_back(T[i][0]);
tess->texture_coordinate.push_back(T[i][1]);
}
+ }
+ tess->triangulated_index.reserve(2*(3*nI+(has_normals?3:0)*nI+(textured?3:0)*nI));
for(uint32_t i=0; i<nI; i++)
{
// first triangle
@@ -1376,21 +1767,17 @@ void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uin
tessFace->sizes_triangulated.push_back(2*nI);
if(triangle_color)
{
-#ifdef __GNUC__
- uint32_t styles[nM];
-#else
- std::vector<uint32_t> styles(nM);
-#endif
- for(uint32_t i=0; i<nM; i++)
- styles[i] = addMaterial(M[i]);
+ tessFace->line_attributes.reserve(2*nI);
for(uint32_t i=0; i<nI; i++)
{
- tessFace->line_attributes.push_back(styles[MI[i]]);
- tessFace->line_attributes.push_back(styles[MI[i]]);
+ tessFace->line_attributes.push_back(SI[i]);
+ tessFace->line_attributes.push_back(SI[i]);
}
}
else
- tessFace->line_attributes.push_back(addMaterial(m));
+ {
+ tessFace->line_attributes.push_back(style_index);
+ }
if(vertex_color)
{
tessFace->is_rgba=false;
@@ -1401,6 +1788,7 @@ void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uin
break;
}
+ tessFace->rgba_vertices.reserve(2*(tessFace->is_rgba?4:3)*3*nI);
for(uint32_t i=0; i<nI; i++)
{
// first triangle
@@ -1439,105 +1827,69 @@ void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uin
}
tess->addTessFace(tessFace);
const uint32_t tess_index = add3DTess(tess);
- PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
- polyBrepModel->index_tessellation = tess_index;
- polyBrepModel->is_closed = group.options.closed;
-// if(!triangle_color)
-// polyBrepModel->index_of_line_style = addMaterial(m);
- group.polymodels.push_back(polyBrepModel);
+ return tess_index;
}
void oPRCFile::addQuad(const double P[][3], const RGBAColour C[])
{
PRCgroup &group = findGroup();
- PRC3DTess *tess = new PRC3DTess();
- PRCTessFace *tessFace = new PRCTessFace();
- tessFace->used_entities_flag = PRC_FACETESSDATA_Triangle;
- tessFace->number_of_texture_coordinate_indexes = 0;
- for(uint32_t i=0; i < 4; i++)
+ group.quads.push_back(PRCtessquad());
+ PRCtessquad &quad = group.quads.back();
+ for(size_t i = 0; i < 4; i++)
{
- tess->coordinates.push_back(P[i][0]);
- tess->coordinates.push_back(P[i][1]);
- tess->coordinates.push_back(P[i][2]);
+ quad.vertices[i].x = P[i][0];
+ quad.vertices[i].y = P[i][1];
+ quad.vertices[i].z = P[i][2];
+ quad.colours[i] = C[i];
}
+}
+/*
+void oPRCFile::addTriangle(const double P[][3], const double T[][2], uint32_t style_index)
+{
+ PRCgroup &group = findGroup();
- tess->triangulated_index.push_back(3*0);
- tess->triangulated_index.push_back(3*1);
- tess->triangulated_index.push_back(3*2);
-
- tess->triangulated_index.push_back(3*1);
- tess->triangulated_index.push_back(3*3);
- tess->triangulated_index.push_back(3*2);
-
- tessFace->sizes_triangulated.push_back(2);
-
- tessFace->is_rgba=
- (C[0].A != 1.0 || C[1].A != 1.0 || C[2].A != 1.0 || C[3].A != 1.0);
-
- // first triangle
- tessFace->rgba_vertices.push_back(byte(C[0].R));
- tessFace->rgba_vertices.push_back(byte(C[0].G));
- tessFace->rgba_vertices.push_back(byte(C[0].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[0].A));
-
- tessFace->rgba_vertices.push_back(byte(C[1].R));
- tessFace->rgba_vertices.push_back(byte(C[1].G));
- tessFace->rgba_vertices.push_back(byte(C[1].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[1].A));
-
- tessFace->rgba_vertices.push_back(byte(C[2].R));
- tessFace->rgba_vertices.push_back(byte(C[2].G));
- tessFace->rgba_vertices.push_back(byte(C[2].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[2].A));
-
- // second triangle
- tessFace->rgba_vertices.push_back(byte(C[1].R));
- tessFace->rgba_vertices.push_back(byte(C[1].G));
- tessFace->rgba_vertices.push_back(byte(C[1].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[1].A));
-
- tessFace->rgba_vertices.push_back(byte(C[3].R));
- tessFace->rgba_vertices.push_back(byte(C[3].G));
- tessFace->rgba_vertices.push_back(byte(C[3].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[3].A));
-
- tessFace->rgba_vertices.push_back(byte(C[2].R));
- tessFace->rgba_vertices.push_back(byte(C[2].G));
- tessFace->rgba_vertices.push_back(byte(C[2].B));
- if(tessFace->is_rgba)
- tessFace->rgba_vertices.push_back(byte(C[2].A));
-
- tess->addTessFace(tessFace);
- const uint32_t tess_index = add3DTess(tess);
- PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel();
- polyBrepModel->index_tessellation = tess_index;
- polyBrepModel->is_closed = group.options.closed;
- group.polymodels.push_back(polyBrepModel);
+ group.triangles.push_back(PRCtesstriangle());
+ PRCtesstriangle &triangle = group.triangles.back();
+ for(size_t i = 0; i < 3; i++)
+ {
+ triangle.vertices[i].x = P[i][0];
+ triangle.vertices[i].y = P[i][1];
+ triangle.vertices[i].z = P[i][2];
+ triangle.texcoords[i].x = T[i][0];
+ triangle.texcoords[i].y = T[i][1];
+ }
+ triangle.style = style_index;
}
+*/
void oPRCFile::addLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[],
- const RGBAColour &c, double w, bool segment_color,
- uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[])
+ const RGBAColour& c, double w,
+ bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[])
{
if(nP==0 || P==NULL || nI==0 || PI==NULL)
return;
+ const uint32_t tess_index = createLines(nP, P, nI, PI, segment_color, nC, C, nCI, CI);
+ useLines(tess_index, c, w);
+}
+
+uint32_t oPRCFile::createLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[],
+ bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[])
+{
+ if(nP==0 || P==NULL || nI==0 || PI==NULL)
+ return m1;
const bool vertex_color = (nC != 0 && C != NULL && CI != NULL);
- PRCgroup &group = findGroup();
PRC3DWireTess *tess = new PRC3DWireTess();
+ tess->coordinates.reserve(3*nP);
for(uint32_t i=0; i<nP; i++)
{
tess->coordinates.push_back(P[i][0]);
tess->coordinates.push_back(P[i][1]);
tess->coordinates.push_back(P[i][2]);
}
+ tess->wire_indexes.reserve(nI);
for(uint32_t i=0; i<nI;)
{
tess->wire_indexes.push_back(PI[i]);
@@ -1555,7 +1907,7 @@ void oPRCFile::addLines(uint32_t nP, const double P[][3], uint32_t nI, const uin
tess->is_rgba=true;
break;
}
-
+ tess->rgba_vertices.reserve((tess->is_rgba?4:3)*nCI);
for(uint32_t i=0; i<nCI; i++)
{
tess->rgba_vertices.push_back(byte(C[CI[i]].R));
@@ -1566,13 +1918,7 @@ void oPRCFile::addLines(uint32_t nP, const double P[][3], uint32_t nI, const uin
}
}
const uint32_t tess_index = add3DWireTess(tess);
- PRCPolyWire *polyWire = new PRCPolyWire();
- polyWire->index_tessellation = tess_index;
- if(vertex_color)
- polyWire->index_of_line_style = addColourWidth(RGBAColour(1,1,1),w);
- else
- polyWire->index_of_line_style = addColourWidth(c,w);
- group.polywires.push_back(polyWire);
+ return tess_index;
}
void oPRCFile::addLine(uint32_t n, const double P[][3], const RGBAColour &c, double w)
@@ -1637,7 +1983,6 @@ void oPRCFile::addRectangle(const double P[][3], const PRCmaterial &m)
PRCgroup &group = findGroup();
if(group.options.tess)
{
- PRCgroup &group = findGroup();
group.rectangles.push_back(PRCtessrectangle());
PRCtessrectangle &rectangle = group.rectangles.back();
rectangle.style = addMaterial(m);
@@ -1755,15 +2100,15 @@ void oPRCFile::addSurface(uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
if(y_axis) surface->y_axis.Set(y_axis[0],y_axis[1],y_axis[2]); \
surface->scale = scale; \
surface->geometry_is_2D = false; \
- if(surface->origin!=PRCVector3d(0,0,0)) \
+ if(surface->origin!=PRCVector3d(0.0,0.0,0.0)) \
surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Translate; \
- if(surface->x_axis!=PRCVector3d(1,0,0)||surface->y_axis!=PRCVector3d(0,1,0)) \
+ if(surface->x_axis!=PRCVector3d(1.0,0.0,0.0)||surface->y_axis!=PRCVector3d(0.0,1.0,0.0)) \
surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Rotate; \
if(surface->scale!=1) \
surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Scale; \
surface->has_transformation = (surface->behaviour != PRC_TRANSFORMATION_Identity);
-#define PRCFACETRANSFORM const double origin[3], const double x_axis[3], const double y_axis[3], double scale, const double t[][4]
+#define PRCFACETRANSFORM const double origin[3], const double x_axis[3], const double y_axis[3], double scale, const double* t
void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial &m, PRCFACETRANSFORM)
{
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.h b/Build/source/utils/asymptote/prc/oPRCFile.h
index 643a0ff6e44..29b7f20b880 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.h
+++ b/Build/source/utils/asymptote/prc/oPRCFile.h
@@ -25,9 +25,11 @@
#include <fstream>
#include <vector>
#include <map>
+#include <set>
#include <list>
#include <stack>
#include <string>
+#include <cstring>
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -46,6 +48,10 @@ struct RGBAColour
R(r), G(g), B(b), A(a) {}
double R,G,B,A;
+ void Set(double r, double g, double b, double a=1.0)
+ {
+ R = r; G = g; B = b; A = a;
+ }
bool operator==(const RGBAColour &c) const
{
return (R==c.R && G==c.G && B==c.B && A==c.A);
@@ -64,6 +70,11 @@ struct RGBAColour
return (B<c.B);
return (A<c.A);
}
+ friend RGBAColour operator * (const RGBAColour& a, const double d)
+ { return RGBAColour(a.R*d,a.G*d,a.B*d,a.A*d); }
+ friend RGBAColour operator * (const double d, const RGBAColour& a)
+ { return RGBAColour(a.R*d,a.G*d,a.B*d,a.A*d); }
+
};
typedef std::map<RGBAColour,uint32_t> PRCcolourMap;
@@ -101,26 +112,45 @@ typedef std::map<PRCRgbColor,uint32_t> PRCcolorMap;
struct PRCmaterial
{
PRCmaterial() : alpha(1.0),shininess(1.0),
- picture(NULL), picture_width(0), picture_height(0), picture_rgba(false), picture_replace(false) {}
+ picture_data(NULL), picture_format(KEPRCPicture_BITMAP_RGB_BYTE), picture_width(0), picture_height(0), picture_size(0),
+ picture_replace(false), picture_repeat(false) {}
PRCmaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e,
const RGBAColour &s, double p, double h,
- const uint8_t* pic=NULL, uint32_t picw=0, uint32_t pich=0, bool pica=false, bool picr=false) :
+ const uint8_t* pic=NULL, EPRCPictureDataFormat picf=KEPRCPicture_BITMAP_RGB_BYTE,
+ uint32_t picw=0, uint32_t pich=0, uint32_t pics=0, bool picreplace=false, bool picrepeat=false) :
ambient(a), diffuse(d), emissive(e), specular(s), alpha(p), shininess(h),
- picture(pic), picture_width(picw), picture_height(pich), picture_rgba(pica), picture_replace(picr) {}
+ picture_data(pic), picture_format(picf), picture_width(picw), picture_height(pich), picture_size(pics),
+ picture_replace(picreplace), picture_repeat(picrepeat) {
+ if(picture_size==0)
+ {
+ if (picture_format==KEPRCPicture_BITMAP_RGB_BYTE)
+ picture_size = picture_width*picture_height*3;
+ if (picture_format==KEPRCPicture_BITMAP_RGBA_BYTE)
+ picture_size = picture_width*picture_height*4;
+ if (picture_format==KEPRCPicture_BITMAP_GREY_BYTE)
+ picture_size = picture_width*picture_height*1;
+ if (picture_format==KEPRCPicture_BITMAP_GREYA_BYTE)
+ picture_size = picture_width*picture_height*2;
+ }
+ }
RGBAColour ambient,diffuse,emissive,specular;
double alpha,shininess;
- const uint8_t* picture;
+ const uint8_t* picture_data;
+ EPRCPictureDataFormat picture_format;
uint32_t picture_width;
uint32_t picture_height;
- bool picture_rgba; // is there alpha component?
+ uint32_t picture_size;
bool picture_replace; // replace material color with texture color? if false - just modify
+ bool picture_repeat; // repeat texture? if false - clamp to edge
bool operator==(const PRCmaterial &m) const
{
return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive
&& specular==m.specular && alpha==m.alpha && shininess==m.shininess
- && picture==m.picture && picture_width==m.picture_width && picture_height==m.picture_height
- && picture_rgba==m.picture_rgba && picture_replace==m.picture_replace);
+ && picture_replace==m.picture_replace && picture_repeat==m.picture_repeat
+ && picture_format==m.picture_format
+ && picture_width==m.picture_width && picture_height==m.picture_height && picture_size==m.picture_size
+ && (picture_data==m.picture_data || memcmp(picture_data,m.picture_data,picture_size)==0) );
}
bool operator<(const PRCmaterial &m) const
{
@@ -136,19 +166,201 @@ struct PRCmaterial
return (alpha<m.alpha);
if(shininess!=m.shininess)
return (shininess<m.shininess);
- if(picture!=m.picture)
- return (picture<m.picture);
+ if(picture_replace!=m.picture_replace)
+ return (picture_replace<m.picture_replace);
+ if(picture_repeat!=m.picture_repeat)
+ return (picture_repeat<m.picture_repeat);
+ if(picture_format!=m.picture_format)
+ return (picture_format<m.picture_format);
if(picture_width!=m.picture_width)
return (picture_width<m.picture_width);
if(picture_height!=m.picture_height)
return (picture_height<m.picture_height);
- if(picture_rgba!=m.picture_rgba)
- return (picture_rgba<m.picture_rgba);
- return (picture_replace<m.picture_replace);
+ if(picture_size!=m.picture_size)
+ return (picture_size<m.picture_size);
+ if(picture_data!=m.picture_data)
+ return (memcmp(picture_data,m.picture_data,picture_size)<0);
+ return false;
}
};
typedef std::map<PRCmaterial,uint32_t> PRCmaterialMap;
+struct PRCpicture
+{
+ PRCpicture() :
+ data(NULL), format(KEPRCPicture_BITMAP_RGB_BYTE),
+ width(0), height(0), size(0) {}
+ PRCpicture(const uint8_t* pic, EPRCPictureDataFormat picf,
+ uint32_t picw, uint32_t pich, uint32_t pics=0) :
+ data(pic), format(picf),
+ width(picw), height(pich), size(pics)
+ {
+ if(size==0)
+ {
+ if (format==KEPRCPicture_BITMAP_RGB_BYTE)
+ size = width*height*3;
+ if (format==KEPRCPicture_BITMAP_RGBA_BYTE)
+ size = width*height*4;
+ if (format==KEPRCPicture_BITMAP_GREY_BYTE)
+ size = width*height*1;
+ if (format==KEPRCPicture_BITMAP_GREYA_BYTE)
+ size = width*height*2;
+ }
+ }
+ PRCpicture(const PRCmaterial& m) :
+ data(m.picture_data), format(m.picture_format),
+ width(m.picture_width), height(m.picture_height), size(m.picture_size) {}
+
+ const uint8_t* data;
+ EPRCPictureDataFormat format;
+ uint32_t width;
+ uint32_t height;
+ uint32_t size;
+ bool operator==(const PRCpicture& p) const
+ {
+ return ( format==p.format
+ && width==p.width && height==p.height && size==p.size
+ && (data==p.data || memcmp(data,p.data,size)==0) );
+ }
+ bool operator<(const PRCpicture& p) const
+ {
+ if(format!=p.format)
+ return (format<p.format);
+ if(width!=p.width)
+ return (width<p.width);
+ if(height!=p.height)
+ return (height<p.height);
+ if(size!=p.size)
+ return (size<p.size);
+ if(data!=p.data)
+ return (memcmp(data,p.data,size)<0);
+ return false;
+ }
+};
+
+typedef std::map<PRCpicture,uint32_t> PRCpictureMap;
+
+struct PRCmaterialgeneric
+{
+ PRCmaterialgeneric() : alpha(1.0),shininess(1.0) {}
+ PRCmaterialgeneric(const RGBAColour& a, const RGBAColour& d, const RGBAColour& e,
+ const RGBAColour& s, double p, double h) :
+ ambient(a), diffuse(d), emissive(e), specular(s), alpha(p), shininess(h) {}
+ PRCmaterialgeneric(const PRCmaterial& m) :
+ ambient(m.ambient), diffuse(m.diffuse), emissive(m.emissive), specular(m.specular), alpha(m.alpha), shininess(m.shininess) {}
+ RGBAColour ambient,diffuse,emissive,specular;
+ double alpha,shininess;
+
+ bool operator==(const PRCmaterialgeneric& m) const
+ {
+ return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive
+ && specular==m.specular && alpha==m.alpha && shininess==m.shininess);
+ }
+ bool operator<(const PRCmaterialgeneric& m) const
+ {
+ if(ambient!=m.ambient)
+ return (ambient<m.ambient);
+ if(diffuse!=m.diffuse)
+ return (diffuse<m.diffuse);
+ if(emissive!=m.emissive)
+ return (emissive<m.emissive);
+ if(specular!=m.specular)
+ return (specular<m.specular);
+ if(alpha!=m.alpha)
+ return (alpha<m.alpha);
+ if(shininess!=m.shininess)
+ return (shininess<m.shininess);
+ return false;
+ }
+};
+typedef std::map<PRCmaterialgeneric,uint32_t> PRCmaterialgenericMap;
+
+struct PRCtexturedefinition
+{
+ PRCtexturedefinition() :
+ picture_index(m1), picture_replace(false), picture_repeat(false) {}
+ PRCtexturedefinition(uint32_t picindex, bool picreplace=false, bool picrepeat=false) :
+ picture_index(picindex), picture_replace(picreplace), picture_repeat(picrepeat) {}
+ PRCtexturedefinition(uint32_t picindex, const PRCmaterial& m) :
+ picture_index(picindex), picture_replace(m.picture_replace), picture_repeat(m.picture_repeat) {}
+ uint32_t picture_index;
+ bool picture_replace; // replace material color with texture color? if false - just modify
+ bool picture_repeat; // repeat texture? if false - clamp to edge
+
+ bool operator==(const PRCtexturedefinition& t) const
+ {
+ return (picture_index==t.picture_index
+ && picture_replace==t.picture_replace && picture_repeat==t.picture_repeat);
+ }
+ bool operator<(const PRCtexturedefinition& t) const
+ {
+ if(picture_index!=t.picture_index)
+ return (picture_index<t.picture_index);
+ if(picture_replace!=t.picture_replace)
+ return (picture_replace<t.picture_replace);
+ if(picture_repeat!=t.picture_repeat)
+ return (picture_repeat<t.picture_repeat);
+ return false;
+ }
+};
+typedef std::map<PRCtexturedefinition,uint32_t> PRCtexturedefinitionMap;
+
+struct PRCtextureapplication
+{
+ PRCtextureapplication() :
+ material_generic_index(m1), texture_definition_index(m1) {}
+ PRCtextureapplication(uint32_t matindex, uint32_t texindex) :
+ material_generic_index(matindex), texture_definition_index(texindex) {}
+ uint32_t material_generic_index;
+ uint32_t texture_definition_index;
+
+ bool operator==(const PRCtextureapplication& t) const
+ {
+ return (material_generic_index==t.material_generic_index
+ && texture_definition_index==t.texture_definition_index);
+ }
+ bool operator<(const PRCtextureapplication& t) const
+ {
+ if(material_generic_index!=t.material_generic_index)
+ return (material_generic_index<t.material_generic_index);
+ if(texture_definition_index!=t.texture_definition_index)
+ return (texture_definition_index<t.texture_definition_index);
+ return false;
+ }
+};
+typedef std::map<PRCtextureapplication,uint32_t> PRCtextureapplicationMap;
+
+struct PRCstyle
+{
+ PRCstyle() :
+ line_width(0), alpha(1), is_material(false), color_material_index(m1) {}
+ PRCstyle(double linewidth, double alph, bool ismat, uint32_t colindex=m1) :
+ line_width(linewidth), alpha(alph), is_material(ismat), color_material_index(colindex) {}
+ double line_width;
+ double alpha;
+ bool is_material;
+ uint32_t color_material_index;
+
+ bool operator==(const PRCstyle& s) const
+ {
+ return (line_width==s.line_width && alpha==s.alpha && is_material==s.is_material
+ && color_material_index==s.color_material_index);
+ }
+ bool operator<(const PRCstyle& s) const
+ {
+ if(line_width!=s.line_width)
+ return (line_width<s.line_width);
+ if(alpha!=s.alpha)
+ return (alpha<s.alpha);
+ if(is_material!=s.is_material)
+ return (is_material<s.is_material);
+ if(color_material_index!=s.color_material_index)
+ return (color_material_index<s.color_material_index);
+ return false;
+ }
+};
+typedef std::map<PRCstyle,uint32_t> PRCstyleMap;
+
struct PRCtessrectangle // rectangle
{
PRCVector3d vertices[4];
@@ -156,15 +368,25 @@ struct PRCtessrectangle // rectangle
};
typedef std::vector<PRCtessrectangle> PRCtessrectangleList;
-struct PRCtesstriangles // triangle
+struct PRCtessquad // rectangle
{
- std::vector<PRCVector3d> vertices;
- std::vector<PRCVector3d> normals;
- std::vector<RGBAColour> colors;
+ PRCVector3d vertices[4];
+ RGBAColour colours[4];
+};
+typedef std::vector<PRCtessquad> PRCtessquadList;
+/*
+struct PRCtesstriangle // textured triangle
+{
+ PRCtesstriangle() :
+ style(m1) {}
+ PRCVector3d vertices[3];
+// PRCVector3d normals[3];
+// RGBAColour colors[3];
+ PRCVector2d texcoords[3];
uint32_t style;
};
-typedef std::vector<PRCtesstriangles> PRCtesstrianglesList;
-
+typedef std::vector<PRCtesstriangle> PRCtesstriangleList;
+*/
struct PRCtessline // polyline
{
std::vector<PRCVector3d> point;
@@ -213,33 +435,38 @@ public:
bool tess; // use tessellated mesh to store straight patches
bool do_break; //
bool no_break; // do not render transparent patches as one-faced nodes
+ double crease_angle; // crease angle for meshes
PRCoptions(double compression=0.0, double granularity=0.0, bool closed=false,
- bool tess=false, bool do_break=true, bool no_break=false)
+ bool tess=false, bool do_break=true, bool no_break=false, double crease_angle=25.8419)
: compression(compression), granularity(granularity), closed(closed),
- tess(tess), do_break(do_break), no_break(no_break) {}
+ tess(tess), do_break(do_break), no_break(no_break), crease_angle(crease_angle) {}
};
class PRCgroup
{
public:
- PRCgroup() : transform(NULL) {}
- PRCgroup(const std::string &name) : name(name), transform(NULL) {}
+ PRCgroup() :
+ product_occurrence(NULL), parent_product_occurrence(NULL), part_definition(NULL), parent_part_definition(NULL), transform(NULL) {}
+ PRCgroup(const std::string& name) :
+ product_occurrence(NULL), parent_product_occurrence(NULL), part_definition(NULL), parent_part_definition(NULL), transform(NULL), name(name) {}
+ PRCProductOccurrence *product_occurrence, *parent_product_occurrence;
+ PRCPartDefinition *part_definition, *parent_part_definition;
PRCfaceList faces;
PRCcompfaceList compfaces;
PRCtessrectangleList rectangles;
+// PRCtesstriangleList triangles;
+ PRCtessquadList quads;
PRCtesslineMap lines;
PRCwireList wires;
PRCpointsetMap points;
std::vector<PRCPointSet*> pointsets;
std::vector<PRCPolyBrepModel*> polymodels;
std::vector<PRCPolyWire*> polywires;
- std::string name;
- std::list<PRCgroup> groupList;
PRCGeneralTransformation3d* transform;
+ std::string name;
PRCoptions options;
};
-typedef std::list<PRCgroup> PRCgroupList;
void makeFileUUID(PRCUniqueId&);
void makeAppUUID(PRCUniqueId&);
@@ -249,11 +476,9 @@ class PRCUncompressedFile
public:
PRCUncompressedFile() : file_size(0), data(NULL) {}
PRCUncompressedFile(uint32_t fs, uint8_t *d) : file_size(fs), data(d) {}
-// PRCUncompressedFile(uint32_t fs, const std::string &fn) : file_size(fs), data(NULL), file_name(fn) {}
~PRCUncompressedFile() { if(data != NULL) delete[] data; }
uint32_t file_size;
uint8_t *data;
-// std::string file_name;
void write(std::ostream&) const;
@@ -417,6 +642,15 @@ class oPRCFile
makeAppUUID(fileStructures[i]->application_uuid);
fileStructures[i]->unit = u;
}
+
+ groups.push(PRCgroup());
+ PRCgroup &group = groups.top();
+ group.name="root";
+ group.transform = NULL;
+ group.product_occurrence = new PRCProductOccurrence(group.name);
+ group.parent_product_occurrence = NULL;
+ group.part_definition = new PRCPartDefinition;
+ group.parent_part_definition = NULL;
}
oPRCFile(const std::string &name, double u=1, uint32_t n=1) :
@@ -437,6 +671,15 @@ class oPRCFile
makeAppUUID(fileStructures[i]->application_uuid);
fileStructures[i]->unit = u;
}
+
+ groups.push(PRCgroup());
+ PRCgroup &group = groups.top();
+ group.name="root";
+ group.transform = NULL;
+ group.product_occurrence = new PRCProductOccurrence(group.name);
+ group.parent_product_occurrence = NULL;
+ group.part_definition = new PRCPartDefinition;
+ group.parent_part_definition = NULL;
}
~oPRCFile()
@@ -447,12 +690,17 @@ class oPRCFile
if(fout != NULL)
delete fout;
free(modelFile_data);
+ for(PRCpictureMap::iterator it=pictureMap.begin(); it!=pictureMap.end(); ++it) delete it->first.data;
}
void begingroup(const char *name, PRCoptions *options=NULL,
- const double t[][4]=NULL);
+ const double* t=NULL);
void endgroup();
+ std::string lastgroupname;
+ std::vector<std::string> lastgroupnames;
+ std::string calculate_unique_name(const ContentPRCBase *prc_entity,const ContentPRCBase *prc_occurence);
+
bool finish();
uint32_t getSize();
@@ -465,32 +713,110 @@ class oPRCFile
PRCcolorMap colorMap;
PRCcolourMap colourMap;
PRCcolourwidthMap colourwidthMap;
- PRCmaterialMap materialMap;
+ PRCmaterialgenericMap materialgenericMap;
+ PRCtexturedefinitionMap texturedefinitionMap;
+ PRCtextureapplicationMap textureapplicationMap;
+ PRCstyleMap styleMap;
+ PRCpictureMap pictureMap;
PRCgroup rootGroup;
PRCtransformMap transformMap;
- std::stack<PRCgroupList::iterator> currentGroups;
+ std::stack<PRCgroup> groups;
PRCgroup& findGroup();
- void doGroup(PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence);
+ void doGroup(PRCgroup& group);
uint32_t addColor(const PRCRgbColor &color);
uint32_t addColour(const RGBAColour &colour);
uint32_t addColourWidth(const RGBAColour &colour, double width);
+ uint32_t addLineMaterial(const RGBAColour& c, double width)
+ { return addColourWidth(c,width); }
uint32_t addMaterial(const PRCmaterial &material);
uint32_t addTransform(PRCGeneralTransformation3d*& transform);
+ uint32_t addTransform(const double* t);
+ uint32_t addTransform(const double origin[3], const double x_axis[3], const double y_axis[3], double scale);
void addPoint(const double P[3], const RGBAColour &c, double w=1.0);
void addPoints(uint32_t n, const double P[][3], const RGBAColour &c, double w=1.0);
void addLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[],
- const RGBAColour &c, double w, bool segment_color,
- uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]);
+ const RGBAColour& c, double w,
+ bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]);
+ uint32_t createLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[],
+ bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]);
void addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial &m,
uint32_t nN, const double N[][3], const uint32_t NI[][3],
uint32_t nT, const double T[][2], const uint32_t TI[][3],
uint32_t nC, const RGBAColour C[], const uint32_t CI[][3],
- uint32_t nM, const PRCmaterial M[], const uint32_t MI[]);
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca);
+ uint32_t createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], uint32_t style_index,
+ uint32_t nN, const double N[][3], const uint32_t NI[][3],
+ uint32_t nT, const double T[][2], const uint32_t TI[][3],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][3],
+ uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca);
+ uint32_t createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial& m,
+ uint32_t nN, const double N[][3], const uint32_t NI[][3],
+ uint32_t nT, const double T[][2], const uint32_t TI[][3],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][3],
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca)
+ {
+ const uint32_t style = addMaterial(m);
+ if(M!=NULL && nM>0)
+ {
+ uint32_t* const styles = new uint32_t[nM];
+ for(uint32_t i=0; i<nM; i++)
+ styles[i]=addMaterial(M[i]);
+ const uint32_t meshid = createTriangleMesh(nP, P, nI, PI, style, nN, N, NI, nT, T, TI, nC, C, CI, nM, styles, MI, ca);
+ delete[] styles;
+ return meshid;
+ }
+ else
+ return createTriangleMesh(nP, P, nI, PI, style, nN, N, NI, nT, T, TI, nC, C, CI, 0, NULL, NULL, ca);
+ }
void addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], const PRCmaterial &m,
uint32_t nN, const double N[][3], const uint32_t NI[][4],
uint32_t nT, const double T[][2], const uint32_t TI[][4],
uint32_t nC, const RGBAColour C[], const uint32_t CI[][4],
- uint32_t nM, const PRCmaterial M[], const uint32_t MI[]);
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca);
+ uint32_t createQuadMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], uint32_t style_index,
+ uint32_t nN, const double N[][3], const uint32_t NI[][4],
+ uint32_t nT, const double T[][2], const uint32_t TI[][4],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][4],
+ uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca);
+ uint32_t createQuadMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], const PRCmaterial& m,
+ uint32_t nN, const double N[][3], const uint32_t NI[][4],
+ uint32_t nT, const double T[][2], const uint32_t TI[][4],
+ uint32_t nC, const RGBAColour C[], const uint32_t CI[][4],
+ uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca)
+ {
+ const uint32_t style = addMaterial(m);
+ if(M!=NULL && nM>0)
+ {
+ uint32_t* const styles = new uint32_t[nM];
+ for(uint32_t i=0; i<nM; i++)
+ styles[i]=addMaterial(M[i]);
+ const uint32_t meshid = createQuadMesh(nP, P, nI, PI, style, nN, N, NI, nT, T, TI, nC, C, CI, nM, styles, MI, ca);
+ delete[] styles;
+ return meshid;
+ }
+ else
+ return createQuadMesh(nP, P, nI, PI, style, nN, N, NI, nT, T, TI, nC, C, CI, 0, NULL, NULL, ca);
+ }
+#define PRCTRANSFORM const double origin[3]=NULL, const double x_axis[3]=NULL, const double y_axis[3]=NULL, double scale=1, const double* t=NULL
+#define PRCCARTRANSFORM const double origin[3], const double x_axis[3], const double y_axis[3], double scale
+#define PRCGENTRANSFORM const double* t=NULL
+#define PRCNOMATERIALINDEX m1
+ void useMesh(uint32_t tess_index, uint32_t style_index, PRCGENTRANSFORM);
+ void useMesh(uint32_t tess_index, const PRCmaterial& m, PRCGENTRANSFORM)
+ { useMesh(tess_index,addMaterial(m),t); }
+ void useMesh(uint32_t tess_index, uint32_t style_index, PRCCARTRANSFORM);
+ void useMesh(uint32_t tess_index, const PRCmaterial& m, PRCCARTRANSFORM)
+ { useMesh(tess_index,addMaterial(m),origin, x_axis, y_axis, scale); }
+
+ void useLines(uint32_t tess_index, uint32_t style_index, PRCGENTRANSFORM);
+ void useLines(uint32_t tess_index, const RGBAColour& c, double w, PRCGENTRANSFORM)
+ { useLines(tess_index, addLineMaterial(c,w), t); }
+ void useLines(uint32_t tess_index, uint32_t style_index, PRCCARTRANSFORM);
+ void useLines(uint32_t tess_index, const RGBAColour& c, double w, PRCCARTRANSFORM)
+ { useLines(tess_index,addLineMaterial(c,w),origin, x_axis, y_axis, scale); }
+
+// void addTriangle(const double P[][3], const double T[][2], uint32_t style_index);
+
void addLine(uint32_t n, const double P[][3], const RGBAColour &c, double w=1.0);
void addBezierCurve(uint32_t n, const double cP[][3], const RGBAColour &c);
void addCurve(uint32_t d, uint32_t n, const double cP[][3], const double *k, const RGBAColour &c, const double w[]);
@@ -501,20 +827,24 @@ class oPRCFile
void addSurface(uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
const double cP[][3], const double *kU, const double *kV, const PRCmaterial &m,
const double w[]);
-#define PRCFACETRANSFORM const double origin[3]=NULL, const double x_axis[3]=NULL, const double y_axis[3]=NULL, double scale=1, const double t[][4]=NULL
- void addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial &m, PRCFACETRANSFORM);
- void addHemisphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM);
- void addSphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM);
- void addDisk(double radius, const PRCmaterial &m, PRCFACETRANSFORM);
- void addCylinder(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM);
- void addCone(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM);
- void addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial &m, PRCFACETRANSFORM);
-#undef PRCFACETRANSFORM
+ void addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial& m, PRCTRANSFORM);
+ void addHemisphere(double radius, const PRCmaterial& m, PRCTRANSFORM);
+ void addSphere(double radius, const PRCmaterial& m, PRCTRANSFORM);
+ void addDisk(double radius, const PRCmaterial& m, PRCTRANSFORM);
+ void addCylinder(double radius, double height, const PRCmaterial& m, PRCTRANSFORM);
+ void addCone(double radius, double height, const PRCmaterial& m, PRCTRANSFORM);
+ void addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial& m, PRCTRANSFORM);
+#undef PRCTRANSFORM
+#undef PRCCARTRANSFORM
+#undef PRCGENTRANSFORM
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 addPicture(const PRCpicture& pic,
+ std::string name="", uint32_t fileStructure=0)
+ { return fileStructures[fileStructure]->addPicture(pic.format, pic.size, pic.data, pic.width, pic.height, name); }
uint32_t addTextureDefinition(PRCTextureDefinition*& pTextureDefinition, uint32_t fileStructure=0)
{
return fileStructures[fileStructure]->addTextureDefinition(pTextureDefinition);
diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc
index 9fbbc41013b..5f62ea6731e 100644
--- a/Build/source/utils/asymptote/prc/writePRC.cc
+++ b/Build/source/utils/asymptote/prc/writePRC.cc
@@ -150,6 +150,84 @@ bool PRCVector3d::Normalize()
return true;
}
+double PRCVector2d::Length()
+{
+ return sqrt(x*x+y*y);
+}
+
+bool PRCVector2d::Normalize()
+{
+ double fLength=Length();
+ if(fLength < FLT_EPSILON) return false;
+ double factor=1.0/fLength;
+ x *= factor;
+ y *= factor;
+
+ return true;
+}
+
+void PRCVector2d::serializeVector2d(PRCbitStream &pbs)
+{
+ WriteDouble (x)
+ WriteDouble (y)
+}
+
+uint32_t makeCADID()
+{
+ static uint32_t ID = 1;
+ return ID++;
+}
+
+uint32_t makePRCID()
+{
+ static uint32_t ID = 1;
+ return ID++;
+}
+
+bool type_eligible_for_reference(uint32_t type)
+{
+ if(
+ type == PRC_TYPE_MISC_EntityReference ||
+ type == PRC_TYPE_MISC_MarkupLinkedItem ||
+ type == PRC_TYPE_RI_BrepModel ||
+ type == PRC_TYPE_RI_Curve ||
+ type == PRC_TYPE_RI_Direction ||
+ type == PRC_TYPE_RI_Plane ||
+ type == PRC_TYPE_RI_PointSet ||
+ type == PRC_TYPE_RI_PolyBrepModel ||
+ type == PRC_TYPE_RI_PolyWire ||
+ type == PRC_TYPE_RI_Set ||
+ type == PRC_TYPE_RI_CoordinateSystem ||
+ type == PRC_TYPE_ASM_ProductOccurence ||
+ type == PRC_TYPE_ASM_PartDefinition ||
+ type == PRC_TYPE_ASM_Filter ||
+ type == PRC_TYPE_MKP_View ||
+ type == PRC_TYPE_MKP_Markup ||
+ type == PRC_TYPE_MKP_Leader ||
+ type == PRC_TYPE_MKP_AnnotationItem ||
+ type == PRC_TYPE_MKP_AnnotationSet ||
+ type == PRC_TYPE_MKP_AnnotationReference ||
+ type == PRC_TYPE_GRAPH_Style ||
+ type == PRC_TYPE_GRAPH_Material ||
+ type == PRC_TYPE_GRAPH_TextureApplication ||
+ type == PRC_TYPE_GRAPH_TextureDefinition ||
+ type == PRC_TYPE_GRAPH_LinePattern ||
+ type == PRC_TYPE_GRAPH_DottingPattern ||
+ type == PRC_TYPE_GRAPH_HatchingPattern ||
+ type == PRC_TYPE_GRAPH_SolidPattern ||
+ type == PRC_TYPE_GRAPH_VPicturePattern ||
+ type == PRC_TYPE_GRAPH_AmbientLight ||
+ type == PRC_TYPE_GRAPH_PointLight ||
+ type == PRC_TYPE_GRAPH_DirectionalLight ||
+ type == PRC_TYPE_GRAPH_SpotLight ||
+ type == PRC_TYPE_GRAPH_SceneDisplayParameters ||
+ type == PRC_TYPE_GRAPH_Camera
+ )
+ return true;
+ else
+ return false;
+}
+
void UserData::write(PRCbitStream &pbs)
{
pbs << size;
@@ -221,12 +299,12 @@ void PRCAttributes::serializeAttributes(PRCbitStream &pbs) const
}
}
-void ContentPRCBase::serializeContentPRCBase(PRCbitStream &pbs)
+void ContentPRCBase::serializeContentPRCBase(PRCbitStream &pbs) const
{
SerializeAttributeData
SerializeName (name)
- if (type_eligible_for_reference)
+ if (type_eligible_for_reference(type))
{
WriteUnsignedInteger (CAD_identifier)
WriteUnsignedInteger (CAD_persistent_identifier)
@@ -381,6 +459,21 @@ void PRCTextureApplication::serializeTextureApplication(PRCbitStream &pbs)
WriteUnsignedInteger (UV_coordinates_index+1)
}
+void PRCLinePattern::serializeLinePattern(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_LinePattern)
+ SerializeContentPRCBase
+
+ const uint32_t size_lengths = lengths.size();
+ WriteUnsignedInteger (size_lengths)
+ for (i=0;i<size_lengths;i++)
+ WriteDouble (lengths[i])
+ WriteDouble (phase)
+ WriteBoolean (is_real_length)
+}
+
+
void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
{
const bool is_additional_1_defined = (additional!=0);
@@ -410,9 +503,8 @@ void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
WriteCharacter (additional_3)
}
-ContentPRCBase EMPTY_CONTENTPRCBASE;
-
std::string currentName;
+
void writeName(PRCbitStream &pbs,const std::string &name)
{
pbs << (name == currentName);
@@ -672,9 +764,8 @@ void PRCPolyWire::serializePolyWire(PRCbitStream &pbs)
void PRCGeneralTransformation3d::serializeGeneralTransformation3d(PRCbitStream &pbs) const
{
WriteUnsignedInteger (PRC_TYPE_MISC_GeneralTransformation)
- for (int j=0;j<4;j++)
- for (int i=0;i<4;i++)
- WriteDouble(mat[i][j]);
+ for (uint32_t i=0; i<16; i++)
+ WriteDouble(m_coef[i]);
}
void PRCCartesianTransformation3d::serializeCartesianTransformation3d(PRCbitStream &pbs) const
@@ -974,24 +1065,6 @@ void PRCMarkupTess::serializeMarkupTess(PRCbitStream &pbs)
WriteCharacter (behaviour)
}
-void PRCVector2d::serializeVector2d(PRCbitStream &pbs)
-{
- WriteDouble (x)
- WriteDouble (y)
-}
-
-uint32_t makeCADID()
-{
- static uint32_t ID = 1;
- return ID++;
-}
-
-uint32_t makePRCID()
-{
- static uint32_t ID = 1;
- return ID++;
-}
-
void writeUnit(PRCbitStream &out,bool fromCAD,double unit)
{
out << fromCAD << unit;
@@ -1300,7 +1373,7 @@ void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep
for(uint32_t i=0;i<number_of_control_point_in_u;i++)
for(uint32_t j=0;j<number_of_control_point_in_v;j++)
P[i][j] = control_point[i*number_of_control_point_in_v+j];
-#if defined(__GNUC__) && !defined(__clang__)
+#ifdef __GNUC__
itriple compressed_control_point[number_of_control_point_in_u][number_of_control_point_in_v];
uint32_t control_point_type[number_of_control_point_in_u][number_of_control_point_in_v];
#else
@@ -1367,7 +1440,7 @@ void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep
if(x*x+y*y<nurbs_tolerance*nurbs_tolerance)
{
control_point_type[i][j] = 1;
- compressed_control_point[i][j] = iroundto(PRCVector3d(0,0,z), nurbs_tolerance);
+ compressed_control_point[i][j] = iroundto(PRCVector3d(0.0,0.0,z), nurbs_tolerance);
P[i][j] = P[i-1][j-1] + U + V + roundto(z, nurbs_tolerance)*Ne; // see above
}
else
diff --git a/Build/source/utils/asymptote/prc/writePRC.h b/Build/source/utils/asymptote/prc/writePRC.h
index 390e8042150..a1c794c919c 100644
--- a/Build/source/utils/asymptote/prc/writePRC.h
+++ b/Build/source/utils/asymptote/prc/writePRC.h
@@ -43,11 +43,12 @@ public :
double x;
double y;
double z;
- PRCVector3d() {}
+ PRCVector3d() :
+ x(0), y(0), z(0) {}
PRCVector3d(double fx, double fy, double fz) :
x(fx), y(fy), z(fz) {}
- PRCVector3d(const double c[]) :
- x(c?c[0]:0), y(c?c[1]:0), z(c?c[2]:0) {}
+ PRCVector3d(const double c[], double fx=0, double fy=0, double fz=0) :
+ x(c?c[0]:fx), y(c?c[1]:fy), z(c?c[2]:fz) {}
PRCVector3d(const PRCVector3d& sVector3d) :
x(sVector3d.x), y(sVector3d.y), z(sVector3d.z) {}
@@ -118,8 +119,6 @@ class UUID
void writeUncompressedUnsignedInteger(std::ostream &out, uint32_t data);
-uint32_t makeCADID();
-uint32_t makePRCID();
void writeUnit(PRCbitStream &,bool,double);
void writeEmptyMarkups(PRCbitStream&);
@@ -239,17 +238,27 @@ class PRCAttributes
PRCAttributeList attributes;
};
+bool type_eligible_for_reference(uint32_t type);
+uint32_t makeCADID();
+uint32_t makePRCID();
+
class ContentPRCBase : public PRCAttributes
{
public:
- 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&);
+ ContentPRCBase(uint32_t t, std::string n="") :
+ type(t),name(n),CAD_identifier(0), CAD_persistent_identifier(0), PRC_unique_identifier(0)
+ {
+ if(type_eligible_for_reference(type))
+ {
+ CAD_identifier = makeCADID();
+ PRC_unique_identifier = makePRCID();
+ }
+ }
+ void serializeContentPRCBase(PRCbitStream&) const;
uint32_t getPRCID() const { return PRC_unique_identifier; }
+ uint32_t getType() const { return type; }
+ uint32_t type;
std::string name;
- bool type_eligible_for_reference;
uint32_t CAD_identifier, CAD_persistent_identifier, PRC_unique_identifier;
};
@@ -265,8 +274,6 @@ public:
uint32_t unique_identifier;
};
-extern ContentPRCBase EMPTY_CONTENTPRCBASE;
-
extern std::string currentName;
void writeName(PRCbitStream&,const std::string&);
void resetName();
@@ -309,7 +316,7 @@ class PRCPicture : public ContentPRCBase
{
public:
PRCPicture(std::string n="") :
- ContentPRCBase(n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
+ ContentPRCBase(PRC_TYPE_GRAPH_Picture,n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
void serializePicture(PRCbitStream&);
EPRCPictureDataFormat format;
uint32_t uncompressed_file_index;
@@ -319,20 +326,67 @@ public:
struct PRCVector2d
{
- PRCVector2d() :
- x(0.0), y(0.0) {}
- PRCVector2d(double X, double Y) :
- x(X), y(Y) {}
- void serializeVector2d(PRCbitStream&);
- double x;
- double y;
+ PRCVector2d() :
+ x(0.0), y(0.0) {}
+ PRCVector2d(double X, double Y) :
+ x(X), y(Y) {}
+ void serializeVector2d(PRCbitStream&);
+ double x;
+ double y;
+ PRCVector2d(const double c[], double fx=0, double fy=0) :
+ x(c?c[0]:fx), y(c?c[1]:fy) {}
+ PRCVector2d(const PRCVector2d& sVector2d) :
+ x(sVector2d.x), y(sVector2d.y) {}
+
+ void Set(double fx, double fy)
+ { x = fx; y = fy; }
+ double Dot(const PRCVector2d & sPt) const
+ { return(x*sPt.x)+(y*sPt.y); }
+ double LengthSquared()
+ { return(x*x+y*y); }
+
+ friend PRCVector2d operator + (const PRCVector2d& a, const PRCVector2d& b)
+ { return PRCVector2d(a.x+b.x,a.y+b.y); }
+ friend PRCVector2d operator - (const PRCVector2d& a)
+ { return PRCVector2d(-a.x,-a.y); }
+ friend PRCVector2d operator - (const PRCVector2d& a, const PRCVector2d& b)
+ { return PRCVector2d(a.x-b.x,a.y-b.y); }
+ friend PRCVector2d operator * (const PRCVector2d& a, const double d)
+ { return PRCVector2d(a.x*d,a.y*d); }
+ friend PRCVector2d operator * (const double d, const PRCVector2d& a)
+ { return PRCVector2d(a.x*d,a.y*d); }
+ friend PRCVector2d operator / (const PRCVector2d& a, const double d)
+ { return PRCVector2d(a.x/d,a.y/d); }
+
+ double Length();
+ bool Normalize();
+
+ bool operator==(const PRCVector2d &v) const
+ {
+ return x==v.x && y==v.y;
+ }
+ bool operator!=(const PRCVector2d &v) const
+ {
+ return !(x==v.x && y==v.y);
+ }
+ bool operator<(const PRCVector2d &v) const
+ {
+ if(x!=v.x)
+ return (x<v.x);
+ return (y<v.y);
+ }
+ friend std::ostream& operator << (std::ostream& out, const PRCVector2d& v)
+ {
+ out << "(" << v.x << "," << v.y << ")";
+ return out;
+ }
};
class PRCTextureDefinition : public ContentPRCBase
{
public:
PRCTextureDefinition(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE),
+ ContentPRCBase(PRC_TYPE_GRAPH_TextureDefinition,n), 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) // ,
@@ -375,7 +429,7 @@ class PRCMaterialGeneric : public ContentPRCBase, public PRCMaterial
{
public:
PRCMaterialGeneric(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(PRC_TYPE_GRAPH_Material,n),
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)
@@ -404,7 +458,7 @@ class PRCTextureApplication : public ContentPRCBase, public PRCMaterial
{
public:
PRCTextureApplication(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(PRC_TYPE_GRAPH_TextureApplication,n),
material_generic_index(m1), texture_definition_index(m1),
next_texture_index(m1), UV_coordinates_index(0)
{}
@@ -416,11 +470,24 @@ public:
uint32_t UV_coordinates_index;
};
+class PRCLinePattern : public ContentPRCBase
+{
+public:
+ PRCLinePattern(std::string n="") :
+ ContentPRCBase(PRC_TYPE_GRAPH_LinePattern,n),
+ phase(0), is_real_length(false) {}
+ void serializeLinePattern(PRCbitStream&);
+ std::vector<double> lengths;
+ double phase;
+ bool is_real_length;
+};
+typedef std::deque <PRCLinePattern*> PRCLinePatternList;
+
class PRCStyle : public ContentPRCBase
{
public:
PRCStyle(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1),
+ ContentPRCBase(PRC_TYPE_GRAPH_Style,n), 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&);
@@ -480,7 +547,7 @@ class PRC3DTess : public PRCTess
public:
PRC3DTess() :
has_faces(false), has_loops(false),
- crease_angle(25.8419)
+ crease_angle(25.8419) // arccos(0.9), default found in Acrobat output
{}
~PRC3DTess() { for(PRCTessFaceList::iterator it=face_tessellation.begin(); it!=face_tessellation.end(); ++it) delete *it; }
void serialize3DTess(PRCbitStream&);
@@ -545,7 +612,7 @@ class PRCMarkup: public PRCGraphics, public ContentPRCBase
{
public:
PRCMarkup(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(PRC_TYPE_MKP_Markup,n),
type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {}
void serializeMarkup(PRCbitStream&);
EPRCMarkupType type;
@@ -560,7 +627,7 @@ class PRCAnnotationItem: public PRCGraphics, public ContentPRCBase
{
public:
PRCAnnotationItem(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()) {}
+ ContentPRCBase(PRC_TYPE_MKP_AnnotationItem,n) {}
void serializeAnnotationItem(PRCbitStream&);
void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); }
PRCReferenceUniqueIdentifier markup;
@@ -570,8 +637,8 @@ typedef std::deque <PRCAnnotationItem*> PRCAnnotationItemList;
class PRCRepresentationItemContent: public PRCGraphics, public ContentPRCBase
{
public:
- PRCRepresentationItemContent(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
+ PRCRepresentationItemContent(uint32_t t, std::string n="") :
+ ContentPRCBase(t,n),
index_local_coordinate_system(m1), index_tessellation(m1) {}
void serializeRepresentationItemContent(PRCbitStream&);
uint32_t index_local_coordinate_system;
@@ -581,11 +648,10 @@ public:
class PRCRepresentationItem : public PRCRepresentationItemContent
{
public:
- PRCRepresentationItem(std::string n="") :
- PRCRepresentationItemContent(n) {}
+ PRCRepresentationItem(uint32_t t, std::string n="") :
+ PRCRepresentationItemContent(t,n) {}
virtual ~PRCRepresentationItem() {}
virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0;
- virtual uint32_t getType() const = 0;
};
typedef std::deque <PRCRepresentationItem*> PRCRepresentationItemList;
@@ -593,10 +659,9 @@ class PRCBrepModel : public PRCRepresentationItem
{
public:
PRCBrepModel(std::string n="") :
- PRCRepresentationItem(n), has_brep_data(true), context_id(m1), body_id(m1), is_closed(false) {}
+ PRCRepresentationItem(PRC_TYPE_RI_BrepModel,n), has_brep_data(true), context_id(m1), body_id(m1), is_closed(false) {}
void serializeBrepModel(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeBrepModel(pbs); }
- uint32_t getType() const { return PRC_TYPE_RI_BrepModel; }
bool has_brep_data;
uint32_t context_id;
uint32_t body_id;
@@ -607,10 +672,9 @@ class PRCPolyBrepModel : public PRCRepresentationItem
{
public:
PRCPolyBrepModel(std::string n="") :
- PRCRepresentationItem(n), is_closed(false) {}
+ PRCRepresentationItem(PRC_TYPE_RI_PolyBrepModel,n), is_closed(false) {}
void serializePolyBrepModel(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyBrepModel(pbs); }
- uint32_t getType() const { return PRC_TYPE_RI_PolyBrepModel; }
bool is_closed;
};
@@ -618,10 +682,9 @@ class PRCPointSet : public PRCRepresentationItem
{
public:
PRCPointSet(std::string n="") :
- PRCRepresentationItem(n) {}
+ PRCRepresentationItem(PRC_TYPE_RI_PointSet,n) {}
void serializePointSet(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); }
- uint32_t getType() const { return PRC_TYPE_RI_PointSet; }
std::vector<PRCVector3d> point;
};
@@ -629,10 +692,9 @@ class PRCWire : public PRCRepresentationItem
{
public:
PRCWire(std::string n="") :
- PRCRepresentationItem(n), has_wire_body(true), context_id(m1), body_id(m1) {}
+ PRCRepresentationItem(PRC_TYPE_RI_Curve,n), has_wire_body(true), context_id(m1), body_id(m1) {}
void serializeWire(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeWire(pbs); }
- uint32_t getType() const { return PRC_TYPE_RI_Curve; }
bool has_wire_body;
uint32_t context_id;
uint32_t body_id;
@@ -642,17 +704,16 @@ class PRCPolyWire : public PRCRepresentationItem
{
public:
PRCPolyWire(std::string n="") :
- PRCRepresentationItem(n) {}
+ PRCRepresentationItem(PRC_TYPE_RI_PolyWire,n) {}
void serializePolyWire(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyWire(pbs); }
- uint32_t getType() const { return PRC_TYPE_RI_PolyWire; }
};
class PRCSet : public PRCRepresentationItem
{
public:
PRCSet(std::string n="") :
- PRCRepresentationItem(n) {}
+ PRCRepresentationItem(PRC_TYPE_RI_Set,n) {}
~PRCSet() { for(PRCRepresentationItemList::iterator it=elements.begin(); it!=elements.end(); ++it) delete *it; }
void serializeSet(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeSet(pbs); }
@@ -663,7 +724,6 @@ public:
uint32_t addWire(PRCWire*& pWire);
uint32_t addPolyWire(PRCPolyWire*& pPolyWire);
uint32_t addRepresentationItem(PRCRepresentationItem*& pRepresentationItem);
- uint32_t getType() const { return PRC_TYPE_RI_Set; }
PRCRepresentationItemList elements;
};
@@ -680,88 +740,63 @@ class PRCGeneralTransformation3d : public PRCTransformation3d
public:
PRCGeneralTransformation3d()
{
- mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0;
- mat[0][1] = mat[0][2] = mat[0][3] = 0.0;
- mat[1][0] = mat[1][2] = mat[1][3] = 0.0;
- mat[2][0] = mat[2][1] = mat[2][3] = 0.0;
- mat[3][0] = mat[3][1] = mat[3][2] = 0.0;
+ setidentity();
}
- PRCGeneralTransformation3d(const double t[][4])
+ PRCGeneralTransformation3d(const double t[])
{
- if(t!=NULL)
- for (size_t i=0;i<4;i++)
- for (size_t j=0;j<4;j++)
- mat[i][j]=t[i][j];
- else
- {
- mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0;
- mat[0][1] = mat[0][2] = mat[0][3] = 0.0;
- mat[1][0] = mat[1][2] = mat[1][3] = 0.0;
- mat[2][0] = mat[2][1] = mat[2][3] = 0.0;
- mat[3][0] = mat[3][1] = mat[3][2] = 0.0;
- }
- }
- PRCGeneralTransformation3d(const double t[][4], double scale)
- {
- if(t!=NULL)
- {
- for (size_t i=0;i<3;i++)
- for (size_t j=0;j<4;j++)
- mat[i][j]=scale*t[i][j];
- for(size_t j= 0;j<4; j++)
- mat[3][j] = scale*t[3][j];
- }
- else
- {
- mat[0][0] = mat[1][1] = mat[2][2] = mat[3][3] = 1.0;
- mat[0][1] = mat[0][2] = mat[0][3] = 0.0;
- mat[1][0] = mat[1][2] = mat[1][3] = 0.0;
- mat[2][0] = mat[2][1] = mat[2][3] = 0.0;
- mat[3][0] = mat[3][1] = mat[3][2] = 0.0;
- }
+ set(t);
}
void serializeGeneralTransformation3d(PRCbitStream&) const;
void serializeTransformation3d(PRCbitStream& pbs) const { serializeGeneralTransformation3d(pbs); }
- double mat[4][4];
+ double m_coef[16];
bool operator==(const PRCGeneralTransformation3d &t) const
{
- for (size_t i=0;i<4;i++)
- for (size_t j=0;j<4;j++)
- if(mat[i][j]!=t.mat[i][j])
+ for (size_t i=0;i<16;i++)
+ if(m_coef[i]!=t.m_coef[i])
return false;
return true;
}
bool operator<(const PRCGeneralTransformation3d &t) const
{
- for (size_t i=0;i<4;i++)
- for (size_t j=0;j<4;j++)
- if(mat[i][j]!=t.mat[i][j])
+ for (size_t i=0;i<16;i++)
+ if(m_coef[i]!=t.m_coef[i])
{
- return (mat[i][j]<t.mat[i][j]);
+ return (m_coef[i]<t.m_coef[i]);
}
return false;
}
- void set(const double t[][4])
+ void set(const double t[])
{
if(t!=NULL)
- for (size_t i=0;i<4;i++)
- for (size_t j=0;j<4;j++)
- mat[i][j]=t[i][j];
+ for (size_t i=0;i<16;i++)
+ m_coef[i]=t[i];
+ else
+ setidentity();
+ }
+ void setidentity()
+ {
+ m_coef[0]=1; m_coef[4]=0; m_coef[ 8]=0; m_coef[12]=0;
+ m_coef[1]=0; m_coef[5]=1; m_coef[ 9]=0; m_coef[13]=0;
+ m_coef[2]=0; m_coef[6]=0; m_coef[10]=1; m_coef[14]=0;
+ m_coef[3]=0; m_coef[7]=0; m_coef[11]=0; m_coef[15]=1;
}
bool isnotidtransform() const {
return(
- mat[0][0]!=1 || mat[0][1]!=0 || mat[0][2]!=0 || mat[0][3]!=0 ||
- mat[1][0]!=0 || mat[1][1]!=1 || mat[1][2]!=0 || mat[1][3]!=0 ||
- mat[2][0]!=0 || mat[2][1]!=0 || mat[2][2]!=1 || mat[2][3]!=0 ||
- mat[3][0]!=0 || mat[3][1]!=0 || mat[3][2]!=0 || mat[3][3]!=1 );
+ m_coef[0]!=1 || m_coef[4]!=0 || m_coef[ 8]!=0 || m_coef[12]!=0 ||
+ m_coef[1]!=0 || m_coef[5]!=1 || m_coef[ 9]!=0 || m_coef[13]!=0 ||
+ m_coef[2]!=0 || m_coef[6]!=0 || m_coef[10]!=1 || m_coef[14]!=0 ||
+ m_coef[3]!=0 || m_coef[7]!=0 || m_coef[11]!=0 || m_coef[15]!=1 );
}
bool isidtransform() const {
return(
- mat[0][0]==1 && mat[0][1]==0 && mat[0][2]==0 && mat[0][3]==0 &&
- mat[1][0]==0 && mat[1][1]==1 && mat[1][2]==0 && mat[1][3]==0 &&
- mat[2][0]==0 && mat[2][1]==0 && mat[2][2]==1 && mat[2][3]==0 &&
- mat[3][0]==0 && mat[3][1]==0 && mat[3][2]==0 && mat[3][3]==1 );
+ m_coef[0]==1 && m_coef[4]==0 && m_coef[ 8]==0 && m_coef[12]==0 &&
+ m_coef[1]==0 && m_coef[5]==1 && m_coef[ 9]==0 && m_coef[13]==0 &&
+ m_coef[2]==0 && m_coef[6]==0 && m_coef[10]==1 && m_coef[14]==0 &&
+ m_coef[3]==0 && m_coef[7]==0 && m_coef[11]==0 && m_coef[15]==1 );
+ }
+ double M(size_t i, size_t j) const {
+ return m_coef[i+j*4];
}
};
typedef std::deque <PRCGeneralTransformation3d> PRCGeneralTransformation3dList;
@@ -773,6 +808,18 @@ public:
behaviour(PRC_TRANSFORMATION_Identity), origin(0.0,0.0,0.0), X(1.0,0.0,0.0), Y(0.0,1.0,0.0), Z(0.0,0.0,1.0),
scale(1.0,1.0,1.0), uniform_scale(1.0),
X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0) {}
+ PRCCartesianTransformation3d(const double o[3], const double x[3], const double y[3], double sc) :
+ behaviour(PRC_TRANSFORMATION_Identity), origin(o,0.0,0.0,0.0), X(x,1.0,0.0,0.0), Y(y,0.0,1.0,0.0), Z(0.0,0.0,1.0),
+ scale(1.0,1.0,1.0), uniform_scale(sc),
+ X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0)
+ {
+ if(origin!=PRCVector3d(0.0,0.0,0.0))
+ behaviour = behaviour | PRC_TRANSFORMATION_Translate;
+ if(X!=PRCVector3d(1.0,0.0,0.0) || Y!=PRCVector3d(0.0,1.0,0.0))
+ behaviour = behaviour | PRC_TRANSFORMATION_Rotate;
+ if(uniform_scale!=1)
+ behaviour = behaviour | PRC_TRANSFORMATION_Scale;
+ }
void serializeCartesianTransformation3d(PRCbitStream& pbs) const;
void serializeTransformation3d(PRCbitStream& pbs) const { serializeCartesianTransformation3d(pbs); }
uint8_t behaviour;
@@ -799,7 +846,7 @@ class PRCTransformation
public:
PRCTransformation() :
has_transformation(false), geometry_is_2D(false), behaviour(PRC_TRANSFORMATION_Identity),
- origin(0,0,0), x_axis(1,0,0), y_axis(0,1,0), scale(1) {}
+ origin(0.0,0.0,0.0), x_axis(1.0,0.0,0.0), y_axis(0.0,1.0,0.0), scale(1) {}
void serializeTransformation(PRCbitStream&);
bool has_transformation;
bool geometry_is_2D;
@@ -814,13 +861,12 @@ class PRCCoordinateSystem : public PRCRepresentationItem
{
public:
PRCCoordinateSystem(std::string n="") :
- PRCRepresentationItem(n), axis_set(NULL) {}
+ PRCRepresentationItem(PRC_TYPE_RI_CoordinateSystem,n), axis_set(NULL) {}
~PRCCoordinateSystem() { delete axis_set; }
void serializeCoordinateSystem(PRCbitStream&);
void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); }
void setAxisSet(PRCGeneralTransformation3d*& transform) { axis_set = transform; transform = NULL; }
void setAxisSet(PRCCartesianTransformation3d*& transform) { axis_set = transform; transform = NULL; }
- uint32_t getType() const { return PRC_TYPE_RI_CoordinateSystem; }
PRCTransformation3d *axis_set;
bool operator==(const PRCCoordinateSystem &t) const
{
@@ -872,7 +918,7 @@ public:
class PRCBoundingBox
{
public:
- PRCBoundingBox() : min(0,0,0), max(0,0,0) {}
+ PRCBoundingBox() : min(0.0,0.0,0.0), max(0.0,0.0,0.0) {}
PRCBoundingBox(const PRCVector3d &m1, const PRCVector3d& m2) : min(m1),max(m2) {}
void serializeBoundingBox(PRCbitStream &pbs);
PRCVector3d min;
@@ -1337,7 +1383,7 @@ class PRCTopoContext : public ContentPRCBase
{
public:
PRCTopoContext(std::string n="") :
- ContentPRCBase(n), behaviour(0), granularity(1), tolerance(0),
+ ContentPRCBase(PRC_TYPE_TOPO_Context,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&);
@@ -1384,7 +1430,7 @@ class PRCProductOccurrence: public PRCGraphics, public ContentPRCBase
{
public:
PRCProductOccurrence(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()),
+ ContentPRCBase(PRC_TYPE_ASM_ProductOccurence,n),
index_part(m1),
index_prototype(m1), prototype_in_same_file_structure(true),
index_external_data(m1), external_data_in_same_file_structure(true),
@@ -1413,7 +1459,7 @@ class PRCPartDefinition: public PRCGraphics, public ContentPRCBase, public PRCBo
{
public:
PRCPartDefinition(std::string n="") :
- ContentPRCBase(n,true,makeCADID(),0,makePRCID()) {}
+ ContentPRCBase(PRC_TYPE_ASM_PartDefinition,n) {}
~PRCPartDefinition() { for(PRCRepresentationItemList::iterator it=representation_item.begin(); it!=representation_item.end(); ++it) delete *it; }
void serializePartDefinition(PRCbitStream&);
uint32_t addBrepModel(PRCBrepModel*& pBrepModel);