1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 \class GEOM_AISShape GEOM_AISShape.hxx
28 #include "GEOM_AISShape.hxx"
29 #include "GEOM_AISVector.hxx"
31 #include <GEOMUtils.hxx>
33 #include <Basics_OCCTVersion.hxx>
35 // Open CASCADE Includes
36 #include <AIS_InteractiveContext.hxx>
37 #include <BRepAdaptor_Surface.hxx>
38 #include <BRep_Tool.hxx>
39 #include <GCPnts_AbscissaPoint.hxx>
40 #include <GeomAdaptor_Curve.hxx>
41 #include <Graphic3d_ArrayOfPoints.hxx>
42 #include <Graphic3d_AspectFillArea3d.hxx>
43 #include <Graphic3d_AspectLine3d.hxx>
44 #include <Graphic3d_AspectMarker3d.hxx>
45 #include <Graphic3d_AspectText3d.hxx>
46 #include <Prs3d_Arrow.hxx>
47 #include <Prs3d_IsoAspect.hxx>
48 #include <Prs3d_ShadingAspect.hxx>
49 #include <SelectBasics_SensitiveEntity.hxx>
50 #include <SelectMgr_EntityOwner.hxx>
51 #include <SelectMgr_IndexedMapOfOwner.hxx>
52 #include <SelectMgr_Selection.hxx>
53 #include <StdPrs_ShadedShape.hxx>
54 #include <StdSelect_BRepOwner.hxx>
55 #include <StdSelect_DisplayMode.hxx>
56 #include <TColStd_IndexedMapOfInteger.hxx>
57 #include <TColStd_ListIteratorOfListOfInteger.hxx>
58 #include <TColStd_ListOfInteger.hxx>
60 #include <TopExp_Explorer.hxx>
61 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <TopoDS_Edge.hxx>
64 #include <TopoDS_Shape.hxx>
65 #include <TopoDS_Vertex.hxx>
66 #include <V3d_View.hxx>
71 #if OCC_VERSION_LARGE > 0x06070200
72 #include <Prs3d_VertexDrawMode.hxx>
75 #if OCC_VERSION_MAJOR < 7
76 #include <StdPrs_WFDeflectionShape.hxx>
78 #include <StdPrs_WFShape.hxx>
81 #include <SalomeApp_Tools.h>
82 #include <SUIT_Session.h>
83 #include <SUIT_ResourceMgr.h>
85 OCCT_IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISShape, SALOME_AISShape)
87 GEOM_AISShape::TopLevelDispMode GEOM_AISShape::myTopLevelDm = GEOM_AISShape::TopKeepCurrent;
88 Quantity_Color GEOM_AISShape::myTopLevelColor;
91 static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
92 const Handle(AIS_InteractiveContext)& theIC,
93 SelectMgr_IndexedMapOfOwner& theMap )
95 if ( theObj.IsNull() || theIC.IsNull() )
98 TColStd_ListOfInteger modes;
99 theIC->ActivatedModes( theObj, modes );
101 TColStd_ListIteratorOfListOfInteger itr( modes );
102 for (; itr.More(); itr.Next() ) {
104 if ( !theObj->HasSelection( m ) )
107 Handle(SelectMgr_Selection) sel = theObj->Selection( m );
109 for ( sel->Init(); sel->More(); sel->Next() ) {
110 #if OCC_VERSION_LARGE > 0x06080100
111 const Handle(SelectMgr_SensitiveEntity) aHSenEntity = sel->Sensitive();
112 if( aHSenEntity.IsNull() )
115 Handle(SelectBasics_SensitiveEntity) entity = aHSenEntity->BaseSensitive();
117 Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive();
119 if ( entity.IsNull() )
121 Handle(SelectMgr_EntityOwner) owner =
122 Handle(SelectMgr_EntityOwner)::DownCast(entity->OwnerId());
123 if ( !owner.IsNull() )
129 static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap,
130 const TopoDS_Shape& aMainShape,
131 const SelectMgr_IndexedMapOfOwner& anAllMap,
132 SelectMgr_IndexedMapOfOwner& aToHiliteMap )
134 TopTools_IndexedMapOfShape aMapOfShapes;
135 TopExp::MapShapes(aMainShape, aMapOfShapes);
137 for ( Standard_Integer i = 1, n = anAllMap.Extent(); i <= n; i++ ) {
138 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(anAllMap( i ));
139 if ( anOwner.IsNull() || !anOwner->HasShape() )
142 const TopoDS_Shape& aSubShape = anOwner->Shape();
143 Standard_Integer aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
144 if ( !aSubShapeId || !aIndexMap.Contains( aSubShapeId ) )
147 if ( !aToHiliteMap.Contains( anOwner ) )
148 aToHiliteMap.Add( anOwner );
152 GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
153 const Standard_CString aName)
154 : SALOME_AISShape(shape),
156 myDisplayVectors(false),
157 myDisplayVertices(false),
158 myFieldDataType(GEOM::FDT_Double),
160 myFieldStepRangeMin(0),
161 myFieldStepRangeMax(0)
163 //rnv: Commented to avoid bug with local selection
164 //SetHilightMode( CustomHighlight ); // override setting the mode to 0 inside AIS_Shape constructor
166 myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
167 myPrevDisplayMode = 0;
169 myEdgesInShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
171 myTopLevel = Standard_False;
172 Graphic3d_MaterialAspect aMatAspect;
173 if ( !HasMaterial() ) {
174 aMatAspect.SetAmbient( 0.5 );
175 aMatAspect.SetDiffuse( 0.5 );
176 aMatAspect.SetEmissive( 0.5 );
177 aMatAspect.SetShininess(0.5 );
178 aMatAspect.SetSpecular( 0.5 );
180 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
181 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
185 GEOM_AISShape::~GEOM_AISShape()
189 void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
193 Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
194 Handle(SALOME_InteractiveObject) IO;
195 if ( !GetOwner().IsNull() )
196 IO = Handle(SALOME_InteractiveObject)::DownCast( GetOwner() );
200 Standard_Boolean GEOM_AISShape::hasIO(){
201 return !getIO().IsNull();
204 void GEOM_AISShape::setName(const Standard_CString aName)
208 Handle(SALOME_InteractiveObject) IO = getIO();
213 Standard_CString GEOM_AISShape::getName(){
214 return myName.ToCString();
217 void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
218 const Handle(Prs3d_Presentation)& aPrs,
219 const Standard_Integer aMode)
221 if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
223 Handle(AIS_InteractiveContext) anIC = GetContext();
224 // AKL: use old behavior to avoid keeping object's wireframe
225 // if to change shape properties (for example: 'Clear Top Level State','Color', 'Isos')
226 // calling popup menu over(!) the shape in OCC viewer.
227 anIC->SetToHilightSelected( false );
229 bool anIsField = !myFieldStepData.isEmpty();
230 bool anIsColorField = anIsField && myFieldDataType != GEOM::FDT_String;
231 bool anIsTextField = anIsField && myFieldDataType == GEOM::FDT_String;
233 #if OCC_VERSION_LARGE > 0x06070200
234 if (isShowVertices())
235 myDrawer->SetVertexDrawMode(Prs3d_VDM_All);
238 // StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
239 bool isTopLev = isTopLevel() && switchTopLevel();
242 case CustomHighlight:
245 SetColor(topLevelColor());
246 Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect();
247 anAspect->SetColor( topLevelColor() );
248 Attributes()->SetWireAspect( anAspect );
250 if( !isTopLev && anIsColorField && myFieldDimension == 1 )
251 drawField( aPrs, false, aMode == CustomHighlight );
253 #if OCC_VERSION_MAJOR < 7
254 StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
256 StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
262 shadingMode(aPresentationManager, aPrs, aMode);
265 case ShadingWithEdges:
267 myDrawer->SetFaceBoundaryDraw( Standard_True );
268 shadingMode(aPresentationManager, aPrs, Shading);
269 if( anIsColorField && myFieldDimension == 1 ) {
270 myDrawer->SetFaceBoundaryDraw( Standard_False );
277 #ifdef USE_TEXTURED_SHAPE
278 AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
280 AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
286 const bool isVector = IsKind(STANDARD_TYPE(GEOM_AISVector));
287 TopExp_Explorer Exp ( myshape, TopAbs_EDGE );
288 for ( ; Exp.More(); Exp.Next() ) {
289 TopoDS_Vertex aV1, aV2;
290 TopoDS_Edge anEdgeE = TopoDS::Edge(Exp.Current());
292 // draw curve direction (issue 0021087)
293 anEdgeE.Orientation( TopAbs_FORWARD );
295 if ( anEdgeE.IsNull() ) continue;
297 TopExp::Vertices(anEdgeE, aV1, aV2);
298 gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
299 gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
303 Handle(Geom_Curve) C = BRep_Tool::Curve(anEdgeE,fp,lp);
305 if ( C.IsNull() ) continue;
307 if ( anEdgeE.Orientation() == TopAbs_FORWARD )
308 C->D1(lp, aP2, aDirVec);
310 C->D1(fp, aP1, aDirVec);
314 GeomAdaptor_Curve aAdC;
315 aAdC.Load(C, fp, lp);
316 Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp);
318 if (aDist > gp::Resolution()) {
320 if ( anEdgeE.Orientation() == TopAbs_FORWARD )
325 Prs3d_Arrow::Draw(aPrs, aP2, aDir, M_PI/180.*5., aDist/10.);
330 // draw color field on vertices
331 if( anIsColorField && myFieldDimension == 0 && aMode != CustomHighlight )
336 drawField( aPrs, true );
341 // aPrs->ReCompute(); // for hidden line recomputation if necessary...
344 void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
346 myShadingColor = aCol;
349 void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
351 myEdgesInShadingColor = aCol;
354 void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol) {
358 void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap,
359 const Standard_Boolean aHighlight )
361 Handle(AIS_InteractiveObject) anObj = this;
362 Handle(AIS_InteractiveContext) anIC = GetContext();
363 if ( anIC.IsNull() || !anIC->HasOpenedContext() )
366 Standard_Boolean isAutoHilight = anIC->AutomaticHilight();
367 anIC->SetAutomaticHilight( false );
369 anIC->ClearSelected( false );
372 SelectMgr_IndexedMapOfOwner anAllMap, aToHiliteMap;
374 // Get entity owners for all activated selection modes
375 getEntityOwners( anObj, anIC, anAllMap );
377 // Convert <aIndexMap> into the map of owners to highlight/unhighlight
378 indicesToOwners( aIndexMap, Shape(), anAllMap, aToHiliteMap );
381 for ( Standard_Integer i = 1, n = aToHiliteMap.Extent(); i <= n; i++ )
382 anIC->AddOrRemoveSelected( aToHiliteMap( i ), false );
385 anIC->SetAutomaticHilight( isAutoHilight );
386 anIC->HilightSelected( false );
389 void GEOM_AISShape::SetDisplayVectors(bool isDisplayed)
391 myDisplayVectors = isDisplayed;
394 void GEOM_AISShape::SetDisplayVertices(bool isDisplayed)
396 myDisplayVertices = isDisplayed;
399 void GEOM_AISShape::SetDisplayName(bool isDisplayed)
401 myDisplayName = isDisplayed;
404 void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
405 const Handle(Prs3d_Presentation)& aPrs,
406 const Standard_Integer aMode)
408 myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
410 Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC);
411 aMatAspect.SetTransparency(Transparency());
412 Graphic3d_MaterialAspect currentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
413 Graphic3d_MaterialAspect currentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
414 myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : currentFrontMaterial );
415 myDrawer->ShadingAspect()->Aspect()->SetBackMaterial ( isTopLevel() ? aMatAspect : currentBackMaterial );
417 if( isTopLevel() && switchTopLevel() )
418 myDrawer->ShadingAspect()->SetColor( topLevelColor() );
420 if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT ))
421 myDrawer->ShadingAspect()->SetColor(myShadingColor);
423 myDrawer->ShadingAspect()->SetColor(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().AmbientColor());
426 bool anIsColorField = !myFieldStepData.isEmpty() && myFieldDataType != GEOM::FDT_String;
427 if( anIsColorField && ( myFieldDimension == 2 || myFieldDimension == 3 || myFieldDimension == -1 ) )
433 // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
434 //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
435 #ifdef USE_TEXTURED_SHAPE
436 AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
438 AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
443 Standard_Boolean GEOM_AISShape::isTopLevel() {
447 void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
450 myPrevDisplayMode = DisplayMode();
452 switch(topLevelDisplayMode()) {
453 case TopWireFrame : dm = Wireframe; break;
454 case TopShading : dm = Shading; break;
455 case TopShadingWithEdges : dm = ShadingWithEdges; break;
456 default : dm = myPrevDisplayMode; break;
461 SetDisplayMode(myPrevDisplayMode);
466 void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode) {
467 myPrevDisplayMode = mode;
470 Quantity_Color GEOM_AISShape::topLevelColor() {
471 return myTopLevelColor;
474 void GEOM_AISShape::setTopLevelColor(const Quantity_Color c) {
478 GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode() {
481 void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm) {
485 Standard_Boolean GEOM_AISShape::switchTopLevel() {
486 return myTopLevelDm != TopShowAdditionalWActor;
489 Standard_Boolean GEOM_AISShape::toActivate() {
490 return ( myTopLevel && myTopLevelDm == TopShowAdditionalWActor ) ? false : true;
493 void GEOM_AISShape::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
494 const int theFieldDimension,
495 const QList<QVariant>& theFieldStepData,
496 const TCollection_AsciiString& theFieldStepName,
497 const double theFieldStepRangeMin,
498 const double theFieldStepRangeMax )
500 myFieldDataType = theFieldDataType;
501 myFieldDimension = theFieldDimension;
502 myFieldStepData = theFieldStepData;
503 myFieldStepName = theFieldStepName;
504 myFieldStepRangeMin = theFieldStepRangeMin;
505 myFieldStepRangeMax = theFieldStepRangeMax;
508 void GEOM_AISShape::getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
509 int& theFieldDimension,
510 QList<QVariant>& theFieldStepData,
511 TCollection_AsciiString& theFieldStepName,
512 double& theFieldStepRangeMin,
513 double& theFieldStepRangeMax ) const
515 theFieldDataType = myFieldDataType;
516 theFieldDimension = myFieldDimension;
517 theFieldStepData = myFieldStepData;
518 theFieldStepName = myFieldStepName;
519 theFieldStepRangeMin = myFieldStepRangeMin;
520 theFieldStepRangeMax = myFieldStepRangeMax;
523 void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
524 const bool theIsString,
525 const bool theIsHighlight )
527 if( myFieldStepData.isEmpty() )
530 QListIterator<QVariant> aFieldStepDataIter( myFieldStepData );
532 TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
533 switch( myFieldDimension )
535 case 0: aShapeType = TopAbs_VERTEX; break;
536 case 1: aShapeType = TopAbs_EDGE; break;
537 case 2: aShapeType = TopAbs_FACE; break;
538 case 3: aShapeType = TopAbs_SOLID; break;
539 case -1: aShapeType = TopAbs_VERTEX; break;
542 TopTools_IndexedMapOfShape aShapeMap;
543 TopExp::MapShapes( myshape, aShapeMap );
545 TColStd_IndexedMapOfInteger anIndexMap;
547 TopExp_Explorer anExp;
548 for( anExp.Init( myshape, aShapeType ); anExp.More(); anExp.Next() )
550 TopoDS_Shape aSubShape = anExp.Current();
551 if( !aSubShape.IsNull() )
553 Standard_Integer aSubShapeIndex = aShapeMap.FindIndex( aSubShape );
554 if( anIndexMap.Contains( aSubShapeIndex ) )
557 anIndexMap.Add( aSubShapeIndex );
559 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup( thePrs );
563 if( aFieldStepDataIter.hasNext() )
565 const QVariant& aVariant = aFieldStepDataIter.next();
567 aString = aVariant.toString();
569 aQColor = aVariant.value<QColor>();
577 if( computeMassCenter( aSubShape, aCenter ) )
579 Graphic3d_Vertex aVertex( aCenter.X(), aCenter.Y(), aCenter.Z() );
581 Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
582 anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
583 anAspectText3d->SetColor( myLabelColor );
584 aGroup->SetPrimitivesAspect( anAspectText3d );
586 aGroup->Text( aString.toLatin1().constData(), aVertex, 14 );
591 Quantity_Color aColor( aQColor.redF(), aQColor.greenF(), aQColor.blueF(), Quantity_TOC_RGB );
592 if( myFieldDimension == 0 )
594 TopoDS_Vertex aVertexShape = TopoDS::Vertex( aSubShape );
595 if( !aVertexShape.IsNull() )
597 gp_Pnt aPnt = BRep_Tool::Pnt( aVertexShape );
599 Handle(Graphic3d_AspectMarker3d) anAspectMarker3d = new Graphic3d_AspectMarker3d();
600 anAspectMarker3d->SetColor( aColor );
601 anAspectMarker3d->SetType( Aspect_TOM_POINT );
602 anAspectMarker3d->SetScale( 10.0 );
603 aGroup->SetPrimitivesAspect( anAspectMarker3d );
605 Handle(Graphic3d_ArrayOfPoints) anArray = new Graphic3d_ArrayOfPoints( 1 );
606 anArray->AddVertex( aPnt.X(), aPnt.Y(), aPnt.Z() );
608 aGroup->AddPrimitiveArray( anArray );
611 else if( myFieldDimension == 1 )
613 myDrawer->WireAspect()->SetColor( aColor );
615 myDrawer->WireAspect()->SetWidth( myOwnWidth );
617 myDrawer->WireAspect()->SetWidth( myOwnWidth + 4 );
618 #if OCC_VERSION_MAJOR < 7
619 StdPrs_WFDeflectionShape::Add( thePrs, aSubShape, myDrawer );
621 StdPrs_WFShape::Add( thePrs, aSubShape, myDrawer );
624 else if( myFieldDimension == 2 ||
625 myFieldDimension == 3 ||
626 myFieldDimension == -1 )
628 myDrawer->ShadingAspect()->SetColor( aColor );
629 StdPrs_ShadedShape::Add( thePrs, aSubShape, myDrawer );
636 void GEOM_AISShape::drawName( const Handle(Prs3d_Presentation)& thePrs )
638 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup( thePrs );
640 gp_Ax3 anAx3 = GEOMUtils::GetPosition(myshape);
641 gp_Pnt aCenter = anAx3.Location();
643 Graphic3d_Vertex aVertex( aCenter.X(), aCenter.Y(), aCenter.Z() );
645 Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
646 anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
647 anAspectText3d->SetColor( myLabelColor );
648 aGroup->SetPrimitivesAspect( anAspectText3d );
650 const char* aName = getIO()->getName();
651 aGroup->Text( TCollection_ExtendedString( aName ), aVertex, 16 );
654 Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
657 theCenter.SetCoord( 0,0,0 );
658 Standard_Integer aNbPoints = 0;
660 if ( theShape.ShapeType() == TopAbs_EDGE )
663 Handle(Geom_Curve) curve = BRep_Tool::Curve( TopoDS::Edge( theShape ), f, l );
664 if ( !curve.IsNull() )
666 theCenter = curve->Value( 0.5 * ( f + l ));
670 else if ( theShape.ShapeType() == TopAbs_FACE )
672 BRepAdaptor_Surface surface( TopoDS::Face( theShape ));
673 theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
674 0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));
678 if ( aNbPoints == 0 )
680 TopExp_Explorer anExp;
681 for( anExp.Init( theShape, TopAbs_VERTEX ); anExp.More(); anExp.Next() )
683 TopoDS_Vertex aVertex = TopoDS::Vertex( anExp.Current() );
684 if( !aVertex.IsNull() )
686 gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
687 theCenter.ChangeCoord() += aPnt.XYZ();
694 theCenter.ChangeCoord() /= (Standard_Real) aNbPoints;