Scribus
Open source desktop publishing at your fingertips
writePRC.h
1 /************
2 *
3 * This file is part of a tool for producing 3D content in the PRC format.
4 * Copyright (C) 2008 Orest Shardt <shardtor (at) gmail dot com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 *************/
20 
21 #ifndef __WRITE_PRC_H
22 #define __WRITE_PRC_H
23 #include <string>
24 #include <vector>
25 #include <deque>
26 #include <list>
27 
28 #include <map>
29 #include <iostream>
30 #include "PRCbitStream.h"
31 #include "PRC.h"
32 #include <float.h>
33 #include <math.h>
34 
35 static const uint32_t m1=(uint32_t)-1;
36 static const double pi=acos(-1.0);
37 
39 {
40 public :
41  double x;
42  double y;
43  double z;
44  PRCVector3d() :
45  x(0), y(0), z(0) {}
46  PRCVector3d(double fx, double fy, double fz) :
47  x(fx), y(fy), z(fz) {}
48  PRCVector3d(const double c[], double fx=0, double fy=0, double fz=0) :
49  x(c?c[0]:fx), y(c?c[1]:fy), z(c?c[2]:fz) {}
50  PRCVector3d(const PRCVector3d& sVector3d) :
51  x(sVector3d.x), y(sVector3d.y), z(sVector3d.z) {}
52 
53  void Set(double fx, double fy, double fz)
54  { x = fx; y = fy; z = fz; }
55  double Dot(const PRCVector3d & sPt) const
56  { return(x*sPt.x)+(y*sPt.y)+(z*sPt.z); }
57  double LengthSquared()
58  { return(x*x+y*y+z*z); }
59 
60  friend PRCVector3d operator + (const PRCVector3d& a, const PRCVector3d& b)
61  { return PRCVector3d(a.x+b.x,a.y+b.y,a.z+b.z); }
62  friend PRCVector3d operator - (const PRCVector3d& a)
63  { return PRCVector3d(-a.x,-a.y,-a.z); }
64  friend PRCVector3d operator - (const PRCVector3d& a, const PRCVector3d& b)
65  { return PRCVector3d(a.x-b.x,a.y-b.y,a.z-b.z); }
66  friend PRCVector3d operator * (const PRCVector3d& a, const double d)
67  { return PRCVector3d(a.x*d,a.y*d,a.z*d); }
68  friend PRCVector3d operator * (const double d, const PRCVector3d& a)
69  { return PRCVector3d(a.x*d,a.y*d,a.z*d); }
70  friend PRCVector3d operator / (const PRCVector3d& a, const double d)
71  { return PRCVector3d(a.x/d,a.y/d,a.z/d); }
72  friend PRCVector3d operator * (const PRCVector3d& a, const PRCVector3d& b)
73  { return PRCVector3d((a.y*b.z)-(a.z*b.y), (a.z*b.x)-(a.x*b.z), (a.x*b.y)-(a.y*b.x)); }
74 
75  void write(PRCbitStream &out) { out << x << y << z; }
76  void serializeVector3d(PRCbitStream &pbs) const { pbs << x << y << z; }
77  void serializeVector2d(PRCbitStream &pbs) const { pbs << x << y; }
78 
79  double Length();
80  bool Normalize();
81 
82  bool operator==(const PRCVector3d &v) const
83  {
84  return x==v.x && y==v.y && z==v.z;
85  }
86  bool operator!=(const PRCVector3d &v) const
87  {
88  return !(x==v.x && y==v.y && z==v.z);
89  }
90  bool operator<(const PRCVector3d &v) const
91  {
92  if(x!=v.x)
93  return (x<v.x);
94  if(y!=v.y)
95  return (y<v.y);
96  return (z<v.z);
97  }
98  friend std::ostream& operator << (std::ostream& out, const PRCVector3d& v)
99  {
100  out << "(" << v.x << "," << v.y << "," << v.z << ")";
101  return out;
102  }
103 };
104 /*
105 class UUID
106 {
107  public:
108  UUID(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3) :
109  id0(u0),id1(u1),id2(u2),id3(u3) {}
110  void write(PRCbitStream &out)
111  {
112  out << id0 << id1 << id2 << id3;
113  }
114  private:
115  uint32_t id0,id1,id2,id3;
116 }; */
117 
118 void writeUncompressedUnsignedInteger(std::ostream &out, uint32_t data);
119 
120 void writeUnit(PRCbitStream &,bool,double);
121 
122 void writeEmptyMarkups(PRCbitStream&);
123 
124 class UserData
125 {
126  public:
127  UserData(uint32_t s = 0, uint8_t* d = 0) : size(s),data(d) {}
128  void write(PRCbitStream&);
129  private:
130  uint32_t size;
131  uint8_t* data;
132 };
133 
135 {
136  PRCAttributeEntry() : title_is_integer(false) {}
137  PRCAttributeEntry(uint32_t integer) : title_is_integer(true)
138  {
139  title_integer = integer;
140  }
141  PRCAttributeEntry(const std::string &text) : title_is_integer(false)
142  {
143  title_text = text;
144  }
145  void serializeAttributeEntry(PRCbitStream&) const;
146  bool title_is_integer;
147  std::string title_text;
148  uint32_t title_integer;
149 };
150 
152 {
153  public:
154  PRCSingleAttribute() : type(KEPRCModellerAttributeTypeNull) {}
155  PRCSingleAttribute(int32_t integer) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeInt)
156  {
157  value.integer = integer;
158  }
159  PRCSingleAttribute(double real) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeReal)
160  {
161  value.real = real;
162  }
163  PRCSingleAttribute(uint32_t time) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeTime)
164  {
165  value.time = time;
166  }
167  PRCSingleAttribute(const std::string &text) : PRCAttributeEntry(), type(KEPRCModellerAttributeTypeString)
168  {
169  value_text = text;}
170  PRCSingleAttribute(uint32_t title, int32_t integer) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeInt)
171  {
172  value.integer = integer;
173  }
174  PRCSingleAttribute(uint32_t title, double real) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeReal)
175  {
176  value.real = real;
177  }
178  PRCSingleAttribute(uint32_t title, uint32_t time) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeTime)
179  {
180  value.time = time;
181  }
182  PRCSingleAttribute(uint32_t title, const std::string &text) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeString)
183  {
184  value_text = text;
185  }
186  PRCSingleAttribute(const std::string title, int32_t integer) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeInt)
187  {
188  value.integer = integer;
189  }
190  PRCSingleAttribute(const std::string title, double real) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeReal)
191  {
192  value.real = real;
193  }
194  PRCSingleAttribute(const std::string title, uint32_t time) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeTime)
195  {
196  value.time = time;
197  }
198  PRCSingleAttribute(const std::string title, const std::string &text) : PRCAttributeEntry(title), type(KEPRCModellerAttributeTypeString)
199  {
200  value_text = text;
201  }
202  void serializeSingleAttribute(PRCbitStream&) const;
203  EPRCModellerAttributeType type;
205  {
206  int32_t integer;
207  double real;
208  uint32_t time;
209  } value;
210  std::string value_text;
211 };
212 
214 {
215  public:
217  PRCAttribute(uint32_t title) : PRCAttributeEntry(title) {}
218  PRCAttribute(const std::string title) : PRCAttributeEntry(title) {}
219  void serializeAttribute(PRCbitStream &) const;
220  PRCSingleAttribute& newKey() { attribute_keys.resize(attribute_keys.size()+1); return attribute_keys.back(); }
221  void addKey(const PRCSingleAttribute &key) { attribute_keys.push_back(key); }
222  std::deque<PRCSingleAttribute> attribute_keys;
223 };
224 
225 typedef std::list<PRCAttribute> PRCAttributeList;
226 
228 {
229  public:
230  void serializeAttributes(PRCbitStream&) const;
231  PRCAttribute& newAttribute() { attributes.push_front(PRCAttribute()); return attributes.front(); }
232  void addAttribute(const PRCAttribute &attribute) { attributes.push_front(attribute); }
233  PRCAttributeList attributes;
234 };
235 
236 bool type_eligible_for_reference(uint32_t type);
237 uint32_t makeCADID();
238 uint32_t makePRCID();
239 
241 {
242  public:
243  ContentPRCBase(uint32_t t, std::string n="") :
244  type(t),name(n),CAD_identifier(0), CAD_persistent_identifier(0), PRC_unique_identifier(0)
245  {
246  if(type_eligible_for_reference(type))
247  {
248  CAD_identifier = makeCADID();
249  PRC_unique_identifier = makePRCID();
250  }
251  }
252  void serializeContentPRCBase(PRCbitStream&) const;
253  uint32_t getPRCID() const { return PRC_unique_identifier; }
254  uint32_t getType() const { return type; }
255  uint32_t type;
256  std::string name;
257  uint32_t CAD_identifier, CAD_persistent_identifier, PRC_unique_identifier;
258 };
259 
261 {
262 public:
264  type(0), unique_identifier(m1) {}
265  void serializeReferenceUniqueIdentifier(PRCbitStream&);
266  uint32_t type;
267 // bool reference_in_same_file_structure;
268 // PRCUniqueId target_file_structure;
269  uint32_t unique_identifier;
270 };
271 
272 extern std::string currentName;
273 void writeName(PRCbitStream&,const std::string&);
274 void resetName();
275 
276 extern uint32_t current_layer_index;
277 extern uint32_t current_index_of_line_style;
278 extern uint16_t current_behaviour_bit_field;
279 
280 void writeGraphics(PRCbitStream&,uint32_t=m1,uint32_t=m1,uint16_t=1,bool=false);
281 void resetGraphics();
282 
283 void resetGraphicsAndName();
284 
286 {
287  PRCRgbColor(double r=0.0, double g=0.0, double b=0.0) :
288  red(r), green(g), blue(b) {}
289  double red,green,blue;
290  void serializeRgbColor(PRCbitStream&);
291 
292  bool operator==(const PRCRgbColor &c) const
293  {
294  return (red==c.red && green==c.green && blue==c.blue);
295  }
296  bool operator!=(const PRCRgbColor &c) const
297  {
298  return !(red==c.red && green==c.green && blue==c.blue);
299  }
300  bool operator<(const PRCRgbColor &c) const
301  {
302  if(red!=c.red)
303  return (red<c.red);
304  if(green!=c.green)
305  return (green<c.green);
306  return (blue<c.blue);
307  }
308 };
309 
311 {
312 public:
313  PRCPicture(std::string n="") :
314  ContentPRCBase(PRC_TYPE_GRAPH_Picture,n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
315  void serializePicture(PRCbitStream&);
316  EPRCPictureDataFormat format;
317  uint32_t uncompressed_file_index;
318  uint32_t pixel_width;
319  uint32_t pixel_height;
320 };
321 
323 {
324  PRCVector2d() :
325  x(0.0), y(0.0) {}
326  PRCVector2d(double X, double Y) :
327  x(X), y(Y) {}
328  void serializeVector2d(PRCbitStream&);
329  double x;
330  double y;
331  PRCVector2d(const double c[], double fx=0, double fy=0) :
332  x(c?c[0]:fx), y(c?c[1]:fy) {}
333  PRCVector2d(const PRCVector2d& sVector2d) :
334  x(sVector2d.x), y(sVector2d.y) {}
335 
336  void Set(double fx, double fy)
337  { x = fx; y = fy; }
338  double Dot(const PRCVector2d & sPt) const
339  { return(x*sPt.x)+(y*sPt.y); }
340  double LengthSquared()
341  { return(x*x+y*y); }
342 
343  friend PRCVector2d operator + (const PRCVector2d& a, const PRCVector2d& b)
344  { return PRCVector2d(a.x+b.x,a.y+b.y); }
345  friend PRCVector2d operator - (const PRCVector2d& a)
346  { return PRCVector2d(-a.x,-a.y); }
347  friend PRCVector2d operator - (const PRCVector2d& a, const PRCVector2d& b)
348  { return PRCVector2d(a.x-b.x,a.y-b.y); }
349  friend PRCVector2d operator * (const PRCVector2d& a, const double d)
350  { return PRCVector2d(a.x*d,a.y*d); }
351  friend PRCVector2d operator * (const double d, const PRCVector2d& a)
352  { return PRCVector2d(a.x*d,a.y*d); }
353  friend PRCVector2d operator / (const PRCVector2d& a, const double d)
354  { return PRCVector2d(a.x/d,a.y/d); }
355 
356  double Length();
357  bool Normalize();
358 
359  bool operator==(const PRCVector2d &v) const
360  {
361  return x==v.x && y==v.y;
362  }
363  bool operator!=(const PRCVector2d &v) const
364  {
365  return !(x==v.x && y==v.y);
366  }
367  bool operator<(const PRCVector2d &v) const
368  {
369  if(x!=v.x)
370  return (x<v.x);
371  return (y<v.y);
372  }
373  friend std::ostream& operator << (std::ostream& out, const PRCVector2d& v)
374  {
375  out << "(" << v.x << "," << v.y << ")";
376  return out;
377  }
378 };
379 
381 {
382 public:
383  PRCTextureDefinition(std::string n="") :
384  ContentPRCBase(PRC_TYPE_GRAPH_TextureDefinition,n), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE),
385  texture_mapping_attribute_intensity(1.0), texture_mapping_attribute_components(PRC_TEXTURE_MAPPING_COMPONENTS_RGBA),
386  texture_function(KEPRCTextureFunction_Modulate), texture_applying_mode(PRC_TEXTURE_APPLYING_MODE_NONE),
387  texture_wrapping_mode_S(KEPRCTextureWrappingMode_Unknown), texture_wrapping_mode_T(KEPRCTextureWrappingMode_Unknown) // ,
388  // texture_transformation(false), texture_flip_S(false), texture_flip_T(false),
389  // behaviour(PRC_TRANSFORMATION_Identity), scale(1.0,1.0), uniform_scale(1.0)
390  {}
391  void serializeTextureDefinition(PRCbitStream&);
392  uint32_t picture_index;
393  uint32_t texture_mapping_attribute;
394  double texture_mapping_attribute_intensity;
395  uint8_t texture_mapping_attribute_components;
396  EPRCTextureFunction texture_function;
397  uint8_t texture_applying_mode;
398  EPRCTextureWrappingMode texture_wrapping_mode_S;
399  EPRCTextureWrappingMode texture_wrapping_mode_T;
400  // bool texture_transformation;
401  // bool texture_flip_S;
402  // bool texture_flip_T;
403  // uint8_t behaviour;
404  // PRCVector2d origin;
405  // PRCVector2d X;
406  // PRCVector2d Y;
407  // PRCVector2d scale;
408  // double uniform_scale;
409  // double X_homegeneous_coord;
410  // double Y_homegeneous_coord;
411  // double origin_homegeneous_coord;
412 };
413 typedef std::deque <PRCTextureDefinition*> PRCTextureDefinitionList;
414 
416 {
417 public:
418  virtual ~PRCMaterial() {}
419  virtual void serializeMaterial(PRCbitStream&) = 0;
420 };
421 typedef std::deque <PRCMaterial*> PRCMaterialList;
422 
424 {
425 public:
426  PRCMaterialGeneric(std::string n="") :
427  ContentPRCBase(PRC_TYPE_GRAPH_Material,n),
428  ambient(m1), diffuse(m1), emissive(m1), specular(m1),
429  shininess(0.0),
430  ambient_alpha(1.0), diffuse_alpha(1.0), emissive_alpha(1.0), specular_alpha(1.0)
431  {}
432  void serializeMaterialGeneric(PRCbitStream&);
433  void serializeMaterial(PRCbitStream &pbs) { serializeMaterialGeneric(pbs); }
434  uint32_t picture_index;
435  uint32_t ambient;
436  uint32_t diffuse;
437  uint32_t emissive;
438  uint32_t specular;
439  double shininess;
440  double ambient_alpha;
441  double diffuse_alpha;
442  double emissive_alpha;
443  double specular_alpha;
444 
445  bool operator==(const PRCMaterialGeneric &m) const
446  {
447  return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive && specular==m.specular && shininess==m.shininess &&
448  ambient_alpha==m.ambient_alpha && diffuse_alpha==m.diffuse_alpha && emissive_alpha==m.emissive_alpha && specular_alpha==m.specular_alpha);
449  }
450 };
451 
453 {
454 public:
455  PRCTextureApplication(std::string n="") :
456  ContentPRCBase(PRC_TYPE_GRAPH_TextureApplication,n),
457  material_generic_index(m1), texture_definition_index(m1),
458  next_texture_index(m1), UV_coordinates_index(0)
459  {}
460  void serializeTextureApplication(PRCbitStream&);
461  void serializeMaterial(PRCbitStream &pbs) { serializeTextureApplication(pbs); }
462  uint32_t material_generic_index;
463  uint32_t texture_definition_index;
464  uint32_t next_texture_index;
465  uint32_t UV_coordinates_index;
466 };
467 
469 {
470 public:
471  PRCLinePattern(std::string n="") :
472  ContentPRCBase(PRC_TYPE_GRAPH_LinePattern,n),
473  phase(0), is_real_length(false) {}
474  void serializeLinePattern(PRCbitStream&);
475  std::vector<double> lengths;
476  double phase;
477  bool is_real_length;
478 };
479 typedef std::deque <PRCLinePattern*> PRCLinePatternList;
480 
481 class PRCStyle : public ContentPRCBase
482 {
483 public:
484  PRCStyle(std::string n="") :
485  ContentPRCBase(PRC_TYPE_GRAPH_Style,n), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1),
486  is_material(false), color_material_index(m1), is_transparency_defined(false), transparency(255), additional(0)
487  {}
488  void serializeCategory1LineStyle(PRCbitStream&);
489  double line_width;
490  bool is_vpicture;
491  uint32_t line_pattern_vpicture_index;
492  bool is_material;
493  uint32_t color_material_index;
494  bool is_transparency_defined;
495  uint8_t transparency;
496  uint8_t additional;
497 };
498 typedef std::deque <PRCStyle*> PRCStyleList;
499 
501 {
502 public:
503  PRCTessFace() :
504  start_wire(0), used_entities_flag(0),
505  start_triangulated(0), number_of_texture_coordinate_indexes(0),
506  is_rgba(false), behaviour(PRC_GRAPHICS_Show)
507  {}
508  void serializeTessFace(PRCbitStream&);
509  std::vector<uint32_t> line_attributes;
510  uint32_t start_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
511  std::vector<uint32_t> sizes_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
512  uint32_t used_entities_flag;
513  uint32_t start_triangulated;
514  std::vector<uint32_t> sizes_triangulated;
515  uint32_t number_of_texture_coordinate_indexes;
516  bool is_rgba;
517  std::vector<uint8_t> rgba_vertices;
518  uint32_t behaviour;
519 };
520 typedef std::deque <PRCTessFace*> PRCTessFaceList;
521 
523 {
524 public:
526  is_calculated(false) {}
527  void serializeContentBaseTessData(PRCbitStream&);
528  bool is_calculated;
529  std::vector<double> coordinates;
530 };
531 
533 {
534 public:
535  virtual ~PRCTess() {}
536  virtual void serializeBaseTessData(PRCbitStream &pbs) = 0;
537 };
538 typedef std::deque <PRCTess*> PRCTessList;
539 
540 class PRC3DTess : public PRCTess
541 {
542 public:
543  PRC3DTess() :
544  has_faces(false), has_loops(false),
545  crease_angle(25.8419) // arccos(0.9), default found in Acrobat output
546  {}
547  ~PRC3DTess() { for(PRCTessFaceList::iterator it=face_tessellation.begin(); it!=face_tessellation.end(); ++it) delete *it; }
548  void serialize3DTess(PRCbitStream&);
549  void serializeBaseTessData(PRCbitStream &pbs) { serialize3DTess(pbs); }
550  void addTessFace(PRCTessFace*& pTessFace);
551 
552  bool has_faces;
553  bool has_loops;
554  double crease_angle;
555  std::vector<double> normal_coordinate;
556  std::vector<uint32_t> wire_index; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
557  std::vector<uint32_t> triangulated_index;
558  PRCTessFaceList face_tessellation;
559  std::vector<double> texture_coordinate;
560 };
561 
562 class PRC3DWireTess : public PRCTess
563 {
564 public:
565  PRC3DWireTess() :
566  is_rgba(false), is_segment_color(false) {}
567  void serialize3DWireTess(PRCbitStream&);
568  void serializeBaseTessData(PRCbitStream &pbs) { serialize3DWireTess(pbs); }
569 
570  bool is_rgba;
571  bool is_segment_color;
572  std::vector<uint32_t> wire_indexes;
573  std::vector<uint8_t> rgba_vertices;
574 };
575 
576 class PRCMarkupTess : public PRCTess
577 {
578 public:
579  PRCMarkupTess() :
580  behaviour(0)
581  {}
582  void serializeMarkupTess(PRCbitStream&);
583  void serializeBaseTessData(PRCbitStream &pbs) { serializeMarkupTess(pbs); }
584 
585  std::vector<uint32_t> codes;
586  std::vector<std::string> texts;
587  std::string label;
588  uint8_t behaviour;
589 };
590 
592 {
593 public:
594  PRCGraphics() : layer_index(m1), index_of_line_style(m1), behaviour_bit_field(PRC_GRAPHICS_Show) {}
595  void serializeGraphics(PRCbitStream&);
596  void serializeGraphicsForced(PRCbitStream&);
597  bool has_graphics() { return (index_of_line_style!=m1 || layer_index!=m1 || behaviour_bit_field!=PRC_GRAPHICS_Show) ; }
598  uint32_t layer_index;
599  uint32_t index_of_line_style;
600  uint16_t behaviour_bit_field;
601 };
602 typedef std::deque <PRCGraphics*> PRCGraphicsList;
603 
604 void writeGraphics(PRCbitStream&,const PRCGraphics&,bool=false);
605 
606 class PRCMarkup: public PRCGraphics, public ContentPRCBase
607 {
608 public:
609  PRCMarkup(std::string n="") :
610  ContentPRCBase(PRC_TYPE_MKP_Markup,n),
611  type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {}
612  void serializeMarkup(PRCbitStream&);
613  EPRCMarkupType type;
614  EPRCMarkupSubType sub_type;
615 // vector<PRCReferenceUniqueIdentifier> linked_items;
616 // vector<PRCReferenceUniqueIdentifier> leaders;
617  uint32_t index_tessellation;
618 };
619 typedef std::deque <PRCMarkup*> PRCMarkupList;
620 
622 {
623 public:
624  PRCAnnotationItem(std::string n="") :
625  ContentPRCBase(PRC_TYPE_MKP_AnnotationItem,n) {}
626  void serializeAnnotationItem(PRCbitStream&);
627  void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); }
629 };
630 typedef std::deque <PRCAnnotationItem*> PRCAnnotationItemList;
631 
633 {
634 public:
635  PRCRepresentationItemContent(uint32_t t, std::string n="") :
636  ContentPRCBase(t,n),
637  index_local_coordinate_system(m1), index_tessellation(m1) {}
638  void serializeRepresentationItemContent(PRCbitStream&);
639  uint32_t index_local_coordinate_system;
640  uint32_t index_tessellation;
641 };
642 
644 {
645 public:
646  PRCRepresentationItem(uint32_t t, std::string n="") :
648  virtual ~PRCRepresentationItem() {}
649  virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0;
650 };
651 typedef std::deque <PRCRepresentationItem*> PRCRepresentationItemList;
652 
654 {
655 public:
656  PRCBrepModel(std::string n="") :
657  PRCRepresentationItem(PRC_TYPE_RI_BrepModel,n), has_brep_data(true), context_id(m1), body_id(m1), is_closed(false) {}
658  void serializeBrepModel(PRCbitStream&);
659  void serializeRepresentationItem(PRCbitStream &pbs) { serializeBrepModel(pbs); }
660  bool has_brep_data;
661  uint32_t context_id;
662  uint32_t body_id;
663  bool is_closed;
664 };
665 
667 {
668 public:
669  PRCPolyBrepModel(std::string n="") :
670  PRCRepresentationItem(PRC_TYPE_RI_PolyBrepModel,n), is_closed(false) {}
671  void serializePolyBrepModel(PRCbitStream&);
672  void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyBrepModel(pbs); }
673  bool is_closed;
674 };
675 
677 {
678 public:
679  PRCPointSet(std::string n="") :
680  PRCRepresentationItem(PRC_TYPE_RI_PointSet,n) {}
681  void serializePointSet(PRCbitStream&);
682  void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); }
683  std::vector<PRCVector3d> point;
684 };
685 
687 {
688 public:
689  PRCWire(std::string n="") :
690  PRCRepresentationItem(PRC_TYPE_RI_Curve,n), has_wire_body(true), context_id(m1), body_id(m1) {}
691  void serializeWire(PRCbitStream&);
692  void serializeRepresentationItem(PRCbitStream &pbs) { serializeWire(pbs); }
693  bool has_wire_body;
694  uint32_t context_id;
695  uint32_t body_id;
696 };
697 
699 {
700 public:
701  PRCPolyWire(std::string n="") :
702  PRCRepresentationItem(PRC_TYPE_RI_PolyWire,n) {}
703  void serializePolyWire(PRCbitStream&);
704  void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyWire(pbs); }
705 };
706 
708 {
709 public:
710  PRCSet(std::string n="") :
711  PRCRepresentationItem(PRC_TYPE_RI_Set,n) {}
712  ~PRCSet() { for(PRCRepresentationItemList::iterator it=elements.begin(); it!=elements.end(); ++it) delete *it; }
713  void serializeSet(PRCbitStream&);
714  void serializeRepresentationItem(PRCbitStream &pbs) { serializeSet(pbs); }
715  uint32_t addBrepModel(PRCBrepModel*& pBrepModel);
716  uint32_t addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel);
717  uint32_t addPointSet(PRCPointSet*& pPointSet);
718  uint32_t addSet(PRCSet*& pSet);
719  uint32_t addWire(PRCWire*& pWire);
720  uint32_t addPolyWire(PRCPolyWire*& pPolyWire);
721  uint32_t addRepresentationItem(PRCRepresentationItem*& pRepresentationItem);
722  PRCRepresentationItemList elements;
723 };
724 
726 {
727 public:
728  virtual ~PRCTransformation3d() {}
729  virtual void serializeTransformation3d(PRCbitStream&) const =0;
730 };
731 typedef std::deque <PRCTransformation3d*> PRCTransformation3dList;
732 
734 {
735 public:
737  {
738  setidentity();
739  }
740  PRCGeneralTransformation3d(const double t[])
741  {
742  set(t);
743  }
744 
745  void serializeGeneralTransformation3d(PRCbitStream&) const;
746  void serializeTransformation3d(PRCbitStream& pbs) const { serializeGeneralTransformation3d(pbs); }
747  double m_coef[16];
748  bool operator==(const PRCGeneralTransformation3d &t) const
749  {
750  for (size_t i=0;i<16;i++)
751  if(m_coef[i]!=t.m_coef[i])
752  return false;
753  return true;
754  }
755  bool operator<(const PRCGeneralTransformation3d &t) const
756  {
757  for (size_t i=0;i<16;i++)
758  if(m_coef[i]!=t.m_coef[i])
759  {
760  return (m_coef[i]<t.m_coef[i]);
761  }
762  return false;
763  }
764  void set(const double t[])
765  {
766  if(t!=NULL)
767  for (size_t i=0;i<16;i++)
768  m_coef[i]=t[i];
769  else
770  setidentity();
771  }
772  void setidentity()
773  {
774  m_coef[0]=1; m_coef[4]=0; m_coef[ 8]=0; m_coef[12]=0;
775  m_coef[1]=0; m_coef[5]=1; m_coef[ 9]=0; m_coef[13]=0;
776  m_coef[2]=0; m_coef[6]=0; m_coef[10]=1; m_coef[14]=0;
777  m_coef[3]=0; m_coef[7]=0; m_coef[11]=0; m_coef[15]=1;
778  }
779  bool isnotidtransform() const {
780  return(
781  m_coef[0]!=1 || m_coef[4]!=0 || m_coef[ 8]!=0 || m_coef[12]!=0 ||
782  m_coef[1]!=0 || m_coef[5]!=1 || m_coef[ 9]!=0 || m_coef[13]!=0 ||
783  m_coef[2]!=0 || m_coef[6]!=0 || m_coef[10]!=1 || m_coef[14]!=0 ||
784  m_coef[3]!=0 || m_coef[7]!=0 || m_coef[11]!=0 || m_coef[15]!=1 );
785  }
786  bool isidtransform() const {
787  return(
788  m_coef[0]==1 && m_coef[4]==0 && m_coef[ 8]==0 && m_coef[12]==0 &&
789  m_coef[1]==0 && m_coef[5]==1 && m_coef[ 9]==0 && m_coef[13]==0 &&
790  m_coef[2]==0 && m_coef[6]==0 && m_coef[10]==1 && m_coef[14]==0 &&
791  m_coef[3]==0 && m_coef[7]==0 && m_coef[11]==0 && m_coef[15]==1 );
792  }
793  double M(size_t i, size_t j) const {
794  return m_coef[i+j*4];
795  }
796 };
797 typedef std::deque <PRCGeneralTransformation3d> PRCGeneralTransformation3dList;
798 
800 {
801 public:
803  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),
804  scale(1.0,1.0,1.0), uniform_scale(1.0),
805  X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0) {}
806  PRCCartesianTransformation3d(const double o[3], const double x[3], const double y[3], double sc) :
807  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),
808  scale(1.0,1.0,1.0), uniform_scale(sc),
809  X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0)
810  {
811  if(origin!=PRCVector3d(0.0,0.0,0.0))
812  behaviour = behaviour | PRC_TRANSFORMATION_Translate;
813  if(X!=PRCVector3d(1.0,0.0,0.0) || Y!=PRCVector3d(0.0,1.0,0.0))
814  behaviour = behaviour | PRC_TRANSFORMATION_Rotate;
815  if(uniform_scale!=1)
816  behaviour = behaviour | PRC_TRANSFORMATION_Scale;
817  }
818  void serializeCartesianTransformation3d(PRCbitStream& pbs) const;
819  void serializeTransformation3d(PRCbitStream& pbs) const { serializeCartesianTransformation3d(pbs); }
820  uint8_t behaviour;
821  PRCVector3d origin;
822  PRCVector3d X;
823  PRCVector3d Y;
824  PRCVector3d Z;
825  PRCVector3d scale;
826  double uniform_scale;
827  double X_homogeneous_coord;
828  double Y_homogeneous_coord;
829  double Z_homogeneous_coord;
830  double origin_homogeneous_coord;
831  bool operator==(const PRCCartesianTransformation3d &t) const
832  {
833  return behaviour==t.behaviour && origin==t.origin && X==t.X && Y==t.Y && Z==t.Z && scale==t.scale && uniform_scale==t.uniform_scale &&
834  X_homogeneous_coord==t.X_homogeneous_coord && Y_homogeneous_coord==t.Y_homogeneous_coord &&
835  Z_homogeneous_coord==t.Z_homogeneous_coord && origin_homogeneous_coord==t.origin_homogeneous_coord;
836  }
837 };
838 
840 {
841 public:
843  has_transformation(false), geometry_is_2D(false), behaviour(PRC_TRANSFORMATION_Identity),
844  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) {}
845  void serializeTransformation(PRCbitStream&);
846  bool has_transformation;
847  bool geometry_is_2D;
848  uint8_t behaviour;
849  PRCVector3d origin;
850  PRCVector3d x_axis;
851  PRCVector3d y_axis;
852  double scale;
853 };
854 
856 {
857 public:
858  PRCCoordinateSystem(std::string n="") :
859  PRCRepresentationItem(PRC_TYPE_RI_CoordinateSystem,n), axis_set(NULL) {}
860  ~PRCCoordinateSystem() { delete axis_set; }
861  void serializeCoordinateSystem(PRCbitStream&);
862  void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); }
863  void setAxisSet(PRCGeneralTransformation3d*& transform) { axis_set = transform; transform = NULL; }
864  void setAxisSet(PRCCartesianTransformation3d*& transform) { axis_set = transform; transform = NULL; }
865  PRCTransformation3d *axis_set;
866  bool operator==(const PRCCoordinateSystem &t) const
867  {
868  if(index_local_coordinate_system!=t.index_local_coordinate_system)
869  return false;
870  PRCGeneralTransformation3d* axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(axis_set);
871  PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(t.axis_set);
872  PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(axis_set);
873  PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(t.axis_set);
874  if(axis_set_general!=NULL)
875  return (t_axis_set_general!=NULL?(*axis_set_general==*t_axis_set_general):false);
876  if(axis_set_cartesian!=NULL)
877  return (t_axis_set_cartesian!=NULL?(*axis_set_cartesian==*t_axis_set_cartesian):false);
878  return false;
879  }
880 };
881 typedef std::deque <PRCCoordinateSystem*> PRCCoordinateSystemList;
882 
884 {
885  uint32_t font_size;
886  uint8_t attributes;
887 };
888 
890 {
891 public:
892  void serializeFontKeysSameFont(PRCbitStream&);
893  std::string font_name;
894  uint32_t char_set;
895  std::vector<PRCFontKey> font_keys;
896 
897 };
898 
899 // Topology
901 {
902 public:
903  PRCBaseGeometry() :
904  base_information(false), identifier(0) {}
905  PRCBaseGeometry(std::string n, uint32_t id = 0) :
906  base_information(true),name(n),identifier(id) {}
907  void serializeBaseGeometry(PRCbitStream&);
908  bool base_information;
909  std::string name;
910  uint32_t identifier;
911 };
912 
914 {
915 public:
916  PRCBoundingBox() : min(0.0,0.0,0.0), max(0.0,0.0,0.0) {}
917  PRCBoundingBox(const PRCVector3d &m1, const PRCVector3d& m2) : min(m1),max(m2) {}
918  void serializeBoundingBox(PRCbitStream &pbs);
919  PRCVector3d min;
920  PRCVector3d max;
921 };
922 
924 {
925 public:
926  void serializeDomain(PRCbitStream &pbs);
927  PRCVector2d min;
928  PRCVector2d max;
929 };
930 
932 {
933 public:
934  PRCInterval() : min(0), max(0) {}
935  PRCInterval(double m, double M) : min(m), max(M) {}
936  void serializeInterval(PRCbitStream &pbs);
937  double min;
938  double max;
939 };
940 
942 {
943 public:
944  PRCParameterization() : parameterization_coeff_a(1), parameterization_coeff_b(0) {}
945  PRCParameterization(double min, double max) : interval(min, max), parameterization_coeff_a(1), parameterization_coeff_b(0) {}
946  void serializeParameterization(PRCbitStream &pbs);
947  PRCInterval interval;
948  double parameterization_coeff_a;
949  double parameterization_coeff_b;
950 };
951 
953 {
954 public:
955  PRCUVParameterization() : swap_uv(false),
956  parameterization_on_u_coeff_a(1), parameterization_on_v_coeff_a(1),
957  parameterization_on_u_coeff_b(0), parameterization_on_v_coeff_b(0) {}
958  void serializeUVParameterization(PRCbitStream &pbs);
959  bool swap_uv;
960  PRCDomain uv_domain;
961  double parameterization_on_u_coeff_a;
962  double parameterization_on_v_coeff_a;
963  double parameterization_on_u_coeff_b;
964  double parameterization_on_v_coeff_b;
965 };
966 
968 {
969 public:
970  PRCControlPoint() :
971  x(0), y(0), z(0), w(1) {}
972  PRCControlPoint(double X, double Y, double Z=0, double W=1) :
973  x(X), y(Y), z(Z), w(W) {}
974  PRCControlPoint(const PRCVector3d &v) :
975  x(v.x), y(v.y), z(v.z), w(1) {}
976  void Set(double fx, double fy, double fz, double fw=1)
977  { x = fx; y = fy; z = fz; w = fw; }
978  double x;
979  double y;
980  double z;
981  double w;
982 };
983 
985 {
986 public:
988  PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone) {}
989  PRCContentSurface(std::string n) :
990  PRCBaseGeometry(n,makeCADID()),extend_info(KEPRCExtendTypeNone) {}
991  void serializeContentSurface(PRCbitStream&);
992  EPRCExtendType extend_info;
993 };
994 
996 {
997 public:
998  PRCSurface() :
999  PRCContentSurface() {}
1000  PRCSurface(std::string n) :
1001  PRCContentSurface(n) {}
1002  virtual ~PRCSurface() {}
1003  virtual void serializeSurface(PRCbitStream &pbs) = 0;
1004 };
1005 
1007 {
1008 public:
1009  PRCNURBSSurface() :
1010  PRCSurface(), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {}
1011  PRCNURBSSurface(std::string n) :
1012  PRCSurface(n), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {}
1013  void serializeNURBSSurface(PRCbitStream &pbs);
1014  void serializeSurface(PRCbitStream &pbs) { serializeNURBSSurface(pbs); }
1015  bool is_rational;
1016  uint32_t degree_in_u;
1017  uint32_t degree_in_v;
1018  std::vector<PRCControlPoint> control_point;
1019  std::vector<double> knot_u;
1020  std::vector<double> knot_v;
1021  const EPRCKnotType knot_type;
1022  const EPRCBSplineSurfaceForm surface_form;
1023 };
1024 
1026 {
1027 public:
1028  PRCContentCurve() :
1029  PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone), is_3d(true) {}
1030  PRCContentCurve(std::string n) :
1031  PRCBaseGeometry(n,makeCADID()),extend_info(KEPRCExtendTypeNone), is_3d(true) {}
1032  void serializeContentCurve(PRCbitStream&);
1033  EPRCExtendType extend_info;
1034  bool is_3d;
1035 };
1036 
1038 {
1039 public:
1040  PRCCurve() :
1041  PRCContentCurve() {}
1042  PRCCurve(std::string n) :
1043  PRCContentCurve(n) {}
1044  virtual ~PRCCurve() {}
1045  virtual void serializeCurve(PRCbitStream &pbs) = 0;
1046 };
1047 typedef std::deque <PRCCurve*> PRCCurveList;
1048 
1049 class PRCNURBSCurve : public PRCCurve
1050 {
1051 public:
1052  PRCNURBSCurve() :
1053  PRCCurve(), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {}
1054  PRCNURBSCurve(std::string n) :
1055  PRCCurve(n), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {}
1056  void serializeNURBSCurve(PRCbitStream &pbs);
1057  void serializeCurve(PRCbitStream &pbs) { serializeNURBSCurve(pbs); }
1058  bool is_rational;
1059  uint32_t degree;
1060  std::vector<PRCControlPoint> control_point;
1061  std::vector<double> knot;
1062  const EPRCKnotType knot_type;
1063  const EPRCBSplineCurveForm curve_form;
1064 };
1065 
1067 {
1068 public:
1069  PRCPolyLine() :
1070  PRCCurve() {}
1071  PRCPolyLine(std::string n) :
1072  PRCCurve(n) {}
1073  void serializePolyLine(PRCbitStream &pbs);
1074  void serializeCurve(PRCbitStream &pbs) { serializePolyLine(pbs); }
1075  std::vector<PRCVector3d> point;
1076 };
1077 
1079 {
1080 public:
1081  PRCCircle() :
1082  PRCCurve(), PRCParameterization(0,2*pi) {}
1083  PRCCircle(std::string n) :
1084  PRCCurve(n), PRCParameterization(0,2*pi) {}
1085  void serializeCircle(PRCbitStream &pbs);
1086  void serializeCurve(PRCbitStream &pbs) { serializeCircle(pbs); }
1087  double radius;
1088 };
1089 
1091 {
1092 public:
1093  PRCComposite() :
1094  PRCCurve() {}
1095  PRCComposite(std::string n) :
1096  PRCCurve(n) {}
1097  void serializeComposite(PRCbitStream &pbs);
1098  void serializeCurve(PRCbitStream &pbs) { serializeComposite(pbs); }
1099  PRCCurveList base_curve;
1100  std::vector<bool> base_sense;
1101  bool is_closed;
1102 };
1103 
1105 {
1106 public:
1107  PRCBlend01() :
1108  PRCSurface(), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {}
1109  PRCBlend01(std::string n) :
1110  PRCSurface(n), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {}
1111  ~PRCBlend01() { delete center_curve; delete origin_curve; delete tangent_curve; }
1112  void serializeBlend01(PRCbitStream &pbs);
1113  void serializeSurface(PRCbitStream &pbs) { serializeBlend01(pbs); }
1114 // void setCenterCurve (PRCCurve*& curve) { center_curve = curve; curve = NULL; }
1115 // void setOriginCurve (PRCCurve*& curve) { origin_curve = curve; curve = NULL; }
1116 // void setTangentCurve(PRCCurve*& curve) { tangent_curve = curve; curve = NULL; }
1117  PRCCurve* center_curve;
1118  PRCCurve* origin_curve;
1119  PRCCurve* tangent_curve;
1120 };
1121 
1123 {
1124 public:
1125  PRCRuled() :
1126  PRCSurface(), first_curve(NULL), second_curve(NULL) {}
1127  PRCRuled(std::string n) :
1128  PRCSurface(n) {}
1129  ~PRCRuled() { delete first_curve; delete second_curve; }
1130  void serializeRuled(PRCbitStream &pbs);
1131  void serializeSurface(PRCbitStream &pbs) { serializeRuled(pbs); }
1132 // void setFirstCurve(PRCCurve*& curve) { first_curve = curve; curve = NULL; }
1133 // void setSecondCurve(PRCCurve*& curve) { second_curve = curve; curve = NULL; }
1134  PRCCurve* first_curve;
1135  PRCCurve* second_curve;
1136 };
1137 
1139 {
1140 public:
1141  PRCSphere() :
1142  PRCSurface() {}
1143  PRCSphere(std::string n) :
1144  PRCSurface(n) {}
1145  void serializeSphere(PRCbitStream &pbs);
1146  void serializeSurface(PRCbitStream &pbs) { serializeSphere(pbs); }
1147  double radius;
1148 };
1149 
1151 {
1152 public:
1153  PRCCone() :
1154  PRCSurface() {}
1155  PRCCone(std::string n) :
1156  PRCSurface(n) {}
1157  void serializeCone(PRCbitStream &pbs);
1158  void serializeSurface(PRCbitStream &pbs) { serializeCone(pbs); }
1159  double bottom_radius;
1160  double semi_angle;
1161 };
1162 
1164 {
1165 public:
1166  PRCCylinder() :
1167  PRCSurface() {}
1168  PRCCylinder(std::string n) :
1169  PRCSurface(n) {}
1170  void serializeCylinder(PRCbitStream &pbs);
1171  void serializeSurface(PRCbitStream &pbs) { serializeCylinder(pbs); }
1172  double radius;
1173 };
1174 
1176 {
1177 public:
1178  PRCTorus() :
1179  PRCSurface() {}
1180  PRCTorus(std::string n) :
1181  PRCSurface(n) {}
1182  void serializeTorus(PRCbitStream &pbs);
1183  void serializeSurface(PRCbitStream &pbs) { serializeTorus(pbs); }
1184  double major_radius;
1185  double minor_radius;
1186 };
1187 
1189 {
1190 public:
1191  PRCBaseTopology() :
1192  base_information(false),identifier(0) {}
1193  PRCBaseTopology(std::string n, uint32_t id = 0) :
1194  base_information(true),name(n),identifier(id) {}
1195  void serializeBaseTopology(PRCbitStream&);
1196  bool base_information;
1197  std::string name;
1198  uint32_t identifier;
1199 };
1200 
1202 {
1203 public:
1204  virtual ~PRCTopoItem() {}
1205  virtual void serializeTopoItem(PRCbitStream&)=0;
1206 };
1207 
1209 {
1210 public:
1211  PRCContentBody() :
1212  PRCBaseTopology(), behavior(0) {}
1213  PRCContentBody(std::string n) :
1214  PRCBaseTopology(n,makeCADID()), behavior(0) {}
1215  void serializeContentBody(PRCbitStream&);
1216  uint8_t behavior;
1217 };
1218 
1219 class PRCBody : public PRCContentBody, public PRCTopoItem
1220 {
1221 public:
1222  PRCBody() :
1223  PRCContentBody(), topo_item_type(PRC_TYPE_ROOT) {}
1224  PRCBody(uint32_t tit) :
1225  PRCContentBody(), topo_item_type(tit) {}
1226  PRCBody(uint32_t tit, std::string n) :
1227  PRCContentBody(n), topo_item_type(tit) {}
1228  virtual ~PRCBody() {}
1229  virtual void serializeBody(PRCbitStream &pbs) = 0;
1230  void serializeTopoItem(PRCbitStream &pbs) { serializeBody(pbs); }
1231  uint32_t serialType() { return topo_item_type; }
1232  virtual double serialTolerance() { return 0; }
1233  const uint32_t topo_item_type;
1234 };
1235 typedef std::deque <PRCBody*> PRCBodyList;
1236 
1238 {
1239 public:
1240  PRCContentWireEdge() :
1241  PRCBaseTopology(), curve_3d(NULL), has_curve_trim_interval(false) {}
1242  PRCContentWireEdge(std::string n) :
1243  PRCBaseTopology(n,makeCADID()), curve_3d(NULL), has_curve_trim_interval(false) {}
1244  ~PRCContentWireEdge() { delete curve_3d; }
1245  void serializeContentWireEdge(PRCbitStream &pbs);
1246 // void setCurve(PRCCurve*& curve) { curve_3d = curve; curve = NULL; }
1247  PRCCurve* curve_3d;
1248  bool has_curve_trim_interval;
1249  PRCInterval curve_trim_interval;
1250 };
1251 
1253 {
1254 public:
1255  void serializeWireEdge(PRCbitStream &pbs);
1256  void serializeTopoItem(PRCbitStream &pbs) { serializeWireEdge(pbs); }
1257 };
1258 
1260 {
1261 public:
1262  PRCSingleWireBody() :
1263  PRCBody(PRC_TYPE_TOPO_SingleWireBody), wire_edge(NULL) {}
1264  PRCSingleWireBody(std::string n) :
1265  PRCBody(PRC_TYPE_TOPO_SingleWireBody, n), wire_edge(NULL) {}
1266  ~PRCSingleWireBody() { delete wire_edge; }
1267  void serializeSingleWireBody(PRCbitStream &pbs);
1268  void serializeBody(PRCbitStream &pbs) { serializeSingleWireBody(pbs); }
1269  void setWireEdge(PRCWireEdge*& wireEdge) { wire_edge = wireEdge; wireEdge = NULL; }
1270  PRCWireEdge* wire_edge;
1271 };
1272 
1273 class PRCFace : public PRCBaseTopology, public PRCTopoItem, public PRCGraphics
1274 {
1275 public:
1276  PRCFace() :
1277  PRCBaseTopology(), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
1278  PRCFace(std::string n) :
1279  PRCBaseTopology(n,makeCADID()), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
1280  ~PRCFace() { delete base_surface; }
1281  void serializeFace(PRCbitStream &pbs);
1282  void serializeTopoItem(PRCbitStream &pbs) { serializeFace(pbs); }
1283  void setBaseSurface(PRCSurface*& surface) { base_surface = surface; surface = NULL; }
1284  PRCSurface *base_surface;
1285  const bool have_surface_trim_domain;
1286  PRCDomain surface_trim_domain;
1287  const bool have_tolerance;
1288  const double tolerance;
1289  const uint32_t number_of_loop;
1290  const int32_t outer_loop_index;
1291 // PRCLoopList loop;
1292 };
1293 typedef std::deque <PRCFace*> PRCFaceList;
1294 
1295 class PRCShell : public PRCBaseTopology, public PRCTopoItem
1296 {
1297 public:
1298  PRCShell() :
1299  PRCBaseTopology(), shell_is_closed(false) {}
1300  PRCShell(std::string n) :
1301  PRCBaseTopology(n,makeCADID()), shell_is_closed(false) {}
1302  ~PRCShell() { for(PRCFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; }
1303  void serializeShell(PRCbitStream &pbs);
1304  void serializeTopoItem(PRCbitStream &pbs) { serializeShell(pbs); }
1305  void addFace(PRCFace*& pFace, uint8_t orientation=2);
1306  bool shell_is_closed;
1307  PRCFaceList face;
1308  std::vector<uint8_t> orientation_surface_with_shell;
1309 };
1310 typedef std::deque <PRCShell*> PRCShellList;
1311 
1312 class PRCConnex : public PRCBaseTopology, public PRCTopoItem
1313 {
1314 public:
1315  PRCConnex() :
1316  PRCBaseTopology() {}
1317  PRCConnex(std::string n) :
1318  PRCBaseTopology(n,makeCADID()) {}
1319  ~PRCConnex() { for(PRCShellList::iterator it=shell.begin(); it!=shell.end(); ++it) delete *it; }
1320  void serializeConnex(PRCbitStream &pbs);
1321  void serializeTopoItem(PRCbitStream &pbs) { serializeConnex(pbs); }
1322  void addShell(PRCShell*& pShell);
1323  PRCShellList shell;
1324 };
1325 typedef std::deque <PRCConnex*> PRCConnexList;
1326 
1327 class PRCBrepData : public PRCBody, public PRCBoundingBox
1328 {
1329 public:
1330  PRCBrepData() :
1331  PRCBody(PRC_TYPE_TOPO_BrepData) {}
1332  PRCBrepData(std::string n) :
1333  PRCBody(PRC_TYPE_TOPO_BrepData, n) {}
1334  ~PRCBrepData() { for(PRCConnexList::iterator it=connex.begin(); it!=connex.end(); ++it) delete *it; }
1335  void serializeBrepData(PRCbitStream &pbs);
1336  void serializeBody(PRCbitStream &pbs) { serializeBrepData(pbs); }
1337  void addConnex(PRCConnex*& pConnex);
1338  PRCConnexList connex;
1339 };
1340 
1341 // For now - treat just the case of Bezier surfaces cubic 4x4 or linear 2x2
1343 {
1344 public:
1345  PRCCompressedFace() :
1346  PRCBaseTopology(), orientation_surface_with_shell(true), degree(0) {}
1347  PRCCompressedFace(std::string n) :
1348  PRCBaseTopology(n,makeCADID()), orientation_surface_with_shell(true), degree(0) {}
1349  void serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance);
1350  void serializeContentCompressedFace(PRCbitStream &pbs);
1351  void serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance);
1352  void serializeCompressedNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance);
1353  bool orientation_surface_with_shell;
1354  uint32_t degree;
1355  std::vector<PRCVector3d> control_point;
1356 };
1357 typedef std::deque <PRCCompressedFace*> PRCCompressedFaceList;
1358 
1359 // For now - treat just the case of one connex/one shell
1361 {
1362 public:
1364  PRCBody(PRC_TYPE_TOPO_BrepDataCompress), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
1365  PRCCompressedBrepData(std::string n) :
1366  PRCBody(PRC_TYPE_TOPO_BrepDataCompress, n), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
1367  ~PRCCompressedBrepData() { for(PRCCompressedFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; }
1368  void serializeCompressedBrepData(PRCbitStream &pbs);
1369  void serializeBody(PRCbitStream &pbs) { serializeCompressedBrepData(pbs); }
1370  void serializeCompressedShell(PRCbitStream &pbs);
1371  double serialTolerance() { return serial_tolerance; }
1372  double serial_tolerance;
1373  double brep_data_compressed_tolerance;
1374  PRCCompressedFaceList face;
1375 };
1376 
1378 {
1379 public:
1380  PRCTopoContext(std::string n="") :
1381  ContentPRCBase(PRC_TYPE_TOPO_Context,n), behaviour(0), granularity(1), tolerance(0),
1382  have_smallest_face_thickness(false), smallest_thickness(0), have_scale(false), scale(1) {}
1383  ~PRCTopoContext() { for(PRCBodyList::iterator it=body.begin(); it!=body.end(); ++it) delete *it; }
1384  void serializeTopoContext(PRCbitStream&);
1385  void serializeContextAndBodies(PRCbitStream&);
1386  void serializeGeometrySummary(PRCbitStream&);
1387  void serializeContextGraphics(PRCbitStream&);
1388  uint32_t addSingleWireBody(PRCSingleWireBody*& body);
1389  uint32_t addBrepData(PRCBrepData*& body);
1390  uint32_t addCompressedBrepData(PRCCompressedBrepData*& body);
1391  uint8_t behaviour;
1392  double granularity;
1393  double tolerance;
1394  bool have_smallest_face_thickness;
1395  double smallest_thickness;
1396  bool have_scale;
1397  double scale;
1398  PRCBodyList body;
1399 };
1400 typedef std::deque <PRCTopoContext*> PRCTopoContextList;
1401 
1403 {
1404 public:
1405  PRCUniqueId() : id0(0), id1(0), id2(0), id3(0) {}
1406  void serializeCompressedUniqueId(PRCbitStream&) const;
1407  void serializeFileStructureUncompressedUniqueId(std::ostream& out) const;
1408  uint32_t id0;
1409  uint32_t id1;
1410  uint32_t id2;
1411  uint32_t id3;
1412 };
1413 
1414 class PRCUnit
1415 {
1416 public:
1417  PRCUnit() : unit_from_CAD_file(false), unit(1) {}
1418  PRCUnit(double u, bool ufcf=true) : unit_from_CAD_file(ufcf), unit(u) {}
1419  void serializeUnit(PRCbitStream&);
1420  bool unit_from_CAD_file;
1421  double unit;
1422 };
1423 
1425 {
1426 public:
1427  PRCProductOccurrence(std::string n="") :
1428  ContentPRCBase(PRC_TYPE_ASM_ProductOccurence,n),
1429  index_part(m1),
1430  index_prototype(m1), prototype_in_same_file_structure(true),
1431  index_external_data(m1), external_data_in_same_file_structure(true),
1432  product_behaviour(0), product_information_flags(0), product_load_status(KEPRCProductLoadStatus_Loaded),
1433  location(NULL) {}
1434  ~PRCProductOccurrence() { delete location; }
1435  void setLocation(PRCGeneralTransformation3d*& transform) { location = transform; transform = NULL; }
1436  void serializeProductOccurrence(PRCbitStream&);
1437  uint32_t index_part;
1438  uint32_t index_prototype;
1439  bool prototype_in_same_file_structure;
1440  PRCUniqueId prototype_file_structure;
1441  uint32_t index_external_data;
1442  bool external_data_in_same_file_structure;
1443  PRCUniqueId external_data_file_structure;
1444  std::vector<uint32_t> index_son_occurrence;
1445  uint8_t product_behaviour;
1446  PRCUnit unit_information;
1447  uint8_t product_information_flags;
1448  EPRCProductLoadStatus product_load_status;
1449  PRCGeneralTransformation3d *location;
1450 };
1451 typedef std::deque <PRCProductOccurrence*> PRCProductOccurrenceList;
1452 
1454 {
1455 public:
1456  PRCPartDefinition(std::string n="") :
1457  ContentPRCBase(PRC_TYPE_ASM_PartDefinition,n) {}
1458  ~PRCPartDefinition() { for(PRCRepresentationItemList::iterator it=representation_item.begin(); it!=representation_item.end(); ++it) delete *it; }
1459  void serializePartDefinition(PRCbitStream&);
1460  uint32_t addBrepModel(PRCBrepModel*& pBrepModel);
1461  uint32_t addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel);
1462  uint32_t addPointSet(PRCPointSet*& pPointSet);
1463  uint32_t addSet(PRCSet*& pSet);
1464  uint32_t addWire(PRCWire*& pWire);
1465  uint32_t addPolyWire(PRCPolyWire*& pPolyWire);
1466  uint32_t addRepresentationItem(PRCRepresentationItem*& pRepresentationItem);
1467  PRCRepresentationItemList representation_item;
1468 };
1469 typedef std::deque <PRCPartDefinition*> PRCPartDefinitionList;
1470 
1471 #endif //__WRITE_PRC_H
Definition: writePRC.h:452
Definition: writePRC.h:941
Definition: writePRC.h:134
Definition: writePRC.h:1006
Definition: writePRC.h:1219
Definition: writePRC.h:889
Definition: writePRC.h:1049
Definition: writePRC.h:522
Definition: writePRC.h:310
Definition: writePRC.h:415
Definition: writePRC.h:1273
Definition: writePRC.h:931
Definition: writePRC.h:1078
Definition: writePRC.h:995
Definition: writePRC.h:698
Definition: writePRC.h:653
Definition: writePRC.h:124
Definition: writePRC.h:1424
Definition: writePRC.h:855
Definition: writePRC.h:1377
Definition: writePRC.h:500
Definition: writePRC.h:1150
Definition: writePRC.h:733
Definition: writePRC.h:1175
Definition: writePRC.h:1208
Definition: writePRC.h:1237
Definition: writePRC.h:900
Definition: writePRC.h:1122
Definition: writePRC.h:725
Definition: writePRC.h:38
Definition: writePRC.h:1259
Definition: writePRC.h:686
Definition: writePRC.h:151
Definition: writePRC.h:1163
Definition: writePRC.h:1037
Definition: writePRC.h:643
Definition: writePRC.h:468
Definition: writePRC.h:1295
Definition: writePRC.h:967
Definition: writePRC.h:540
Definition: writePRC.h:240
Definition: writePRC.h:481
Definition: writePRC.h:1342
Definition: writePRC.h:984
Definition: writePRC.h:1188
Definition: writePRC.h:913
Definition: writePRC.h:1025
Definition: writePRC.h:1327
Definition: writePRC.h:666
Definition: writePRC.h:923
Definition: writePRC.h:883
Definition: writePRC.h:1402
Definition: writePRC.h:1090
Definition: writePRC.h:632
Definition: writePRC.h:591
Definition: writePRC.h:799
Definition: writePRC.h:606
Definition: writePRC.h:260
Definition: writePRC.h:1066
Definition: writePRC.h:621
Definition: writePRC.h:562
Definition: writePRC.h:1138
Definition: writePRC.h:676
Definition: writePRC.h:380
Definition: writePRC.h:1104
Definition: writePRC.h:1414
Definition: writePRC.h:1201
Definition: writePRC.h:285
Definition: PRCbitStream.h:46
Definition: writePRC.h:1360
Definition: writePRC.h:1453
Definition: writePRC.h:1252
Definition: writePRC.h:423
Definition: writePRC.h:213
Definition: writePRC.h:952
Definition: writePRC.h:1312
Definition: writePRC.h:532
Definition: writePRC.h:322
Definition: writePRC.h:707
Definition: writePRC.h:839
Definition: writePRC.h:576
Definition: writePRC.h:227