ShHealOper_ShapeProcess::ShHealOper_ShapeProcess ( ) : myOperations(TCollection_AsciiString("ShHealing").ToCString(), TCollection_AsciiString("ShapeProcess").ToCString()) { //myResource = new Resource_Manager("ShHealing"); myPrefix = "ShapeProcess"; mySaveHistoryMode = Standard_False; myLevel = TopAbs_FACE; myDone = Standard_False; }
//======================================================================= //function : ShapeProcess //purpose : //======================================================================= Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI, const TopoDS_Shape& theOriginalShape, TopoDS_Shape& theOutShape) const { Handle(TColStd_HArray1OfExtendedString) anOperators = theHI->GetOperators(); Handle(TColStd_HArray1OfExtendedString) aParams = theHI->GetParameters(); Handle(TColStd_HArray1OfExtendedString) aValues = theHI->GetValues(); if (anOperators.IsNull() || anOperators->Length() <= 0) return Standard_False; Standard_Integer nbParams = 0, nbValues = 0; if (!aParams.IsNull()) { nbParams = aParams->Length(); } if (!aValues.IsNull()) { nbValues = aValues->Length(); } if (nbParams != nbValues) return Standard_False; ShHealOper_ShapeProcess aHealer; TColStd_SequenceOfAsciiString anOperatorsAS, aParamsAS, aValuesAS; int i; for (i = 1; i <= anOperators->Length(); i++) anOperatorsAS.Append(TCollection_AsciiString(anOperators->Value(i))); aHealer.SetOperators(anOperatorsAS); for (i = 1; i <= nbParams; i++) { aHealer.SetParameter(TCollection_AsciiString(aParams->Value(i)), TCollection_AsciiString(aValues->Value(i))); } aHealer.Perform(theOriginalShape, theOutShape); if (!aHealer.isDone()) raiseNotDoneExeption( ShHealOper_NotError ); return Standard_True; }
void CAngleParamsVerticesPage::OnBnClickedVertex3Btn() { myAISContext->LocalContext()->InitSelected(); if (!myAISContext->LocalContext()->MoreSelected()) { AfxMessageBox (_T ("Choose the vertex and press the button again"), MB_ICONINFORMATION | MB_OK); return; } myThirdVertex = TopoDS::Vertex (myAISContext->LocalContext()->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); //Build dimension here TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge (myFirstVertex, mySecondVertex); TopoDS_Edge anEdge23 = BRepBuilderAPI_MakeEdge (mySecondVertex, myThirdVertex); CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); gp_Pnt aP1 = BRep_Tool::Pnt (myFirstVertex), aP2 = BRep_Tool::Pnt (mySecondVertex), aP3 = BRep_Tool::Pnt (myThirdVertex); GC_MakePlane aPlaneBuilder (aP1,aP2,aP3); Handle(Geom_Plane) aPlane = aPlaneBuilder.Value(); Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (aP1,aP2,aP3); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); anAspect->MakeText3d (aDimDlg->GetTextType()); anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight()); anAspect->MakeTextShaded (aDimDlg->IsText3dShaded()); anAspect->SetCommonColor (aDimDlg->GetDimensionColor()); anAspect->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); if (aDimDlg->IsUnitsDisplayed()) { anAngleDim->SetDisplayUnits (aDimDlg->GetUnits()); if ((anAngleDim->GetDisplayUnits().IsEqual (TCollection_AsciiString ("deg")))) { // No units - for degree is special symbol that is enabled by default anAspect->MakeUnitsDisplayed (Standard_False); } else // radians - no special symbol { anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No); } } anAngleDim->SetDimensionAspect (anAspect); myAISContext->CloseAllContexts(); myAISContext->Display (anAngleDim); myAISContext->OpenLocalContext(); myAISContext->ActivateStandardMode (TopAbs_VERTEX); }
void CLengthParamsEdgesPage::OnBnClickedEdge2Btn() { myAISContext->LocalContext()->InitSelected(); if (!myAISContext->LocalContext()->MoreSelected()) { AfxMessageBox (_T("Choose the edge and press the button again"), MB_ICONINFORMATION | MB_OK); return; } // Workaround for AIS_LocalContext::SelectedShape() mySecondEdge = TopoDS::Edge (CDimensionDlg::SelectedShape()); //mySecondEdge = TopoDS::Edge (myAISContext->LocalContext()->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); // Build plane through three points BRepAdaptor_Curve aCurve1 (myFirstEdge); BRepAdaptor_Curve aCurve2 (mySecondEdge); gp_Pnt aP1=aCurve1.Value (0.1); gp_Pnt aP2=aCurve1.Value (0.9); gp_Pnt aP3=aCurve2.Value (0.5); GC_MakePlane aMkPlane (aP1,aP2,aP3); Handle(Geom_Plane) aPlane = aMkPlane.Value(); CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); myAISContext->CloseAllContexts(); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); anAspect->MakeText3d (aDimDlg->GetTextType()); anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight()); anAspect->MakeTextShaded (aDimDlg->IsText3dShaded()); anAspect->SetCommonColor (aDimDlg->GetDimensionColor()); anAspect->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); if (myIsAngleDimension) { // Build an angle dimension between two non-parallel edges Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstEdge, mySecondEdge); anAngleDim->SetDimensionAspect (anAspect); anAngleDim->DimensionAspect()->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); if (aDimDlg->IsUnitsDisplayed()) { anAngleDim->SetDisplayUnits (aDimDlg->GetUnits ()); if ((anAngleDim->GetDisplayUnits().IsEqual (TCollection_AsciiString ("deg")))) { anAngleDim->DimensionAspect()->MakeUnitsDisplayed (Standard_False); } else { anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No); } } anAngleDim->SetFlyout (aDimDlg->GetFlyout()); myAISContext->Display (anAngleDim); } else { Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstEdge, mySecondEdge, aPlane->Pln()); aLenDim->SetDimensionAspect (anAspect); aLenDim->SetFlyout (aDimDlg->GetFlyout()); if (aDimDlg->IsUnitsDisplayed()) { aLenDim->SetDisplayUnits (aDimDlg->GetUnits()); } myAISContext->Display (aLenDim); } myAISContext->OpenLocalContext(); myAISContext->ActivateStandardMode (TopAbs_EDGE); }
//======================================================================= //function : Execute //purpose : //======================================================================= Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const { if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_IVector aPI (aFunction); Standard_Integer aType = aFunction->GetType(); if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT && aType != VECTOR_TANGENT_CURVE_PAR && aType != VECTOR_REVERSE) return 0; TopoDS_Shape aShape; if (aType == VECTOR_DX_DY_DZ) { gp_Pnt P1 = gp::Origin(); gp_Pnt P2 (aPI.GetDX(), aPI.GetDY(), aPI.GetDZ()); if (P1.Distance(P2) < Precision::Confusion()) { TCollection_AsciiString aMsg ("Can not build vector with length, less than "); aMsg += TCollection_AsciiString(Precision::Confusion()); Standard_ConstructionError::Raise(aMsg.ToCString()); } aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); } else if (aType == VECTOR_TWO_PNT) { Handle(GEOM_Function) aRefPnt1 = aPI.GetPoint1(); Handle(GEOM_Function) aRefPnt2 = aPI.GetPoint2(); TopoDS_Shape aShape1 = aRefPnt1->GetValue(); TopoDS_Shape aShape2 = aRefPnt2->GetValue(); if (aShape1.ShapeType() != TopAbs_VERTEX || aShape2.ShapeType() != TopAbs_VERTEX) return 0; if (aShape1.IsSame(aShape2)) { Standard_ConstructionError::Raise("The end points must be different"); } TopoDS_Vertex V1 = TopoDS::Vertex(aShape1); TopoDS_Vertex V2 = TopoDS::Vertex(aShape2); gp_Pnt P1 = BRep_Tool::Pnt(V1); gp_Pnt P2 = BRep_Tool::Pnt(V2); if (P1.Distance(P2) < Precision::Confusion()) { Standard_ConstructionError::Raise("The end points are too close"); } aShape = BRepBuilderAPI_MakeEdge(V1, V2).Shape(); } else if (aType == VECTOR_TANGENT_CURVE_PAR) { Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); TopoDS_Shape aRefShape = aRefCurve->GetValue(); if (aRefShape.ShapeType() != TopAbs_EDGE) { Standard_TypeMismatch::Raise ("Tangent On Curve creation aborted : curve shape is not an edge"); } Standard_Real aFParam =0., aLParam =0., aParam =0.; Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFParam, aLParam); if(aCurve.IsNull()) { Standard_TypeMismatch::Raise ("Tangent On Curve creation aborted : curve is null"); } aParam = aFParam + (aLParam - aFParam) * aPI.GetParameter(); gp_Pnt aPoint1,aPoint2; gp_Vec aVec; aCurve->D1(aParam,aPoint1,aVec); if(aVec.Magnitude() < gp::Resolution()) Standard_TypeMismatch::Raise ("Tangent On Curve creation aborted : invalid value of tangent"); aPoint2.SetXYZ(aPoint1.XYZ() + aVec.XYZ()); BRepBuilderAPI_MakeEdge aBuilder(aPoint1,aPoint2); if(aBuilder.IsDone()) aShape = aBuilder.Shape(); } else if (aType == VECTOR_REVERSE) { Handle(GEOM_Function) aRefVec = aPI.GetCurve(); TopoDS_Shape aRefShape = aRefVec->GetValue(); if (aRefShape.ShapeType() != TopAbs_EDGE) { Standard_TypeMismatch::Raise ("Reversed vector creation aborted : vector shape is not an edge"); } TopoDS_Edge anE = TopoDS::Edge(aRefShape); TopoDS_Vertex V1, V2; TopExp::Vertices(anE, V1, V2, Standard_True); aShape = BRepBuilderAPI_MakeEdge(V2, V1).Shape(); } if (aShape.IsNull()) return 0; aFunction->SetValue(aShape); log.SetTouched(Label()); return 1; }
static TCollection_AsciiString Comment(Standard_Real Step, Standard_Integer Upper, Standard_Integer DegMin, Standard_Integer DegMax, Standard_Integer Indicator, Standard_Real Tol) { TCollection_AsciiString aText; aText = ( "/////////////////////////////////////////////////////////////////" EOL "// Approximation of surface." EOL "// Building a BSpline surface which approximates a set of points." EOL "/////////////////////////////////////////////////////////////////" EOL EOL "// creating a set of points:" EOL ); aText += "Standard_Real Step = "; aText += TCollection_AsciiString(Step); aText += ";" EOL; aText += "Standard_Integer Upper = "; aText += TCollection_AsciiString(Upper); aText += ";" EOL EOL; aText += ( " //a set of X and Y coordinates:" EOL " Standard_Real aXStep = Step , aYStep = Step ;" EOL " Standard_Real aX0 = -300, aY0 = -200;" EOL " //Z coordinates:" EOL " TColStd_Array2OfReal aZPoints( 1, Upper , 1, Upper );" EOL EOL "// initializing array of Z coordinates:" EOL "// aZPoints(1,1) = -2;" EOL "// aZPoints(1,2) = 3;" EOL "// ..." EOL EOL "//creating a approximate BSpline surface:" EOL ); aText += "Parameters of surface:" EOL ; aText += "DegMin = "; aText += TCollection_AsciiString(DegMin); aText += ";" EOL; aText += "DegMax = "; aText += TCollection_AsciiString(DegMax); aText += ";" EOL; aText += "Continuity = " ; if( Indicator == 2 ) aText += "GeomAbs_C1"; if( Indicator == 3 ) aText += "GeomAbs_C2"; if( Indicator == 4 ) aText += "GeomAbs_C3"; aText += ";" EOL; aText += "Tolerance = "; aText += TCollection_AsciiString(Tol/SCALE); aText += ";" EOL EOL ; aText += ( "GeomAPI_PointsToBSplineSurface aPTBS;" EOL "aPTBS.Init(aZPoints,aX0,aXStep,aY0,aYStep," EOL " DegMin,DegMax,Continuity,Tolerance);" EOL "Handle(Geom_BSplineSurface) aSurface = aPTBS.Surface();" EOL EOL EOL ); return aText; }
//! Conversion of the QString \p str to an OCC TCollection_AsciiString TCollection_AsciiString toAsciiString(const QString& str) { return TCollection_AsciiString(toCString(str)); }
void Tesselate_Presentation::tesselateShape(const TopoDS_Shape& aShape) { // setResultTitle("Tesselate shape"); TCollection_AsciiString aText = ( "/////////////////////////////////////////////////////////////////" EOL "// Tesselate shape." EOL "/////////////////////////////////////////////////////////////////" EOL EOL ) ; Standard_Real aDeflection = DATA[myIndex][0]; Standard_Integer aNumOfFace = (Standard_Integer)DATA[myIndex][1]; Standard_Integer aNumOfEdge = (Standard_Integer)DATA[myIndex][2]; aText += "Standard_Real aDeflection;" EOL "// aDeflection = ... ;" EOL EOL "// removes all the triangulations of the faces ," EOL "//and all the polygons on the triangulations of the edges:" EOL "BRepTools::Clean(aShape);" EOL EOL "// adds a triangulation of the shape aShape with the deflection aDeflection:" EOL "BRepMesh::Mesh(aShape,aDeflection);" EOL EOL "TopExp_Explorer aExpFace,aExpEdge;" EOL "for(aExpFace.Init(aShape,TopAbs_FACE);aExpFace.More();aExpFace.Next())" EOL "{ " EOL " TopoDS_Face aFace = TopoDS::Face(aExpFace.Current());" EOL " TopLoc_Location aLocation;" EOL EOL " // takes the triangulation of the face aFace:" EOL " Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation);" EOL EOL " if(!aTr.IsNull()) // if this triangulation is not NULL" EOL " { " EOL " // takes the array of nodes for this triangulation:" EOL " const TColgp_Array1OfPnt& aNodes = aTr->Nodes();" EOL " // takes the array of triangles for this triangulation:" EOL " const Poly_Array1OfTriangle& triangles = aTr->Triangles();" EOL EOL " // create array of node points in absolute coordinate system" EOL " TColgp_Array1OfPnt aPoints(1, aNodes.Length());" EOL " for( Standard_Integer i = 1; i < aNodes.Length()+1; i++)" EOL " aPoints(i) = aNodes(i).Transformed(aLocation);" EOL EOL " // Takes the node points of each triangle of this triangulation." EOL " // takes a number of triangles:" EOL " Standard_Integer nnn = aTr->NbTriangles();" EOL " Standard_Integer nt,n1,n2,n3;" EOL " for( nt = 1 ; nt < nnn+1 ; nt++)" EOL " {" EOL " // takes the node indices of each triangle in n1,n2,n3:" EOL " triangles(nt).Get(n1,n2,n3);" EOL " // takes the node points:" EOL " gp_Pnt aPnt1 = aPoints(n1);" EOL " gp_Pnt aPnt2 = aPoints(n2);" EOL " gp_Pnt aPnt3 = aPoints(n3);" EOL " } " EOL EOL " // Takes the polygon associated to an edge." EOL " aExpEdge.Init(aFace,TopAbs_EDGE);" EOL " TopoDS_Edge aEdge;" EOL " // for example,working with the first edge:" EOL " if(aExpEdge.More())" EOL " aEdge = TopoDS::Edge(aExpEdge.Current());" EOL EOL " if(!aEdge.IsNull()) // if this edge is not NULL" EOL " {" EOL " // takes the polygon associated to the edge aEdge:" EOL " Handle_Poly_PolygonOnTriangulation aPol = " EOL " BRep_Tool::PolygonOnTriangulation(aEdge,aTr,aEdge.Location());" EOL EOL " if(!aPol.IsNull()) // if this polygon is not NULL" EOL " // takes the array of nodes for this polygon" EOL " // (indexes in the array of nodes for triangulation of theFace):" EOL " const TColStd_Array1OfInteger& aNodesOfPol = aPol->Nodes();" EOL " }" EOL " }" EOL "}" EOL EOL "//==================================================" EOL EOL ; aText += " Result with deflection = "; aText += TCollection_AsciiString(aDeflection); aText += " :" EOL; GetDocument()->PocessTextInDialog("Compute the triangulation on a shape", aText); // setResultText(aText.ToCString()); //========================================================================== BRepTools::Clean(aShape); BRepMesh::Mesh(aShape,aDeflection); BRep_Builder aBuilder,aBuild1,aBuild2; TopoDS_Compound aCompound,aComp1,aComp2; aBuilder.MakeCompound(aCompound); aBuild1.MakeCompound(aComp1); aBuild2.MakeCompound(aComp2); TopTools_SequenceOfShape aVertices; Standard_Integer aCount = 0; Standard_Integer aNumOfNodes = 0; Standard_Integer aNumOfTriangles = 0; Handle_AIS_InteractiveObject aShowEdge,aShowFace,aShowShape; TopExp_Explorer aExpFace,aExpEdge; for(aExpFace.Init(aShape,TopAbs_FACE);aExpFace.More();aExpFace.Next()) { aCount++; TopoDS_Face aFace = TopoDS::Face(aExpFace.Current()); TopLoc_Location aLocation; Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); if(!aTr.IsNull()) { const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); aNumOfNodes += aTr->NbNodes(); Standard_Integer aLower = aNodes.Lower(); Standard_Integer anUpper = aNodes.Upper(); const Poly_Array1OfTriangle& triangles = aTr->Triangles(); aNumOfTriangles += aTr->NbTriangles(); if(aCount == aNumOfFace) { Standard_Integer aNbOfNodesOfFace = aTr->NbNodes(); Standard_Integer aNbOfTrianglesOfFace = aTr->NbTriangles(); aExpEdge.Init(aFace,TopAbs_EDGE); TopoDS_Edge aEdge; for( Standard_Integer i = 0; aExpEdge.More() && i < aNumOfEdge ; aExpEdge.Next(), i++) aEdge = TopoDS::Edge(aExpEdge.Current()); if(!aEdge.IsNull()) { Handle_Poly_PolygonOnTriangulation aPol = BRep_Tool::PolygonOnTriangulation(aEdge,aTr,aEdge.Location()); if(!aPol.IsNull()) { const TColStd_Array1OfInteger& aNodesOfPol = aPol->Nodes(); Standard_Integer aNbOfNodesOfEdge = aPol->NbNodes(); aText += "Number of nodes of the edge = "; aText += TCollection_AsciiString(aNbOfNodesOfEdge) + EOL; aText += "Number of nodes of the face = "; aText += TCollection_AsciiString(aNbOfNodesOfFace) + EOL; aText += "Number of triangles of the face = "; aText += TCollection_AsciiString(aNbOfTrianglesOfFace) + EOL; GetDocument()->PocessTextInDialog("Compute the triangulation on a shape", aText); // setResultText(aText.ToCString()); Standard_Integer aLower = aNodesOfPol.Lower(), anUpper = aNodesOfPol.Upper(); for( int i = aLower; i < anUpper ; i++) { gp_Pnt aPnt1 = aNodes(aNodesOfPol(i)).Transformed(aLocation); gp_Pnt aPnt2 = aNodes(aNodesOfPol(i+1)).Transformed(aLocation); TopoDS_Vertex aVertex1 = BRepBuilderAPI_MakeVertex (aPnt1); TopoDS_Vertex aVertex2 = BRepBuilderAPI_MakeVertex (aPnt2); if(!aVertex1.IsNull() && !aVertex2.IsNull() && // if vertices are "alive" !BRep_Tool::Pnt(aVertex1).IsEqual( BRep_Tool::Pnt(aVertex2),Precision::Confusion())) // if they are different { aEdge = BRepBuilderAPI_MakeEdge (aVertex1,aVertex2); aBuild2.Add(aComp2,aVertex1); if(!aEdge.IsNull()) aBuild2.Add(aComp2,aEdge); if(i == anUpper-1) aBuild2.Add(aComp2,aVertex2); } } getAISContext()->EraseAll(); aShowShape = drawShape(aShape); if(WAIT_A_SECOND) return; aShowEdge = drawShape(aComp2,Quantity_NOC_GREEN); getAISContext()->Erase(aShowShape); if(WAIT_A_SECOND) return; } } } TopTools_DataMapOfIntegerShape aEdges; TopTools_SequenceOfShape aVertices; for( Standard_Integer i = 1; i < aNodes.Length()+1; i++) { gp_Pnt aPnt = aNodes(i).Transformed(aLocation); TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex(aPnt); if(!aVertex.IsNull()) { aBuilder.Add(aCompound,aVertex); if(aCount == aNumOfFace ) aBuild1.Add(aComp1,aVertex); aVertices.Append(aVertex); } } Standard_Integer nnn = aTr->NbTriangles(); Standard_Integer nt,n1,n2,n3; for( nt = 1 ; nt < nnn+1 ; nt++) { triangles(nt).Get(n1,n2,n3); Standard_Integer key[3]; TopoDS_Vertex aV1,aV2; key[0] = _key(n1, n2); if(!aEdges.IsBound(key[0])) { aV1 = TopoDS::Vertex(aVertices(n1)); aV2 = TopoDS::Vertex(aVertices(n2)); if(!aV1.IsNull() && !aV2.IsNull() && !BRep_Tool::Pnt(aV1).IsEqual(BRep_Tool::Pnt(aV2),Precision::Confusion())) { TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge (aV1,aV2); if(!aEdge.IsNull()) { aEdges.Bind(key[0], aEdge); aBuilder.Add(aCompound,aEdges(key[0])); if(aCount == aNumOfFace) aBuild1.Add(aComp1,aEdges(key[0])); } } } key[1] = _key(n2,n3); if(!aEdges.IsBound(key[1])) { aV1 = TopoDS::Vertex(aVertices(n2)); aV2 = TopoDS::Vertex(aVertices(n3)); if(!aV1.IsNull() && !aV2.IsNull() && !BRep_Tool::Pnt(aV1).IsEqual(BRep_Tool::Pnt(aV2),Precision::Confusion())) { TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge (aV1,aV2); if(!aEdge.IsNull()) { aEdges.Bind(key[1],aEdge); aBuilder.Add(aCompound,aEdges(key[1])); if(aCount == aNumOfFace) aBuild1.Add(aComp1,aEdges(key[1])); } } } key[2] = _key(n3,n1); if(!aEdges.IsBound(key[2])) { aV1 = TopoDS::Vertex(aVertices(n3)); aV2 = TopoDS::Vertex(aVertices(n1)); if(!aV1.IsNull() && !aV2.IsNull() && !BRep_Tool::Pnt(aV1).IsEqual(BRep_Tool::Pnt(aV2),Precision::Confusion())) { TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge (aV1,aV2); if(!aEdge.IsNull()) { aEdges.Bind(key[2],aEdge); aBuilder.Add(aCompound,aEdges(key[2])); if(aCount == aNumOfFace) aBuild1.Add(aComp1,aEdges(key[2])); } } } } if(aCount == aNumOfFace) { aShowFace = drawShape(aComp1,Quantity_NOC_GREEN); getAISContext()->Erase(aShowEdge); } } else { aText += "Can't compute a triangulation on face "; aText += TCollection_AsciiString(aCount) + EOL; GetDocument()->PocessTextInDialog("Compute the triangulation on a shape", aText); // setResultText(aText.ToCString()); } } aText += "Number of nodes of the shape = "; aText += TCollection_AsciiString(aNumOfNodes) + EOL; aText += "Number of triangles of the shape = "; aText += TCollection_AsciiString(aNumOfTriangles) + EOL EOL; GetDocument()->PocessTextInDialog("Compute the triangulation on a shape", aText); // setResultText(aText.ToCString()); if(WAIT_A_SECOND) return; drawShape(aCompound,Quantity_NOC_GREEN); getAISContext()->Erase(aShowFace); }
void CParamsFacesPage::OnBnClickedFacesbtn2() { // Check if face is selected myAISContext->LocalContext()->InitSelected(); if (!myAISContext->LocalContext()->MoreSelected()) { AfxMessageBox(_T("Choose the face and press the button again"), MB_ICONINFORMATION | MB_OK); return; } // Workaround for AIS_LocalContext::SelectedShape() mySecondFace = TopoDS::Face (CDimensionDlg::SelectedShape()); //mySecondFace = TopoDS::Face (myAISContext->LocalContext()->SelectedShape()); myAISContext->LocalContext()->ClearSelected(); CDimensionDlg *aDimDlg = (CDimensionDlg*)(GetParentOwner()); myAISContext->CloseAllContexts(); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); anAspect->MakeText3d (aDimDlg->GetTextType()); anAspect->TextAspect()->SetHeight (aDimDlg->GetFontHeight()); anAspect->MakeTextShaded (aDimDlg->IsText3dShaded()); anAspect->SetCommonColor (aDimDlg->GetDimensionColor()); anAspect->MakeUnitsDisplayed (aDimDlg->IsUnitsDisplayed()); if (myIsAngleDimension) { // Build an angle dimension between two non-parallel edges Handle(AIS_AngleDimension) anAngleDim = new AIS_AngleDimension (myFirstFace, mySecondFace); anAngleDim->SetDimensionAspect (anAspect); if (aDimDlg->IsUnitsDisplayed()) { anAngleDim->SetDisplayUnits (aDimDlg->GetUnits ()); if ((anAngleDim->GetDisplayUnits().IsEqual (TCollection_AsciiString ("deg")))) { anAngleDim->DimensionAspect()->MakeUnitsDisplayed (Standard_False); } else { anAngleDim->SetDisplaySpecialSymbol (AIS_DSS_No); } } anAngleDim->SetFlyout (aDimDlg->GetFlyout()); myAISContext->Display (anAngleDim); } else { Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (myFirstFace, mySecondFace); aLenDim->SetDimensionAspect (anAspect); if (aLenDim->DimensionAspect()->IsUnitsDisplayed()) { aLenDim->SetFlyout (aDimDlg->GetFlyout()); aLenDim->SetDisplayUnits (aDimDlg->GetUnits()); } myAISContext->Display (aLenDim); } myAISContext->OpenLocalContext(); myAISContext->ActivateStandardMode (TopAbs_FACE); }