FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
BinaryFieldOperatorObject.hpp
1#ifndef __FISH_BINARYOPERATOROBJECT_HPP
2#define __FISH_BINARYOPERATOROBJECT_HPP
3
4#include "FieldOperatorObject.hpp"
5#include <baseop/EvalGrid.hpp>
6
7#include <fish/fiber/field/BinaryOperator.hpp>
8
9namespace Wizt
10{
11
12 using Fiber::Field;
13
14
18template <class TheBinaryOperator,
19 class NamingOperator,
20 class PrimaryValueType,
21 class SecondaryValueType = PrimaryValueType,
22 class ResultValueType = PrimaryValueType>
23
25{
27 typedef ResultValueType result_t;
28
31
34
35 TypedSlot<Field> SecondaryField;
36
37 VOutput<Field> ResultField;
38
39 BinaryFieldOperatorObject(const string&name, int p = 0, const RefPtr<VCreationPreferences>&VP = NullPtr() )
40 : FieldOperatorObject(name, "leftField", p, VP)
41 , SecondaryField(this, "right")
42 , ResultField(self(), "result")
43 {}
44
46 {}
47
49 Fiber::Representation&FieldRep//, Fiber::Representation&FieldIDSource
50 ) override
51 {
52 using namespace Fiber;
54
57
59 if (!PrimaryGrid)
60 return false;
61
62 RefPtr<Slice> mySlice = PrimaryFS.getSlice();
63 if (!mySlice)
64 return false;
65
68
70 if (!SecondaryGrid)
71 return false;
72
74 bool StoreResultInGrid = true;
75
76 Grid&SourceGrid = *SecondaryGrid;
77 Slice&DestSlice = *mySlice;
79
80 string HelperDestGridName = "alpha";
81
83
86 SourceGrid, SelectedFieldName,
88
89
92 ResultValueType>
93
95
97 {
98 string NewFieldname = NamingOperator::ResultName(PrimaryFS(), SecondaryFS() );
99 RefPtr<FieldID> NewFieldID = FieldRep.createSharedFieldID(FieldIDSource, NewFieldname);
100
101 FieldRep[ NewFieldID ] = ResultField;
102 }
103
104 return true;
105 }
106
107
108 bool postFieldOperation(VRequest&Context, int newlyCreatedFields) override
109 {
110 if (newlyCreatedFields>0)
111 {
114
117
118 string NewFieldname = NamingOperator::ResultName(PrimaryFS(), SecondaryFS() );
119
122
124 OutputFieldSelection.selectTypedField<ResultValueType>( NewFieldname );
125
126 ResultField << Context << OutputFieldSelection;
127
128 return setStatusInfo(Context, "Created new field " + NewFieldname);
129 }
130 else
131 return setStatusError(Context, "No computation performed on " + Fieldname(Context), false );
132 }
133
134static string createChildname(const string&parent_name)
135 {
136 return NamingOperator::createChildname(parent_name);
137 }
138};
139
140
141} // namespace Wizt
142
143
144#endif // __FISH_BINARYOPERATOROBJECT_HPP
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
An abstract selection of fields, that is given by names of fields and possible types for each field.
Definition FieldSelection.hpp:23
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
Information per time slice, mainly a set of Grid objects that are accessed via GridID objects.
Definition Slice.hpp:36
Base class for objects that operate on Field objects and create new fields.
Definition FieldOperatorObject.hpp:44
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
ComputationalField< FieldOperator > * newComputationalField(const FieldOperator &FO, const RefPtr< Field > &InputField, const MemCore::RefPtr< MemCore::Cache > &theCache=MemCore::Cache::MemCache())
A convenience template function to construct a computational field (class ComputationalField) from an...
Definition ComputationalField.hpp:266
RefPtr< Field > EvalFieldOnRepresentation(Representation &DstRep, const RefPtr< Skeleton > &DestVertices, Grid &SourceGrid, const string &fieldname, Slice &DestGridSlice, const string &HelperDestGridName, bool StoreResult)
Evaluate a Field given on some source Grid on a specific Representation.
Definition EvalGrid.cpp:326
std::nullptr_t NullPtr
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
Definition Lytica.hpp:7
Implementing a binary operation on two fields with on-demand computation per fragment and discarding ...
Definition BinaryOperator.hpp:36
Template class for binary operations on Fields.
Definition BinaryFieldOperatorObject.hpp:25
META::LIST< value_type > InputTypes
For usage with a TypedFieldInputCreator<>
Definition BinaryFieldOperatorObject.hpp:30
bool FieldOperation(VRequest &Context, Fiber::Field &InputField, Fiber::Representation &FieldRep) override
The operation to be performed on the given field, to be overloaded in a subclass.
Definition BinaryFieldOperatorObject.hpp:48
Fiber::GridInspector< Fiber::BundleProperty::Anything > GridInspector
Constraints on the grid type.
Definition BinaryFieldOperatorObject.hpp:33
string Fieldname(const RefPtr< ValuePool > &VP) const
Get the name of the selected field.
Definition FishField.cpp:250
bool setStatusInfo(const RefPtr< ValuePool > &Context, const string &what) const
bool setStatusError(const RefPtr< ValuePool > &Context, const string &what, bool AnnouncePublic=false) const