summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prc/writePRC.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/prc/writePRC.cc')
-rw-r--r--Build/source/utils/asymptote/prc/writePRC.cc127
1 files changed, 100 insertions, 27 deletions
diff --git a/Build/source/utils/asymptote/prc/writePRC.cc b/Build/source/utils/asymptote/prc/writePRC.cc
index 9fbbc41013b..5f62ea6731e 100644
--- a/Build/source/utils/asymptote/prc/writePRC.cc
+++ b/Build/source/utils/asymptote/prc/writePRC.cc
@@ -150,6 +150,84 @@ bool PRCVector3d::Normalize()
return true;
}
+double PRCVector2d::Length()
+{
+ return sqrt(x*x+y*y);
+}
+
+bool PRCVector2d::Normalize()
+{
+ double fLength=Length();
+ if(fLength < FLT_EPSILON) return false;
+ double factor=1.0/fLength;
+ x *= factor;
+ y *= factor;
+
+ return true;
+}
+
+void PRCVector2d::serializeVector2d(PRCbitStream &pbs)
+{
+ WriteDouble (x)
+ WriteDouble (y)
+}
+
+uint32_t makeCADID()
+{
+ static uint32_t ID = 1;
+ return ID++;
+}
+
+uint32_t makePRCID()
+{
+ static uint32_t ID = 1;
+ return ID++;
+}
+
+bool type_eligible_for_reference(uint32_t type)
+{
+ if(
+ type == PRC_TYPE_MISC_EntityReference ||
+ type == PRC_TYPE_MISC_MarkupLinkedItem ||
+ type == PRC_TYPE_RI_BrepModel ||
+ type == PRC_TYPE_RI_Curve ||
+ type == PRC_TYPE_RI_Direction ||
+ type == PRC_TYPE_RI_Plane ||
+ type == PRC_TYPE_RI_PointSet ||
+ type == PRC_TYPE_RI_PolyBrepModel ||
+ type == PRC_TYPE_RI_PolyWire ||
+ type == PRC_TYPE_RI_Set ||
+ type == PRC_TYPE_RI_CoordinateSystem ||
+ type == PRC_TYPE_ASM_ProductOccurence ||
+ type == PRC_TYPE_ASM_PartDefinition ||
+ type == PRC_TYPE_ASM_Filter ||
+ type == PRC_TYPE_MKP_View ||
+ type == PRC_TYPE_MKP_Markup ||
+ type == PRC_TYPE_MKP_Leader ||
+ type == PRC_TYPE_MKP_AnnotationItem ||
+ type == PRC_TYPE_MKP_AnnotationSet ||
+ type == PRC_TYPE_MKP_AnnotationReference ||
+ type == PRC_TYPE_GRAPH_Style ||
+ type == PRC_TYPE_GRAPH_Material ||
+ type == PRC_TYPE_GRAPH_TextureApplication ||
+ type == PRC_TYPE_GRAPH_TextureDefinition ||
+ type == PRC_TYPE_GRAPH_LinePattern ||
+ type == PRC_TYPE_GRAPH_DottingPattern ||
+ type == PRC_TYPE_GRAPH_HatchingPattern ||
+ type == PRC_TYPE_GRAPH_SolidPattern ||
+ type == PRC_TYPE_GRAPH_VPicturePattern ||
+ type == PRC_TYPE_GRAPH_AmbientLight ||
+ type == PRC_TYPE_GRAPH_PointLight ||
+ type == PRC_TYPE_GRAPH_DirectionalLight ||
+ type == PRC_TYPE_GRAPH_SpotLight ||
+ type == PRC_TYPE_GRAPH_SceneDisplayParameters ||
+ type == PRC_TYPE_GRAPH_Camera
+ )
+ return true;
+ else
+ return false;
+}
+
void UserData::write(PRCbitStream &pbs)
{
pbs << size;
@@ -221,12 +299,12 @@ void PRCAttributes::serializeAttributes(PRCbitStream &pbs) const
}
}
-void ContentPRCBase::serializeContentPRCBase(PRCbitStream &pbs)
+void ContentPRCBase::serializeContentPRCBase(PRCbitStream &pbs) const
{
SerializeAttributeData
SerializeName (name)
- if (type_eligible_for_reference)
+ if (type_eligible_for_reference(type))
{
WriteUnsignedInteger (CAD_identifier)
WriteUnsignedInteger (CAD_persistent_identifier)
@@ -381,6 +459,21 @@ void PRCTextureApplication::serializeTextureApplication(PRCbitStream &pbs)
WriteUnsignedInteger (UV_coordinates_index+1)
}
+void PRCLinePattern::serializeLinePattern(PRCbitStream &pbs)
+{
+ uint32_t i = 0;
+ WriteUnsignedInteger (PRC_TYPE_GRAPH_LinePattern)
+ SerializeContentPRCBase
+
+ const uint32_t size_lengths = lengths.size();
+ WriteUnsignedInteger (size_lengths)
+ for (i=0;i<size_lengths;i++)
+ WriteDouble (lengths[i])
+ WriteDouble (phase)
+ WriteBoolean (is_real_length)
+}
+
+
void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
{
const bool is_additional_1_defined = (additional!=0);
@@ -410,9 +503,8 @@ void PRCStyle::serializeCategory1LineStyle(PRCbitStream &pbs)
WriteCharacter (additional_3)
}
-ContentPRCBase EMPTY_CONTENTPRCBASE;
-
std::string currentName;
+
void writeName(PRCbitStream &pbs,const std::string &name)
{
pbs << (name == currentName);
@@ -672,9 +764,8 @@ void PRCPolyWire::serializePolyWire(PRCbitStream &pbs)
void PRCGeneralTransformation3d::serializeGeneralTransformation3d(PRCbitStream &pbs) const
{
WriteUnsignedInteger (PRC_TYPE_MISC_GeneralTransformation)
- for (int j=0;j<4;j++)
- for (int i=0;i<4;i++)
- WriteDouble(mat[i][j]);
+ for (uint32_t i=0; i<16; i++)
+ WriteDouble(m_coef[i]);
}
void PRCCartesianTransformation3d::serializeCartesianTransformation3d(PRCbitStream &pbs) const
@@ -974,24 +1065,6 @@ void PRCMarkupTess::serializeMarkupTess(PRCbitStream &pbs)
WriteCharacter (behaviour)
}
-void PRCVector2d::serializeVector2d(PRCbitStream &pbs)
-{
- WriteDouble (x)
- WriteDouble (y)
-}
-
-uint32_t makeCADID()
-{
- static uint32_t ID = 1;
- return ID++;
-}
-
-uint32_t makePRCID()
-{
- static uint32_t ID = 1;
- return ID++;
-}
-
void writeUnit(PRCbitStream &out,bool fromCAD,double unit)
{
out << fromCAD << unit;
@@ -1300,7 +1373,7 @@ void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep
for(uint32_t i=0;i<number_of_control_point_in_u;i++)
for(uint32_t j=0;j<number_of_control_point_in_v;j++)
P[i][j] = control_point[i*number_of_control_point_in_v+j];
-#if defined(__GNUC__) && !defined(__clang__)
+#ifdef __GNUC__
itriple compressed_control_point[number_of_control_point_in_u][number_of_control_point_in_v];
uint32_t control_point_type[number_of_control_point_in_u][number_of_control_point_in_v];
#else
@@ -1367,7 +1440,7 @@ void PRCCompressedFace::serializeCompressedNurbs(PRCbitStream &pbs, double brep
if(x*x+y*y<nurbs_tolerance*nurbs_tolerance)
{
control_point_type[i][j] = 1;
- compressed_control_point[i][j] = iroundto(PRCVector3d(0,0,z), nurbs_tolerance);
+ compressed_control_point[i][j] = iroundto(PRCVector3d(0.0,0.0,z), nurbs_tolerance);
P[i][j] = P[i-1][j-1] + U + V + roundto(z, nurbs_tolerance)*Ne; // see above
}
else