@@ -85,23 +85,24 @@ public:
8585 const TopLoc_Location& Location () const { return myLocation; }
8686
8787 // ! Sets the shape local coordinate system.
88- void Location (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_True)
88+ // ! @param theLoc the new local coordinate system.
89+ // ! @param theRaiseExc flag to raise exception in case of transformation with scale or negative.
90+ void Location (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_False)
8991 {
9092 const gp_Trsf& aTrsf = theLoc.Transformation ();
91- if (( Abs ( Abs (aTrsf. ScaleFactor ()) - 1 .) > TopLoc_Location::ScalePrec () || aTrsf. IsNegative ()) && theRaiseExc)
93+ if (theRaiseExc)
9294 {
93- // Exception
94- throw Standard_DomainError (" Location with scaling transformation is forbidden" );
95- }
96- else
97- {
98- myLocation = theLoc;
95+ validateTransformation (aTrsf);
9996 }
97+ myLocation = theLoc;
10098 }
10199
102- // ! Returns a shape similar to <me> with the local
100+ // ! Returns a shape similar to <me> with the local
103101 // ! coordinate system set to <Loc>.
104- TopoDS_Shape Located (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_True) const
102+ // ! @param theLoc the new local coordinate system.
103+ // ! @param theRaiseExc flag to raise exception in case of transformation with scale or negative.
104+ // ! @return the located shape.
105+ TopoDS_Shape Located (const TopLoc_Location& theLoc, const Standard_Boolean theRaiseExc = Standard_False) const
105106 {
106107 TopoDS_Shape aShape (*this );
107108 aShape.Location (theLoc, theRaiseExc);
@@ -182,22 +183,23 @@ public:
182183 void Convex (Standard_Boolean theIsConvex) { myTShape->Convex (theIsConvex); }
183184
184185 // ! Multiplies the Shape location by thePosition.
185- void Move (const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_True)
186+ // ! @param thePosition the transformation to apply.
187+ // ! @param theRaiseExc flag to raise exception in case of transformation with scale or negative.
188+ void Move (const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_False)
186189 {
187190 const gp_Trsf& aTrsf = thePosition.Transformation ();
188- if (( Abs ( Abs (aTrsf. ScaleFactor ()) - 1 .) > TopLoc_Location::ScalePrec () || aTrsf. IsNegative ()) && theRaiseExc)
191+ if (theRaiseExc)
189192 {
190- // Exception
191- throw Standard_DomainError (" Moving with scaling transformation is forbidden" );
192- }
193- else
194- {
195- myLocation = thePosition * myLocation;
193+ validateTransformation (aTrsf);
196194 }
195+ myLocation = thePosition * myLocation;
197196 }
198197
199198 // ! Returns a shape similar to <me> with a location multiplied by thePosition.
200- TopoDS_Shape Moved (const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_True) const
199+ // ! @param thePosition the transformation to apply.
200+ // ! @param theRaiseExc flag to raise exception in case of transformation with scale or negative.
201+ // ! @return the moved shape.
202+ TopoDS_Shape Moved (const TopLoc_Location& thePosition, const Standard_Boolean theRaiseExc = Standard_False) const
201203 {
202204 TopoDS_Shape aShape (*this );
203205 aShape.Move (thePosition, theRaiseExc);
@@ -300,6 +302,20 @@ public:
300302 // ! Dumps the content of me into the stream
301303 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1 ) const ;
302304
305+ protected:
306+
307+ // ! Checks if the transformation contains scaling or negative values.
308+ // ! Raises an exception if the transformation is invalid.
309+ // ! @param theTrsf transformation to validate
310+ void validateTransformation (const gp_Trsf& theTrsf) const
311+ {
312+ if (Abs (Abs (theTrsf.ScaleFactor ()) - 1 .) > TopLoc_Location::ScalePrec () || theTrsf.IsNegative ())
313+ {
314+ // Exception
315+ throw Standard_DomainError (" Transformation with scaling transformation is forbidden" );
316+ }
317+ }
318+
303319private:
304320
305321 Handle (TopoDS_TShape) myTShape;
0 commit comments