Hi nnikbin.
I tried the Following as given below.
My Solid has 7 Faces. Your routine Ptr<Vector3D> NormalVectorToFace(Ptr<Point3D>& point, Ptr<BRepFace>& face),
worked for two out of 7 faces; Face 0 and 3, which are planer faces, and gave the following printouts;
IFace = 0, normalVector x = 0.000e+000, y = 0.000e+000, z = 1.000e+000
IFace = 3, normalVector x = 0.000e+000, y = 0.000e+000, z = - 1.000e+000.
But it did not work for the other faces; Face 1, 2, 4, 5 and 6. which are obtained by lofting the profiles with the planer faces Face 0 and 3.
I would like a method which works for all the faces.
Thanks,
Thurai
///////////////////////////////////////////////
Ptr<Vector3D> NormalVectorToFace(Ptr<Point3D>& point, Ptr<BRepFace>& face);
for(IFace = 0; IFace <= longeron.ComponentFaceCount - 1; IFace++)
{//IFace
ComponentFace[IFace] = ComponentFaces->item(IFace);
Ptr<Point3D> Point = Point3D::create(0,0,0);
normalVector[IFace] = NormalVectorToFace(Point, ComponentFace[IFace]);
fprintf(Com.out," \n\n IFace = %4d, normalVectorPoint[JPhi][0] x = %10.3e, y = %10.3e, z = %10.3e \n ",
IFace, longeron.normalVector[JPhi][IFace]->x(), longeron.normalVector[JPhi][IFace]->y(), longeron.normalVector[JPhi][IFace]->z());
}//IFace
Ptr<Vector3D> NormalVectorToFace(Ptr<Point3D>& point, Ptr<BRepFace>& face)
{//NormalVectorToFace(
Ptr<Component> component = face->body()->parentComponent();
Ptr<ObjectCollection> objectCollection = ObjectCollection::create();
objectCollection->add(face);
Ptr<OffsetFeatureInput> offsetInput = component->features()->offsetFeatures()->createInput(objectCollection, ValueInput::createByReal(0), FeatureOperations::NewBodyFeatureOperation);
Ptr<OffsetFeature> offsetFeature = component->features()->offsetFeatures()->add(offsetInput);
Ptr<BRepFace> offsetFace = offsetFeature->faces()->item(0);
Ptr<MeasureManager> measureManager = Application::get()->measureManager();
Ptr<MeasureResults> measureResult = measureManager->measureMinimumDistance(point, offsetFace);
Ptr<Vector3D> vectorToFace = measureResult->positionTwo()->vectorTo(measureResult->positionOne());
Ptr<Vector3D> normalAtFace;
face->geometry()->evaluator()->getNormalAtPoint(measureResult->positionOne(), normalAtFace);
Ptr<Vector3D> crossProduct = normalAtFace->crossProduct(vectorToFace);
offsetFace->body()->deleteMe();
if (crossProduct->length() < 0.000001)
{
vectorToFace->normalize();
return vectorToFace;
}
else
{
return nullptr;
}
}//end NormalVectorToFace()