summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
committerKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
commita960e44eb527236f39aec81babc0474911a86078 (patch)
tree9950eca71791d90820a80a521a7cc252c0955db5 /Build/source/utils/asymptote/prc
parent6443467452320c296faa1f43f0606a9457bd4463 (diff)
asy 1.96
git-svn-id: svn://tug.org/texlive/trunk@18817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/prc')
-rw-r--r--Build/source/utils/asymptote/prc/Makefile34
-rw-r--r--Build/source/utils/asymptote/prc/PRC.h699
-rw-r--r--Build/source/utils/asymptote/prc/PRCdouble.h29
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.cc1593
-rw-r--r--Build/source/utils/asymptote/prc/oPRCFile.h454
-rw-r--r--Build/source/utils/asymptote/prc/test.asy5
-rw-r--r--Build/source/utils/asymptote/prc/test.cc545
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.cc1785
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.h1247
9 files changed, 5437 insertions, 954 deletions
diff --git a/Build/source/utils/asymptote/prc/Makefile b/Build/source/utils/asymptote/prc/Makefile
index cfa9ac9be5d..22f67e29725 100644
--- a/Build/source/utils/asymptote/prc/Makefile
+++ b/Build/source/utils/asymptote/prc/Makefile
@@ -3,20 +3,32 @@
CFLAGS = -O3 -g -Wall
CXX = g++
-test: PRCbitStream oPRCFile PRCdouble writePRC test.cc
- $(CXX) $(CFLAGS) -o test PRCbitStream.o oPRCFile.o PRCdouble.o writePRC.o test.cc -lz
+MAKEDEPEND = $(CFLAGS) -O0 -M -DDEPEND
-PRCbitStream: PRCbitStream.cc
- $(CXX) $(CFLAGS) -c PRCbitStream.cc -o PRCbitStream.o
+FILES = PRCbitStream oPRCFile PRCdouble writePRC
-oPRCFile: oPRCFile.cc
- $(CXX) $(CFLAGS) -c oPRCFile.cc -o oPRCFile.o
+test: $(FILES:=.o) test.cc
+ $(CXX) $(CFLAGS) -o test $(FILES:=.o) test.cc -lz
-PRCdouble: PRCdouble.cc
- $(CXX) $(CFLAGS) -c PRCdouble.cc -o PRCdouble.o
+.SUFFIXES: .c .cc .o .d
+.cc.o:
+ $(CXX) $(CFLAGS) $(INCL) -o $@ -c $<
+.cc.d:
+ @echo Creating $@; \
+ rm -f $@; \
+ ${CXX} $(MAKEDEPEND) $(INCL) $(MDOPTS) $< > $@.$$$$ 2>/dev/null && \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+.c.d:
+ @echo Creating $@; \
+ rm -f $@; \
+ ${CC} $(MAKEDEPEND) $(INCL) $(MDOPTS) $< > $@.$$$$ 2>/dev/null && \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
-writePRC: writePRC.cc PRCbitStream
- $(CXX) $(CFLAGS) -c writePRC.cc -o writePRC.o
+ifeq (,$(findstring clean,${MAKECMDGOALS}))
+-include $(FILES:=.d)
+endif
clean:
- rm -f *.o test.prc test
+ rm -f *.o *.d test.prc test
diff --git a/Build/source/utils/asymptote/prc/PRC.h b/Build/source/utils/asymptote/prc/PRC.h
index ce04cea4801..da1aff7ef9c 100644
--- a/Build/source/utils/asymptote/prc/PRC.h
+++ b/Build/source/utils/asymptote/prc/PRC.h
@@ -3,198 +3,216 @@
#include <stdint.h>
-const uint32_t PRCVersion=7094; // For Adobe Reader 8 or later
-//const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later
+const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later
// from Adobe's documentation
-#define PRC_TYPE_ROOT 0 // This type does not correspond to any entity
-
-#define PRC_TYPE_ROOT_PRCBase ( PRC_TYPE_ROOT + 1 ) // Abstract root type for any PRC entity.
-#define PRC_TYPE_ROOT_PRCBaseWithGraphics ( PRC_TYPE_ROOT + 2 ) // Abstract root type for any PRC entity which can bear graphics.
-
-#define PRC_TYPE_CRV ( PRC_TYPE_ROOT + 10 ) // Types for PRC geometrical curves
-#define PRC_TYPE_SURF ( PRC_TYPE_ROOT + 75 ) // Types for PRC geometrical surfaces
-#define PRC_TYPE_TOPO ( PRC_TYPE_ROOT + 140 ) // Types for PRC topology
-#define PRC_TYPE_TESS ( PRC_TYPE_ROOT + 170 ) // Types for PRC tessellation
-#define PRC_TYPE_MISC ( PRC_TYPE_ROOT + 200 ) // Types for PRC global data
-#define PRC_TYPE_RI ( PRC_TYPE_ROOT + 230 ) // Types for PRC representation items
-#define PRC_TYPE_ASM ( PRC_TYPE_ROOT + 300 ) // Types for PRC assembly
-#define PRC_TYPE_MKP ( PRC_TYPE_ROOT + 500 ) // Types for PRC markup
-#define PRC_TYPE_GRAPH ( PRC_TYPE_ROOT + 700 ) // Types for PRC graphics
-#define PRC_TYPE_MATH ( PRC_TYPE_ROOT + 900 ) // Types for PRC mathematical operators
-
-#define PRC_TYPE_CRV_Base ( PRC_TYPE_CRV + 1 ) // Abstract type for all geometric curves.
-#define PRC_TYPE_CRV_Blend02Boundary ( PRC_TYPE_CRV + 2 ) // Boundary Curve.
-#define PRC_TYPE_CRV_NURBS ( PRC_TYPE_CRV + 3 ) // Non Uniform BSpline curve.
-#define PRC_TYPE_CRV_Circle ( PRC_TYPE_CRV + 4 ) // Circle.
-#define PRC_TYPE_CRV_Composite ( PRC_TYPE_CRV + 5 ) // Array of oriented curves.
-#define PRC_TYPE_CRV_OnSurf ( PRC_TYPE_CRV + 6 ) // Curve defined by a UV curve on a surface.
-#define PRC_TYPE_CRV_Ellipse ( PRC_TYPE_CRV + 7 ) // Ellipse.
-#define PRC_TYPE_CRV_Equation ( PRC_TYPE_CRV + 8 ) // curve described by specific law elements
-#define PRC_TYPE_CRV_Helix ( PRC_TYPE_CRV + 9 ) // Helix curve.
-#define PRC_TYPE_CRV_Hyperbola ( PRC_TYPE_CRV + 10 ) // Hyperbola.
-#define PRC_TYPE_CRV_Intersection ( PRC_TYPE_CRV + 11 ) // Intersection between 2 surfaces.
-#define PRC_TYPE_CRV_Line ( PRC_TYPE_CRV + 12 ) // Line.
-#define PRC_TYPE_CRV_Offset ( PRC_TYPE_CRV + 13 ) // Offset curve.
-#define PRC_TYPE_CRV_Parabola ( PRC_TYPE_CRV + 14 ) // Parabola.
-#define PRC_TYPE_CRV_PolyLine ( PRC_TYPE_CRV + 15 ) // Polyedric curve.
-#define PRC_TYPE_CRV_Transform ( PRC_TYPE_CRV + 16 ) // Transformed curve.
-
-#define PRC_TYPE_SURF_Base ( PRC_TYPE_SURF + 1 ) // Abstract type for all geometric surfaces.
-#define PRC_TYPE_SURF_Blend01 ( PRC_TYPE_SURF + 2 ) // Blend surface.
-#define PRC_TYPE_SURF_Blend02 ( PRC_TYPE_SURF + 3 ) // Blend Surface.
-#define PRC_TYPE_SURF_Blend03 ( PRC_TYPE_SURF + 4 ) // Blend Surface.
-#define PRC_TYPE_SURF_NURBS ( PRC_TYPE_SURF + 5 ) // Non Uniform BSpline surface.
-#define PRC_TYPE_SURF_Cone ( PRC_TYPE_SURF + 6 ) // Cone.
-#define PRC_TYPE_SURF_Cylinder ( PRC_TYPE_SURF + 7 ) // Cylinder.
-#define PRC_TYPE_SURF_Cylindrical ( PRC_TYPE_SURF + 8 ) // Surface who is defined in cylindrical space.
-#define PRC_TYPE_SURF_Offset ( PRC_TYPE_SURF + 9 ) // Offset surface.
-#define PRC_TYPE_SURF_Pipe ( PRC_TYPE_SURF + 10 ) // Pipe.
-#define PRC_TYPE_SURF_Plane ( PRC_TYPE_SURF + 11 ) // Plane.
-#define PRC_TYPE_SURF_Ruled ( PRC_TYPE_SURF + 12 ) // Ruled surface.
-#define PRC_TYPE_SURF_Sphere ( PRC_TYPE_SURF + 13 ) // Sphere.
-#define PRC_TYPE_SURF_Revolution ( PRC_TYPE_SURF + 14 ) // Surface of revolution.
-#define PRC_TYPE_SURF_Extrusion ( PRC_TYPE_SURF + 15 ) // Surface of extrusion.
-#define PRC_TYPE_SURF_FromCurves ( PRC_TYPE_SURF + 16 ) // Surface from two curves.
-#define PRC_TYPE_SURF_Torus ( PRC_TYPE_SURF + 17 ) // Torus.
-#define PRC_TYPE_SURF_Transform ( PRC_TYPE_SURF + 18 ) // Transformed surface.
-#define PRC_TYPE_SURF_Blend04 ( PRC_TYPE_SURF + 19 ) // defined for future use.
-
-#define PRC_TYPE_TOPO_Context ( PRC_TYPE_TOPO + 1 ) // Self-containing set of topological entities.
-#define PRC_TYPE_TOPO_Item ( PRC_TYPE_TOPO + 2 ) // Abstract root type for any topological entity (body or single item).
-#define PRC_TYPE_TOPO_MultipleVertex ( PRC_TYPE_TOPO + 3 ) // Vertex whose position is the average of all edges' extremity positions to whom it belongs.
-#define PRC_TYPE_TOPO_UniqueVertex ( PRC_TYPE_TOPO + 4 ) // Vertex with one set of coordinates (absolute position).
-#define PRC_TYPE_TOPO_WireEdge ( PRC_TYPE_TOPO + 5 ) // Edge belonging to a wire body / single wire body.
-#define PRC_TYPE_TOPO_Edge ( PRC_TYPE_TOPO + 6 ) // Edge belonging to a brep data.
-#define PRC_TYPE_TOPO_CoEdge ( PRC_TYPE_TOPO + 7 ) // Usage of an edge in a loop.
-#define PRC_TYPE_TOPO_Loop ( PRC_TYPE_TOPO + 8 ) // Array of co edges which delimits a face.
-#define PRC_TYPE_TOPO_Face ( PRC_TYPE_TOPO + 9 ) // Topological face delimiting a shell.
-#define PRC_TYPE_TOPO_Shell ( PRC_TYPE_TOPO + 10 ) // Topological shell (open or closed).
-#define PRC_TYPE_TOPO_Connex ( PRC_TYPE_TOPO + 11 ) // Topological region delimited by one or several shells.
-#define PRC_TYPE_TOPO_Body ( PRC_TYPE_TOPO + 12 ) // Abstract root type for any topological body.
-#define PRC_TYPE_TOPO_SingleWireBody ( PRC_TYPE_TOPO + 13 ) // Single wire body.
-#define PRC_TYPE_TOPO_BrepData ( PRC_TYPE_TOPO + 14 ) // Main entry to solid and surface topology (regular form).
-#define PRC_TYPE_TOPO_SingleWireBodyCompress ( PRC_TYPE_TOPO + 15 ) // Single wire body. (ultra compressed form).
-#define PRC_TYPE_TOPO_BrepDataCompress ( PRC_TYPE_TOPO + 16 ) // Main entry to solid and surface topology (ultra compressed form).
-#define PRC_TYPE_TOPO_WireBody ( PRC_TYPE_TOPO + 17 ) // This type is the main entry to wire topology.
-
-#define PRC_TYPE_TESS_Base ( PRC_TYPE_TESS + 1 ) // Abstract root type for any tessellated entity.
-#define PRC_TYPE_TESS_3D ( PRC_TYPE_TESS + 2 ) // Tessellated faceted data; regular form.
-#define PRC_TYPE_TESS_3D_Compressed ( PRC_TYPE_TESS + 3 ) // Tessellated faceted data; highly compressed form.
-#define PRC_TYPE_TESS_Face ( PRC_TYPE_TESS + 4 ) // Tessellated face.
-#define PRC_TYPE_TESS_3D_Wire ( PRC_TYPE_TESS + 5 ) // Tessellated wireframe.
-#define PRC_TYPE_TESS_Markup ( PRC_TYPE_TESS + 6 ) // Tessellated markup.
-
-#define PRC_TYPE_MISC_Attribute ( PRC_TYPE_MISC + 1 ) // Entity attribute.
-#define PRC_TYPE_MISC_CartesianTransformation ( PRC_TYPE_MISC + 2 ) // Cartesian transformation.
-#define PRC_TYPE_MISC_EntityReference ( PRC_TYPE_MISC + 3 ) // Entity reference.
-#define PRC_TYPE_MISC_MarkupLinkedItem ( PRC_TYPE_MISC + 4 ) // Link between a markup and an entity.
-#define PRC_TYPE_MISC_ReferenceOnPRCBase ( PRC_TYPE_MISC + 5 ) // Reference pointing on a regular entity (not topological).
-#define PRC_TYPE_MISC_ReferenceOnTopology ( PRC_TYPE_MISC + 6 ) // Reference pointing on a topological entity.
-
-#define PRC_TYPE_RI_RepresentationItem ( PRC_TYPE_RI + 1 ) // Basic abstract type for representation items.
-#define PRC_TYPE_RI_BrepModel ( PRC_TYPE_RI + 2 ) // Basic type for surfaces and solids.
-#define PRC_TYPE_RI_Curve ( PRC_TYPE_RI + 3 ) // Basic type for curves.
-#define PRC_TYPE_RI_Direction ( PRC_TYPE_RI + 4 ) // Optional point + vector.
-#define PRC_TYPE_RI_Plane ( PRC_TYPE_RI + 5 ) // Construction plane, as opposed to planar surface.
-#define PRC_TYPE_RI_PointSet ( PRC_TYPE_RI + 6 ) // Set of points.
-#define PRC_TYPE_RI_PolyBrepModel ( PRC_TYPE_RI + 7 ) // Basic type to polyhedral surfaces and solids.
-#define PRC_TYPE_RI_PolyWire ( PRC_TYPE_RI + 8 ) // Polyedric wireframe entity.
-#define PRC_TYPE_RI_Set ( PRC_TYPE_RI + 9 ) // Logical grouping of arbitrary number of representation items.
-#define PRC_TYPE_RI_CoordinateSystem ( PRC_TYPE_RI + 10 ) // Coordinate system.
-
-#define PRC_TYPE_ASM_ModelFile ( PRC_TYPE_ASM + 1 ) // Basic entry type for PRC.
-#define PRC_TYPE_ASM_FileStructure ( PRC_TYPE_ASM + 2 ) // Basic structure for PRC files.
-#define PRC_TYPE_ASM_FileStructureGlobals ( PRC_TYPE_ASM + 3 ) // Basic structure for PRC files : globals.
-#define PRC_TYPE_ASM_FileStructureTree ( PRC_TYPE_ASM + 4 ) // Basic structure for PRC files : tree.
-#define PRC_TYPE_ASM_FileStructureTessellation ( PRC_TYPE_ASM + 5 ) // Basic structure for PRC files : tessellation.
-#define PRC_TYPE_ASM_FileStructureGeometry ( PRC_TYPE_ASM + 6 ) // Basic structure for PRC files : geometry.
-#define PRC_TYPE_ASM_FileStructureExtraGeometry ( PRC_TYPE_ASM + 7 ) // Basic structure for PRC files : extra geometry data.
-#define PRC_TYPE_ASM_ProductOccurence ( PRC_TYPE_ASM + 10 ) // Basic contruct for assemblies.
-#define PRC_TYPE_ASM_PartDefinition ( PRC_TYPE_ASM + 11 ) // Basic construct for parts.
-
-#define PRC_TYPE_MKP_View ( PRC_TYPE_MKP + 1 ) // Grouping of markup by views.
-#define PRC_TYPE_MKP_Markup ( PRC_TYPE_MKP + 2 ) // Basic type for simple markups.
-#define PRC_TYPE_MKP_Leader ( PRC_TYPE_MKP + 3 ) // basic type for markup leader
-#define PRC_TYPE_MKP_AnnotationItem ( PRC_TYPE_MKP + 4 ) // Usage of a markup.
-#define PRC_TYPE_MKP_AnnotationSet ( PRC_TYPE_MKP + 5 ) // Group of annotations.
-#define PRC_TYPE_MKP_AnnotationReference ( PRC_TYPE_MKP + 6 ) // Logical grouping of annotations for reference.
-
-#define PRC_TYPE_GRAPH_Style ( PRC_TYPE_GRAPH + 1 ) // Display style.
-#define PRC_TYPE_GRAPH_Material ( PRC_TYPE_GRAPH + 2 ) // Display material properties.
-#define PRC_TYPE_GRAPH_Picture ( PRC_TYPE_GRAPH + 3 ) // Picture.
-#define PRC_TYPE_GRAPH_TextureApplication ( PRC_TYPE_GRAPH + 11 ) // Texture application.
-#define PRC_TYPE_GRAPH_TextureDefinition ( PRC_TYPE_GRAPH + 12 ) // Texture definition.
-#define PRC_TYPE_GRAPH_TextureTransformation ( PRC_TYPE_GRAPH + 13 ) // Texture transformation.
-#define PRC_TYPE_GRAPH_LinePattern ( PRC_TYPE_GRAPH + 21 ) // One dimensional display style.
-#define PRC_TYPE_GRAPH_FillPattern ( PRC_TYPE_GRAPH + 22 ) // Abstract class for two-dimensional display style.
-#define PRC_TYPE_GRAPH_DottingPattern ( PRC_TYPE_GRAPH + 23 ) // Two-dimensional filling with dots.
-#define PRC_TYPE_GRAPH_HatchingPattern ( PRC_TYPE_GRAPH + 24 ) // Two-dimensional filling with hatches.
-#define PRC_TYPE_GRAPH_SolidPattern ( PRC_TYPE_GRAPH + 25 ) // Two-dimensional filling with particular style (color, material, texture).
-#define PRC_TYPE_GRAPH_VPicturePattern ( PRC_TYPE_GRAPH + 26 ) // Two-dimensional filling with vectorised picture.
-#define PRC_TYPE_GRAPH_AmbientLight ( PRC_TYPE_GRAPH + 31 ) // Scene ambient illumination.
-#define PRC_TYPE_GRAPH_PointLight ( PRC_TYPE_GRAPH + 32 ) // Scene point illumination.
-#define PRC_TYPE_GRAPH_DirectionalLight ( PRC_TYPE_GRAPH + 33 ) // Scene directional illumination.
-#define PRC_TYPE_GRAPH_SpotLight ( PRC_TYPE_GRAPH + 34 ) // Scene spot illumination.
-#define PRC_TYPE_GRAPH_SceneDisplayParameters ( PRC_TYPE_GRAPH + 41 ) // Parameters for scene visualisation.
-#define PRC_TYPE_GRAPH_Camera ( PRC_TYPE_GRAPH + 42 ) //
-
-#define PRC_TYPE_MATH_FCT_1D ( PRC_TYPE_MATH + 1 ) // Basic type for one degree equation object.
-#define PRC_TYPE_MATH_FCT_1D_Polynom ( PRC_TYPE_MATH_FCT_1D + 1 ) // Polynomial equation.
-#define PRC_TYPE_MATH_FCT_1D_Trigonometric ( PRC_TYPE_MATH_FCT_1D + 2 ) // Cosinus based equation.
-#define PRC_TYPE_MATH_FCT_1D_Fraction ( PRC_TYPE_MATH_FCT_1D + 3 ) // Fraction between 2 one degree equation object.
-#define PRC_TYPE_MATH_FCT_1D_ArctanCos ( PRC_TYPE_MATH_FCT_1D + 4 ) // Specific equation.
-#define PRC_TYPE_MATH_FCT_1D_Combination ( PRC_TYPE_MATH_FCT_1D + 5 ) // Combination of one degree equation object.
-#define PRC_TYPE_MATH_FCT_3D ( PRC_TYPE_MATH + 10 ) // Basic type for 3rd degree equation object.
-#define PRC_TYPE_MATH_FCT_3D_Linear ( PRC_TYPE_MATH_FCT_3D + 1 ) // Linear transformation ( with a matrix ).
-#define PRC_TYPE_MATH_FCT_3D_NonLinear ( PRC_TYPE_MATH_FCT_3D + 2 ) // Specific transformation.
-
-#define PRC_PRODUCT_FLAG_DEFAULT 0x0001
-#define PRC_PRODUCT_FLAG_INTERNAL 0x0002
-#define PRC_PRODUCT_FLAG_CONTAINER 0x0004
-#define PRC_PRODUCT_FLAG_CONFIG 0x0008
-#define PRC_PRODUCT_FLAG_VIEW 0x0010
-
-#define PRC_TRANSFORMATION_Identity 0x00
-#define PRC_TRANSFORMATION_Translate 0x01
-#define PRC_TRANSFORMATION_Rotate 0x02
-#define PRC_TRANSFORMATION_Mirror 0x04
-#define PRC_TRANSFORMATION_Scale 0x08
-#define PRC_TRANSFORMATION_NonUniformScale 0x10
-#define PRC_TRANSFORMATION_NonOrtho 0x20
-#define PRC_TRANSFORMATION_Homogeneous 0x40
-
-#define PRC_FACETESSDATA_Polyface 0x0001
-#define PRC_FACETESSDATA_Triangle 0x0002
-#define PRC_FACETESSDATA_TriangleFan 0x0004
-#define PRC_FACETESSDATA_TriangleStripe 0x0008
-#define PRC_FACETESSDATA_PolyfaceOneNormal 0x0010
-#define PRC_FACETESSDATA_TriangleOneNormal 0x0020
-#define PRC_FACETESSDATA_TriangleFanOneNormal 0x0040
-#define PRC_FACETESSDATA_TriangleStripeOneNormal 0x0080
-#define PRC_FACETESSDATA_PolyfaceTextured 0x0100
-#define PRC_FACETESSDATA_TriangleTextured 0x0200
-#define PRC_FACETESSDATA_TriangleFanTextured 0x0400
-#define PRC_FACETESSDATA_TriangleStripeTextured 0x0800
-#define PRC_FACETESSDATA_PolyfaceOneNormalTextured 0x1000
-#define PRC_FACETESSDATA_TriangleOneNormalTextured 0x2000
-#define PRC_FACETESSDATA_TriangleFanOneNormalTextured 0x4000
-#define PRC_FACETESSDATA_TriangleStripeOneNormalTextured 0x8000
-
-#define PRC_TEXTURE_MAPPING_DIFFUSE 0x0001
-#define PRC_TEXTURE_MAPPING_BUMP 0x0002
-#define PRC_TEXTURE_MAPPING_OPACITY 0x0004
-#define PRC_TEXTURE_MAPPING_SPHERICAL_REFLECTION 0x0008
-#define PRC_TEXTURE_MAPPING_CUBICAL_REFLECTION 0x0010
-#define PRC_TEXTURE_MAPPING_REFRACTION 0x0020
-#define PRC_TEXTURE_MAPPING_SPECULAR 0x0040
-#define PRC_TEXTURE_MAPPING_AMBIENT 0x0080
-#define PRC_TEXTURE_MAPPING_EMISSION 0x0100
-#define PRC_TEXTURE_APPLYING_MODE_NONE 0x00 // let the application choose
-#define PRC_TEXTURE_APPLYING_MODE_LIGHTING 0x01 // use lighting mode
-#define PRC_TEXTURE_APPLYING_MODE_ALPHATEST 0x02 // use alpha test
-#define PRC_TEXTURE_APPLYING_MODE_VERTEXCOLOR 0x04 // combine a texture with one-color-per-vertex mode
+#define PRC_TYPE_Unknown ( (uint32_t)-1 )
+
+#define PRC_TYPE_ROOT 0 // This type does not correspond to any entity
+
+#define PRC_TYPE_ROOT_PRCBase ( PRC_TYPE_ROOT + 1 ) // Abstract root type for any PRC entity.
+#define PRC_TYPE_ROOT_PRCBaseWithGraphics ( PRC_TYPE_ROOT + 2 ) // Abstract root type for any PRC entity which can bear graphics.
+
+#define PRC_TYPE_CRV ( PRC_TYPE_ROOT + 10 ) // Types for PRC geometrical curves
+#define PRC_TYPE_SURF ( PRC_TYPE_ROOT + 75 ) // Types for PRC geometrical surfaces
+#define PRC_TYPE_TOPO ( PRC_TYPE_ROOT + 140 ) // Types for PRC topology
+#define PRC_TYPE_TESS ( PRC_TYPE_ROOT + 170 ) // Types for PRC tessellation
+#define PRC_TYPE_MISC ( PRC_TYPE_ROOT + 200 ) // Types for PRC global data
+#define PRC_TYPE_RI ( PRC_TYPE_ROOT + 230 ) // Types for PRC representation items
+#define PRC_TYPE_ASM ( PRC_TYPE_ROOT + 300 ) // Types for PRC assembly
+#define PRC_TYPE_MKP ( PRC_TYPE_ROOT + 500 ) // Types for PRC markup
+#define PRC_TYPE_GRAPH ( PRC_TYPE_ROOT + 700 ) // Types for PRC graphics
+#define PRC_TYPE_MATH ( PRC_TYPE_ROOT + 900 ) // Types for PRC mathematical operators
+
+#define PRC_TYPE_CRV_Base ( PRC_TYPE_CRV + 1 ) // Abstract type for all geometric curves.
+#define PRC_TYPE_CRV_Blend02Boundary ( PRC_TYPE_CRV + 2 ) // Boundary Curve.
+#define PRC_TYPE_CRV_NURBS ( PRC_TYPE_CRV + 3 ) // Non Uniform BSpline curve.
+#define PRC_TYPE_CRV_Circle ( PRC_TYPE_CRV + 4 ) // Circle.
+#define PRC_TYPE_CRV_Composite ( PRC_TYPE_CRV + 5 ) // Array of oriented curves.
+#define PRC_TYPE_CRV_OnSurf ( PRC_TYPE_CRV + 6 ) // Curve defined by a UV curve on a surface.
+#define PRC_TYPE_CRV_Ellipse ( PRC_TYPE_CRV + 7 ) // Ellipse.
+#define PRC_TYPE_CRV_Equation ( PRC_TYPE_CRV + 8 ) // curve described by specific law elements
+#define PRC_TYPE_CRV_Helix ( PRC_TYPE_CRV + 9 ) // Helix curve.
+#define PRC_TYPE_CRV_Hyperbola ( PRC_TYPE_CRV + 10 ) // Hyperbola.
+#define PRC_TYPE_CRV_Intersection ( PRC_TYPE_CRV + 11 ) // Intersection between 2 surfaces.
+#define PRC_TYPE_CRV_Line ( PRC_TYPE_CRV + 12 ) // Line.
+#define PRC_TYPE_CRV_Offset ( PRC_TYPE_CRV + 13 ) // Offset curve.
+#define PRC_TYPE_CRV_Parabola ( PRC_TYPE_CRV + 14 ) // Parabola.
+#define PRC_TYPE_CRV_PolyLine ( PRC_TYPE_CRV + 15 ) // Polyedric curve.
+#define PRC_TYPE_CRV_Transform ( PRC_TYPE_CRV + 16 ) // Transformed curve.
+
+#define PRC_TYPE_SURF_Base ( PRC_TYPE_SURF + 1 ) // Abstract type for all geometric surfaces.
+#define PRC_TYPE_SURF_Blend01 ( PRC_TYPE_SURF + 2 ) // Blend surface.
+#define PRC_TYPE_SURF_Blend02 ( PRC_TYPE_SURF + 3 ) // Blend Surface.
+#define PRC_TYPE_SURF_Blend03 ( PRC_TYPE_SURF + 4 ) // Blend Surface.
+#define PRC_TYPE_SURF_NURBS ( PRC_TYPE_SURF + 5 ) // Non Uniform BSpline surface.
+#define PRC_TYPE_SURF_Cone ( PRC_TYPE_SURF + 6 ) // Cone.
+#define PRC_TYPE_SURF_Cylinder ( PRC_TYPE_SURF + 7 ) // Cylinder.
+#define PRC_TYPE_SURF_Cylindrical ( PRC_TYPE_SURF + 8 ) // Surface who is defined in cylindrical space.
+#define PRC_TYPE_SURF_Offset ( PRC_TYPE_SURF + 9 ) // Offset surface.
+#define PRC_TYPE_SURF_Pipe ( PRC_TYPE_SURF + 10 ) // Pipe.
+#define PRC_TYPE_SURF_Plane ( PRC_TYPE_SURF + 11 ) // Plane.
+#define PRC_TYPE_SURF_Ruled ( PRC_TYPE_SURF + 12 ) // Ruled surface.
+#define PRC_TYPE_SURF_Sphere ( PRC_TYPE_SURF + 13 ) // Sphere.
+#define PRC_TYPE_SURF_Revolution ( PRC_TYPE_SURF + 14 ) // Surface of revolution.
+#define PRC_TYPE_SURF_Extrusion ( PRC_TYPE_SURF + 15 ) // Surface of extrusion.
+#define PRC_TYPE_SURF_FromCurves ( PRC_TYPE_SURF + 16 ) // Surface from two curves.
+#define PRC_TYPE_SURF_Torus ( PRC_TYPE_SURF + 17 ) // Torus.
+#define PRC_TYPE_SURF_Transform ( PRC_TYPE_SURF + 18 ) // Transformed surface.
+#define PRC_TYPE_SURF_Blend04 ( PRC_TYPE_SURF + 19 ) // defined for future use.
+
+#define PRC_TYPE_TOPO_Context ( PRC_TYPE_TOPO + 1 ) // Self-containing set of topological entities.
+#define PRC_TYPE_TOPO_Item ( PRC_TYPE_TOPO + 2 ) // Abstract root type for any topological entity (body or single item).
+#define PRC_TYPE_TOPO_MultipleVertex ( PRC_TYPE_TOPO + 3 ) // Vertex whose position is the average of all edges' extremity positions to whom it belongs.
+#define PRC_TYPE_TOPO_UniqueVertex ( PRC_TYPE_TOPO + 4 ) // Vertex with one set of coordinates (absolute position).
+#define PRC_TYPE_TOPO_WireEdge ( PRC_TYPE_TOPO + 5 ) // Edge belonging to a wire body / single wire body.
+#define PRC_TYPE_TOPO_Edge ( PRC_TYPE_TOPO + 6 ) // Edge belonging to a brep data.
+#define PRC_TYPE_TOPO_CoEdge ( PRC_TYPE_TOPO + 7 ) // Usage of an edge in a loop.
+#define PRC_TYPE_TOPO_Loop ( PRC_TYPE_TOPO + 8 ) // Array of co edges which delimits a face.
+#define PRC_TYPE_TOPO_Face ( PRC_TYPE_TOPO + 9 ) // Topological face delimiting a shell.
+#define PRC_TYPE_TOPO_Shell ( PRC_TYPE_TOPO + 10 ) // Topological shell (open or closed).
+#define PRC_TYPE_TOPO_Connex ( PRC_TYPE_TOPO + 11 ) // Topological region delimited by one or several shells.
+#define PRC_TYPE_TOPO_Body ( PRC_TYPE_TOPO + 12 ) // Abstract root type for any topological body.
+#define PRC_TYPE_TOPO_SingleWireBody ( PRC_TYPE_TOPO + 13 ) // Single wire body.
+#define PRC_TYPE_TOPO_BrepData ( PRC_TYPE_TOPO + 14 ) // Main entry to solid and surface topology (regular form).
+#define PRC_TYPE_TOPO_SingleWireBodyCompress ( PRC_TYPE_TOPO + 15 ) // Single wire body. (ultra compressed form).
+#define PRC_TYPE_TOPO_BrepDataCompress ( PRC_TYPE_TOPO + 16 ) // Main entry to solid and surface topology (ultra compressed form).
+#define PRC_TYPE_TOPO_WireBody ( PRC_TYPE_TOPO + 17 ) // This type is the main entry to wire topology.
+
+#define PRC_TYPE_TESS_Base ( PRC_TYPE_TESS + 1 ) // Abstract root type for any tessellated entity.
+#define PRC_TYPE_TESS_3D ( PRC_TYPE_TESS + 2 ) // Tessellated faceted data; regular form.
+#define PRC_TYPE_TESS_3D_Compressed ( PRC_TYPE_TESS + 3 ) // Tessellated faceted data; highly compressed form.
+#define PRC_TYPE_TESS_Face ( PRC_TYPE_TESS + 4 ) // Tessellated face.
+#define PRC_TYPE_TESS_3D_Wire ( PRC_TYPE_TESS + 5 ) // Tessellated wireframe.
+#define PRC_TYPE_TESS_Markup ( PRC_TYPE_TESS + 6 ) // Tessellated markup.
+
+#define PRC_TYPE_MISC_Attribute ( PRC_TYPE_MISC + 1 ) // Entity attribute.
+#define PRC_TYPE_MISC_CartesianTransformation ( PRC_TYPE_MISC + 2 ) // Cartesian transformation.
+#define PRC_TYPE_MISC_EntityReference ( PRC_TYPE_MISC + 3 ) // Entity reference.
+#define PRC_TYPE_MISC_MarkupLinkedItem ( PRC_TYPE_MISC + 4 ) // Link between a markup and an entity.
+#define PRC_TYPE_MISC_ReferenceOnPRCBase ( PRC_TYPE_MISC + 5 ) // Reference pointing on a regular entity (not topological).
+#define PRC_TYPE_MISC_ReferenceOnTopology ( PRC_TYPE_MISC + 6 ) // Reference pointing on a topological entity.
+#define PRC_TYPE_MISC_GeneralTransformation ( PRC_TYPE_MISC + 7 ) // General transformation.
+
+#define PRC_TYPE_RI_RepresentationItem ( PRC_TYPE_RI + 1 ) // Basic abstract type for representation items.
+#define PRC_TYPE_RI_BrepModel ( PRC_TYPE_RI + 2 ) // Basic type for surfaces and solids.
+#define PRC_TYPE_RI_Curve ( PRC_TYPE_RI + 3 ) // Basic type for curves.
+#define PRC_TYPE_RI_Direction ( PRC_TYPE_RI + 4 ) // Optional point + vector.
+#define PRC_TYPE_RI_Plane ( PRC_TYPE_RI + 5 ) // Construction plane, as opposed to planar surface.
+#define PRC_TYPE_RI_PointSet ( PRC_TYPE_RI + 6 ) // Set of points.
+#define PRC_TYPE_RI_PolyBrepModel ( PRC_TYPE_RI + 7 ) // Basic type to polyhedral surfaces and solids.
+#define PRC_TYPE_RI_PolyWire ( PRC_TYPE_RI + 8 ) // Polyedric wireframe entity.
+#define PRC_TYPE_RI_Set ( PRC_TYPE_RI + 9 ) // Logical grouping of arbitrary number of representation items.
+#define PRC_TYPE_RI_CoordinateSystem ( PRC_TYPE_RI + 10 ) // Coordinate system.
+
+#define PRC_TYPE_ASM_ModelFile ( PRC_TYPE_ASM + 1 ) // Basic entry type for PRC.
+#define PRC_TYPE_ASM_FileStructure ( PRC_TYPE_ASM + 2 ) // Basic structure for PRC files.
+#define PRC_TYPE_ASM_FileStructureGlobals ( PRC_TYPE_ASM + 3 ) // Basic structure for PRC files : globals.
+#define PRC_TYPE_ASM_FileStructureTree ( PRC_TYPE_ASM + 4 ) // Basic structure for PRC files : tree.
+#define PRC_TYPE_ASM_FileStructureTessellation ( PRC_TYPE_ASM + 5 ) // Basic structure for PRC files : tessellation.
+#define PRC_TYPE_ASM_FileStructureGeometry ( PRC_TYPE_ASM + 6 ) // Basic structure for PRC files : geometry.
+#define PRC_TYPE_ASM_FileStructureExtraGeometry ( PRC_TYPE_ASM + 7 ) // Basic structure for PRC files : extra geometry data.
+#define PRC_TYPE_ASM_ProductOccurence ( PRC_TYPE_ASM + 10 ) // Basic contruct for assemblies.
+#define PRC_TYPE_ASM_PartDefinition ( PRC_TYPE_ASM + 11 ) // Basic construct for parts.
+#define PRC_TYPE_ASM_Filter ( PRC_TYPE_ASM + 20 )
+
+#define PRC_TYPE_MKP_View ( PRC_TYPE_MKP + 1 ) // Grouping of markup by views.
+#define PRC_TYPE_MKP_Markup ( PRC_TYPE_MKP + 2 ) // Basic type for simple markups.
+#define PRC_TYPE_MKP_Leader ( PRC_TYPE_MKP + 3 ) // basic type for markup leader
+#define PRC_TYPE_MKP_AnnotationItem ( PRC_TYPE_MKP + 4 ) // Usage of a markup.
+#define PRC_TYPE_MKP_AnnotationSet ( PRC_TYPE_MKP + 5 ) // Group of annotations.
+#define PRC_TYPE_MKP_AnnotationReference ( PRC_TYPE_MKP + 6 ) // Logical grouping of annotations for reference.
+
+#define PRC_TYPE_GRAPH_Style ( PRC_TYPE_GRAPH + 1 ) // Display style.
+#define PRC_TYPE_GRAPH_Material ( PRC_TYPE_GRAPH + 2 ) // Display material properties.
+#define PRC_TYPE_GRAPH_Picture ( PRC_TYPE_GRAPH + 3 ) // Picture.
+#define PRC_TYPE_GRAPH_TextureApplication ( PRC_TYPE_GRAPH + 11 ) // Texture application.
+#define PRC_TYPE_GRAPH_TextureDefinition ( PRC_TYPE_GRAPH + 12 ) // Texture definition.
+#define PRC_TYPE_GRAPH_TextureTransformation ( PRC_TYPE_GRAPH + 13 ) // Texture transformation.
+#define PRC_TYPE_GRAPH_LinePattern ( PRC_TYPE_GRAPH + 21 ) // One dimensional display style.
+#define PRC_TYPE_GRAPH_FillPattern ( PRC_TYPE_GRAPH + 22 ) // Abstract class for two-dimensional display style.
+#define PRC_TYPE_GRAPH_DottingPattern ( PRC_TYPE_GRAPH + 23 ) // Two-dimensional filling with dots.
+#define PRC_TYPE_GRAPH_HatchingPattern ( PRC_TYPE_GRAPH + 24 ) // Two-dimensional filling with hatches.
+#define PRC_TYPE_GRAPH_SolidPattern ( PRC_TYPE_GRAPH + 25 ) // Two-dimensional filling with particular style (color, material, texture).
+#define PRC_TYPE_GRAPH_VPicturePattern ( PRC_TYPE_GRAPH + 26 ) // Two-dimensional filling with vectorised picture.
+#define PRC_TYPE_GRAPH_AmbientLight ( PRC_TYPE_GRAPH + 31 ) // Scene ambient illumination.
+#define PRC_TYPE_GRAPH_PointLight ( PRC_TYPE_GRAPH + 32 ) // Scene point illumination.
+#define PRC_TYPE_GRAPH_DirectionalLight ( PRC_TYPE_GRAPH + 33 ) // Scene directional illumination.
+#define PRC_TYPE_GRAPH_SpotLight ( PRC_TYPE_GRAPH + 34 ) // Scene spot illumination.
+#define PRC_TYPE_GRAPH_SceneDisplayParameters ( PRC_TYPE_GRAPH + 41 ) // Parameters for scene visualisation.
+#define PRC_TYPE_GRAPH_Camera ( PRC_TYPE_GRAPH + 42 ) //
+
+#define PRC_TYPE_MATH_FCT_1D ( PRC_TYPE_MATH + 1 ) // Basic type for one degree equation object.
+#define PRC_TYPE_MATH_FCT_1D_Polynom ( PRC_TYPE_MATH_FCT_1D + 1 ) // Polynomial equation.
+#define PRC_TYPE_MATH_FCT_1D_Trigonometric ( PRC_TYPE_MATH_FCT_1D + 2 ) // Cosinus based equation.
+#define PRC_TYPE_MATH_FCT_1D_Fraction ( PRC_TYPE_MATH_FCT_1D + 3 ) // Fraction between 2 one degree equation object.
+#define PRC_TYPE_MATH_FCT_1D_ArctanCos ( PRC_TYPE_MATH_FCT_1D + 4 ) // Specific equation.
+#define PRC_TYPE_MATH_FCT_1D_Combination ( PRC_TYPE_MATH_FCT_1D + 5 ) // Combination of one degree equation object.
+#define PRC_TYPE_MATH_FCT_3D ( PRC_TYPE_MATH + 10 ) // Basic type for 3rd degree equation object.
+#define PRC_TYPE_MATH_FCT_3D_Linear ( PRC_TYPE_MATH_FCT_3D + 1 ) // Linear transformation ( with a matrix ).
+#define PRC_TYPE_MATH_FCT_3D_NonLinear ( PRC_TYPE_MATH_FCT_3D + 2 ) // Specific transformation.
+
+#define PRC_PRODUCT_FLAG_DEFAULT 0x0001
+#define PRC_PRODUCT_FLAG_INTERNAL 0x0002
+#define PRC_PRODUCT_FLAG_CONTAINER 0x0004
+#define PRC_PRODUCT_FLAG_CONFIG 0x0008
+#define PRC_PRODUCT_FLAG_VIEW 0x0010
+
+#define PRC_TRANSFORMATION_Identity 0x00
+#define PRC_TRANSFORMATION_Translate 0x01
+#define PRC_TRANSFORMATION_Rotate 0x02
+#define PRC_TRANSFORMATION_Mirror 0x04
+#define PRC_TRANSFORMATION_Scale 0x08
+#define PRC_TRANSFORMATION_NonUniformScale 0x10
+#define PRC_TRANSFORMATION_NonOrtho 0x20
+#define PRC_TRANSFORMATION_Homogeneous 0x40
+
+#define PRC_FACETESSDATA_Polyface 0x0001
+#define PRC_FACETESSDATA_Triangle 0x0002
+#define PRC_FACETESSDATA_TriangleFan 0x0004
+#define PRC_FACETESSDATA_TriangleStripe 0x0008
+#define PRC_FACETESSDATA_PolyfaceOneNormal 0x0010
+#define PRC_FACETESSDATA_TriangleOneNormal 0x0020
+#define PRC_FACETESSDATA_TriangleFanOneNormal 0x0040
+#define PRC_FACETESSDATA_TriangleStripeOneNormal 0x0080
+#define PRC_FACETESSDATA_PolyfaceTextured 0x0100
+#define PRC_FACETESSDATA_TriangleTextured 0x0200
+#define PRC_FACETESSDATA_TriangleFanTextured 0x0400
+#define PRC_FACETESSDATA_TriangleStripeTextured 0x0800
+#define PRC_FACETESSDATA_PolyfaceOneNormalTextured 0x1000
+#define PRC_FACETESSDATA_TriangleOneNormalTextured 0x2000
+#define PRC_FACETESSDATA_TriangleFanOneNormalTextured 0x4000
+#define PRC_FACETESSDATA_TriangleStripeOneNormalTextured 0x8000
+#define PRC_FACETESSDATA_NORMAL_Single 0x40000000
+#define PRC_FACETESSDATA_NORMAL_Mask 0x3FFFFFFF
+#define PRC_FACETESSDATA_WIRE_IsNotDrawn 0x4000 // Indicates that the edge should not be drawn (its neighbor will be drawn).
+#define PRC_FACETESSDATA_WIRE_IsClosing 0x8000 // Indicates that this is the last edge of a loop.
+
+#define PRC_3DWIRETESSDATA_IsClosing 0x10000000 // Indicates that the first point is implicitely repeated after the last one to close the wire edge.
+#define PRC_3DWIRETESSDATA_IsContinuous 0x20000000 // Indicates that the last point of the preceding wire should be linked with the first point of the current one.
+
+#define PRC_TEXTURE_MAPPING_DIFFUSE 0x0001 // Diffuse texture mapping attribute. Default value.
+#define PRC_TEXTURE_MAPPING_BUMP 0x0002 // Bump texture mapping attribute.
+#define PRC_TEXTURE_MAPPING_OPACITY 0x0004 // Opacity texture mapping attribute.
+#define PRC_TEXTURE_MAPPING_SPHERICAL_REFLECTION 0x0008 // Spherical reflection texture mapping attribute (used for environment mapping).
+#define PRC_TEXTURE_MAPPING_CUBICAL_REFLECTION 0x0010 // Cubical reflection texture mapping attribute (used for environment mapping).
+#define PRC_TEXTURE_MAPPING_REFRACTION 0x0020 // Refraction texture mapping attribute.
+#define PRC_TEXTURE_MAPPING_SPECULAR 0x0040 // Specular texture mapping attribute.
+#define PRC_TEXTURE_MAPPING_AMBIENT 0x0080 // Ambient texture mapping attribute.
+#define PRC_TEXTURE_MAPPING_EMISSION 0x0100 // Emission texture mapping attribute.
+
+#define PRC_TEXTURE_APPLYING_MODE_NONE 0x00 // let the application choose
+#define PRC_TEXTURE_APPLYING_MODE_LIGHTING 0x01 // use lighting mode
+#define PRC_TEXTURE_APPLYING_MODE_ALPHATEST 0x02 // use alpha test
+#define PRC_TEXTURE_APPLYING_MODE_VERTEXCOLOR 0x04 // combine a texture with one-color-per-vertex mode
+
+#define PRC_TEXTURE_MAPPING_COMPONENTS_RED 0x0001 // Red texture mapping component.
+#define PRC_TEXTURE_MAPPING_COMPONENTS_GREEN 0x0002 // Green texture mapping component.
+#define PRC_TEXTURE_MAPPING_COMPONENTS_BLUE 0x0004 // Blue texture mapping component.
+#define PRC_TEXTURE_MAPPING_COMPONENTS_RGB 0x0007 // RGB texture mapping component.
+#define PRC_TEXTURE_MAPPING_COMPONENTS_ALPHA 0x0008 // Alpha texture mapping component.
+#define PRC_TEXTURE_MAPPING_COMPONENTS_RGBA 0x000F // RGBA texture mapping component.
enum EPRCModellerAttributeType {
KEPRCModellerAttributeTypeNull = 0,
@@ -221,83 +239,260 @@ enum EPRCProductLoadStatus {
KEPRCProductLoadStatus_Loaded
};
-enum EPRCExtendType {
- KEPRCExtendTypeNone = 0,
- KEPRCExtendTypeExt1 = 2,
- KEPRCExtendTypeExt2 = 4,
- KEPRCExtendTypeG1 = 6,
- KEPRCExtendTypeG1R = 8,
- KEPRCExtendTypeG1_G2 = 10,
- KEPRCExtendTypeCInfinity = 12
+enum EPRCExtendType {
+ KEPRCExtendTypeNone = 0, // Discontinuous position.
+ KEPRCExtendTypeExt1 = 2, // Same as EPRCExtendTypeCInfinity.
+ KEPRCExtendTypeExt2 = 4, // Same as EPRCExtendTypeG1R for surface, and EPRCExtendTypeG1 for curve.
+ KEPRCExtendTypeG1 = 6, // Continuous in direction but not magnitude of first derivative.
+ KEPRCExtendTypeG1R = 8, // Surface extended with a ruled surface that connects with G1-continuity.
+ KEPRCExtendTypeG1_G2 = 10, // Extended by reflection, yielding a G2 continuous extension.
+ KEPRCExtendTypeCInfinity = 12 // Unlimited continuity.
};
-enum EPRCKnotType {
- KEPRCKnotTypeUniformKnots,
- KEPRCKnotTypeUnspecified,
- KEPRCKnotTypeQuasiUniformKnots,
- KEPRCKnotTypePiecewiseBezierKnots
-};
+enum EPRCKnotType { // Knot vector type
+ KEPRCKnotTypeUniformKnots, // Uniform knot vector.
+ KEPRCKnotTypeUnspecified, // Unspecified knot type.
+ KEPRCKnotTypeQuasiUniformKnots, // Quasi-uniform knot vector.
+ KEPRCKnotTypePiecewiseBezierKnots // Extrema with multiplicities of degree +1.
+}; // Note : this value is currently unused and should be set to KEPRCKnotTypeUnspecified.
+
enum EPRCBSplineSurfaceForm {
- KEPRCBSplineSurfaceFormPlane,
- KEPRCBSplineSurfaceFormCylindrical,
- KEPRCBSplineSurfaceFormConical,
- KEPRCBSplineSurfaceFormSpherical,
- KEPRCBSplineSurfaceFormRevolution,
- KEPRCBSplineSurfaceFormRuled,
- KEPRCBSplineSurfaceFormGeneralizedCone,
- KEPRCBSplineSurfaceFormQuadric,
- KEPRCBSplineSurfaceFormLinearExtrusion,
- KEPRCBSplineSurfaceFormUnspecified,
- KEPRCBSplineSurfaceFormPolynomial
+ KEPRCBSplineSurfaceFormPlane, // Planar surface.
+ KEPRCBSplineSurfaceFormCylindrical, // Cylindrical surface.
+ KEPRCBSplineSurfaceFormConical, // Conical surface.
+ KEPRCBSplineSurfaceFormSpherical, // Spherical surface.
+ KEPRCBSplineSurfaceFormRevolution, // Surface of revolution.
+ KEPRCBSplineSurfaceFormRuled, // Ruled surface.
+ KEPRCBSplineSurfaceFormGeneralizedCone, // Cone.
+ KEPRCBSplineSurfaceFormQuadric, // Quadric surface.
+ KEPRCBSplineSurfaceFormLinearExtrusion, // Surface of extrusion.
+ KEPRCBSplineSurfaceFormUnspecified, // Unspecified surface.
+ KEPRCBSplineSurfaceFormPolynomial // Polynomial surface.
+};
+
+enum EPRCBSplineCurveForm { // NURBS curve form
+ KEPRCBSplineCurveFormUnspecified, // Unspecified curve form.
+ KEPRCBSplineCurveFormPolyline, // Polygon.
+ KEPRCBSplineCurveFormCircularArc, // Circle arc.
+ KEPRCBSplineCurveFormEllipticArc, // Elliptical arc.
+ KEPRCBSplineCurveFormParabolicArc, // Parabolic arc.
+ KEPRCBSplineCurveFormHyperbolicArc // Hyperbolic arc.
+}; // Note : this value is currently unused and should be set to KEPRCBSplineCurveFormUnspecified.
+
+enum EPRCTextureMappingType { // Defines how to retrieve mapping coordinates.
+ KEPRCTextureMappingType_Unknown, // Let the application choose.
+ KEPRCTextureMappingType_Stored, // Use the mapping coordinates that are stored on a 3D tessellation object
+ KEPRCTextureMappingType_Parametric, // Retrieve the UV coordinates on the surface as mapping coordinates
+ KEPRCTextureMappingType_Operator // Use the defined Texture mapping operator to calculate mapping coordinates
+};
+
+enum EPRCTextureFunction { // Defines how to paint a texture on the surface being rendered.
+ KEPRCTextureFunction_Unknown, // Let the application choose.
+ KEPRCTextureFunction_Modulate, // Combine lighting with texturing. This is the default value.
+ KEPRCTextureFunction_Replace, // Replace the object color with texture color data.
+ KEPRCTextureFunction_Blend, // Reserved for future use.
+ KEPRCTextureFunction_Decal // Reserved for future use.
};
-enum EPRCBSplineCurveForm {
- KEPRCBSplineCurveFormUnspecified,
- KEPRCBSplineCurveFormPolyline,
- KEPRCBSplineCurveFormCircularArc,
- KEPRCBSplineCurveFormEllipticArc,
- KEPRCBSplineCurveFormParabolicArc,
- KEPRCBSplineCurveFormHyperbolicArc
+enum EPRCTextureMappingOperator { // The operator to use when computing mapping coordinates.
+ KEPRCTextureMappingOperator_Unknown, // Default value
+ KEPRCTextureMappingOperator_Planar, // Reserved for future use
+ KEPRCTextureMappingOperator_Cylindrical, // Reserved for future use
+ KEPRCTextureMappingOperator_Spherical, // Reserved for future use
+ KEPRCTextureMappingOperator_Cubical // Reserved for future use
};
-enum EPRCTextureMappingType {
- KEPRCTextureMappingType_Unknown,
- KEPRCTextureMappingType_Stored,
- KEPRCTextureMappingType_Parametric,
- KEPRCTextureMappingType_Operator
+enum EPRCTextureBlendParameter { // Reserved for future use. Defines how to apply blending.
+ KEPRCTextureBlendParameter_Unknown, // Default value.
+ KEPRCTextureBlendParameter_Zero, // Reserved for future use.
+ KEPRCTextureBlendParameter_One, // Reserved for future use.
+ KEPRCTextureBlendParameter_SrcColor, // Reserved for future use.
+ KEPRCTextureBlendParameter_OneMinusSrcColor, // Reserved for future use.
+ KEPRCTextureBlendParameter_DstColor, // Reserved for future use.
+ KEPRCTextureBlendParameter_OneMinusDstColor, // Reserved for future use.
+ KEPRCTextureBlendParameter_SrcAlpha, // Reserved for future use.
+ KEPRCTextureBlendParameter_OneMinusSrcAlpha, // Reserved for future use.
+ KEPRCTextureBlendParameter_DstAlpha, // Reserved for future use.
+ KEPRCTextureBlendParameter_OneMinusDstAlpha, // Reserved for future use.
+ KEPRCTextureBlendParameter_SrcAlphaSaturate // Reserved for future use.
};
-enum EPRCTextureFunction {
- KEPRCTextureFunction_Unknown,
- KEPRCTextureFunction_Modulate,
- KEPRCTextureFunction_Replace,
- KEPRCTextureFunction_Blend,
- KEPRCTextureFunction_Decal
+enum EPRCTextureWrappingMode { // Defines repeating and clamping texture modes.
+ KEPRCTextureWrappingMode_Unknown, // Let the application choose.
+ KEPRCTextureWrappingMode_Repeat, // Display the repeated texture on the surface.
+ KEPRCTextureWrappingMode_ClampToBorder, // Clamp the texture to the border. Display the surface color along the texture limits.
+ KEPRCTextureWrappingMode_Clamp, // Reserved for future use.
+ KEPRCTextureWrappingMode_ClampToEdge, // Reserved for future use.
+ KEPRCTextureWrappingMode_MirroredRepeat // Reserved for future use.
};
-enum EPRCTextureBlendParameter {
- KEPRCTextureBlendParameter_Unknown,
- KEPRCTextureBlendParameter_Zero,
- KEPRCTextureBlendParameter_One,
- KEPRCTextureBlendParameter_SrcColor,
- KEPRCTextureBlendParameter_OneMinusSrcColor,
- KEPRCTextureBlendParameter_DstColor,
- KEPRCTextureBlendParameter_OneMinusDstColor,
- KEPRCTextureBlendParameter_SrcAlpha,
- KEPRCTextureBlendParameter_OneMinusSrcAlpha,
- KEPRCTextureBlendParameter_DstAlpha,
- KEPRCTextureBlendParameter_OneMinusDstAlpha,
- KEPRCTextureBlendParameter_SrcAlphaSaturate
+enum EPRCTextureAlphaTest { // Reserved for future use. Defines how to use a texture alpha test.
+ KEPRCTextureAlphaTest_Unknown, // Default value.
+ KEPRCTextureAlphaTest_Never, // Reserved for future use.
+ KEPRCTextureAlphaTest_Less, // Reserved for future use.
+ KEPRCTextureAlphaTest_Equal, // Reserved for future use.
+ KEPRCTextureAlphaTest_Lequal, // Reserved for future use.
+ KEPRCTextureAlphaTest_Greater, // Reserved for future use.
+ KEPRCTextureAlphaTest_Notequal, // Reserved for future use.
+ KEPRCTextureAlphaTest_Gequal, // Reserved for future use.
+ KEPRCTextureAlphaTest_Always // Reserved for future use.
};
-enum EPRCTextureWrappingMode {
- KEPRCTextureWrappingMode_Unknown,
- KEPRCTextureWrappingMode_Repeat,
- KEPRCTextureWrappingMode_ClampToBorder,
- KEPRCTextureWrappingMode_Clamp,
- KEPRCTextureWrappingMode_ClampToEdge,
- KEPRCTextureWrappingMode_MirroredRepeat
+
+// Bit field for graphics behavior
+#define PRC_GRAPHICS_Show 0x0001 // The entity is shown.
+#define PRC_GRAPHICS_SonHeritShow 0x0002 // Shown entity son inheritance.
+#define PRC_GRAPHICS_FatherHeritShow 0x0004 // Shown entity father inheritance.
+#define PRC_GRAPHICS_SonHeritColor 0x0008 // Color/material son inheritance.
+#define PRC_GRAPHICS_FatherHeritColor 0x0010 // Color/material father inheritance.
+#define PRC_GRAPHICS_SonHeritLayer 0x0020 // Layer son inheritance.
+#define PRC_GRAPHICS_FatherHeritLayer 0x0040 // Layer father inheritance.
+#define PRC_GRAPHICS_SonHeritTransparency 0x0080 // Transparency son inheritance.
+#define PRC_GRAPHICS_FatherHeritTransparency 0x0100 // Transparency father inheritance.
+#define PRC_GRAPHICS_SonHeritLinePattern 0x0200 // Line pattern son inheritance.
+#define PRC_GRAPHICS_FatherHeritLinePattern 0x0400 // Line pattern father inheritance.
+#define PRC_GRAPHICS_SonHeritLineWidth 0x0800 // Line width son inheritance.
+#define PRC_GRAPHICS_FatherHeritLineWidth 0x1000 // Line width father inheritance.
+#define PRC_GRAPHICS_Removed 0x2000 // The entity has been removed and no longer appears in the tree.
+
+enum EPRCMarkupType {
+ KEPRCMarkupType_Unknown = 0,
+ KEPRCMarkupType_Text,
+ KEPRCMarkupType_Dimension,
+ KEPRCMarkupType_Arrow,
+ KEPRCMarkupType_Balloon,
+ KEPRCMarkupType_CircleCenter,
+ KEPRCMarkupType_Coordinate,
+ KEPRCMarkupType_Datum,
+ KEPRCMarkupType_Fastener,
+ KEPRCMarkupType_Gdt,
+ KEPRCMarkupType_Locator,
+ KEPRCMarkupType_MeasurementPoint,
+ KEPRCMarkupType_Roughness,
+ KEPRCMarkupType_Welding,
+ KEPRCMarkupType_Table,
+ KEPRCMarkupType_Other
+};
+
+enum EPRCMarkupSubType {
+ KEPRCMarkupSubType_Unknown = 0,
+ KEPRCMarkupSubType_EnumMax,
+
+ KEPRCMarkupSubType_Datum_Ident = 1 ,
+ KEPRCMarkupSubType_Datum_EnumMax,
+
+ KEPRCMarkupSubType_Dimension_Distance = 1,
+ KEPRCMarkupSubType_Dimension_Radius_Tangent,
+ KEPRCMarkupSubType_Dimension_Radius_Cylinder,
+ KEPRCMarkupSubType_Dimension_Radius_Edge,
+ KEPRCMarkupSubType_Dimension_Diameter,
+ KEPRCMarkupSubType_Dimension_Diameter_Tangent,
+ KEPRCMarkupSubType_Dimension_Diameter_Cylinder,
+ KEPRCMarkupSubType_Dimension_Diameter_Edge,
+ KEPRCMarkupSubType_Dimension_Diameter_Cone,
+ KEPRCMarkupSubType_Dimension_Length,
+ KEPRCMarkupSubType_Dimension_Length_Curvilinear,
+ KEPRCMarkupSubType_Dimension_Length_Circular,
+ KEPRCMarkupSubType_Dimension_Angle,
+ KEPRCMarkupSubType_Dimension_EnumMax,
+
+ KEPRCMarkupSubType_Gdt_Fcf = 1,
+ KEPRCMarkupSubType_Gdt_EnumMax,
+
+ KEPRCMarkupSubType_Welding_Line = 1,
+ KEPRCMarkupSubType_Welding_EnumMax,
+
+ KEPRCMarkupSubType_Other_Symbol_User = 1,
+ KEPRCMarkupSubType_Other_EnumMax
};
+#define PRC_MARKUP_IsHidden 0x01 // The tessellation is hidden.
+#define PRC_MARKUP_HasFrame 0x02 // The tessellation has a frame.
+#define PRC_MARKUP_IsNotModifiable 0x04 // The tessellation is given and should not be modified.
+#define PRC_MARKUP_IsZoomable 0x08 // The tessellation has zoom capability.
+#define PRC_MARKUP_IsOnTop 0x10 // The tessellation is on top of the geometry.
+#define PRC_MARKUP_IsFlipable 0x20 // The text tessellation can be flipped to always be readable on screen. This value is currently unused.
+
+#define PRC_RENDERING_PARAMETER_SPECIAL_CULLING 0x0001 // special culling strategy to apply
+#define PRC_RENDERING_PARAMETER_FRONT_CULLING 0x0002 // apply front culling (ignored if no special culling strategy)
+#define PRC_RENDERING_PARAMETER_BACK_CULLING 0x0004 // apply back culling (ignored if no special culling strategy)
+#define PRC_RENDERING_PARAMETER_NO_LIGHT 0x0008 // if set, no light will apply on corresponding object
+
+#define PRC_MARKUP_IsMatrix 0x08000000 // Bit to denote that the current entity is a matrix.
+#define PRC_MARKUP_IsExtraData 0x04000000 // Bit to denote that the current entity is extra data (it is neither a matrix nor a polyline).
+#define PRC_MARKUP_IntegerMask 0xFFFFF // Integer mask to retrieve sizes.
+#define PRC_MARKUP_ExtraDataType 0x3E00000 // Mask to retrieve the integer type of the entity.
+
+#define PRC_MARKUP_ExtraDataType_Pattern (( 0<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Picture (( 1<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Triangles (( 2<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Quads (( 3<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_FaceViewMode (( 6<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_FrameDrawMode (( 7<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_FixedSizeMode (( 8<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Symbol (( 9<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Cylinder ((10<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Color ((11<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_LineStipple ((12<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Font ((13<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Text ((14<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Points ((15<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_Polygon ((16<<21)|PRC_MARKUP_IsExtraData)
+#define PRC_MARKUP_ExtraDataType_LineWidth ((17<<21)|PRC_MARKUP_IsExtraData)
+
+enum EPRCCharSet
+{
+ KEPRCCharsetUnknown = -1,
+ KEPRCCharsetRoman = 0,
+ KEPRCCharsetJapanese,
+ KEPRCCharsetTraditionalChinese,
+ KEPRCCharsetKorean,
+ KEPRCCharsetArabic,
+ KEPRCCharsetHebrew,
+ KEPRCCharsetGreek,
+ KEPRCCharsetCyrillic,
+ KEPRCCharsetRightLeft,
+ KEPRCCharsetDevanagari,
+ KEPRCCharsetGurmukhi,
+ KEPRCCharsetGujarati,
+ KEPRCCharsetOriya,
+ KEPRCCharsetBengali,
+ KEPRCCharsetTamil,
+ KEPRCCharsetTelugu,
+ KEPRCCharsetKannada,
+ KEPRCCharsetMalayalam,
+ KEPRCCharsetSinhalese,
+ KEPRCCharsetBurmese,
+ KEPRCCharsetKhmer,
+ KEPRCCharsetThai,
+ KEPRCCharsetLaotian,
+ KEPRCCharsetGeorgian,
+ KEPRCCharsetArmenian,
+ KEPRCCharsetSimplifiedChinese,
+ KEPRCCharsetTibetan,
+ KEPRCCharsetMongolian,
+ KEPRCCharsetGeez,
+ KEPRCCharsetEastEuropeanRoman,
+ KEPRCCharsetVietnamese,
+ KEPRCCharsetExtendedArabic
+};
+
+#define PRC_Font_Bold 0x02 /*!< Bold. */
+#define PRC_Font_Italic 0x04 /*!< Italic. */
+#define PRC_Font_Underlined 0x08 /*!< Underlined. */
+#define PRC_Font_StrikedOut 0x10 /*!< Striked-out. */
+#define PRC_Font_Overlined 0x20 /*!< Overlined. */
+#define PRC_Font_Streched 0x40 /*!< Streched. In case the font used is not the original font, it indicates that the text needs to be stretched to fit its bounding box. */
+#define PRC_Font_Wired 0x80 /*!< Wired. Indicates that the original font is a wirefame font. */
+#define PRC_Font_FixedWidth 0x100 /*!< Fixed width. Indicates that the original font is not proportional (each glyph has the same width). */
+
+#define PRC_CONTEXT_OuterLoopFirst 0x0001 // Outer loops are always first loops (specific to PRC_TYPE_TOPO_BrepData).
+#define PRC_CONTEXT_NoClamp 0x0002 // UV curves are clamped on the surface (specific to PRC_TYPE_TOPO_BrepData).
+#define PRC_CONTEXT_NoSplit 0x0004 // Faces are split (specific to PRC_TYPE_TOPO_BrepData).
+
+#define PRC_BODY_BBOX_Evaluation 0x0001 // Bounding box based on geometry.
+#define PRC_BODY_BBOX_Precise 0x0002 // Bounding box based on tessellation.
+#define PRC_BODY_BBOX_CADData 0x0003 // Bounding box given by a CAD data file.
+
#endif // __PRC_H
diff --git a/Build/source/utils/asymptote/prc/PRCdouble.h b/Build/source/utils/asymptote/prc/PRCdouble.h
index c21d33e5dc9..ae4e8fedb8c 100644
--- a/Build/source/utils/asymptote/prc/PRCdouble.h
+++ b/Build/source/utils/asymptote/prc/PRCdouble.h
@@ -8,6 +8,17 @@
#include "config.h"
#endif
+#ifdef BYTE_ORDER
+# undef WORDS_BIG_ENDIAN
+# undef WORDS_LITTLE_ENDIAN
+# if BYTE_ORDER == BIG_ENDIAN
+# define WORDS_BIG_ENDIAN 1
+# endif
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define WORDS_LITTLE_ENDIAN 1
+# endif
+#endif
+
// from Adobe's documentation
union ieee754_double
@@ -32,8 +43,22 @@ union ieee754_double
} ieee;
};
-
-
+union ieee754_float
+{
+ float f;
+ /* This is the IEEE 754 float-precision format. */
+ struct {
+#ifdef WORDS_BIGENDIAN
+ unsigned int negative:1;
+ unsigned int exponent:8;
+ unsigned int mantissa:23;
+#else
+ unsigned int mantissa:23;
+ unsigned int exponent:8;
+ unsigned int negative:1;
+#endif
+ } ieee;
+};
enum ValueType {VT_double,VT_exponent};
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.cc b/Build/source/utils/asymptote/prc/oPRCFile.cc
index 73c7ef32efe..37397b1e675 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.cc
+++ b/Build/source/utils/asymptote/prc/oPRCFile.cc
@@ -2,6 +2,7 @@
*
* This file is part of a tool for producing 3D content in the PRC format.
* Copyright (C) 2008 Orest Shardt <shardtor (at) gmail dot com>
+* with enhancements contributed by Michail Vidiassov.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -21,269 +22,37 @@
#include "oPRCFile.h"
#include <time.h>
#include <sstream>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <zlib.h>
+#include <string.h>
+
+#define WriteUnsignedInteger( value ) out << (uint32_t)(value);
+#define WriteInteger( value ) out << (int32_t)(value);
+#define SerializeContentPRCBase write(out);
+#define SerializeRgbColor( value ) (value).serializeRgbColor(out);
+#define SerializePicture( value ) (value).serializePicture(out);
+#define SerializeTextureDefinition( value ) (value)->serializeTextureDefinition(out);
+#define SerializeMarkup( value ) (value)->serializeMarkup(out);
+#define SerializeAnnotationEntity( value ) (value)->serializeAnnotationEntity(out);
+#define SerializeFontKeysSameFont( value ) (value).serializeFontKeysSameFont(out);
+#define SerializeMaterial( value ) (value)->serializeMaterial(out);
+
+#define SerializeCategory1LineStyle( value ) (value)->serializeCategory1LineStyle(out);
+#define SerializeCoordinateSystem( value ) (value)->serializeCoordinateSystem(out);
+#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(out);
+#define SerializePartDefinition( value ) (value)->serializePartDefinition(out);
+#define SerializeProductOccurrence( value ) (value)->serializeProductOccurrence(out);
+#define SerializeContextAndBodies( value ) (fileStructure->value)->serializeContextAndBodies(out);
+#define SerializeGeometrySummary( value ) (fileStructure->value)->serializeGeometrySummary(out);
+#define SerializeContextGraphics( value ) (fileStructure->value)->serializeContextGraphics(out);
using std::string;
+using namespace std;
+using namespace std::tr1;
-uint32_t PRCentity::getGraphicsIndex()
-{
- if(useMaterial)
- return parent->colourMap.size()+parent->getMaterialIndex(material);
- else
- return parent->getColourIndex(colour);
-}
-
-void PRCline::writeRepresentationItem(PRCbitStream &out,uint32_t index)
-{
- out << (uint32_t)(PRC_TYPE_RI_Curve);
- ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
- writeGraphics(out,m1,getGraphicsIndex(),1);
- out << (uint32_t)0 // index_local_coordinate_system+1
- << (uint32_t)0; // index_tessellation
-
- out << true // has wire body
- << (uint32_t)index+1 // index of context in geometry section
- << (uint32_t)1; // body index in topological context
- UserData(0,0).write(out);
-}
-
-void PRCline::writeTopologicalContext(PRCbitStream &out)
-{
- // topological context
- out << (uint32_t)(PRC_TYPE_TOPO_Context);
- EMPTY_CONTENTPRCBASE.write(out);
- out << (uint8_t)0 // behaviour
- << 0.0 // granularity
- << 0.0 // tolerance
- << false // have smallest face thickness
- << false; // have scale
-
- out << (uint32_t)1; // number of bodies
- // body
- out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody;
-
- out << false // base topology: no base information
- << (uint8_t)0; // content body: behaviour
- // Not sure what a 0 means, since it satisfies no #define,
- // but I think it means no bbox
-
- // wire edge
- out << false // not already stored
- << (uint32_t)PRC_TYPE_TOPO_WireEdge
- << false; // base topology: no base information
-
- // polyline
- out << false // not already stored
- << (uint32_t)PRC_TYPE_CRV_PolyLine
- << false // base topology: no base information
- << (uint32_t)KEPRCExtendTypeNone // extend info
- << true // is 3d
- << false // no transformation
- << 0.0 << static_cast<double>(numberOfPoints-1) // parameterization interval
- << 1.0 // no reparameterization
- << 0.0 // no reparameterization
- << (uint32_t)numberOfPoints;
-
- // points
- for(uint32_t i = 0; i < numberOfPoints; ++i)
- out << points[i][0]*scale << points[i][1]*scale << points[i][2]*scale;
-
- // ending of wire edge
- out << false; // trim surface domain
-}
-
-void PRCline::writeExtraGeometryContext(PRCbitStream &out)
-{
- //geometry summary
- out << (uint32_t)1; // number of bodies
- out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; // body's serial type
- //context graphics
- out << (uint32_t)0; // number of treat types
-}
-
-void PRCcurve::writeRepresentationItem(PRCbitStream &out,uint32_t index)
-{
- out << (uint32_t)(PRC_TYPE_RI_Curve);
- ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
- writeGraphics(out,m1,getGraphicsIndex(),1);
- out << (uint32_t)0 // index_local_coordinate_system+1
- << (uint32_t)0; // index_tessellation
-
- out << true // has wire body
- << (uint32_t)index+1 // index of context in geometry section
- << (uint32_t)1; // body index in topological context
- UserData(0,0).write(out);
-}
-
-void PRCcurve::writeTopologicalContext(PRCbitStream &out)
-{
- // topological context
- out << (uint32_t)(PRC_TYPE_TOPO_Context);
- EMPTY_CONTENTPRCBASE.write(out);
- out << (uint8_t)0 // behaviour
- << 0.0 // granularity
- << 0.0 // tolerance
- << false // have smallest face thickness
- << false; // have scale
-
- out << (uint32_t)1; // number of bodies
- // body
- out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody;
-
- out << false // base topology: no base information
- << (uint8_t)0; // content body: behaviour
- // Not sure what a 0 means, since it satisfies no #define,
- // but I think it means no bbox
-
- // wire edge
- out << false // not already stored
- << (uint32_t)PRC_TYPE_TOPO_WireEdge
- << false; // base topology: no base information
-
- // curve
- out << false // not already stored
- << (uint32_t)PRC_TYPE_CRV_NURBS
- << false // base topology: no base information
- << (uint32_t)KEPRCExtendTypeNone // extend info
- << true // is 3D
- << isRational
- << (uint32_t)degree // degree
- << (uint32_t)numberOfControlPoints-1 // control points - 1
- << (uint32_t)degree+numberOfControlPoints; // knots - 1
-
- // control points
- for(uint32_t i = 0; i < numberOfControlPoints; ++i)
- {
- double Scale=scale;
- if(isRational) Scale *= weights[i];
- out << controlPoints[i][0]*Scale << controlPoints[i][1]*Scale
- << controlPoints[i][2]*Scale;
- if(isRational)
- out << weights[i];
- }
-
- writeKnots(out);
-
- out << (uint32_t)KEPRCKnotTypeUnspecified // KEPRCKnotTypePiecewiseBezierKnots
- << (uint32_t)KEPRCBSplineCurveFormUnspecified; // curve form
-
- // ending of wire edge
- out << false; // trim surface domain
-
-}
-
-void PRCcurve::writeExtraGeometryContext(PRCbitStream &out)
-{
- //geometry summary
- out << (uint32_t)1; // number of bodies
- out << (uint32_t)PRC_TYPE_TOPO_SingleWireBody; // body's serial type
- //context graphics
- out << (uint32_t)0; // number of treat types
-}
-
-void PRCsurface::writeRepresentationItem(PRCbitStream &out,uint32_t index)
-{
- out << (uint32_t)(PRC_TYPE_RI_BrepModel);
- ContentPRCBase(&EMPTY_ATTRIBUTES,name,true,makeCADID(),0,makePRCID()).write(out);
- writeGraphics(out,0,getGraphicsIndex(),1);
- out << (uint32_t)0 // index_local_coordinate_system+1
- << (uint32_t)0; // index_tessellation
-
- out << true // has brep data
- << (uint32_t)index+1 // index of context in geometry section
- << (uint32_t)1 // body index in topological context
- << false; // is closed???? when is it closed?
- UserData(0,0).write(out);
-}
-
-void PRCsurface::writeTopologicalContext(PRCbitStream &out)
-{
- // topological context
- out << (uint32_t)(PRC_TYPE_TOPO_Context);
- EMPTY_CONTENTPRCBASE.write(out);
- out << (uint8_t)0 // behaviour
- << granularity // granularity
- << 0.0 // tolerance
- << false // have smallest face thickness
- << false; // have scale
-
- out << (uint32_t)1; // number of bodies
- // body
- out << (uint32_t)PRC_TYPE_TOPO_BrepData;
-
- out << false // base topology: no base information
- << (uint8_t)0 // content body: behaviour. Not sure what a 0 means, since it satisfies no #define, but I think it means no bbox
- << (uint32_t)1; // number of connex
-
- // connex
- out << false // not already stored
- << (uint32_t)PRC_TYPE_TOPO_Connex
- << false // base topology: no base information
- << (uint32_t)1; // number of shells
-
- // shell
- out << false // not already stored
- << (uint32_t)PRC_TYPE_TOPO_Shell
- << false // base topology: no base information
- << false // shell is closed
- << (uint32_t)1; // number of faces
-
- // face
- out << false // not already stored
- << (uint32_t)PRC_TYPE_TOPO_Face
- << false; // base topology: no base information
-
- // NURBS
- out << false // not already stored
- << (uint32_t)PRC_TYPE_SURF_NURBS
- << false // base topology: no base information
- << (uint32_t)KEPRCExtendTypeNone // Extend Info
- << isRational // is rational
- << (uint32_t)degreeU // degree in u
- << (uint32_t)degreeV // degree in v
- << (uint32_t)numberOfControlPointsU-1 // control points in u - 1
- << (uint32_t)numberOfControlPointsV-1 // control points in v - 1
- << (uint32_t)degreeU+numberOfControlPointsU // knots in u - 1
- << (uint32_t)degreeV+numberOfControlPointsV; // knots in v -1
-
- // control points
- for(uint32_t i = 0; i < numberOfControlPointsU*numberOfControlPointsV; ++i)
- {
- double Scale=scale;
- if(isRational) Scale *= weights[i];
- out << controlPoints[i][0]*Scale << controlPoints[i][1]*Scale
- << controlPoints[i][2]*Scale;
- if(isRational)
- out << weights[i];
- }
-
- writeKnots(out);
-
- out << (uint32_t)KEPRCKnotTypeUnspecified // KEPRCKnotTypePiecewiseBezierKnots
- << (uint32_t)KEPRCBSplineSurfaceFormUnspecified; // surface form
-
- // ending of face
- out << false // trim surface domain
- << false // have tolerance
- << (uint32_t)0 // number of loops
- << (int32_t)-1; // outer loop index
-
- // ending of shell
- out << (uint8_t)1;
- // orientation of surface normal w.r.t. face normal:
- // 0: same, 1: opposite, 2: unknown, 1 used in example
-}
-
-void PRCsurface::writeExtraGeometryContext(PRCbitStream &out)
-{
- //geometry summary
- out << (uint32_t)1; // number of bodies
- out << (uint32_t)PRC_TYPE_TOPO_BrepData; // body's serial type
- //context graphics
- out << (uint32_t)0; // number of treat types
-}
-
-
-void PRCCompressedSection::write(std::ostream &out)
+void PRCCompressedSection::write(ostream &out)
{
if(prepared)
out.write((char*)data,getSize());
@@ -309,6 +78,7 @@ void PRCGlobalsSection::writeData()
// even though this is technically not part of this section,
// it is handled here for convenience
out << (uint32_t)(0); // number of schemas
+ uint32_t i=0; // universal index for PRC standard compatibility
out << (uint32_t)PRC_TYPE_ASM_FileStructureGlobals;
SingleAttributeData value = {PRCVersion};
@@ -322,29 +92,33 @@ void PRCGlobalsSection::writeData()
out << tessellationAngleDegrees;
out << defaultFontFamilyName; // markup serialization helper
- out << numberOfFonts
- << (uint32_t)parent->colourMap.size();
- for(std::vector<RGBAColour>::iterator i = parent->colourMap.begin(); i != parent->colourMap.end(); i++)
+ const uint32_t number_of_fonts = font_keys_of_font.size();
+ WriteUnsignedInteger (number_of_fonts)
+ for (i=0;i<number_of_fonts;i++)
{
- out << i->R << i->G << i->B;
+ SerializeFontKeysSameFont (font_keys_of_font[i])
}
- out << numberOfPictures << numberOfTextureDefinitions;
- out << (uint32_t)parent->materialMap.size(); // number of materials
- for(std::vector<PRCMaterial>::iterator i = parent->materialMap.begin(); i != parent->materialMap.end(); i++)
- {
- out << (uint32_t)PRC_TYPE_GRAPH_Material;
- ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out);
- out << 3*parent->getColourIndex(i->ambient)+1 // ambient + 1
- << 3*parent->getColourIndex(i->diffuse)+1 // diffuse + 1
- << 3*parent->getColourIndex(i->emissive)+1 // emissive + 1
- << 3*parent->getColourIndex(i->specular)+1 // specular + 1
- << i->shininess // shininess
- << i->ambient.A // ambient_alpha
- << i->diffuse.A // diffuse_alpha
- << i->emissive.A // emissive_alpha
- << i->specular.A; // specular_alpha
- }
+
+ const uint32_t number_of_colors = colors.size();
+ WriteUnsignedInteger (number_of_colors)
+ for (i=0;i<number_of_colors;i++)
+ SerializeRgbColor (colors[i])
+
+ const uint32_t number_of_pictures = pictures.size();
+ WriteUnsignedInteger (number_of_pictures)
+ for (i=0;i<number_of_pictures;i++)
+ SerializePicture (pictures[i])
+
+ const uint32_t number_of_texture_definitions = texture_definitions.size();
+ WriteUnsignedInteger (number_of_texture_definitions)
+ for (i=0;i<number_of_texture_definitions;i++)
+ SerializeTextureDefinition (texture_definitions[i])
+
+ const uint32_t number_of_materials = materials.size();
+ WriteUnsignedInteger (number_of_materials)
+ for (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;
@@ -353,47 +127,18 @@ void PRCGlobalsSection::writeData()
<< 0.0 // phase
<< false; // is real length
- out << (uint32_t)(parent->colourMap.size()+parent->materialMap.size()); // number of styles
- uint32_t index = 0;
- // colours are written first
- for(std::vector<RGBAColour>::iterator i = parent->colourMap.begin(); i != parent->colourMap.end(); i++, ++index)
- {
- out << (uint32_t)PRC_TYPE_GRAPH_Style;
- ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out);
- out << 0.0 // line width in mm
- << false // is vpicture
- << (uint32_t)1 // line pattern index+1
- << false // is material
- << (uint32_t)(3*index+1); // 3*color_index+1
- if(i->A < 1.0)
- out << true << (uint8_t)(i->A * 256);
- else
- out << false;
- out << false // additional 1 not defined
- << false // additional 2 not defined
- << false; // additional 3 not defined
- }
- // materials are after colours
- index = 0;
- for(std::vector<PRCMaterial>::iterator i = parent->materialMap.begin(); i != parent->materialMap.end(); i++, ++index)
- {
- out << (uint32_t)PRC_TYPE_GRAPH_Style;
- ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out);
- out << 0.0 // line width in mm
- << false // is vpicture
- << (uint32_t)1 // line pattern index+1
- << true // is material
- << index+1; // material_index+1
- if(i->alpha < 1.0)
- out << true << (uint8_t)(i->alpha * 256);
- else
- out << false;
- out << false // additional 1 not defined
- << false // additional 2 not defined
- << false; // additional 3 not defined
- }
- out << numberOfFillPatterns
- << numberOfReferenceCoordinateSystems;
+ const uint32_t number_of_styles = styles.size();
+ WriteUnsignedInteger (number_of_styles)
+ for (i=0;i<number_of_styles;i++)
+ SerializeCategory1LineStyle (styles[i])
+
+ out << numberOfFillPatterns;
+
+ const uint32_t number_of_reference_coordinate_systems = reference_coordinate_systems.size();
+ WriteUnsignedInteger (number_of_reference_coordinate_systems)
+ for (i=0;i<number_of_reference_coordinate_systems;i++)
+ SerializeCoordinateSystem (reference_coordinate_systems[i])
+
userData.write(out);
}
@@ -403,68 +148,20 @@ void PRCTreeSection::writeData()
EMPTY_CONTENTPRCBASE.write(out);
- out << (uint32_t)1; // number of part definitions
- // part definitions
- out << (uint32_t)(PRC_TYPE_ASM_PartDefinition);
- ContentPRCBase(&EMPTY_ATTRIBUTES,"",true,makeCADID(),0,makePRCID()).write(out);
- writeGraphics(out,m1,m1,1,true);
- Point3d M=Point3d(1e20,1e20,1e20);
- Point3d m=Point3d(-1e20,-1e20,-1e20);
- Extent3d(M,m).write(out);
-
- out << (uint32_t)parent->fileEntities.size(); // number of representation items
- for(uint32_t i = 0; i < parent->fileEntities.size(); ++i)
+ 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();
+ WriteUnsignedInteger (number_of_product_occurrences)
+ for (uint32_t i=0;i<number_of_product_occurrences;i++)
{
- parent->fileEntities[i]->writeRepresentationItem(out,i);
+ product_occurrences[i]->unit_information.unit_from_CAD_file = true;
+ product_occurrences[i]->unit_information.unit = unit;
+ SerializeProductOccurrence (product_occurrences[i])
}
- writeEmptyMarkups(out);
-
- out << (uint32_t)0; // no views
-
- UserData(0,0).write(out);
- out << (uint32_t)1; // number of product occurrences
- // only one product occurrence
- out << (uint32_t)(PRC_TYPE_ASM_ProductOccurence);
- SingleAttribute sas[3];
- SingleAttributeData sad;
- AttributeTitle at;
-
- at.text = "FilePath";
- sad.text = "file name not specified";
- sas[0] = SingleAttribute(false,at,KEPRCModellerAttributeTypeString,sad);
-
- at.text = "FileSize";
- sad.integer = 1234;
- sas[1] = SingleAttribute(false,at,KEPRCModellerAttributeTypeInt,sad);
-
- at.text = "FileModificationTime";
- sad.time = time(NULL);
- sas[2] = SingleAttribute(false,at,KEPRCModellerAttributeTypeInt,sad);
-
- at.text = "__PRC_RESERVED_ATTRIBUTE_A3DF_ProductInformation";
- Attribute attr(false,at,3,sas);
- Attributes attrs(1,&attr);
- ContentPRCBase(&attrs,"root",true,makeCADID(),0,makePRCID()).write(out);
-
- writeGraphics(out,m1,m1,1,true);
- out << (uint32_t)1 // index_part+1
- << (uint32_t)0 // index_prototype+1
- << (uint32_t)0 // index_external_data+1
- << (uint32_t)0 // number of son product occurrences
- << (uint8_t)0; // product behaviour
- writeUnit(out,true,10.0);
- out << (uint8_t)0 // product information flags
- << (uint32_t)KEPRCProductLoadStatus_Loaded; // product_load_status
- out << false // has location
- << (uint32_t)0; // number of references
- writeEmptyMarkups(out);
- out << (uint32_t)0 // number_of_views
- << false // has entity filter
- << (uint32_t)0 // number_of_display_filters
- << (uint32_t)0; // number_of_scene_display_parameters
- UserData(0,0).write(out);
-
// File Structure Internal Data
out << (uint32_t)(PRC_TYPE_ASM_FileStructure);
EMPTY_CONTENTPRCBASE.write(out);
@@ -479,34 +176,38 @@ void PRCTessellationSection::writeData()
out << (uint32_t)(PRC_TYPE_ASM_FileStructureTessellation);
EMPTY_CONTENTPRCBASE.write(out);
- out << (uint32_t)0; // number of tessellations
+ const uint32_t number_of_tessellations = tessellations.size();
+ WriteUnsignedInteger (number_of_tessellations)
+ for (uint32_t i=0;i<number_of_tessellations;i++)
+ tessellations[i]->serializeBaseTessData(out);
UserData(0,0).write(out); // no user data
}
void PRCGeometrySection::writeData()
{
- out << (uint32_t)(PRC_TYPE_ASM_FileStructureGeometry);
+ WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureGeometry)
EMPTY_CONTENTPRCBASE.write(out);
- out << (uint32_t)parent->fileEntities.size(); // number of topological contexts
- for(uint32_t i = 0; i < parent->fileEntities.size(); ++i)
- {
- parent->fileEntities[i]->writeTopologicalContext(out);
- }
+ const uint32_t number_of_contexts = fileStructure->contexts.size();
+ WriteUnsignedInteger (number_of_contexts)
+ for (uint32_t i=0;i<number_of_contexts;i++)
+ SerializeContextAndBodies (contexts[i])
UserData(0,0).write(out);
}
void PRCExtraGeometrySection::writeData()
{
- out << (uint32_t)(PRC_TYPE_ASM_FileStructureExtraGeometry);
+ WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureExtraGeometry)
EMPTY_CONTENTPRCBASE.write(out);
- out << (uint32_t)parent->fileEntities.size(); // number of contexts
- for(uint32_t i = 0; i < parent->fileEntities.size(); ++i)
- {
- parent->fileEntities[i]->writeExtraGeometryContext(out);
- }
+ const uint32_t number_of_contexts = fileStructure->contexts.size();
+ WriteUnsignedInteger (number_of_contexts)
+ for (uint32_t i=0;i<number_of_contexts;i++)
+ {
+ SerializeGeometrySummary (contexts[i])
+ SerializeContextGraphics (contexts[i])
+ }
UserData(0,0).write(out);
}
@@ -525,7 +226,7 @@ void PRCModelFile::writeData()
Attributes as(1,&a);
ContentPRCBase(&as,"PRC file").write(out);
- writeUnit(out,true,10); // unit is 10 mm, and happens to come from a CAD file
+ writeUnit(out,true,unit); // unit is specified, and happens to come from a CAD file
out << (uint32_t)1; // 1 product occurrence
//UUID
@@ -534,7 +235,7 @@ void PRCModelFile::writeData()
<< parent->fileStructures[0]->header.fileStructureUUID[2]
<< parent->fileStructures[0]->header.fileStructureUUID[3];
// index+1
- out << (uint32_t)1;
+ out << (uint32_t)parent->fileStructures[0]->tree.product_occurrences.size();
// active
out << true;
out << (uint32_t)0; // index in model file
@@ -562,7 +263,7 @@ void makeAppUUID(uint32_t *UUID)
UUID[0] = UUID[1] = UUID[2] = UUID[3] = 0;
}
-void writeUINT32_T(std::ostream &out, uint32_t data)
+void writeUINT32_T(ostream &out, uint32_t data)
{
#ifdef WORDS_BIGENDIAN
out.write(((char*)&data)+3,1);
@@ -577,10 +278,13 @@ void writeUINT32_T(std::ostream &out, uint32_t data)
#endif
}
-void PRCUncompressedFile::write(std::ostream &out)
+void PRCUncompressedFile::write(ostream &out)
{
- writeUINT32_T(out,file_size);
- out.write((char*)data,file_size);
+ if(data!=NULL)
+ {
+ writeUINT32_T(out,file_size);
+ out.write((char*)data,file_size);
+ }
}
uint32_t PRCUncompressedFile::getSize()
@@ -589,7 +293,7 @@ uint32_t PRCUncompressedFile::getSize()
}
-void PRCStartHeader::write(std::ostream &out)
+void PRCStartHeader::write(ostream &out)
{
out.write("PRC",3);
writeUINT32_T(out,minimal_version_for_read);
@@ -611,14 +315,13 @@ uint32_t PRCStartHeader::getSize()
}
-void PRCFileStructure::write(std::ostream &out)
+void PRCFileStructure::write(ostream &out)
{
header.write(out);
+ uint32_t number_of_uncompressed_files = uncompressedFiles.size();
writeUINT32_T(out,number_of_uncompressed_files);
- for(uint32_t i = 0; i < number_of_uncompressed_files; ++i)
- {
- uncompressedFiles[i].write(out);
- }
+ for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++)
+ i->write(out);
globals.write(out);
tree.write(out);
tessellations.write(out);
@@ -649,8 +352,8 @@ uint32_t PRCFileStructure::getSize()
uint32_t size = 0;
size += header.getSize();
size += sizeof(uint32_t);
- for(uint32_t i = 0; i < number_of_uncompressed_files; ++i)
- size += uncompressedFiles[i].getSize();
+ for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++)
+ size += i->getSize();
size += globals.getSize();
size += tree.getSize();
size += tessellations.getSize();
@@ -660,7 +363,7 @@ uint32_t PRCFileStructure::getSize()
}
-void PRCFileStructureInformation::write(std::ostream &out)
+void PRCFileStructureInformation::write(ostream &out)
{
writeUINT32_T(out,UUID[0]);
writeUINT32_T(out,UUID[1]);
@@ -680,7 +383,7 @@ uint32_t PRCFileStructureInformation::getSize()
return (4+2+number_of_offsets)*sizeof(uint32_t);
}
-void PRCHeader::write(std::ostream &out)
+void PRCHeader::write(ostream &out)
{
startHeader.write(out);
writeUINT32_T(out,number_of_file_structures);
@@ -690,11 +393,10 @@ void PRCHeader::write(std::ostream &out)
}
writeUINT32_T(out,model_file_offset);
writeUINT32_T(out,file_size);
+ uint32_t number_of_uncompressed_files = uncompressedFiles.size();
writeUINT32_T(out,number_of_uncompressed_files);
- for(uint32_t i = 0; i < number_of_uncompressed_files; ++i)
- {
- uncompressedFiles[i].write(out);
- }
+ for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++)
+ i->write(out);
}
uint32_t PRCHeader::getSize()
@@ -703,53 +405,361 @@ uint32_t PRCHeader::getSize()
for(uint32_t i = 0; i < number_of_file_structures; ++i)
size += fileStructureInformation[i].getSize();
size += 3*sizeof(uint32_t);
- for(uint32_t i = 0; i < number_of_uncompressed_files; ++i)
- size += uncompressedFiles[i].getSize();
+ for(list<PRCUncompressedFile>::iterator i = uncompressedFiles.begin(); i != uncompressedFiles.end(); i++)
+ size += i->getSize();
return size;
}
-bool oPRCFile::add(PRCentity *p)
+void oPRCFile::doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence)
{
- fileEntities.push_back(p);
- if(p->useMaterial)
- {
- if(getMaterialIndex(p->material) == m1)
+ const string& name = group.name;
+
+ PRCPartDefinition *part_definition = new PRCPartDefinition;
+
+ if(group.options.tess)
+ {
+ if(!group.lines.empty())
+ {
+ bool same_color = true;
+ const PRCRgbColor &color = group.lines.front().color;
+ for(PRCtesslineList::const_iterator lit=group.lines.begin(); lit!=group.lines.end(); lit++)
+ if(color!=lit->color)
+ {
+ same_color = false;
+ break;
+ }
+ map<PRCVector3d,uint32_t> points;
+ PRC3DWireTess *tess = new PRC3DWireTess();
+ if(!same_color)
+ {
+ tess->is_segment_color = true;
+ tess->is_rgba = false;
+ }
+ for(PRCtesslineList::const_iterator lit=group.lines.begin(); lit!=group.lines.end(); lit++)
+ {
+ tess->wire_indexes.push_back(lit->point.size());
+ for(uint32_t i=0; i<lit->point.size(); i++)
+ {
+ map<PRCVector3d,uint32_t>::iterator pPoint = points.find(lit->point[i]);
+ if(pPoint!=points.end())
+ 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())));
+ tess->wire_indexes.push_back(point_index);
+ tess->coordinates.push_back(lit->point[i].x);
+ tess->coordinates.push_back(lit->point[i].y);
+ tess->coordinates.push_back(lit->point[i].z);
+ }
+ if(!same_color && i>0)
+ {
+ tess->rgba_vertices.push_back((uint8_t)(255*lit->color.red));
+ tess->rgba_vertices.push_back((uint8_t)(255*lit->color.green));
+ tess->rgba_vertices.push_back((uint8_t)(255*lit->color.blue));
+ }
+ }
+ }
+ const uint32_t tess_index = add3DWireTess(tess);
+ PRCPolyWire *polyWire = new PRCPolyWire();
+ polyWire->index_tessellation = tess_index;
+ if(same_color)
+ polyWire->index_of_line_style = addColour(RGBAColour(color.red,color.green,color.blue));
+ part_definition->addPolyWire(polyWire);
+ }
+// make rectangles pairs of triangles in a tesselation
+ if(!group.rectangles.empty())
+ {
+ bool same_color = true;
+ const uint32_t &style = group.rectangles.front().style;
+ for(PRCtessrectangleList::const_iterator rit=group.rectangles.begin(); rit!=group.rectangles.end(); rit++)
+ if(style!=rit->style)
+ {
+ same_color = false;
+ break;
+ }
+ map<PRCVector3d,uint32_t> points;
+ PRC3DTess *tess = new PRC3DTess();
+ PRCTessFace *tessFace = new PRCTessFace();
+ tessFace->used_entities_flag=PRC_FACETESSDATA_Triangle;
+ uint32_t triangles = 0;
+ for(PRCtessrectangleList::const_iterator rit=group.rectangles.begin(); rit!=group.rectangles.end(); rit++)
+ {
+ const bool degenerate = (rit->vertices[0]==rit->vertices[1]);
+ uint32_t vertex_indices[4];
+ for(size_t i = (degenerate?1:0); i < 4; ++i)
+ {
+ map<PRCVector3d,uint32_t>::iterator pPoint = points.find(rit->vertices[i]);
+ if(pPoint!=points.end())
+ vertex_indices[i] = pPoint->second;
+ else
+ {
+ points.insert(make_pair(rit->vertices[i],(vertex_indices[i] = tess->coordinates.size())));
+ tess->coordinates.push_back(rit->vertices[i].x);
+ tess->coordinates.push_back(rit->vertices[i].y);
+ tess->coordinates.push_back(rit->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_color)
+ tessFace->line_attributes.push_back(rit->style);
+ }
+ 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_color)
+ tessFace->line_attributes.push_back(rit->style);
+ 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_color)
+ tessFace->line_attributes.push_back(rit->style);
+ }
+ }
+ 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_color)
+ polyBrepModel->index_of_line_style = style;
+ part_definition->addPolyBrepModel(polyBrepModel);
+ }
+ }
+
+ if(!group.points.empty())
+ {
+ for(PRCpointsetMap::const_iterator pit=group.points.begin(); pit!=group.points.end(); pit++)
+ {
+ PRCPointSet *pointset = new PRCPointSet();
+ pointset->index_of_line_style = pit->first;
+ pointset->point = pit->second;
+ part_definition->addPointSet(pointset);
+ }
+ }
+
+ if(!group.wires.empty())
{
- materialMap.push_back(p->material);
+ PRCTopoContext *wireContext = new PRCTopoContext;
+ uint32_t context_index = addTopoContext(wireContext);
+ for(PRCwireList::const_iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++)
+ {
+ PRCSingleWireBody *wireBody = new PRCSingleWireBody;
+ const uint32_t wire_body_index = wireContext->addSingleWireBody(wireBody);
+ PRCWireEdge *wireEdge = new PRCWireEdge;
+ wireBody->setWireEdge(wireEdge);
+ wireEdge->setCurve(wit->curve);
+ PRCWire *wire = new PRCWire();
+ wire->index_of_line_style = wit->style;
+ wire->context_id = context_index;
+ wire->body_id = wire_body_index;
+ if(wit->transform)
+ wire->index_local_coordinate_system = addTransform(wit->transform);
+ part_definition->addWire(wire);
+ }
+ }
- if(getColourIndex(p->material.ambient) == m1)
- colourMap.push_back(p->material.ambient);
+ const PRCfaceList &faces = group.faces;
+ if(!faces.empty())
+ {
+ bool same_color = true;
+ uint32_t style = faces.front().style;
+ for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++)
+ if(style!=fit->style)
+ {
+ same_color = false;
+ break;
+ }
+ PRCTopoContext *context = new PRCTopoContext;
+ context->granularity = group.options.granularity;
+ const uint32_t context_index = addTopoContext(context);
+ PRCShell *shell = new PRCShell;
+
+ for(PRCfaceList::const_iterator fit=faces.begin(); fit!=faces.end(); fit++)
+ {
+ if(fit->transform || group.options.do_break ||
+ (fit->transparent && !group.options.no_break))
+ {
+ PRCBrepData *body = new PRCBrepData;
+ const uint32_t body_index = context->addBrepData(body);
+ PRCConnex *connex = new PRCConnex;
+ body->addConnex(connex);
+ PRCShell *shell = new PRCShell;
+ connex->addShell(shell);
+ shell->addFace(fit->face);
+
+ PRCBrepModel *brepmodel = new PRCBrepModel();
+ brepmodel->index_of_line_style = fit->style;
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = group.options.closed;
+
+ brepmodel->index_local_coordinate_system = addTransform(fit->transform);
+
+ part_definition->addBrepModel(brepmodel);
+ }
+ else
+ {
+ if(!same_color)
+ fit->face->index_of_line_style = fit->style;
+ shell->addFace(fit->face);
+ }
+ }
+ if(shell->face.empty())
+ {
+ delete shell;
+ }
+ else
+ {
+ PRCBrepData *body = new PRCBrepData;
+ const uint32_t body_index = context->addBrepData(body);
+ PRCConnex *connex = new PRCConnex;
+ body->addConnex(connex);
+ connex->addShell(shell);
+ PRCBrepModel *brepmodel = new PRCBrepModel();
+ if(same_color)
+ brepmodel->index_of_line_style = style;
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = group.options.closed;
+ part_definition->addBrepModel(brepmodel);
+ }
+ }
- if(getColourIndex(p->material.diffuse) == m1)
- colourMap.push_back(p->material.diffuse);
+ const PRCcompfaceList &compfaces = group.compfaces;
+ if(!compfaces.empty())
+ {
+ bool same_color = true;
+ uint32_t style = compfaces.front().style;
+ for(PRCcompfaceList::const_iterator fit=compfaces.begin(); fit!=compfaces.end(); fit++)
+ if(style!=fit->style)
+ {
+ same_color = false;
+ break;
+ }
+ PRCTopoContext *context = new PRCTopoContext;
+ context->granularity = group.options.granularity;
+ const uint32_t context_index = addTopoContext(context);
+ PRCCompressedBrepData *body = new PRCCompressedBrepData;
+
+ body->serial_tolerance=group.options.compression;
+ body->brep_data_compressed_tolerance=0.1*group.options.compression;
+
+ for(PRCcompfaceList::const_iterator fit=compfaces.begin(); fit!=compfaces.end(); fit++)
+ {
+ if(group.options.do_break ||
+ (fit->transparent && !group.options.no_break))
+ {
+ PRCCompressedBrepData *body = new PRCCompressedBrepData;
+ const uint32_t body_index = context->addCompressedBrepData(body);
+ body->face.push_back(fit->face);
+
+ body->serial_tolerance=group.options.compression;
+ body->brep_data_compressed_tolerance=2.8346456*
+ group.options.compression;
+
+ PRCBrepModel *brepmodel = new PRCBrepModel();
+ brepmodel->index_of_line_style = fit->style;
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = group.options.closed;
+
+ part_definition->addBrepModel(brepmodel);
+ }
+ else
+ {
+ if(!same_color)
+ fit->face->index_of_line_style = fit->style;
+ body->face.push_back(fit->face);
+ }
+ }
+ if(body->face.empty())
+ {
+ delete body;
+ }
+ else
+ {
+ const uint32_t body_index = context->addCompressedBrepData(body);
+ PRCBrepModel *brepmodel = new PRCBrepModel();
+ if(same_color)
+ brepmodel->index_of_line_style = style;
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = group.options.closed;
+ part_definition->addBrepModel(brepmodel);
+ }
+ }
- if(getColourIndex(p->material.emissive) == m1)
- colourMap.push_back(p->material.emissive);
+ PRCProductOccurrence *product_occurrence = new PRCProductOccurrence(name);
- if(getColourIndex(p->material.specular) == m1)
- colourMap.push_back(p->material.specular);
+ for(PRCgroupList::const_iterator it=group.groupList.begin(); it!=group.groupList.end(); it++)
+ {
+ doGroup(*it, part_definition, product_occurrence);
}
- }
- else
- {
- if(getColourIndex(p->colour) == m1)
+
+ // Simplify and reduce to as simple entities as possible
+ // First option - reduce to one element in parent
+ if (parent_part_definition && product_occurrence->index_son_occurrence.empty() &&
+ part_definition->representation_item.size() == 1 &&
+ ( name.empty() || part_definition->representation_item.front()->name.empty() ) &&
+ ( !group.transform || part_definition->representation_item.front()->index_local_coordinate_system==m1) )
{
- colourMap.push_back(p->colour);
+ if(part_definition->representation_item.front()->name.empty() )
+ 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);
+ parent_part_definition->addRepresentationItem(part_definition->representation_item.front());
+ delete product_occurrence;
+ delete part_definition;
}
- }
- return true;
+ // 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 )
+ {
+ PRCSet *set = new PRCSet(name);
+ set->index_local_coordinate_system = addTransform(group.transform);
+ for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++)
+ set->addRepresentationItem(*it);
+ parent_part_definition->addSet(set);
+ delete product_occurrence;
+ delete part_definition;
+ }
+ // Third option - create product
+ else
+ {
+ if (part_definition->representation_item.empty())
+ delete part_definition;
+ else
+ product_occurrence->index_part = addPartDefinition(part_definition);
+ if (group.transform) {
+ product_occurrence->location = group.transform;
+ product_occurrence->has_location = true;
+ }
+ if (parent_product_occurrence) {
+ parent_product_occurrence->index_son_occurrence.push_back(addProductOccurrence(product_occurrence));
+ }
+ else {
+ addProductOccurrence(product_occurrence);
+ }
+ }
+
}
bool oPRCFile::finish()
{
- // only one file structure is currently used
- // prepare data
- fileStructures[0] = new PRCFileStructure(this,0);
- fileStructures[0]->header.minimal_version_for_read = PRCVersion;
- fileStructures[0]->header.authoring_version = PRCVersion;
- makeFileUUID(fileStructures[0]->header.fileStructureUUID);
- makeAppUUID(fileStructures[0]->header.applicationUUID);
- fileStructures[0]->number_of_uncompressed_files = 0;
+ rootGroup.name = "root";
+ doGroup(rootGroup, NULL, NULL);
// write each section's bit data
fileStructures[0]->prepare();
@@ -758,7 +768,6 @@ bool oPRCFile::finish()
// create the header
// fill out enough info so that sizes can be computed correctly
- header.number_of_uncompressed_files = 0;
header.number_of_file_structures = number_of_file_structures;
header.fileStructureInformation = new PRCFileStructureInformation[number_of_file_structures];
for(uint32_t i = 0; i < number_of_file_structures; ++i)
@@ -786,8 +795,8 @@ bool oPRCFile::finish()
{
header.fileStructureInformation[i].offsets[0] = currentOffset; // header offset
currentOffset += fileStructures[i]->header.getSize() + sizeof(uint32_t);
- for(uint32_t j = 0; j < fileStructures[i]->number_of_uncompressed_files; ++j)
- currentOffset += fileStructures[i]->uncompressedFiles[j].getSize();
+ for(list<PRCUncompressedFile>::iterator j = fileStructures[i]->uncompressedFiles.begin(); j != fileStructures[i]->uncompressedFiles.end(); j++)
+ currentOffset += j->getSize();
header.fileStructureInformation[i].offsets[1] = currentOffset; // globals offset
currentOffset += fileStructures[i]->globals.getSize();
header.fileStructureInformation[i].offsets[2] = currentOffset; // tree offset
@@ -818,35 +827,695 @@ bool oPRCFile::finish()
return true;
}
-uint32_t oPRCFile::getColourIndex(const RGBAColour &c)
+uint32_t oPRCFile::getSize()
{
- for(uint32_t i = 0; i < colourMap.size(); ++i)
+ uint32_t size = header.getSize();
+
+ for(uint32_t i = 0; i < number_of_file_structures; ++i)
{
- if(colourMap[i] == c)
- return i;
+ size += fileStructures[i]->getSize();
}
- return m1;
+
+ size += modelFile.getSize();
+ return size;
}
-uint32_t oPRCFile::getMaterialIndex(const PRCMaterial &m)
+#define REPORT_ERROR( value ) { cerr << value << endl; return m1; }
+
+uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *p, uint32_t width, uint32_t height, string name)
{
- for(uint32_t i = 0; i < materialMap.size(); ++i)
+ if(size==0 || p==NULL)
+ REPORT_ERROR( "image not set" )
+ PRCPicture picture(name);
+ PRCUncompressedFile uncompressedFile;
+ uint32_t components=0;
+ uint8_t *data = NULL;
+ switch(format)
{
- if(materialMap[i] == m)
- return i;
+ case KEPRCPicture_BITMAP_RGB_BYTE:
+ components = 3;
+ case KEPRCPicture_BITMAP_RGBA_BYTE:
+ components = 4;
+ case KEPRCPicture_BITMAP_GREY_BYTE:
+ components = 1;
+ case KEPRCPicture_BITMAP_GREYA_BYTE:
+ components = 2;
+ if(width==0 || height==0)
+ REPORT_ERROR( "width or height parameter not set" )
+ if (size < width*height*components)
+ REPORT_ERROR( "image too small" )
+
+ {
+ uint32_t compressedDataSize = 0;
+ const int CHUNK= 1024; // is this reasonable?
+
+ z_stream strm;
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ if(deflateInit(&strm,Z_DEFAULT_COMPRESSION) != Z_OK)
+ REPORT_ERROR ( "Compression initialization failed" )
+ unsigned int sizeAvailable = deflateBound(&strm,size);
+ uint8_t *compressedData = (uint8_t*) malloc(sizeAvailable);
+ strm.avail_in = size;
+ strm.next_in = (unsigned char*)p;
+ strm.next_out = (unsigned char*)compressedData;
+ strm.avail_out = sizeAvailable;
+
+ int code;
+ unsigned int chunks = 0;
+ while((code = deflate(&strm,Z_FINISH)) == Z_OK)
+ {
+ ++chunks;
+ // strm.avail_out should be 0 if we got Z_OK
+ compressedDataSize = sizeAvailable - strm.avail_out;
+ compressedData = (uint8_t*) realloc(compressedData,CHUNK*chunks);
+ strm.next_out = (Bytef*)(compressedData + compressedDataSize);
+ strm.avail_out += CHUNK;
+ sizeAvailable += CHUNK;
+ }
+ compressedDataSize = sizeAvailable-strm.avail_out;
+
+ if(code != Z_STREAM_END)
+ {
+ deflateEnd(&strm);
+ free(compressedData);
+ REPORT_ERROR ( "Compression error" )
+ }
+
+ deflateEnd(&strm);
+ size = compressedDataSize;
+ data = new uint8_t[compressedDataSize];
+ memcpy(data, compressedData, compressedDataSize);
+ free(compressedData);
+ }
+ uncompressedFiles.push_back(uncompressedFile);
+ uncompressedFiles.back().file_size = size;
+ uncompressedFiles.back().data = data;
+ picture.format = format;
+ picture.uncompressed_file_index = uncompressedFiles.size()-1;
+ picture.pixel_width = width;
+ picture.pixel_height = height;
+ globals.pictures.push_back(picture);
+ return globals.pictures.size()-1;
+ break;
+
+ case KEPRCPicture_PNG:
+ case KEPRCPicture_JPG:
+ data = new uint8_t[size];
+ memcpy(data, p, size);
+ uncompressedFiles.push_back(uncompressedFile);
+ uncompressedFiles.back().file_size = size;
+ uncompressedFiles.back().data = data;
+ picture.format = format;
+ picture.uncompressed_file_index = uncompressedFiles.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;
+ globals.pictures.push_back(picture);
+ return globals.pictures.size()-1;
+ break;
+
+ default:
+ REPORT_ERROR( "unknown picture format" )
}
return m1;
}
+#undef REPORT_ERROR
-uint32_t oPRCFile::getSize()
+uint32_t PRCFileStructure::addTextureDefinition(PRCTextureDefinition *pTextureDefinition)
{
- uint32_t size = header.getSize();
+ globals.texture_definitions.push_back(PRCpTextureDefinition(pTextureDefinition));
+ return globals.texture_definitions.size()-1;
+}
- for(uint32_t i = 0; i < number_of_file_structures; ++i)
+uint32_t PRCFileStructure::addRgbColor(const PRCRgbColor &color)
+{
+ globals.colors.push_back(color);
+ return 3*(globals.colors.size()-1);
+}
+
+uint32_t PRCFileStructure::addRgbColorUnique(const PRCRgbColor &color)
+{
+ for(uint32_t i = 0; i < globals.colors.size(); ++i)
{
- size += fileStructures[i]->getSize();
+ if(globals.colors[i] == color)
+ return 3*i;
}
+ globals.colors.push_back(color);
+ return 3*(globals.colors.size()-1);
+}
- size += modelFile.getSize();
- return size;
+uint32_t oPRCFile::addColor(const PRCRgbColor &color)
+{
+ PRCcolorMap::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);
+ colorMap.insert(make_pair(color,color_index));
+ return color_index;
+}
+
+uint32_t oPRCFile::addColour(const RGBAColour &colour)
+{
+ PRCcolourMap::iterator pColour = colourMap.find(colour);
+ if(pColour!=colourMap.end())
+ return pColour->second;
+ const uint32_t color_index = addColor(PRCRgbColor(colour.R, colour.G, colour.B));
+ PRCStyle *style = new PRCStyle();
+ style->line_width = 1.0;
+ style->is_vpicture = false;
+ style->line_pattern_vpicture_index = 0;
+ style->is_material = false;
+ style->color_material_index = color_index;
+ style->is_transparency_defined = (colour.A < 1.0);
+ style->transparency = (uint8_t)(colour.A * 256);
+ style->additional = 0;
+ const uint32_t style_index = fileStructures[0]->addStyle(style);
+ colourMap.insert(make_pair(colour,style_index));
+ return style_index;
+}
+
+uint32_t oPRCFile::addTransform(const PRCpGeneralTransformation3d &transform)
+{
+ if(!transform)
+ return m1;
+ PRCtransformMap::iterator pTransform = transformMap.find(*transform);
+ if(pTransform!=transformMap.end())
+ return pTransform->second;
+ PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem();
+ coordinateSystem->axis_set = transform;
+ const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem);
+ transformMap.insert(make_pair(*transform,coordinate_system_index));
+ return coordinate_system_index;
+}
+
+uint32_t oPRCFile::addMaterial(const PRCmaterial &material)
+{
+ PRCmaterialMap::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);
+ materialGeneric->ambient = addColor(ambient);
+ const PRCRgbColor diffuse(material.diffuse.R, material.diffuse.G, material.diffuse.B);
+ materialGeneric->diffuse = addColor(diffuse);
+ const PRCRgbColor emissive(material.emissive.R, material.emissive.G, material.emissive.B);
+ materialGeneric->emissive = addColor(emissive);
+ const PRCRgbColor specular(material.specular.R, material.specular.G, material.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 = fileStructures[0]->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->color_material_index = material_index;
+ style->is_transparency_defined = (material.alpha < 1.0);
+ style->transparency = (uint8_t)(material.alpha * 256);
+ style->additional = 0;
+ const uint32_t style_index = fileStructures[0]->addStyle(style);
+ materialMap.insert(make_pair(material,style_index)).first;
+ return style_index;
+}
+
+bool isid(const double t[][4])
+{
+ return(
+ t[0][0]==1 && t[0][1]==0 && t[0][2]==0 && t[0][3]==0 &&
+ t[1][0]==0 && t[1][1]==1 && t[1][2]==0 && t[1][3]==0 &&
+ t[2][0]==0 && t[2][1]==0 && t[2][2]==1 && t[2][3]==0 &&
+ t[3][0]==0 && t[3][1]==0 && t[3][2]==0 && t[3][3]==1 );
+}
+
+void oPRCFile::begingroup(const char *name, PRCoptions *options,
+ const double t[][4])
+{
+ 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());
+ group.name=name;
+ if(options) group.options=*options;
+ if(t&&!isid(t))
+ group.transform.reset(new PRCGeneralTransformation3d(t));
+}
+
+void oPRCFile::endgroup()
+{
+ if(!currentGroups.empty())
+ currentGroups.pop();
+}
+
+PRCgroup& oPRCFile::findGroup()
+{
+ if(!currentGroups.empty())
+ return *(currentGroups.top());
+ else
+ return rootGroup;
+}
+
+#define ADDWIRE(curvtype) \
+ PRCgroup &group = findGroup(); \
+ group.wires.push_back(PRCwire()); \
+ PRCwire &wire = group.wires.back(); \
+ curvtype *curve = new curvtype; \
+ wire.curve.reset(curve); \
+ wire.style = addColour(c);
+
+#define ADDFACE(surftype) \
+ PRCgroup &group = findGroup(); \
+ group.faces.push_back(PRCface()); \
+ PRCface& face = group.faces.back(); \
+ surftype *surface = new surftype; \
+ face.face.reset(new PRCFace); \
+ face.face->setSurface(surface); \
+ face.transparent = m.alpha < 1.0; \
+ face.style = addMaterial(m);
+
+#define ADDCOMPFACE \
+ PRCgroup &group = findGroup(); \
+ group.compfaces.push_back(PRCcompface()); \
+ PRCcompface& face = group.compfaces.back(); \
+ PRCCompressedFace *compface = new PRCCompressedFace; \
+ face.face.reset(compface); \
+ face.transparent = m.alpha < 1.0; \
+ face.style = addMaterial(m);
+
+void oPRCFile::addPoint(const double P[3], const RGBAColour &c)
+{
+ PRCgroup &group = findGroup();
+ group.points[addColour(c)].push_back(PRCVector3d(P[0],P[1],P[2]));
+}
+
+void oPRCFile::addLine(uint32_t n, const double P[][3], const RGBAColour &c)
+{
+ PRCgroup &group = findGroup();
+ if(group.options.tess)
+ {
+ group.lines.push_back(PRCtessline());
+ group.lines.back().color.red = c.R;
+ group.lines.back().color.green = c.G;
+ group.lines.back().color.blue = c.B;
+ for(uint32_t i=0; i<n; i++)
+ group.lines.back().point.push_back(PRCVector3d(P[i][0],P[i][1],P[i][2]));
+ }
+ else
+ {
+ ADDWIRE(PRCPolyLine)
+ curve->point.resize(n);
+ for(uint32_t i=0; i<n; i++)
+ curve->point[i].Set(P[i][0],P[i][1],P[i][2]);
+ curve->interval.min = 0;
+ curve->interval.max = curve->point.size()-1;
+ }
+}
+
+void oPRCFile::addBezierCurve(uint32_t n, const double cP[][3],
+ const RGBAColour &c)
+{
+ ADDWIRE(PRCNURBSCurve)
+ curve->is_rational = false;
+ curve->degree = 3;
+ const size_t NUMBER_OF_POINTS = n;
+ curve->control_point.resize(NUMBER_OF_POINTS);
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+ curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]);
+ curve->knot.resize(3+NUMBER_OF_POINTS+1);
+ curve->knot[0] = 1;
+ for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i)
+ curve->knot[i] = (i+2)/3; // integer division is intentional
+ curve->knot[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3;
+}
+
+void oPRCFile::addCurve(uint32_t d, uint32_t n, const double cP[][3], const double *k, const RGBAColour &c, const double w[])
+{
+ ADDWIRE(PRCNURBSCurve)
+ curve->is_rational = w;
+ curve->degree = d;
+ curve->control_point.resize(n);
+ for(uint32_t i = 0; i < n; i++)
+ if(w)
+ curve->control_point[i].Set(cP[i][0]*w[i],cP[i][1]*w[i],cP[i][2]*w[i],w[i]);
+ else
+ curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]);
+ curve->knot.resize(d+n+1);
+ for(uint32_t i = 0; i < d+n+1; i++)
+ curve->knot[i] = k[i];
+}
+
+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);
+ for(size_t i = 0; i < 4; i++)
+ {
+ rectangle.vertices[i].x = P[i][0];
+ rectangle.vertices[i].y = P[i][1];
+ rectangle.vertices[i].z = P[i][2];
+ }
+ }
+ else if(group.options.compression == 0.0)
+ {
+ ADDFACE(PRCNURBSSurface)
+
+ surface->is_rational = false;
+ surface->degree_in_u = 1;
+ surface->degree_in_v = 1;
+ surface->control_point.resize(4);
+ for(size_t i = 0; i < 4; ++i)
+ {
+ surface->control_point[i].x = P[i][0];
+ surface->control_point[i].y = P[i][1];
+ surface->control_point[i].z = P[i][2];
+ }
+ surface->knot_u.resize(4);
+ surface->knot_v.resize(4);
+ surface->knot_v[0] = surface->knot_u[0] = 1;
+ surface->knot_v[1] = surface->knot_u[1] = 3;
+ surface->knot_v[2] = surface->knot_u[2] = 4;
+ surface->knot_v[3] = surface->knot_u[3] = 4;
+ }
+ else
+ {
+ ADDCOMPFACE
+
+ compface->degree = 1;
+ compface->control_point.resize(4);
+ for(size_t i = 0; i < 4; ++i)
+ {
+ compface->control_point[i].x = P[i][0];
+ compface->control_point[i].y = P[i][1];
+ compface->control_point[i].z = P[i][2];
+ }
+ }
+}
+
+void oPRCFile::addPatch(const double cP[][3], const PRCmaterial &m)
+{
+ PRCgroup &group = findGroup();
+ if(group.options.compression == 0.0)
+ {
+ ADDFACE(PRCNURBSSurface)
+
+ surface->is_rational = false;
+ surface->degree_in_u = 3;
+ surface->degree_in_v = 3;
+ surface->control_point.resize(16);
+ for(size_t i = 0; i < 16; ++i)
+ {
+ surface->control_point[i].x = cP[i][0];
+ surface->control_point[i].y = cP[i][1];
+ surface->control_point[i].z = cP[i][2];
+ }
+ surface->knot_u.resize(8);
+ surface->knot_v.resize(8);
+ surface->knot_v[0] = surface->knot_u[0] = 1;
+ surface->knot_v[1] = surface->knot_u[1] = 1;
+ surface->knot_v[2] = surface->knot_u[2] = 1;
+ surface->knot_v[3] = surface->knot_u[3] = 1;
+ surface->knot_v[4] = surface->knot_u[4] = 2;
+ surface->knot_v[5] = surface->knot_u[5] = 2;
+ surface->knot_v[6] = surface->knot_u[6] = 2;
+ surface->knot_v[7] = surface->knot_u[7] = 2;
+ }
+ else
+ {
+ ADDCOMPFACE
+
+ compface->degree = 3;
+ compface->control_point.resize(16);
+ for(size_t i = 0; i < 16; ++i)
+ {
+ compface->control_point[i].x = cP[i][0];
+ compface->control_point[i].y = cP[i][1];
+ compface->control_point[i].z = cP[i][2];
+ }
+ }
+}
+
+void oPRCFile::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[])
+{
+ ADDFACE(PRCNURBSSurface)
+
+ surface->is_rational = w;
+ surface->degree_in_u = dU;
+ surface->degree_in_v = dV;
+ surface->control_point.resize(nU*nV);
+ for(size_t i = 0; i < nU*nV; i++)
+ if(w)
+ surface->control_point[i]=PRCControlPoint(cP[i][0]*w[i],cP[i][1]*w[i],cP[i][2]*w[i],w[i]);
+ else
+ surface->control_point[i]=PRCControlPoint(cP[i][0],cP[i][1],cP[i][2]);
+ surface->knot_u.insert(surface->knot_u.end(), kU, kU+(dU+nU+1));
+ surface->knot_v.insert(surface->knot_v.end(), kV, kV+(dV+nV+1));
+}
+
+#define SETTRANSF \
+ if(t&&!isid(t)) \
+ face.transform.reset(new PRCGeneralTransformation3d(t)); \
+ if(origin) surface->origin.Set(origin[0],origin[1],origin[2]); \
+ if(x_axis) surface->x_axis.Set(x_axis[0],x_axis[1],x_axis[2]); \
+ if(y_axis) surface->y_axis.Set(y_axis[0],y_axis[1],y_axis[2]); \
+ surface->scale = scale; \
+ surface->geometry_is_2D = false; \
+ if(surface->origin!=PRCVector3d(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)) \
+ 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]
+
+void oPRCFile::addTube(uint32_t n, const double cP[][3], const double oP[][3], bool straight, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCBlend01)
+ SETTRANSF
+ if(straight)
+ {
+ PRCPolyLine *center_curve = new PRCPolyLine;
+ center_curve->point.resize(n);
+ for(uint32_t i=0; i<n; i++)
+ center_curve->point[i].Set(cP[i][0],cP[i][1],cP[i][2]);
+ center_curve->interval.min = 0;
+ center_curve->interval.max = center_curve->point.size()-1;
+ surface->setCenterCurve(center_curve);
+
+ PRCPolyLine *origin_curve = new PRCPolyLine;
+ origin_curve->point.resize(n);
+ for(uint32_t i=0; i<n; i++)
+ origin_curve->point[i].Set(oP[i][0],oP[i][1],oP[i][2]);
+ origin_curve->interval.min = 0;
+ origin_curve->interval.max = origin_curve->point.size()-1;
+ surface->setOriginCurve(origin_curve);
+
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*pi;
+ surface->uv_domain.min.y = center_curve->interval.min;
+ surface->uv_domain.max.y = center_curve->interval.max;
+ }
+ else
+ {
+ PRCNURBSCurve *center_curve = new PRCNURBSCurve;
+ center_curve->is_rational = false;
+ center_curve->degree = 3;
+ const uint32_t CENTER_NUMBER_OF_POINTS = n;
+ center_curve->control_point.resize(CENTER_NUMBER_OF_POINTS);
+ for(uint32_t i = 0; i < CENTER_NUMBER_OF_POINTS; ++i)
+ center_curve->control_point[i].Set(cP[i][0],cP[i][1],cP[i][2]);
+ center_curve->knot.resize(3+CENTER_NUMBER_OF_POINTS+1);
+ center_curve->knot[0] = 1;
+ for(uint32_t i = 1; i < 3+CENTER_NUMBER_OF_POINTS; ++i)
+ center_curve->knot[i] = (i+2)/3; // integer division is intentional
+ center_curve->knot[3+CENTER_NUMBER_OF_POINTS] = (3+CENTER_NUMBER_OF_POINTS+1)/3;
+ surface->setCenterCurve(center_curve);
+
+ PRCNURBSCurve *origin_curve = new PRCNURBSCurve;
+ origin_curve->is_rational = false;
+ origin_curve->degree = 3;
+ const uint32_t ORIGIN_NUMBER_OF_POINTS = n;
+ origin_curve->control_point.resize(ORIGIN_NUMBER_OF_POINTS);
+ for(uint32_t i = 0; i < ORIGIN_NUMBER_OF_POINTS; ++i)
+ origin_curve->control_point[i].Set(oP[i][0],oP[i][1],oP[i][2]);
+ origin_curve->knot.resize(3+ORIGIN_NUMBER_OF_POINTS+1);
+ origin_curve->knot[0] = 1;
+ for(size_t i = 1; i < 3+ORIGIN_NUMBER_OF_POINTS; ++i)
+ origin_curve->knot[i] = (i+2)/3; // integer division is intentional
+ origin_curve->knot[3+ORIGIN_NUMBER_OF_POINTS] = (3+ORIGIN_NUMBER_OF_POINTS+1)/3;
+ surface->setOriginCurve(origin_curve);
+
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*pi;
+ surface->uv_domain.min.y = 1; // first knot
+ surface->uv_domain.max.y = (3+CENTER_NUMBER_OF_POINTS+1)/3; // last knot
+ }
+}
+
+void oPRCFile::addHemisphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCSphere)
+ SETTRANSF
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*pi;
+ surface->uv_domain.min.y = 0;
+ surface->uv_domain.max.y = 0.5*pi;
+ surface->radius = radius;
+}
+
+void oPRCFile::addSphere(double radius, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCSphere)
+ SETTRANSF
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*pi;
+ surface->uv_domain.min.y =-0.5*pi;
+ surface->uv_domain.max.y = 0.5*pi;
+ surface->radius = radius;
+}
+
+void oPRCFile::addDisk(double radius, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCRuled)
+ SETTRANSF
+ PRCCircle *first_curve = new PRCCircle;
+ first_curve->radius = radius;
+ surface->setFirstCurve(first_curve);
+ PRCCircle *second_curve = new PRCCircle;
+ second_curve->radius = 0;
+ surface->setSecondCurve(second_curve);
+
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 1;
+ surface->uv_domain.min.y = 0;
+ surface->uv_domain.max.y = 2*pi;
+ surface->parameterization_on_v_coeff_a = -1;
+ surface->parameterization_on_v_coeff_b = 2*pi;
+}
+
+void oPRCFile::addCylinder(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCCylinder)
+ SETTRANSF
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*pi;
+ surface->uv_domain.min.y = (height>0)?0:height;
+ surface->uv_domain.max.y = (height>0)?height:0;
+ surface->radius = radius;
+}
+
+void oPRCFile::addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial &m, PRCFACETRANSFORM)
+{
+ ADDFACE(PRCTorus)
+ SETTRANSF
+ surface->uv_domain.min.x = (angle1/180)*pi;
+ surface->uv_domain.max.x = (angle2/180)*pi;
+ surface->uv_domain.min.y = 0;
+ surface->uv_domain.max.y = 2*pi;
+ surface->major_radius = major_radius;
+ surface->minor_radius = minor_radius;
+}
+
+#undef PRCFACETRANSFORM
+#undef ADDFACE
+#undef ADDWIRE
+#undef SETTRANSF
+
+uint32_t PRCFileStructure::addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric)
+{
+ globals.materials.push_back(PRCpMaterial(pMaterialGeneric));
+ return globals.materials.size()-1;
+}
+
+uint32_t PRCFileStructure::addTextureApplication(PRCTextureApplication *pTextureApplication)
+{
+ globals.materials.push_back(PRCpMaterial(pTextureApplication));
+ return globals.materials.size()-1;
+}
+
+uint32_t PRCFileStructure::addStyle(PRCStyle *pStyle)
+{
+ globals.styles.push_back(PRCpStyle(pStyle));
+ return globals.styles.size()-1;
+}
+
+uint32_t PRCFileStructure::addPartDefinition(PRCPartDefinition *pPartDefinition)
+{
+ tree.part_definitions.push_back(PRCpPartDefinition(pPartDefinition));
+ return tree.part_definitions.size()-1;
+}
+
+uint32_t PRCFileStructure::addProductOccurrence(PRCProductOccurrence *pProductOccurrence)
+{
+ tree.product_occurrences.push_back(PRCpProductOccurrence(pProductOccurrence));
+ return tree.product_occurrences.size()-1;
+}
+
+uint32_t PRCFileStructure::addTopoContext(PRCTopoContext *pTopoContext)
+{
+ contexts.push_back(PRCpTopoContext(pTopoContext));
+ return contexts.size()-1;
+}
+
+uint32_t PRCFileStructure::add3DTess(PRC3DTess *p3DTess)
+{
+ tessellations.tessellations.push_back(PRCpTess(p3DTess));
+ return tessellations.tessellations.size()-1;
+}
+
+uint32_t PRCFileStructure::add3DWireTess(PRC3DWireTess *p3DWireTess)
+{
+ tessellations.tessellations.push_back(PRCpTess(p3DWireTess));
+ return tessellations.tessellations.size()-1;
+}
+/*
+uint32_t PRCFileStructure::addMarkupTess(PRCMarkupTess *pMarkupTess)
+{
+ tessellations.tessellations.push_back(PRCpTess(pMarkupTess));
+ return tessellations.tessellations.size()-1;
+}
+
+uint32_t PRCFileStructure::addMarkup(PRCMarkup *pMarkup)
+{
+ tree.markups.push_back(PRCpMarkup(pMarkup));
+ return tree.markups.size()-1;
+}
+
+uint32_t PRCFileStructure::addAnnotationItem(PRCAnnotationItem *pAnnotationItem)
+{
+ tree.annotation_entities.push_back(PRCpAnnotationItem(pAnnotationItem));
+ return tree.annotation_entities.size()-1;
+}
+*/
+uint32_t PRCFileStructure::addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem)
+{
+ globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem));
+ return globals.reference_coordinate_systems.size()-1;
+}
+
+uint32_t PRCFileStructure::addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem)
+{
+ for(uint32_t i = 0; i < globals.reference_coordinate_systems.size(); ++i)
+ {
+ if(*(globals.reference_coordinate_systems[i])==*pCoordinateSystem)
+ return i;
+ }
+ globals.reference_coordinate_systems.push_back(PRCpCoordinateSystem(pCoordinateSystem));
+ return globals.reference_coordinate_systems.size()-1;
}
diff --git a/Build/source/utils/asymptote/prc/oPRCFile.h b/Build/source/utils/asymptote/prc/oPRCFile.h
index 2ee01ddcba4..647f57c7d52 100644
--- a/Build/source/utils/asymptote/prc/oPRCFile.h
+++ b/Build/source/utils/asymptote/prc/oPRCFile.h
@@ -24,6 +24,9 @@
#include <iostream>
#include <fstream>
#include <vector>
+#include <map>
+#include <list>
+#include <stack>
#include <string>
#ifdef HAVE_CONFIG_H
@@ -35,6 +38,7 @@
#include "writePRC.h"
class oPRCFile;
+class PRCFileStructure;
struct RGBAColour
{
@@ -46,145 +50,140 @@ struct RGBAColour
{
return (R==c.R && G==c.G && B==c.B && A==c.A);
}
+ bool operator!=(const RGBAColour &c) const
+ {
+ return !(R==c.R && G==c.G && B==c.B && A==c.A);
+ }
+ bool operator<(const RGBAColour &c) const
+ {
+ if(R!=c.R)
+ return (R<c.R);
+ if(G!=c.G)
+ return (G<c.G);
+ if(B!=c.B)
+ return (B<c.B);
+ return (A<c.A);
+ }
};
+typedef std::map<RGBAColour,uint32_t> PRCcolourMap;
+typedef std::map<PRCRgbColor,uint32_t> PRCcolorMap;
-struct PRCMaterial
+struct PRCmaterial
{
- PRCMaterial() : alpha(1.0),shininess(1.0) {}
- PRCMaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e,
+ PRCmaterial() : alpha(1.0),shininess(1.0) {}
+ PRCmaterial(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) {}
RGBAColour ambient,diffuse,emissive,specular;
double alpha,shininess;
- bool operator==(const PRCMaterial &m) const
+ bool operator==(const PRCmaterial &m) const
{
return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive
- && specular==m.specular && shininess==m.shininess);
+ && specular==m.specular && alpha==m.alpha && shininess==m.shininess);
+ }
+ bool operator<(const PRCmaterial &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);
+ return (shininess<m.shininess);
}
};
+typedef std::map<PRCmaterial,uint32_t> PRCmaterialMap;
-class PRCentity
+struct PRCtessrectangle // rectangle
{
- public:
- PRCentity(oPRCFile *p,const RGBAColour &c, double scale = 1.0,
- std::string name = "") :
- colour(c), useMaterial(false), scale(scale), name(name), parent(p) {}
- PRCentity(oPRCFile *p,const PRCMaterial &m, double scale = 1.0,
- std::string name = "") :
- material(m), useMaterial(true), scale(scale), name(name), parent(p) {}
- uint32_t getGraphicsIndex();
- virtual void writeRepresentationItem(PRCbitStream&,uint32_t) = 0;
- virtual void writeTopologicalContext(PRCbitStream&) = 0;
- virtual void writeExtraGeometryContext(PRCbitStream&) = 0;
- RGBAColour colour;
- PRCMaterial material;
- bool useMaterial;
- double scale;
- std::string name;
- virtual ~PRCentity() {}
- protected:
- oPRCFile *parent;
+ PRCVector3d vertices[4];
+ uint32_t style;
};
+typedef std::vector<PRCtessrectangle> PRCtessrectangleList;
-class PRCsurface : public PRCentity
+struct PRCtessline // polyline
{
- public:
- // contructor with colour
- PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
- double cP[][3], double *kU, double *kV, const RGBAColour &c,
- double scale = 1.0, bool iR = false, double w[] = 0,
- double g = 0, std::string name = "") :
- PRCentity(p,c,scale,name), degreeU(dU), degreeV(dV),
- numberOfControlPointsU(nU), numberOfControlPointsV(nV),
- knotsU(kU), knotsV(kV), controlPoints(cP),
- isRational(iR), weights(w), granularity(g) {}
- // contructor with material
- PRCsurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU, uint32_t nV,
- double cP[][3], double *kU, double *kV, const PRCMaterial &m,
- double scale = 1.0, bool iR = false, double w[] = 0,
- double g = 0, std::string name = "") :
- PRCentity(p,m,scale,name), degreeU(dU), degreeV(dV),
- numberOfControlPointsU(nU), numberOfControlPointsV(nV),
- knotsU(kU), knotsV(kV), controlPoints(cP),
- isRational(iR), weights(w), granularity(g) {}
- virtual void writeRepresentationItem(PRCbitStream&,uint32_t);
- virtual void writeTopologicalContext(PRCbitStream&);
- virtual void writeExtraGeometryContext(PRCbitStream&);
- protected:
- virtual void writeKnots(PRCbitStream &out)
- {
- for(uint32_t i = 0; i < degreeU+numberOfControlPointsU+1; ++i)
- out << knotsU[i];
- for(uint32_t i = 0; i < degreeV+numberOfControlPointsV+1; ++i)
- out << knotsV[i];
- }
- private:
- uint32_t degreeU, degreeV, numberOfControlPointsU, numberOfControlPointsV;
- double *knotsU, *knotsV;
- double (*controlPoints)[3];
- bool isRational;
- double *weights;
- double granularity;
+ std::vector<PRCVector3d> point;
+ PRCRgbColor color;
};
+typedef std::list<PRCtessline> PRCtesslineList;
-class PRCline : public PRCentity
+struct PRCface
{
- public:
- // constructor with colour
- PRCline(oPRCFile *p, uint32_t n, double P[][3], const RGBAColour &c,
- double scale = 1.0, std::string name="") :
- PRCentity(p,c,scale,name), numberOfPoints(n), points(P) {}
- // constructor with material
- PRCline(oPRCFile *p, uint32_t n, double P[][3], const PRCMaterial &m,
- double scale = 1.0, std::string name = "") :
- PRCentity(p,m,scale,name), numberOfPoints(n), points(P) {}
- virtual void writeRepresentationItem(PRCbitStream&,uint32_t);
- virtual void writeTopologicalContext(PRCbitStream&);
- virtual void writeExtraGeometryContext(PRCbitStream&);
- private:
- uint32_t numberOfPoints;
- double (*points)[3];
+ uint32_t style;
+ bool transparent;
+ PRCpGeneralTransformation3d transform;
+ PRCpFace face;
};
+typedef std::tr1::shared_ptr <PRCface> PRCpface;
+typedef std::vector <PRCface> PRCfaceList;
-class PRCcurve : public PRCentity
+struct PRCcompface
{
- public:
- // constructor with colour
- PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k,
- const RGBAColour &c, double scale = 1.0, bool iR = false,
- double w[] = 0, std::string name="") :
- PRCentity(p,c,scale,name), degree(d),
- numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR),
- weights(w) {}
- // constructor with material
- PRCcurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3], double *k,
- const PRCMaterial &m, double scale = 1.0, bool iR = false,
- double w[] = 0, std::string name = "") :
- PRCentity(p,m,scale,name), degree(d),
- numberOfControlPoints(n), knots(k), controlPoints(cP), isRational(iR),
- weights(w) {}
- virtual void writeRepresentationItem(PRCbitStream&,uint32_t);
- virtual void writeTopologicalContext(PRCbitStream&);
- virtual void writeExtraGeometryContext(PRCbitStream&);
- protected:
- virtual void writeKnots(PRCbitStream &out)
- {
- for(uint32_t i = 0; i < degree+numberOfControlPoints+1; ++i)
- out << knots[i];
- }
- private:
- uint32_t degree, numberOfControlPoints;
- double *knots;
- double (*controlPoints)[3];
- bool isRational;
- double *weights;
+ uint32_t style;
+ bool transparent;
+ PRCpCompressedFace face;
+};
+typedef std::tr1::shared_ptr <PRCcompface> PRCpcompface;
+typedef std::vector <PRCcompface> PRCcompfaceList;
+
+struct PRCwire
+{
+ uint32_t style;
+ PRCpGeneralTransformation3d transform;
+ PRCpCurve curve;
};
+typedef std::tr1::shared_ptr <PRCwire> PRCpwire;
+typedef std::vector <PRCwire> PRCwireList;
+
+typedef std::map <uint32_t,std::vector<PRCVector3d> > PRCpointsetMap;
+
+class PRCoptions
+{
+public:
+ double compression;
+ double granularity;
+
+ bool closed; // render the surface as one-sided; may yield faster rendering
+ bool tess; // use tessellated mesh to store straight patches
+ bool do_break; //
+ bool no_break; // do not render transparent patches as one-faced nodes
+
+ PRCoptions(double compression=0.0, double granularity=0.0, bool closed=false,
+ bool tess=false, bool do_break=true, bool no_break=false)
+ : compression(compression), granularity(granularity), closed(closed),
+ tess(tess), do_break(do_break), no_break(no_break) {}
+};
+
+class PRCgroup
+{
+ public:
+ PRCgroup() {}
+ PRCgroup(const std::string &name) : name(name) {}
+ PRCfaceList faces;
+ PRCcompfaceList compfaces;
+ PRCtessrectangleList rectangles;
+ PRCtesslineList lines;
+ PRCwireList wires;
+ PRCpointsetMap points;
+ std::string name;
+ std::list<PRCgroup> groupList;
+ PRCpGeneralTransformation3d transform;
+ PRCoptions options;
+};
+typedef std::list<PRCgroup> PRCgroupList;
class PRCCompressedSection
{
public:
- PRCCompressedSection(oPRCFile *p) : data(0),prepared(false),parent(p),
+ PRCCompressedSection(oPRCFile *p) : data(0),prepared(false),parent(p),fileStructure(NULL),
+ out(data,0) {}
+ PRCCompressedSection(PRCFileStructure *fs) : data(0),prepared(false),parent(NULL),fileStructure(fs),
out(data,0) {}
virtual ~PRCCompressedSection()
{
@@ -204,25 +203,31 @@ class PRCCompressedSection
}
bool prepared;
oPRCFile *parent;
+ PRCFileStructure *fileStructure;
PRCbitStream out; // order matters: PRCbitStream must be initialized last
};
class PRCGlobalsSection : public PRCCompressedSection
{
public:
- PRCGlobalsSection(oPRCFile *p, uint32_t i) :
- PRCCompressedSection(p),numberOfReferencedFileStructures(0),
+ PRCGlobalsSection(PRCFileStructure *fs, uint32_t i) :
+ PRCCompressedSection(fs),numberOfReferencedFileStructures(0),
tessellationChordHeightRatio(2000.0),tessellationAngleDegrees(40.0),
- defaultFontFamilyName(""),numberOfFonts(0),numberOfPictures(0),
- numberOfTextureDefinitions(0),numberOfFillPatterns(0),
- numberOfReferenceCoordinateSystems(0),userData(0,0),index(i) {}
+ defaultFontFamilyName(""),
+ numberOfFillPatterns(0),
+ userData(0,0),index(i) {}
uint32_t numberOfReferencedFileStructures;
double tessellationChordHeightRatio;
double tessellationAngleDegrees;
std::string defaultFontFamilyName;
- uint32_t numberOfFonts,numberOfPictures,numberOfTextureDefinitions;
+ std::vector<PRCRgbColor> colors;
+ std::vector<PRCPicture> pictures;
+ PRCTextureDefinitionList texture_definitions;
+ PRCMaterialList materials;
+ PRCStyleList styles;
uint32_t numberOfFillPatterns;
- uint32_t numberOfReferenceCoordinateSystems;
+ PRCCoordinateSystemList reference_coordinate_systems;
+ std::vector<PRCFontKeysSameFont> font_keys_of_font;
UserData userData;
private:
uint32_t index;
@@ -232,8 +237,15 @@ class PRCGlobalsSection : public PRCCompressedSection
class PRCTreeSection : public PRCCompressedSection
{
public:
- PRCTreeSection(oPRCFile *p, uint32_t i) :
- PRCCompressedSection(p),index(i) {}
+ PRCTreeSection(PRCFileStructure *fs, uint32_t i) :
+ PRCCompressedSection(fs),unit(1),index(i) {}
+ PRCPartDefinitionList part_definitions;
+ PRCProductOccurrenceList product_occurrences;
+/*
+ PRCMarkupList markups;
+ PRCAnnotationItemList annotation_entities;
+ */
+ double unit;
private:
uint32_t index;
virtual void writeData();
@@ -242,8 +254,9 @@ class PRCTreeSection : public PRCCompressedSection
class PRCTessellationSection : public PRCCompressedSection
{
public:
- PRCTessellationSection(oPRCFile *p, uint32_t i) :
- PRCCompressedSection(p),index(i) {}
+ PRCTessellationSection(PRCFileStructure *fs, uint32_t i) :
+ PRCCompressedSection(fs),index(i) {}
+ PRCTessList tessellations;
private:
uint32_t index;
virtual void writeData();
@@ -252,8 +265,8 @@ class PRCTessellationSection : public PRCCompressedSection
class PRCGeometrySection : public PRCCompressedSection
{
public:
- PRCGeometrySection(oPRCFile *p, uint32_t i) :
- PRCCompressedSection(p),index(i) {}
+ PRCGeometrySection(PRCFileStructure *fs, uint32_t i) :
+ PRCCompressedSection(fs),index(i) {}
private:
uint32_t index;
virtual void writeData();
@@ -262,8 +275,8 @@ class PRCGeometrySection : public PRCCompressedSection
class PRCExtraGeometrySection : public PRCCompressedSection
{
public:
- PRCExtraGeometrySection(oPRCFile *p, uint32_t i) :
- PRCCompressedSection(p),index(i) {}
+ PRCExtraGeometrySection(PRCFileStructure *fs, uint32_t i) :
+ PRCCompressedSection(fs),index(i) {}
private:
uint32_t index;
virtual void writeData();
@@ -272,7 +285,8 @@ class PRCExtraGeometrySection : public PRCCompressedSection
class PRCModelFile : public PRCCompressedSection
{
public:
- PRCModelFile(oPRCFile *p) : PRCCompressedSection(p) {}
+ PRCModelFile(oPRCFile *p) : PRCCompressedSection(p), unit(1) {}
+ double unit;
private:
virtual void writeData();
};
@@ -283,8 +297,13 @@ void makeAppUUID(uint32_t*);
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&);
@@ -311,8 +330,8 @@ class PRCFileStructure
uint32_t index;
public:
PRCStartHeader header;
- uint32_t number_of_uncompressed_files;
- PRCUncompressedFile *uncompressedFiles;
+ std::list<PRCUncompressedFile> uncompressedFiles;
+ PRCTopoContextList contexts;
PRCGlobalsSection globals;
PRCTreeSection tree;
@@ -321,11 +340,30 @@ class PRCFileStructure
PRCExtraGeometrySection extraGeometry;
PRCFileStructure(oPRCFile *p, uint32_t i) : parent(p),index(i),
- globals(p,i),tree(p,i),tessellations(p,i),geometry(p,i),
- extraGeometry(p,i) {}
+ globals(this,i),tree(this,i),tessellations(this,i),geometry(this,i),
+ extraGeometry(this,i) {}
void write(std::ostream&);
void prepare();
uint32_t getSize();
+ 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 addTextureDefinition(PRCTextureDefinition *pTextureDefinition);
+ uint32_t addRgbColor(const PRCRgbColor &color);
+ uint32_t addRgbColorUnique(const PRCRgbColor &color);
+ uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric);
+ uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication);
+ uint32_t addStyle(PRCStyle *pStyle);
+ uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition);
+ uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence);
+ uint32_t addTopoContext(PRCTopoContext *pTopoContext);
+ uint32_t add3DTess(PRC3DTess *p3DTess);
+ uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess);
+/*
+ uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess);
+ uint32_t addMarkup(PRCMarkup *pMarkup);
+ uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem);
+ */
+ uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem);
+ uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem);
};
class PRCFileStructureInformation
@@ -349,27 +387,52 @@ class PRCHeader
PRCFileStructureInformation *fileStructureInformation;
uint32_t model_file_offset;
uint32_t file_size; // not documented
- uint32_t number_of_uncompressed_files;
- PRCUncompressedFile *uncompressedFiles;
+ std::list<PRCUncompressedFile> uncompressedFiles;
void write(std::ostream&);
uint32_t getSize();
};
+typedef std::map <PRCGeneralTransformation3d,uint32_t> PRCtransformMap;
+
class oPRCFile
{
public:
- oPRCFile(std::ostream &os, uint32_t n=1) :
+ oPRCFile(std::ostream &os, double unit=1, uint32_t n=1) :
number_of_file_structures(n),
fileStructures(new PRCFileStructure*[n]),modelFile(this),
- fout(NULL),output(os) {}
-
- oPRCFile(const std::string &name, uint32_t n=1) :
+ fout(NULL),output(os)
+ {
+ for(uint32_t i = 0; i < number_of_file_structures; ++i)
+ {
+ fileStructures[i] = new PRCFileStructure(this,i);
+ fileStructures[i]->header.minimal_version_for_read = PRCVersion;
+ fileStructures[i]->header.authoring_version = PRCVersion;
+ makeFileUUID(fileStructures[i]->header.fileStructureUUID);
+ makeAppUUID(fileStructures[i]->header.applicationUUID);
+ fileStructures[i]->tree.unit = unit;
+ }
+ modelFile.unit = unit;
+ }
+
+ oPRCFile(const std::string &name, double unit=1, uint32_t n=1) :
number_of_file_structures(n),
fileStructures(new PRCFileStructure*[n]),modelFile(this),
fout(new std::ofstream(name.c_str(),
std::ios::out|std::ios::binary|std::ios::trunc)),
- output(*fout) {}
+ output(*fout)
+ {
+ for(uint32_t i = 0; i < number_of_file_structures; ++i)
+ {
+ fileStructures[i] = new PRCFileStructure(this,i);
+ fileStructures[i]->header.minimal_version_for_read = PRCVersion;
+ fileStructures[i]->header.authoring_version = PRCVersion;
+ makeFileUUID(fileStructures[i]->header.fileStructureUUID);
+ makeAppUUID(fileStructures[i]->header.applicationUUID);
+ fileStructures[i]->tree.unit = unit;
+ }
+ modelFile.unit = unit;
+ }
~oPRCFile()
{
@@ -380,23 +443,120 @@ class oPRCFile
delete fout;
}
- void begingroup(std::string name) {}
- void endgroup() {}
+ void begingroup(const char *name, PRCoptions *options=NULL,
+ const double t[][4]=NULL);
+ void endgroup();
- bool add(PRCentity*);
bool finish();
- uint32_t getColourIndex(const RGBAColour&);
- uint32_t getMaterialIndex(const PRCMaterial&);
uint32_t getSize();
const uint32_t number_of_file_structures;
PRCFileStructure **fileStructures;
PRCHeader header;
PRCModelFile modelFile;
- std::vector<PRCentity*> fileEntities;
- std::vector<RGBAColour> colourMap;
- std::vector<PRCMaterial> materialMap;
-
+ PRCcolorMap colorMap;
+ PRCcolourMap colourMap;
+ PRCmaterialMap materialMap;
+ PRCgroup rootGroup;
+ PRCtransformMap transformMap;
+ std::stack<PRCgroupList::iterator> currentGroups;
+ PRCgroup& findGroup();
+ void doGroup(const PRCgroup& group, PRCPartDefinition *parent_part_definition, PRCProductOccurrence *parent_product_occurrence);
+ uint32_t addColor(const PRCRgbColor &color);
+ uint32_t addColour(const RGBAColour &colour);
+ uint32_t addMaterial(const PRCmaterial &material);
+ uint32_t addTransform(const PRCpGeneralTransformation3d &transform);
+ void addPoint(const double P[3], const RGBAColour &c);
+ void addLine(uint32_t n, const double P[][3], const RGBAColour &c);
+ void addBezierCurve(uint32_t n, const double cP[][3], const RGBAColour &c);
+ void addCurve(uint32_t d, uint32_t n, const double cP[][3], const double *k, const RGBAColour &c, const double w[]);
+ void addRectangle(const double P[][3], const PRCmaterial &m);
+ void addPatch(const double cP[][3], const PRCmaterial &m);
+ 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 addTorus(double major_radius, double minor_radius, double angle1, double angle2, const PRCmaterial &m, PRCFACETRANSFORM);
+#undef PRCFACETRANSFORM
+
+
+ uint32_t addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *picture, uint32_t width=0, uint32_t height=0,
+ std::string name="", uint32_t fileStructure=0)
+ { return fileStructures[fileStructure]->addPicture(format, size, picture, width, height, name); }
+ uint32_t addTextureDefinition(PRCTextureDefinition *pTextureDefinition, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addTextureDefinition(pTextureDefinition);
+ }
+ uint32_t addTextureApplication(PRCTextureApplication *pTextureApplication, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addTextureApplication(pTextureApplication);
+ }
+ uint32_t addRgbColor(const PRCRgbColor &color,
+ uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addRgbColor(color);
+ }
+ uint32_t addRgbColorUnique(const PRCRgbColor &color,
+ uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addRgbColorUnique(color);
+ }
+ uint32_t addMaterialGeneric(PRCMaterialGeneric *pMaterialGeneric,
+ uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addMaterialGeneric(pMaterialGeneric);
+ }
+ uint32_t addStyle(PRCStyle *pStyle, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addStyle(pStyle);
+ }
+ uint32_t addPartDefinition(PRCPartDefinition *pPartDefinition, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addPartDefinition(pPartDefinition);
+ }
+ uint32_t addProductOccurrence(PRCProductOccurrence *pProductOccurrence, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addProductOccurrence(pProductOccurrence);
+ }
+ uint32_t addTopoContext(PRCTopoContext *pTopoContext, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addTopoContext(pTopoContext);
+ }
+ uint32_t add3DTess(PRC3DTess *p3DTess, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->add3DTess(p3DTess);
+ }
+ uint32_t add3DWireTess(PRC3DWireTess *p3DWireTess, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->add3DWireTess(p3DWireTess);
+ }
+/*
+ uint32_t addMarkupTess(PRCMarkupTess *pMarkupTess, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addMarkupTess(pMarkupTess);
+ }
+ uint32_t addMarkup(PRCMarkup *pMarkup, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addMarkup(pMarkup);
+ }
+ uint32_t addAnnotationItem(PRCAnnotationItem *pAnnotationItem, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addAnnotationItem(pAnnotationItem);
+ }
+ */
+ uint32_t addCoordinateSystem(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addCoordinateSystem(pCoordinateSystem);
+ }
+ uint32_t addCoordinateSystemUnique(PRCCoordinateSystem *pCoordinateSystem, uint32_t fileStructure=0)
+ {
+ return fileStructures[fileStructure]->addCoordinateSystemUnique(pCoordinateSystem);
+ }
private:
std::ofstream *fout;
std::ostream &output;
diff --git a/Build/source/utils/asymptote/prc/test.asy b/Build/source/utils/asymptote/prc/test.asy
new file mode 100644
index 00000000000..21463f2eefa
--- /dev/null
+++ b/Build/source/utils/asymptote/prc/test.asy
@@ -0,0 +1,5 @@
+settings.outformat="pdf";
+
+import embed;
+
+label(embed("test.prc","poster,3Droo=25",1500,500));
diff --git a/Build/source/utils/asymptote/prc/test.cc b/Build/source/utils/asymptote/prc/test.cc
index e450f3acd01..4b0cadfc8a8 100644
--- a/Build/source/utils/asymptote/prc/test.cc
+++ b/Build/source/utils/asymptote/prc/test.cc
@@ -22,16 +22,52 @@
#include <iomanip>
#include <fstream>
#include <cmath>
+#include <string>
#include "oPRCFile.h"
using namespace std;
int main()
{
-// ofstream outf("test.prc",ios::binary);
+ oPRCFile file("test.prc");
+
+ const size_t N_COLOURS = 32;
+ RGBAColour colours[N_COLOURS];
+ for(size_t i = 0; i < N_COLOURS; ++i)
+ {
+ colours[i%N_COLOURS].R = 0.0;
+ colours[i%N_COLOURS].G = (i%N_COLOURS)/static_cast<double>(N_COLOURS);
+ colours[i%N_COLOURS].B = 0.95;
+ colours[i%N_COLOURS].A = 0.75;
+ }
+
+ PRCmaterial materials[N_COLOURS];
+ for(size_t i = 0; i < N_COLOURS; ++i)
+ {
+ materials[i%N_COLOURS].diffuse.R = 0.0;
+ materials[i%N_COLOURS].diffuse.G = (i%N_COLOURS)/static_cast<double>(N_COLOURS);
+ materials[i%N_COLOURS].diffuse.B = 0.95;
+ materials[i%N_COLOURS].diffuse.A = 0.75;
+ materials[i%N_COLOURS].specular.R = 0.01*0.0;
+ materials[i%N_COLOURS].specular.G = 0.01*(i%N_COLOURS)/static_cast<double>(N_COLOURS);
+ materials[i%N_COLOURS].specular.B = 0.01*0.95;
+ materials[i%N_COLOURS].specular.A = 0.01*0.75;
+ materials[i%N_COLOURS].emissive.R = 0.20*0.0;
+ materials[i%N_COLOURS].emissive.G = 0.20*(i%N_COLOURS)/static_cast<double>(N_COLOURS);
+ materials[i%N_COLOURS].emissive.B = 0.20*0.95;
+ materials[i%N_COLOURS].emissive.A = 0.20*0.75;
+ materials[i%N_COLOURS].ambient.R = 0.05*0.0;
+ materials[i%N_COLOURS].ambient.G = 0.05*(i%N_COLOURS)/static_cast<double>(N_COLOURS);
+ materials[i%N_COLOURS].ambient.B = 0.05*0.95;
+ materials[i%N_COLOURS].ambient.A = 0.05*0.75;
+ materials[i%N_COLOURS].alpha = 0.75;
+ materials[i%N_COLOURS].shininess = 0.1;
+ }
+
+ if(1) {
double knotsU[] = {1,1,1,1,2,2,2,2};
double knotsV[] = {1,1,1,1,2,2,2,2};
- const int NUMBER_OF_PATCHES = 32;
+ const size_t NUMBER_OF_PATCHES = 32;
double controlPoints[NUMBER_OF_PATCHES][16][3] =
{
{ // Patch 0
@@ -227,51 +263,500 @@ int main()
{0,-1.5,0.15},{0.84,-1.5,0.15},{1.5,-0.84,0.15},{1.5,0,0.15},
},
};
- oPRCFile file("test.prc");
- PRCsurface *psn[NUMBER_OF_PATCHES];
- const int N_COLOURS = 32;
- RGBAColour colours[N_COLOURS];
- for(int i = 0; i < N_COLOURS; ++i)
- {
- colours[i%N_COLOURS].R = 0.0;
- colours[i%N_COLOURS].G = (i%N_COLOURS)/static_cast<double>(N_COLOURS);
- colours[i%N_COLOURS].B = 0.95;
- colours[i%N_COLOURS].A = 0.75;
+ const size_t NUMBER_OF_TEAPOTS = 2;
+ double shifted_controlPoints[NUMBER_OF_TEAPOTS][NUMBER_OF_PATCHES][16][3];
+ for(size_t teapot = 0; teapot < NUMBER_OF_TEAPOTS; ++teapot)
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ for(size_t i = 0; i < 16; ++i)
+ {
+ shifted_controlPoints[teapot][patch][i][0] = controlPoints[patch][i][0]+6*teapot;
+ shifted_controlPoints[teapot][patch][i][1] = controlPoints[patch][i][1];
+ shifted_controlPoints[teapot][patch][i][2] = controlPoints[patch][i][2];
+ }
+ for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i)
+ {
+ // was so in old API
+ // psn[i] = new PRCsurface(&file,3,3,4,4,controlPoints[i],knotsU,knotsV,colours[i%N_COLOURS]);
+ // file.add(psn[i]);
+ file.begingroup("Teapot");
+ if (1) file.addPatch(controlPoints[i],materials[i%N_COLOURS]);
+ file.endgroup();
+ if (0) file.addSurface(3,3,4,4,controlPoints[i],knotsU,knotsV,materials[i%N_COLOURS],NULL); // use (too) general API for the same result as above
+ }
+// file.begingroup("Teapot rendered in the way of opaque surfacesPRCNOBREAKPRCCOMPRESSLOW");
+// for(size_t i = 0; i < NUMBER_OF_PATCHES; ++i)
+// {
+// file.addPatch(shifted_controlPoints[1][i],materials[i%N_COLOURS]); // force joining together of patches, damaging transparency
+// }
+// file.endgroup();
}
- for(int i = 0; i < NUMBER_OF_PATCHES; ++i)
- {
- psn[i] = new PRCsurface(&file,3,3,4,4,controlPoints[i],knotsU,knotsV,colours[i%N_COLOURS]);
- file.add(psn[i]);
- }
-
- const int NUMBER_OF_POINTS = 31;
+
+if(1) {
+ const size_t NUMBER_OF_POINTS = 31;
double points[NUMBER_OF_POINTS][3];
- for(int i = 0; i < NUMBER_OF_POINTS; ++i)
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
{
points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0;
}
+ const size_t NUMBER_OF_WIRES = 2;
+ double shifted_points[NUMBER_OF_WIRES][NUMBER_OF_POINTS][3];
+ for(size_t wire = 0; wire < NUMBER_OF_WIRES; ++wire)
+ for(size_t point = 0; point < NUMBER_OF_POINTS; ++point)
+ {
+ shifted_points[wire][point][0] = points[point][0];
+ shifted_points[wire][point][1] = points[point][1];
+ shifted_points[wire][point][2] = points[point][2]+0.1*wire+0.1;
+ }
double knots[3+NUMBER_OF_POINTS+1];
knots[0] = 1;
- for(int i = 1; i < 3+NUMBER_OF_POINTS; ++i)
+ for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i)
{
knots[i] = (i+2)/3; // integer division is intentional
}
knots[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3;
- RGBAColour white(1.0,1.0,1.0);
- PRCcurve pc(&file,3,NUMBER_OF_POINTS,points,knots,white);
- file.add(&pc);
+ double point[3] = {11,0,0};
+ file.begingroup("point");
+ file.addPoint(point, RGBAColour(1.0,0.0,0.0));
+ file.endgroup();
+
+// RGBAColour red(1.0,0.0,0.0);
+// PRCline pl(&file,NUMBER_OF_POINTS,points,red);
+// file.add(&pl);
+ file.begingroup("polyline");
+ file.addLine(NUMBER_OF_POINTS, points, RGBAColour(1.0,0.0,0.0));
+ file.endgroup();
+
+ file.begingroup("polylines");
+ file.addLine(NUMBER_OF_POINTS, shifted_points[0], RGBAColour(0.0,1.0,0.0));
+ file.addLine(NUMBER_OF_POINTS, shifted_points[1], RGBAColour(1.0,1.0,0.0));
+ file.endgroup();
+
+// RGBAColour white(1.0,1.0,1.0);
+// PRCcurve pc(&file,3,NUMBER_OF_POINTS,points,knots,white);
+// file.add(&pc);
+ if(1)
+ {
+ file.begingroup("bezier_wire");
+ file.addBezierCurve(NUMBER_OF_POINTS,points,RGBAColour(1.0,1.0,1.0));
+ file.endgroup();
+ }
+ if(0)
+ {
+ file.begingroup("NURBS_wire");
+ file.addCurve(3, NUMBER_OF_POINTS, points, knots, RGBAColour(1.0,1.0,1.0), NULL); // genarl API for the above
+ file.endgroup();
+ }
+
+ }
+
+// following box examples show a) different ways to represent a surface consisting of flat rectangles
+// b) that the only way to have almost working transparency is a set of NURBS bodies.
+// (Or may be other topology types like plane also work
+// demonstration how non-transparent materials work the same for all kinds of objects
+
+ if (1) { // demonstration how non-transparent materials work the same for all kinds of objects
+ const size_t NUMBER_OF_PATCHES = 6;
+ double vertices[NUMBER_OF_PATCHES][4][3] =
+ {
+ { // Patch 0
+ {-1,-1,-1},
+ { 1,-1,-1},
+ {-1, 1,-1},
+ { 1, 1,-1}
+ },
+ { // Patch 1
+ {-1,-1, 1},
+ { 1,-1, 1},
+ {-1, 1, 1},
+ { 1, 1, 1}
+ },
+ { // Patch 2
+ {-1,-1,-1},
+ { 1,-1,-1},
+ {-1,-1, 1},
+ { 1,-1, 1}
+ },
+ { // Patch 3
+ {-1, 1,-1},
+ { 1, 1,-1},
+ {-1, 1, 1},
+ { 1, 1, 1}
+ },
+ { // Patch 4
+ {-1,-1,-1},
+ {-1, 1,-1},
+ {-1,-1, 1},
+ {-1, 1, 1}
+ },
+ { // Patch 5
+ { 1,-1,-1},
+ { 1, 1,-1},
+ { 1,-1, 1},
+ { 1, 1, 1}
+ }
+ };
+ const size_t NUMBER_OF_BOXES = 6;
+ double shifted_vertices[NUMBER_OF_BOXES][NUMBER_OF_PATCHES][4][3];
+ for(size_t box = 0; box < NUMBER_OF_BOXES; ++box)
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ for(size_t i = 0; i < 4; ++i)
+ {
+ shifted_vertices[box][patch][i][0] = vertices[patch][i][0]+3*box;
+ shifted_vertices[box][patch][i][1] = vertices[patch][i][1];
+ shifted_vertices[box][patch][i][2] = vertices[patch][i][2]-2;
+ }
+ PRCmaterial materialGreen(
+ RGBAColour(0.0,0.18,0.0),
+ RGBAColour(0.0,0.878431,0.0),
+ RGBAColour(0.0,0.32,0.0),
+ RGBAColour(0.0,0.072,0.0),
+ 1.0,0.1);
+
+ file.begingroup("TransparentBox");
+ file.begingroup("SetOfNURBSBodies");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[0][patch], materials[(patch*5)%N_COLOURS]);
+ }
+ file.endgroup();
+ file.begingroup("NURBSFacesPRCNOBREAK");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[1][patch], materials[(patch*5)%N_COLOURS]);
+ }
+ file.endgroup();
+ file.begingroup("TessellatedPRCTESS");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[2][patch], materials[(patch*5)%N_COLOURS]);
+ }
+ file.endgroup();
+ file.endgroup();
+
+ file.begingroup("Box");
+ file.begingroup("TessellatedPRCTESS");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[3][patch], materialGreen);
+ }
+ file.endgroup();
+ file.begingroup("NURBSFaces");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[4][patch], materialGreen);
+ }
+ file.endgroup();
+ file.begingroup("SetOfNURBSBodiesPRCDOBREAK");
+ for(size_t patch = 0; patch < NUMBER_OF_PATCHES; ++patch)
+ {
+ file.addRectangle(shifted_vertices[5][patch], materialGreen);
+ }
+ file.endgroup();
+ file.endgroup();
+ }
+
+ if(0) { // test disk
+ PRCTopoContext *diskContext = new PRCTopoContext;
+ uint32_t context_index = file.addTopoContext(diskContext);
+
+ PRCBrepData *body = new PRCBrepData;
+ uint32_t body_index = diskContext->addBrepData(body);
+ PRCConnex *connex = new PRCConnex;
+ body->addConnex(connex);
+ PRCShell *shell = new PRCShell;
+ // shell->shell_is_closed = true;
+ connex->addShell(shell);
+ PRCFace *face = new PRCFace;
+ shell->addFace(face,2);
+ PRCRuled *surface = new PRCRuled;
+ face->setSurface(surface);
+
+ PRCCircle *first_curve = new PRCCircle;
+ first_curve->radius = 1;
+ surface->setFirstCurve(first_curve);
+ PRCCircle *second_curve = new PRCCircle;
+ second_curve->radius = 0;
+ surface->setSecondCurve(second_curve);
+
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 1;
+ surface->uv_domain.min.y = 0;
+ surface->uv_domain.max.y = 2*M_PI;
+ surface->parameterization_on_v_coeff_a = -1;
+ surface->parameterization_on_v_coeff_b = 2*M_PI;
+
+ surface->has_transformation = true;
+ surface->geometry_is_2D = false;
+ surface->behaviour = PRC_TRANSFORMATION_Translate|PRC_TRANSFORMATION_Rotate;
+ surface->origin.Set(0,0,0);
+ surface->x_axis.Set(1,0,0);
+ surface->y_axis.Set(0,1,0);
+
+ PRCBrepModel *brepmodel = new PRCBrepModel("disk");
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = true; // we do not need to see the tube from inside
+ brepmodel->index_of_line_style = 0;
+// file.addBrepModel(brepmodel);
+
+ PRCSingleWireBody *firstCurveBody = new PRCSingleWireBody;
+ uint32_t first_curve_body_index = diskContext->addSingleWireBody(firstCurveBody);
+ PRCWireEdge *firstCurveEdge = new PRCWireEdge;
+ firstCurveBody->setWireEdge(firstCurveEdge);
+ firstCurveEdge->curve_3d = surface->first_curve;
+ PRCWire *firstCurveWire = new PRCWire("firstCurveWire");
+ firstCurveWire->index_of_line_style = 0;
+ firstCurveWire->context_id = context_index;
+ firstCurveWire->body_id = first_curve_body_index;
+// file.addWire(firstCurveWire);
+ }
+
+ if(1) {
+ PRCmaterial materialGreen(
+ RGBAColour(0.0,0.18,0.0),
+ RGBAColour(0.0,0.878431,0.0),
+ RGBAColour(0.0,0.32,0.0),
+ RGBAColour(0.0,0.072,0.0),
+ 1.0,0.1);
+
+ const double disk_origin[3] = {11,0,2};
+ const double disk_x_axis[3] = {1,0,0};
+ const double disk_y_axis[3] = {0,-1,0};
+ const double disk_scale = 2;
+ file.begingroup("diskPRCCLOSED");
+ file.addDisk(1,materialGreen,disk_origin,disk_x_axis,disk_y_axis,disk_scale);
+ file.endgroup();
+ const double hs_origin[3] = {11,0,2};
+ const double hs_x_axis[3] = {1,0,0};
+ const double hs_y_axis[3] = {0,1,0};
+ const double hs_scale = 2;
+ file.begingroup("hemispherePRCCLOSED");
+ file.addHemisphere(1,materialGreen,hs_origin,hs_x_axis,hs_y_axis,hs_scale);
+ file.endgroup();
+ const double cyl_origin[3] = {11,0,1};
+ const double cyl_x_axis[3] = {1,0,0};
+ const double cyl_y_axis[3] = {0,1,0};
+ const double cyl_scale = 1;
+ file.begingroup("cylinderPRCCLOSED");
+ file.addCylinder(1,1,materialGreen,cyl_origin,cyl_x_axis,cyl_y_axis,cyl_scale);
+ file.endgroup();
+ const double sp_origin[3] = {11,0,1};
+ const double sp_x_axis[3] = {1,0,0};
+ const double sp_y_axis[3] = {0,1,0};
+ const double sp_scale = 1;
+ file.begingroup("spherePRCCLOSED");
+ file.addSphere(0.5,materialGreen,sp_origin,sp_x_axis,sp_y_axis,sp_scale);
+ file.endgroup();
+ const double tor_origin[3] = {11,0,0};
+ const double tor_x_axis[3] = {1,0,0};
+ const double tor_y_axis[3] = {0,1,0};
+ const double tor_scale = 1;
+ file.begingroup("torusPRCCLOSED");
+ file.addTorus(0.5,0.1,0,360,materialGreen,tor_origin,tor_x_axis,tor_y_axis,tor_scale);
+ file.endgroup();
+ }
+
+ if(0) { // Blend01 tube around a Composite curve - no good at corners
+ const size_t NUMBER_OF_POINTS = 4;
+ double points[NUMBER_OF_POINTS][3];
+ points[0][0] = 1; points[0][1] = 0; points[0][2] = 0;
+ points[1][0] = 1; points[1][1] = 0.552284749830793; points[1][2] = 0;
+ points[2][0] = 0.552284749830793; points[2][1] = 1; points[2][2] = 0;
+ points[3][0] = 0; points[3][1] = 1; points[3][2] = 0;
+ double qoints[NUMBER_OF_POINTS][3];
+ qoints[0][0] = 0; qoints[0][1] = 1; qoints[0][2] = 0;
+ qoints[1][0] = 0; qoints[1][1] = 1; qoints[1][2] = 0.552284749830793;
+ qoints[2][0] = 0; qoints[2][1] = 0.552284749830793; qoints[2][2] = 1;
+ qoints[3][0] = 0; qoints[3][1] = 0; qoints[3][2] = 1;
+// for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+// {
+// points[i][0] = 3.5*cos(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
+// points[i][1] = 3.5*sin(3.0*i/NUMBER_OF_POINTS*2.0*M_PI);
+// points[i][2] = 5.0*i/NUMBER_OF_POINTS-1.0;
+// }
+
+ double knots[3+NUMBER_OF_POINTS+1];
+ knots[0] = 1;
+ for(size_t i = 1; i < 3+NUMBER_OF_POINTS; ++i)
+ {
+ knots[i] = (i+2)/3; // integer division is intentional
+ }
+ knots[3+NUMBER_OF_POINTS] = (3+NUMBER_OF_POINTS+1)/3;
+
+ PRCTopoContext *tubeContext = new PRCTopoContext;
+ uint32_t context_index = file.addTopoContext(tubeContext);
+
+ PRCBrepData *body = new PRCBrepData;
+ uint32_t body_index = tubeContext->addBrepData(body);
+ PRCConnex *connex = new PRCConnex;
+ body->addConnex(connex);
+ PRCShell *shell = new PRCShell;
+ connex->addShell(shell);
+ PRCFace *face = new PRCFace;
+ shell->addFace(face);
+ PRCBlend01 *surface = new PRCBlend01;
+ face->setSurface(surface);
+
+ PRCNURBSCurve *center_curve = new PRCNURBSCurve;
+ center_curve->is_rational = false;
+ center_curve->degree = 3;
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+ center_curve->control_point.push_back(PRCControlPoint(points[i][0]+0.0,points[i][1],points[i][2]));
+ for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
+ center_curve->knot.push_back(knots[i]);
+ surface->setCenterCurve(center_curve);
+
+ PRCNURBSCurve *origin_curve = new PRCNURBSCurve;
+ origin_curve->is_rational = false;
+ origin_curve->degree = 3;
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+ origin_curve->control_point.push_back(PRCControlPoint(points[i][0]*1.01+0.0,points[i][1]*1.01,points[i][2]));
+ for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
+ origin_curve->knot.push_back(knots[i]);
+ surface->setOriginCurve(origin_curve);
+
+ surface->uv_domain.min.x = 0;
+ surface->uv_domain.max.x = 2*M_PI;
+ surface->uv_domain.min.y = 1; // first knot
+ surface->uv_domain.max.y = 2; // last knot
+ PRCBrepModel *brepmodel = new PRCBrepModel("Tube");
+ brepmodel->context_id = context_index;
+ brepmodel->body_id = body_index;
+ brepmodel->is_closed = true; // we do not need to see the tube from inside
+ brepmodel->index_of_line_style = 0;
+// file.addBrepModel(brepmodel);
+
+ PRCSingleWireBody *originCurveBody = new PRCSingleWireBody;
+ uint32_t origin_curve_body_index = tubeContext->addSingleWireBody(originCurveBody);
+ PRCWireEdge *originCurveEdge = new PRCWireEdge;
+ originCurveBody->setWireEdge(originCurveEdge);
+ originCurveEdge->curve_3d = surface->origin_curve;
+ PRCWire *originCurveWire = new PRCWire("originCurveWire");
+ originCurveWire->index_of_line_style = 0;
+ originCurveWire->context_id = context_index;
+ originCurveWire->body_id = origin_curve_body_index;
+// file.addWire(originCurveWire);
+
+ PRCSingleWireBody *centerCurveBody = new PRCSingleWireBody;
+ uint32_t center_curve_body_index = tubeContext->addSingleWireBody(centerCurveBody);
+ PRCWireEdge *centerCurveEdge = new PRCWireEdge;
+ centerCurveBody->setWireEdge(centerCurveEdge);
+ centerCurveEdge->curve_3d = surface->center_curve;
+ PRCWire *centerCurveWire = new PRCWire("centerCurveWire");
+ centerCurveWire->index_of_line_style = 0;
+ centerCurveWire->context_id = context_index;
+ centerCurveWire->body_id = center_curve_body_index;
+// file.addWire(centerCurveWire);
+
+ PRCNURBSCurve *Center_curve = new PRCNURBSCurve;
+ Center_curve->is_rational = false;
+ Center_curve->degree = 3;
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+ Center_curve->control_point.push_back(PRCControlPoint(qoints[i][0],qoints[i][1],qoints[i][2]));
+ for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
+ Center_curve->knot.push_back(knots[i]);
+
+ PRCNURBSCurve *Origin_curve = new PRCNURBSCurve;
+ Origin_curve->is_rational = false;
+ Origin_curve->degree = 3;
+ for(size_t i = 0; i < NUMBER_OF_POINTS; ++i)
+ Origin_curve->control_point.push_back(PRCControlPoint(qoints[i][0],qoints[i][1]*1.01,qoints[i][2]*1.01));
+ for(size_t i = 0; i < 3+NUMBER_OF_POINTS+1; ++i)
+ Origin_curve->knot.push_back(knots[i]);
+
+ PRCSingleWireBody *OriginCurveBody = new PRCSingleWireBody;
+ uint32_t Origin_curve_body_index = tubeContext->addSingleWireBody(OriginCurveBody);
+ PRCWireEdge *OriginCurveEdge = new PRCWireEdge;
+ OriginCurveBody->setWireEdge(OriginCurveEdge);
+ OriginCurveEdge->setCurve(Origin_curve);
+ PRCWire *OriginCurveWire = new PRCWire("OriginCurveWire");
+ OriginCurveWire->index_of_line_style = 0;
+ OriginCurveWire->context_id = context_index;
+ OriginCurveWire->body_id = Origin_curve_body_index;
+// file.addWire(OriginCurveWire);
+
+ PRCSingleWireBody *CenterCurveBody = new PRCSingleWireBody;
+ uint32_t Center_curve_body_index = tubeContext->addSingleWireBody(CenterCurveBody);
+ PRCWireEdge *CenterCurveEdge = new PRCWireEdge;
+ CenterCurveBody->setWireEdge(CenterCurveEdge);
+ CenterCurveEdge->setCurve(Center_curve);
+ PRCWire *CenterCurveWire = new PRCWire("CenterCurveWire");
+ CenterCurveWire->index_of_line_style = 0;
+ CenterCurveWire->context_id = context_index;
+ CenterCurveWire->body_id = Center_curve_body_index;
+// file.addWire(CenterCurveWire);
+
+ PRCComposite *compositeCenter_curve = new PRCComposite;
+ compositeCenter_curve->base_curve.push_back(centerCurveEdge->curve_3d);
+ compositeCenter_curve->base_sense.push_back(true);
+ compositeCenter_curve->base_curve.push_back(CenterCurveEdge->curve_3d);
+ compositeCenter_curve->base_sense.push_back(true);
+ compositeCenter_curve->is_closed = false;
+ compositeCenter_curve->interval.min = 0;
+ compositeCenter_curve->interval.max = 2;
+
+ PRCSingleWireBody *compositeCenterCurveBody = new PRCSingleWireBody;
+ uint32_t compositeCenter_curve_body_index = tubeContext->addSingleWireBody(compositeCenterCurveBody);
+ PRCWireEdge *compositeCenterCurveEdge = new PRCWireEdge;
+ compositeCenterCurveBody->setWireEdge(compositeCenterCurveEdge);
+ compositeCenterCurveEdge->setCurve(compositeCenter_curve);
+ PRCWire *compositeCenterCurveWire = new PRCWire("compositeCenterCurveWire");
+ compositeCenterCurveWire->index_of_line_style = 0;
+ compositeCenterCurveWire->context_id = context_index;
+ compositeCenterCurveWire->body_id = compositeCenter_curve_body_index;
+// file.addWire(compositeCenterCurveWire);
+
+ PRCComposite *compositeOrigin_curve = new PRCComposite;
+ compositeOrigin_curve->base_curve.push_back(originCurveEdge->curve_3d);
+ compositeOrigin_curve->base_sense.push_back(true);
+ compositeOrigin_curve->base_curve.push_back(OriginCurveEdge->curve_3d);
+ compositeOrigin_curve->base_sense.push_back(true);
+ compositeOrigin_curve->is_closed = false;
+ compositeOrigin_curve->interval.min = 0;
+ compositeOrigin_curve->interval.max = 2;
- RGBAColour red(1.0,0.0,0.0);
- PRCline pl(&file,NUMBER_OF_POINTS,points,red);
- file.add(&pl);
+ PRCSingleWireBody *compositeOriginCurveBody = new PRCSingleWireBody;
+ uint32_t compositeOrigin_curve_body_index = tubeContext->addSingleWireBody(compositeOriginCurveBody);
+ PRCWireEdge *compositeOriginCurveEdge = new PRCWireEdge;
+ compositeOriginCurveBody->setWireEdge(compositeOriginCurveEdge);
+ compositeOriginCurveEdge->setCurve(compositeOrigin_curve);
+ PRCWire *compositeOriginCurveWire = new PRCWire("compositeOriginCurveWire");
+ compositeOriginCurveWire->index_of_line_style = 0;
+ compositeOriginCurveWire->context_id = context_index;
+ compositeOriginCurveWire->body_id = compositeOrigin_curve_body_index;
+// file.addWire(compositeOriginCurveWire);
+
+ PRCBrepData *cbody = new PRCBrepData;
+ uint32_t cbody_index = tubeContext->addBrepData(cbody);
+ PRCConnex *cconnex = new PRCConnex;
+ cbody->addConnex(cconnex);
+ PRCShell *cshell = new PRCShell;
+ cconnex->addShell(cshell);
+ PRCFace *cface = new PRCFace;
+ cshell->addFace(cface);
+ PRCBlend01 *csurface = new PRCBlend01;
+ cface->setSurface(csurface);
- file.finish();
+ csurface->uv_domain.min.x = 0;
+ csurface->uv_domain.max.x = 2*M_PI;
+ csurface->uv_domain.min.y = 0; // first knot
+ csurface->uv_domain.max.y = 2; // last knot
+ csurface->center_curve = compositeCenterCurveEdge->curve_3d;
+ csurface->origin_curve = compositeOriginCurveEdge->curve_3d;
+ PRCBrepModel *cbrepmodel = new PRCBrepModel("cTube");
+ cbrepmodel->context_id = context_index;
+ cbrepmodel->body_id = cbody_index;
+ cbrepmodel->is_closed = true; // we do not need to see the tube from inside
+ cbrepmodel->index_of_line_style = 0;
+// file.addBrepModel(cbrepmodel);
+
+
+ }
- for(int i = 0; i < NUMBER_OF_PATCHES; ++i)
- delete psn[i];
+ file.finish();
return 0;
}
diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc
index eb476dc7494..eb7141d3315 100644
--- a/Build/source/utils/asymptote/prc/writePRC.cc
+++ b/Build/source/utils/asymptote/prc/writePRC.cc
@@ -2,6 +2,7 @@
*
* This file is part of a tool for producing 3D content in the PRC format.
* Copyright (C) 2008 Orest Shardt <shardtor (at) gmail dot com>
+* with enhancements contributed by Michail Vidiassov.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -19,24 +20,43 @@
*************/
#include "writePRC.h"
+#include <climits>
+#include <cassert>
+
+// debug print includes
+#include <iostream>
+#include <iomanip>
+#include <fstream>
+#include <sstream>
+
+using namespace std;
+
+double PRCVector3d::Length()
+{
+ return sqrt(x*x+y*y+z*z);
+}
+
+bool PRCVector3d::Normalize()
+{
+ double fLength=Length();
+ if(fLength < FLT_EPSILON) return false;
+ double factor=1.0/fLength;
+ x *= factor;
+ y *= factor;
+ z *= factor;
+ return true;
+}
void UserData::write(PRCbitStream &pbs)
{
pbs << size;
- if(size > 0)
- {
- uint32_t i = 0;
- for(; i < size/8; ++i)
- {
+ if(size > 0) {
+ uint32_t quot=size/8;
+ uint32_t rem=size-8*quot;
+ for(uint32_t i = 0; i < quot; ++i)
pbs << data[i];
- }
- if(size % 8 != 0)
- {
- for(uint32_t j = 0; j < size%8; ++j) // 0-based, big endian bit counting
- {
- pbs << (bool)(data[i] & (0x80 >> j));
- }
- }
+ for(uint32_t j = 0; j < rem; ++j) // 0-based, big endian bit counting
+ pbs << (bool)(data[quot] & (0x80 >> j));
}
}
@@ -101,6 +121,226 @@ void ContentPRCBase::write(PRCbitStream &pbs)
}
}
+#define WriteUnsignedInteger( value ) pbs << (uint32_t)(value);
+#define WriteInteger( value ) pbs << (int32_t)(value);
+#define WriteCharacter( value ) pbs << (uint8_t)(value);
+#define WriteDouble( value ) pbs << (double)(value);
+#define WriteBit( value ) pbs << (bool)(value);
+#define WriteBoolean( value ) pbs << (bool)(value);
+#define WriteString( value ) pbs << (value);
+#define SerializeContentPRCBase write(pbs);
+#define SerializeGraphics serializeGraphics(pbs);
+#define SerializePRCBaseWithGraphics { write(pbs); serializeGraphics(pbs); }
+#define SerializeRepresentationItemContent serializeRepresentationItemContent(pbs);
+#define SerializeRepresentationItem( value ) (value)->serializeRepresentationItem(pbs);
+#define SerializeMarkup( value ) (value).serializeMarkup(pbs);
+#define SerializeReferenceUniqueIdentifier( value ) (value).serializeReferenceUniqueIdentifier(pbs);
+#define SerializeContentBaseTessData serializeContentBaseTessData(pbs);
+#define SerializeTessFace( value ) (value)->serializeTessFace(pbs);
+#define SerializeUserData UserData(0,0).write(pbs);
+#define SerializeLineAttr( value ) pbs << (uint32_t)((value)+1);
+#define SerializeVector3d( value ) (value).serializeVector3d(pbs);
+#define SerializeVector2d( value ) (value).serializeVector2d(pbs);
+#define SerializeName( value ) writeName(pbs, (value));
+#define SerializeInterval( value ) (value).serializeInterval(pbs);
+// #define SerializeBoundingBox( value ) (value).serializeBoundingBox(pbs);
+#define SerializeDomain( value ) (value).serializeDomain(pbs);
+#define SerializeParameterization serializeParameterization(pbs);
+#define SerializeUVParameterization serializeUVParameterization(pbs);
+#define SerializeTransformation serializeTransformation(pbs);
+#define SerializeAttributeData if(attributes) attributes->write(pbs); else WriteUnsignedInteger (0)
+#define SerializeBaseTopology serializeBaseTopology(pbs);
+#define SerializeBaseGeometry serializeBaseGeometry(pbs);
+#define SerializePtrCurve( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeCurve(pbs);}
+#define SerializePtrSurface( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeSurface(pbs);}
+#define SerializePtrTopology( value ) {WriteBoolean( false ); if((value)==NULL) pbs << (uint32_t)PRC_TYPE_ROOT; else (value)->serializeTopoItem(pbs);}
+#define SerializeContentCurve serializeContentCurve(pbs);
+#define SerializeContentWireEdge serializeContentWireEdge(pbs);
+#define SerializeContentBody serializeContentBody(pbs);
+#define SerializeTopoContext serializeTopoContext(pbs);
+#define SerializeContextAndBodies( value ) (value).serializeContextAndBodies(pbs);
+#define SerializeBody( value ) (value)->serializeBody(pbs);
+#define ResetCurrentGraphics resetGraphics();
+#define SerializeContentSurface serializeContentSurface(pbs);
+#define SerializeCompressedUniqueId( value ) (value).serializeCompressedUniqueId(pbs);
+#define SerializeUnit( value ) (value).serializeUnit(pbs);
+#define SerializeBoundingBox serializeBoundingBox(pbs);
+
+bool IsCompressedType(uint32_t type)
+{
+ return (type == PRC_TYPE_TOPO_BrepDataCompress || type == PRC_TYPE_TOPO_SingleWireBodyCompress || type == PRC_TYPE_TESS_3D_Compressed);
+}
+
+void PRCReferenceUniqueIdentifier::serializeReferenceUniqueIdentifier(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_MISC_ReferenceOnPRCBase)
+ WriteUnsignedInteger (type)
+ const bool reference_in_same_file_structure = true;
+ WriteBoolean (reference_in_same_file_structure)
+// if (!reference_in_same_file_structure)
+// SerializeCompressedUniqueId (target_file_structure)
+ WriteUnsignedInteger (unique_identifier)
+}
+
+void PRCRgbColor::serializeRgbColor(PRCbitStream &pbs)
+{
+ WriteDouble (red)
+ WriteDouble (green)
+ WriteDouble (blue)
+}
+
+void PRCPicture::serializePicture(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_Picture)
+ SerializeContentPRCBase
+ WriteInteger (format) //see Types for picture files
+ WriteUnsignedInteger (uncompressed_file_index+1)
+ WriteUnsignedInteger (pixel_width)
+ WriteUnsignedInteger (pixel_height)
+}
+
+void PRCTextureDefinition::serializeTextureDefinition(PRCbitStream &pbs)
+{
+ uint32_t i=0; // universal index for PRC standart compatibility
+ const uint8_t texture_dimension = 2;
+ const uint32_t texture_mapping_attributes = texture_mapping_attribute;
+ const uint32_t size_texture_mapping_attributes_intensities = 1;
+ const double *texture_mapping_attributes_intensities = &texture_mapping_attribute_intensity;
+ const uint32_t size_texture_mapping_attributes_components = 1;
+ const uint8_t *texture_mapping_attributes_components = &texture_mapping_attribute_components;
+ const EPRCTextureMappingType eMappingType = KEPRCTextureMappingType_Stored;
+
+ const double red = 1.0;
+ const double green = 1.0;
+ const double blue = 1.0;
+ const double alpha = 1.0;
+ const EPRCTextureBlendParameter blend_src_rgb = KEPRCTextureBlendParameter_Unknown;
+ const EPRCTextureBlendParameter blend_dst_rgb = KEPRCTextureBlendParameter_Unknown;
+ const EPRCTextureBlendParameter blend_src_alpha = KEPRCTextureBlendParameter_Unknown;
+ const EPRCTextureBlendParameter blend_dst_alpha = KEPRCTextureBlendParameter_Unknown;
+ const EPRCTextureAlphaTest alpha_test = KEPRCTextureAlphaTest_Unknown;
+ const double alpha_test_reference = 1.0;
+ const EPRCTextureWrappingMode texture_wrapping_mode_R = KEPRCTextureWrappingMode_ClampToBorder;
+ const bool texture_transformation = false;
+
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_TextureDefinition)
+
+ SerializeContentPRCBase
+
+ WriteUnsignedInteger (picture_index+1)
+ WriteCharacter (texture_dimension)
+
+ // SerializeTextureMappingType
+ WriteInteger (eMappingType) // Texture mapping type
+ // if (eMappingType == TEXTURE_MAPPING_OPERATOR)
+ // {
+ // WriteInteger (eMappingOperator) // Texture mapping operator
+ // WriteInteger (transformation)
+ // if (transformation)
+ // SerializeCartesianTransformation3d (transformation)
+ // }
+
+ WriteUnsignedInteger (texture_mapping_attributes) // Texture mapping attributes
+ WriteUnsignedInteger (size_texture_mapping_attributes_intensities)
+ for (i=0;i<size_texture_mapping_attributes_intensities;i++)
+ WriteDouble (texture_mapping_attributes_intensities[i])
+ WriteUnsignedInteger (size_texture_mapping_attributes_components)
+ for (i=0;i<size_texture_mapping_attributes_components;i++)
+ WriteCharacter (texture_mapping_attributes_components[i])
+
+ WriteInteger (texture_function)
+ // reserved for future use; see Texture function
+ if (texture_function == KEPRCTextureFunction_Blend)
+ {
+ WriteDouble (red) // blend color component in the range [0.0,1.0]
+ WriteDouble (green) // blend color component in the range [0.0,1.0]
+ WriteDouble (blue) // blend color component in the range [0.0,1.0]
+ WriteDouble (alpha) // blend color component in the range [0.0,1.0]
+ }
+
+ WriteInteger (blend_src_rgb) // Texture blend parameter
+ // reserved for future use; see Texture blend parameter
+ if (blend_src_rgb != KEPRCTextureBlendParameter_Unknown)
+ WriteInteger (blend_dst_rgb) // Texture blend parameter
+
+ WriteInteger (blend_src_alpha) // Texture blend parameter
+ // reserved for future use; see Texture blend parameter
+ if (blend_src_alpha != KEPRCTextureBlendParameter_Unknown)
+ WriteInteger (blend_dst_alpha) // Texture blend parameter
+
+ WriteCharacter (texture_applying_mode) // Texture applying mode
+ if (texture_applying_mode & PRC_TEXTURE_APPLYING_MODE_ALPHATEST)
+ {
+ WriteInteger (alpha_test) // Texture alpha test
+ WriteDouble (alpha_test_reference)
+ }
+
+ WriteInteger (texture_wrapping_mode_S) // Texture wrapping mode
+ if (texture_dimension > 1)
+ WriteInteger (texture_wrapping_mode_T) // Texture wrapping mode
+ if (texture_dimension > 2 )
+ WriteInteger (texture_wrapping_mode_R) // Texture wrapping mode
+
+ WriteBit (texture_transformation)
+// if (texture_transformation)
+// SerializeTextureTransformation (texture_transformation)
+}
+
+void PRCMaterialGeneric::serializeMaterialGeneric(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_Material)
+ SerializeContentPRCBase
+ WriteUnsignedInteger (ambient + 1)
+ WriteUnsignedInteger (diffuse + 1)
+ WriteUnsignedInteger (emissive + 1)
+ WriteUnsignedInteger (specular + 1)
+ WriteDouble (shininess)
+ WriteDouble (ambient_alpha)
+ WriteDouble (diffuse_alpha)
+ WriteDouble (emissive_alpha)
+ WriteDouble (specular_alpha)
+}
+
+void PRCTextureApplication::serializeTextureApplication(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_TextureApplication)
+ SerializeContentPRCBase
+
+ WriteUnsignedInteger (material_generic_index+1)
+ WriteUnsignedInteger (texture_definition_index+1)
+ WriteUnsignedInteger (next_texture_index+1)
+ WriteUnsignedInteger (UV_coordinates_index+1)
+}
+
+void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
+{
+ const bool is_additional_1_defined = (additional!=0);
+ const uint8_t additional_1 = additional;
+ const bool is_additional_2_defined = false;
+ const uint8_t additional_2 = 0;
+ const bool is_additional_3_defined = false;
+ const uint8_t additional_3 = 0;
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_Style)
+ SerializeContentPRCBase
+ WriteDouble (line_width)
+ WriteBoolean (is_vpicture)
+ WriteUnsignedInteger (line_pattern_vpicture_index + 1)
+ WriteBoolean (is_material)
+ WriteUnsignedInteger (color_material_index + 1)
+ WriteBoolean (is_transparency_defined)
+ if (is_transparency_defined)
+ WriteCharacter (transparency)
+ WriteBoolean (is_additional_1_defined)
+ if (is_additional_1_defined)
+ WriteCharacter (additional_1)
+ WriteBoolean (is_additional_2_defined)
+ if (is_additional_2_defined)
+ WriteCharacter (additional_2)
+ WriteBoolean (is_additional_3_defined)
+ if (is_additional_3_defined)
+ WriteCharacter (additional_3)
+}
+
AttributeTitle EMPTY_ATTRIBUTE_TITLE = {(char*)""};
Attribute EMPTY_ATTRIBUTE(false,EMPTY_ATTRIBUTE_TITLE,0,NULL);
Attributes EMPTY_ATTRIBUTES(0,0);
@@ -122,29 +362,75 @@ void resetName()
currentName = "";
}
-uint32_t layer_index = m1;
-uint32_t index_of_line_style = m1;
-uint32_t behaviour_bit_field = 1;
+uint32_t current_layer_index = m1;
+uint32_t current_index_of_line_style = m1;
+uint16_t current_behaviour_bit_field = 1;
void writeGraphics(PRCbitStream &pbs,uint32_t l,uint32_t i,uint32_t b,bool force)
{
- if(force || layer_index != l || index_of_line_style != i || behaviour_bit_field != b)
+ if(force || current_layer_index != l || current_index_of_line_style != i || current_behaviour_bit_field != b)
{
pbs << false << (uint32_t)(l+1) << (uint32_t)(i+1)
<< (uint8_t)(b&0xFF) << (uint8_t)((b>>8)&0xFF);
- layer_index = l;
- index_of_line_style = i;
- behaviour_bit_field = b;
+ current_layer_index = l;
+ current_index_of_line_style = i;
+ current_behaviour_bit_field = b;
}
else
pbs << true;
}
+void writeGraphics(PRCbitStream &pbs,const PRCGraphics &graphics,bool force)
+{
+ if(force || current_layer_index != graphics.layer_index || current_index_of_line_style != graphics.index_of_line_style || current_behaviour_bit_field != graphics.behaviour_bit_field)
+ {
+ pbs << false
+ << (uint32_t)(graphics.layer_index+1)
+ << (uint32_t)(graphics.index_of_line_style+1)
+ << (uint8_t)(graphics.behaviour_bit_field&0xFF)
+ << (uint8_t)((graphics.behaviour_bit_field>>8)&0xFF);
+ current_layer_index = graphics.layer_index;
+ current_index_of_line_style = graphics.index_of_line_style;
+ current_behaviour_bit_field = graphics.behaviour_bit_field;
+ }
+ else
+ pbs << true;
+}
+
+void PRCGraphics::serializeGraphics(PRCbitStream &pbs)
+{
+ if(current_layer_index != this->layer_index || current_index_of_line_style != this->index_of_line_style || current_behaviour_bit_field != this->behaviour_bit_field)
+ {
+ pbs << false
+ << (uint32_t)(this->layer_index+1)
+ << (uint32_t)(this->index_of_line_style+1)
+ << (uint8_t)(this->behaviour_bit_field&0xFF)
+ << (uint8_t)((this->behaviour_bit_field>>8)&0xFF);
+ current_layer_index = this->layer_index;
+ current_index_of_line_style = this->index_of_line_style;
+ current_behaviour_bit_field = this->behaviour_bit_field;
+ }
+ else
+ pbs << true;
+}
+
+void PRCGraphics::serializeGraphicsForced(PRCbitStream &pbs)
+{
+ pbs << false
+ << (uint32_t)(this->layer_index+1)
+ << (uint32_t)(this->index_of_line_style+1)
+ << (uint8_t)(this->behaviour_bit_field&0xFF)
+ << (uint8_t)((this->behaviour_bit_field>>8)&0xFF);
+ current_layer_index = this->layer_index;
+ current_index_of_line_style = this->index_of_line_style;
+ current_behaviour_bit_field = this->behaviour_bit_field;
+}
+
void resetGraphics()
{
- layer_index = m1;
- index_of_line_style = m1;
- behaviour_bit_field = 1;
+ current_layer_index = m1;
+ current_index_of_line_style = m1;
+ current_behaviour_bit_field = 1;
}
void resetGraphicsAndName()
@@ -152,6 +438,480 @@ void resetGraphicsAndName()
resetGraphics(); resetName();
}
+void PRCMarkup::serializeMarkup(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_MKP_Markup)
+ SerializeContentPRCBase
+ SerializeGraphics
+ WriteUnsignedInteger (type)
+ WriteUnsignedInteger (sub_type)
+ const uint32_t number_of_linked_items = 0;
+ WriteUnsignedInteger (number_of_linked_items)
+// for (i=0;i<number_of_linked_items;i++)
+// SerializeReferenceUniqueIdentifier (linked_items[i])
+ const uint32_t number_of_leaders = 0;
+ WriteUnsignedInteger (number_of_leaders)
+// for (i=0;i<number_of_leaders;i++)
+// SerializeReferenceUniqueIdentifier (leaders[i])
+ WriteUnsignedInteger (index_tessellation + 1)
+ SerializeUserData
+}
+
+void PRCAnnotationItem::serializeAnnotationItem(PRCbitStream &pbs)
+{
+// group___tf_annotation_item_____serialize2.html
+// group___tf_annotation_item_____serialize_content2.html
+// group___tf_annotation_entity_____serialize_content2.html
+ WriteUnsignedInteger (PRC_TYPE_MKP_AnnotationItem)
+ SerializeContentPRCBase
+ SerializeGraphics
+ SerializeReferenceUniqueIdentifier (markup)
+ SerializeUserData
+}
+
+void PRCRepresentationItemContent::serializeRepresentationItemContent(PRCbitStream &pbs)
+{
+ SerializeContentPRCBase
+ SerializeGraphics
+ WriteUnsignedInteger (index_local_coordinate_system + 1)
+ WriteUnsignedInteger (index_tessellation + 1)
+}
+
+void PRCBrepModel::serializeBrepModel(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_BrepModel)
+
+ SerializeRepresentationItemContent
+ WriteBit (has_brep_data)
+ if (has_brep_data)
+ {
+ WriteUnsignedInteger (context_id+1)
+ WriteUnsignedInteger (body_id+1)
+ }
+ WriteBoolean (is_closed)
+ SerializeUserData
+}
+
+void PRCPolyBrepModel::serializePolyBrepModel(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_PolyBrepModel)
+
+ SerializeRepresentationItemContent
+ WriteBoolean (is_closed)
+ SerializeUserData
+}
+
+void PRCPointSet::serializePointSet(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_PointSet)
+
+ SerializeRepresentationItemContent
+
+ const uint32_t number_of_points = point.size();
+ WriteUnsignedInteger (number_of_points)
+ for (uint32_t i=0;i<number_of_points;i++)
+ {
+ SerializeVector3d (point[i])
+ }
+ SerializeUserData
+}
+
+void PRCSet::serializeSet(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_Set)
+
+ SerializeRepresentationItemContent
+
+ const uint32_t number_of_elements = elements.size();
+ WriteUnsignedInteger (number_of_elements)
+ for (uint32_t i=0;i<number_of_elements;i++)
+ {
+ SerializeRepresentationItem (elements[i])
+ }
+ SerializeUserData
+}
+
+uint32_t PRCSet::addBrepModel(PRCBrepModel *pBrepModel)
+{
+ elements.push_back(PRCpRepresentationItem(pBrepModel));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel)
+{
+ elements.push_back(PRCpRepresentationItem(pPolyBrepModel));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addPointSet(PRCPointSet *pPointSet)
+{
+ elements.push_back(PRCpRepresentationItem(pPointSet));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addSet(PRCSet *pSet)
+{
+ elements.push_back(PRCpRepresentationItem(pSet));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addWire(PRCWire *pWire)
+{
+ elements.push_back(PRCpRepresentationItem(pWire));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addPolyWire(PRCPolyWire *pPolyWire)
+{
+ elements.push_back(PRCpRepresentationItem(pPolyWire));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addRepresentationItem(PRCRepresentationItem *pRepresentationItem)
+{
+ elements.push_back(PRCpRepresentationItem(pRepresentationItem));
+ return elements.size()-1;
+}
+
+uint32_t PRCSet::addRepresentationItem(PRCpRepresentationItem pRepresentationItem)
+{
+ elements.push_back(pRepresentationItem);
+ return elements.size()-1;
+}
+
+void PRCWire::serializeWire(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_Curve)
+
+ SerializeRepresentationItemContent
+ WriteBit (has_wire_body)
+ if (has_wire_body)
+ {
+ WriteUnsignedInteger (context_id+1)
+ WriteUnsignedInteger (body_id+1)
+ }
+
+ SerializeUserData
+}
+
+void PRCPolyWire::serializePolyWire(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_PolyWire)
+
+ SerializeRepresentationItemContent
+ SerializeUserData
+}
+
+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]);
+}
+
+void PRCCartesianTransformation3d::serializeCartesianTransformation3d(PRCbitStream &pbs) const
+{
+ WriteUnsignedInteger (PRC_TYPE_MISC_CartesianTransformation)
+ WriteCharacter ( behaviour )
+ if (behaviour & PRC_TRANSFORMATION_Translate)
+ SerializeVector3d ( origin )
+ if (behaviour & PRC_TRANSFORMATION_NonOrtho)
+ {
+ SerializeVector3d ( X )
+ SerializeVector3d ( Y )
+ SerializeVector3d ( Z )
+ }
+ else if (behaviour & PRC_TRANSFORMATION_Rotate)
+ {
+ SerializeVector3d ( X )
+ SerializeVector3d ( Y )
+ }
+
+ if (behaviour & PRC_TRANSFORMATION_NonUniformScale)
+ {
+ SerializeVector3d ( scale )
+ }
+ else if (behaviour & PRC_TRANSFORMATION_Scale)
+ {
+ WriteDouble ( uniform_scale )
+ }
+
+ if (behaviour & PRC_TRANSFORMATION_Homogeneous)
+ {
+ WriteDouble ( X_homogeneous_coord )
+ WriteDouble ( Y_homogeneous_coord )
+ WriteDouble ( Z_homogeneous_coord )
+ WriteDouble ( origin_homogeneous_coord )
+ }
+}
+
+void PRCTransformation::serializeTransformation(PRCbitStream &pbs)
+{
+ WriteBit ( has_transformation )
+ if (has_transformation)
+ {
+ WriteCharacter ( behaviour )
+ if ( geometry_is_2D )
+ {
+ if (behaviour & PRC_TRANSFORMATION_Translate)
+ SerializeVector2d ( origin )
+ if (behaviour & PRC_TRANSFORMATION_Rotate)
+ {
+ SerializeVector2d ( x_axis )
+ SerializeVector2d ( y_axis )
+ }
+ if (behaviour & PRC_TRANSFORMATION_Scale)
+ WriteDouble ( scale )
+ }
+ else
+ {
+ if (behaviour & PRC_TRANSFORMATION_Translate)
+ SerializeVector3d ( origin )
+ if (behaviour & PRC_TRANSFORMATION_Rotate)
+ {
+ SerializeVector3d ( x_axis )
+ SerializeVector3d ( y_axis )
+ }
+ if (behaviour & PRC_TRANSFORMATION_Scale)
+ WriteDouble ( scale )
+ }
+ }
+}
+void PRCCoordinateSystem::serializeCoordinateSystem(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_RI_CoordinateSystem)
+
+ SerializeRepresentationItemContent
+ axis_set->serializeTransformation3d(pbs);
+ SerializeUserData
+}
+
+void PRCFontKeysSameFont::serializeFontKeysSameFont(PRCbitStream &pbs)
+{
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteString (font_name)
+ WriteUnsignedInteger (char_set)
+ const uint32_t number_of_font_keys = font_keys.size();
+ WriteUnsignedInteger (number_of_font_keys)
+ for (i=0;i<number_of_font_keys;i++)
+ {
+ WriteUnsignedInteger (font_keys[i].font_size + 1)
+ WriteCharacter (font_keys[i].attributes)
+ }
+}
+
+void SerializeArrayRGBA (const std::vector<uint8_t> &rgba_vertices,const bool is_rgba, PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ uint32_t j = 0;
+// number_by_vector can be assigned a value of 3 (RGB) or 4 (RGBA).
+// number_of_vectors is equal to number_of_colors / number_by_vector.
+ const uint32_t number_by_vector=is_rgba?4:3;
+ const std::vector<uint8_t> &vector_color = rgba_vertices;
+ const uint32_t number_of_colors=vector_color.size();
+ const uint32_t number_of_vectors=number_of_colors / number_by_vector;
+ // first one
+ for (i=0;i<number_by_vector;i++)
+ WriteCharacter (vector_color[i])
+
+ for (i=1;i<number_of_vectors;i++)
+ {
+ bool b_same = true;
+ for (j=0;j<number_by_vector;j++)
+ {
+ if ((vector_color[i*number_by_vector+j] - vector_color[(i-1)*number_by_vector+j]) != 0)
+ {
+ b_same = false;
+ break;
+ }
+ }
+ WriteBoolean (b_same)
+ if (!b_same)
+ {
+ for (j=0;j<number_by_vector;j++)
+ WriteCharacter (vector_color[i*number_by_vector+j])
+ }
+ }
+}
+
+void PRCTessFace::serializeTessFace(PRCbitStream &pbs)
+{
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteUnsignedInteger (PRC_TYPE_TESS_Face)
+
+ const uint32_t size_of_line_attributes=line_attributes.size();
+ WriteUnsignedInteger (size_of_line_attributes)
+ for (i=0;i<size_of_line_attributes;i++)
+ SerializeLineAttr (line_attributes[i])
+
+ WriteUnsignedInteger (start_wire)
+ const uint32_t size_of_sizes_wire=sizes_wire.size();
+ WriteUnsignedInteger (size_of_sizes_wire)
+ for (i=0;i<size_of_sizes_wire;i++)
+ WriteUnsignedInteger (sizes_wire[i])
+
+ WriteUnsignedInteger (used_entities_flag)
+
+ WriteUnsignedInteger (start_triangulated)
+ const uint32_t size_of_sizes_triangulated=sizes_triangulated.size();
+ WriteUnsignedInteger (size_of_sizes_triangulated)
+ for (i=0;i<size_of_sizes_triangulated;i++)
+ WriteUnsignedInteger (sizes_triangulated[i])
+
+ if(number_of_texture_coordinate_indexes==0 &&
+ used_entities_flag &
+ (
+ PRC_FACETESSDATA_PolyfaceTextured|
+ PRC_FACETESSDATA_TriangleTextured|
+ PRC_FACETESSDATA_TriangleFanTextured|
+ PRC_FACETESSDATA_TriangleStripeTextured|
+ PRC_FACETESSDATA_PolyfaceOneNormalTextured|
+ PRC_FACETESSDATA_TriangleOneNormalTextured|
+ PRC_FACETESSDATA_TriangleFanOneNormalTextured|
+ PRC_FACETESSDATA_TriangleStripeOneNormalTextured
+ ))
+ WriteUnsignedInteger (1) // workaround for error of not setting number_of_texture_coordinate_indexes
+ else
+ WriteUnsignedInteger (number_of_texture_coordinate_indexes)
+
+ const bool has_vertex_colors = !rgba_vertices.empty();
+ WriteBoolean (has_vertex_colors)
+ if (has_vertex_colors)
+ {
+ WriteBoolean (is_rgba)
+ const bool b_optimised=false;
+ WriteBoolean (b_optimised)
+ if (!b_optimised)
+ {
+ SerializeArrayRGBA (rgba_vertices, is_rgba, pbs);
+ }
+ else
+ {
+ // not described
+ }
+ }
+ if (size_of_line_attributes)
+ WriteUnsignedInteger (behaviour)
+}
+
+void PRCContentBaseTessData::serializeContentBaseTessData(PRCbitStream &pbs)
+{
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteBoolean (is_calculated)
+ const uint32_t number_of_coordinates = coordinates.size();
+ WriteUnsignedInteger (number_of_coordinates)
+ for (i=0;i<number_of_coordinates;i++)
+ WriteDouble (coordinates[i])
+}
+
+void PRC3DTess::serialize3DTess(PRCbitStream &pbs)
+{
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteUnsignedInteger (PRC_TYPE_TESS_3D)
+ SerializeContentBaseTessData
+ WriteBoolean (has_faces)
+ WriteBoolean (has_loops)
+ const bool must_recalculate_normals=normal_coordinate.empty();
+ WriteBoolean (must_recalculate_normals)
+ if (must_recalculate_normals)
+ {
+ const uint8_t normals_recalculation_flags=0;
+ // not used; should be zero
+ WriteCharacter (normals_recalculation_flags)
+ // definition similar to VRML
+ WriteDouble (crease_angle)
+ }
+
+ const uint32_t number_of_normal_coordinates=normal_coordinate.size();
+ WriteUnsignedInteger (number_of_normal_coordinates)
+ for (i=0;i<number_of_normal_coordinates;i++)
+ WriteDouble (normal_coordinate[i])
+
+ const uint32_t number_of_wire_indices=wire_index.size();
+ WriteUnsignedInteger (number_of_wire_indices)
+ for (i=0;i<number_of_wire_indices;i++)
+ WriteUnsignedInteger (wire_index[i])
+
+ // note : those can be single triangles, triangle fans or stripes
+ const uint32_t number_of_triangulated_indices=triangulated_index.size();
+ WriteUnsignedInteger (number_of_triangulated_indices)
+ for (i=0;i<number_of_triangulated_indices;i++)
+ WriteUnsignedInteger (triangulated_index[i])
+
+ const uint32_t number_of_face_tessellation=face_tessellation.size();
+ WriteUnsignedInteger (number_of_face_tessellation)
+ for (i=0;i<number_of_face_tessellation;i++)
+ SerializeTessFace (face_tessellation[i])
+
+ const uint32_t number_of_texture_coordinates=texture_coordinate.size();
+ WriteUnsignedInteger (number_of_texture_coordinates)
+ for (i=0;i<number_of_texture_coordinates;i++)
+ WriteDouble (texture_coordinate[i])
+}
+
+void PRC3DTess::addTessFace(PRCTessFace *pTessFace)
+{
+ face_tessellation.push_back(PRCpTessFace(pTessFace));
+}
+
+void PRC3DWireTess::serialize3DWireTess(PRCbitStream &pbs)
+{
+// group___tf3_d_wire_tess_data_____serialize2.html
+// group___tf3_d_wire_tess_data_____serialize_content2.html
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteUnsignedInteger (PRC_TYPE_TESS_3D_Wire)
+ SerializeContentBaseTessData
+ const uint32_t number_of_wire_indexes=wire_indexes.size();
+ WriteUnsignedInteger (number_of_wire_indexes)
+ for (i=0;i<number_of_wire_indexes;i++)
+ WriteUnsignedInteger (wire_indexes[i])
+
+ const bool has_vertex_colors = !rgba_vertices.empty();
+ WriteBoolean (has_vertex_colors)
+ if (has_vertex_colors)
+ {
+ WriteBoolean (is_rgba)
+ WriteBoolean (is_segment_color)
+ const bool b_optimised=false;
+ WriteBoolean (b_optimised)
+ if (!b_optimised)
+ {
+ SerializeArrayRGBA (rgba_vertices, is_rgba, pbs);
+ }
+ else
+ {
+ // not described
+ }
+ }
+}
+
+void PRCMarkupTess::serializeMarkupTess(PRCbitStream &pbs)
+{
+// group___tf_markup_tess_data_____serialize2.html
+// group___tf_markup_tess_data_____serialize_content2.html
+ uint32_t i=0; // universal index for PRC standart compatibility
+ WriteUnsignedInteger (PRC_TYPE_TESS_Markup)
+ SerializeContentBaseTessData
+
+ const uint32_t number_of_codes=codes.size();
+ WriteUnsignedInteger (number_of_codes)
+ for (i=0;i<number_of_codes;i++)
+ WriteUnsignedInteger (codes[i])
+ const uint32_t number_of_texts=texts.size();
+ WriteUnsignedInteger (number_of_texts)
+ for (i=0;i<number_of_texts;i++)
+ WriteString (texts[i])
+ WriteString (label) // label of tessellation
+ WriteCharacter (behaviour)
+}
+
+void PRCVector2d::serializeVector2d(PRCbitStream &pbs)
+{
+ WriteDouble (x)
+ WriteDouble (y)
+}
+
uint32_t makeCADID()
{
static uint32_t ID = 1;
@@ -176,3 +936,982 @@ void writeEmptyMarkups(PRCbitStream &out)
<< (uint32_t)0 // # of markups
<< (uint32_t)0; // # of annotation entities
}
+
+void PRCBaseTopology::serializeBaseTopology(PRCbitStream &pbs)
+{
+ WriteBoolean (base_information)
+ if (base_information)
+ {
+ SerializeAttributeData
+ SerializeName (name)
+ WriteUnsignedInteger (identifier)
+ }
+}
+
+void PRCBaseGeometry::serializeBaseGeometry(PRCbitStream &pbs)
+{
+ WriteBoolean (base_information)
+ if (base_information)
+ {
+ SerializeAttributeData
+ SerializeName (name)
+ WriteUnsignedInteger (identifier)
+ }
+}
+
+void PRCContentBody::serializeContentBody(PRCbitStream &pbs)
+{
+ SerializeBaseTopology
+ WriteCharacter ( behavior )
+}
+
+void PRCBoundingBox::serializeBoundingBox(PRCbitStream &pbs)
+{
+ SerializeVector3d ( min )
+ SerializeVector3d ( max )
+}
+
+void PRCDomain::serializeDomain(PRCbitStream &pbs)
+{
+ SerializeVector2d ( min )
+ SerializeVector2d ( max )
+}
+
+void PRCInterval::serializeInterval(PRCbitStream &pbs)
+{
+ WriteDouble ( min )
+ WriteDouble ( max )
+}
+
+void PRCParameterization::serializeParameterization(PRCbitStream &pbs)
+{
+ SerializeInterval ( interval )
+ WriteDouble ( parameterization_coeff_a )
+ WriteDouble ( parameterization_coeff_b )
+}
+
+void PRCUVParameterization::serializeUVParameterization(PRCbitStream &pbs)
+{
+ WriteBoolean ( swap_uv )
+ SerializeDomain ( uv_domain )
+ WriteDouble ( parameterization_on_u_coeff_a )
+ WriteDouble ( parameterization_on_v_coeff_a )
+ WriteDouble ( parameterization_on_u_coeff_b )
+ WriteDouble ( parameterization_on_v_coeff_b )
+}
+
+void PRCContentSurface::serializeContentSurface(PRCbitStream &pbs)
+{
+ SerializeBaseGeometry
+ WriteUnsignedInteger ( extend_info )
+}
+
+void PRCNURBSSurface::serializeNURBSSurface(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+// uint32_t i=0, j=0;
+ WriteUnsignedInteger (PRC_TYPE_SURF_NURBS)
+
+ SerializeContentSurface
+ WriteBoolean ( is_rational )
+ WriteUnsignedInteger ( degree_in_u )
+ WriteUnsignedInteger ( degree_in_v )
+ const uint32_t highest_index_of_knots_in_u = knot_u.size()-1;
+ const uint32_t highest_index_of_knots_in_v = knot_v.size()-1;
+ const uint32_t highest_index_of_control_point_in_u = highest_index_of_knots_in_u - degree_in_u - 1;
+ const uint32_t highest_index_of_control_point_in_v = highest_index_of_knots_in_v - degree_in_v - 1;
+ WriteUnsignedInteger ( highest_index_of_control_point_in_u )
+ WriteUnsignedInteger ( highest_index_of_control_point_in_v )
+ WriteUnsignedInteger ( highest_index_of_knots_in_u )
+ WriteUnsignedInteger ( highest_index_of_knots_in_v )
+ for (i=0; i < (highest_index_of_control_point_in_u+1)*(highest_index_of_control_point_in_v+1); i++)
+ {
+ WriteDouble ( control_point[i].x )
+ WriteDouble ( control_point[i].y )
+ WriteDouble ( control_point[i].z )
+ if (is_rational)
+ WriteDouble ( control_point[i].w )
+ }
+// for (i=0; i<=highest_index_of_control_point_in_u; i++)
+// {
+// for (j=0; j<=highest_index_of_control_point_in_v; j++)
+// {
+// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].x )
+// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].y )
+// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].z )
+// if (is_rational)
+// WriteDouble ( control_point[i*(highest_index_of_control_point_in_u+1)+j].w )
+// }
+// }
+ for (i=0; i<=highest_index_of_knots_in_u; i++)
+ WriteDouble ( knot_u[i] )
+ for (i=0; i<=highest_index_of_knots_in_v; i++)
+ WriteDouble ( knot_v[i] )
+ WriteUnsignedInteger ( knot_type )
+ WriteUnsignedInteger ( surface_form )
+}
+
+void writeUnsignedIntegerWithVariableBitNumber(PRCbitStream &pbs, uint32_t value, uint32_t bit_number)
+{
+ uint32_t i;
+ for(i=0; i<bit_number; i++)
+ {
+ if( value >= 1u<<(bit_number - 1 - i) )
+ {
+ WriteBoolean (true)
+
+ value -= 1u<<(bit_number - 1 - i);
+ }
+ else
+ {
+ WriteBoolean (false)
+ }
+ }
+}
+#define WriteUnsignedIntegerWithVariableBitNumber( value, bit_number ) writeUnsignedIntegerWithVariableBitNumber( pbs, (value), (bit_number) );
+
+void writeIntegerWithVariableBitNumber(PRCbitStream &pbs, int32_t iValue, uint32_t uBitNumber)
+{
+ WriteBoolean(iValue<0);
+ WriteUnsignedIntegerWithVariableBitNumber(abs(iValue), uBitNumber - 1);
+}
+#define WriteIntegerWithVariableBitNumber( value, bit_number ) writeIntegerWithVariableBitNumber( pbs, (value), (bit_number) );
+
+void writeDoubleWithVariableBitNumber(PRCbitStream &pbs, double dValue,double dTolerance, unsigned uBitNumber)
+{
+// calling functions must ensure no overflow
+ int32_t iTempValue = (int32_t) ( dValue / dTolerance );
+ WriteIntegerWithVariableBitNumber(iTempValue, uBitNumber);
+}
+#define WriteDoubleWithVariableBitNumber( value, bit_number ) writeDoubleWithVariableBitNumber( pbs, (value), (bit_number) );
+
+uint32_t GetNumberOfBitsUsedToStoreUnsignedInteger(uint32_t uValue)
+{
+ uint32_t uNbBit=2;
+ uint32_t uTemp = 2;
+ while(uValue >= uTemp)
+ {
+ uTemp*=2;
+ uNbBit++;
+ }
+ return uNbBit-1;
+}
+
+void writeNumberOfBitsThenUnsignedInteger(PRCbitStream &pbs, uint32_t unsigned_integer)
+{
+ uint32_t number_of_bits = GetNumberOfBitsUsedToStoreUnsignedInteger( unsigned_integer );
+ WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits, 5 )
+ WriteUnsignedIntegerWithVariableBitNumber ( unsigned_integer, number_of_bits )
+}
+#define WriteNumberOfBitsThenUnsignedInteger( value ) writeNumberOfBitsThenUnsignedInteger( pbs, value );
+
+uint32_t GetNumberOfBitsUsedToStoreInteger(int32_t iValue)
+{
+ return GetNumberOfBitsUsedToStoreUnsignedInteger(abs(iValue))+1;
+}
+
+int32_t intdiv(double dValue, double dTolerance)
+{
+ double ratio=fabs(dValue)/dTolerance;
+ assert(ratio <= INT_MAX);
+ int32_t iTempValue=(int32_t) ratio;
+ if(ratio - iTempValue >= 0.5) iTempValue++;
+ if(dValue < 0)
+ return -iTempValue;
+ else
+ return iTempValue;
+}
+
+// round dValue to nearest multiple of dTolerance
+double roundto(double dValue, double dTolerance)
+{
+ return intdiv(dValue, dTolerance) * dTolerance;
+}
+
+PRCVector3d roundto(PRCVector3d vec, double dTolerance)
+{
+ PRCVector3d res;
+ res.x = roundto(vec.x,dTolerance);
+ res.y = roundto(vec.y,dTolerance);
+ res.z = roundto(vec.z,dTolerance);
+ return res;
+}
+
+uint32_t GetNumberOfBitsUsedToStoreDouble(double dValue, double dTolerance )
+{
+ return GetNumberOfBitsUsedToStoreInteger(intdiv(dValue,dTolerance));
+}
+
+struct itriple
+{
+ int32_t x;
+ int32_t y;
+ int32_t z;
+};
+
+uint32_t GetNumberOfBitsUsedToStoreTripleInteger(const itriple &iTriple)
+{
+ const uint32_t x_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.x);
+ const uint32_t y_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.y);
+ const uint32_t z_bits = GetNumberOfBitsUsedToStoreInteger(iTriple.z);
+ uint32_t bits = x_bits;
+ if(y_bits > bits)
+ bits = y_bits;
+ if(z_bits > bits)
+ bits = z_bits;
+ return bits;
+}
+
+itriple iroundto(PRCVector3d vec, double dTolerance)
+{
+ itriple res;
+ res.x = intdiv(vec.x, dTolerance);
+ res.y = intdiv(vec.y, dTolerance);
+ res.z = intdiv(vec.z, dTolerance);
+ return res;
+}
+
+void PRCCompressedFace::serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance)
+{
+ serializeCompressedAnaNurbs( pbs, brep_data_compressed_tolerance );
+}
+#define SerializeCompressedFace( value ) (value)->serializeCompressedFace( pbs, brep_data_compressed_tolerance );
+
+void PRCCompressedFace::serializeContentCompressedFace(PRCbitStream &pbs)
+{
+ WriteBoolean ( orientation_surface_with_shell )
+ const bool surface_is_trimmed = false;
+ WriteBoolean ( surface_is_trimmed )
+}
+
+void PRCCompressedFace::serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance)
+{
+ // WriteCompressedEntityType ( PRC_HCG_AnaNurbs )
+ const bool is_a_curve = false;
+ WriteBoolean ( is_a_curve )
+ WriteUnsignedIntegerWithVariableBitNumber (13 , 4)
+ serializeContentCompressedFace( pbs );
+ serializeCompressedNurbs( pbs, brep_data_compressed_tolerance );
+}
+
+void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance)
+{
+ const double nurbs_tolerance = 0.2*brep_data_compressed_tolerance;
+ const uint32_t degree_in_u = degree;
+ const uint32_t degree_in_v = degree;
+
+ WriteUnsignedIntegerWithVariableBitNumber ( degree_in_u, 5)
+ WriteUnsignedIntegerWithVariableBitNumber ( degree_in_v, 5)
+
+ const uint32_t number_of_knots_in_u = 4; // 0011 or 00001111 knot vector - just 2 spans
+ WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_u - 2, 16)
+ uint32_t number_bit = degree_in_u ? ceil( log2( degree_in_u + 2 ) ) : 2;
+ WriteBoolean (false) // Multiplicity_is_already_stored - no
+ WriteUnsignedIntegerWithVariableBitNumber( degree_in_u+1,number_bit)
+ WriteBoolean (true) // Multiplicity_is_already_stored - yes
+ const uint32_t number_of_knots_in_v = 4; // 0011 or 00001111 knot vector - just 2 spans
+ WriteUnsignedIntegerWithVariableBitNumber (number_of_knots_in_v - 2, 16)
+ number_bit = degree_in_v ? ceil( log2( degree_in_v + 2 ) ) : 2;
+ WriteBoolean (false) // Multiplicity_is_already_stored - no
+ WriteUnsignedIntegerWithVariableBitNumber( degree_in_v+1,number_bit)
+ WriteBoolean (true) // Multiplicity_is_already_stored - yes
+
+ const bool is_closed_u = false;
+ WriteBoolean ( is_closed_u )
+ const bool is_closed_v = false;
+ WriteBoolean ( is_closed_v )
+
+ const uint32_t number_of_control_point_in_u = degree_in_u + 1;
+ const uint32_t number_of_control_point_in_v = degree_in_v + 1;
+ PRCVector3d P[number_of_control_point_in_u][number_of_control_point_in_v];
+ 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];
+ 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];
+
+ uint32_t number_of_bits_for_isomin = 1;
+ uint32_t number_of_bits_for_rest = 1;
+
+ for(uint32_t j = 1; j < number_of_control_point_in_v; j++)
+ {
+ compressed_control_point[0][j] = iroundto(P[0][j]-P[0][j-1], nurbs_tolerance );
+ P[0][j] = P[0][j-1] + roundto(P[0][j]-P[0][j-1], nurbs_tolerance);
+ uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[0][j]);
+ if (bit_size > number_of_bits_for_isomin)
+ number_of_bits_for_isomin = bit_size;
+ }
+
+ for(uint32_t i = 1; i < number_of_control_point_in_u; i++)
+ {
+ compressed_control_point[i][0] = iroundto(P[i][0]-P[i-1][0], nurbs_tolerance );
+ P[i][0] = P[i-1][0] + roundto(P[i][0]-P[i-1][0], nurbs_tolerance);
+ uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[i][0]);
+ if (bit_size > number_of_bits_for_isomin)
+ number_of_bits_for_isomin = bit_size;
+ }
+
+ for(uint32_t i=1;i<number_of_control_point_in_u;i++)
+ for(uint32_t j=1;j<number_of_control_point_in_v;j++)
+ {
+ compressed_control_point[i][j].x = 0;
+ compressed_control_point[i][j].y = 0;
+ compressed_control_point[i][j].z = 0;
+
+ PRCVector3d V = P[i-1][j] - P[i-1][j-1];
+ PRCVector3d U = P[i][j-1] - P[i-1][j-1];
+ PRCVector3d Pc = P[i][j] - (P[i-1][j-1] + U + V);
+
+ if(Pc.Length() < nurbs_tolerance)
+ {
+ control_point_type[i][j] = 0;
+ P[i][j] = P[i-1][j-1] + U + V;
+ }
+ else
+ {
+ PRCVector3d N = U*V;
+ PRCVector3d Ue = U;
+ PRCVector3d Ne = N;
+ if( V.Length() < FLT_EPSILON || !Ue.Normalize() || !Ne.Normalize())
+ {
+ control_point_type[i][j] = 3;
+ // Pc = roundto(Pc, nurbs_tolerance); // not sure if this rounding really happens, need to experiment, docs imply but do not state
+ compressed_control_point[i][j] = iroundto(Pc, nurbs_tolerance);
+ P[i][j] = P[i-1][j-1] + U + V + roundto(Pc, nurbs_tolerance); // see above
+ }
+ else
+ {
+ PRCVector3d NUe = Ne*Ue;
+ double x = Pc.Dot(Ue);
+ double y = Pc.Dot(NUe);
+ double z = Pc.Dot(Ne);
+
+ 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);
+ P[i][j] = P[i-1][j-1] + U + V + roundto(z, nurbs_tolerance)*Ne; // see above
+ }
+ else
+ {
+ if(fabs(z)<nurbs_tolerance/2)
+ {
+ control_point_type[i][j] = 2;
+ compressed_control_point[i][j] = iroundto(PRCVector3d(x,y,0), nurbs_tolerance);
+ P[i][j] = P[i-1][j-1] + U + V + roundto(x, nurbs_tolerance)*Ue + roundto(y, nurbs_tolerance)*NUe; // see above
+ }
+ else
+ {
+ control_point_type[i][j] = 3;
+ compressed_control_point[i][j] = iroundto(Pc, nurbs_tolerance);
+ P[i][j] = P[i-1][j-1] + U + V + roundto(Pc, nurbs_tolerance); // see above
+ }
+ }
+ }
+ }
+ uint32_t bit_size = GetNumberOfBitsUsedToStoreTripleInteger(compressed_control_point[i][j]);
+ if (bit_size > number_of_bits_for_rest)
+ number_of_bits_for_rest = bit_size;
+ }
+
+ if( number_of_bits_for_rest == 2 ) number_of_bits_for_rest--; // really I think it must be unconditional, but so it seems to be done in Adobe Acrobat (9.3)
+ WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits_for_isomin, 20 )
+ WriteUnsignedIntegerWithVariableBitNumber ( number_of_bits_for_rest, 20 )
+ WriteDouble ( P[0][0].x )
+ WriteDouble ( P[0][0].y )
+ WriteDouble ( P[0][0].z )
+
+ for(uint32_t j = 1; j < number_of_control_point_in_v; j++)
+ {
+ WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].x, number_of_bits_for_isomin+1)
+ WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].y, number_of_bits_for_isomin+1)
+ WriteIntegerWithVariableBitNumber(compressed_control_point[0][j].z, number_of_bits_for_isomin+1)
+ }
+
+ for(uint32_t i = 1; i < number_of_control_point_in_u; i++)
+ {
+ WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].x, number_of_bits_for_isomin+1)
+ WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].y, number_of_bits_for_isomin+1)
+ WriteIntegerWithVariableBitNumber(compressed_control_point[i][0].z, number_of_bits_for_isomin+1)
+ }
+
+ for(uint32_t i = 1; i < number_of_control_point_in_u; i++)
+ {
+ for(uint32_t j = 1; j < number_of_control_point_in_v; j++)
+ {
+ WriteUnsignedIntegerWithVariableBitNumber ( control_point_type[i][j], 2 )
+
+ if(control_point_type[i][j] == 1)
+ {
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].z, number_of_bits_for_rest+1 )
+ }
+ else if(control_point_type[i][j] == 2)
+ {
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].x, number_of_bits_for_rest+1 )
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].y, number_of_bits_for_rest+1 )
+ }
+ else if(control_point_type[i][j] == 3)
+ {
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].x, number_of_bits_for_rest+1 )
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].y, number_of_bits_for_rest+1 )
+ WriteIntegerWithVariableBitNumber ( compressed_control_point[i][j].z, number_of_bits_for_rest+1 )
+ }
+ }
+ }
+
+ const uint32_t type_param_u = 0;
+ WriteBoolean( type_param_u == 0 )
+ const uint32_t type_param_v = 0;
+ WriteBoolean( type_param_v == 0 )
+ const bool is_rational = false;
+ WriteBoolean( is_rational )
+}
+
+void PRCCompressedBrepData::serializeCompressedShell(PRCbitStream &pbs)
+{
+ uint32_t i;
+ const uint32_t number_of_face = face.size();
+ WriteBoolean ( number_of_face == 1 )
+
+ if( number_of_face != 1 )
+ WriteNumberOfBitsThenUnsignedInteger (number_of_face)
+
+ for( i=0; i < number_of_face; i++)
+ SerializeCompressedFace ( face[i] )
+
+ const bool is_an_iso_face = false;
+ for( i=0; i < number_of_face; i++)
+ WriteBoolean ( is_an_iso_face )
+}
+
+void PRCCompressedBrepData::serializeCompressedBrepData(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger ( PRC_TYPE_TOPO_BrepDataCompress )
+ SerializeContentBody
+
+ WriteDouble ( brep_data_compressed_tolerance )
+ const uint32_t number_of_bits_to_store_reference = 1;
+ WriteNumberOfBitsThenUnsignedInteger ( number_of_bits_to_store_reference )
+ const uint32_t number_vertex_iso = 0;
+ WriteUnsignedIntegerWithVariableBitNumber ( number_vertex_iso, number_of_bits_to_store_reference )
+ const uint32_t number_edge_iso = 0;
+ WriteUnsignedIntegerWithVariableBitNumber ( number_edge_iso, number_of_bits_to_store_reference )
+
+ const uint32_t number_of_shell = 1;
+ const uint32_t number_of_connex = 1;
+ WriteBoolean ( number_of_shell == 1 && number_of_connex == 1 )
+ serializeCompressedShell( pbs );
+
+ uint32_t i;
+ const uint32_t number_of_faces = face.size();
+ for(i=0; i< number_of_faces; i++)
+ face[i]->serializeBaseTopology( pbs );
+}
+
+void PRCBlend01::serializeBlend01(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_SURF_Blend01)
+
+ SerializeContentSurface
+ SerializeTransformation
+ SerializeUVParameterization
+ SerializePtrCurve ( center_curve )
+ SerializePtrCurve ( origin_curve )
+ SerializePtrCurve ( tangent_curve )
+}
+
+void PRCRuled::serializeRuled(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_SURF_Ruled)
+
+ SerializeContentSurface
+ SerializeTransformation
+ SerializeUVParameterization
+ SerializePtrCurve ( first_curve )
+ SerializePtrCurve ( second_curve )
+}
+
+void PRCSphere::serializeSphere(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_SURF_Sphere)
+
+ SerializeContentSurface
+ SerializeTransformation
+ SerializeUVParameterization
+ WriteDouble ( radius )
+}
+
+void PRCCylinder::serializeCylinder(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_SURF_Cylinder)
+
+ SerializeContentSurface
+ SerializeTransformation
+ SerializeUVParameterization
+ WriteDouble ( radius )
+}
+
+void PRCTorus::serializeTorus(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_SURF_Torus)
+
+ SerializeContentSurface
+ SerializeTransformation
+ SerializeUVParameterization
+ WriteDouble ( major_radius )
+ WriteDouble ( minor_radius )
+}
+
+void PRCFace::serializeFace(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger (PRC_TYPE_TOPO_Face)
+
+ SerializeBaseTopology
+ SerializePtrSurface ( base_surface )
+ WriteBit ( have_surface_trim_domain )
+ if ( have_surface_trim_domain )
+ SerializeDomain ( surface_trim_domain )
+ WriteBit ( have_tolerance )
+ if ( have_tolerance )
+ WriteDouble ( tolerance )
+ WriteUnsignedInteger ( number_of_loop )
+ WriteInteger ( outer_loop_index )
+ for (i=0;i<number_of_loop;i++)
+ {
+// SerializePtrTopology ( loop[i] )
+ }
+}
+
+void PRCShell::serializeShell(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger (PRC_TYPE_TOPO_Shell)
+
+ SerializeBaseTopology
+ WriteBoolean ( shell_is_closed )
+ uint32_t number_of_face = face.size();
+ WriteUnsignedInteger ( number_of_face )
+ for (i=0;i<number_of_face;i++)
+ {
+ SerializePtrTopology ( face[i] )
+ WriteCharacter ( orientation_surface_with_shell[i] )
+ }
+}
+
+void PRCShell::addFace(PRCFace *pFace, uint8_t orientation)
+{
+ face.push_back(PRCpFace(pFace));
+ orientation_surface_with_shell.push_back(orientation);
+}
+
+void PRCShell::addFace(const PRCpFace &pFace, uint8_t orientation)
+{
+ face.push_back(pFace);
+ orientation_surface_with_shell.push_back(orientation);
+}
+
+void PRCConnex::serializeConnex(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger (PRC_TYPE_TOPO_Connex)
+
+ SerializeBaseTopology
+ uint32_t number_of_shell = shell.size();
+ WriteUnsignedInteger ( number_of_shell )
+ for (i=0;i<number_of_shell;i++)
+ {
+ SerializePtrTopology ( shell[i] )
+ }
+}
+
+void PRCConnex::addShell(PRCShell *pShell)
+{
+ shell.push_back(PRCpShell(pShell));
+}
+
+#define have_bbox( behavior ) (behavior!=0)
+void PRCBrepData::serializeBrepData(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger ( PRC_TYPE_TOPO_BrepData)
+
+ SerializeContentBody
+ uint32_t number_of_connex = connex.size();
+ WriteUnsignedInteger ( number_of_connex )
+ for ( i=0; i<number_of_connex; i++)
+ {
+ SerializePtrTopology ( connex[i] )
+ }
+ if ( have_bbox(behavior) )
+ SerializeBoundingBox
+}
+#undef have_bbox
+
+void PRCBrepData::addConnex(PRCConnex *pConnex)
+{
+ connex.push_back(PRCpConnex(pConnex));
+}
+
+void PRCContentWireEdge::serializeContentWireEdge(PRCbitStream &pbs)
+{
+ SerializeBaseTopology
+ SerializePtrCurve ( curve_3d )
+ WriteBit ( has_curve_trim_interval )
+ if ( has_curve_trim_interval )
+ SerializeInterval ( curve_trim_interval )
+}
+
+void PRCWireEdge::serializeWireEdge(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_TOPO_WireEdge)
+ SerializeContentWireEdge
+}
+
+void PRCContentCurve::serializeContentCurve(PRCbitStream &pbs)
+{
+ SerializeBaseGeometry
+ WriteUnsignedInteger ( extend_info )
+ WriteBoolean ( is_3d )
+}
+
+void PRCNURBSCurve::serializeNURBSCurve(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+ WriteUnsignedInteger (PRC_TYPE_CRV_NURBS)
+
+ SerializeContentCurve
+ WriteBoolean ( is_rational )
+ WriteUnsignedInteger ( degree )
+ uint32_t highest_index_of_control_point = control_point.size()-1;
+ uint32_t highest_index_of_knots = knot.size()-1;
+ WriteUnsignedInteger ( highest_index_of_control_point )
+ WriteUnsignedInteger ( highest_index_of_knots )
+ for (i=0; i<=highest_index_of_control_point; i++)
+ {
+ WriteDouble ( control_point[i].x )
+ WriteDouble ( control_point[i].y )
+ if (is_3d)
+ WriteDouble ( control_point[i].z )
+ if (is_rational)
+ WriteDouble ( control_point[i].w )
+ }
+ for (i=0; i<=highest_index_of_knots; i++)
+ WriteDouble ( knot[i] )
+ WriteUnsignedInteger ( knot_type )
+ WriteUnsignedInteger ( curve_form )
+}
+
+void PRCPolyLine::serializePolyLine(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+ WriteUnsignedInteger (PRC_TYPE_CRV_PolyLine)
+
+ SerializeContentCurve
+ SerializeTransformation
+ SerializeParameterization
+ uint32_t number_of_point = point.size();
+ WriteUnsignedInteger ( number_of_point )
+ for (i=0; i<number_of_point; i++)
+ {
+ if (is_3d)
+ SerializeVector3d ( point[i] )
+ else
+ SerializeVector2d ( point[i] )
+ }
+}
+
+void PRCCircle::serializeCircle(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_CRV_Circle)
+
+ SerializeContentCurve
+ SerializeTransformation
+ SerializeParameterization
+ WriteDouble ( radius )
+}
+
+void PRCComposite::serializeComposite(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+ WriteUnsignedInteger (PRC_TYPE_CRV_Composite)
+
+ SerializeContentCurve
+ SerializeTransformation
+ SerializeParameterization
+ uint32_t number_of_curves = base_curve.size();
+ WriteUnsignedInteger ( number_of_curves )
+ for (i=0; i<number_of_curves; i++)
+ {
+ SerializePtrCurve ( base_curve[i] )
+ WriteBoolean ( base_sense[i] )
+ }
+ WriteBoolean ( is_closed )
+}
+
+void PRCTopoContext::serializeTopoContext(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (PRC_TYPE_TOPO_Context)
+
+ SerializeContentPRCBase
+ WriteCharacter ( behaviour )
+ WriteDouble ( granularity )
+ WriteDouble ( tolerance )
+ WriteBoolean ( have_smallest_face_thickness )
+ if ( have_smallest_face_thickness )
+ WriteDouble ( smallest_thickness )
+ WriteBoolean ( have_scale )
+ if ( have_scale )
+ WriteDouble ( scale )
+}
+
+void PRCTopoContext::serializeContextAndBodies(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+ SerializeTopoContext
+ uint32_t number_of_bodies = body.size();
+ WriteUnsignedInteger (number_of_bodies)
+ for (i=0;i<number_of_bodies;i++)
+ SerializeBody (body[i])
+}
+
+void PRCTopoContext::serializeGeometrySummary(PRCbitStream &pbs)
+{
+ uint32_t i=0;
+ uint32_t number_of_bodies = body.size();
+ WriteUnsignedInteger (number_of_bodies)
+ for (i=0;i<number_of_bodies;i++)
+ {
+ WriteUnsignedInteger ( body[i]->serialType() )
+ if ( IsCompressedType(body[i]->serialType()) )
+ {
+ WriteDouble ( body[i]->serialTolerance() )
+ }
+ }
+}
+
+void PRCTopoContext::serializeContextGraphics(PRCbitStream &pbs)
+{
+ uint32_t i=0, j=0, k=0, l=0;
+ ResetCurrentGraphics
+ uint32_t number_of_body = body.size();
+ PRCGraphicsList element;
+ bool has_graphics = false;
+ for (i=0;i<number_of_body;i++)
+ {
+ if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepData && dynamic_cast<PRCBrepData*>(body[i].get()))
+ {
+ PRCBrepData *body_i = dynamic_cast<PRCBrepData*>(body[i].get());
+ for (j=0;j<body_i->connex.size();j++)
+ {
+ for(k=0;k<body_i->connex[j]->shell.size();k++)
+ {
+ for( l=0;l<body_i->connex[j]->shell[k]->face.size();l++)
+ {
+ element.push_back( body_i->connex[j]->shell[k]->face[l] );
+ has_graphics = has_graphics || body_i->connex[j]->shell[k]->face[l]->has_graphics();
+ }
+ }
+ }
+ }
+ else if ( body[i]->topo_item_type == PRC_TYPE_TOPO_BrepDataCompress && dynamic_cast<PRCCompressedBrepData*>(body[i].get()))
+ {
+ PRCCompressedBrepData *body_i = dynamic_cast<PRCCompressedBrepData*>(body[i].get());
+ for( l=0;l<body_i->face.size();l++)
+ {
+ element.push_back( body_i->face[l] );
+ has_graphics = has_graphics || body_i->face[l]->has_graphics();
+ }
+ }
+ }
+ uint32_t number_of_treat_type = 0;
+ if (has_graphics && !element.empty())
+ number_of_treat_type = 1;
+ WriteUnsignedInteger (number_of_treat_type)
+ for (i=0;i<number_of_treat_type;i++)
+ {
+ const uint32_t element_type = PRC_TYPE_TOPO_Face;
+ WriteUnsignedInteger (element_type)
+ const uint32_t number_of_element = element.size();
+ WriteUnsignedInteger (number_of_element)
+ for (j=0;j<number_of_element;j++)
+ {
+ WriteBoolean ( element[j]->has_graphics() )
+ if (element[j]->has_graphics())
+ {
+ element[j]->serializeGraphics(pbs);
+ }
+ }
+ }
+}
+
+uint32_t PRCTopoContext::addSingleWireBody(PRCSingleWireBody *pSingleWireBody)
+{
+ body.push_back(PRCpBody(pSingleWireBody));
+ return body.size()-1;
+}
+
+uint32_t PRCTopoContext::addBrepData(PRCBrepData *pBrepData)
+{
+ body.push_back(PRCpBody(pBrepData));
+ return body.size()-1;
+}
+
+uint32_t PRCTopoContext::addCompressedBrepData(PRCCompressedBrepData *pCompressedBrepData)
+{
+ body.push_back(PRCpBody(pCompressedBrepData));
+ return body.size()-1;
+}
+
+void PRCSingleWireBody::setWireEdge(PRCWireEdge *wireEdge)
+{
+ wire_edge.reset(wireEdge);
+}
+
+void PRCSingleWireBody::serializeSingleWireBody(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger ( PRC_TYPE_TOPO_SingleWireBody)
+
+ SerializeContentBody
+ SerializePtrTopology ( wire_edge )
+}
+
+void PRCUniqueId::serializeCompressedUniqueId(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger (unique_id0)
+ WriteUnsignedInteger (unique_id1)
+ WriteUnsignedInteger (unique_id2)
+ WriteUnsignedInteger (unique_id3)
+}
+
+void PRCUnit::serializeUnit(PRCbitStream &pbs)
+{
+ WriteBoolean (unit_from_CAD_file)
+ WriteDouble (unit)
+}
+
+void PRCProductOccurrence::serializeProductOccurrence(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger ( PRC_TYPE_ASM_ProductOccurence )
+
+ SerializePRCBaseWithGraphics
+
+// SerializeReferencesOfProductOccurrence
+ WriteUnsignedInteger (index_part+1)
+ WriteUnsignedInteger (index_prototype+1)
+ if (index_prototype != m1)
+ {
+ WriteBoolean (prototype_in_same_file_structure)
+ if (!prototype_in_same_file_structure)
+ SerializeCompressedUniqueId (prototype_file_structure)
+ }
+ WriteUnsignedInteger(index_external_data+1)
+ if (index_external_data != m1)
+ {
+ WriteBoolean (external_data_in_same_file_structure)
+ if (!external_data_in_same_file_structure)
+ SerializeCompressedUniqueId (external_data_file_structure)
+ }
+ const uint32_t number_of_son_product_occurrences = index_son_occurrence.size();
+ WriteUnsignedInteger (number_of_son_product_occurrences)
+ for (uint32_t i=0;i<number_of_son_product_occurrences;i++)
+ WriteUnsignedInteger (index_son_occurrence[i])
+
+ WriteCharacter (product_behaviour)
+
+// SerializeProductInformation (product_information)
+ SerializeUnit (unit_information)
+ WriteCharacter (product_information_flags)
+ WriteInteger (product_load_status)
+
+ WriteBit (has_location)
+ if (has_location)
+ location->serializeTransformation3d (pbs);
+
+ WriteUnsignedInteger (0) // number_of_references
+
+// SerializeMarkups (markups)
+ WriteUnsignedInteger (0) // number_of_linked_items
+ WriteUnsignedInteger (0) // number_of_leaders
+ WriteUnsignedInteger (0) // number_of_markups
+ WriteUnsignedInteger (0) // number_of_annotation_entities
+
+
+ WriteUnsignedInteger (0) // number_of_views
+ WriteBit (false) // has_entity_filter
+ WriteUnsignedInteger (0) // number_of_display_filters
+ WriteUnsignedInteger (0) // number_of_scene_display_parameters
+
+ SerializeUserData
+}
+
+uint32_t PRCPartDefinition::addBrepModel(PRCBrepModel *pBrepModel)
+{
+ representation_item.push_back(PRCpRepresentationItem(pBrepModel));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel)
+{
+ representation_item.push_back(PRCpRepresentationItem(pPolyBrepModel));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addPointSet(PRCPointSet *pPointSet)
+{
+ representation_item.push_back(PRCpRepresentationItem(pPointSet));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addSet(PRCSet *pSet)
+{
+ representation_item.push_back(PRCpRepresentationItem(pSet));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addWire(PRCWire *pWire)
+{
+ representation_item.push_back(PRCpRepresentationItem(pWire));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addPolyWire(PRCPolyWire *pPolyWire)
+{
+ representation_item.push_back(PRCpRepresentationItem(pPolyWire));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addRepresentationItem(PRCRepresentationItem *pRepresentationItem)
+{
+ representation_item.push_back(PRCpRepresentationItem(pRepresentationItem));
+ return representation_item.size()-1;
+}
+
+uint32_t PRCPartDefinition::addRepresentationItem(PRCpRepresentationItem pRepresentationItem)
+{
+ representation_item.push_back(pRepresentationItem);
+ return representation_item.size()-1;
+}
+
+
+void PRCPartDefinition::serializePartDefinition(PRCbitStream &pbs)
+{
+ WriteUnsignedInteger ( PRC_TYPE_ASM_PartDefinition )
+
+ SerializePRCBaseWithGraphics
+ SerializeBoundingBox
+
+ uint32_t number_of_representation_items = representation_item.size();
+ WriteUnsignedInteger (number_of_representation_items)
+ for (uint32_t i=0;i<number_of_representation_items;i++)
+ SerializeRepresentationItem (representation_item[i])
+
+ // SerializeMarkups (markups)
+ WriteUnsignedInteger (0) // number_of_linked_items
+ WriteUnsignedInteger (0) // number_of_leaders
+ WriteUnsignedInteger (0) // number_of_markups
+ WriteUnsignedInteger (0) // number_of_annotation_entities
+
+ WriteUnsignedInteger (0) // number_of_views
+ SerializeUserData
+}
diff --git a/Build/source/utils/asymptote/prc/writePRC.h b/Build/source/utils/asymptote/prc/writePRC.h
index 6a4da7a70ba..18c616ccfac 100644
--- a/Build/source/utils/asymptote/prc/writePRC.h
+++ b/Build/source/utils/asymptote/prc/writePRC.h
@@ -21,33 +21,86 @@
#ifndef __WRITE_PRC_H
#define __WRITE_PRC_H
#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+#if defined(_MSC_VER)
+#include <memory>
+#else
+#include <tr1/memory>
+#endif
#include "PRCbitStream.h"
#include "PRC.h"
+#include <float.h>
+#include <math.h>
-struct Point3d
-{
- double x,y,z;
- Point3d(double a, double b, double c) : x(a),y(b),z(c) {}
- void write(PRCbitStream &out)
- {
- out << x << y << z;
- }
-};
+static const uint32_t m1=(uint32_t)-1;
+static const double pi=acos(-1);
-struct Extent3d
+class PRCVector3d
{
- Point3d min,max;
- Extent3d(const Point3d &m1, const Point3d& m2) : min(m1),max(m2) {}
- void write(PRCbitStream &out)
- {
- // flip the order? Following the documentation, in a real file, min>max.
- // Considering the file to be right, min and max can be flipped in both places (here and in description)
- // resulting in no practical difference.
- // But in other places (Extent3D and Extent1D), min is really before max, so for consistency
- // this is left alone.
- min.write(out);
- max.write(out);
- }
+public :
+ double x;
+ double y;
+ double z;
+ PRCVector3d() {}
+ 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 PRCVector3d& sVector3d) :
+ x(sVector3d.x), y(sVector3d.y), z(sVector3d.z) {}
+
+ void Set(double fx, double fy, double fz)
+ { x = fx; y = fy; z = fz; }
+ double Dot(const PRCVector3d & sPt) const
+ { return(x*sPt.x)+(y*sPt.y)+(z*sPt.z); }
+ double LengthSquared()
+ { return(x*x+y*y+z*z); }
+
+ friend PRCVector3d operator + (const PRCVector3d& a, const PRCVector3d& b)
+ { return PRCVector3d(a.x+b.x,a.y+b.y,a.z+b.z); }
+ friend PRCVector3d operator - (const PRCVector3d& a)
+ { return PRCVector3d(-a.x,-a.y,-a.z); }
+ friend PRCVector3d operator - (const PRCVector3d& a, const PRCVector3d& b)
+ { return PRCVector3d(a.x-b.x,a.y-b.y,a.z-b.z); }
+ friend PRCVector3d operator * (const PRCVector3d& a, const double d)
+ { return PRCVector3d(a.x*d,a.y*d,a.z*d); }
+ friend PRCVector3d operator * (const double d, const PRCVector3d& a)
+ { return PRCVector3d(a.x*d,a.y*d,a.z*d); }
+ friend PRCVector3d operator / (const PRCVector3d& a, const double d)
+ { return PRCVector3d(a.x/d,a.y/d,a.z/d); }
+ friend PRCVector3d operator * (const PRCVector3d& a, const PRCVector3d& b)
+ { 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)); }
+
+ void write(PRCbitStream &out) { out << x << y << z; }
+ void serializeVector3d(PRCbitStream &pbs) const { pbs << x << y << z; }
+ void serializeVector2d(PRCbitStream &pbs) const { pbs << x << y; }
+
+ double Length();
+ bool Normalize();
+
+ bool operator==(const PRCVector3d &v) const
+ {
+ return x==v.x && y==v.y && z==v.z;
+ }
+ bool operator!=(const PRCVector3d &v) const
+ {
+ return !(x==v.x && y==v.y && z==v.z);
+ }
+ bool operator<(const PRCVector3d &v) const
+ {
+ if(x!=v.x)
+ return (x<v.x);
+ if(y!=v.y)
+ return (y<v.y);
+ return (z<v.z);
+ }
+ friend std::ostream& operator << (std::ostream& out, const PRCVector3d& v)
+ {
+ out << "(" << v.x << "," << v.y << "," << v.z << ")";
+ return out;
+ }
};
class UUID
@@ -140,13 +193,25 @@ class ContentPRCBase
attributes(a),name(n),eligibleForReference(efr),CADID(ci),
CADPersistentID(cpi),PRCID(pi) {}
void write(PRCbitStream&);
- private:
+ uint32_t getPRCID() { return PRCID; }
Attributes *attributes;
std::string name;
bool eligibleForReference;
uint32_t CADID, CADPersistentID, PRCID;
};
+class PRCReferenceUniqueIdentifier
+{
+public:
+ PRCReferenceUniqueIdentifier() :
+ type(0), unique_identifier(m1) {}
+ void serializeReferenceUniqueIdentifier(PRCbitStream&);
+ uint32_t type;
+// bool reference_in_same_file_structure;
+// PRCUniqueId target_file_structure;
+ uint32_t unique_identifier;
+};
+
extern AttributeTitle EMPTY_ATTRIBUTE_TITLE;
extern Attribute EMPTY_ATTRIBUTE;
extern Attributes EMPTY_ATTRIBUTES;
@@ -157,16 +222,1144 @@ extern std::string currentName;
void writeName(PRCbitStream&,const std::string&);
void resetName();
-extern uint32_t layer_index;
-extern uint32_t index_of_line_style;
-extern uint32_t behaviour_bit_field;
-static const uint32_t m1=(uint32_t)-1;
+extern uint32_t current_layer_index;
+extern uint32_t current_index_of_line_style;
+extern uint16_t current_behaviour_bit_field;
void writeGraphics(PRCbitStream&,uint32_t=m1,uint32_t=m1,uint32_t=1,bool=false);
void resetGraphics();
void resetGraphicsAndName();
+struct PRCRgbColor
+{
+ PRCRgbColor(double r=0.0, double g=0.0, double b=0.0) :
+ red(r), green(g), blue(b) {}
+ double red,green,blue;
+ void serializeRgbColor(PRCbitStream&);
+
+ bool operator==(const PRCRgbColor &c) const
+ {
+ return (red==c.red && green==c.green && blue==c.blue);
+ }
+ bool operator!=(const PRCRgbColor &c) const
+ {
+ return !(red==c.red && green==c.green && blue==c.blue);
+ }
+ bool operator<(const PRCRgbColor &c) const
+ {
+ if(red!=c.red)
+ return (red<c.red);
+ if(green!=c.green)
+ return (green<c.green);
+ return (blue<c.blue);
+ }
+};
+
+class PRCPicture : public ContentPRCBase
+{
+public:
+ PRCPicture(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n), format(KEPRCPicture_PNG), uncompressed_file_index(m1), pixel_width(0), pixel_height(0) {}
+ void serializePicture(PRCbitStream&);
+ EPRCPictureDataFormat format;
+ uint32_t uncompressed_file_index;
+ uint32_t pixel_width;
+ uint32_t pixel_height;
+};
+
+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;
+};
+
+class PRCTextureDefinition : public ContentPRCBase
+{
+public:
+ PRCTextureDefinition(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), picture_index(m1), texture_mapping_attribute(PRC_TEXTURE_MAPPING_DIFFUSE),
+ 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) // ,
+ // texture_transformation(false), texture_flip_S(false), texture_flip_T(false),
+ // behaviour(PRC_TRANSFORMATION_Identity), scale(1.0,1.0), uniform_scale(1.0)
+ {}
+ void serializeTextureDefinition(PRCbitStream&);
+ uint32_t picture_index;
+ uint32_t texture_mapping_attribute;
+ double texture_mapping_attribute_intensity;
+ uint8_t texture_mapping_attribute_components;
+ EPRCTextureFunction texture_function;
+ uint8_t texture_applying_mode;
+ EPRCTextureWrappingMode texture_wrapping_mode_S;
+ EPRCTextureWrappingMode texture_wrapping_mode_T;
+ // bool texture_transformation;
+ // bool texture_flip_S;
+ // bool texture_flip_T;
+ // uint8_t behaviour;
+ // PRCVector2d origin;
+ // PRCVector2d X;
+ // PRCVector2d Y;
+ // PRCVector2d scale;
+ // double uniform_scale;
+ // double X_homegeneous_coord;
+ // double Y_homegeneous_coord;
+ // double origin_homegeneous_coord;
+};
+typedef std::tr1::shared_ptr <PRCTextureDefinition> PRCpTextureDefinition;
+typedef std::vector <PRCpTextureDefinition> PRCTextureDefinitionList;
+
+class PRCMaterial
+{
+public:
+ virtual void serializeMaterial(PRCbitStream&) = 0;
+};
+typedef std::tr1::shared_ptr <PRCMaterial> PRCpMaterial;
+typedef std::vector <PRCpMaterial> PRCMaterialList;
+
+class PRCMaterialGeneric : public ContentPRCBase, public PRCMaterial
+{
+public:
+ PRCMaterialGeneric(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ ambient(m1), diffuse(m1), emissive(m1), specular(m1),
+ shininess(0.0),
+ ambient_alpha(1.0), diffuse_alpha(1.0), emissive_alpha(1.0), specular_alpha(1.0)
+ {}
+ void serializeMaterialGeneric(PRCbitStream&);
+ void serializeMaterial(PRCbitStream &pbs) { serializeMaterialGeneric(pbs); }
+ uint32_t picture_index;
+ uint32_t ambient;
+ uint32_t diffuse;
+ uint32_t emissive;
+ uint32_t specular;
+ double shininess;
+ double ambient_alpha;
+ double diffuse_alpha;
+ double emissive_alpha;
+ double specular_alpha;
+
+ bool operator==(const PRCMaterialGeneric &m) const
+ {
+ return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive && specular==m.specular && shininess==m.shininess &&
+ ambient_alpha==m.ambient_alpha && diffuse_alpha==m.diffuse_alpha && emissive_alpha==m.emissive_alpha && specular_alpha==m.specular_alpha);
+ }
+};
+
+class PRCTextureApplication : public ContentPRCBase, public PRCMaterial
+{
+public:
+ PRCTextureApplication(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ material_generic_index(m1), texture_definition_index(m1),
+ next_texture_index(m1), UV_coordinates_index(0)
+ {}
+ void serializeTextureApplication(PRCbitStream&);
+ void serializeMaterial(PRCbitStream &pbs) { serializeTextureApplication(pbs); }
+ uint32_t material_generic_index;
+ uint32_t texture_definition_index;
+ uint32_t next_texture_index;
+ uint32_t UV_coordinates_index;
+};
+
+class PRCStyle : public ContentPRCBase
+{
+public:
+ PRCStyle(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()), line_width(0.0), is_vpicture(false), line_pattern_vpicture_index(m1),
+ is_material(false), color_material_index(m1), is_transparency_defined(false), transparency(255), additional(0)
+ {}
+ void serializeCategory1LineStyle(PRCbitStream&);
+ double line_width;
+ bool is_vpicture;
+ uint32_t line_pattern_vpicture_index;
+ bool is_material;
+ uint32_t color_material_index;
+ bool is_transparency_defined;
+ uint8_t transparency;
+ uint8_t additional;
+};
+typedef std::tr1::shared_ptr <PRCStyle> PRCpStyle;
+typedef std::vector <PRCpStyle> PRCStyleList;
+
+class PRCTessFace
+{
+public:
+ PRCTessFace() :
+ start_wire(0), used_entities_flag(0),
+ start_triangulated(0), number_of_texture_coordinate_indexes(0),
+ is_rgba(false), behaviour(PRC_GRAPHICS_Show)
+ {}
+ void serializeTessFace(PRCbitStream&);
+ std::vector<uint32_t> line_attributes;
+ uint32_t start_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
+ std::vector<uint32_t> sizes_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
+ uint32_t used_entities_flag;
+ uint32_t start_triangulated;
+ std::vector<uint32_t> sizes_triangulated;
+ uint32_t number_of_texture_coordinate_indexes;
+ bool is_rgba;
+ std::vector<uint8_t> rgba_vertices;
+ uint32_t behaviour;
+};
+typedef std::tr1::shared_ptr <PRCTessFace> PRCpTessFace;
+typedef std::vector <PRCpTessFace> PRCTessFaceList;
+
+class PRCContentBaseTessData
+{
+public:
+ PRCContentBaseTessData() :
+ is_calculated(false) {}
+ void serializeContentBaseTessData(PRCbitStream&);
+ bool is_calculated;
+ std::vector<double> coordinates;
+};
+
+class PRCTess : public PRCContentBaseTessData
+{
+public:
+ virtual void serializeBaseTessData(PRCbitStream &pbs) = 0;
+};
+typedef std::tr1::shared_ptr <PRCTess> PRCpTess;
+typedef std::vector <PRCpTess> PRCTessList;
+
+class PRC3DTess : public PRCTess
+{
+public:
+ PRC3DTess() :
+ has_faces(false), has_loops(false),
+ crease_angle(25.8419)
+ {}
+ void serialize3DTess(PRCbitStream&);
+ void serializeBaseTessData(PRCbitStream &pbs) { serialize3DTess(pbs); }
+ void addTessFace(PRCTessFace *pTessFace);
+
+ bool has_faces;
+ bool has_loops;
+ double crease_angle;
+ std::vector<double> normal_coordinate;
+ std::vector<uint32_t> wire_index; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2
+ std::vector<uint32_t> triangulated_index;
+ PRCTessFaceList face_tessellation;
+ std::vector<double> texture_coordinate;
+};
+
+class PRC3DWireTess : public PRCTess
+{
+public:
+ PRC3DWireTess() :
+ is_rgba(false), is_segment_color(false) {}
+ void serialize3DWireTess(PRCbitStream&);
+ void serializeBaseTessData(PRCbitStream &pbs) { serialize3DWireTess(pbs); }
+
+ bool is_rgba;
+ bool is_segment_color;
+ std::vector<uint32_t> wire_indexes;
+ std::vector<uint8_t> rgba_vertices;
+};
+
+class PRCMarkupTess : public PRCTess
+{
+public:
+ PRCMarkupTess() :
+ behaviour(0)
+ {}
+ void serializeMarkupTess(PRCbitStream&);
+ void serializeBaseTessData(PRCbitStream &pbs) { serializeMarkupTess(pbs); }
+
+ std::vector<uint32_t> codes;
+ std::vector<std::string> texts;
+ std::string label;
+ uint8_t behaviour;
+};
+
+class PRCGraphics
+{
+public:
+ PRCGraphics() : layer_index(m1), index_of_line_style(m1), behaviour_bit_field(PRC_GRAPHICS_Show) {}
+ void serializeGraphics(PRCbitStream&);
+ void serializeGraphicsForced(PRCbitStream&);
+ bool has_graphics() { return (index_of_line_style!=m1 || layer_index!=m1 || behaviour_bit_field!=PRC_GRAPHICS_Show) ; }
+ uint32_t layer_index;
+ uint32_t index_of_line_style;
+ uint16_t behaviour_bit_field;
+};
+typedef std::tr1::shared_ptr <PRCGraphics> PRCpGraphics;
+typedef std::vector <PRCpGraphics> PRCGraphicsList;
+
+void writeGraphics(PRCbitStream&,const PRCGraphics&,bool=false);
+
+class PRCMarkup: public PRCGraphics, public ContentPRCBase
+{
+public:
+ PRCMarkup(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {}
+ void serializeMarkup(PRCbitStream&);
+ EPRCMarkupType type;
+ EPRCMarkupSubType sub_type;
+// vector<PRCReferenceUniqueIdentifier> linked_items;
+// vector<PRCReferenceUniqueIdentifier> leaders;
+ uint32_t index_tessellation;
+};
+typedef std::tr1::shared_ptr <PRCMarkup> PRCpMarkup;
+typedef std::vector <PRCpMarkup> PRCMarkupList;
+
+class PRCAnnotationItem: public PRCGraphics, public ContentPRCBase
+{
+public:
+ PRCAnnotationItem(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {}
+ void serializeAnnotationItem(PRCbitStream&);
+ void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); }
+ PRCReferenceUniqueIdentifier markup;
+};
+typedef std::tr1::shared_ptr <PRCAnnotationItem> PRCpAnnotationItem;
+typedef std::vector <PRCpAnnotationItem> PRCAnnotationItemList;
+
+class PRCRepresentationItemContent: public PRCGraphics, public ContentPRCBase
+{
+public:
+ PRCRepresentationItemContent(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ index_local_coordinate_system(m1), index_tessellation(m1) {}
+ void serializeRepresentationItemContent(PRCbitStream&);
+ uint32_t index_local_coordinate_system;
+ uint32_t index_tessellation;
+};
+
+class PRCRepresentationItem : public PRCRepresentationItemContent
+{
+public:
+ PRCRepresentationItem(std::string n="") :
+ PRCRepresentationItemContent(n) {}
+ virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0;
+};
+typedef std::tr1::shared_ptr <PRCRepresentationItem> PRCpRepresentationItem;
+typedef std::vector <PRCpRepresentationItem> PRCRepresentationItemList;
+
+class PRCBrepModel : public PRCRepresentationItem
+{
+public:
+ PRCBrepModel(std::string n="") :
+ PRCRepresentationItem(n), has_brep_data(true), context_id(m1), body_id(m1), is_closed(false) {}
+ void serializeBrepModel(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializeBrepModel(pbs); }
+ bool has_brep_data;
+ uint32_t context_id;
+ uint32_t body_id;
+ bool is_closed;
+};
+
+class PRCPolyBrepModel : public PRCRepresentationItem
+{
+public:
+ PRCPolyBrepModel(std::string n="") :
+ PRCRepresentationItem(n), is_closed(false) {}
+ void serializePolyBrepModel(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyBrepModel(pbs); }
+ bool is_closed;
+};
+
+class PRCPointSet : public PRCRepresentationItem
+{
+public:
+ PRCPointSet(std::string n="") :
+ PRCRepresentationItem(n) {}
+ void serializePointSet(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); }
+ std::vector<PRCVector3d> point;
+};
+typedef std::tr1::shared_ptr <PRCPointSet> PRCpPointSet;
+
+class PRCWire : public PRCRepresentationItem
+{
+public:
+ PRCWire(std::string n="") :
+ PRCRepresentationItem(n), has_wire_body(true), context_id(m1), body_id(m1) {}
+ void serializeWire(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializeWire(pbs); }
+ bool has_wire_body;
+ uint32_t context_id;
+ uint32_t body_id;
+};
+
+class PRCPolyWire : public PRCRepresentationItem
+{
+public:
+ PRCPolyWire(std::string n="") :
+ PRCRepresentationItem(n) {}
+ void serializePolyWire(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyWire(pbs); }
+};
+
+class PRCSet : public PRCRepresentationItem
+{
+public:
+ PRCSet(std::string n="") :
+ PRCRepresentationItem(n) {}
+ void serializeSet(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializeSet(pbs); }
+ uint32_t addBrepModel(PRCBrepModel *pBrepModel);
+ uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel);
+ uint32_t addPointSet(PRCPointSet *pPointSet);
+ uint32_t addSet(PRCSet *pSet);
+ uint32_t addWire(PRCWire *pWire);
+ uint32_t addPolyWire(PRCPolyWire *pPolyWire);
+ uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem);
+ uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem);
+ PRCRepresentationItemList elements;
+};
+
+class PRCTransformation3d
+{
+public:
+ virtual void serializeTransformation3d(PRCbitStream&) const =0;
+};
+typedef std::tr1::shared_ptr <PRCTransformation3d> PRCpTransformation3d;
+typedef std::vector <PRCpTransformation3d> PRCTransformation3dList;
+
+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;
+ }
+ PRCGeneralTransformation3d(const double t[][4])
+ {
+ 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;
+ }
+ }
+
+ void serializeGeneralTransformation3d(PRCbitStream&) const;
+ void serializeTransformation3d(PRCbitStream& pbs) const { serializeGeneralTransformation3d(pbs); }
+ double mat[4][4];
+ 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])
+ 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])
+ {
+ return (mat[i][j]<t.mat[i][j]);
+ }
+ return false;
+ }
+ void set(const double t[][4])
+ {
+ 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];
+ }
+ 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 );
+ }
+ 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 );
+ }
+};
+typedef std::tr1::shared_ptr <PRCGeneralTransformation3d> PRCpGeneralTransformation3d;
+typedef std::vector <PRCpGeneralTransformation3d> PRCGeneralTransformation3dList;
+class PRCCartesianTransformation3d : public PRCTransformation3d
+{
+public:
+ PRCCartesianTransformation3d() :
+ 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) {}
+ void serializeCartesianTransformation3d(PRCbitStream& pbs) const;
+ void serializeTransformation3d(PRCbitStream& pbs) const { serializeCartesianTransformation3d(pbs); }
+ uint8_t behaviour;
+ PRCVector3d origin;
+ PRCVector3d X;
+ PRCVector3d Y;
+ PRCVector3d Z;
+ PRCVector3d scale;
+ double uniform_scale;
+ double X_homogeneous_coord;
+ double Y_homogeneous_coord;
+ double Z_homogeneous_coord;
+ double origin_homogeneous_coord;
+ bool operator==(const PRCCartesianTransformation3d &t) const
+ {
+ return behaviour==t.behaviour && origin==t.origin && X==t.X && Y==t.Y && Z==t.Z && scale==t.scale && uniform_scale==t.uniform_scale &&
+ X_homogeneous_coord==t.X_homogeneous_coord && Y_homogeneous_coord==t.Y_homogeneous_coord &&
+ Z_homogeneous_coord==t.Z_homogeneous_coord && origin_homogeneous_coord==t.origin_homogeneous_coord;
+ }
+};
+
+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) {}
+ void serializeTransformation(PRCbitStream&);
+ bool has_transformation;
+ bool geometry_is_2D;
+ uint8_t behaviour;
+ PRCVector3d origin;
+ PRCVector3d x_axis;
+ PRCVector3d y_axis;
+ double scale;
+};
+
+class PRCCoordinateSystem : public PRCRepresentationItem
+{
+public:
+ PRCCoordinateSystem(std::string n="") :
+ PRCRepresentationItem(n) {}
+ void serializeCoordinateSystem(PRCbitStream&);
+ void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); }
+ PRCpTransformation3d axis_set;
+ bool operator==(const PRCCoordinateSystem &t) const
+ {
+ if(index_local_coordinate_system!=t.index_local_coordinate_system)
+ return false;
+ PRCGeneralTransformation3d* axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(axis_set.get());
+ PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast<PRCGeneralTransformation3d*>(t.axis_set.get());
+ PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(axis_set.get());
+ PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast<PRCCartesianTransformation3d*>(t.axis_set.get());
+ if(axis_set_general!=NULL)
+ return (t_axis_set_general!=NULL?(*axis_set_general==*t_axis_set_general):false);
+ if(axis_set_cartesian!=NULL)
+ return (t_axis_set_cartesian!=NULL?(*axis_set_cartesian==*t_axis_set_cartesian):false);
+ return false;
+ }
+};
+typedef std::tr1::shared_ptr <PRCCoordinateSystem> PRCpCoordinateSystem;
+typedef std::vector <PRCpCoordinateSystem> PRCCoordinateSystemList;
+
+struct PRCFontKey
+{
+ uint32_t font_size;
+ uint8_t attributes;
+};
+
+class PRCFontKeysSameFont
+{
+public:
+ void serializeFontKeysSameFont(PRCbitStream&);
+ std::string font_name;
+ uint32_t char_set;
+ std::vector<PRCFontKey> font_keys;
+
+};
+
+// Topology
+class PRCBaseGeometry
+{
+public:
+ PRCBaseGeometry() :
+ base_information(false) {}
+ PRCBaseGeometry(Attributes *a, std::string n="", uint32_t id = 0) :
+ base_information(true),attributes(a),name(n),identifier(id) {}
+ void serializeBaseGeometry(PRCbitStream&);
+ bool base_information;
+ Attributes *attributes;
+ std::string name;
+ uint32_t identifier;
+};
+
+class PRCBoundingBox
+{
+public:
+ PRCBoundingBox() : min(0,0,0), max(0,0,0) {}
+ PRCBoundingBox(const PRCVector3d &m1, const PRCVector3d& m2) : min(m1),max(m2) {}
+ void serializeBoundingBox(PRCbitStream &pbs);
+ PRCVector3d min;
+ PRCVector3d max;
+};
+
+class PRCDomain
+{
+public:
+ void serializeDomain(PRCbitStream &pbs);
+ PRCVector2d min;
+ PRCVector2d max;
+};
+
+class PRCInterval
+{
+public:
+ PRCInterval() : min(0), max(0) {}
+ PRCInterval(double m, double M) : min(m), max(M) {}
+ void serializeInterval(PRCbitStream &pbs);
+ double min;
+ double max;
+};
+
+class PRCParameterization
+{
+public:
+ PRCParameterization() : parameterization_coeff_a(1), parameterization_coeff_b(0) {}
+ PRCParameterization(double min, double max) : interval(min, max), parameterization_coeff_a(1), parameterization_coeff_b(0) {}
+ void serializeParameterization(PRCbitStream &pbs);
+ PRCInterval interval;
+ double parameterization_coeff_a;
+ double parameterization_coeff_b;
+};
+
+class PRCUVParameterization
+{
+public:
+ PRCUVParameterization() : swap_uv(false),
+ parameterization_on_u_coeff_a(1), parameterization_on_v_coeff_a(1),
+ parameterization_on_u_coeff_b(0), parameterization_on_v_coeff_b(0) {}
+ void serializeUVParameterization(PRCbitStream &pbs);
+ bool swap_uv;
+ PRCDomain uv_domain;
+ double parameterization_on_u_coeff_a;
+ double parameterization_on_v_coeff_a;
+ double parameterization_on_u_coeff_b;
+ double parameterization_on_v_coeff_b;
+};
+
+class PRCControlPoint
+{
+public:
+ PRCControlPoint() :
+ x(0), y(0), z(0), w(1) {}
+ PRCControlPoint(double X, double Y, double Z=0, double W=1) :
+ x(X), y(Y), z(Z), w(W) {}
+ PRCControlPoint(const PRCVector3d &v) :
+ x(v.x), y(v.y), z(v.z), w(1) {}
+ void Set(double fx, double fy, double fz, double fw=1)
+ { x = fx; y = fy; z = fz; w = fw; }
+ double x;
+ double y;
+ double z;
+ double w;
+};
+
+class PRCContentSurface: public PRCBaseGeometry
+{
+public:
+ PRCContentSurface() :
+ PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone) {}
+ PRCContentSurface(std::string n) :
+ PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone) {}
+ void serializeContentSurface(PRCbitStream&);
+ EPRCExtendType extend_info;
+};
+
+class PRCSurface : public PRCContentSurface
+{
+public:
+ PRCSurface() :
+ PRCContentSurface() {}
+ PRCSurface(std::string n) :
+ PRCContentSurface(n) {}
+ virtual void serializeSurface(PRCbitStream &pbs) = 0;
+};
+typedef std::tr1::shared_ptr <PRCSurface> PRCpSurface;
+typedef std::vector <PRCpSurface> PRCSurfaceList;
+
+class PRCNURBSSurface : public PRCSurface
+{
+public:
+ PRCNURBSSurface() :
+ PRCSurface(), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {}
+ PRCNURBSSurface(std::string n) :
+ PRCSurface(n), knot_type(KEPRCKnotTypeUnspecified), surface_form(KEPRCBSplineSurfaceFormUnspecified) {}
+ void serializeNURBSSurface(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeNURBSSurface(pbs); }
+ bool is_rational;
+ uint32_t degree_in_u;
+ uint32_t degree_in_v;
+ std::vector<PRCControlPoint> control_point;
+ std::vector<double> knot_u;
+ std::vector<double> knot_v;
+ const EPRCKnotType knot_type;
+ const EPRCBSplineSurfaceForm surface_form;
+};
+
+class PRCContentCurve: public PRCBaseGeometry
+{
+public:
+ PRCContentCurve() :
+ PRCBaseGeometry(), extend_info(KEPRCExtendTypeNone), is_3d(true) {}
+ PRCContentCurve(std::string n) :
+ PRCBaseGeometry(&EMPTY_ATTRIBUTES,n,makeCADID()),extend_info(KEPRCExtendTypeNone), is_3d(true) {}
+ void serializeContentCurve(PRCbitStream&);
+ EPRCExtendType extend_info;
+ bool is_3d;
+};
+
+class PRCCurve : public PRCContentCurve
+{
+public:
+ PRCCurve() :
+ PRCContentCurve() {}
+ PRCCurve(std::string n) :
+ PRCContentCurve(n) {}
+ virtual void serializeCurve(PRCbitStream &pbs) = 0;
+};
+typedef std::tr1::shared_ptr <PRCCurve> PRCpCurve;
+typedef std::vector <PRCpCurve> PRCCurveList;
+
+class PRCNURBSCurve : public PRCCurve
+{
+public:
+ PRCNURBSCurve() :
+ PRCCurve(), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {}
+ PRCNURBSCurve(std::string n) :
+ PRCCurve(n), knot_type(KEPRCKnotTypeUnspecified), curve_form(KEPRCBSplineCurveFormUnspecified) {}
+ void serializeNURBSCurve(PRCbitStream &pbs);
+ void serializeCurve(PRCbitStream &pbs) { serializeNURBSCurve(pbs); }
+ bool is_rational;
+ uint32_t degree;
+ std::vector<PRCControlPoint> control_point;
+ std::vector<double> knot;
+ const EPRCKnotType knot_type;
+ const EPRCBSplineCurveForm curve_form;
+};
+
+class PRCPolyLine : public PRCCurve, public PRCTransformation, public PRCParameterization
+{
+public:
+ PRCPolyLine() :
+ PRCCurve() {}
+ PRCPolyLine(std::string n) :
+ PRCCurve(n) {}
+ void serializePolyLine(PRCbitStream &pbs);
+ void serializeCurve(PRCbitStream &pbs) { serializePolyLine(pbs); }
+ std::vector<PRCVector3d> point;
+};
+
+class PRCCircle : public PRCCurve, public PRCTransformation, public PRCParameterization
+{
+public:
+ PRCCircle() :
+ PRCCurve(), PRCParameterization(0,2*pi) {}
+ PRCCircle(std::string n) :
+ PRCCurve(n), PRCParameterization(0,2*pi) {}
+ void serializeCircle(PRCbitStream &pbs);
+ void serializeCurve(PRCbitStream &pbs) { serializeCircle(pbs); }
+ double radius;
+};
+
+class PRCComposite : public PRCCurve, public PRCTransformation, public PRCParameterization
+{
+public:
+ PRCComposite() :
+ PRCCurve() {}
+ PRCComposite(std::string n) :
+ PRCCurve(n) {}
+ void serializeComposite(PRCbitStream &pbs);
+ void serializeCurve(PRCbitStream &pbs) { serializeComposite(pbs); }
+ PRCCurveList base_curve;
+ std::vector<bool> base_sense;
+ bool is_closed;
+};
+
+class PRCBlend01 : public PRCSurface, public PRCTransformation, public PRCUVParameterization
+{
+public:
+ PRCBlend01() :
+ PRCSurface() {}
+ PRCBlend01(std::string n) :
+ PRCSurface(n) {}
+ void serializeBlend01(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeBlend01(pbs); }
+ void setCenterCurve(PRCCurve *curve) { center_curve.reset(curve); }
+ void setOriginCurve(PRCCurve *curve) { origin_curve.reset(curve); }
+ void setTangentCurve(PRCCurve *curve) { tangent_curve.reset(curve); }
+ PRCpCurve center_curve;
+ PRCpCurve origin_curve;
+ PRCpCurve tangent_curve;
+};
+
+class PRCRuled : public PRCSurface, public PRCTransformation, public PRCUVParameterization
+{
+public:
+ PRCRuled() :
+ PRCSurface() {}
+ PRCRuled(std::string n) :
+ PRCSurface(n) {}
+ void serializeRuled(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeRuled(pbs); }
+ void setFirstCurve(PRCCurve *curve) { first_curve.reset(curve); }
+ void setSecondCurve(PRCCurve *curve) { second_curve.reset(curve); }
+ PRCpCurve first_curve;
+ PRCpCurve second_curve;
+};
+
+class PRCSphere : public PRCSurface, public PRCTransformation, public PRCUVParameterization
+{
+public:
+ PRCSphere() :
+ PRCSurface() {}
+ PRCSphere(std::string n) :
+ PRCSurface(n) {}
+ void serializeSphere(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeSphere(pbs); }
+ double radius;
+};
+
+class PRCCylinder : public PRCSurface, public PRCTransformation, public PRCUVParameterization
+{
+public:
+ PRCCylinder() :
+ PRCSurface() {}
+ PRCCylinder(std::string n) :
+ PRCSurface(n) {}
+ void serializeCylinder(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeCylinder(pbs); }
+ double radius;
+};
+
+class PRCTorus : public PRCSurface, public PRCTransformation, public PRCUVParameterization
+{
+public:
+ PRCTorus() :
+ PRCSurface() {}
+ PRCTorus(std::string n) :
+ PRCSurface(n) {}
+ void serializeTorus(PRCbitStream &pbs);
+ void serializeSurface(PRCbitStream &pbs) { serializeTorus(pbs); }
+ double major_radius;
+ double minor_radius;
+};
+
+class PRCBaseTopology
+{
+public:
+ PRCBaseTopology() :
+ base_information(false),attributes(NULL),identifier(0) {}
+ PRCBaseTopology(Attributes *a, std::string n="", uint32_t id = 0) :
+ base_information(true),attributes(a),name(n),identifier(id) {}
+ void serializeBaseTopology(PRCbitStream&);
+ bool base_information;
+ Attributes *attributes;
+ std::string name;
+ uint32_t identifier;
+};
+
+class PRCTopoItem
+{
+public:
+ virtual void serializeTopoItem(PRCbitStream&)=0;
+};
+typedef std::tr1::shared_ptr <PRCTopoItem> PRCpTopoItem;
+
+class PRCContentBody: public PRCBaseTopology
+{
+public:
+ PRCContentBody() :
+ PRCBaseTopology(), behavior(0) {}
+ PRCContentBody(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), behavior(0) {}
+ void serializeContentBody(PRCbitStream&);
+ uint8_t behavior;
+};
+
+class PRCBody : public PRCContentBody, public PRCTopoItem
+{
+public:
+ PRCBody() :
+ PRCContentBody(), topo_item_type(PRC_TYPE_ROOT) {}
+ PRCBody(uint32_t tit) :
+ PRCContentBody(), topo_item_type(tit) {}
+ PRCBody(uint32_t tit, std::string n) :
+ PRCContentBody(n), topo_item_type(tit) {}
+ virtual void serializeBody(PRCbitStream &pbs) = 0;
+ void serializeTopoItem(PRCbitStream &pbs) { serializeBody(pbs); }
+ uint32_t serialType() { return topo_item_type; }
+ virtual double serialTolerance() { return 0; }
+ const uint32_t topo_item_type;
+};
+typedef std::tr1::shared_ptr <PRCBody> PRCpBody;
+typedef std::vector <PRCpBody> PRCBodyList;
+
+class PRCContentWireEdge : public PRCBaseTopology
+{
+public:
+ PRCContentWireEdge() :
+ PRCBaseTopology(), has_curve_trim_interval(false) {}
+ PRCContentWireEdge(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), has_curve_trim_interval(false) {}
+ void serializeContentWireEdge(PRCbitStream &pbs);
+ void setCurve(PRCCurve *pCurve) { curve_3d.reset(pCurve); }
+ void setCurve(PRCpCurve pCurve) { curve_3d = pCurve; }
+ PRCpCurve curve_3d;
+ bool has_curve_trim_interval;
+ PRCInterval curve_trim_interval;
+};
+
+class PRCWireEdge : public PRCContentWireEdge, public PRCTopoItem
+{
+public:
+ void serializeWireEdge(PRCbitStream &pbs);
+ void serializeTopoItem(PRCbitStream &pbs) { serializeWireEdge(pbs); }
+};
+
+class PRCSingleWireBody : public PRCBody
+{
+public:
+ PRCSingleWireBody() :
+ PRCBody(PRC_TYPE_TOPO_SingleWireBody) {}
+ PRCSingleWireBody(std::string n) :
+ PRCBody(PRC_TYPE_TOPO_SingleWireBody, n) {}
+ void serializeSingleWireBody(PRCbitStream &pbs);
+ void serializeBody(PRCbitStream &pbs) { serializeSingleWireBody(pbs); }
+ void setWireEdge(PRCWireEdge *wireEdge);
+// void setEdge(const PRCEdge &edge);
+ PRCpTopoItem wire_edge;
+};
+
+class PRCFace : public PRCBaseTopology, public PRCTopoItem, public PRCGraphics
+{
+public:
+ PRCFace() :
+ PRCBaseTopology(), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
+ PRCFace(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {}
+ void serializeFace(PRCbitStream &pbs);
+ void serializeTopoItem(PRCbitStream &pbs) { serializeFace(pbs); }
+ void setSurface(PRCSurface *pSurface) { base_surface.reset(pSurface); }
+ PRCpSurface base_surface;
+ const bool have_surface_trim_domain;
+ PRCDomain surface_trim_domain;
+ const bool have_tolerance;
+ const double tolerance;
+ const uint32_t number_of_loop;
+ const int32_t outer_loop_index;
+// PRCLoopList loop;
+};
+typedef std::tr1::shared_ptr <PRCFace> PRCpFace;
+typedef std::vector <PRCpFace> PRCFaceList;
+
+class PRCShell : public PRCBaseTopology, public PRCTopoItem
+{
+public:
+ PRCShell() :
+ PRCBaseTopology(), shell_is_closed(false) {}
+ PRCShell(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), shell_is_closed(false) {}
+ void serializeShell(PRCbitStream &pbs);
+ void serializeTopoItem(PRCbitStream &pbs) { serializeShell(pbs); }
+ void addFace(PRCFace *pFace, uint8_t orientation=2);
+ void addFace(const PRCpFace &pFace, uint8_t orientation=2);
+ bool shell_is_closed;
+ PRCFaceList face;
+ std::vector<uint8_t> orientation_surface_with_shell;
+};
+typedef std::tr1::shared_ptr <PRCShell> PRCpShell;
+typedef std::vector <PRCpShell> PRCShellList;
+
+class PRCConnex : public PRCBaseTopology, public PRCTopoItem
+{
+public:
+ PRCConnex() :
+ PRCBaseTopology() {}
+ PRCConnex(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()) {}
+ void serializeConnex(PRCbitStream &pbs);
+ void serializeTopoItem(PRCbitStream &pbs) { serializeConnex(pbs); }
+ void addShell(PRCShell *pShell);
+ PRCShellList shell;
+};
+typedef std::tr1::shared_ptr <PRCConnex> PRCpConnex;
+typedef std::vector <PRCpConnex> PRCConnexList;
+
+class PRCBrepData : public PRCBody, public PRCBoundingBox
+{
+public:
+ PRCBrepData() :
+ PRCBody(PRC_TYPE_TOPO_BrepData) {}
+ PRCBrepData(std::string n) :
+ PRCBody(PRC_TYPE_TOPO_BrepData, n) {}
+ void serializeBrepData(PRCbitStream &pbs);
+ void serializeBody(PRCbitStream &pbs) { serializeBrepData(pbs); }
+ void addConnex(PRCConnex *pConnex);
+ PRCConnexList connex;
+};
+
+// For now - treat just the case of Bezier surfaces cubic 4x4 or linear 2x2
+class PRCCompressedFace : public PRCBaseTopology, public PRCGraphics
+{
+public:
+ PRCCompressedFace() :
+ PRCBaseTopology(), orientation_surface_with_shell(true), degree(0) {}
+ PRCCompressedFace(std::string n) :
+ PRCBaseTopology(&EMPTY_ATTRIBUTES,n,makeCADID()), orientation_surface_with_shell(true), degree(0) {}
+ void serializeCompressedFace(PRCbitStream &pbs, double brep_data_compressed_tolerance);
+ void serializeContentCompressedFace(PRCbitStream &pbs);
+ void serializeCompressedAnaNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance);
+ void serializeCompressedNurbs(PRCbitStream &pbs, double brep_data_compressed_tolerance);
+ bool orientation_surface_with_shell;
+ uint32_t degree;
+ std::vector<PRCVector3d> control_point;
+};
+typedef std::tr1::shared_ptr <PRCCompressedFace> PRCpCompressedFace;
+typedef std::vector <PRCpCompressedFace> PRCCompressedFaceList;
+
+// For now - treat just the case of one connex/one shell
+class PRCCompressedBrepData : public PRCBody
+{
+public:
+ PRCCompressedBrepData() :
+ PRCBody(PRC_TYPE_TOPO_BrepDataCompress), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
+ PRCCompressedBrepData(std::string n) :
+ PRCBody(PRC_TYPE_TOPO_BrepDataCompress, n), serial_tolerance(0), brep_data_compressed_tolerance(0) {}
+ void serializeCompressedBrepData(PRCbitStream &pbs);
+ void serializeBody(PRCbitStream &pbs) { serializeCompressedBrepData(pbs); }
+ void serializeCompressedShell(PRCbitStream &pbs);
+ double serialTolerance() { return serial_tolerance; }
+ double serial_tolerance;
+ double brep_data_compressed_tolerance;
+ PRCCompressedFaceList face;
+};
+
+class PRCTopoContext : public ContentPRCBase
+{
+public:
+ PRCTopoContext(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n), behaviour(0), /* granularity(0), */ tolerance(0),
+ have_smallest_face_thickness(false), smallest_thickness(0), have_scale(false), scale(1) {}
+ void serializeTopoContext(PRCbitStream&);
+ void serializeContextAndBodies(PRCbitStream&);
+ void serializeGeometrySummary(PRCbitStream&);
+ void serializeContextGraphics(PRCbitStream&);
+ uint32_t addSingleWireBody(PRCSingleWireBody *body);
+ uint32_t addBrepData(PRCBrepData *body);
+ uint32_t addCompressedBrepData(PRCCompressedBrepData *body);
+ uint8_t behaviour;
+ double granularity;
+ double tolerance;
+ bool have_smallest_face_thickness;
+ double smallest_thickness;
+ bool have_scale;
+ double scale;
+ PRCBodyList body;
+};
+typedef std::tr1::shared_ptr <PRCTopoContext> PRCpTopoContext;
+typedef std::vector <PRCpTopoContext> PRCTopoContextList;
+
+class PRCUniqueId
+{
+public:
+ PRCUniqueId() : unique_id0(0), unique_id1(0), unique_id2(0), unique_id3(0) {}
+ void serializeCompressedUniqueId(PRCbitStream&);
+ uint32_t unique_id0;
+ uint32_t unique_id1;
+ uint32_t unique_id2;
+ uint32_t unique_id3;
+};
+
+class PRCUnit
+{
+public:
+ PRCUnit() : unit_from_CAD_file(false), unit(1) {}
+ void serializeUnit(PRCbitStream&);
+ bool unit_from_CAD_file;
+ double unit;
+};
+
+class PRCProductOccurrence: public PRCGraphics, public ContentPRCBase
+{
+public:
+ PRCProductOccurrence(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()),
+ index_part(m1),
+ index_prototype(m1), prototype_in_same_file_structure(true),
+ index_external_data(m1), external_data_in_same_file_structure(true),
+ product_behaviour(0), product_information_flags(0), product_load_status(KEPRCProductLoadStatus_Loaded),
+ has_location(false) {}
+ void serializeProductOccurrence(PRCbitStream&);
+ uint32_t index_part;
+ uint32_t index_prototype;
+ bool prototype_in_same_file_structure;
+ PRCUniqueId prototype_file_structure;
+ uint32_t index_external_data;
+ bool external_data_in_same_file_structure;
+ PRCUniqueId external_data_file_structure;
+ std::vector<uint32_t> index_son_occurrence;
+ uint8_t product_behaviour;
+ PRCUnit unit_information;
+ uint8_t product_information_flags;
+ EPRCProductLoadStatus product_load_status;
+ bool has_location;
+ PRCpGeneralTransformation3d location;
+};
+typedef std::tr1::shared_ptr <PRCProductOccurrence> PRCpProductOccurrence;
+typedef std::vector <PRCpProductOccurrence> PRCProductOccurrenceList;
+
+class PRCPartDefinition: public PRCGraphics, public ContentPRCBase, public PRCBoundingBox
+{
+public:
+ PRCPartDefinition(std::string n="") :
+ ContentPRCBase(&EMPTY_ATTRIBUTES,n,true,makeCADID(),0,makePRCID()) {}
+ void serializePartDefinition(PRCbitStream&);
+ uint32_t addBrepModel(PRCBrepModel *pBrepModel);
+ uint32_t addPolyBrepModel(PRCPolyBrepModel *pPolyBrepModel);
+ uint32_t addPointSet(PRCPointSet *pPointSet);
+ uint32_t addSet(PRCSet *pSet);
+ uint32_t addWire(PRCWire *pWire);
+ uint32_t addPolyWire(PRCPolyWire *pPolyWire);
+ uint32_t addRepresentationItem(PRCRepresentationItem *pRepresentationItem);
+ uint32_t addRepresentationItem(PRCpRepresentationItem pRepresentationItem);
+ PRCRepresentationItemList representation_item;
+};
+typedef std::tr1::shared_ptr <PRCPartDefinition> PRCpPartDefinition;
+typedef std::vector <PRCpPartDefinition> PRCPartDefinitionList;
#endif //__WRITE_PRC_H