1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
// Created by: CKY / Contract Toubro-Larsen
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//--------------------------------------------------------------------
//--------------------------------------------------------------------
#include <IGESDraw_ToolDrawingWithRotation.ixx>
#include <IGESData_ParamCursor.hxx>
#include <IGESData_IGESEntity.hxx>
#include <IGESData_ViewKindEntity.hxx>
#include <gp_XY.hxx>
#include <gp_Pnt2d.hxx>
#include <IGESData_HArray1OfIGESEntity.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_HArray1OfXY.hxx>
#include <IGESDraw_HArray1OfViewKindEntity.hxx>
#include <IGESData_Dump.hxx>
#include <IGESDraw_View.hxx>
#include <IGESDraw_PerspectiveView.hxx>
#include <Interface_Macros.hxx>
IGESDraw_ToolDrawingWithRotation::IGESDraw_ToolDrawingWithRotation () { }
void IGESDraw_ToolDrawingWithRotation::ReadOwnParams
(const Handle(IGESDraw_DrawingWithRotation)& ent,
const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
{
//Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
Standard_Integer nbval;
Handle(IGESDraw_HArray1OfViewKindEntity) views;
Handle(TColgp_HArray1OfXY) viewOrigins;
Handle(TColStd_HArray1OfReal) orientationAngles;
Handle(IGESData_HArray1OfIGESEntity) annotations;
// Reading nbval(Count of Array Views)
Standard_Boolean st = PR.ReadInteger(PR.Current(), "count of array views", nbval);
if (st && nbval > 0)
{
views = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
viewOrigins = new TColgp_HArray1OfXY(1, nbval);
orientationAngles = new TColStd_HArray1OfReal(1, nbval);
Handle(IGESData_ViewKindEntity) tempView;
gp_XY tempXY;
Standard_Real tempOrient;
for (Standard_Integer i = 1; i <= nbval; i++)
{
// Reading views(HArray1OfView)
//st = PR.ReadEntity (IR, PR.Current(), "Instance of views",
//STANDARD_TYPE(IGESData_ViewKindEntity), tempView,Standard_True); //szv#4:S4163:12Mar99 moved in if
if (PR.ReadEntity (IR, PR.Current(), "Instance of views",
STANDARD_TYPE(IGESData_ViewKindEntity), tempView,Standard_True))
views->SetValue(i, tempView);
// Reading viewOrigins(HArray1OfXY)
//st = PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY); //szv#4:S4163:12Mar99 moved in if
if (PR.ReadXY(PR.CurrentList(1, 2), "array viewOrigins", tempXY))
viewOrigins->SetValue(i, tempXY);
if (PR.DefinedElseSkip())
{
// Reading orientationAngles(HArray1OfReal)
//st = PR.ReadReal(PR.Current(), "array viewOrigins", tempOrient); //szv#4:S4163:12Mar99 moved in if
if (PR.ReadReal(PR.Current(), "array viewOrigins", tempOrient))
orientationAngles->SetValue(i, tempOrient);
}
else orientationAngles->SetValue(i, 0.0); // Default Value
}
}
else if (nbval <= 0)
PR.AddFail("Count of view entities : Not Positive");
// Reading nbval(No. of Annotation Entities)
//st = PR.ReadInteger(PR.Current(), "Count of array of Annotation entities", nbval); //szv#4:S4163:12Mar99 moved in if
if (PR.ReadInteger(PR.Current(), "Count of array of Annotation entities", nbval)) {
if ( nbval > 0 )
PR.ReadEnts (IR,PR.CurrentList(nbval), "Annotation Entities", annotations); //szv#4:S4163:12Mar99 `st=` not needed
/*
{
// Reading annotations(HArray1OfIGESEntity)
annotations = new IGESData_HArray1OfIGESEntity(1, nbval);
Handle(IGESData_IGESEntity) tempAnnotation;
for (Standard_Integer i = 1; i <= nbval; i++)
{
st = PR.ReadEntity
(IR, PR.Current(), "annotation entity", tempAnnotation,Standard_True);
if (st) annotations->SetValue(i, tempAnnotation);
}
}
*/
else if (nbval < 0)
PR.AddFail("Count of Annotation entities : Less than zero");
}
DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
ent->Init (views, viewOrigins, orientationAngles, annotations);
}
void IGESDraw_ToolDrawingWithRotation::WriteOwnParams
(const Handle(IGESDraw_DrawingWithRotation)& ent, IGESData_IGESWriter& IW) const
{
Standard_Integer Up = ent->NbViews();
IW.Send( Up );
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
for ( i = 1; i <= Up; i++)
{
IW.Send( ent->ViewItem(i) );
IW.Send( (ent->ViewOrigin(i)).X() );
IW.Send( (ent->ViewOrigin(i)).Y() );
IW.Send( ent->OrientationAngle(i) );
}
Up = ent->NbAnnotations();
IW.Send( Up );
for ( i = 1; i <= Up; i++)
IW.Send( ent->Annotation(i) );
}
void IGESDraw_ToolDrawingWithRotation::OwnShared
(const Handle(IGESDraw_DrawingWithRotation)& ent, Interface_EntityIterator& iter) const
{
Standard_Integer Up = ent->NbViews();
Standard_Integer i; // svv Jan 10 2000 : porting on DEC
for ( i = 1; i <= Up; i++)
iter.GetOneItem( ent->ViewItem(i) );
Up = ent->NbAnnotations();
for ( i = 1; i <= Up; i++)
iter.GetOneItem( ent->Annotation(i) );
}
void IGESDraw_ToolDrawingWithRotation::OwnCopy
(const Handle(IGESDraw_DrawingWithRotation)& another,
const Handle(IGESDraw_DrawingWithRotation)& ent, Interface_CopyTool& TC) const
{
Standard_Integer nbanot;
Standard_Integer nbval;
Handle(IGESDraw_HArray1OfViewKindEntity) views;
Handle(TColgp_HArray1OfXY) viewOrigins;
Handle(TColStd_HArray1OfReal) orientationAngles;
Handle(IGESData_HArray1OfIGESEntity) annotations;
nbanot = another->NbAnnotations();
nbval = another->NbViews();
views = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
viewOrigins = new TColgp_HArray1OfXY(1, nbval);
orientationAngles = new TColStd_HArray1OfReal(1, nbval);
if ( nbanot > 0 )
{
annotations = new IGESData_HArray1OfIGESEntity(1, nbanot);
for (Standard_Integer i = 1; i <= nbanot; i++)
{
DeclareAndCast(IGESData_IGESEntity, tempAnnotation,
TC.Transferred(another->Annotation(i)));
annotations->SetValue( i, tempAnnotation );
}
}
for (Standard_Integer i = 1; i <= nbval; i++)
{
DeclareAndCast(IGESData_ViewKindEntity, tempView,
TC.Transferred(another->ViewItem(i)));
views->SetValue( i, tempView );
viewOrigins->SetValue( i, (another->ViewOrigin(i)).XY() );
orientationAngles->SetValue( i, another->OrientationAngle(i) );
}
ent->Init(views, viewOrigins,orientationAngles, annotations);
}
Standard_Boolean IGESDraw_ToolDrawingWithRotation::OwnCorrect
(const Handle(IGESDraw_DrawingWithRotation)& ent ) const
{
// Vues vides : les supprimer
Standard_Integer i, nb = ent->NbViews();
Standard_Integer nbtrue = nb;
for (i = 1; i <= nb; i ++) {
Handle(IGESData_ViewKindEntity) val = ent->ViewItem(i);
if (val.IsNull()) nbtrue --;
else if (val->TypeNumber() == 0) nbtrue --;
}
if (nbtrue == nb) return Standard_False;
Handle(IGESDraw_HArray1OfViewKindEntity) views;
Handle(TColgp_HArray1OfXY) viewOrigins;
Handle(TColStd_HArray1OfReal) orientationAngles;
if (nbtrue > 0) {
views = new IGESDraw_HArray1OfViewKindEntity (1, nbtrue);
viewOrigins = new TColgp_HArray1OfXY(1, nbtrue);
orientationAngles = new TColStd_HArray1OfReal(1, nbtrue);
}
nbtrue = 0;
for (i = 1; i <= nb; i ++) {
Handle(IGESData_ViewKindEntity) val = ent->ViewItem(i);
if (val.IsNull()) continue;
else if (val->TypeNumber() == 0) continue;
nbtrue ++;
views->SetValue (nbtrue,val);
viewOrigins->SetValue (nbtrue, ent->ViewOrigin(i).XY() );
orientationAngles->SetValue (nbtrue,ent->OrientationAngle(i));
}
// Ne pas oublier les annotations ...
Standard_Integer nbanot = ent->NbAnnotations();
Handle(IGESData_HArray1OfIGESEntity) annotations =
new IGESData_HArray1OfIGESEntity(1, nbanot);
for (i = 1; i <= nbanot; i ++) annotations->SetValue (i,ent->Annotation(i));
ent->Init(views, viewOrigins,orientationAngles, annotations);
return Standard_True;
}
IGESData_DirChecker IGESDraw_ToolDrawingWithRotation::DirChecker
(const Handle(IGESDraw_DrawingWithRotation)& /*ent*/) const
{
IGESData_DirChecker DC (404, 1);
DC.Structure(IGESData_DefVoid);
DC.LineFont(IGESData_DefVoid);
DC.LineWeight(IGESData_DefVoid);
DC.Color(IGESData_DefVoid);
DC.BlankStatusIgnored();
DC.SubordinateStatusRequired(0);
DC.UseFlagRequired(1);
DC.HierarchyStatusIgnored();
return DC;
}
void IGESDraw_ToolDrawingWithRotation::OwnCheck
(const Handle(IGESDraw_DrawingWithRotation)& ent,
const Interface_ShareTool& , Handle(Interface_Check)& ach) const
{
Standard_Boolean ianul = Standard_False;
Standard_Integer i, nb = ent->NbViews();
for (i = 1; i <= nb; i ++) {
Handle(IGESData_ViewKindEntity) tempView = ent->ViewItem(i);
if (tempView.IsNull()) ianul = Standard_True;
else if (tempView->TypeNumber() == 0) ianul = Standard_True;
if (ianul) {
ach->AddWarning ("At least one View is Null");
break;
}
}
nb = ent->NbAnnotations();
for (i = 1; i <= nb; i ++) {
Handle(IGESData_IGESEntity) ann = ent->Annotation(i);
if (ann.IsNull()) ianul = Standard_True;
else if (ann->TypeNumber() == 0) ianul = Standard_True;
if (ianul) {
ach->AddWarning ("At least one Annotation is Null");
break;
}
}
}
void IGESDraw_ToolDrawingWithRotation::OwnDump
(const Handle(IGESDraw_DrawingWithRotation)& ent, const IGESData_IGESDumper& dumper,
const Handle(Message_Messenger)& S, const Standard_Integer level) const
{
Standard_Integer sublevel = (level <= 4) ? 0 : 1;
S << "IGESDraw_DrawingWithRotation" << endl;
S << "View Entities : " << endl
<< "Transformed View Origins : " << endl
<< "Orientation Angles : ";
S << "Count = " << ent->NbViews() << endl;
if (level > 4) // Level = 4 : no Dump. Level = 5 & 6 have same Dump
{
Standard_Integer I;
Standard_Integer up = ent->NbViews();
for (I = 1; I <= up; I++)
{
S << "[" << I << "]:" << endl;
S << "View Entity : ";
dumper.Dump (ent->ViewItem(I),S, sublevel);
S << endl;
S << "Transformed View Origin : ";
IGESData_DumpXY(S, ent->ViewOrigin(I));
S << " Orientation Angle : " << ent->OrientationAngle(I) << endl;
}
}
S << "Annotation Entities : ";
IGESData_DumpEntities(S,dumper ,level,1, ent->NbAnnotations(),ent->Annotation);
S << endl;
}
|