public override string ToString() { StringBuilder sb = new StringBuilder(); // mark start sb.AppendLine(((int)MessageCode.ENTITY_START).ToString()); // 0 sb.AppendLine(ComponentMessage.MESSAGE); // MESSAGE // message position in sequence sb.AppendLine(((int)MessageCode.MSG_POSITION).ToString()); sb.AppendLine(ComponentMessage.MessagePositionInSeqToString(this.msg_pos)); // parent component id sb.AppendLine(((int)MessageCode.MSG_COMP_PARENT_ID).ToString()); sb.AppendLine(this.comp_parent_id.ToString()); // ids of referenced components sb.AppendLine(((int)MessageCode.MSG_COMP_REF_IDS_SEQUENCE).ToString()); sb.AppendLine(this.comp_ref_ids.Count.ToString()); foreach (long id in this.comp_ref_ids) { sb.AppendLine(((int)MessageCode.MSG_COMP_REF_ID).ToString()); sb.AppendLine(id.ToString()); } // comp sb.AppendLine(((int)MessageCode.COMP_ID).ToString()); sb.AppendLine(this.comp_id.ToString()); sb.AppendLine(((int)MessageCode.COMP_AUTOM_GEN).ToString()); string tmp = (this.comp_automatically_generated) ? "1" : "0"; sb.AppendLine(tmp); sb.AppendLine(((int)MessageCode.COMP_DESCR).ToString()); sb.AppendLine(this.comp_descr); // comp parameters if (this.comp_params != null && this.comp_params.Count > 0) { sb.AppendLine(((int)MessageCode.PARAM_SEQUENCE).ToString()); sb.AppendLine(this.comp_params.Count.ToString()); foreach (var entry in this.comp_params) { sb.AppendLine(((int)MessageCode.PARAM_NAME).ToString()); sb.AppendLine(entry.Key); sb.AppendLine(((int)MessageCode.PARAM_VALUE).ToString()); sb.AppendLine(entry.Value.ToString(ComponentMessage.NR_FORMATTER)); } } // geometric relationships sb.AppendLine(((int)MessageCode.GR_SEQUENCE).ToString()); sb.AppendLine(this.geom_relationships.Count.ToString()); foreach (GeometricRelationship gr in this.geom_relationships) { sb.AppendLine(((int)MessageCode.GR_ID).ToString()); sb.AppendLine(gr.GrID.ToString()); sb.AppendLine(((int)MessageCode.GR_NAME).ToString()); sb.AppendLine(gr.GrName); sb.AppendLine(((int)MessageCode.GR_STATE_TYPE).ToString()); sb.AppendLine(GeometryUtils.Relationship2GeometryToString(gr.GrState.Type)); sb.AppendLine(((int)MessageCode.GR_STATE_ISREALIZED).ToString()); string tmp_gr = (gr.GrState.IsRealized) ? "1" : "0"; sb.AppendLine(tmp_gr); sb.AppendLine(((int)MessageCode.GR_GEOM_IDS_X).ToString()); sb.AppendLine(gr.GrIds.X.ToString()); sb.AppendLine(((int)MessageCode.GR_GEOM_IDS_Y).ToString()); sb.AppendLine(gr.GrIds.Y.ToString()); sb.AppendLine(((int)MessageCode.GR_GEOM_IDS_Z).ToString()); sb.AppendLine(gr.GrIds.Z.ToString()); sb.AppendLine(((int)MessageCode.GR_GEOM_IDS_W).ToString()); sb.AppendLine(gr.GrIds.W.ToString()); sb.AppendLine(((int)MessageCode.GR_GEOM_CS).ToString()); sb.AppendLine(gr.GrUCS.ToString(ComponentMessage.NR_FORMATTER)); // instance information sb.AppendLine(((int)MessageCode.GR_INST_SIZE).ToString()); sb.AppendLine(gr.InstSize.Count.ToString()); foreach (double entry in gr.InstSize) { sb.AppendLine(((int)MessageCode.GR_INST_VAL_X).ToString()); sb.AppendLine(entry.ToString(ComponentMessage.NR_FORMATTER)); } sb.AppendLine(((int)MessageCode.GR_INST_NWE_ID).ToString()); sb.AppendLine(gr.InstNWeId.ToString()); sb.AppendLine(((int)MessageCode.GR_INST_NWE_NAME).ToString()); sb.AppendLine(gr.InstNWeName); sb.AppendLine(((int)MessageCode.GR_INST_PATH).ToString()); sb.AppendLine(gr.InstPath.Count.ToString()); foreach (Point3D vertex in gr.InstPath) { sb.AppendLine(((int)MessageCode.GR_INST_VAL_X).ToString()); sb.AppendLine(vertex.X.ToString(ComponentMessage.NR_FORMATTER)); sb.AppendLine(((int)MessageCode.GR_INST_VAL_Y).ToString()); sb.AppendLine(vertex.Y.ToString(ComponentMessage.NR_FORMATTER)); sb.AppendLine(((int)MessageCode.GR_INST_VAL_Z).ToString()); sb.AppendLine(vertex.Z.ToString(ComponentMessage.NR_FORMATTER)); } // transforms sb.AppendLine(((int)MessageCode.GR_TRANSF_WC2LC).ToString()); sb.AppendLine(gr.GrTrWC2LC.ToString(ComponentMessage.NR_FORMATTER)); // SHOULD COME LAST! sb.AppendLine(((int)MessageCode.GR_TRANSF_LC2WC).ToString()); sb.AppendLine(gr.GrTrLC2WC.ToString(ComponentMessage.NR_FORMATTER)); } // structural info from the representations (for automatically generated components) sb.AppendLine(((int)MessageCode.MSG_COMP_REPRESENTATION_ID).ToString()); sb.AppendLine(this.comp_rep_id.ToString()); sb.AppendLine(((int)MessageCode.MSG_COMP_REPRESENTATION_PARENT_ID).ToString()); sb.AppendLine(this.comp_rep_parent_id.ToString()); // action to take on return to original sender sb.AppendLine(((int)MessageCode.MSG_COMP_ACTION).ToString()); sb.AppendLine(ComponentMessage.MessageActionToString(this.action_to_take)); // done sb.AppendLine(((int)MessageCode.ENTITY_START).ToString()); // 0 sb.AppendLine(ComponentMessage.END_OF_MESSAGE); // EOF return(sb.ToString()); }
private void ParseComponentMessage() { switch (this.FCode) { case (int)MessageCode.ENTITY_START: // start of entity ... do nothing break; case (int)MessageCode.MSG_POSITION: this.p_msg_pos = ComponentMessage.StringToMessagePositionInSeq(this.FValue); break; case (int)MessageCode.MSG_COMP_PARENT_ID: this.p_comp_parent_id = this.LongValue(); break; case (int)MessageCode.MSG_COMP_REPRESENTATION_ID: this.p_comp_repres_id = this.LongValue(); break; case (int)MessageCode.MSG_COMP_REPRESENTATION_PARENT_ID: this.p_comp_repres_parent_id = this.LongValue(); break; case (int)MessageCode.MSG_COMP_REF_IDS_SEQUENCE: this.nr_comp_ref_ids = this.IntValue(); break; case (int)MessageCode.MSG_COMP_REF_ID: if (this.nr_comp_ref_ids > this.nr_comp_ref_ids_read) { this.p_comp_ref_ids.Add(this.LongValue()); this.nr_comp_ref_ids_read++; } break; case (int)MessageCode.MSG_COMP_ACTION: this.p_msg_action_to_take = ComponentMessage.StringToMessageAction(this.FValue); break; case (int)MessageCode.COMP_ID: this.p_comp_id = this.LongValue(); break; case (int)MessageCode.COMP_AUTOM_GEN: this.p_comp_autom_gen = (this.IntValue() == 1); break; case (int)MessageCode.COMP_DESCR: this.p_comp_descr = this.FValue; break; case (int)MessageCode.PARAM_SEQUENCE: this.nr_comp_params = this.IntValue(); break; case (int)MessageCode.PARAM_NAME: this.param_name = this.FValue; break; case (int)MessageCode.PARAM_VALUE: if (!string.IsNullOrEmpty(this.param_name) && this.nr_comp_params > this.nr_comp_params_read) { double param_value = this.DoubleValue(); this.p_comp_params.Add(this.param_name, param_value); this.param_name = string.Empty; this.nr_comp_params_read++; } break; case (int)MessageCode.GR_SEQUENCE: this.nr_geom_relationships = this.IntValue(); break; case (int)MessageCode.GR_ID: this.p_gr_id = this.LongValue(); break; case (int)MessageCode.GR_NAME: this.p_gr_name = this.FValue; break; case (int)MessageCode.GR_STATE_TYPE: this.p_gr_state_type = GeometryUtils.StringToRelationship2Geometry(this.FValue); break; case (int)MessageCode.GR_STATE_ISREALIZED: this.p_gr_state_isRealized = (this.IntValue() == 1); break; case (int)MessageCode.GR_GEOM_IDS_X: this.p_gr_ids.X = this.IntValue(); break; case (int)MessageCode.GR_GEOM_IDS_Y: this.p_gr_ids.Y = this.IntValue(); break; case (int)MessageCode.GR_GEOM_IDS_Z: this.p_gr_ids.Z = this.IntValue(); break; case (int)MessageCode.GR_GEOM_IDS_W: this.p_gr_ids.W = this.IntValue(); break; case (int)MessageCode.GR_GEOM_CS: this.p_gr_ucs = Matrix3D.Parse(this.FValue); break; // instance information case (int)MessageCode.GR_INST_SIZE: this.pp_gr_nr_inst_size = this.IntValue(); break; case (int)MessageCode.GR_INST_NWE_ID: this.p_gr_inst_nwe_id = this.LongValue(); break; case (int)MessageCode.GR_INST_NWE_NAME: this.p_gr_inst_nwe_name = this.FValue; break; case (int)MessageCode.GR_INST_PATH: this.pp_gr_nr_inst_path = this.IntValue(); break; case (int)MessageCode.GR_INST_VAL_X: if (this.pp_gr_nr_inst_size > this.p_gr_inst_size.Count) { this.p_gr_inst_size.Add(this.DoubleValue()); } else if (this.pp_gr_nr_inst_path > this.p_gr_inst_path.Count) { this.pp_gr_inst_path_current_vertex.X = this.DoubleValue(); } break; case (int)MessageCode.GR_INST_VAL_Y: if (this.pp_gr_nr_inst_path > this.p_gr_inst_path.Count) { this.pp_gr_inst_path_current_vertex.Y = this.DoubleValue(); } break; case (int)MessageCode.GR_INST_VAL_Z: if (this.pp_gr_nr_inst_path > this.p_gr_inst_path.Count) { this.pp_gr_inst_path_current_vertex.Z = this.DoubleValue(); this.p_gr_inst_path.Add(this.pp_gr_inst_path_current_vertex); this.pp_gr_inst_path_current_vertex = new Point3D(0, 0, 0); } break; // transforms case (int)MessageCode.GR_TRANSF_WC2LC: this.p_gr_trWC2LC = Matrix3D.Parse(this.FValue); break; case (int)MessageCode.GR_TRANSF_LC2WC: // should come last for every GeometricRelationship this.p_gr_trLC2WC = Matrix3D.Parse(this.FValue); if (this.nr_geom_relationships > this.nr_geom_relationships_read) { Relation2GeomState gr_state = new Relation2GeomState { Type = this.p_gr_state_type, IsRealized = this.p_gr_state_isRealized }; GeometricRelationship gr = new GeometricRelationship(this.p_gr_id, this.p_gr_name, gr_state, this.p_gr_ids, this.p_gr_ucs, this.p_gr_trWC2LC, this.p_gr_trLC2WC, this.p_gr_inst_size, this.p_gr_inst_nwe_id, this.p_gr_inst_nwe_name, this.p_gr_inst_path); this.geom_relationships.Add(gr); this.nr_geom_relationships_read++; this.p_gr_inst_size = new List <double>(); this.p_gr_inst_path = new List <Point3D>(); } break; } }